From patchwork Sun Dec 12 18:14:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1818 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BC6363F071 for ; Sun, 12 Dec 2021 19:14:53 +0100 (CET) Received: by mail-pg1-f200.google.com with SMTP id z13-20020a63e10d000000b0033b165097ccsf854053pgh.6 for ; Sun, 12 Dec 2021 10:14:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639332892; cv=pass; d=google.com; s=arc-20160816; b=DCQJFTzFH1xLgloJOnxaKvPDfQB1UGNadSZFrW1m0zmAjVcT4mPDGraZsMISXgfRYQ PFzZ6sj9AJ0iv8qyj2CAqXUBQ1YMbcmhGRoCmcjgnEB/aloc8NnX8nOLr0Bdq5CtVTUa yEOBLrExWxyC2wmKGMt8gP2IT6mqztq6T+IZbxcTdnE8vQs0UXU3rflp/pUN5tTsT2wc GfOjan+rcU9nIjelkUg16ibMfbKhwd41NAfseuIEMRcbkRH3FscwmtSVEUpsCjXYyhzB zjYwy2D7B5BA0TjNia03MH2ToqBRwhdHOn/yNAxY8lLmK2LxC5D3GeXGctoOqN9lu6qR nP8g== 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=e3by6WC0BAL7R0io38qMyyzTep3TuVxCkMEzDTq5U58=; b=TlWONUdts7ALo4DWdaPGYu6te3y1nOKRMFKrBHIOyRKrA/7wATgF+88003MPj3aCX7 jXfFw2ZtziRYoCY9LiIHEqxE8HZHWqvs134vrSbhnXqmkdat994Jis75+BSTq3hlRcSI lEMmI1GHFwv97yBZ8sOxKlOkEg1UCERYiyLDGfSMqR5RbmO1U23xeVezT7hAq2M49vva MssmGCPMeWGGvjisuIOWqMaGQEP3FfiFRhakuojN9xnymDMtXedSm94zqAdMJyfKOxxs Li/6nO7Z4UZrpFyeAg+HoW+uODm5QJgErdhW2CBerl7Qi2/w0vLJ23GQZbQ2lEIF1Xw0 Wf3Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="qfR6c/TY"; 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=e3by6WC0BAL7R0io38qMyyzTep3TuVxCkMEzDTq5U58=; b=JPPIuyr5CX0nRrDXhoBc5y6MkL/EDW7gzc09sf8XcK6qngTDUR5EjPvQWKf9b+j4sK 3aW2rlr5QdY4y6ihosa+S3ULdq+w7BXY0UDj5DwuIC/IxBGQ8CRNwd/G+Jnsl6hsQBmi u9369sgWCAl6m4Opdy9iNRmULBjL3OGoGi2Vg= 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=e3by6WC0BAL7R0io38qMyyzTep3TuVxCkMEzDTq5U58=; b=BEYZjOqJ5gdp00skJLqH0NFEhu3xtJ0wXeN6gmYOO6foaLclCZdp7cn2P4spHTF8LL xzfiXO2gOsQB8rABi4cU+8DnwAJIYPy4rczmPr5Z6bJofTzI+5T3ool8zXjcvd8ggYmB lf2JH1LxDIY7xMzCCMTSSJemT50xV3x4umHcZBiMZJ4UpMomRDBkVM1JzwAtVC7O72TK KGHAy2DF2O+h07+a1dVcpfxOEMTr3vXbQIIKiItCkh8s5/JAeP0FX9K8thKtC+InZKqu E4jVkWb/1U8i1f1BilNBTbIIxlnefEXPPjB83hn+21v0moIusO5YKudP/OTJi2Gj5gOm zUZg== X-Gm-Message-State: AOAM5326+OEcBbY/qEchiazHl5esBkYh7iP6kTTpc1WQzyEHpHLjDkrM T8A1h9wUz4uAV+VmV3Kk1RFDGt0k X-Google-Smtp-Source: ABdhPJyvCiEGAjaD5MI1gBnn3IHNJnQxvYodsuYNDjCaMdVYghqszlxdoKY6lgVrowL9F9NLHLdNzg== X-Received: by 2002:a17:902:7005:b0:142:4452:25de with SMTP id y5-20020a170902700500b00142445225demr91004922plk.3.1639332892576; Sun, 12 Dec 2021 10:14:52 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6a00:84c:: with SMTP id q12ls3512273pfk.4.gmail; Sun, 12 Dec 2021 10:14:52 -0800 (PST) X-Received: by 2002:aa7:870d:0:b0:49f:e41d:4f8d with SMTP id b13-20020aa7870d000000b0049fe41d4f8dmr30121224pfo.16.1639332891867; Sun, 12 Dec 2021 10:14:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639332891; cv=none; d=google.com; s=arc-20160816; b=wGRCjCc3Toi6h/+nCetpSgRy/6NiAa83FPPSb3u9BkGad9z09ZHz0yWLI21XViDzDb xUnrZvVWKMWQwc4FKStiMXRtLS0ZZ0mXWNPormgEoMgDE7/nIl5O5CkhL+/IjjReSQNa Ick3+rB2D86tH2ngkZtvgNJL7TUm1w66swmHb54WtlaH35Nnt5Rts6arxTzNcFFKjjVA v7mXLMjI98VUg74Eo837ABRQAnaIc0EfczQr4wHi5zVS1l7ngg8n6QnnThR2il892g8I b9b4m2R/rU5Til81NOinUu8MP8KBgsEgf0ei4JgUDm7Vr6Y3cpW1WpNet28V0q/a+xAN pmsA== 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=tFBdWXWRLumKPbljQcPfLHxrbq6FvQTLeBP3tnX7MWM=; b=WnwikfP5HV/dUbt8nUJE+QP/X8PIGCE65OYXEFPceqMnyxFjYbOC7QoI0FgWa7VICJ bNAcmvfVPZrs5Xaz57KKYLF7iOVL8rQEB6UYi39PV1mi/VRbTHGn6JtB8c1An8O7dhhD ercf6TQvbH0swpGwmkZ5KSb6kOKi4ZijatllSOg30cfES5d2Zv4p/TqvdfnHPt3qd3V6 MIvOvHAy4P6T794vhCTW0a9TmctiZjo0BV0bVTmSjPfdmaxcEnXgandtwlMOeWoex3ne wLkI7qIT83s8nCkn/Es8TznI4HVvEfVGiymdgFRPLfjXwBAVWqLOJBRcuadwJevznNPp Qgiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="qfR6c/TY"; 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 x9sor4230052pgc.2.2021.12.12.10.14.51 for (Google Transport Security); Sun, 12 Dec 2021 10:14:51 -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:951b:: with SMTP id p27mr28326382pgd.524.1639332891536; Sun, 12 Dec 2021 10:14:51 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:264b:de7a:bc69:cfbd]) by smtp.gmail.com with ESMTPSA id bt2sm4567904pjb.33.2021.12.12.10.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 10:14:51 -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 v3 3/7] drm: exynos: dsi: Convert to bridge driver Date: Sun, 12 Dec 2021 23:44:12 +0530 Message-Id: <20211212181416.3312656-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211212181416.3312656-1-jagan@amarulasolutions.com> References: <20211212181416.3312656-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="qfR6c/TY"; 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 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 | 82 +++++++++++++------------ 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index d1039628b6f2..1450187c1edc 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -259,7 +259,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; @@ -289,9 +289,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 { @@ -882,9 +882,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; @@ -1376,10 +1377,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) @@ -1393,52 +1394,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, bridge, flags); +} + +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); @@ -1460,8 +1462,9 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, DRM_DEV_INFO(dsi->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 +1502,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); - 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 +1595,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 +1614,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 +1641,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 +1708,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;