[PATCH 1/2] drm/bridge: dw-hdmi: filter safe formats when first in bridge chain

Neil Armstrong narmstrong at baylibre.com
Wed Jan 19 12:36:55 UTC 2022


If the dw-bridge is in the first position in the bridge chain, this
means there is no way to set the encoder output bus format.

In this case, this makes sure we only return the default format as return
of the get_input_bus_fmts() callback, limiting possible output formats
of dw-hdmi to what the dw-hdmi can convert from the default RGB24 input
format.

Fixes: 6c3c719936da ("drm/bridge: synopsys: dw-hdmi: add bus format negociation")
Signed-off-by: Neil Armstrong <narmstrong at baylibre.com>
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 97cdc61b57f6..56021f20d396 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -2674,6 +2674,25 @@ static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 	if (!input_fmts)
 		return NULL;
 
+	/* If dw-hdmi is the first bridge make sure it only takes RGB24 as input */
+	if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) {
+		switch (output_fmt) {
+		case MEDIA_BUS_FMT_FIXED:
+		case MEDIA_BUS_FMT_RGB888_1X24:
+		case MEDIA_BUS_FMT_YUV8_1X24:
+		case MEDIA_BUS_FMT_UYVY8_1X16:
+			input_fmts[i++] = MEDIA_BUS_FMT_RGB888_1X24;
+			break;
+		default:
+			kfree(input_fmts);
+			input_fmts = NULL;
+		}
+
+		*num_input_fmts = i;
+
+		return input_fmts;
+	}
+
 	switch (output_fmt) {
 	/* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */
 	case MEDIA_BUS_FMT_FIXED:
-- 
2.25.1



More information about the dri-devel mailing list