diff mbox series

[2/3] video: rockchip: rk3328: filter unsupported modes

Message ID 20250114052548.763611-2-anarsoul@gmail.com
State New
Delegated to: Quentin Schulz
Headers show
Series [1/3] clk: rockchip: rk3328: use HDMIPHY PLL as a clock parent for VOP_DCLK | expand

Commit Message

Vasily Khoruzhick Jan. 14, 2025, 5:24 a.m. UTC
While RK3328 is capable of 4K resolution, dw-hdmi driver in u-boot
seems to have some issue with 4K. 1440p or lower works fine.

Limit max resolution by 2560x1440x60Hz, by filtering the modes with
pixel clock > 297MHz

Fixes: f3ea872970d603 ("video: rockchip: Add rk3328 hdmi support")
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 drivers/video/rockchip/rk3328_hdmi.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Quentin Schulz Jan. 15, 2025, 10:48 a.m. UTC | #1
Hi Vasily,

On 1/14/25 6:24 AM, Vasily Khoruzhick wrote:
> While RK3328 is capable of 4K resolution, dw-hdmi driver in u-boot
> seems to have some issue with 4K. 1440p or lower works fine.
> 
> Limit max resolution by 2560x1440x60Hz, by filtering the modes with
> pixel clock > 297MHz
> 
> Fixes: f3ea872970d603 ("video: rockchip: Add rk3328 hdmi support")
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
>   drivers/video/rockchip/rk3328_hdmi.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/video/rockchip/rk3328_hdmi.c b/drivers/video/rockchip/rk3328_hdmi.c
> index 763669c09be..d02c58c44c5 100644
> --- a/drivers/video/rockchip/rk3328_hdmi.c
> +++ b/drivers/video/rockchip/rk3328_hdmi.c
> @@ -105,9 +105,16 @@ static int rk3328_hdmi_probe(struct udevice *dev)
>   	return 0;
>   }
>   
> +static bool rk3328_hdmi_mode_valid(struct udevice *dev,
> +				   const struct display_timing *timing)
> +{
> +	return timing->pixelclock.typ <= 297000000;
> +}
> +

This seems like a hack to me and I would feel better with it being 
documented as such in the code. Can you simply add a comment there 
stating that this is a work-around for resolutions above 4K that should 
be working (that's what I gathered from the commit log, does it work in 
Linux?) but aren't right now. Maybe also add the formula in the comment?

I also wonder what would happen if we have 120+Hz displays at lower 
resolutions, they would be filtered out as well. Is that an issue? /me 
shrugs.

I don't own an RK3328 device though, so...

Cheers,
Quentin
Vasily Khoruzhick Jan. 18, 2025, 11:14 p.m. UTC | #2
On Wed, Jan 15, 2025 at 2:48 AM Quentin Schulz <quentin.schulz@cherry.de> wrote:
>
> Hi Vasily,

Hey Quentin,

> > +static bool rk3328_hdmi_mode_valid(struct udevice *dev,
> > +                                const struct display_timing *timing)
> > +{
> > +     return timing->pixelclock.typ <= 297000000;
> > +}
> > +
>
> This seems like a hack to me and I would feel better with it being
> documented as such in the code. Can you simply add a comment there
> stating that this is a work-around for resolutions above 4K that should
> be working (that's what I gathered from the commit log, does it work in
> Linux?) but aren't right now.

Yeah, I agree it is a hack, and yes, 4K works fine in Linux. I noticed
that some other drivers that use dw-hdmi in u-boot also limit max
pixel clock at 297MHz, so it might be a known but not documented
issue. I'll add a comment about that in v2.

> Maybe also add the formula in the comment?

htotal * vtotal * refresh_rate? That would require an explanation of
what htotal and vtotal is, and TBH if you know where to get htotal and
vtotal from, you know where to look for a pixel clock. I don't think
that rk3328_hdmi.c is a proper place for such an explanation.

> I also wonder what would happen if we have 120+Hz displays at lower
> resolutions, they would be filtered out as well. Is that an issue? /me
> shrugs.

Yeah, or 4K displays at 30Hz which is exactly 297MHz.

I spent some time debugging this issue, unfortunately with no useful
result. This change at least allows my rock64 to show something on my
4K monitor, so it is an improvement.

Regards,
Vasily
diff mbox series

Patch

diff --git a/drivers/video/rockchip/rk3328_hdmi.c b/drivers/video/rockchip/rk3328_hdmi.c
index 763669c09be..d02c58c44c5 100644
--- a/drivers/video/rockchip/rk3328_hdmi.c
+++ b/drivers/video/rockchip/rk3328_hdmi.c
@@ -105,9 +105,16 @@  static int rk3328_hdmi_probe(struct udevice *dev)
 	return 0;
 }
 
+static bool rk3328_hdmi_mode_valid(struct udevice *dev,
+				   const struct display_timing *timing)
+{
+	return timing->pixelclock.typ <= 297000000;
+}
+
 static const struct dm_display_ops rk3328_hdmi_ops = {
 	.read_edid = rk_hdmi_read_edid,
 	.enable = rk3328_hdmi_enable,
+	.mode_valid = rk3328_hdmi_mode_valid,
 };
 
 static const struct udevice_id rk3328_hdmi_ids[] = {