Re: [Intel-gfx] [PATCH] drm/i915: Round to closest in g4x+ HDMI clock readout

2022-09-27 Thread Jani Nikula
On Mon, 26 Sep 2022, Ville Syrjala  wrote:
> From: Ville Syrjälä 
>
> On pre-ddi platforms we have slightly different code being
> used for HDMI TMDS clock to dotclock conversion between the
> state computation and state readout. Both of these need to
> round the same way in order to not get a mismatch between
> the computed and read out states. Fix up the rounding
> direction in the readout path to match what is used during
> state computation.
>
> Another option would to just use intel_crtc_dotclock()
> in the readout path as well, but I don't really want to
> do that as the current code more accurately represents
> how the hardware really works; The HDMI port register
> defines whether we're actually outputting 8bpc or 12bpc
> over HDMI, and the PIPECONF bpc setting just defines what
> goes over FDI between the CPU and PCH. The fact that we
> try to cram all that into a single pipe_bpp during state
> computation is perhaps not entirely great...
>
> Fixes: f2c9df101095 ("drm/i915: Round TMDS clock to nearest")
> Signed-off-by: Ville Syrjälä 

Reviewed-by: Jani Nikula 

> ---
>  drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c 
> b/drivers/gpu/drm/i915/display/g4x_hdmi.c
> index 5606c667e422..8aadf96fa5e9 100644
> --- a/drivers/gpu/drm/i915/display/g4x_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c
> @@ -120,7 +120,7 @@ static void intel_hdmi_get_config(struct intel_encoder 
> *encoder,
>   pipe_config->hw.adjusted_mode.flags |= flags;
>  
>   if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc)
> - dotclock = pipe_config->port_clock * 2 / 3;
> + dotclock = DIV_ROUND_CLOSEST(pipe_config->port_clock * 2, 3);
>   else
>   dotclock = pipe_config->port_clock;

-- 
Jani Nikula, Intel Open Source Graphics Center


[Intel-gfx] [PATCH] drm/i915: Round to closest in g4x+ HDMI clock readout

2022-09-26 Thread Ville Syrjala
From: Ville Syrjälä 

On pre-ddi platforms we have slightly different code being
used for HDMI TMDS clock to dotclock conversion between the
state computation and state readout. Both of these need to
round the same way in order to not get a mismatch between
the computed and read out states. Fix up the rounding
direction in the readout path to match what is used during
state computation.

Another option would to just use intel_crtc_dotclock()
in the readout path as well, but I don't really want to
do that as the current code more accurately represents
how the hardware really works; The HDMI port register
defines whether we're actually outputting 8bpc or 12bpc
over HDMI, and the PIPECONF bpc setting just defines what
goes over FDI between the CPU and PCH. The fact that we
try to cram all that into a single pipe_bpp during state
computation is perhaps not entirely great...

Fixes: f2c9df101095 ("drm/i915: Round TMDS clock to nearest")
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c 
b/drivers/gpu/drm/i915/display/g4x_hdmi.c
index 5606c667e422..8aadf96fa5e9 100644
--- a/drivers/gpu/drm/i915/display/g4x_hdmi.c
+++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c
@@ -120,7 +120,7 @@ static void intel_hdmi_get_config(struct intel_encoder 
*encoder,
pipe_config->hw.adjusted_mode.flags |= flags;
 
if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc)
-   dotclock = pipe_config->port_clock * 2 / 3;
+   dotclock = DIV_ROUND_CLOSEST(pipe_config->port_clock * 2, 3);
else
dotclock = pipe_config->port_clock;
 
-- 
2.35.1