Re: [RFC PATCH 3/4] drm/tilcdc: Implement state readout support

From: Maxime Ripard

Date: Fri Nov 27 2026 - 04:53:38 EST


Hi,

On Wed, Nov 25, 2026 at 02:31:49PM +0100, Màxim Pedraza Padilla wrote:
> On Wed, Nov 25, 2026 at 11:07:17AM +0100, Maxime Ripard wrote:
> > > The tidss approach rounds the clock to the closest standard refresh rate.
> > > Panels driven by tilcdc often don't use one: with the timings from its
> > > datasheet, the panel on this board runs at 56.8 Hz (33.3 MHz), which would
> > > be read back as 60 Hz and 35.19 MHz. The adopted mode would then never
> > > match the panel mode, even with U-Boot programming exactly the same one.
> >
> > This is *very* surprising. Do you have the datasheet available somewhere?
>
> You were right to be surprised, I got it wrong, sorry. The datasheet
> counts the sync pulse within the back porch: a line is 1056 clocks
> (800 + 46 + 210) and a frame 525 lines (480 + 23 + 22), so 60.06 Hz at
> 33.3 MHz. The board DT added the sync lengths on top of the porches,
> hence the 56.8 Hz. The bootloader had the same mistake, and also ran the
> panel at 16.94 MHz.
>
> With the timings fixed, and the bootloader programming the same mode as
> the kernel, the readout adopts exactly the DT mode (33300 kHz, 60 Hz),
> and the first commit from userspace with that mode doesn't need a
> modeset at all.

Awesome :)

> > > So the readout keeps the actual rate (rounded to the nearest kHz), and
> > > tilcdc's CRTC compare hook accepts a 1% difference on the pixel clock
> > > before calling drm_atomic_helper_crtc_compare_state(). [...]
> >
> > Yes, that's why we need the above mentionned helper, and more generally
> > why a lot of drivers allow some deviation from the clock.
>
> If it helps, I can write that helper: dispc_find_closest_refresh_rate_from_clk()
> turned into a DRM helper, with the tolerance as a parameter since drivers
> want different ones (5% for tidss, 0.5% for most). Something like:
>
> int drm_mode_set_clock_from_rate(struct drm_display_mode *mode,
> unsigned long rate,
> unsigned int tolerance);
>
> with the tolerance in per mille, so 0.5% can be expressed. It would fill
> mode->clock with the ideal clock of the closest standard refresh rate, or
> return an error if none is close enough. tidss would then use it, and so
> would tilcdc instead of its own compare hook. I'm also fine with you
> folding it into your series if you'd rather do it yourself, just let me
> know.

This is part of v10 now, together with some unit tests.

Maxime

Attachment: signature.asc
Description: PGP signature