From patchwork Wed Sep 30 11:40:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 313891 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:1081:0:0:0:0 with SMTP id r1csp110861ilj; Wed, 30 Sep 2020 04:40:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+siaFhlavBCKFM8HhPY2tRZntL/gdpuMY5ts2o1TdJC5LP877Y4wNnW6h06S1AegZZ202 X-Received: by 2002:a17:90a:1903:: with SMTP id 3mr2233871pjg.74.1601466057393; Wed, 30 Sep 2020 04:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601466057; cv=none; d=google.com; s=arc-20160816; b=zyfeITlDZwMcXAr6sotEsf8/5uQIyrdnZ7YXa1X9EidYDO7cWcA//a2ki9w9NwKfx3 9YDJE6kYT1mMiBflPxw0iOqRQu/9faD4/+0/AeaXarK8KU1Pj5zzAo6KVdi3Al+2pLgJ GpED7QHxw2wdpscy+8XpdrCHgzLHQMYnm4coosZvUioacjiLRfJ+cbZPciOgG4SyIaSt DW3fApvxnd0k9dC19MRZa5RlqokHLLs5CT7PJiQWJTF/jFLHoO4XhWaQx5Pw0TLzNlml TeLR9t93h2TegRNu3NUV88w0dXjeD+23xRc+Ltcz0M6kqdmyoutLaLuIQRdrQ0d0WEKQ rz8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:cms-type:message-id:date:subject:to :from:dkim-signature:dkim-filter:delivered-to; bh=Hl9kIInvzRF3qGet+QQyi1X6bNVqU8uaZfQrNWGqjQA=; b=rkQYoi6cGYUPfkhRlBjwPpCYjln3yjEs8gK5G/w4YoYTfR8RLc8KJoI2wIXMK1r7T0 IJhElwOLS2UhhOCHBdGBOlpp6F5bK4w9QZ1di47svfmjVS0gpSL14Fxdw+uh+IjcfAEm O0dDTi6qjS+21ZUQs89MYCkHavcSdV9xhyx1d8uHfBicmsiXrebRY8vpQkhodgFheFPA +ivu4g4MZYwkH+QS91aG5i/Y6a/Sim9Gvu7UmNf/KT8cO4dJ3aczYsOfEEU+zZXPpn1P zvuY5ItaOyqfimCpTe6gC3NYXRvNdhEhO3WaZrzXaRT1mbOfobc2azI4VlzTCi8Y3V5r t9Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b="b7UET/pg"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id o28si1000982pgl.75.2020.09.30.04.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 04:40:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b="b7UET/pg"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3C9689907; Wed, 30 Sep 2020 11:40:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7AE389907 for ; Wed, 30 Sep 2020 11:40:52 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200930114051euoutp011aa61c6a4654fd0ef8bc05bceed7ac68~5jON5A8Co1064410644euoutp010 for ; Wed, 30 Sep 2020 11:40:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200930114051euoutp011aa61c6a4654fd0ef8bc05bceed7ac68~5jON5A8Co1064410644euoutp010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601466051; bh=2TmK0Cd2dcSjEXv4p3j4u0LUwJ5ah0OK12YGNxuOZKs=; h=From:To:Cc:Subject:Date:References:From; b=b7UET/pgRcwPwe9osf3BN7PYSippSgIBv3wjn3jp9E4xBxH9TiswGNtSeurbixWh0 bHnjXGkdlipa33PmQs1jPIQu130TzZRWE7Xejg4wvqGj6BNRbleXmEOhHqTaNWkVkE RCMcfRFDlSz9FJqzhEMmfIHLaQt8dWNa47xLX75w= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200930114050eucas1p253e6bb99c55b23d7e23ee7e47068eddd~5jONi5pZ22053920539eucas1p2u; Wed, 30 Sep 2020 11:40:50 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 52.35.05997.2CE647F5; Wed, 30 Sep 2020 12:40:50 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200930114050eucas1p2fd39f213b4cf82068b79c97992a9acc7~5jOM_Kj8T2053920539eucas1p2t; Wed, 30 Sep 2020 11:40:50 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200930114050eusmtrp2dbf62baaf4a76d1d8c4378b53f17c14b~5jOM9XYDf3088230882eusmtrp2D; Wed, 30 Sep 2020 11:40:50 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-ed-5f746ec2195e Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id E2.5A.06314.1CE647F5; Wed, 30 Sep 2020 12:40:50 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200930114049eusmtip213d9a422c8f9f21b008628d18f0fab22~5jOMWPT_T2020420204eusmtip2G; Wed, 30 Sep 2020 11:40:49 +0000 (GMT) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH RESEND] drm/bridge: tc358764: restore connector support Date: Wed, 30 Sep 2020 13:40:42 +0200 Message-Id: <20200930114042.5806-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA0VSe0gTcRzvd7fdzuHimpa/tCwWJQZqVsiBFr2wI/+JKILC5sxLLTdtNy0H lq20udSs8NHsxdJ8peYwUyHT+Zg6NkVnTCkkE01TpJyIPbTNU/vv8+Tz/eOLo8JMriceK1PQ cpkkToTxOXUdCz1+BplCvKf6oy85VGXhkta5GYwcmJ9Aya6pAQ6Z8aCIR/Y3PsHIgp4mhKxs +8wjDdnnydKFt+AQn5qxpfGoQvVjLtWZ04dQw/eMCFWUN4BR2bXlgGrOesShZvXeJ/Fz/JAo Oi42iZYHHIzgx5jHm7AEXdD1r3qfVGDw0wAXHBL7YeuYhaMBfFxIlAI4OWhCWGIHUJfftUJm AdQvZWOrlU77S5Q1SgAsM9dw1iq95SM8ZwojAqFmWrP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kCiOF2JNLCuuzD3EKMHBrCTC63T2dJwQb0piZVVqUX58UWlOavEhRlOg5ROZpUST84GRBYwe Q1NDcwtLQ3Njc2MzCyVx3g6BgzFCAumJJanZqakFqUUwfUwcnFINjM41Bs8WVUVeXi6Zs1p8 0vVkNRaFy8GaBwq78u9c/G3+1KH/evaKlV/bJmjqppyZNoux1rT7euZkV37G/QtWiZ9K/MK/ IXrDammJRh7l+Yqs9+Wur7h1wNuOd61KfNS/zRbaK87qN7ivYW9aueBFhLFtmU1vWu+75/GK ue5L2zdpF7AlWwhLKrEUZyQaajEXFScCABuioW50AgAA X-CMS-MailID: 20200930114050eucas1p2fd39f213b4cf82068b79c97992a9acc7 X-Msg-Generator: CA X-RootMTR: 20200930114050eucas1p2fd39f213b4cf82068b79c97992a9acc7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200930114050eucas1p2fd39f213b4cf82068b79c97992a9acc7 References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , Jonas Karlman , Neil Armstrong , linux-kernel@vger.kernel.org, Andrzej Hajda , Laurent Pinchart , Sam Ravnborg , Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch restores DRM connector registration in the TC358764 bridge driver and restores usage of the old drm_panel_* API, thus allows dynamic panel registration. This fixes panel operation on Exynos5250-based Arndale board. This is equivalent to the revert of the following commits: 1644127f83bc "drm/bridge: tc358764: add drm_panel_bridge support" 385ca38da29c "drm/bridge: tc358764: drop drm_connector_(un)register" and removal of the calls to drm_panel_attach()/drm_panel_detach(), which were no-ops and has been removed in meanwhile. Signed-off-by: Marek Szyprowski Reviewed-by: Andrzej Hajda --- As I've reported and Andrzej Hajda pointed, the reverted patches break operation of the panel on the Arndale board. Noone suggested how to fix the regression, I've decided to send a revert until a new solution is found. The issues with tc358764 might be automatically resolved once the Exynos DSI itself is converted to DRM bridge: https://patchwork.kernel.org/cover/11770683/ but that approach has also its own issues so far. Resend reason: added Sam Ravnborg to CC: Best regards, Marek Szyprowski --- drivers/gpu/drm/bridge/tc358764.c | 107 +++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 15 deletions(-) -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/bridge/tc358764.c b/drivers/gpu/drm/bridge/tc358764.c index d89394bc5aa4..c1e35bdf9232 100644 --- a/drivers/gpu/drm/bridge/tc358764.c +++ b/drivers/gpu/drm/bridge/tc358764.c @@ -153,9 +153,10 @@ static const char * const tc358764_supplies[] = { struct tc358764 { struct device *dev; struct drm_bridge bridge; + struct drm_connector connector; struct regulator_bulk_data supplies[ARRAY_SIZE(tc358764_supplies)]; struct gpio_desc *gpio_reset; - struct drm_bridge *panel_bridge; + struct drm_panel *panel; int error; }; @@ -209,6 +210,12 @@ static inline struct tc358764 *bridge_to_tc358764(struct drm_bridge *bridge) return container_of(bridge, struct tc358764, bridge); } +static inline +struct tc358764 *connector_to_tc358764(struct drm_connector *connector) +{ + return container_of(connector, struct tc358764, connector); +} + static int tc358764_init(struct tc358764 *ctx) { u32 v = 0; @@ -271,11 +278,43 @@ static void tc358764_reset(struct tc358764 *ctx) usleep_range(1000, 2000); } +static int tc358764_get_modes(struct drm_connector *connector) +{ + struct tc358764 *ctx = connector_to_tc358764(connector); + + return drm_panel_get_modes(ctx->panel, connector); +} + +static const +struct drm_connector_helper_funcs tc358764_connector_helper_funcs = { + .get_modes = tc358764_get_modes, +}; + +static const struct drm_connector_funcs tc358764_connector_funcs = { + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static void tc358764_disable(struct drm_bridge *bridge) +{ + struct tc358764 *ctx = bridge_to_tc358764(bridge); + int ret = drm_panel_disable(bridge_to_tc358764(bridge)->panel); + + if (ret < 0) + dev_err(ctx->dev, "error disabling panel (%d)\n", ret); +} + static void tc358764_post_disable(struct drm_bridge *bridge) { struct tc358764 *ctx = bridge_to_tc358764(bridge); int ret; + ret = drm_panel_unprepare(ctx->panel); + if (ret < 0) + dev_err(ctx->dev, "error unpreparing panel (%d)\n", ret); tc358764_reset(ctx); usleep_range(10000, 15000); ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); @@ -296,28 +335,71 @@ static void tc358764_pre_enable(struct drm_bridge *bridge) ret = tc358764_init(ctx); if (ret < 0) dev_err(ctx->dev, "error initializing bridge (%d)\n", ret); + ret = drm_panel_prepare(ctx->panel); + if (ret < 0) + dev_err(ctx->dev, "error preparing panel (%d)\n", ret); +} + +static void tc358764_enable(struct drm_bridge *bridge) +{ + struct tc358764 *ctx = bridge_to_tc358764(bridge); + int ret = drm_panel_enable(ctx->panel); + + if (ret < 0) + dev_err(ctx->dev, "error enabling panel (%d)\n", ret); } static int tc358764_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) +{ + struct tc358764 *ctx = bridge_to_tc358764(bridge); + struct drm_device *drm = bridge->dev; + int ret; + + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { + DRM_ERROR("Fix bridge driver to make connector optional!"); + return -EINVAL; + } + + ctx->connector.polled = DRM_CONNECTOR_POLL_HPD; + ret = drm_connector_init(drm, &ctx->connector, + &tc358764_connector_funcs, + DRM_MODE_CONNECTOR_LVDS); + if (ret) { + DRM_ERROR("Failed to initialize connector\n"); + return ret; + } + + drm_connector_helper_add(&ctx->connector, + &tc358764_connector_helper_funcs); + drm_connector_attach_encoder(&ctx->connector, bridge->encoder); + ctx->connector.funcs->reset(&ctx->connector); + drm_connector_register(&ctx->connector); + + return 0; +} + +static void tc358764_detach(struct drm_bridge *bridge) { struct tc358764 *ctx = bridge_to_tc358764(bridge); - return drm_bridge_attach(bridge->encoder, ctx->panel_bridge, - bridge, flags); + drm_connector_unregister(&ctx->connector); + ctx->panel = NULL; + drm_connector_put(&ctx->connector); } static const struct drm_bridge_funcs tc358764_bridge_funcs = { + .disable = tc358764_disable, .post_disable = tc358764_post_disable, + .enable = tc358764_enable, .pre_enable = tc358764_pre_enable, .attach = tc358764_attach, + .detach = tc358764_detach, }; static int tc358764_parse_dt(struct tc358764 *ctx) { - struct drm_bridge *panel_bridge; struct device *dev = ctx->dev; - struct drm_panel *panel; int ret; ctx->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); @@ -326,16 +408,12 @@ static int tc358764_parse_dt(struct tc358764 *ctx) return PTR_ERR(ctx->gpio_reset); } - ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL); - if (ret) - return ret; - - panel_bridge = devm_drm_panel_bridge_add(dev, panel); - if (IS_ERR(panel_bridge)) - return PTR_ERR(panel_bridge); + ret = drm_of_find_panel_or_bridge(ctx->dev->of_node, 1, 0, &ctx->panel, + NULL); + if (ret && ret != -EPROBE_DEFER) + dev_err(dev, "cannot find panel (%d)\n", ret); - ctx->panel_bridge = panel_bridge; - return 0; + return ret; } static int tc358764_configure_regulators(struct tc358764 *ctx) @@ -381,7 +459,6 @@ static int tc358764_probe(struct mipi_dsi_device *dsi) return ret; ctx->bridge.funcs = &tc358764_bridge_funcs; - ctx->bridge.type = DRM_MODE_CONNECTOR_LVDS; ctx->bridge.of_node = dev->of_node; drm_bridge_add(&ctx->bridge);