From patchwork Tue Jul 14 20:56:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chrisanthus, Anitha" X-Patchwork-Id: 11663577 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 98AC160D for ; Tue, 14 Jul 2020 20:58:52 +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 80F83206D9 for ; Tue, 14 Jul 2020 20:58:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80F83206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC8B06E9A7; Tue, 14 Jul 2020 20:58:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id A798A6E88A; Tue, 14 Jul 2020 20:58:21 +0000 (UTC) IronPort-SDR: RGC4se/sP2aT0+cE0e50D3h9r+L5vXjyChJRe+zs1ArfPksM8vlEaQFW300tPncLmaNH1coqfj Px8Bed0BxRXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9682"; a="233883726" X-IronPort-AV: E=Sophos;i="5.75,352,1589266800"; d="scan'208";a="233883726" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 13:58:21 -0700 IronPort-SDR: Q7Hix19Lc4FSCjzxE3XoSFWLrg40QXYDbD8XN1KK4+ickGhbfBCymHT8/cFXWy3ieKfK0yg8Ab Waq8fWL3x++A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,352,1589266800"; d="scan'208";a="316504078" Received: from ahanamuk-mobl.amr.corp.intel.com (HELO achrisan-DESK2.amr.corp.intel.com) ([10.251.155.61]) by orsmga008.jf.intel.com with ESMTP; 14 Jul 2020 13:58:20 -0700 From: Anitha Chrisanthus To: dri-devel@lists.freedesktop.org, anitha.chrisanthus@intel.com, bob.j.paauwe@intel.com, edmund.j.dea@intel.com Subject: [PATCH v2 06/59] drm/kmb: Initial check-in for Mipi DSI Date: Tue, 14 Jul 2020 13:56:52 -0700 Message-Id: <1594760265-11618-7-git-send-email-anitha.chrisanthus@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594760265-11618-1-git-send-email-anitha.chrisanthus@intel.com> References: <1594760265-11618-1-git-send-email-anitha.chrisanthus@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@intel.com, intel-gfx@lists.freedesktop.org, rodrigo.vivi@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 | 94 +++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/kmb/kmb_dsi.h | 38 +++++++++++++++++ 4 files changed, 135 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 11f8d1f..aec8a5b 100644 --- a/drivers/gpu/drm/kmb/kmb_drv.c +++ b/drivers/gpu/drm/kmb/kmb_drv.c @@ -25,6 +25,7 @@ #include #include "kmb_crtc.h" #include "kmb_drv.h" +#include "kmb_dsi.h" #include "kmb_plane.h" #include "kmb_regs.h" @@ -63,6 +64,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..654fae8 --- /dev/null +++ b/drivers/gpu/drm/kmb/kmb_dsi.c @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright © 2019-2020 Intel Corporation + */ + +#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..9a6b0b7 --- /dev/null +++ b/drivers/gpu/drm/kmb/kmb_dsi.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * + * Copyright © 2019-2020 Intel Corporation + */ + +#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__ */