Skip to contentSkip to conversation

Add additional YUV420 bus format check for dw-meson's bridge enable

PATCH Superseded Adrián Larumbe 2 participants 5 messages Jun 12, 2023

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add additional YUV420 bus format check for dw-meson's bridge enable

This is v2 of:
https://lore.kernel.org/dri-devel/[email protected]/

The only difference is having added an actual commit message to patch number 3 in the series.

Adrián Larumbe (3):
drm/meson: dw-hdmi: change YUV420 selection logic at clock setup
dw-hdmi: truly enforce 420-only formats when drm mode demands it
dw-hdmi: remove dead code and fix indentation

 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 35 +++++++++--------------
 drivers/gpu/drm/meson/meson_dw_hdmi.c     |  4 +--
 include/drm/bridge/dw_hdmi.h              |  2 ++
 3 files changed, 18 insertions(+), 23 deletions(-)
Signature · 1 line
2.40.0
#1 lore raw

PATCH v2 1/3 drm/meson: dw-hdmi: change YUV420 selection logic at clock setup

Right now clocking value selection code is prioritising RGB, YUV444 modes over YUV420 for HDMI2 sinks. However, because of the bus format selection procedure in dw-hdmi, for HDMI2 sinks YUV420 is the format that will always be picked during the drm bridge chain check stage.

Later on dw_hdmi_setup will configure a colour space based on the bus format that doesn't match the pixel value we had calculated as described above.

Fix it by bringing back dw-hdmi bus format check when picking the right pixel clock.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 6 ++++++
 drivers/gpu/drm/meson/meson_dw_hdmi.c     | 4 ++--
 include/drm/bridge/dw_hdmi.h              | 2 ++
 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6 -0
index 3b40e0fdca5c..e6a456b72610 100644
@@ -3346,6 +3346,12 @@ static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi)
 	return 0;
 }
 
+bool dw_hdmi_bus_fmt_is_420(struct dw_hdmi *hdmi)
+{
+	return hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_bus_fmt_is_420);
+
 struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
 			      const struct dw_hdmi_plat_data *plat_data)
 {
drivers/gpu/drm/meson/meson_dw_hdmi.c +2 -2
index 3d046878ce6c..b49bb0d86efe 100644
@@ -379,8 +379,8 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data,
 			 mode->clock > 340000 ? 40 : 10);
 
 	if (drm_mode_is_420_only(display, mode) ||
-	    (!is_hdmi2_sink &&
-	     drm_mode_is_420_also(display, mode)))
+	    (!is_hdmi2_sink && drm_mode_is_420_also(display, mode)) ||
+	    dw_hdmi_bus_fmt_is_420(hdmi))
 		mode_is_420 = true;
 
 	/* Enable clocks */
include/drm/bridge/dw_hdmi.h +2 -0
index f668e75fbabe..6a46baa0737c 100644
@@ -206,4 +206,6 @@ void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,
 			    bool force, bool disabled, bool rxsense);
 void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data);
 
+bool dw_hdmi_bus_fmt_is_420(struct dw_hdmi *hdmi);
+
 #endif /* __IMX_HDMI_H__ */
Signature · 1 line
2.40.0
#2 lore raw

PATCH v2 2/3 dw-hdmi: truly enforce 420-only formats when drm mode demands it

In reply to Adrián Larumbe

The current output bus format selection logic is enforcing YUV420 even when the drm mode allows for other bus formats as well.
Fix it by adding check for 420-only drm modes.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -3
index e6a456b72610..3a788316e2e5 100644
@@ -2710,9 +2710,10 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
 		/* Default 8bit fallback */
 		output_fmts[i++] = MEDIA_BUS_FMT_UYYVYY8_0_5X24;
 
-		*num_output_fmts = i;
-
-		return output_fmts;
+		if (drm_mode_is_420_only(info, mode)) {
+			*num_output_fmts = i;
+			return output_fmts;
+		}
 	}
 
 	/*
Signature · 1 line
2.40.0
#3 lore raw

PATCH v2 3/3 dw-hdmi: remove dead code and fix indentation

In reply to Adrián Larumbe

The hdmi_datamap enum is no longer in use. Also reindent enable_audio's call params.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -18
index 3a788316e2e5..69c0e80b8525 100644
@@ -49,20 +49,6 @@
 
 #define HDMI14_MAX_TMDSCLK	340000000
 
-enum hdmi_datamap {
-	RGB444_8B = 0x01,
-	RGB444_10B = 0x03,
-	RGB444_12B = 0x05,
-	RGB444_16B = 0x07,
-	YCbCr444_8B = 0x09,
-	YCbCr444_10B = 0x0B,
-	YCbCr444_12B = 0x0D,
-	YCbCr444_16B = 0x0F,
-	YCbCr422_8B = 0x16,
-	YCbCr422_10B = 0x14,
-	YCbCr422_12B = 0x12,
-};
-
 static const u16 csc_coeff_default[3][4] = {
 	{ 0x2000, 0x0000, 0x0000, 0x0000 },
 	{ 0x0000, 0x2000, 0x0000, 0x0000 },
@@ -856,10 +842,10 @@ static void dw_hdmi_gp_audio_enable(struct dw_hdmi *hdmi)
 
 	if (pdata->enable_audio)
 		pdata->enable_audio(hdmi,
-					    hdmi->channels,
-					    hdmi->sample_width,
-					    hdmi->sample_rate,
-					    hdmi->sample_non_pcm);
+				    hdmi->channels,
+				    hdmi->sample_width,
+				    hdmi->sample_rate,
+				    hdmi->sample_non_pcm);
 }
 
 static void dw_hdmi_gp_audio_disable(struct dw_hdmi *hdmi)
Signature · 1 line
2.40.0
maintainer
#4 lore raw
In reply to Adrián Larumbe

Hi,

Quoted 5 lines · Adrián Larumbe

This is v2 of:
https://lore.kernel.org/dri-devel/[email protected]/

The only difference is having added an actual commit message to patch number 3 in the series.

Seems you didn't keep my Acked-by/Reviewed-by and you used my old [email protected] email address.... and you only selected the Meson & Bridge maintainers and not the reviewers.

Quoted 4 lines

Adrián Larumbe (3):
drm/meson: dw-hdmi: change YUV420 selection logic at clock setup
dw-hdmi: truly enforce 420-only formats when drm mode demands it

The subject should be: "drm/bridge: dw-hdmi: ..."

Quoted 1 line

dw-hdmi: remove dead code and fix indentation

Ditto

Quoted 6 lines
  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 35 +++++++++--------------
  drivers/gpu/drm/meson/meson_dw_hdmi.c     |  4 +--
  include/drm/bridge/dw_hdmi.h              |  2 ++
  3 files changed, 18 insertions(+), 23 deletions(-)

Please resend a v3 with all those changes,
Thanks

Neil