From patchwork Wed Dec 15 10:15:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1829 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 9BCD53F18E for ; Wed, 15 Dec 2021 11:15:56 +0100 (CET) Received: by mail-pg1-f197.google.com with SMTP id u4-20020a63ef04000000b0033ab2693122sf6572718pgh.3 for ; Wed, 15 Dec 2021 02:15:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639563355; cv=pass; d=google.com; s=arc-20160816; b=b2cBIzFAsArn0pQpwUyEMqYWnFh45cppUEuVvvHtfUVsWo//3JmSOJ2xBIA9I2H5mM zCIo2pZ6c+l3DAeST296Zt3bpgTliiluFLdMTQALB7+0DPTYf+/h5FIbcLALKg5kUj5B Ku71q8dAYmuP3K1XNqXQnVDidOeh5jX6Iqar71tucFZ1cPyvmXtIwLWVOrLFRlvtJmIY xQdIQsBgY6q+aDc841j0BhQhqEsRATX68GCOWLGf3RLUEOzUHRE7vH+90gjpwRc1ZEzA woI9YRWX3RfIdW7/nbh2ipLdSZhxrFeexrXp848Y7Jkj6txDpqQnx6tFPBRk6INjTo6X SYoQ== 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=EPanpM5WK/I5KI3lF5R2dqhqi1fzJ52IZbKFHZZJIMU=; b=r6/xweloEXO44/s5uTkNIGHJG1aqhu510RLLoelYVANo77+GV156MQS0BoD51uUtdx 5PRJniJNB0xX4BTEcbYEPunQGMmsJuuDQDaVIrGH1CGWxryqfXpk/+zHOu6Zs4tfcFXT 7wm8+yPl1JWzwhGfrXgTY8Q9haQp+Sk29FWtmNUjU6/Z/40sMH3Skx0jM8ejm3ocWzWN cAa9bPchY3sGBI5kjPV/52EfbRqcBJwg11icVwzVvdkTFa9btRhKu8kHj7IkHw8AkuUf C5RJkiqZo+9Zjv1dBlPTm5JslSUnRGGO+o0zx9F9QgEvDwamIqht/O0rgDROCwNfpYRQ 5ofw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FkFA+o0I; 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=EPanpM5WK/I5KI3lF5R2dqhqi1fzJ52IZbKFHZZJIMU=; b=psPDb/fcDWXn6IzEYV/MgEugRCsrxQxC9iUM8mOApvPIU5Rh4qr5RckzOr+R/WQYwX 5uxbrFj7waF/wn/QhPCNEiWDTQGRfvnCkSQ8mi/ROb5lhYGYtDq4u6DugB34dQLc1Qbt MEPPUWs1MIVnkUqwTW5G+1tt/dOBLn3MIzAJA= 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=EPanpM5WK/I5KI3lF5R2dqhqi1fzJ52IZbKFHZZJIMU=; b=F2owjGK0zvVKufnAbFSq9tbBo6u+QVY4f5i9/OKffXz4znuI2dqV71+3XJVESsBVuN Fpq6wv04ZeMcJh9Fl3EQM4GtX2SPRIVS2F2PUOuKmwfZ9LAqn+mlp3PakJwafvi+jotn 8jCx1n3Ut53LWHBeKZbYnxp5WpNRXd/Q5Bm5CpEaw37mukI6dUWJAJN38hO/kCfkxbsC 2/g8OdSKn5PWdhg2LZ7BPYxrAnTFQcD+9BLZbNlhKJmUDOI7zNgNKg+ggUFVUlNERTf+ JJcwzqiLZd26vpubhr67qIWxM4dlqXuIS7xDqUhK3zBClm/IEY4+aiFLrJxrR5o54hjP x8oQ== X-Gm-Message-State: AOAM533QoyCbNeEWTfNsJgQt5+e+TNgiBWvdsOfcFkSGq9f4EzVhxEOB ge0NriaSfJh+uhJ4s9IdDhwERxW2 X-Google-Smtp-Source: ABdhPJw/Y3QxotmdUkeTaapAcaFpgfkr2ncjana0lasL6AJdN3lREVsqDEXsDVrXggGLj/nsqq6Lvw== X-Received: by 2002:a17:90a:f292:: with SMTP id fs18mr11025879pjb.188.1639563355415; Wed, 15 Dec 2021 02:15:55 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90b:1a8a:: with SMTP id ng10ls2499799pjb.1.canary-gmail; Wed, 15 Dec 2021 02:15:54 -0800 (PST) X-Received: by 2002:a17:90b:4c4c:: with SMTP id np12mr10909509pjb.68.1639563354723; Wed, 15 Dec 2021 02:15:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639563354; cv=none; d=google.com; s=arc-20160816; b=rQkValf2kn7DHjiVOi3DFGNLZ/UjOki2TA5Ots8HABYgikca4blqaIG6cmj0mpDlqz 7qqq1h6byI4yLpFMsEq6dTRpDODWwL8OMRH7/fIWMi5rWcWv5dl57IGqDYenh3P82+aS r/K2mPrT/Ibvfv4OhJdhZ3kOms1IzaJ1t5T5aJQnYEO9eXpZIQ7dUlS0hZuHXasg/hDH CxbPNuajPvF7k5oJBccBnDejb24NNK61vl8z7KifMMO1j56RDF6NiCj1HFMt0g9keZMW A+9/1YJjgy6yro3/DatJA7pKoPyD7Q96DJXafuLB7v2l6nDOFoy99XStz2pYLqTNs4Iz CRmg== 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=vzWxnXfCEtfJtmf3hDGkV6u62l3KVpf2aBYAb8aByi8=; b=CpDICJ0b9g9hZWNi6yMWvOJki4EoRn2KfHm8sfbUIVrOxFCi2CrD608cciM0LmUUcG E7tL2GjF7FuY+wkbpdVEUWfuGbfxgoqa4EV3EWQXk2POU3TByNhPmgeBF9muUXsvfNmW UqoevXVPewNkbGQpnHw6/fEjmTZFQVZjgMxcxPfHVX7mY8tKm2znUtq4oGBxwp8bbUHY LKYLsA/7vnH/WY2PzGzYQSTliTgII6eMgr6f3Mnxgmmwi46hCDYmbjkQm+HJ/Pcl62gS YNF2EfUxqvHifYtanjLU0vw9bRxdlt744XJayjAQZFzaJK6Qdb80zYFjx5ZnfT5kmQfL EOyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FkFA+o0I; 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 o9sor739826pgv.52.2021.12.15.02.15.54 for (Google Transport Security); Wed, 15 Dec 2021 02:15:54 -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:a63:8a4b:: with SMTP id y72mr7342101pgd.1.1639563354413; Wed, 15 Dec 2021 02:15:54 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:a7:8328:d9c4:5bc9]) by smtp.gmail.com with ESMTPSA id v11sm2408149pfu.184.2021.12.15.02.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 02:15:54 -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 v4 3/6] drm: exynos: dsi: Convert to bridge driver Date: Wed, 15 Dec 2021 15:45:31 +0530 Message-Id: <20211215101534.45003-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215101534.45003-1-jagan@amarulasolutions.com> References: <20211215101534.45003-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=FkFA+o0I; 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. - Adds drm_bridge_funcs and register a drm bridge. - Drops bridge_chain. - Separate pre_enable from enable function. - Separate post_disable from disable function. Convert it. Signed-off-by: Jagan Teki --- Changes for v4: - add pre_enable function - add post_disable function Changes for v3: - move bridge add in host_attach - move bridge remove in host_detach - use flags, bridge in drm_bridge_attach in attch Changes for v2: - drop bridge_chain drivers/gpu/drm/exynos/exynos_drm_dsi.c | 85 +++++++++++++------------ 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 14e16f2d594b..29c68379e6be 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -257,7 +257,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; @@ -287,9 +287,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 { @@ -880,9 +880,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; @@ -1374,10 +1375,9 @@ static void exynos_dsi_unregister_te_irq(struct exynos_dsi *dsi) } } -static void exynos_dsi_enable(struct drm_encoder *encoder) +static void exynos_dsi_pre_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); int ret; if (dsi->state & DSIM_STATE_ENABLED) @@ -1390,53 +1390,54 @@ 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); - } +static void exynos_dsi_enable(struct drm_bridge *bridge) +{ + struct exynos_dsi *dsi = bridge_to_dsi(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); - } - 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); 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); - } +static void exynos_dsi_post_disable(struct drm_bridge *bridge) +{ + struct exynos_dsi *dsi = bridge_to_dsi(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); - } - 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, flags); +} + +static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { + .pre_enable = exynos_dsi_pre_enable, + .enable = exynos_dsi_enable, + .disable = exynos_dsi_disable, + .post_disable = exynos_dsi_post_disable, + .attach = exynos_dsi_attach, }; MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); @@ -1459,8 +1460,9 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, 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); + drm_bridge_add(&dsi->bridge); + + drm_bridge_attach(encoder, &dsi->bridge, NULL, 0); /* * This is a temporary solution and should be made by more generic way. @@ -1499,13 +1501,14 @@ 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); dsi->out_bridge = NULL; - INIT_LIST_HEAD(&dsi->bridge_chain); if (drm->mode_config.poll_enabled) drm_kms_helper_hotplug_event(drm); exynos_dsi_unregister_te_irq(dsi); + drm_bridge_remove(&dsi->bridge); + return 0; } @@ -1591,8 +1594,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; @@ -1612,9 +1613,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); } @@ -1640,7 +1640,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; @@ -1708,6 +1707,10 @@ 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; + ret = component_add(dev, &exynos_dsi_component_ops); if (ret) goto err_disable_runtime;