From patchwork Thu Mar 3 16:36:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1858 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 8CC483F236 for ; Thu, 3 Mar 2022 17:38:08 +0100 (CET) Received: by mail-pl1-f197.google.com with SMTP id n12-20020a170902e54c00b0015011534fa3sf3195183plf.9 for ; Thu, 03 Mar 2022 08:38:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646325487; cv=pass; d=google.com; s=arc-20160816; b=L0Q5UYfQ3OeFzwPOLBCM3TmznyK5cBbpZ2+eCpOVzc8QMGNvc0vkwxKDYrUxIzOvjl 1DQs+1H2HP+I8jj/xXFTYiISFFleSZq81Rlo4poRoRDkFmX4iM0474TcGv/+Wp4RpqqI GPci8vgz2p+6evHfsZYImR1F+O36e9HynZEXs0ZDXDiGgbFIWjiUjPgKTHcOT+Sv3QN2 7Rs1b12cwJyjouRMyIBBlSd2rCMfL5L7c+ySF2RTaOju721VcH0pOH0L2NPRZDovtgTb O3BPSGnonKqqtZzG8ijG4ZDc0rKCxKqHgmhGFVNrWdbXiJy5j2EK34VymZDDQZvrXwbL GBmw== 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=mdzGhfxfgZiyiOQRrr4uE6JADbPttUDb6C1TlIgorpQ=; b=mjpDXzV9KGQRby2a63N8BQXHLStcMTQITBFeOZO2eHc/qyMe4kXF4L/Ri3laH+Ytu2 86kZ+lDE++YXEYFDSvHh+oRf+YSpRzgUCi2gYFrKHYEC4AtYc8cHWX6V2WoFs5MJjemt QZsSG11cGS67J+Zayd8q2QAf7zqlK4wlexngfYd6xySDWeE5BarNr8bob7A2asuRgiUD acKsYZozShTHh6UILj4/3g3sNOqeIIv/Vl/fJwyOPqr9kjjEOpB+CTOKkWNCLrKLAfEO mhO7EOBhOisXifeWjGEMLNEZAwzsynvoaukABbMuC3cVygZms4jTvV8zS4st9WSSTjXD o/tA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Q7mS9TBz; 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=mdzGhfxfgZiyiOQRrr4uE6JADbPttUDb6C1TlIgorpQ=; b=L7lwxxYJzK7jicd1QVX90zGeoXkIHCAg38ZnHJuj9C/rh8Ye0x5gbucUIL+tjSiici Z/6DycThmSZ83unSYQcQ4k6FgxbNtdg6b0jcxWJ7UK/2mXovQQYynyf7xN9Q58wg1NSP bbwQ1FhJ8ZH96fpvaSwa/bu0yCY2lsVcOUr2Q= 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=mdzGhfxfgZiyiOQRrr4uE6JADbPttUDb6C1TlIgorpQ=; b=3X3wE1+x+1SiAAvE0nwraWHmApJype0o41ZWiqu8DGC8VZDHWPfHiJFKSZu53Utrqp fMt58m5WD/WvA6yINKQSb/DnhcKF9YUvlQJi3IDpFR8ZbSPY6ysDq4nkAbRN98Wz93Hk jC4WvZa62r+5X3fjXM00yH7ZaU8r2HlH4BH78ezAj7y+HaWM28FU34ae3AQKh9XDCGgy hcr0Bx2Nt7Wb+sgLPlEgK7rtt16qtxTS4MKIoDbGU61hWlJVkck26Pzt9PCmS4jaRI0m DVo37zQ0GAyYMoHdmwSLe0eRl5b7qMXtlaB3x6gSBEPfqPDp5ujfdSiwsgnQgN/zCVEI 2l4w== X-Gm-Message-State: AOAM532E1UvgkdJ3vXF1TiiG4nU5cPsNe+RewgPYgGg902trkLV7ok/i 3cEx44oxdDPSOTa/ANS+Xq9iZfzH X-Google-Smtp-Source: ABdhPJxeMshwg0m5+N1f+GsRv/anyt0PYLBg8cj9NoPC/6ztxqWkJkNOEurmxq3DRuFMiKzDuv6t2w== X-Received: by 2002:a17:902:6941:b0:14c:b815:6d45 with SMTP id k1-20020a170902694100b0014cb8156d45mr37648293plt.49.1646325487344; Thu, 03 Mar 2022 08:38:07 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:ff0f:b0:151:a570:297a with SMTP id f15-20020a170902ff0f00b00151a570297als2516584plj.0.gmail; Thu, 03 Mar 2022 08:38:06 -0800 (PST) X-Received: by 2002:a17:90a:8c86:b0:1bb:fbfc:49cf with SMTP id b6-20020a17090a8c8600b001bbfbfc49cfmr6237525pjo.80.1646325486464; Thu, 03 Mar 2022 08:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646325486; cv=none; d=google.com; s=arc-20160816; b=edzH3C2SSdPebXU5Rt7h1L2XphfvTCRpPgEKRZ1Eo6FBp8r1yiV5qI8T7omMijtN7p lrBJzIsh6mVbq02XYCUicrxRBh6I0PpiFz1rUe4MLu28PeaEaoe0oq4aDM0r2PzMzOiw 469Rs5ml72G9tKibODQpIBOYpL9oCHtMqRx/bqulNWfvFuuL9QEjv8xZFhfZBziE85Wr AlIFQKQ2qDp1LJOwRLJ44im1dlK487iexhm/C6MHdSaFNOnOVLbmdYApRT+3a28bp+CM TbzakpTVNl1cAo7cTiX9ORhZcXKfJuBKPoe5rNrHHFH8o+HjdIAp0CNyfkb/27FJ45w2 Dg6g== 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=oCoF5MNpfuxI3cBKtQYePj3PhXTndQKRGc6x152fDqQ=; b=MEXegB45WIarD4dchrmUQ3bNPmVlykiVDS73U3yf/JQL4ORLT4xP3knecBrbF3mRLM a81xjuAqrhhcm6Be79nEwDRqBxQklUwTafoXzGOIojOKg1yCWzJ5/glhCXGEM3daH9Rl 1Ipys1kXmm33O58c3rNx0c3dz7YdgdzqYUztK0x4Ihah2kYa8ggVfzzp59aLfAqayCxX a00MmRihyJ2KYlcAql5xGlwrjIzYEZO8fwNdwXd8pisXvmWSgxtmE+7byCwB/I++Gw9P 1nHbGKPT0cZ9m5JkRqhPjHMPmRG3oRo0giUKhMd7e5zMoNvRUFHTLfRApcaVQ6BF1kef ZX7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Q7mS9TBz; 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 j5-20020a17090276c500b0014fe92899b2sor10000032plt.98.2022.03.03.08.38.06 for (Google Transport Security); Thu, 03 Mar 2022 08:38:06 -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:90a:4604:b0:1bc:8bdd:4a63 with SMTP id w4-20020a17090a460400b001bc8bdd4a63mr6155141pjg.147.1646325486083; Thu, 03 Mar 2022 08:38:06 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:4526:5253:a010:63f4]) by smtp.gmail.com with ESMTPSA id j20-20020a056a00235400b004e192221ec2sm3220983pfj.14.2022.03.03.08.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:38:05 -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 v6 4/6] drm: exynos: dsi: Use drm panel_bridge API Date: Thu, 3 Mar 2022 22:06:52 +0530 Message-Id: <20220303163654.3381470-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303163654.3381470-1-jagan@amarulasolutions.com> References: <20220303163654.3381470-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=Q7mS9TBz; 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 Acked-by: Marek Szyprowski Tested-by: Marek Szyprowski --- Changes for v6, 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 | 157 ++++-------------------- 1 file changed, 23 insertions(+), 134 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 741c046513e8..953094133ed8 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -24,9 +24,7 @@ #include #include -#include #include -#include #include #include #include @@ -253,8 +251,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 +281,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) { @@ -1380,42 +1375,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) @@ -1428,15 +1402,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) @@ -1456,70 +1427,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, @@ -1532,33 +1439,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, 1, 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. * @@ -1566,7 +1463,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; } @@ -1593,18 +1490,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);