From patchwork Fri Dec 10 19:19:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12670789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0FD50C433F5 for ; Fri, 10 Dec 2021 19:20:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EB5C10EC8B; Fri, 10 Dec 2021 19:20:04 +0000 (UTC) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4531810EC8B for ; Fri, 10 Dec 2021 19:20:03 +0000 (UTC) Received: by mail-pl1-x62f.google.com with SMTP id m24so6879995pls.10 for ; Fri, 10 Dec 2021 11:20:03 -0800 (PST) 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:content-transfer-encoding; bh=wZ823IYdWVSXlqlfCjZXc9dDMONl8prYaLH+tdv9C84=; b=cqSBRtkotKu54uCZJ51b6tmkcxwzEvZY6QT4noWN9hpvuhKrps163Bop4BwxEn5Nwb bVysIpFMaqOj6PgDpnffKz1s7ONqW/aHoorJLhEw8V5ofD3BkjfNaQbLKQUXbZ/KZtEu 02rUK+plGf+pFkU8qvVfGubsQXUq2y0f8eC1A= 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:content-transfer-encoding; bh=wZ823IYdWVSXlqlfCjZXc9dDMONl8prYaLH+tdv9C84=; b=MNxMXXYMO3iwnARrLLEVhdGaYeLz1wGmYhX2It8Q+hqGmrZM5S4N4cgPlBdFIrPqLO JxmBbFeKysiUtTaV37Dxlfrvv0ZtOXPu+AXJZwSXlbrEKiYzMQWBTig+Pwthf7k2GGGG 2RFYEVwDRADM86+zuzHETNFvRO96jD6YCDR52DHEFlWkif78u3EkstE8oxukfGVgdyqO bTfcN+Ox16eCubRJdEOy+oIsQnl7BWHdbyQ+Y2D8yk1Tjk5XMndibJYaF4fhxgDsNh5q UQCSFWrxKB/qHd2ZzdG+aZ8WBdyTKQ/bhmh8WVgvvAtyvf50SYdntq8MseeCyzq4AadG bhxw== X-Gm-Message-State: AOAM533XiZkyioKj8drzTw7XF3sT41DrpvdxNKUH5WVuRcKzhm9R/9pC i0+L+UKS7UPJP2aW2Wk15oRfbw== X-Google-Smtp-Source: ABdhPJwWrs+dnAWj8L79l+mNp5vavQ/dUdNVp6ikZ+3J9RUpr8EioShq8n2TQ2KiZkwpbtPfVU1KGA== X-Received: by 2002:a17:90b:1947:: with SMTP id nk7mr26414009pjb.227.1639164002862; Fri, 10 Dec 2021 11:20:02 -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.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 11:20:02 -0800 (PST) From: Jagan Teki To: Marek Szyprowski , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Sam Ravnborg , Michael Nazzareno Trimarchi , Inki Dae Subject: [PATCH v2 1/4] drm: exynos: dsi: Check panel for panel helpers Date: Sat, 11 Dec 2021 00:49:19 +0530 Message-Id: <20211210191922.2367979-2-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-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: linux-amarula@amarulasolutions.com, Jagan Teki , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Trigger the panel operation helpers only if host found the panel. Add check. Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 8d137857818c..0bb44e476633 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1439,7 +1439,8 @@ static void exynos_dsi_disable(struct drm_encoder *encoder) dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; - drm_panel_disable(dsi->panel); + if (dsi->panel) + drm_panel_disable(dsi->panel); list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { if (iter->funcs->disable) @@ -1447,7 +1448,8 @@ static void exynos_dsi_disable(struct drm_encoder *encoder) } exynos_dsi_set_display_enable(dsi, false); - drm_panel_unprepare(dsi->panel); + if (dsi->panel) + drm_panel_unprepare(dsi->panel); list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { if (iter->funcs->post_disable) 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: 12670791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B0585C433F5 for ; Fri, 10 Dec 2021 19:20:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0010610EC8C; Fri, 10 Dec 2021 19:20:14 +0000 (UTC) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0949610EC8D for ; Fri, 10 Dec 2021 19:20:14 +0000 (UTC) Received: by mail-pl1-x62e.google.com with SMTP id z6so6898502plk.6 for ; Fri, 10 Dec 2021 11:20:14 -0800 (PST) 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:content-transfer-encoding; bh=u+8J0typzXJBP9SmIdZ7aUHRk1S8ZG0rEGDpl9ZWmlI=; b=mNAfy4UDJvH/nRCdp3aoTE8QQwZuxUWfThmVGEandqbraI1OYaBTgqjI/TAuCgCMZS NeLNQiAT2CtDO2hRl5+EaC79WyHyUXyBIHoArbatsn+GMOm3Dudnn923YWxg4P8YThcf bn23I7eoP+dPpxep4Y8GYfn3rtX7wblNoTLvs= 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:content-transfer-encoding; bh=u+8J0typzXJBP9SmIdZ7aUHRk1S8ZG0rEGDpl9ZWmlI=; b=P9lQZfLek9F//md6keraWUl6FpI2rvMSj+EAkib2+k09nB7m4jhzkb/OH6NcewPb/F RRPO/O8pM9D9b72b1iq/gLI7brK5WMK1Aikksn8Xnr6WoTxPvaLg1xoeK539PFo2MHI+ 0rYJBr7LjyuW5gWSCJdo555eQTWs+CcGdwKkaEur5zKXYust0GWP7qxtXgSH6+8C7xbJ ttGT8P0/In6dCtEFWQPfyTalbQlLAc+ROUExKhaTtuFA2e6ZrDi4nm1FTCdGyzY3h9vW mYTM71GkiNFw/n6rNWeBQ+PnQbWyzxTbd1rEC55EzskLBt4wX/olzDgjQysI4qBYMSig xR3g== X-Gm-Message-State: AOAM531AR+AmvBrr0i/0WWlOtg6wnhLuYY1AryMTHLDIjK+mj/Uy9U17 13Vb/TSzB5FIwTYbEVq3euWyEw== X-Google-Smtp-Source: ABdhPJxMQOpx152M/GZGKuIjj0d01lN2hqkjiHT3C4dCzlblT4FFK6H6oS/QeG9bSGKAGSJ2NxzkyA== 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 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-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: linux-amarula@amarulasolutions.com, Jagan Teki , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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); From patchwork Fri Dec 10 19:19:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12670793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5AD0DC433F5 for ; Fri, 10 Dec 2021 19:20:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F30510EC8F; Fri, 10 Dec 2021 19:20:35 +0000 (UTC) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by gabe.freedesktop.org (Postfix) with ESMTPS id 590FE10EC91 for ; Fri, 10 Dec 2021 19:20:33 +0000 (UTC) Received: by mail-pl1-x631.google.com with SMTP id z6so6898959plk.6 for ; Fri, 10 Dec 2021 11:20:33 -0800 (PST) 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:content-transfer-encoding; bh=+LaYYqalTE0PFqsd8qC0JzK3G3SgXuhMj6ny3iea3fQ=; b=n3Doa08lDSmdO4jWKs1uPdyqEpX4Z9w5iN1+BIZBjwbF2RpeT9QDpwWIJkJ0kKs9FX T8vJka8f+nfF/H4DKKTdOKGCUSeY8sha2K0sB8vNy2dXOhyn/mPYT11j0HdEsy9LpY3Y ZbzL0r+f5Apw8U8YxAxy0MnbV2b7EJ/75e+XY= 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:content-transfer-encoding; bh=+LaYYqalTE0PFqsd8qC0JzK3G3SgXuhMj6ny3iea3fQ=; b=DeqZmY0lQz+s5fwq0panEoZxC/CxkOWD8kRqTEJMr7pSGehb2FmsmuKKjKve0RWzVD 4ic8cDd/G+fB4cGcv1ZJ74CHPmDH0G1Fa7KmvglPbPKNNRCDYUMdOQL3pIOXIe1bHNGA /qs9iwuihw7CCWigM9tJHncsPfnyLq38h65JzS5LjHDTloLbGx80j05GdkyeuakPmEAa sW6IjF/qOVXNjtPrzizjy+uiwggnpu9CaAxsmBvFW9C587almlqSrCKJYG1/we92VXuv 53gg27FZ4KYnKzIND60OIN4WGoMQLt8LKwpbBmDSAhT7prWwAGP1+2ko8+lEn1HXofSc nT8g== X-Gm-Message-State: AOAM530qz0Z2H2PiSKVWpFkD+b44572cJWl9aWg3rTrWEhYGCj3DfCBv 1oMcGDXfcaqMgX2RmkgV9gdD4w== X-Google-Smtp-Source: ABdhPJxmdOOctZJWXW42amwU8uEYxGlbwB/oKY1i3l01cqiOC+hykLYOUFC7XBPJbTOtkbBueSc2ew== X-Received: by 2002:a17:90a:ff03:: with SMTP id ce3mr26106350pjb.89.1639164032951; Fri, 10 Dec 2021 11:20:32 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 11:20:32 -0800 (PST) From: Jagan Teki To: Marek Szyprowski , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Sam Ravnborg , Michael Nazzareno Trimarchi , Inki Dae Subject: [PATCH v2 3/4] drm: exynos: dsi: Convert to bridge driver Date: Sat, 11 Dec 2021 00:49:21 +0530 Message-Id: <20211210191922.2367979-4-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-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: linux-amarula@amarulasolutions.com, Jagan Teki , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert the encoders to bridge drivers in order to standardize on a single API with built-in dumb encoder support for compatibility with existing component drivers. Driver bridge conversion will help to reuse the same bridge on different platforms as exynos dsi driver can be used as a Samsung DSIM and use it for i.MX8MM platform. Bridge conversion, - Drops drm_encoder_helper_funcs, bridge_chain. - Adds drm_bridge_funcs and register a drm bridge. Convert it. Signed-off-by: Jagan Teki --- Changes for v2: - drop bridge_chain drivers/gpu/drm/exynos/exynos_drm_dsi.c | 84 +++++++++++++------------ 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 8c6f7ac82822..37ad94b563c4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -254,7 +254,7 @@ struct exynos_dsi_driver_data { struct exynos_dsi { struct drm_encoder encoder; struct mipi_dsi_host dsi_host; - struct list_head bridge_chain; + struct drm_bridge bridge; struct drm_bridge *out_bridge; struct device *dev; @@ -284,9 +284,9 @@ struct exynos_dsi { #define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) -static inline struct exynos_dsi *encoder_to_dsi(struct drm_encoder *e) +static inline struct exynos_dsi *bridge_to_dsi(struct drm_bridge *b) { - return container_of(e, struct exynos_dsi, encoder); + return container_of(b, struct exynos_dsi, bridge); } enum reg_idx { @@ -877,9 +877,10 @@ static int exynos_dsi_init_link(struct exynos_dsi *dsi) return 0; } -static void exynos_dsi_set_display_mode(struct exynos_dsi *dsi) +static void exynos_dsi_set_display_mode(struct drm_bridge *bridge) { - struct drm_display_mode *m = &dsi->encoder.crtc->state->adjusted_mode; + struct exynos_dsi *dsi = bridge_to_dsi(bridge); + struct drm_display_mode *m = &bridge->encoder->crtc->state->adjusted_mode; unsigned int num_bits_resol = dsi->driver_data->num_bits_resol; u32 reg; @@ -1371,10 +1372,10 @@ static void exynos_dsi_unregister_te_irq(struct exynos_dsi *dsi) } } -static void exynos_dsi_enable(struct drm_encoder *encoder) +static void exynos_dsi_enable(struct drm_bridge *bridge) { - struct exynos_dsi *dsi = encoder_to_dsi(encoder); - struct drm_bridge *iter; + struct exynos_dsi *dsi = bridge_to_dsi(bridge); + const struct drm_bridge_funcs *funcs = dsi->out_bridge->funcs; int ret; if (dsi->state & DSIM_STATE_ENABLED) @@ -1388,52 +1389,53 @@ static void exynos_dsi_enable(struct drm_encoder *encoder) dsi->state |= DSIM_STATE_ENABLED; - list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->pre_enable) - iter->funcs->pre_enable(iter); - } + if (dsi->out_bridge) + funcs->pre_enable(dsi->out_bridge); - exynos_dsi_set_display_mode(dsi); + exynos_dsi_set_display_mode(bridge); exynos_dsi_set_display_enable(dsi, true); - list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->enable) - iter->funcs->enable(iter); - } + if (dsi->out_bridge) + funcs->enable(dsi->out_bridge); dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE; return; } -static void exynos_dsi_disable(struct drm_encoder *encoder) +static void exynos_dsi_disable(struct drm_bridge *bridge) { - struct exynos_dsi *dsi = encoder_to_dsi(encoder); - struct drm_bridge *iter; + struct exynos_dsi *dsi = bridge_to_dsi(bridge); + const struct drm_bridge_funcs *funcs = dsi->out_bridge->funcs; if (!(dsi->state & DSIM_STATE_ENABLED)) return; dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; - list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->disable) - iter->funcs->disable(iter); - } + if (dsi->out_bridge) + funcs->disable(dsi->out_bridge); exynos_dsi_set_display_enable(dsi, false); - list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->post_disable) - iter->funcs->post_disable(iter); - } + if (dsi->out_bridge) + funcs->post_disable(dsi->out_bridge); dsi->state &= ~DSIM_STATE_ENABLED; pm_runtime_put_sync(dsi->dev); } -static const struct drm_encoder_helper_funcs exynos_dsi_encoder_helper_funcs = { - .enable = exynos_dsi_enable, - .disable = exynos_dsi_disable, +static int exynos_dsi_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct exynos_dsi *dsi = bridge_to_dsi(bridge); + + return drm_bridge_attach(bridge->encoder, dsi->out_bridge, NULL, 0); +} + +static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { + .enable = exynos_dsi_enable, + .disable = exynos_dsi_disable, + .attach = exynos_dsi_attach, }; MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); @@ -1449,8 +1451,7 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, if (IS_ERR(dsi->out_bridge)) return PTR_ERR(dsi->out_bridge); - drm_bridge_attach(encoder, dsi->out_bridge, NULL, 0); - list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); + drm_bridge_attach(encoder, &dsi->bridge, NULL, 0); /* * This is a temporary solution and should be made by more generic way. @@ -1488,7 +1489,6 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, 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); @@ -1585,8 +1585,6 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS); - drm_encoder_helper_add(encoder, &exynos_dsi_encoder_helper_funcs); - ret = exynos_drm_set_possible_crtcs(encoder, EXYNOS_DISPLAY_TYPE_LCD); if (ret < 0) return ret; @@ -1606,9 +1604,8 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, void *data) { struct exynos_dsi *dsi = dev_get_drvdata(dev); - struct drm_encoder *encoder = &dsi->encoder; - exynos_dsi_disable(encoder); + exynos_dsi_disable(&dsi->bridge); mipi_dsi_host_unregister(&dsi->dsi_host); } @@ -1634,7 +1631,6 @@ static int exynos_dsi_probe(struct platform_device *pdev) init_completion(&dsi->completed); spin_lock_init(&dsi->transfer_lock); INIT_LIST_HEAD(&dsi->transfer_list); - INIT_LIST_HEAD(&dsi->bridge_chain); dsi->dsi_host.ops = &exynos_dsi_ops; dsi->dsi_host.dev = dev; @@ -1702,6 +1698,12 @@ static int exynos_dsi_probe(struct platform_device *pdev) pm_runtime_enable(dev); + dsi->bridge.funcs = &exynos_dsi_bridge_funcs; + dsi->bridge.of_node = dev->of_node; + dsi->bridge.type = DRM_MODE_CONNECTOR_DSI; + + drm_bridge_add(&dsi->bridge); + ret = component_add(dev, &exynos_dsi_component_ops); if (ret) goto err_disable_runtime; @@ -1716,6 +1718,10 @@ static int exynos_dsi_probe(struct platform_device *pdev) static int exynos_dsi_remove(struct platform_device *pdev) { + struct exynos_dsi *dsi = platform_get_drvdata(pdev); + + drm_bridge_remove(&dsi->bridge); + pm_runtime_disable(&pdev->dev); component_del(&pdev->dev, &exynos_dsi_component_ops); From patchwork Fri Dec 10 19:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12670795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E3F0DC433EF for ; Fri, 10 Dec 2021 19:20:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0279110EC90; Fri, 10 Dec 2021 19:20:47 +0000 (UTC) Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D65D10EC90 for ; Fri, 10 Dec 2021 19:20:46 +0000 (UTC) Received: by mail-pg1-x530.google.com with SMTP id f125so8920560pgc.0 for ; Fri, 10 Dec 2021 11:20:46 -0800 (PST) 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:content-transfer-encoding; bh=LJL7M/YkR4k8VZB5K5AMyhwtJ9pwnvBOZ1XLM0mNSl0=; b=Y+rDwOdMkIKVZHlOc0oabo2HQ1KoEFMMnhdgJ6y4FwoME1K9vbyDUP8ljbTzLirHwY Vz/Xs1j+pwB3ZOzCOWlQDDblmjlO/fsihecLgMRoHvqh5TKrDacfFI9WV9M1Wp01ltAI 2lfddpokK7KlRszjKcEDCke0uf8IEhi9rjWtM= 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:content-transfer-encoding; bh=LJL7M/YkR4k8VZB5K5AMyhwtJ9pwnvBOZ1XLM0mNSl0=; b=AdnRoeaxMz/a9VnlDqhHRJnADNP3KlyALaHfaAZGcYZFdsHDuklmRFUss1oOyIdOyM RMU1I1RUzn/hIvuclhgQasCaPHnLSw8nGle5LFj7u4xY0CEPPr0liy4qTMqodFvqxHWX Vi/NXQJ2KtgK60yWmqUko1MSOrtvkLcjkDYCaqaLK/lU4vbu5POgAshVmxB/iU/Uo+Iv c3e7e2FuUkrAXsrzzxOJEK90djxpxWRadO3ggzFtLP/YW8xF+csTTiCi7QZNgwFjuxaV 3F6eUaExq2VzoC+jPuPzHyrAEamGs24VQoXPst/cLIEYUwyOS0Y8LEq5qUfnethdudi5 p/VQ== X-Gm-Message-State: AOAM5324TaYEBohbq5ZVWZQH8KrVwrnoWnKQ4V6ZjwgqxKlPpjgXlcfE TADAH0Vd52VoHJ4hY0ICXd1KKN31wbpV6cjx X-Google-Smtp-Source: ABdhPJwAkCsiYeobS7ekhkjzLm34JPfTh+rXROd2+Lzo6YxPBFLp7P7MD/M6OnDGCrO3x9E0FgTojg== X-Received: by 2002:a63:4f42:: with SMTP id p2mr41362855pgl.381.1639164045711; Fri, 10 Dec 2021 11:20:45 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 11:20:45 -0800 (PST) From: Jagan Teki To: Marek Szyprowski , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Sam Ravnborg , Michael Nazzareno Trimarchi , Inki Dae Subject: [PATCH v2 4/4] drm: exynos: dsi: Switch to atomic funcs Date: Sat, 11 Dec 2021 00:49:22 +0530 Message-Id: <20211210191922.2367979-5-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-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: linux-amarula@amarulasolutions.com, Jagan Teki , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The new support drm bridges are moving towards atomic functions. Replace atomic version of functions to continue the transition to the atomic API. Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 37ad94b563c4..f2c12a356952 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1372,7 +1372,8 @@ static void exynos_dsi_unregister_te_irq(struct exynos_dsi *dsi) } } -static void exynos_dsi_enable(struct drm_bridge *bridge) +static void exynos_dsi_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct exynos_dsi *dsi = bridge_to_dsi(bridge); const struct drm_bridge_funcs *funcs = dsi->out_bridge->funcs; @@ -1390,19 +1391,20 @@ static void exynos_dsi_enable(struct drm_bridge *bridge) dsi->state |= DSIM_STATE_ENABLED; if (dsi->out_bridge) - funcs->pre_enable(dsi->out_bridge); + funcs->atomic_pre_enable(dsi->out_bridge, old_bridge_state); exynos_dsi_set_display_mode(bridge); exynos_dsi_set_display_enable(dsi, true); if (dsi->out_bridge) - funcs->enable(dsi->out_bridge); + funcs->atomic_enable(dsi->out_bridge, old_bridge_state); dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE; return; } -static void exynos_dsi_disable(struct drm_bridge *bridge) +static void exynos_dsi_atomic_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct exynos_dsi *dsi = bridge_to_dsi(bridge); const struct drm_bridge_funcs *funcs = dsi->out_bridge->funcs; @@ -1413,12 +1415,12 @@ static void exynos_dsi_disable(struct drm_bridge *bridge) dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; if (dsi->out_bridge) - funcs->disable(dsi->out_bridge); + funcs->atomic_disable(dsi->out_bridge, old_bridge_state); exynos_dsi_set_display_enable(dsi, false); if (dsi->out_bridge) - funcs->post_disable(dsi->out_bridge); + funcs->atomic_post_disable(dsi->out_bridge, old_bridge_state); dsi->state &= ~DSIM_STATE_ENABLED; pm_runtime_put_sync(dsi->dev); @@ -1433,8 +1435,11 @@ static int exynos_dsi_attach(struct drm_bridge *bridge, } static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { - .enable = exynos_dsi_enable, - .disable = exynos_dsi_disable, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, + .atomic_enable = exynos_dsi_atomic_enable, + .atomic_disable = exynos_dsi_atomic_disable, .attach = exynos_dsi_attach, }; @@ -1605,7 +1610,7 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, { struct exynos_dsi *dsi = dev_get_drvdata(dev); - exynos_dsi_disable(&dsi->bridge); + exynos_dsi_atomic_disable(&dsi->bridge, NULL); mipi_dsi_host_unregister(&dsi->dsi_host); }