From nobody Sun Sep 14 22:52:48 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEE0DC6FA82 for ; Tue, 13 Sep 2022 14:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231355AbiIMOrR (ORCPT ); Tue, 13 Sep 2022 10:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbiIMOoC (ORCPT ); Tue, 13 Sep 2022 10:44:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FA7661116; Tue, 13 Sep 2022 07:23:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BA87DB80F63; Tue, 13 Sep 2022 14:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23ED3C433D6; Tue, 13 Sep 2022 14:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078883; bh=yFnDgQPHh04lImNs9zxwG2wlMAoD+s2Zxc3+wS2Q0ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TqUrKfwYxW1RUDFEo/bf7ogC/Akxb7gt1JXEwJXtre0+GfUh8IlEBg6UUU4+rOnfD fXoUESyJX8Se0bnBgwN3N/S0RYgYCLKZD+fk3WDzPgI9qTGYU8P/eceNBUJdi4ylTX Znx/Vb/6pl01B/cp1EDzPA3LUn3BlqTgl417QBFQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Neil Armstrong , Sam Ravnborg , Stefan Agner Subject: [PATCH 5.15 119/121] drm/bridge: display-connector: implement bus fmts callbacks Date: Tue, 13 Sep 2022 16:05:10 +0200 Message-Id: <20220913140402.477899469@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Neil Armstrong commit 7cd70656d1285b79c001f041a017fcfee4292ff9 upstream. Since this bridge is tied to the connector, it acts like a passthrough, so concerning the output & input bus formats, either pass the bus formats f= rom the previous bridge or return fallback data like done in the bridge function: drm_atomic_bridge_chain_select_bus_fmts() & select_bus_fmt_recursive. This permits avoiding skipping the negociation if the remaining bridge chai= n has all the bits in place. Without this bus fmt negociation breaks on drm/meson HDMI pipeline when att= aching dw-hdmi with DRM_BRIDGE_ATTACH_NO_CONNECTOR, because the last bridge of the display-connector doesn't implement buf fmt callbacks and MEDIA_BUS_FMT_FIX= ED is used leading to select an unsupported default bus format from dw-hdmi. Signed-off-by: Neil Armstrong Reviewed-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20211020123947.2585572-= 2-narmstrong@baylibre.com Cc: Stefan Agner Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/bridge/display-connector.c | 86 ++++++++++++++++++++++++= +++++ 1 file changed, 86 insertions(+) --- a/drivers/gpu/drm/bridge/display-connector.c +++ b/drivers/gpu/drm/bridge/display-connector.c @@ -13,6 +13,7 @@ #include #include =20 +#include #include #include =20 @@ -87,10 +88,95 @@ static struct edid *display_connector_ge return drm_get_edid(connector, conn->bridge.ddc); } =20 +/* + * Since this bridge is tied to the connector, it acts like a passthrough, + * so concerning the output bus formats, either pass the bus formats from = the + * previous bridge or return fallback data like done in the bridge functio= n: + * drm_atomic_bridge_chain_select_bus_fmts(). + * This supports negotiation if the bridge chain has all bits in place. + */ +static u32 *display_connector_get_output_bus_fmts(struct drm_bridge *bridg= e, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + unsigned int *num_output_fmts) +{ + struct drm_bridge *prev_bridge =3D drm_bridge_get_prev_bridge(bridge); + struct drm_bridge_state *prev_bridge_state; + + if (!prev_bridge || !prev_bridge->funcs->atomic_get_output_bus_fmts) { + struct drm_connector *conn =3D conn_state->connector; + u32 *out_bus_fmts; + + *num_output_fmts =3D 1; + out_bus_fmts =3D kmalloc(sizeof(*out_bus_fmts), GFP_KERNEL); + if (!out_bus_fmts) + return NULL; + + if (conn->display_info.num_bus_formats && + conn->display_info.bus_formats) + out_bus_fmts[0] =3D conn->display_info.bus_formats[0]; + else + out_bus_fmts[0] =3D MEDIA_BUS_FMT_FIXED; + + return out_bus_fmts; + } + + prev_bridge_state =3D drm_atomic_get_new_bridge_state(crtc_state->state, + prev_bridge); + + return prev_bridge->funcs->atomic_get_output_bus_fmts(prev_bridge, prev_b= ridge_state, + crtc_state, conn_state, + num_output_fmts); +} + +/* + * Since this bridge is tied to the connector, it acts like a passthrough, + * so concerning the input bus formats, either pass the bus formats from t= he + * previous bridge or MEDIA_BUS_FMT_FIXED (like select_bus_fmt_recursive()) + * when atomic_get_input_bus_fmts is not supported. + * This supports negotiation if the bridge chain has all bits in place. + */ +static u32 *display_connector_get_input_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts) +{ + struct drm_bridge *prev_bridge =3D drm_bridge_get_prev_bridge(bridge); + struct drm_bridge_state *prev_bridge_state; + + if (!prev_bridge || !prev_bridge->funcs->atomic_get_input_bus_fmts) { + u32 *in_bus_fmts; + + *num_input_fmts =3D 1; + in_bus_fmts =3D kmalloc(sizeof(*in_bus_fmts), GFP_KERNEL); + if (!in_bus_fmts) + return NULL; + + in_bus_fmts[0] =3D MEDIA_BUS_FMT_FIXED; + + return in_bus_fmts; + } + + prev_bridge_state =3D drm_atomic_get_new_bridge_state(crtc_state->state, + prev_bridge); + + return prev_bridge->funcs->atomic_get_input_bus_fmts(prev_bridge, prev_br= idge_state, + crtc_state, conn_state, output_fmt, + num_input_fmts); +} + static const struct drm_bridge_funcs display_connector_bridge_funcs =3D { .attach =3D display_connector_attach, .detect =3D display_connector_detect, .get_edid =3D display_connector_get_edid, + .atomic_get_output_bus_fmts =3D display_connector_get_output_bus_fmts, + .atomic_get_input_bus_fmts =3D display_connector_get_input_bus_fmts, + .atomic_duplicate_state =3D drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state =3D drm_atomic_helper_bridge_destroy_state, + .atomic_reset =3D drm_atomic_helper_bridge_reset, }; =20 static irqreturn_t display_connector_hpd_irq(int irq, void *arg)