From patchwork Fri Dec 10 19:19:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1812 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 505183F075 for ; Fri, 10 Dec 2021 20:20:16 +0100 (CET) Received: by mail-pg1-f198.google.com with SMTP id j3-20020a634a43000000b00325af3ab5f0sf5656351pgl.11 for ; Fri, 10 Dec 2021 11:20:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639164014; cv=pass; d=google.com; s=arc-20160816; b=orz2oTOvYfT2S6BWiVrwHK/7nITSqGEFCwBkrToQuW6FEwDTxGCqWgSDLNKNcslqWd uhiCyFrTjbA+53EC4sTilkNeNGHPEHm2c/k8rILNfkeYmWbtY1RVWDMHOv2JAlOGHOij MWS4vGUcaVWYMyyGq/CNKAb1egZhzkAO4BYj3xjlK8MzPDPcqGt9d+EYO5IrjQiMH5b9 qcE9B8ey8vto4kfGb43egiGpODKnsYyCDrEpfuT59igdrytX6oLQc1argdAQEHi+PO6r QnaC1NYL5TcSXwuuLjYOeTUP+Fv75NXc5NCSmgvHu1vTT/4AQ6bakSgFOlqYiP4hf+Z7 ommA== 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=ldQJqYcJuvQfd7gQQDG8Dle5n8FO3Zn+0Iqeda7YJpk=; b=lNxFsYNavU0YXv3BwcOoqpDivQ6ThlaV6Hc7kde1V5BUvFR6ivb65TR3fLPyOEdQny 9V1Dy/A+wlli+GecxGCr66kw3CyhpRpzTBAttN/5XHDBtRECnLewBLBxwGjcU+rJrN3o Hsse/3M1erNHRV8TmafXGS8uTelWIq8zjuXilUp0Zzapw4XE39+TjFyKO8eDoAopW6aw M0TrroMEPcETo9gfrxgqHDL1XfH95cakKerCV9BwmKXEImJF1/rw+tSTxsDcTYTFByqG eX2MPuBIRnIjdSEERPxwe+ZGLlaOFvYaU54ekoPzx5RJrjB0xuvq7fAP8gUjZk4kAmjE Pe/w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mNAfy4UD; 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=ldQJqYcJuvQfd7gQQDG8Dle5n8FO3Zn+0Iqeda7YJpk=; b=HGkoUMlXBmf+k1+E0fn4h8v5WxbVU3ISm1FcszlaQBCcAjMRHAI5xzBB/Z352uPS4G 4gIA4PPwY0udiL3CC2E9pSYRRtyxyaleARhcpQIG1snYK/keeohIMmLYQ2kaDfnhFsmj 8ysVcpAm61jkOpKfYGbRXYUSOmTNOQ9cn9O9E= 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=ldQJqYcJuvQfd7gQQDG8Dle5n8FO3Zn+0Iqeda7YJpk=; b=5hdN0jW+3xNQBW/U5sGDitr0AHP/dJkrz63vlEFuRacbmbgNp+arMpz6z+IhyscERS Y6Rp1MpuGpl3P8HulERfFT/CDbAvF0IZkraQw2Y/WxyXdWfWjwUbNVrZtNX1C/sQDwMA im+zyzIsuro/tDjOAWOZB5XXj9fipuKQtbHSGa7k9QhWZ6pVUD/HTrGb9qEgxUxy+u62 ae7hC490orVo6IrUko0UGrSxzGxKk+faNcbuWk51pgq/I+3C8VbK64XGWKSYwtMISukA FkQyGkm95LiVd6aYBTqIbp4ghzAiXWXndAKnDy3ENMSqum+HIDlBuxR223aA6v/hHDjo am+Q== X-Gm-Message-State: AOAM530Q0RCWN3rvu18PPMKM1IlJcZCPNsVQwB5JAtdfGWKkCJy/lfKy OMradWwFvzIHLQbhTARhaCqqXPzs X-Google-Smtp-Source: ABdhPJxIc+IMVNCV0pyi9WbSAixVANg78oNJpWoeCRUTNPM/+mJ5DSZTqVS4bLCHDjkCG/HPdWXjLw== X-Received: by 2002:aa7:9143:0:b0:4ac:bc9a:1074 with SMTP id 3-20020aa79143000000b004acbc9a1074mr20082562pfi.38.1639164014679; Fri, 10 Dec 2021 11:20:14 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:1c2:: with SMTP id e2ls5288367plh.9.gmail; Fri, 10 Dec 2021 11:20:14 -0800 (PST) X-Received: by 2002:a17:902:9a4a:b0:146:8ce2:672 with SMTP id x10-20020a1709029a4a00b001468ce20672mr32857274plv.29.1639164013920; Fri, 10 Dec 2021 11:20:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639164013; cv=none; d=google.com; s=arc-20160816; b=BEQWRzYVxgKKa3yYEauMx5bZ3CjrsPQRRClA6b2Jm2AGpWgCw+8yFbNV0Yus8JNJ7/ 4u7QUOskYZ0eUm9i47+XpA8kd9hw3dWDyMc14fjq5JznCy2RHJZMRtC+G0klYg1sixnu 2x7LjSTvVqmivAWpCxs9QhF4Y1E0ojuG2gCZOhgcKtquqqkKYjQeWaYGbz9/0OS/FXXS uuMSCPRYjtQ7d4YqtFJUCNqDUsvhFpnjgzRKdz7H1LQW9uDZyI3AeFqXiJMq9P1BYSo5 8m/+8wgWWPMAtyBGb77QTM1Y3ORU5bL0MgaQT1xPNw/Vu3wVCIHGHTIW5R9Ug0og4YwJ UhTA== 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=u+8J0typzXJBP9SmIdZ7aUHRk1S8ZG0rEGDpl9ZWmlI=; b=lZq7C0QMvHUUvVpHV2/uBH6UPNQsqRJkYhH1iMquPms4qBVvuMfc/ySM1u2LiQ6gLr rZt18KR3qQB6lY8gdt7/wlqTwNaO63iI1X709N++O7h53J+h43qC1URClgHR5yVv7M83 ZdpdGZHz+sYKtBlZSBS5u6RWz/nEmVbJ8mg83RJMB/aOCWcxU++DVL5s/yR7YWuYjeIM MelnJZoDoVtLesw9UegI52aCMK+V905XlxPLwy2eII21atLxQ0Ig/OPSqLjtexm9mD4x C9HldPtXzDi6LC7p3MJwHYGUh1hoG2A+cbR1cUhackWUnSZooBkhvS/7rnbL5NKnOUuk iJxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mNAfy4UD; 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 i12sor3142281plb.60.2021.12.10.11.20.13 for (Google Transport Security); Fri, 10 Dec 2021 11:20:13 -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:a17:902:ce8c:b0:141:d218:954 with SMTP id f12-20020a170902ce8c00b00141d2180954mr76943327plg.1.1639164013383; Fri, 10 Dec 2021 11:20:13 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:28d6:2bae:633e:b110]) by smtp.gmail.com with ESMTPSA id o62sm3493022pfb.211.2021.12.10.11.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 11:20:12 -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 v2 2/4] drm: exynos: dsi: Use drm panel_bridge API Date: Sat, 11 Dec 2021 00:49:20 +0530 Message-Id: <20211210191922.2367979-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211210191922.2367979-1-jagan@amarulasolutions.com> References: <20211210191922.2367979-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=mNAfy4UD; 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 v2: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 147 +++--------------------- 1 file changed, 14 insertions(+), 133 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 0bb44e476633..8c6f7ac82822 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -254,8 +254,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 +283,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 +1388,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 +1415,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 +1431,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,30 +1444,13 @@ 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; - } + dsi->out_bridge = devm_drm_of_get_bridge(dsi->dev, dsi->dev->of_node, 0, 0); + if (IS_ERR(dsi->out_bridge)) + return PTR_ERR(dsi->out_bridge); - 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; - } + 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. @@ -1596,18 +1486,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);