drm/panel/panel-sitronix-st7701: Fix RTNI calculation
authorMarek Vasut <marex@denx.de>
Wed, 12 Oct 2022 22:11:59 +0000 (00:11 +0200)
committerMarek Vasut <marex@denx.de>
Tue, 1 Nov 2022 17:34:08 +0000 (18:34 +0100)
The RTNI field is multiplied by 16 and incremented by 512 before being
used as the minimum number of pixel clock per horizontal line, hence
it is necessary to subtract those 512 bytes from htotal and then divide
the result by 16 before writing the value into the RTNI field. Fix the
calculation.

Fixes: de2b4917843c ("drm/panel/panel-sitronix-st7701: Infer horizontal pixel count from TFT mode")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20221012221159.88397-1-marex@denx.de
drivers/gpu/drm/panel/panel-sitronix-st7701.c

index c481daa4bbceb8732a0cb4f247c8e0e27527f9c2..9578f461f5e4871b843fc8e5b294edce73155d09 100644 (file)
@@ -244,7 +244,7 @@ static void st7701_init_sequence(struct st7701 *st7701)
                   DSI_CMD2_BK0_INVSEL_ONES_MASK |
                   FIELD_PREP(DSI_CMD2_BK0_INVSEL_NLINV_MASK, desc->nlinv),
                   FIELD_PREP(DSI_CMD2_BK0_INVSEL_RTNI_MASK,
-                             DIV_ROUND_UP(mode->htotal, 16)));
+                             (clamp((u32)mode->htotal, 512U, 1008U) - 512) / 16));
 
        /* Command2, BK1 */
        ST7701_DSI(st7701, DSI_CMD2BKX_SEL,