* [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates
@ 2024-01-09 23:07 Christian Hewitt
2024-01-10 9:04 ` Neil Armstrong
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christian Hewitt @ 2024-01-09 23:07 UTC (permalink / raw)
To: Neil Armstrong, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Daniel Vetter, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, dri-devel, linux-amlogic,
linux-arm-kernel, linux-kernel
Playing 4K media with 59.94 fractional rate (typically VP9) causes the screen to lose
sync with the following error reported in the system log:
[ 89.610280] Fatal Error, invalid HDMI vclk freq 593406
Modetest shows the following:
3840x2160 59.94 3840 4016 4104 4400 2160 2168 2178 2250 593407 flags: xxxx, xxxx,
drm calculated value -------------------------------------^
Change the fractional rate calculation to stop DIV_ROUND_CLOSEST rounding down which
results in vclk freq failing to match correctly.
Fixes: e5fab2ec9ca4 ("drm/meson: vclk: add support for YUV420 setup")
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
I'm unable to give a better mathematical description of the fix as I can barely read
code. The change was inspired by [0] which I chanced upon while looking at how other
dw-hdmi drivers handle fractional rates.
[0] https://github.com/torvalds/linux/commit/4f510aa10468954b1da4e94689c38ac6ea8d3627
drivers/gpu/drm/meson/meson_vclk.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c
index 2a82119eb58e..2a942dc6a6dc 100644
--- a/drivers/gpu/drm/meson/meson_vclk.c
+++ b/drivers/gpu/drm/meson/meson_vclk.c
@@ -790,13 +790,13 @@ meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned int phy_freq,
FREQ_1000_1001(params[i].pixel_freq));
DRM_DEBUG_DRIVER("i = %d phy_freq = %d alt = %d\n",
i, params[i].phy_freq,
- FREQ_1000_1001(params[i].phy_freq/10)*10);
+ FREQ_1000_1001(params[i].phy_freq/1000)*1000);
/* Match strict frequency */
if (phy_freq == params[i].phy_freq &&
vclk_freq == params[i].vclk_freq)
return MODE_OK;
/* Match 1000/1001 variant */
- if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/10)*10) &&
+ if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/1000)*1000) &&
vclk_freq == FREQ_1000_1001(params[i].vclk_freq))
return MODE_OK;
}
@@ -1070,7 +1070,7 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target,
for (freq = 0 ; params[freq].pixel_freq ; ++freq) {
if ((phy_freq == params[freq].phy_freq ||
- phy_freq == FREQ_1000_1001(params[freq].phy_freq/10)*10) &&
+ phy_freq == FREQ_1000_1001(params[freq].phy_freq/1000)*1000) &&
(vclk_freq == params[freq].vclk_freq ||
vclk_freq == FREQ_1000_1001(params[freq].vclk_freq))) {
if (vclk_freq != params[freq].vclk_freq)
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates
2024-01-09 23:07 [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates Christian Hewitt
@ 2024-01-10 9:04 ` Neil Armstrong
2024-03-29 15:59 ` Neil Armstrong
2024-03-29 16:37 ` Neil Armstrong
2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2024-01-10 9:04 UTC (permalink / raw)
To: Christian Hewitt, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Daniel Vetter, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, dri-devel, linux-amlogic,
linux-arm-kernel, linux-kernel
Hi,
On 10/01/2024 00:07, Christian Hewitt wrote:
> Playing 4K media with 59.94 fractional rate (typically VP9) causes the screen to lose
> sync with the following error reported in the system log:
>
> [ 89.610280] Fatal Error, invalid HDMI vclk freq 593406
>
> Modetest shows the following:
>
> 3840x2160 59.94 3840 4016 4104 4400 2160 2168 2178 2250 593407 flags: xxxx, xxxx,
> drm calculated value -------------------------------------^
>
> Change the fractional rate calculation to stop DIV_ROUND_CLOSEST rounding down which
> results in vclk freq failing to match correctly.
Thanks for the patch, it may need to closely look what's would be the consequence
here, since /1000)*1000 would reduce comparison to less digits, but why ?
A good thing would be to find the offending commit of when this broke, or redo
the entire math because it looks super fishy a few years later...
What puzzles me is that the same calculation is done on both side:
- meson_vclk_vic_supported_freq() called from meson_encoder_hdmi_mode_valid()
- meson_vclk_setup() called from meson_encoder_hdmi_set_vclk() and meson_encoder_hdmi_atomic_enable()
so when a mode freq is selected from meson_encoder_hdmi_mode_valid(), it should match the
mode freq in meson_vclk_setup(), but no.
So why reducing precision makes this work ???
Neil
>
> Fixes: e5fab2ec9ca4 ("drm/meson: vclk: add support for YUV420 setup")
> Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
> ---
> I'm unable to give a better mathematical description of the fix as I can barely read
> code. The change was inspired by [0] which I chanced upon while looking at how other
> dw-hdmi drivers handle fractional rates.
>
> [0] https://github.com/torvalds/linux/commit/4f510aa10468954b1da4e94689c38ac6ea8d3627
>
> drivers/gpu/drm/meson/meson_vclk.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c
> index 2a82119eb58e..2a942dc6a6dc 100644
> --- a/drivers/gpu/drm/meson/meson_vclk.c
> +++ b/drivers/gpu/drm/meson/meson_vclk.c
> @@ -790,13 +790,13 @@ meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned int phy_freq,
> FREQ_1000_1001(params[i].pixel_freq));
> DRM_DEBUG_DRIVER("i = %d phy_freq = %d alt = %d\n",
> i, params[i].phy_freq,
> - FREQ_1000_1001(params[i].phy_freq/10)*10);
> + FREQ_1000_1001(params[i].phy_freq/1000)*1000);
> /* Match strict frequency */
> if (phy_freq == params[i].phy_freq &&
> vclk_freq == params[i].vclk_freq)
> return MODE_OK;
> /* Match 1000/1001 variant */
> - if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/10)*10) &&
> + if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/1000)*1000) &&
> vclk_freq == FREQ_1000_1001(params[i].vclk_freq))
> return MODE_OK;
> }
> @@ -1070,7 +1070,7 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target,
>
> for (freq = 0 ; params[freq].pixel_freq ; ++freq) {
> if ((phy_freq == params[freq].phy_freq ||
> - phy_freq == FREQ_1000_1001(params[freq].phy_freq/10)*10) &&
> + phy_freq == FREQ_1000_1001(params[freq].phy_freq/1000)*1000) &&
> (vclk_freq == params[freq].vclk_freq ||
> vclk_freq == FREQ_1000_1001(params[freq].vclk_freq))) {
> if (vclk_freq != params[freq].vclk_freq)
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates
2024-01-09 23:07 [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates Christian Hewitt
2024-01-10 9:04 ` Neil Armstrong
@ 2024-03-29 15:59 ` Neil Armstrong
2024-03-29 16:37 ` Neil Armstrong
2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2024-03-29 15:59 UTC (permalink / raw)
To: Christian Hewitt, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Daniel Vetter, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, dri-devel, linux-amlogic,
linux-arm-kernel, linux-kernel
On 10/01/2024 00:07, Christian Hewitt wrote:
> Playing 4K media with 59.94 fractional rate (typically VP9) causes the screen to lose
> sync with the following error reported in the system log:
>
> [ 89.610280] Fatal Error, invalid HDMI vclk freq 593406
>
> Modetest shows the following:
>
> 3840x2160 59.94 3840 4016 4104 4400 2160 2168 2178 2250 593407 flags: xxxx, xxxx,
> drm calculated value -------------------------------------^
>
> Change the fractional rate calculation to stop DIV_ROUND_CLOSEST rounding down which
> results in vclk freq failing to match correctly.
>
> Fixes: e5fab2ec9ca4 ("drm/meson: vclk: add support for YUV420 setup")
> Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
> ---
> I'm unable to give a better mathematical description of the fix as I can barely read
> code. The change was inspired by [0] which I chanced upon while looking at how other
> dw-hdmi drivers handle fractional rates.
>
> [0] https://github.com/torvalds/linux/commit/4f510aa10468954b1da4e94689c38ac6ea8d3627
>
> drivers/gpu/drm/meson/meson_vclk.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c
> index 2a82119eb58e..2a942dc6a6dc 100644
> --- a/drivers/gpu/drm/meson/meson_vclk.c
> +++ b/drivers/gpu/drm/meson/meson_vclk.c
> @@ -790,13 +790,13 @@ meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned int phy_freq,
> FREQ_1000_1001(params[i].pixel_freq));
> DRM_DEBUG_DRIVER("i = %d phy_freq = %d alt = %d\n",
> i, params[i].phy_freq,
> - FREQ_1000_1001(params[i].phy_freq/10)*10);
> + FREQ_1000_1001(params[i].phy_freq/1000)*1000);
> /* Match strict frequency */
> if (phy_freq == params[i].phy_freq &&
> vclk_freq == params[i].vclk_freq)
> return MODE_OK;
> /* Match 1000/1001 variant */
> - if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/10)*10) &&
> + if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/1000)*1000) &&
> vclk_freq == FREQ_1000_1001(params[i].vclk_freq))
> return MODE_OK;
> }
> @@ -1070,7 +1070,7 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target,
>
> for (freq = 0 ; params[freq].pixel_freq ; ++freq) {
> if ((phy_freq == params[freq].phy_freq ||
> - phy_freq == FREQ_1000_1001(params[freq].phy_freq/10)*10) &&
> + phy_freq == FREQ_1000_1001(params[freq].phy_freq/1000)*1000) &&
> (vclk_freq == params[freq].vclk_freq ||
> vclk_freq == FREQ_1000_1001(params[freq].vclk_freq))) {
> if (vclk_freq != params[freq].vclk_freq)
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates
2024-01-09 23:07 [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates Christian Hewitt
2024-01-10 9:04 ` Neil Armstrong
2024-03-29 15:59 ` Neil Armstrong
@ 2024-03-29 16:37 ` Neil Armstrong
2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2024-03-29 16:37 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Daniel Vetter, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
dri-devel, linux-amlogic, linux-arm-kernel, linux-kernel,
Christian Hewitt
Hi,
On Tue, 09 Jan 2024 23:07:04 +0000, Christian Hewitt wrote:
> Playing 4K media with 59.94 fractional rate (typically VP9) causes the screen to lose
> sync with the following error reported in the system log:
>
> [ 89.610280] Fatal Error, invalid HDMI vclk freq 593406
>
> Modetest shows the following:
>
> [...]
Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)
[1/1] drm/meson: vclk: fix calculation of 59.94 fractional rates
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/bfbc68e4d8695497f858a45a142665e22a512ea3
--
Neil
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-29 16:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-09 23:07 [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates Christian Hewitt
2024-01-10 9:04 ` Neil Armstrong
2024-03-29 15:59 ` Neil Armstrong
2024-03-29 16:37 ` Neil Armstrong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).