From patchwork Fri Mar 4 15:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12769320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEF24C433F5 for ; Fri, 4 Mar 2022 15:18:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AAEEA10FD7F; Fri, 4 Mar 2022 15:18:35 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F5D110FD74 for ; Fri, 4 Mar 2022 15:18:34 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id e24so183062wrc.10 for ; Fri, 04 Mar 2022 07:18:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=glR9JQYYRBPEgy2tXaGq1LuTK3dY0m0s7CnJOVhH8VM=; b=sm/dxW4bSFIs9SffLaGb1/eGZCYXCqBPaX3UE9X1lO/qKrr0rrBkKuGelKKNwQwxvZ KJiT/uTrbcfsqse5aW4l5B+QpLjT5NKdxPtIRcoEYWsvQHIIbuFA/d30cVcYFYd3gFIc Fm3x9A8Yb5vLOCWs+vTgBTZzY/8R8uaU4qgcb55Krop8JHqlr0PIk9ft4W01nb2BTYNg i/e+iVX4+eKV2NSRU67KzBkSUBUSe2M+YcSakRoejPGyMJI21BAFt7Qr1tZoI59ePJkg F0HyGlcC3kBlFaghBuQI3vgYrx8ZLP1ABXJsiNjkcD7rPSq/BQEs95gZhon87DnnBqTM G8qA== 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:in-reply-to:references; bh=glR9JQYYRBPEgy2tXaGq1LuTK3dY0m0s7CnJOVhH8VM=; b=01eSxdMXxCfNYQTYSeZipdolv4QkYKaTC1cQDsytfZKQOcOxPjF0+9o7F/aSt/9rnf cc1zITPMgyMObEKGYk0Q19llza6Uh+DVbQQdVPJb4uOFT+wXeNyW3OD+5XpM56E23pUm rsrSNKLjc7ogif3s38BqGkdVMEOzMSIfLuCmSKpBDne+olNwW7pQgsWyzmIiT/rJoGKQ atEONf5/gfbk2nS7dAwZK2OmyrBnCpFHolrHXeznizmAEi1oqnBsR/QkTJQqlC3iEEAv jxlH8yyMehncic5JIHrkkLv/qyLgqCyWHrpAQ1KAjAxHqj8CxyzFyUUA4m0tw9OyH8DX TvDA== X-Gm-Message-State: AOAM533wVFXKFgmt8Zz4FEjyBF45ztK1oAzd6xJtSIVYG2U4PpafHfDD mirNMkoNodXKpmO70SB9OOpPfA== X-Google-Smtp-Source: ABdhPJz8P84dbixxhWn7/NsEX2HNwr+tC9jl3V/UD4g3TX9ANK+vDn0N9KgEQtM2u8Ypn8K+P8ZCOA== X-Received: by 2002:adf:f804:0:b0:1f0:326e:5e78 with SMTP id s4-20020adff804000000b001f0326e5e78mr9974146wrp.251.1646407112503; Fri, 04 Mar 2022 07:18:32 -0800 (PST) Received: from dave-VirtualBox.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id r13-20020a5d498d000000b001f0587248c4sm4409711wrq.3.2022.03.04.07.18.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2022 07:18:31 -0800 (PST) From: Dave Stevenson To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH V2 1/4] drm/bridge: Remove duplication from drm_bridge and drm_atomic_bridge chains Date: Fri, 4 Mar 2022 15:17:56 +0000 Message-Id: <67888b7a05a896c8b9b0f15bd81ef614d082dc9f.1646406653.git.dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: 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: Marek Vasut , Jonas Karlman , Robert Foss , Neil Armstrong , Douglas Anderson , Jernej Skrabec , andrzej.hajda@gmail.com, Laurent Pinchart , Andrzej Hajda , Dmitry Baryshkov , Dave Stevenson , Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_bridge_chain_pre_enable is a subset of drm_atomic_bridge_chain_pre_enable, and drm_bridge_chain_post_disable is a subset of drm_atomic_bridge_chain_post_disable. Change drm_bridge_chain_pre_enable and drm_bridge_chain_post_disable to call the atomic versions with a NULL state, and ensure that atomic calls are not made if there is no state. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/drm_bridge.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index c96847fc0ebc..198fd471a488 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -527,16 +527,7 @@ EXPORT_SYMBOL(drm_bridge_chain_disable); */ void drm_bridge_chain_post_disable(struct drm_bridge *bridge) { - struct drm_encoder *encoder; - - if (!bridge) - return; - - encoder = bridge->encoder; - list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { - if (bridge->funcs->post_disable) - bridge->funcs->post_disable(bridge); - } + drm_atomic_bridge_chain_post_disable(bridge, NULL); } EXPORT_SYMBOL(drm_bridge_chain_post_disable); @@ -582,20 +573,7 @@ EXPORT_SYMBOL(drm_bridge_chain_mode_set); */ void drm_bridge_chain_pre_enable(struct drm_bridge *bridge) { - struct drm_encoder *encoder; - struct drm_bridge *iter; - - if (!bridge) - return; - - encoder = bridge->encoder; - list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { - if (iter->funcs->pre_enable) - iter->funcs->pre_enable(iter); - - if (iter == bridge) - break; - } + drm_atomic_bridge_chain_pre_enable(bridge, NULL); } EXPORT_SYMBOL(drm_bridge_chain_pre_enable); @@ -690,7 +668,7 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, encoder = bridge->encoder; list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { - if (bridge->funcs->atomic_post_disable) { + if (old_state && bridge->funcs->atomic_post_disable) { struct drm_bridge_state *old_bridge_state; old_bridge_state = @@ -732,7 +710,7 @@ void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, encoder = bridge->encoder; list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { - if (iter->funcs->atomic_pre_enable) { + if (old_state && iter->funcs->atomic_pre_enable) { struct drm_bridge_state *old_bridge_state; old_bridge_state = From patchwork Fri Mar 4 15:17:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12769321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CE56C433F5 for ; Fri, 4 Mar 2022 15:18:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1DB610FEFD; Fri, 4 Mar 2022 15:18:42 +0000 (UTC) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF24310FEC1 for ; Fri, 4 Mar 2022 15:18:41 +0000 (UTC) Received: by mail-wr1-x433.google.com with SMTP id u1so13137844wrg.11 for ; Fri, 04 Mar 2022 07:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=LRw1kOuLW7vbLY523kmCpuiGHmdgKZXnbTS2wneH8y0=; b=Q65/j41OHj8wXaogWMZh2RkEod2+63BawOQgHBkLbhj/IcFAuCQeiRzopL0jhvMWzk HQS5Zd54Z33sOeoB/Dh+r4981R6/Z3LUmKXb7n91wGECd5roZfM2MhP1K7pt9AfSMA0I aYy6nhhNMV1T4eSOy8Q3ceEz/vOdPfnUr7L8LEqqVoHI9wvmdqafQ5B3CprOsirKF+2N ZDVBI2Ms+t4QkJMpHOfpk9AsB7Jh4XP966PuRMKGdwQlvY+nU0CuzB4BktUKheVQvG7/ 4j6/mi31AlX2HLEWmGhNfMwgNWstWdl9p9UER9YBZ6QXD5UQXSSebSHrZagA48R1sBH4 5BHQ== 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:in-reply-to:references; bh=LRw1kOuLW7vbLY523kmCpuiGHmdgKZXnbTS2wneH8y0=; b=JqXlqYt4+I3nWgZC58OqqgvyM2bH0XOzm4bkbz/ReOfruRiBoi5h93REYxCQvRWyMR HOdFAQvsHT/DgxM4KNvvnhPqrFkCr+9AoY5lMRuFaxZ/u+91XED0VYNCa/f7Xv12q7q3 4cYNZB/2BSAE9fDv8fYTqp8pH0/d+Yzop2wiy4eNyO6cSkj43gLq2wMY5bMsGqINhzr8 FFlq80Lu/YuIHHoXBW5XX3KTriNS0KMPPez8mAC+/VaLzEjFCnCp1HqapMz6OCukgvCy W3y58cyJ4fgMVoAv/nTFr5nLOGeICgcTq26sFzyUAasbgnhOPqn4Vy7dPc9zKOe1IyhN H0dg== X-Gm-Message-State: AOAM533ANJXZKaFqrGqA0IAkLiTrXDy8zm4Bkbr4CdnCKvksjp6lf76o ubOUX1Jy7ah6GhT4s5S3GEbVOA== X-Google-Smtp-Source: ABdhPJweUj4LzJ6in8KjbsMpvJ1r339BDdH7F6AhnTIrjv0tpO/at/w//6oqIAnLkxX6v7I88y8RmA== X-Received: by 2002:adf:ea4a:0:b0:1f0:6501:80f7 with SMTP id j10-20020adfea4a000000b001f0650180f7mr4040481wrn.306.1646407120342; Fri, 04 Mar 2022 07:18:40 -0800 (PST) Received: from dave-VirtualBox.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id r13-20020a5d498d000000b001f0587248c4sm4409711wrq.3.2022.03.04.07.18.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2022 07:18:39 -0800 (PST) From: Dave Stevenson To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH V2 2/4] drm/bridge: Introduce pre_enable_upstream_first to alter bridge init order Date: Fri, 4 Mar 2022 15:17:57 +0000 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: 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: Marek Vasut , Jonas Karlman , Robert Foss , Neil Armstrong , Douglas Anderson , Jernej Skrabec , andrzej.hajda@gmail.com, Laurent Pinchart , Andrzej Hajda , Dmitry Baryshkov , Dave Stevenson , Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" DSI sink devices typically want the DSI host powered up and configured before they are powered up. pre_enable is the place this would normally happen, but they are called in reverse order from panel/connector towards the encoder, which is the "wrong" order. Add a new flag pre_enable_upstream_first that any bridge can set to swap the order of pre_enable (and post_disable) for that and the immediately upstream bridge. Should the immediately upstream bridge also set the pre_enable_upstream_first flag, the bridge upstream of that will be called before either of those which requested pre_enable_upstream_first. eg: - Panel - Bridge 1 - Bridge 2 pre_enable_upstream_first - Bridge 3 - Bridge 4 pre_enable_upstream_first - Bridge 5 pre_enable_upstream_first - Bridge 6 - Encoder Would result in pre_enable's being called as Panel, Bridge 1, Bridge 3, Bridge 2, Bridge 6, Bridge 5, Bridge 4, Encoder. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/drm_bridge.c | 116 +++++++++++++++++++++++++++++++++---------- include/drm/drm_bridge.h | 8 +++ 2 files changed, 98 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 198fd471a488..70b513f5ce0d 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -523,6 +523,10 @@ EXPORT_SYMBOL(drm_bridge_chain_disable); * encoder chain, starting from the first bridge to the last. These are called * after completing the encoder's prepare op. * + * If a bridge sets @pre_enable_upstream_first, then the @post_disable for that + * bridge will be called before the previous one to reverse the @pre_enable + * calling direction. + * * Note: the bridge passed should be the one closest to the encoder */ void drm_bridge_chain_post_disable(struct drm_bridge *bridge) @@ -569,6 +573,9 @@ EXPORT_SYMBOL(drm_bridge_chain_mode_set); * chain, starting from the last bridge to the first. These are called * before calling the encoder's commit op. * + * If a bridge sets @pre_enable_upstream_first, then the @pre_enable for the + * previous bridge will be called before @pre_enable of this bridge. + * * Note: the bridge passed should be the one closest to the encoder */ void drm_bridge_chain_pre_enable(struct drm_bridge *bridge) @@ -645,6 +652,25 @@ void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, } EXPORT_SYMBOL(drm_atomic_bridge_chain_disable); +static void drm_atomic_bridge_call_post_disable(struct drm_bridge *bridge, + struct drm_atomic_state *old_state) +{ + if (old_state && bridge->funcs->atomic_post_disable) { + struct drm_bridge_state *old_bridge_state; + + old_bridge_state = + drm_atomic_get_old_bridge_state(old_state, + bridge); + if (WARN_ON(!old_bridge_state)) + return; + + bridge->funcs->atomic_post_disable(bridge, + old_bridge_state); + } else if (bridge->funcs->post_disable) { + bridge->funcs->post_disable(bridge); + } +} + /** * drm_atomic_bridge_chain_post_disable - cleans up after disabling all bridges * in the encoder chain @@ -655,6 +681,9 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_disable); * &drm_bridge_funcs.post_disable) op for all the bridges in the encoder chain, * starting from the first bridge to the last. These are called after completing * &drm_encoder_helper_funcs.atomic_disable + * If a bridge sets @pre_enable_upstream_first, then the @post_disable for that + * bridge will be called before the previous one to reverse the @pre_enable + * calling direction. * * Note: the bridge passed should be the one closest to the encoder */ @@ -662,30 +691,55 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, struct drm_atomic_state *old_state) { struct drm_encoder *encoder; + struct drm_bridge *prev, *tmp; if (!bridge) return; encoder = bridge->encoder; - list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { - if (old_state && bridge->funcs->atomic_post_disable) { - struct drm_bridge_state *old_bridge_state; - old_bridge_state = - drm_atomic_get_old_bridge_state(old_state, - bridge); - if (WARN_ON(!old_bridge_state)) - return; + list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { + if (!list_is_last(&bridge->chain_node, &encoder->bridge_chain) && + list_next_entry(bridge, chain_node)->pre_enable_upstream_first) + /* Skip bridges where the downstream bridge wanted + * pre_enable after / post_disable before the upstream + * bridge. + */ + continue; - bridge->funcs->atomic_post_disable(bridge, - old_bridge_state); - } else if (bridge->funcs->post_disable) { - bridge->funcs->post_disable(bridge); - } + /* Call this bridge and any skipped ones in reverse order */ + tmp = bridge; + do { + prev = tmp; + drm_atomic_bridge_call_post_disable(tmp, old_state); + if (tmp == list_first_entry(&encoder->bridge_chain, + struct drm_bridge, chain_node)) + tmp = NULL; + else + tmp = list_prev_entry(tmp, chain_node); + } while (tmp && prev->pre_enable_upstream_first); } } EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable); +static void drm_atomic_bridge_call_pre_enable(struct drm_bridge *bridge, + struct drm_atomic_state *old_state) +{ + if (old_state && bridge->funcs->atomic_pre_enable) { + struct drm_bridge_state *old_bridge_state; + + old_bridge_state = + drm_atomic_get_old_bridge_state(old_state, + bridge); + if (WARN_ON(!old_bridge_state)) + return; + + bridge->funcs->atomic_pre_enable(bridge, old_bridge_state); + } else if (bridge->funcs->pre_enable) { + bridge->funcs->pre_enable(bridge); + } +} + /** * drm_atomic_bridge_chain_pre_enable - prepares for enabling all bridges in * the encoder chain @@ -697,32 +751,42 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable); * starting from the last bridge to the first. These are called before calling * &drm_encoder_helper_funcs.atomic_enable * + * If a bridge sets @pre_enable_upstream_first, then the pre_enable for the + * upstream bridge will be called before pre_enable of this bridge. + * * Note: the bridge passed should be the one closest to the encoder */ void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, struct drm_atomic_state *old_state) { struct drm_encoder *encoder; - struct drm_bridge *iter; + struct drm_bridge *iter, *tmp; if (!bridge) return; encoder = bridge->encoder; - list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { - if (old_state && iter->funcs->atomic_pre_enable) { - struct drm_bridge_state *old_bridge_state; - old_bridge_state = - drm_atomic_get_old_bridge_state(old_state, - iter); - if (WARN_ON(!old_bridge_state)) - return; + list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { + if (iter->pre_enable_upstream_first && iter != bridge) + /* Skip bridges which want the upstream pre_enable + * called before their pre_enable. + */ + continue; - iter->funcs->atomic_pre_enable(iter, old_bridge_state); - } else if (iter->funcs->pre_enable) { - iter->funcs->pre_enable(iter); - } + tmp = iter; + do { + /* Work forward through the current bridge, and any + * that had been skipped. + */ + drm_atomic_bridge_call_pre_enable(tmp, old_state); + if (tmp == list_last_entry(&encoder->bridge_chain, + struct drm_bridge, + chain_node)) + tmp = NULL; + else + tmp = list_next_entry(tmp, chain_node); + } while (tmp && tmp->pre_enable_upstream_first); if (iter == bridge) break; diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index f27b4060faa2..cf1fb3ad7054 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -769,6 +769,14 @@ struct drm_bridge { */ bool interlace_allowed; /** + * @pre_enable_upstream_first: The bridge requires that the upstream + * bridge @pre_enable function is called before its @pre_enable, + * and conversely for post_disable. This is most frequently a + * requirement for DSI devices which need the host to be initialised + * before the peripheral. + */ + bool pre_enable_upstream_first; + /** * @ddc: Associated I2C adapter for DDC access, if any. */ struct i2c_adapter *ddc; From patchwork Fri Mar 4 15:17:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12769322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E997C433EF for ; Fri, 4 Mar 2022 15:18:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E95CA10FF0D; Fri, 4 Mar 2022 15:18:46 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC12210FF0C for ; Fri, 4 Mar 2022 15:18:45 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id i8so13148492wrr.8 for ; Fri, 04 Mar 2022 07:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Oi/LHO8R88coh5oofTByzBlQgewaBXVn5ghgyo5mAuc=; b=XkOb0p3aN2aKjdAFuyZ/GCfeH9aPhQ3GIbTsSnNo3vq8AvEI+NNWjW425LW84jQ6xG n/FYts0y44jh6T6VBHiQJjrACxa13vAmPtJ2PeMeicMR+v744GZeq+KtsjvG0/7vbXMf tGJFfuFFObcBLSQl8kFbQMvKU/im9ZNW5UJOx1XfT24SNl5FqdIB7fxC77dsiBgFb3q3 rhthKViK2zq/YCto2GtWVLQaYeb4It5tMGnTzRNzsiNqcV+A7F5UeC6nqGLjqb5WOWTc aFVjDlerqkUsPRPHAP6apzawU6S2cp2NHGEA58CxUXgijP5r7Z1KVrUVlg27ZfKsyg9I VDIQ== 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:in-reply-to:references; bh=Oi/LHO8R88coh5oofTByzBlQgewaBXVn5ghgyo5mAuc=; b=cmaYrW8B1Qrt4LXv1+nJLHmxA6RukSeKjdBd2uPBggOnB6FPGKCGkJPs05pD1eLkhV G160/IdKMGMJzSPKwBKIdDNVShnQDhCDNHcVl8t6KOM/YkfFmsnhChwzzs+UrKZVjtyq Aw0VgdWsyFNwqqaWhVSIZbet1OF0Lsnw2JdBNGtvITeJWyN0wb4EC7I61p7iLZdkaXYM k8OPKvX8aSmAM1HnuwF+jVF1jePckGIQwPlGceOINAX3uHuio5z+FoM+eBs4WAPdxC1+ Ji0LVkhmMbaKrqOMQhn2HT4DgCow3EWai9O61+ubB3GBdwIvtbgmIE3vdcVqwSG8OQt7 h5pQ== X-Gm-Message-State: AOAM531pQkrz+HOvvDmxB5OThWsz9KLuK9rMtmwNYQldQ4cxJx37IIr6 cA69aTzwms24JGd+CEVN7cptfg== X-Google-Smtp-Source: ABdhPJxhXtJMGNHrWXXAdGFF0BsEwrV0IdqoU3ohtNpCs8sMchpPktwGbE/O+LWquGbLejhaHu/qIw== X-Received: by 2002:adf:aac6:0:b0:1f0:6848:54a3 with SMTP id i6-20020adfaac6000000b001f0684854a3mr3512725wrc.611.1646407124171; Fri, 04 Mar 2022 07:18:44 -0800 (PST) Received: from dave-VirtualBox.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id r13-20020a5d498d000000b001f0587248c4sm4409711wrq.3.2022.03.04.07.18.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2022 07:18:42 -0800 (PST) From: Dave Stevenson To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH V2 3/4] drm/panel: Add prepare_upstream_first flag to drm_panel Date: Fri, 4 Mar 2022 15:17:58 +0000 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: 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: Marek Vasut , Jonas Karlman , Robert Foss , Neil Armstrong , Douglas Anderson , Jernej Skrabec , andrzej.hajda@gmail.com, Laurent Pinchart , Andrzej Hajda , Dmitry Baryshkov , Dave Stevenson , Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Mapping to the drm_bridge flag pre_enable_upstream_first, add a new flag prepare_upstream_first to drm_panel to allow the panel driver to request that the upstream bridge should be pre_enabled before the panel prepare. Signed-off-by: Dave Stevenson Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/panel.c | 3 +++ include/drm/drm_panel.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 5be057575183..2ea08b3ba326 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -234,6 +234,9 @@ struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, panel_bridge->bridge.ops = DRM_BRIDGE_OP_MODES; panel_bridge->bridge.type = connector_type; + panel_bridge->bridge.pre_enable_upstream_first = + panel->prepare_upstream_first; + drm_bridge_add(&panel_bridge->bridge); return &panel_bridge->bridge; diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 1ba2d424a53f..c0f39dfbd071 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -179,6 +179,16 @@ struct drm_panel { * Panel entry in registry. */ struct list_head list; + + /** + * @prepare_upstream_first: + * + * The upstream controller should be prepared first, before the prepare + * for the panel is called. This is largely required for DSI panels + * where the DSI host controller should be initialised to LP-11 before + * the panel is powered up. + */ + bool prepare_upstream_first; }; void drm_panel_init(struct drm_panel *panel, struct device *dev, From patchwork Fri Mar 4 15:17:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12769323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BBEBC433F5 for ; Fri, 4 Mar 2022 15:18:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10ACB10FEBA; Fri, 4 Mar 2022 15:18:53 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D8F110FF0A for ; Fri, 4 Mar 2022 15:18:51 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id u10so11536793wra.9 for ; Fri, 04 Mar 2022 07:18:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/kLVO2mBjUg6ZEMThkrlP90TKZ1i1rq899x9t4LqlHM=; b=YALkyOAgCyJenPehbHsY90BofCy7G+amhHgULqRd/Ya1Hh8x8u7a9EppgJ4p/YNU/D nRuYTUWj3rnIBnuKO2+a6Kz/905FgrK08w/aKOcN9aRbB6lGZr3auUbLBEzqngMpNJOW 9+0ISLqQUTiphuL5d8b2CKgp6jLZpU0NB7CkCOJ3T/wfOFp5HU7DTMoiD1avKpAqLTT8 9OZ196Jz/mA50PiVKVTYxfvmForez6/pYJhMgU9l0wB5iirXmCuWuNDSvpyl6yoHgOBs DOC6255ugbau+MFveWfr9Z7ARAwwfCYSPFaKwcKvskVCWVQRcaaS9zhMW600Bq0h/VLA OiLg== 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:in-reply-to:references; bh=/kLVO2mBjUg6ZEMThkrlP90TKZ1i1rq899x9t4LqlHM=; b=elRYZSG408Z7LZu9errMe2NwrIAOGAQDeinqjd9djSzlNSexGLaVwmE7MZhklGO/UA /utH7IAdXAywPQi9i16ys5INYO/X3KuzuJ6TYhvsLg/Akt9NVpgvLvcrMNJ3mvkrny37 s5JO8aNcEWWemMwghJvRWd/ZM84jGAnE4bTWMXNyY89tI/cRojgr11W6qla1mr1SyvhC sTvmB3I9EhOL4/yqBV+7AHZ/i8pH/WPMJtz1DRribH96O1sN2iFkvWlyKfHU6WVKEMv6 3XG2uwHjZu6iEqssIW5RSJv9D0GNWSIC7DN+bdO6f2zIFcBH2IVsDVVZ2/2GXie7kSW7 +3nw== X-Gm-Message-State: AOAM5331rAuqlUytS46rlQ3D3vxb4l9n8A3SWwXwmI1K+pUzJf1WHOMb 7Q3t2Etxw5Z6JILeNoglcXQwAA== X-Google-Smtp-Source: ABdhPJxUvSN8wQ2WYUsQkxnb2Z8PYEhtCZSsHl89UOevi9ytxpI3iSl9byguTIFTfFug3ItOOu9OEg== X-Received: by 2002:adf:902c:0:b0:1f0:4a72:feff with SMTP id h41-20020adf902c000000b001f04a72feffmr7481618wrh.190.1646407129660; Fri, 04 Mar 2022 07:18:49 -0800 (PST) Received: from dave-VirtualBox.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id r13-20020a5d498d000000b001f0587248c4sm4409711wrq.3.2022.03.04.07.18.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2022 07:18:48 -0800 (PST) From: Dave Stevenson To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH V2 4/4] drm/bridge: Document the expected behaviour of DSI host controllers Date: Fri, 4 Mar 2022 15:17:59 +0000 Message-Id: <41b8b82299dfa30962f98adc2fc43c1787df5598.1646406653.git.dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: 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: Marek Vasut , Jonas Karlman , Robert Foss , Neil Armstrong , Douglas Anderson , Jernej Skrabec , andrzej.hajda@gmail.com, Laurent Pinchart , Andrzej Hajda , Dmitry Baryshkov , Dave Stevenson , Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The exact behaviour of DSI host controllers is not specified, therefore define it. Signed-off-by: Dave Stevenson Reviewed-by: Laurent Pinchart --- Documentation/gpu/drm-kms-helpers.rst | 7 +++++++ drivers/gpu/drm/drm_bridge.c | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Documentation/gpu/drm-kms-helpers.rst b/Documentation/gpu/drm-kms-helpers.rst index c3ce91eecbc1..362afdb867c6 100644 --- a/Documentation/gpu/drm-kms-helpers.rst +++ b/Documentation/gpu/drm-kms-helpers.rst @@ -185,6 +185,13 @@ Bridge Helper Reference .. kernel-doc:: drivers/gpu/drm/drm_bridge.c :export: +MIPI-DSI bridge operation +------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_bridge.c + :doc: dsi bridge operations + + Bridge Connector Helper Reference --------------------------------- diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 70b513f5ce0d..32def1be682a 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -152,6 +152,45 @@ * situation when probing. */ +/** + * DOC: dsi bridge operations + * + * DSI host interfaces are expected to be implemented as bridges rather than + * encoders, however there are a few aspects of their operation that need to + * be defined in order to provide a consistent interface. + * + * A DSI host should keep the PHY powered down until the pre_enable operation is + * called. All lanes are in an undefined idle state up to this point, and it + * must not be assumed that it is LP-11. + * pre_enable should initialise the PHY, set the data lanes to LP-11, and the + * clock lane to either LP-11 or HS depending on the mode_flag + * %MIPI_DSI_CLOCK_NON_CONTINUOUS. + * + * Ordinarily the downstream bridge DSI peripheral pre_enable will have been + * called before the DSI host. If the DSI peripheral requires LP-11 and/or + * the clock lane to be in HS mode prior to pre_enable, then it can set the + * &pre_enable_upstream_first flag to request the pre_enable (and + * post_disable) order to be altered to enable the DSI host first. + * + * Either the CRTC being enabled, or the DSI host enable operation should switch + * the host to actively transmitting video on the data lanes. + * + * The reverse also applies. The DSI host disable operation or stopping the CRTC + * should stop transmitting video, and the data lanes should return to the LP-11 + * state. The DSI host &post_disable operation should disable the PHY. + * If the &pre_enable_upstream_first flag is set, then the DSI peripheral's + * bridge &post_disable will be called before the DSI host's post_disable. + * + * Whilst it is valid to call &host_transfer prior to pre_enable or after + * post_disable, the exact state of the lanes is undefined at this point. The + * DSI host should initialise the interface, transmit the data, and then disable + * the interface again. + * + * Ultra Low Power State (ULPS) is not explicitly supported by DRM. If + * implemented, it therefore needs to be handled entirely within the DSI Host + * driver. + */ + static DEFINE_MUTEX(bridge_lock); static LIST_HEAD(bridge_list);