Skip to contentSkip to conversation

drm/vc4: Fix HDMI mode validation

PATCH In review Nicolas Saenz Julienne 3 participants 9 messages Mar 26, 2020 – Mar 27, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vc4: Fix HDMI mode validation

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +16 -4
index cea18dc15f77..340719238753 100644
@@ -681,11 +681,23 @@ static enum drm_mode_status
 vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc,
 			    const struct drm_display_mode *mode)
 {
-	/* HSM clock must be 108% of the pixel clock.  Additionally,
-	 * the AXI clock needs to be at least 25% of pixel clock, but
-	 * HSM ends up being the limiting factor.
+	/*
+	 * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must
+	 * be faster than pixel clock, infinitesimally faster, tested in
+	 * simulation. Otherwise, exact value is unimportant for HDMI
+	 * operation." This conflicts with bcm2835's vc4 documentation, which
+	 * states HSM's clock has to be at least 108% of the pixel clock.
+	 *
+	 * Real life tests reveal that vc4's firmware statement holds up, and
+	 * users are able to use pixel clocks closer to HSM's, namely for
+	 * 1920x1200@60Hz. So it was decided to have leave a 1% margin between
+	 * both clocks. Which, for RPi0-3 implies a maximum pixel clock of
+	 * 162MHz.
+	 *
+	 * Additionally, the AXI clock needs to be at least 25% of
+	 * pixel clock, but HSM ends up being the limiting factor.
 	 */
-	if (mode->clock > HSM_CLOCK_FREQ / (1000 * 108 / 100))
+	if (mode->clock > HSM_CLOCK_FREQ / (1000 * 101 / 100))
 		return MODE_CLOCK_HIGH;
 
 	return MODE_OK;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Nicolas Saenz Julienne

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")

Maxime

Tested-by on v1 1/1
#2 lore raw
In reply to Nicolas Saenz Julienne

Am 26.03.20 um 13:20 schrieb Nicolas Saenz Julienne:

Quoted 26 lines

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -3
index cea18dc15f77..340719238753 100644
@@ -681,11 +681,23 @@ static enum drm_mode_status
 vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc,
 			    const struct drm_display_mode *mode)
 {
-	/* HSM clock must be 108% of the pixel clock.  Additionally,
-	 * the AXI clock needs to be at least 25% of pixel clock, but
-	 * HSM ends up being the limiting factor.
+	/*

drivers/gpu/drm/vc4/vc4_hdmi.c static enum drm_mode_status · line 694

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +10 -0
+	 * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must
+	 * be faster than pixel clock, infinitesimally faster, tested in
+	 * simulation. Otherwise, exact value is unimportant for HDMI
+	 * operation." This conflicts with bcm2835's vc4 documentation, which
+	 * states HSM's clock has to be at least 108% of the pixel clock.
+	 *
+	 * Real life tests reveal that vc4's firmware statement holds up, and
+	 * users are able to use pixel clocks closer to HSM's, namely for
+	 * 1920x1200@60Hz. So it was decided to have leave a 1% margin between
+	 * both clocks. Which, for RPi0-3 implies a maximum pixel clock of

s/RPi0-3/bcm2835/ ?

Beside this nit:

Thanks

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Am 26.03.20 um 18:19 schrieb Stefan Wahren:

Quoted 39 lines

Am 26.03.20 um 13:20 schrieb Nicolas Saenz Julienne:

Quoted 26 lines

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -3
index cea18dc15f77..340719238753 100644
@@ -681,11 +681,23 @@ static enum drm_mode_status
 vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc,
 			    const struct drm_display_mode *mode)
 {
-	/* HSM clock must be 108% of the pixel clock.  Additionally,
-	 * the AXI clock needs to be at least 25% of pixel clock, but
-	 * HSM ends up being the limiting factor.
+	/*

drivers/gpu/drm/vc4/vc4_hdmi.c static enum drm_mode_status · line 694

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +10 -0
+	 * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must
+	 * be faster than pixel clock, infinitesimally faster, tested in
+	 * simulation. Otherwise, exact value is unimportant for HDMI
+	 * operation." This conflicts with bcm2835's vc4 documentation, which
+	 * states HSM's clock has to be at least 108% of the pixel clock.
+	 *
+	 * Real life tests reveal that vc4's firmware statement holds up, and
+	 * users are able to use pixel clocks closer to HSM's, namely for
+	 * 1920x1200@60Hz. So it was decided to have leave a 1% margin between
+	 * both clocks. Which, for RPi0-3 implies a maximum pixel clock of

s/RPi0-3/bcm2835/ ?

Quoted 5 lines

Beside this nit:

Thanks

Sorry typo in the mail address:

[email protected]

#4 lore raw
In reply to Stefan Wahren
Quoted 31 lines · Stefan Wahren

Am 26.03.20 um 13:20 schrieb Nicolas Saenz Julienne:

Quoted 30 lines

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +5 -3
index cea18dc15f77..340719238753 100644
@@ -681,11 +681,23 @@ static enum drm_mode_status
 vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc,
 			    const struct drm_display_mode *mode)
 {
-	/* HSM clock must be 108% of the pixel clock.  Additionally,
-	 * the AXI clock needs to be at least 25% of pixel clock, but
-	 * HSM ends up being the limiting factor.
+	/*
+	 * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must
+	 * be faster than pixel clock, infinitesimally faster, tested in
+	 * simulation. Otherwise, exact value is unimportant for HDMI
+	 * operation." This conflicts with bcm2835's vc4 documentation, which
Quoted 8 lines

drivers/gpu/drm/vc4/vc4_hdmi.c static enum drm_mode_status · line 694

Quoted 6 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +6 -0
+	 * states HSM's clock has to be at least 108% of the pixel clock.
+	 *
+	 * Real life tests reveal that vc4's firmware statement holds up, and
+	 * users are able to use pixel clocks closer to HSM's, namely for
+	 * 1920x1200@60Hz. So it was decided to have leave a 1% margin between
+	 * both clocks. Which, for RPi0-3 implies a maximum pixel clock of

s/RPi0-3/bcm2835/ ?

Well as Dave Stevenson stated on the previous thread[1], it's the firmware that sets up the HSM limitation. IIUC technically both HSM and pixel clocks could be increased. Hence this being more of a RPi limitation than the chip itself.

"Whilst the firmware would appear to use a fixed HSM clock on Pi0-3, I don't anticipate there being any issue with varying it. It looks like there was the expectation of it being variable in the past, but someone has refactored it and either accidentally or deliberately given up on the idea."

Regards,
Nicolas

[1] https://www.spinics.net/lists/arm-kernel/msg794591.html

#5 lore raw

Am 26.03.20 um 18:36 schrieb Nicolas Saenz Julienne:

Quoted 43 lines · Stefan Wahren
Quoted 30 lines

Am 26.03.20 um 13:20 schrieb Nicolas Saenz Julienne:

Quoted 29 lines

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -3
index cea18dc15f77..340719238753 100644
@@ -681,11 +681,23 @@ static enum drm_mode_status
 vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc,
 			    const struct drm_display_mode *mode)
 {
-	/* HSM clock must be 108% of the pixel clock.  Additionally,
-	 * the AXI clock needs to be at least 25% of pixel clock, but
-	 * HSM ends up being the limiting factor.
+	/*
+	 * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must
+	 * be faster than pixel clock, infinitesimally faster, tested in
+	 * simulation. Otherwise, exact value is unimportant for HDMI
Quoted 8 lines

drivers/gpu/drm/vc4/vc4_hdmi.c static enum drm_mode_status · line 694

Quoted 7 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +7 -0
+	 * operation." This conflicts with bcm2835's vc4 documentation, which
+	 * states HSM's clock has to be at least 108% of the pixel clock.
+	 *
+	 * Real life tests reveal that vc4's firmware statement holds up, and
+	 * users are able to use pixel clocks closer to HSM's, namely for
+	 * 1920x1200@60Hz. So it was decided to have leave a 1% margin between
+	 * both clocks. Which, for RPi0-3 implies a maximum pixel clock of

s/RPi0-3/bcm2835/ ?

Well as Dave Stevenson stated on the previous thread[1], it's the firmware that sets up the HSM limitation. IIUC technically both HSM and pixel clocks could be increased. Hence this being more of a RPi limitation than the chip itself.

Quoted 5 lines

"Whilst the firmware would appear to use a fixed HSM clock on Pi0-3, I don't anticipate there being any issue with varying it. It looks like there was the expectation of it being variable in the past, but someone has refactored it and either accidentally or deliberately given up on the idea."

Okay thanks for the explanation again

So i'm fine this patch

Quoted 6 lines

Regards,
Nicolas

[1] https://www.spinics.net/lists/arm-kernel/msg794591.html

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
In reply to Nicolas Saenz Julienne

Hi Daniel,

Quoted 10 lines · Nicolas Saenz Julienne

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")

Would it be possible for you to take this in for v5.7 (or as a fix for v5.6, but it seems a little late)?

A device-tree patch I have to channel trough the SoC tree depends on this to avoid regressions.

Regards,
Nicolas

#7 lore raw
Quoted 14 lines · Nicolas Saenz Julienne

Hi Daniel,

Quoted 10 lines · Nicolas Saenz Julienne

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
Quoted 5 lines

Would it be possible for you to take this in for v5.7 (or as a fix for v5.6, but it seems a little late)?

A device-tree patch I have to channel trough the SoC tree depends on this to avoid regressions.

I've applied it for 5.7-rc1

Maxime

#8 lore raw
Quoted 15 lines · Maxime Ripard
Quoted 14 lines · Nicolas Saenz Julienne

Hi Daniel,

Quoted 10 lines · Nicolas Saenz Julienne

Current mode validation impedes setting up some video modes which should be supported otherwise. Namely 1920x1200@60Hz.

Fix this by lowering the minimum HDMI state machine clock to pixel clock ratio allowed.

Fixes 32e823c63e90 ("drm/vc4: Reject HDMI modes with too high of clocks")
Quoted 7 lines
Quoted 5 lines

Would it be possible for you to take this in for v5.7 (or as a fix for v5.6, but it seems a little late)?

A device-tree patch I have to channel trough the SoC tree depends on this to avoid regressions.

I've applied it for 5.7-rc1

Thanks!