From patchwork Thu Mar 3 16:36:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1859 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 95A673F236 for ; Thu, 3 Mar 2022 17:38:18 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id i72-20020a62874b000000b004f66c5b963csf1704771pfe.6 for ; Thu, 03 Mar 2022 08:38:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646325497; cv=pass; d=google.com; s=arc-20160816; b=YHWSCdVkN3hvfP5qXgl/kjvzRspnbCmi7ZYbQp7Z5oQafABUSfhtAc9g5ULB7H+jLI b2OnQPFL/pvlH97qCVF1Pt44sQ1G6kw2CvkBkoTDpPeqFZil8cObNAQRGezwhcPNTV8M Q+GQyYoQiMn0eP8qoZhm8FsCSbesRj99WKcysJZSNUrXcjz8RblKPN/RKL6Y6RzyTLGx dYnhaW82R8SOEbO8b4WYGB3w7Z4fQSgEcVlHHzCDNoeRT+QnrMIH00M1yVYHsJ8f4Igz dn+TQJ6Ibblmh115PnmzKWExM+IO944lrnqXohX+OKMGTkIx7iCyTRa/QfoJbrH6YeUi W5Rw== 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=nGrbjhhOrsTacb4YI1NsRTdux0AC+GzaNZ2/VsA3hY8=; b=LZFLH7RIliFbJo/WjGxB6IqOBgaHMEFJmOJ/OzvL6f9pnf4Ujp8CAD9jn0RWM+bDmB LBIS22shHKclYdO5fLKrp6DJaKyr1CKJpotohLAr+AWtTYDB+NijLm/1evN8KuXA2AT6 onXMYJCMtsb3Ugtjec+1NEPjh7Z7Hm93RZoQvDEBRQogq7wwBYHF2WEd7yUJdtkDPa2b RE5eSDOFvuleCRqgx8v6Y3Uq8tiERsT2kGX9FF25oc8cfEa62MMpY9130GxqhCZ/4vt3 sfn44SZlkCK4OKI9K/UZKC7+TFAoj2aN15aRg29fhOo+hXpukHHMzIC7748mnzkOvnR7 MhZw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N71k2Qgd; 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=nGrbjhhOrsTacb4YI1NsRTdux0AC+GzaNZ2/VsA3hY8=; b=j2FJATPvDoVBF9tw5UaAA/Dpz+LEBJ6H9ijacnQZhGnCzuoku/2cV1oFNLe+pCL65k 7Z8lX5sCtEQ1CAbZdlEUWZza2n08x+0pqMnbHMs39hW3puOF/FJwLeN18lYo34J3czP+ z1YvouWn8bfEcAt30l4tRxAT4rbj2n9lawUoc= 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=nGrbjhhOrsTacb4YI1NsRTdux0AC+GzaNZ2/VsA3hY8=; b=fCOSnAvMkmq1K5eAFxVaCzh7qGYwU3Ce4ubWmPAYfwDgs8+zPAGVafBB7hGryR5hro QXCxxAzFmTt3KQfOPtgoAQszrBQbDucB5d5yorF5YPkQLbaBhyb90mA5sqrVLuoKT40U DLC9wRVZX1ZCa8f9vhn8IhIK3EIBhOCeZsOQ0r0MZFID0amGvJsm/ZasjRN+LX6c/VsA X6b8V28g8MAzJCl/z6qG8h4AOhBKQizfASEdTOqF+xp6720awphAqaCOW+AV7hkIZ81E +CJGTIO7ISIfLQXBMg6v1paCgGfxFdsOfW5AeEifvoQJp13Omy+wjGGREMWb0X+OOhMB p9VA== X-Gm-Message-State: AOAM530vgBX3Zf0cucCdU1NUyjXC8Ap7JRGkZoE8wCNL1b8gKep9brDN 2H0N+a0UGi4UptQhaNko7niPATvC X-Google-Smtp-Source: ABdhPJw/+kKmUy/vdYglnwoYR/l1W7zAvaQk82qzD//dbGVF9rN92ltVCX63WBjb5ADJHSttG7yV0g== X-Received: by 2002:a63:be0e:0:b0:363:e0be:613f with SMTP id l14-20020a63be0e000000b00363e0be613fmr30609974pgf.448.1646325497349; Thu, 03 Mar 2022 08:38:17 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:54c1:0:b0:4e0:1a99:c74b with SMTP id i184-20020a6254c1000000b004e01a99c74bls1348132pfb.3.gmail; Thu, 03 Mar 2022 08:38:16 -0800 (PST) X-Received: by 2002:a62:644a:0:b0:4f6:a2e6:c706 with SMTP id y71-20020a62644a000000b004f6a2e6c706mr1333452pfb.42.1646325496390; Thu, 03 Mar 2022 08:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646325496; cv=none; d=google.com; s=arc-20160816; b=0s+s3bM7NoA3rrsSfLKbpHF3kmGtKK6IhISZdOqUXARf5j92z6rPptFY/Bclx84CIc l1HxVEFD79ILX+3s8dst82inso0TyxEn45o28UUB235bmWe/4H4UBBdZjVLdBIzBnm1X OGmTTq8girfn5+EYR1D6y7Z2o+VlPYJu42lJ4tsm++D2pxpGGRLtUfXQuNRCU4+TfDOJ NsKaDRDMNfRhjK90AB+3nhpMz04xJcciUj3hXuAv9bvTK85/s8I2SwEOJMkAPjLrtswD 3s1tx3+CMpDWYKeGFDAoHAIUA+hKWSSSkENwE8uKlxY10U9yUpkEpt9e75ea7wlL8y6w xibA== 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=CKZoe4JiEp2MmbPOTfnaYpdtxIogdQhsVfZjlkmH+tI=; b=yD/9m4AuXqtiIsU++xSrbKtzU6b4lrbn5ndzhf70nPKxs5gRHdMTNvg30VhJIvrSx+ ESLe4U0Ls5I2Cg1QT4NxpPF8a6lSWXdZT9SeldS+soEOY6Y/OibdHpiKHEAdVTJsQDyF pSfSkTmNvrpZbN/A5mKAthyp2NAvC6BCHzSAMY1kfHLz43oWlXUGamU9ck6XMyCFbodF o+M7nCKx8ZsJXxUUDAZ94NXh+q7l7LxZ9tfA+GK4XWGzz5bPr+/3slEkRAPtAsolQhV+ EtlTFDgMtalDmYzskqI43tPebvTEVz59XhCH7d4TA1usV+861p66SwmNJWxhvBrIGdvN B1+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N71k2Qgd; 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 l1-20020a056a0016c100b004f3bc62a693sor10425490pfc.66.2022.03.03.08.38.16 for (Google Transport Security); Thu, 03 Mar 2022 08:38:16 -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:a05:6a00:23d4:b0:4c9:f1b6:8e97 with SMTP id g20-20020a056a0023d400b004c9f1b68e97mr38751714pfc.27.1646325496017; Thu, 03 Mar 2022 08:38:16 -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.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:38:15 -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 5/6] drm: exynos: dsi: Convert to bridge driver Date: Thu, 3 Mar 2022 22:06:53 +0530 Message-Id: <20220303163654.3381470-6-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=N71k2Qgd; 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 Acked-by: Marek Szyprowski Tested-by: Marek Szyprowski --- Changes for v6, 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 953094133ed8..59a4f7f52180 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -251,7 +251,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; @@ -282,9 +282,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 { @@ -1358,10 +1358,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) @@ -1374,63 +1373,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); @@ -1453,8 +1453,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. @@ -1493,13 +1494,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; } @@ -1583,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; @@ -1596,9 +1596,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); } @@ -1621,7 +1620,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; @@ -1689,6 +1687,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;