From patchwork Sun Dec 12 18:14:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1817 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AD3F13F071 for ; Sun, 12 Dec 2021 19:14:49 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id q82-20020a627555000000b004a4f8cadb6fsf9162651pfc.20 for ; Sun, 12 Dec 2021 10:14:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639332888; cv=pass; d=google.com; s=arc-20160816; b=BgJ7WxySiYBzyTE6hAHNkZBuZJaiTGoeiIX9QlRkocf97SoyShyvo+mpIK650y8u34 lMkivDAjuFU40jG+2BYhk4uHhi+TQVJDK4OXkLM7ZL41D2olDyficH5Zr79/svoLw9nJ snF1e1Dg4yCREGoVi4IY6cemyNLuJ0QfbBCAPSn09ZxtpVK1FnoqoVIM6Tg0cnyBFKvA NeWiRp6tyv3j0xEa0+jY84XocM+UPO7hPdWc+7kAA/EVsHUHGdOoiLdlQmUemZMRua8D zp+INJLfk+qbWGQDW+i+IwbxlYn4EyGyWgBSR7bzRCThjiues49oc9td2TplT8usRbFZ oj1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=7ecpDNWVJ3iD6vkiYN9cY8e/Ck/Irr5R1b0pgC0T9m0=; b=bz9pte0p4Tvq6iJiIi8OyTq2KxQpf8ky2VtdZfnWZoMw6Fd+uTpvCy2hwl/JIjGKKU wu0yEcfSTY6ZGhm3Mi2McImv//qBviEJUjfCX7bCaqpjn1CiQis2GafObBjyAUKyjS8y A8thQiyhMyB6QVziojzVEUl4mqEjE9Ql2D5wunorG2Bn/t3zQnqlDu4Sp/w0RmZZ1pcy srN3/hx1xiCBQXBurzHZf6weLAZGqGCqWOfDO2YRzA7IPW3e4AaasA/6DRE5De1JtgmX SXsFax9Z0N9xi0pCXNUEpUlILDq7l1KWzpgmx0uRqZ3mESkW3xSeFroYpxHX5Dn71VPK HMJg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Z8von0bz; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=7ecpDNWVJ3iD6vkiYN9cY8e/Ck/Irr5R1b0pgC0T9m0=; b=GdgTg+stG55HsuYlqVOB3dbpOygCX/hNOdv8u4ZAfJI8FQUM4RXazhKncEZ+RP/cBr jVe0GveDhdiYaaXIPaEpSVlj/skMbsrpnu1ruqTg1gQOT/pCSjNV9cpEv+YMB0baRu2+ myqjczTCgCKdWael83/UnUBjqgazQbqKJmlh0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=7ecpDNWVJ3iD6vkiYN9cY8e/Ck/Irr5R1b0pgC0T9m0=; b=kdQCqAlb4JyYS+oDVSRDZUjzA0dg38SMyVIbKVuiu/6WMB/+kakXk2MAYK3F6jYM8H 9LTjqdZJopQWGjrPxC0lFGcg5qkL1BbGNJdZmCKvrsFOtoMIBfxq/aMDGQuyCAQ7qHeK 6jpMxnE4YFwDPX16B7bx7NwHsJWZCRnv4/3UiEr64LKIqrDuBryZsbaA3knRrEL+6fHj c/cRmxKDNPPAcM7Qwvura/BWtQDrUyu5XymmY8lAm99SmbqljEyOuItZZzfeLkesyKQ6 Ru6DhL+v0PnvmalHgBtdHzKUlMIyZCpSpLH4B55caxw5zD2myu8lWcD2vilMIX7W8omR 9JKQ== X-Gm-Message-State: AOAM531gsKLEjQuuf3CCckLhxIEBKaohonSdPY7QApkHruiVL6jFI4HM ybceHI8hOCrgumYDJjzaZoRnFWY3 X-Google-Smtp-Source: ABdhPJyX2/qZEDxGiApdVPHPhVRR4VzJPU9hiauGNx1lP2ypsBBjlPOsdgYdtrFeF0zHVt3S+4rx5g== X-Received: by 2002:a17:902:694b:b0:143:722f:91c1 with SMTP id k11-20020a170902694b00b00143722f91c1mr90562377plt.68.1639332888251; Sun, 12 Dec 2021 10:14:48 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:f687:: with SMTP id l7ls7078629plg.10.gmail; Sun, 12 Dec 2021 10:14:47 -0800 (PST) X-Received: by 2002:a17:90a:1913:: with SMTP id 19mr38720637pjg.174.1639332887493; Sun, 12 Dec 2021 10:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639332887; cv=none; d=google.com; s=arc-20160816; b=C3QtSHRfN9BJyMZRCLIuql+CBOyS25mTSYO+v9wr4paaJDWxayjwKS7kA6C3bK8lEa CvjwDAMMFtb0G8h+y4CfaCH6MFW+2RNa50TWfToGUfnryXlUPRH15bpJ5JiMTdF7LEqH /zESr77GcAlfLfHRhXL4mwmR/jv0Qhj2PfuNG0fk3xuhbJkmS3ekx8T04VPN19NHm4PU oBKQypWZebSOWC7brsjZJ5vR2e2aIfx8tkI96lxoZo5NaZ6y3U3kvADuZaML31QvXNjM 7JrgIkdMPX/6wto6tKZOVOmFegUHMiehWWVz/tyCofewbwNDW1+X2rfVBzv1DNKnJtE9 +Quw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=nndxS3DBXwds0GdG4+eUAhTHP19wWLCxCMUGMS1dL44=; b=0Vp1AkHPsw5e68TZAMHfGPv4clfMmxFdzBqtnyObgImA+P59KLpmjwzaB1VkQhbg+b bxIVdJRj8xogVp5qPbr9O9VX89WfA4lgYhI+djCnGOkAPerU8o2H/kQ7WR51+a9raDVr fnhDh905QPehE66wu27vtyXbiGnri5H7SWnfRqD9AbCJ9u/9VOlEZgcGKr2Oluoi2W1M IGeMpm8X6GoOHBYaYjr/7a8nYxpW5aNzPyevW9PE+80K+ghv0QPPfhDQ6Kv+8VAYrhxm 2MXqVljBUQOXqkWw37Pc9VCq0dx6thQd1z2e7QGmahycw3Ab+vBrvwcDVaOwogt8SiEW Zf4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Z8von0bz; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id k11sor4098980pgj.81.2021.12.12.10.14.47 for (Google Transport Security); Sun, 12 Dec 2021 10:14:47 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a63:82c2:: with SMTP id w185mr42246113pgd.390.1639332887181; Sun, 12 Dec 2021 10:14:47 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:264b:de7a:bc69:cfbd]) by smtp.gmail.com with ESMTPSA id bt2sm4567904pjb.33.2021.12.12.10.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 10:14:46 -0800 (PST) From: Jagan Teki To: Marek Szyprowski , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Sam Ravnborg , Michael Nazzareno Trimarchi , Inki Dae Cc: dri-devel@lists.freedesktop.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v3 2/7] drm: exynos: dsi: Use drm panel_bridge API Date: Sun, 12 Dec 2021 23:44:11 +0530 Message-Id: <20211212181416.3312656-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211212181416.3312656-1-jagan@amarulasolutions.com> References: <20211212181416.3312656-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Z8von0bz; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Replace the manual panel handling code by a drm panel_bridge via devm_drm_of_get_bridge(). Adding panel_bridge handling, - Drops drm_connector and related operations as drm_bridge_attach creates connector during attachment. - Drops panel pointer and iterate the bridge, so-that it can operate the normal bridge and panel_bridge in constitutive callbacks. This simplifies the driver and allows all components in the display pipeline to be treated as bridges. Signed-off-by: Jagan Teki --- Changes for v3: - fix port number - add print for attached device Changes for v2: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 165 ++++-------------------- 1 file changed, 26 insertions(+), 139 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 0bb44e476633..d1039628b6f2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -221,6 +221,11 @@ enum exynos_dsi_transfer_type { EXYNOS_DSI_RX, }; +enum { + DSI_PORT_IN, + DSI_PORT_OUT +}; + struct exynos_dsi_transfer { struct list_head list; struct completion completed; @@ -254,8 +259,6 @@ struct exynos_dsi_driver_data { struct exynos_dsi { struct drm_encoder encoder; struct mipi_dsi_host dsi_host; - struct drm_connector connector; - struct drm_panel *panel; struct list_head bridge_chain; struct drm_bridge *out_bridge; struct device *dev; @@ -285,7 +288,6 @@ struct exynos_dsi { }; #define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) -#define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector) static inline struct exynos_dsi *encoder_to_dsi(struct drm_encoder *e) { @@ -1391,42 +1393,21 @@ static void exynos_dsi_enable(struct drm_encoder *encoder) dsi->state |= DSIM_STATE_ENABLED; - if (dsi->panel) { - ret = drm_panel_prepare(dsi->panel); - if (ret < 0) - goto err_put_sync; - } else { - list_for_each_entry_reverse(iter, &dsi->bridge_chain, - chain_node) { - if (iter->funcs->pre_enable) - iter->funcs->pre_enable(iter); - } + list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { + if (iter->funcs->pre_enable) + iter->funcs->pre_enable(iter); } exynos_dsi_set_display_mode(dsi); exynos_dsi_set_display_enable(dsi, true); - if (dsi->panel) { - ret = drm_panel_enable(dsi->panel); - if (ret < 0) - goto err_display_disable; - } else { - list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->enable) - iter->funcs->enable(iter); - } + list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { + if (iter->funcs->enable) + iter->funcs->enable(iter); } dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE; return; - -err_display_disable: - exynos_dsi_set_display_enable(dsi, false); - drm_panel_unprepare(dsi->panel); - -err_put_sync: - dsi->state &= ~DSIM_STATE_ENABLED; - pm_runtime_put(dsi->dev); } static void exynos_dsi_disable(struct drm_encoder *encoder) @@ -1439,17 +1420,12 @@ static void exynos_dsi_disable(struct drm_encoder *encoder) dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; - if (dsi->panel) - drm_panel_disable(dsi->panel); - list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { if (iter->funcs->disable) iter->funcs->disable(iter); } exynos_dsi_set_display_enable(dsi, false); - if (dsi->panel) - drm_panel_unprepare(dsi->panel); list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { if (iter->funcs->post_disable) @@ -1460,70 +1436,6 @@ static void exynos_dsi_disable(struct drm_encoder *encoder) pm_runtime_put_sync(dsi->dev); } -static enum drm_connector_status -exynos_dsi_detect(struct drm_connector *connector, bool force) -{ - return connector->status; -} - -static void exynos_dsi_connector_destroy(struct drm_connector *connector) -{ - drm_connector_unregister(connector); - drm_connector_cleanup(connector); - connector->dev = NULL; -} - -static const struct drm_connector_funcs exynos_dsi_connector_funcs = { - .detect = exynos_dsi_detect, - .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = exynos_dsi_connector_destroy, - .reset = drm_atomic_helper_connector_reset, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, -}; - -static int exynos_dsi_get_modes(struct drm_connector *connector) -{ - struct exynos_dsi *dsi = connector_to_dsi(connector); - - if (dsi->panel) - return drm_panel_get_modes(dsi->panel, connector); - - return 0; -} - -static const struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = { - .get_modes = exynos_dsi_get_modes, -}; - -static int exynos_dsi_create_connector(struct drm_encoder *encoder) -{ - struct exynos_dsi *dsi = encoder_to_dsi(encoder); - struct drm_connector *connector = &dsi->connector; - struct drm_device *drm = encoder->dev; - int ret; - - connector->polled = DRM_CONNECTOR_POLL_HPD; - - ret = drm_connector_init(drm, connector, &exynos_dsi_connector_funcs, - DRM_MODE_CONNECTOR_DSI); - if (ret) { - DRM_DEV_ERROR(dsi->dev, - "Failed to initialize connector with drm\n"); - return ret; - } - - connector->status = connector_status_disconnected; - drm_connector_helper_add(connector, &exynos_dsi_connector_helper_funcs); - drm_connector_attach_encoder(connector, encoder); - if (!drm->registered) - return 0; - - connector->funcs->reset(connector); - drm_connector_register(connector); - return 0; -} - static const struct drm_encoder_helper_funcs exynos_dsi_encoder_helper_funcs = { .enable = exynos_dsi_enable, .disable = exynos_dsi_disable, @@ -1537,31 +1449,20 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct exynos_dsi *dsi = host_to_dsi(host); struct drm_encoder *encoder = &dsi->encoder; struct drm_device *drm = encoder->dev; - struct drm_bridge *out_bridge; - - out_bridge = of_drm_find_bridge(device->dev.of_node); - if (out_bridge) { - drm_bridge_attach(encoder, out_bridge, NULL, 0); - dsi->out_bridge = out_bridge; - list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); - } else { - int ret = exynos_dsi_create_connector(encoder); - - if (ret) { - DRM_DEV_ERROR(dsi->dev, - "failed to create connector ret = %d\n", - ret); - drm_encoder_cleanup(encoder); - return ret; - } + int ret; - dsi->panel = of_drm_find_panel(device->dev.of_node); - if (IS_ERR(dsi->panel)) - dsi->panel = NULL; - else - dsi->connector.status = connector_status_connected; + dsi->out_bridge = devm_drm_of_get_bridge(dsi->dev, dsi->dev->of_node, DSI_PORT_OUT, 0); + if (IS_ERR(dsi->out_bridge)) { + ret = PTR_ERR(dsi->out_bridge); + DRM_DEV_ERROR(dsi->dev, "failed to find the bridge: %d\n", ret); + return ret; } + DRM_DEV_INFO(dsi->dev, "Attached %s device\n", device->name); + + drm_bridge_attach(encoder, dsi->out_bridge, NULL, 0); + list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); + /* * This is a temporary solution and should be made by more generic way. * @@ -1569,7 +1470,7 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, * TE interrupt handler. */ if (!(device->mode_flags & MIPI_DSI_MODE_VIDEO)) { - int ret = exynos_dsi_register_te_irq(dsi, &device->dev); + ret = exynos_dsi_register_te_irq(dsi, &device->dev); if (ret) return ret; } @@ -1596,18 +1497,9 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, struct exynos_dsi *dsi = host_to_dsi(host); struct drm_device *drm = dsi->encoder.dev; - if (dsi->panel) { - mutex_lock(&drm->mode_config.mutex); - exynos_dsi_disable(&dsi->encoder); - dsi->panel = NULL; - dsi->connector.status = connector_status_disconnected; - mutex_unlock(&drm->mode_config.mutex); - } else { - if (dsi->out_bridge->funcs->detach) - dsi->out_bridge->funcs->detach(dsi->out_bridge); - dsi->out_bridge = NULL; - INIT_LIST_HEAD(&dsi->bridge_chain); - } + if (dsi->out_bridge->funcs->detach) + dsi->out_bridge->funcs->detach(dsi->out_bridge); + INIT_LIST_HEAD(&dsi->bridge_chain); if (drm->mode_config.poll_enabled) drm_kms_helper_hotplug_event(drm); @@ -1663,11 +1555,6 @@ static int exynos_dsi_of_read_u32(const struct device_node *np, return ret; } -enum { - DSI_PORT_IN, - DSI_PORT_OUT -}; - static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) { struct device *dev = dsi->dev;