From patchwork Mon Jan 17 08:42:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1842 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 41EA33F067 for ; Mon, 17 Jan 2022 09:42:49 +0100 (CET) Received: by mail-pf1-f197.google.com with SMTP id n203-20020a628fd4000000b004be3d8ec115sf5853960pfd.0 for ; Mon, 17 Jan 2022 00:42:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1642408968; cv=pass; d=google.com; s=arc-20160816; b=Kvw4q96UQuXKOg2PBdZ+y5Os8oIdKz5cLMtOfEFuYcL+zXVtagioo9mYqYViawia/6 pnLHRmFVhtaxzLwm7EG3+1vM3a910bw1GtkiGxyNSrRLn0kfr/CLR72x84lVuAPvoZeK s+gvwV1heb2la3ENQmmS6cbPG4YIhPKlPlOFX7E6ImN37o/uOCojuu85810tPw1xsfV+ 0DmpmpvggyOdjmKzVE437b0mwhPTfLUgiHLonvtDuz6i8epxlBK29hT8NHqaHrBgsrjG U37nU01duXJmG+reteaWmtVWOUpu1vNMRjG1CavhZMGPFVvvSGWTD8v5i+ChDDMZOR82 QxCA== 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=joXlxJttfQRSoiskrZxO8QliZ9bthSdv4T6pxThyIA0=; b=cfFUhYkDUT09ZDywacxoC5Jx1Z+LoPoJwKhAYNOkAHZLzR7goynQzXmNVNsz32GrWf rNb3xOH9Up+OgiWbnBF2+EkTwf8DLFsCPWN/lktCpck+J6l34rxfPZUHjaK5LUZv2dn5 8PIgHIgHTkIXQ60seEU68xsJuXCMHBpa/OP73iDKd/bcI3yQYOELVtXC/JCJ/XH0PTbq I0NHjZOPZTntFXzp4kAkgZ+CtOou+ZsgpZfhu6dEOj7RktOejkNg+7Cs2DWKDcYRRa+V idlTPvxhfZdkZ6E1x49jjezoAi+tC4bPeu47LZJDLsw8ZXUQlwjtkCxwQXQAhuficwWv +Qqg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NG3UQCY9; 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=joXlxJttfQRSoiskrZxO8QliZ9bthSdv4T6pxThyIA0=; b=evZdJy57HGh4I+uiXmO58BzHpxsiBjlo8I3mxm8RctbO6K+KsI1XTxXT6exc50ynxD T/HLp9fFCN3o77ddcA6t9vY0Ag7qL8twdqXyRp+sN0sapbQppO1DPH6ySacIYydWscEf 1+hE+CcAmdZnNb2TkHNaDxZ8Y7aEpX3XEKKPc= 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=joXlxJttfQRSoiskrZxO8QliZ9bthSdv4T6pxThyIA0=; b=dup9xoWPldfq1k+Q97zvKJJGnpCTV/coywyef3YqPryaMCWzQZ4dBSVmhyk67jFDB2 Fw1oxQGFo/XtRx3K7Z2sASTTBNNvj7QfT8yfFPwMWOZD7aRXwGYpGPjYO2LkQWC6sqFW gkxQfqrCwV6W0ywwCk4ahLMY8jT4PiinC/0JQBnR6fnBNuFfY+VVQHwh8mm1v2X6eDku lilNfSDPLC6A5jTUCdVGs9EGFuO8t8q9rxQeFueendi7TuaRvKBDrgVsBM6WvGMRjlsy YqauIGtcrp1Cs0i5NxqYl2dCrsf1xrGdjsvVZvnRUSK9BtCayPvm/UGwKg71FOhIfRfo UWfg== X-Gm-Message-State: AOAM532xnuqUW6EKPeFWNsf1NwEMhSh/r/hUEvcnaQPS/5edbW5KbvSQ 5endij6pMaXW2I3YN1bAMwapegeJ X-Google-Smtp-Source: ABdhPJwwyGNAC3zNkIgTGUYsdyqWqbyL41WxJ4IxtsukioXEupq/qFP/7t7vf2NtU+L9myiLYkcHfg== X-Received: by 2002:aa7:80cf:0:b0:4bc:ecc1:e7f5 with SMTP id a15-20020aa780cf000000b004bcecc1e7f5mr20426036pfn.11.1642408968042; Mon, 17 Jan 2022 00:42:48 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6a00:a94:: with SMTP id b20ls6031654pfl.9.gmail; Mon, 17 Jan 2022 00:42:47 -0800 (PST) X-Received: by 2002:aa7:9e10:0:b0:4be:d337:45ca with SMTP id y16-20020aa79e10000000b004bed33745camr20219588pfq.21.1642408967417; Mon, 17 Jan 2022 00:42:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642408967; cv=none; d=google.com; s=arc-20160816; b=CIx2OSKiVY5WVKeyaq1sTurOonXe8MEdtQBdnM+imn2AvWqZET8+dPd+1JgdrPhDt+ inxGLKPK2qTedCDbQTeypPWlcOopPNuzkWGYHZMK0wb+Jfa/cTkEqHk3BT3BLUCKVGzo 9qQbAU4z/4qTULERYG6ZZOuslC74P3ENX44MzAM9R5kUKImrt7SVGqFTnr0J0eC6Wbhf xzT5i9eIi4U9munPJT0wbtjdEXsUnWxi6mDkHcZYCxGFyUsAKp+tPA7Rx5Ot2EhoQV6I LltwmJVlu7z6jkx8Ix3JQ2SU7flZC4IeaD3OT9jwrC8K3a/qzuFG4SHFJsZp79XGqoTt U6hw== 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=lu7N54hDgGGVeugilU9YpEcDIXXB4MJdT5H56dpnQUM=; b=VIAoDxoeOuN4aP5Zi2vsT3aY6zn2o7O5BQTj7ASNWHj5TyZ7EP/NvLZIbDLLSHSvFP lu10JE9rKoO2KdZjHKQmjClKulCz3PVjpJXfOsPW6AjSlsp6VKicX5mVzyX4Sh5B003G Awj7D5bQ7UIHVl5vWU90nuuZh0s+yX8+4B5K8QikJbYB/JT5MBTtkwUvYkiKNl+64PQA 1N+Vkq5F3UD56ynnikjX+KoEQQOIUqh3vnrrahau6Z4ofQHMxMmlm6Ai8paLABr3x5JS wlsolerNffTzuiyhaadtz9CW8c9ZS4DNu8zCqdITiaAuNIIpMWve7pgA/WHYIqiDcFna xLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NG3UQCY9; 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 lw16sor1778413pjb.28.2022.01.17.00.42.47 for (Google Transport Security); Mon, 17 Jan 2022 00:42:47 -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:b701:: with SMTP id l1mr12422181pjr.153.1642408967021; Mon, 17 Jan 2022 00:42:47 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 00:42:46 -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 3/5] drm: exynos: dsi: Convert to bridge driver Date: Mon, 17 Jan 2022 14:12:23 +0530 Message-Id: <20220117084225.125868-4-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=NG3UQCY9; 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 v5: - none 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 | 88 +++++++++++++------------ 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index ebb19194bb86..8ca95c72ef18 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; struct drm_display_mode mode; @@ -288,9 +288,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 { @@ -1375,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) @@ -1391,63 +1390,64 @@ 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_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 void exynos_dsi_mode_set(struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static void exynos_dsi_mode_set(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + const struct drm_display_mode *adjusted_mode) { - struct exynos_dsi *dsi = encoder_to_dsi(encoder); + struct exynos_dsi *dsi = bridge_to_dsi(bridge); drm_mode_copy(&dsi->mode, adjusted_mode); } -static const struct drm_encoder_helper_funcs exynos_dsi_encoder_helper_funcs = { - .enable = exynos_dsi_enable, - .disable = exynos_dsi_disable, - .mode_set = exynos_dsi_mode_set, +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, + .mode_set = exynos_dsi_mode_set, + .attach = exynos_dsi_attach, }; MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); @@ -1470,8 +1470,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. @@ -1510,13 +1511,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; } @@ -1602,8 +1604,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; @@ -1623,9 +1623,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); } @@ -1651,7 +1650,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; @@ -1719,6 +1717,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;