From patchwork Mon Jan 17 08:42:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1841 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 963BC3F067 for ; Mon, 17 Jan 2022 09:42:44 +0100 (CET) Received: by mail-pj1-f71.google.com with SMTP id n23-20020a17090a161700b001b3ea76b406sf13766715pja.5 for ; Mon, 17 Jan 2022 00:42:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1642408963; cv=pass; d=google.com; s=arc-20160816; b=CwkJslLQmIN/TsEOQPKBWXNDtH+Skke6gg8MfgPNFeDOGhW0JvonK88XP4IKzrMqIr smoqG/0iBzqgHopBxAzOeveZQWpjFUjW5eCS4fGQLhc6vohks53Hq5BIPB0N1bEpHzhC WttJxakFhcopF6v6m0xaxxrhLGPnoeMLFfsqZ2ctoEIrHJikTz//4wVdCXEWkfPQCgP4 z8aJuD1rjXhMH5h/8eoNdopHj0KR9R+bRnLscK+f+lzWeQEu/I10NVwSDsb+n9wSHAHg wCdZPsBru78U+ByPunGQj9AjV0wRMjVHsO6y07AZ5GeyR9PqadFnQGtiqE+YVgNqjOuo nvsA== 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=ugVgp0BGEBg5DyTtTDb5whnxi4KHlhnGp/NSIDe3k40=; b=Q1bpg1QWTRFElu2bJBoF13+kNOJr4jEsM2pfrEPmuLs8Xf6BwHaAjbMhwoZVVsGtcC Z/ezJ2f01TV6SO4asCUhDCqSW3y3VJvR0bZ9aBelh+zLxqOupdhoXb4iEKNyougXCde1 MGFszGmZK78tNifALnDa79FvuZ0w8ucWRkqyudQ32y9kWdYLEHlbDsIZ18BToo+jS8DO 0JKaJ15fKanF3lPAedJRUzTaKHhDqJbv3DvQk6uAXDRe+aU/EKIa4y6dDF2UlWON6pKi 43pNqR8SLk381Aegc8DI3nMlu6e/CbrDRTGJloMYzLiQtJLsqFHpUzJEqXXX5MbHvafA uYMw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OCWX3MH7; 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=ugVgp0BGEBg5DyTtTDb5whnxi4KHlhnGp/NSIDe3k40=; b=RC7x6x6YUT4za7nMeN7hxLyYg+3+yNCMUqtB4Qebh4YdYwEADgQJq3+yRK6Qy4VJod ZePSC9O7GHGrwRwuTRFWMmySIxixl5UY9e+0+0g2Y4vusxm1arizksn/rxXBlUAUvXof +ApjSoIVY1P21P72SV4mT+uiyUD/0KaI1eRJU= 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=ugVgp0BGEBg5DyTtTDb5whnxi4KHlhnGp/NSIDe3k40=; b=MEr4aB2Qw7eu+WHLhMHHxRiNRWPoHkSi2zz8RyvlMen4z6Nq9SWBkNc1VHKCbmAjti F12rgViOiKzKOaawjULn4f7VQpyPSgN0NyLN0b3xCpz5WZYelMbAN8aRg7pTYWPMrJk6 W5E0ftHghJbFoGRfAQsrO2umzjmzvHBU0tMQt6yR9sjT0J/lqjEzt9ODu/7VzMB1a+sV fNBQOGDJ258cvMwOQ1xDXqtxpD8ebiw4elHsCmLd3C2q4AcWm0p7ECbCKA90JgbOC1P3 YenEMlIwuGO2nMObEsrQ5ENubkOC3m+7IKfTprZdR1FpNbxmZYv+FOIaf2i9j5TmhcPW ENkw== X-Gm-Message-State: AOAM5322NigyngLFNTGZqZvkpHzWTRPcxyFw8MPfvWdjsnVO/6wNijot GjFa3nN7WfzVCKBh4CuPEmY07iju X-Google-Smtp-Source: ABdhPJxJu9na0hf57VN9bnxmdTuiD7UOaMLSv0WSCLwMgXrnVMm18Z0Rq1k6z2vxSJuQSrVWtFr8GQ== X-Received: by 2002:a63:705c:: with SMTP id a28mr17909651pgn.339.1642408963417; Mon, 17 Jan 2022 00:42:43 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:be41:: with SMTP id g1ls4471192pgo.4.gmail; Mon, 17 Jan 2022 00:42:43 -0800 (PST) X-Received: by 2002:aa7:904e:0:b0:4bc:bdd5:f3d with SMTP id n14-20020aa7904e000000b004bcbdd50f3dmr20203564pfo.9.1642408962747; Mon, 17 Jan 2022 00:42:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642408962; cv=none; d=google.com; s=arc-20160816; b=cdi7Hs/FhMguMnolcjHpzP73JY/g98qsn/CBHRldTh/QRzvlS1HHihuDgbjXU3rwAx RhjVcrX0ues8kBu1UM9azXUTKrP+1BWUZqPGsUpmJHLy4xhgmEQaw1Fgh9rfCQHU4Jcs Tbo0zmhIJ13T8AsHYLh9L8z0L4hO2mXLeNdhvIsdUj6GWs7xW2mNmDr5zLYRFx9BTOam mCo7BaPu8cGyj9ytptBO/YLUphAGqdrHzF4iFqChxNghjC2c8spUVMIpjEN7dXDkaigg eG/Q40bgV8QYuDHeQQXapCrYVE0gR8kdv5X5HoaqKWmpPXv8v7SX6k8zFf+Clunlrze7 VUVA== 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=/zfiuuS6N+V6QtdVoRyeHCOQ8xFFFvWB1WtlwywfESc=; b=KsPgsKnU/rUc3Fuv3Kzx09Nyjbl1OfgLVW2AOeYGSpHUNh6sG3ElYPpiUAwyusiQBm WQpmNdr5AQK1sbemOEFnCrT1q0ThW8c5hzVKmFZ49ltOr1Ai81GqrWj8a6fuiVoxDkDw u5rlDbFr6C0glhfSXtUQ2FMO+/ipH+pJWwoWhsJ0aCoqWUOEtfRuJKwIG0dUov4YXzsW mfRubiJTpdt8gmSxv8iY3Uha8EkbfKIP1Gb7HJZ1dyt2VA0GuW7n+QgefVlPy6/paqaS /pCrt0xQCebOoe2Z6pV7e9mm5UJ3UUn1t3NLLlvybS8v4ttP+DDa4FVY8aQb76WSV9qR IgKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OCWX3MH7; 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 v1sor5974474pjh.26.2022.01.17.00.42.42 for (Google Transport Security); Mon, 17 Jan 2022 00:42:42 -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:90b:33d0:: with SMTP id lk16mr22492164pjb.45.1642408962469; Mon, 17 Jan 2022 00:42:42 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:955a:760d:bbf3:5d4b]) by smtp.gmail.com with ESMTPSA id z3sm11763423pjq.32.2022.01.17.00.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 00:42:42 -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 v5 2/5] drm: exynos: dsi: Use drm panel_bridge API Date: Mon, 17 Jan 2022 14:12:22 +0530 Message-Id: <20220117084225.125868-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220117084225.125868-1-jagan@amarulasolutions.com> References: <20220117084225.125868-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=OCWX3MH7; 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 v5: - none Changes for v4: - drop unneeded headers Changes for v3: - fix port number - add print for attached device Changes for v2: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 167 ++++-------------------- 1 file changed, 28 insertions(+), 139 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index bce5331ed1e6..ebb19194bb86 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -25,9 +25,7 @@ #include #include -#include #include -#include #include #include #include @@ -221,6 +219,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 +257,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; @@ -286,7 +287,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) { @@ -1392,42 +1392,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) @@ -1440,15 +1419,12 @@ static void exynos_dsi_disable(struct drm_encoder *encoder) dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; - 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); - drm_panel_unprepare(dsi->panel); list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { if (iter->funcs->post_disable) @@ -1468,70 +1444,6 @@ static void exynos_dsi_mode_set(struct drm_encoder *encoder, drm_mode_copy(&dsi->mode, adjusted_mode); } -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, @@ -1544,33 +1456,23 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct exynos_dsi *dsi = host_to_dsi(host); + struct device *dev = dsi->dev; 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(dev, dev->of_node, DSI_PORT_OUT, 0); + if (IS_ERR(dsi->out_bridge)) { + ret = PTR_ERR(dsi->out_bridge); + DRM_DEV_ERROR(dev, "failed to find the bridge: %d\n", ret); + return ret; } + DRM_DEV_INFO(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. * @@ -1578,7 +1480,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; } @@ -1605,18 +1507,10 @@ 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); + dsi->out_bridge = NULL; + INIT_LIST_HEAD(&dsi->bridge_chain); if (drm->mode_config.poll_enabled) drm_kms_helper_hotplug_event(drm); @@ -1672,11 +1566,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;