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: 1813 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4B49C3F075 for ; Fri, 10 Dec 2021 20:20:35 +0100 (CET) Received: by mail-pg1-f197.google.com with SMTP id s18-20020a63ff52000000b00320f169c0aasf5645170pgk.18 for ; Fri, 10 Dec 2021 11:20:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639164034; cv=pass; d=google.com; s=arc-20160816; b=x5Vu8AR1SlBXYREy4yTBxCJq1PYPlluTcOflEyoISL8/Q9T2/a+EHAU3KE7cRzGWp1 Y+ZmldOG43rhkNU8ba1WLBC6yhlaEgeUgd0ef3tkwSCzlyz4bekBXmV9yslpAyQzg4dv wYIYeV/synm3ZGrXs9T4vtxYHnxCVbWgZNTduZRkQJnQj6iMuZ4dd4q+KLZ1KU6pOuSD RvjJvIPZfu0K4207t/45uVgv4kCkAXwQoIb44DDVtUdsssoHvh9iAxw40UAAXoR2h96T sNa0TqaDfeIlS4NP1nR4cFrjZvCW4EOrLzAPHq8UOauO2baiegc9c+NXXKjWT+z13Dqg yTKw== 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=Sx/e6IoGKA66UMf04qFwQjPiVCqaddbrkCS6cQ9RxOU=; b=u36LeZRLFjr/G1OZ9UseqCBS03noEBUyZAT2P1PhJr93yv2c6jeThz7qf38adciEl5 JBtA6NtGJ1jwn9wQ1srUp6GgPNxAQs37+h9d0+SxY6MJGYJSKpdLAl6aY/fw5htL96lz IYytG9vz9tWHD8kJVtkHKjWk6R6YLW9y0XMXXe87GH0wGm9hekvlQ8UpOp8Sdmgyj5eF WgkunyJi+LalrWM/TYaGjdcjX0Wb02Ojg/YBaBQKyTv7msaoM7s8+a7jEF6WN8u+nkaN VxJseElYNZw1a/iMzb2fIDWjUHV4e4tDdJQMF1kds7HWbI9UVxsOEDxIlXe4hTY7mQ/T 86fA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=n3Doa08l; 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=Sx/e6IoGKA66UMf04qFwQjPiVCqaddbrkCS6cQ9RxOU=; b=HxmwpHs832Z4ukWxhO2Dt/zlBJrNtKGigSaNwfMXh56BKBy4mFRhuFp03oBlZLZwsB GqLgR8zTzzgKFjGn4/0bQePrpaVkV26wJoEeyEtf+lpfXiKXP4Mg1uj7fuh0UcUOUdLH dKSddlKPI7LcwaBn+Ffu0XQ4il+twcd5pFit0= 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=Sx/e6IoGKA66UMf04qFwQjPiVCqaddbrkCS6cQ9RxOU=; b=I9Tidu/V1KzY1pOBda3PraEUQuYeAyHsbS/GfhhW5TG92JyI0QBQCfvNXGS5YPUK1a Bj4m/VTSyFDLo6h1c7Yh7iS1EkTE189SUGVAIFJeTPirJ6ECX56wQ2+MCVTPC/2BwGXU 5/qM5L0s4TMuWczb4ESam8+DDCInhM2DOhSSi0fBEmH3bgvGO6LDrqf1JZYuvpgQ+EB/ 3f6NAQyunrdYluz8/bjXzUmqYXoDTA8p2njV7jyI3KqJhxc8vx3pbCi2oLiYX2SwxhMt jwR/WqmqBKnEUpHlePwi8PndF07DIMXtWIewUTikB8WZDb0u8E7a+fmUV870nn5VYKhB hJGw== X-Gm-Message-State: AOAM530aVv7qvJ+HzAbYghQGg4okCyhJ/N6s2Ytigu0pxMUMYDSEuXPc /34r43xVJAIWLDQ7AVVvkfbO+6C+ X-Google-Smtp-Source: ABdhPJyC2BtIC2QwscHqs9S0Jxo4Kn7IlKNg2G3memSz1i4hsB+v8noebseO5VQ3UGFACmnaWdJL5g== X-Received: by 2002:a17:90b:3ecd:: with SMTP id rm13mr25667993pjb.157.1639164034009; Fri, 10 Dec 2021 11:20:34 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6a00:18a9:: with SMTP id x41ls3672846pfh.0.gmail; Fri, 10 Dec 2021 11:20:33 -0800 (PST) X-Received: by 2002:a63:5906:: with SMTP id n6mr39545780pgb.563.1639164033245; Fri, 10 Dec 2021 11:20:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639164033; cv=none; d=google.com; s=arc-20160816; b=S6cTn0EPXCyzwcZsv6B+kE59Si8zRtVvdLTo+XtOQeVcphK60i0fABfoXkTXc0sJur z/acvMQ2Ixu4ZV7g31qJsEH/gymjB8GOwjKaMV4jQmmhq2VnfIX7UOjsZTEunFDrloDe KI4UpS/ldCzlpX9kK3CT6yBpJXnOamaNrqppL7z4CvocIAWnlB81loxyeJhHqu7CZoEc apMYfYSYLattmLlrlybuRo6xOPl+FMM5VamYEMrBtW3KO/pGuiaig//cbgjWNhoAeqsQ K+LwYh4fC6R9BWzc9B/kgvP1/1d7ICMrDBcpylc8EQzg1aK0wYxFNJQHNbkWUQkVRfXb PeIQ== 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=+LaYYqalTE0PFqsd8qC0JzK3G3SgXuhMj6ny3iea3fQ=; b=H1/B9mkURCbiMj8ztOoCzrylm2dxisks0IW18u1Us+j8m05yL68+bR5C62vqeh4+Eo W6V6b158ZvqCkR9IEXKGCPhpDa+uUi1Qak4GUfUfyTL/kj2isaos0INppYPd50zAou60 Z+3vf/VFzgEtRySkdEb73pc8xmEFpqMkkgmA6lCPYIwW9gZXdN8jtwaGofCchXAqH1IB N2WkeAYYbvAfoh5l6bRyT8mquSgKDvjrKxwSafDg8oshvxv99qwRn2snmkxmkjY3qJF8 AIh99Kj839XmOFH48igQDhdBBUC7kjMNwiGgiswf+eDAT7i2oCzBw8tbA83Ad/LzwqM4 2wmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=n3Doa08l; 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 v1sor10128801pjd.18.2021.12.10.11.20.33 for (Google Transport Security); Fri, 10 Dec 2021 11:20:33 -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: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 Cc: dri-devel@lists.freedesktop.org, linux-amarula@amarulasolutions.com, Jagan Teki 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-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=n3Doa08l; 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: , 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);