From patchwork Tue Jun 30 21:27:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chrisanthus, Anitha" X-Patchwork-Id: 11634887 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2279013B4 for ; Tue, 30 Jun 2020 21:29:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0ABDE2065D for ; Tue, 30 Jun 2020 21:29:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0ABDE2065D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8877B6E334; Tue, 30 Jun 2020 21:28:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB6DE6E2E5; Tue, 30 Jun 2020 21:28:36 +0000 (UTC) IronPort-SDR: HvPSqlA3gb1YLCshUfb2fkIilQR1+uN3T5zylGIDU5nP9vO8yLIIl3BvfJVnInFC9DQyfvV4fm rV1HJ1TMAm6Q== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="146386942" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="146386942" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 14:28:36 -0700 IronPort-SDR: MZtYoO7UZYC783HNSb5fkO2YU+2ldQOjrJI1CHdxORFoa6GIdM8325Wi56RJp6Riv+vqF8zYas tKKZbsbg9nlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="481066623" Received: from hdwiyono-mobl.amr.corp.intel.com (HELO achrisan-DESK2.amr.corp.intel.com) ([10.254.176.225]) by fmsmga006.fm.intel.com with ESMTP; 30 Jun 2020 14:28:36 -0700 From: Anitha Chrisanthus To: dri-devel@lists.freedesktop.org, anitha.chrisanthus@intel.com, bob.j.paauwe@intel.com, edmund.j.dea@intel.com Date: Tue, 30 Jun 2020 14:27:18 -0700 Message-Id: <1593552491-23698-7-git-send-email-anitha.chrisanthus@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593552491-23698-1-git-send-email-anitha.chrisanthus@intel.com> References: <1593552491-23698-1-git-send-email-anitha.chrisanthus@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 06/59] drm/kmb: Initial check-in for Mipi DSI X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Basic frame work for mipi encoder and connector. More hardware specific details will be added in the future commits. Signed-off-by: Anitha Chrisanthus Reviewed-by: Bob Paauwe --- drivers/gpu/drm/kmb/Makefile | 2 +- drivers/gpu/drm/kmb/kmb_drv.c | 2 + drivers/gpu/drm/kmb/kmb_dsi.c | 114 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/kmb/kmb_dsi.h | 58 +++++++++++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.c create mode 100644 drivers/gpu/drm/kmb/kmb_dsi.h diff --git a/drivers/gpu/drm/kmb/Makefile b/drivers/gpu/drm/kmb/Makefile index be9f19c..8102bc9 100644 --- a/drivers/gpu/drm/kmb/Makefile +++ b/drivers/gpu/drm/kmb/Makefile @@ -1,2 +1,2 @@ -kmb-display-y := kmb_crtc.o kmb_drv.o kmb_plane.o +kmb-display-y := kmb_crtc.o kmb_drv.o kmb_plane.o kmb_dsi.o obj-$(CONFIG_DRM_KMB_DISPLAY) += kmb-display.o diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c index ee4e3bd..24e7c2b 100644 --- a/drivers/gpu/drm/kmb/kmb_drv.c +++ b/drivers/gpu/drm/kmb/kmb_drv.c @@ -47,6 +47,7 @@ #include "kmb_regs.h" #include "kmb_crtc.h" #include "kmb_plane.h" +#include "kmb_dsi.h" static int kmb_load(struct drm_device *drm, unsigned long flags) { @@ -83,6 +84,7 @@ static int kmb_load(struct drm_device *drm, unsigned long flags) goto setup_fail; } + kmb_dsi_init(drm); ret = drm_irq_install(drm, platform_get_irq(pdev, 0)); if (ret < 0) { DRM_ERROR("failed to install IRQ handler\n"); diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c new file mode 100644 index 0000000..b5c57e1 --- /dev/null +++ b/drivers/gpu/drm/kmb/kmb_dsi.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright © 2019 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kmb_drv.h" +#include "kmb_dsi.h" + +static enum drm_mode_status +kmb_dsi_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode) +{ + return MODE_OK; +} + +static int kmb_dsi_get_modes(struct drm_connector *connector) +{ + struct drm_display_mode *mode; + struct kmb_connector *kmb_connector = to_kmb_connector(connector); + + mode = drm_mode_duplicate(connector->dev, kmb_connector->fixed_mode); + drm_mode_probed_add(connector, mode); + return 1; +} + +static void kmb_dsi_connector_destroy(struct drm_connector *connector) +{ + struct kmb_connector *kmb_connector = to_kmb_connector(connector); + + drm_connector_cleanup(connector); + kfree(kmb_connector); +} + +static void kmb_dsi_encoder_destroy(struct drm_encoder *encoder) +{ + struct kmb_dsi *kmb_dsi = to_kmb_dsi(encoder); + + drm_encoder_cleanup(encoder); + kfree(kmb_dsi); +} + +static const struct drm_encoder_funcs kmb_dsi_funcs = { + .destroy = kmb_dsi_encoder_destroy, +}; + +static const struct +drm_connector_helper_funcs kmb_dsi_connector_helper_funcs = { + .get_modes = kmb_dsi_get_modes, + .mode_valid = kmb_dsi_mode_valid, +}; + +static const struct drm_connector_funcs kmb_dsi_connector_funcs = { + .destroy = kmb_dsi_connector_destroy, + .fill_modes = drm_helper_probe_single_connector_modes, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, +}; + +void kmb_dsi_init(struct drm_device *dev) +{ + struct kmb_dsi *kmb_dsi; + struct drm_encoder *encoder; + struct kmb_connector *kmb_connector; + struct drm_connector *connector; + + kmb_dsi = kzalloc(sizeof(*kmb_dsi), GFP_KERNEL); + if (!kmb_dsi) + return; + + kmb_connector = kzalloc(sizeof(*kmb_connector), GFP_KERNEL); + if (!kmb_connector) { + kfree(kmb_dsi); + return; + } + + kmb_dsi->attached_connector = kmb_connector; + + connector = &kmb_connector->base; + encoder = &kmb_dsi->base; + drm_encoder_init(dev, encoder, &kmb_dsi_funcs, DRM_MODE_ENCODER_DSI, + "MIPI-DSI"); + drm_connector_init(dev, connector, &kmb_dsi_connector_funcs, + DRM_MODE_CONNECTOR_DSI); + drm_connector_helper_add(connector, &kmb_dsi_connector_helper_funcs); +} diff --git a/drivers/gpu/drm/kmb/kmb_dsi.h b/drivers/gpu/drm/kmb/kmb_dsi.h new file mode 100644 index 0000000..3829360 --- /dev/null +++ b/drivers/gpu/drm/kmb/kmb_dsi.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright © 2019 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ +#ifndef __KMB_DSI_H__ +#define __KMB_DSI_H__ + +#include +#include +#include +#include "kmb_drv.h" + +struct kmb_connector; + +struct kmb_dsi { + struct drm_encoder base; + struct kmb_connector *attached_connector; +}; + +struct kmb_dsi_host { + struct mipi_dsi_host base; + struct kmb_dsi *kmb_dsi; +}; + +struct kmb_connector { + struct drm_connector base; + struct drm_display_mode *fixed_mode; +}; + +void kmb_dsi_init(struct drm_device *dev); +void kmb_plane_destroy(struct drm_plane *plane); + +#define to_kmb_connector(x) container_of(x, struct kmb_connector, base) +#define to_kmb_host(x) container_of(x, struct kmb_dsi_host, base) +#define to_kmb_dsi(x) container_of(x, struct kmb_dsi, base) + +#endif /* __KMB_DSI_H__ */