* [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding
2026-02-26 16:16 [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern Luca Ceresoli
@ 2026-02-26 16:16 ` Luca Ceresoli
2026-02-27 10:39 ` Marek Vasut
2026-04-08 15:32 ` Louis Chauvet
2026-02-26 16:16 ` [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output Luca Ceresoli
` (2 subsequent siblings)
3 siblings, 2 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-02-26 16:16 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Frieder Schrempf,
Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, Luca Ceresoli, stable
The DSI frequency must be in the range:
(CHA_DSI_CLK_RANGE * 5 MHz) <= DSI freq < ((CHA_DSI_CLK_RANGE + 1) * 5 MHz)
So the register value shouldpoint to the lower range value, but
DIV_ROUND_UP() rounds the division to the higher range value, resulting in
an excess of 1 (unless the frequency is an exact multiple of 5 MHz).
For example for a 437100000 MHz clock CHA_DSI_CLK_RANGE should be 87 (0x57):
(87 * 5 = 435) <= 437.1 < (88 * 5 = 440)
but current code returns 88 (0x58).
Fix the computation by removing the DIV_ROUND_UP().
Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver")
Cc: stable@vger.kernel.org
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ti-sn65dsi83.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
index f6736b4457bb..d2a81175d279 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
@@ -351,9 +351,9 @@ static u8 sn65dsi83_get_dsi_range(struct sn65dsi83 *ctx,
* DSI_CLK = mode clock * bpp / dsi_data_lanes / 2
* the 2 is there because the bus is DDR.
*/
- return DIV_ROUND_UP(clamp((unsigned int)mode->clock *
- mipi_dsi_pixel_format_to_bpp(ctx->dsi->format) /
- ctx->dsi->lanes / 2, 40000U, 500000U), 5000U);
+ return clamp((unsigned int)mode->clock *
+ mipi_dsi_pixel_format_to_bpp(ctx->dsi->format) /
+ ctx->dsi->lanes / 2, 40000U, 500000U) / 5000U;
}
static u8 sn65dsi83_get_dsi_div(struct sn65dsi83 *ctx)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding
2026-02-26 16:16 ` [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding Luca Ceresoli
@ 2026-02-27 10:39 ` Marek Vasut
2026-04-08 15:32 ` Louis Chauvet
1 sibling, 0 replies; 15+ messages in thread
From: Marek Vasut @ 2026-02-27 10:39 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, stable
On 2/26/26 5:16 PM, Luca Ceresoli wrote:
> The DSI frequency must be in the range:
>
> (CHA_DSI_CLK_RANGE * 5 MHz) <= DSI freq < ((CHA_DSI_CLK_RANGE + 1) * 5 MHz)
>
> So the register value shouldpoint to the lower range value, but
should point (missing space)
> DIV_ROUND_UP() rounds the division to the higher range value, resulting in
> an excess of 1 (unless the frequency is an exact multiple of 5 MHz).
>
> For example for a 437100000 MHz clock CHA_DSI_CLK_RANGE should be 87 (0x57):
>
> (87 * 5 = 435) <= 437.1 < (88 * 5 = 440)
>
> but current code returns 88 (0x58).
>
> Fix the computation by removing the DIV_ROUND_UP().
>
> Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
Thanks !
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding
2026-02-26 16:16 ` [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding Luca Ceresoli
2026-02-27 10:39 ` Marek Vasut
@ 2026-04-08 15:32 ` Louis Chauvet
1 sibling, 0 replies; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 15:32 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, stable
On 2/26/26 17:16, Luca Ceresoli wrote:
> The DSI frequency must be in the range:
>
> (CHA_DSI_CLK_RANGE * 5 MHz) <= DSI freq < ((CHA_DSI_CLK_RANGE + 1) * 5 MHz)
>
> So the register value shouldpoint to the lower range value, but
> DIV_ROUND_UP() rounds the division to the higher range value, resulting in
> an excess of 1 (unless the frequency is an exact multiple of 5 MHz).
>
> For example for a 437100000 MHz clock CHA_DSI_CLK_RANGE should be 87 (0x57):
>
> (87 * 5 = 435) <= 437.1 < (88 * 5 = 440)
>
> but current code returns 88 (0x58).
>
> Fix the computation by removing the DIV_ROUND_UP().
>
> Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/ti-sn65dsi83.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> index f6736b4457bb..d2a81175d279 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> @@ -351,9 +351,9 @@ static u8 sn65dsi83_get_dsi_range(struct sn65dsi83 *ctx,
> * DSI_CLK = mode clock * bpp / dsi_data_lanes / 2
> * the 2 is there because the bus is DDR.
> */
> - return DIV_ROUND_UP(clamp((unsigned int)mode->clock *
> - mipi_dsi_pixel_format_to_bpp(ctx->dsi->format) /
> - ctx->dsi->lanes / 2, 40000U, 500000U), 5000U);
> + return clamp((unsigned int)mode->clock *
> + mipi_dsi_pixel_format_to_bpp(ctx->dsi->format) /
> + ctx->dsi->lanes / 2, 40000U, 500000U) / 5000U;
If you need to do a v2, I think it could be nice to introduce one or two
intermediate variable to allow a human to read this line:
required_bitrate = pixel_clock * bpp;
lane_rate = required_bitrate / lanes / 2;
return clamp(lane_rate) / 5000;
With or without this:
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> }
>
> static u8 sn65dsi83_get_dsi_div(struct sn65dsi83 *ctx)
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output
2026-02-26 16:16 [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern Luca Ceresoli
2026-02-26 16:16 ` [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding Luca Ceresoli
@ 2026-02-26 16:16 ` Luca Ceresoli
2026-02-27 10:41 ` Marek Vasut
2026-04-08 15:34 ` Louis Chauvet
2026-02-26 16:16 ` [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support Luca Ceresoli
2026-03-09 22:11 ` (subset) [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern Luca Ceresoli
3 siblings, 2 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-02-26 16:16 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Frieder Schrempf,
Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, Luca Ceresoli, stable
Dual LVDS output (available on the SN65DSI84) requires HSYNC_PULSE_WIDTH
and HORIZONTAL_BACK_PORCH to be divided by two with respect to the values
used for single LVDS output.
While not clearly stated in the datasheet, this is needed according to the
DSI Tuner [0] output. It also makes sense intuitively because in dual LVDS
output two pixels at a time are output and so the output clock is half of
the pixel clock.
Some dual-LVDS panels refuse to show any picture without this fix.
Divide by two HORIZONTAL_FRONT_PORCH too, even though this register is used
only for test pattern generation which is not currently implemented by this
driver.
[0] https://www.ti.com/tool/DSI-TUNER
Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver")
Cc: stable@vger.kernel.org
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
index d2a81175d279..17a885244e1e 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
@@ -517,6 +517,7 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
struct drm_atomic_state *state)
{
struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
+ const unsigned int dual_factor = ctx->lvds_dual_link ? 2 : 1;
const struct drm_bridge_state *bridge_state;
const struct drm_crtc_state *crtc_state;
const struct drm_display_mode *mode;
@@ -653,18 +654,18 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
/* 32 + 1 pixel clock to ensure proper operation */
le16val = cpu_to_le16(32 + 1);
regmap_bulk_write(ctx->regmap, REG_VID_CHA_SYNC_DELAY_LOW, &le16val, 2);
- le16val = cpu_to_le16(mode->hsync_end - mode->hsync_start);
+ le16val = cpu_to_le16((mode->hsync_end - mode->hsync_start) / dual_factor);
regmap_bulk_write(ctx->regmap, REG_VID_CHA_HSYNC_PULSE_WIDTH_LOW,
&le16val, 2);
le16val = cpu_to_le16(mode->vsync_end - mode->vsync_start);
regmap_bulk_write(ctx->regmap, REG_VID_CHA_VSYNC_PULSE_WIDTH_LOW,
&le16val, 2);
regmap_write(ctx->regmap, REG_VID_CHA_HORIZONTAL_BACK_PORCH,
- mode->htotal - mode->hsync_end);
+ (mode->htotal - mode->hsync_end) / dual_factor);
regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_BACK_PORCH,
mode->vtotal - mode->vsync_end);
regmap_write(ctx->regmap, REG_VID_CHA_HORIZONTAL_FRONT_PORCH,
- mode->hsync_start - mode->hdisplay);
+ (mode->hsync_start - mode->hdisplay) / dual_factor);
regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_FRONT_PORCH,
mode->vsync_start - mode->vdisplay);
regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, 0x00);
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output
2026-02-26 16:16 ` [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output Luca Ceresoli
@ 2026-02-27 10:41 ` Marek Vasut
2026-04-08 15:34 ` Louis Chauvet
1 sibling, 0 replies; 15+ messages in thread
From: Marek Vasut @ 2026-02-27 10:41 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, stable
On 2/26/26 5:16 PM, Luca Ceresoli wrote:
> Dual LVDS output (available on the SN65DSI84) requires HSYNC_PULSE_WIDTH
> and HORIZONTAL_BACK_PORCH to be divided by two with respect to the values
> used for single LVDS output.
>
> While not clearly stated in the datasheet, this is needed according to the
> DSI Tuner [0] output. It also makes sense intuitively because in dual LVDS
> output two pixels at a time are output and so the output clock is half of
> the pixel clock.
>
> Some dual-LVDS panels refuse to show any picture without this fix.
>
> Divide by two HORIZONTAL_FRONT_PORCH too, even though this register is used
> only for test pattern generation which is not currently implemented by this
> driver.
Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
Thanks !
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output
2026-02-26 16:16 ` [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output Luca Ceresoli
2026-02-27 10:41 ` Marek Vasut
@ 2026-04-08 15:34 ` Louis Chauvet
1 sibling, 0 replies; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 15:34 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, stable
On 2/26/26 17:16, Luca Ceresoli wrote:
> Dual LVDS output (available on the SN65DSI84) requires HSYNC_PULSE_WIDTH
> and HORIZONTAL_BACK_PORCH to be divided by two with respect to the values
> used for single LVDS output.
>
> While not clearly stated in the datasheet, this is needed according to the
> DSI Tuner [0] output. It also makes sense intuitively because in dual LVDS
> output two pixels at a time are output and so the output clock is half of
> the pixel clock.
>
> Some dual-LVDS panels refuse to show any picture without this fix.
>
> Divide by two HORIZONTAL_FRONT_PORCH too, even though this register is used
> only for test pattern generation which is not currently implemented by this
> driver.
>
> [0] https://www.ti.com/tool/DSI-TUNER
>
> Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
> drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> index d2a81175d279..17a885244e1e 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> @@ -517,6 +517,7 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
> struct drm_atomic_state *state)
> {
> struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
> + const unsigned int dual_factor = ctx->lvds_dual_link ? 2 : 1;
> const struct drm_bridge_state *bridge_state;
> const struct drm_crtc_state *crtc_state;
> const struct drm_display_mode *mode;
> @@ -653,18 +654,18 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
> /* 32 + 1 pixel clock to ensure proper operation */
> le16val = cpu_to_le16(32 + 1);
> regmap_bulk_write(ctx->regmap, REG_VID_CHA_SYNC_DELAY_LOW, &le16val, 2);
> - le16val = cpu_to_le16(mode->hsync_end - mode->hsync_start);
> + le16val = cpu_to_le16((mode->hsync_end - mode->hsync_start) / dual_factor);
> regmap_bulk_write(ctx->regmap, REG_VID_CHA_HSYNC_PULSE_WIDTH_LOW,
> &le16val, 2);
> le16val = cpu_to_le16(mode->vsync_end - mode->vsync_start);
> regmap_bulk_write(ctx->regmap, REG_VID_CHA_VSYNC_PULSE_WIDTH_LOW,
> &le16val, 2);
> regmap_write(ctx->regmap, REG_VID_CHA_HORIZONTAL_BACK_PORCH,
> - mode->htotal - mode->hsync_end);
> + (mode->htotal - mode->hsync_end) / dual_factor);
> regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_BACK_PORCH,
> mode->vtotal - mode->vsync_end);
> regmap_write(ctx->regmap, REG_VID_CHA_HORIZONTAL_FRONT_PORCH,
> - mode->hsync_start - mode->hdisplay);
> + (mode->hsync_start - mode->hdisplay) / dual_factor);
> regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_FRONT_PORCH,
> mode->vsync_start - mode->vdisplay);
> regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, 0x00);
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-02-26 16:16 [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern Luca Ceresoli
2026-02-26 16:16 ` [PATCH 1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding Luca Ceresoli
2026-02-26 16:16 ` [PATCH 2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output Luca Ceresoli
@ 2026-02-26 16:16 ` Luca Ceresoli
2026-02-27 10:41 ` Marek Vasut
` (2 more replies)
2026-03-09 22:11 ` (subset) [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern Luca Ceresoli
3 siblings, 3 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-02-26 16:16 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Frieder Schrempf,
Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel, Luca Ceresoli
Generation of a test pattern output is a useful tool for panel bringup and
debugging, and very simple to support with this chip.
The value of REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW needs to be divided by two
for the test pattern to work in dual LVDS mode. While not clearly stated in
the datasheet, this is needed according to the DSI Tuner [0] output. And
some dual-LVDS panels refuse to show any picture without this division by
two.
[0] https://www.ti.com/tool/DSI-TUNER
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ti-sn65dsi83.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
index 17a885244e1e..ddc8b5e1dd15 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
@@ -114,6 +114,7 @@
#define REG_VID_CHA_HORIZONTAL_FRONT_PORCH 0x38
#define REG_VID_CHA_VERTICAL_FRONT_PORCH 0x3a
#define REG_VID_CHA_TEST_PATTERN 0x3c
+#define REG_VID_CHA_TEST_PATTERN_EN BIT(4)
/* IRQ registers */
#define REG_IRQ_GLOBAL 0xe0
#define REG_IRQ_GLOBAL_IRQ_EN BIT(0)
@@ -134,6 +135,9 @@
#define REG_IRQ_STAT_CHA_SOT_BIT_ERR BIT(2)
#define REG_IRQ_STAT_CHA_PLL_UNLOCK BIT(0)
+static bool sn65dsi83_test_pattern;
+module_param_named(test_pattern, sn65dsi83_test_pattern, bool, 0644);
+
enum sn65dsi83_channel {
CHANNEL_A,
CHANNEL_B
@@ -645,7 +649,11 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
REG_LVDS_LANE_CHB_LVDS_TERM : 0));
regmap_write(ctx->regmap, REG_LVDS_CM, 0x00);
- le16val = cpu_to_le16(mode->hdisplay);
+ /*
+ * Active line length needs to be halved for test pattern
+ * generation in dual LVDS output.
+ */
+ le16val = cpu_to_le16(mode->hdisplay / (sn65dsi83_test_pattern ? 2 : 1));
regmap_bulk_write(ctx->regmap, REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW,
&le16val, 2);
le16val = cpu_to_le16(mode->vdisplay);
@@ -668,7 +676,8 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
(mode->hsync_start - mode->hdisplay) / dual_factor);
regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_FRONT_PORCH,
mode->vsync_start - mode->vdisplay);
- regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, 0x00);
+ regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN,
+ sn65dsi83_test_pattern ? REG_VID_CHA_TEST_PATTERN_EN : 0);
/* Enable PLL */
regmap_write(ctx->regmap, REG_RC_PLL_EN, REG_RC_PLL_EN_PLL_EN);
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-02-26 16:16 ` [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support Luca Ceresoli
@ 2026-02-27 10:41 ` Marek Vasut
2026-02-27 10:57 ` Maxime Ripard
2026-02-27 12:57 ` Luca Ceresoli
2026-04-08 15:40 ` Louis Chauvet
2 siblings, 1 reply; 15+ messages in thread
From: Marek Vasut @ 2026-02-27 10:41 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel
On 2/26/26 5:16 PM, Luca Ceresoli wrote:
> Generation of a test pattern output is a useful tool for panel bringup and
> debugging, and very simple to support with this chip.
>
> The value of REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW needs to be divided by two
> for the test pattern to work in dual LVDS mode. While not clearly stated in
> the datasheet, this is needed according to the DSI Tuner [0] output. And
> some dual-LVDS panels refuse to show any picture without this division by
> two.
>
> [0] https://www.ti.com/tool/DSI-TUNER
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/ti-sn65dsi83.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> index 17a885244e1e..ddc8b5e1dd15 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> @@ -114,6 +114,7 @@
> #define REG_VID_CHA_HORIZONTAL_FRONT_PORCH 0x38
> #define REG_VID_CHA_VERTICAL_FRONT_PORCH 0x3a
> #define REG_VID_CHA_TEST_PATTERN 0x3c
> +#define REG_VID_CHA_TEST_PATTERN_EN BIT(4)
> /* IRQ registers */
> #define REG_IRQ_GLOBAL 0xe0
> #define REG_IRQ_GLOBAL_IRQ_EN BIT(0)
> @@ -134,6 +135,9 @@
> #define REG_IRQ_STAT_CHA_SOT_BIT_ERR BIT(2)
> #define REG_IRQ_STAT_CHA_PLL_UNLOCK BIT(0)
>
> +static bool sn65dsi83_test_pattern;
> +module_param_named(test_pattern, sn65dsi83_test_pattern, bool, 0644);
Can this be enabled/disabled at runtime via sysfs attribute instead ?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-02-27 10:41 ` Marek Vasut
@ 2026-02-27 10:57 ` Maxime Ripard
2026-02-27 12:58 ` Luca Ceresoli
0 siblings, 1 reply; 15+ messages in thread
From: Maxime Ripard @ 2026-02-27 10:57 UTC (permalink / raw)
To: Marek Vasut
Cc: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Frieder Schrempf, Marek Vasut, Linus Walleij, Thomas Petazzoni,
dri-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]
On Fri, Feb 27, 2026 at 11:41:29AM +0100, Marek Vasut wrote:
> On 2/26/26 5:16 PM, Luca Ceresoli wrote:
> > Generation of a test pattern output is a useful tool for panel bringup and
> > debugging, and very simple to support with this chip.
> >
> > The value of REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW needs to be divided by two
> > for the test pattern to work in dual LVDS mode. While not clearly stated in
> > the datasheet, this is needed according to the DSI Tuner [0] output. And
> > some dual-LVDS panels refuse to show any picture without this division by
> > two.
> >
> > [0] https://www.ti.com/tool/DSI-TUNER
> >
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > ---
> > drivers/gpu/drm/bridge/ti-sn65dsi83.c | 13 +++++++++++--
> > 1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> > index 17a885244e1e..ddc8b5e1dd15 100644
> > --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> > @@ -114,6 +114,7 @@
> > #define REG_VID_CHA_HORIZONTAL_FRONT_PORCH 0x38
> > #define REG_VID_CHA_VERTICAL_FRONT_PORCH 0x3a
> > #define REG_VID_CHA_TEST_PATTERN 0x3c
> > +#define REG_VID_CHA_TEST_PATTERN_EN BIT(4)
> > /* IRQ registers */
> > #define REG_IRQ_GLOBAL 0xe0
> > #define REG_IRQ_GLOBAL_IRQ_EN BIT(0)
> > @@ -134,6 +135,9 @@
> > #define REG_IRQ_STAT_CHA_SOT_BIT_ERR BIT(2)
> > #define REG_IRQ_STAT_CHA_PLL_UNLOCK BIT(0)
> > +static bool sn65dsi83_test_pattern;
> > +module_param_named(test_pattern, sn65dsi83_test_pattern, bool, 0644);
>
> Can this be enabled/disabled at runtime via sysfs attribute instead ?
Then you would have to deal with concurrency with the atomic state
updates, and it would really be better implemented as a connector
property.
In other words, it's probably enough for now :)
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-02-27 10:57 ` Maxime Ripard
@ 2026-02-27 12:58 ` Luca Ceresoli
0 siblings, 0 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-02-27 12:58 UTC (permalink / raw)
To: Maxime Ripard, Marek Vasut
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Frieder Schrempf,
Marek Vasut, Linus Walleij, Thomas Petazzoni, dri-devel,
linux-kernel
Hello Marek, Maxime,
On Fri Feb 27, 2026 at 11:57 AM CET, Maxime Ripard wrote:
>> > @@ -134,6 +135,9 @@
>> > #define REG_IRQ_STAT_CHA_SOT_BIT_ERR BIT(2)
>> > #define REG_IRQ_STAT_CHA_PLL_UNLOCK BIT(0)
>> > +static bool sn65dsi83_test_pattern;
>> > +module_param_named(test_pattern, sn65dsi83_test_pattern, bool, 0644);
>>
>> Can this be enabled/disabled at runtime via sysfs attribute instead ?
>
> Then you would have to deal with concurrency with the atomic state
> updates, and it would really be better implemented as a connector
> property.
>
> In other words, it's probably enough for now :)
I agree with Maxime, let's keep it simple, especially as it's a debugging
tool and nobody wants to debug a debugging tool. :)
It can be made more complex in the future if there is a real need.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-02-26 16:16 ` [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support Luca Ceresoli
2026-02-27 10:41 ` Marek Vasut
@ 2026-02-27 12:57 ` Luca Ceresoli
2026-04-08 15:40 ` Louis Chauvet
2 siblings, 0 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-02-27 12:57 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel
Hello,
On Thu Feb 26, 2026 at 5:16 PM CET, Luca Ceresoli wrote:
> Generation of a test pattern output is a useful tool for panel bringup and
> debugging, and very simple to support with this chip.
>
> The value of REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW needs to be divided by two
> for the test pattern to work in dual LVDS mode. While not clearly stated in
> the datasheet, this is needed according to the DSI Tuner [0] output. And
> some dual-LVDS panels refuse to show any picture without this division by
> two.
>
> [0] https://www.ti.com/tool/DSI-TUNER
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
I just noticed a small glitch in the implementation.
> +static bool sn65dsi83_test_pattern;
> +module_param_named(test_pattern, sn65dsi83_test_pattern, bool, 0644);
> +
> enum sn65dsi83_channel {
> CHANNEL_A,
> CHANNEL_B
> @@ -645,7 +649,11 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
> REG_LVDS_LANE_CHB_LVDS_TERM : 0));
> regmap_write(ctx->regmap, REG_LVDS_CM, 0x00);
>
> - le16val = cpu_to_le16(mode->hdisplay);
> + /*
> + * Active line length needs to be halved for test pattern
> + * generation in dual LVDS output.
> + */
> + le16val = cpu_to_le16(mode->hdisplay / (sn65dsi83_test_pattern ? 2 : 1));
In case sn65dsi83_test_pattern is changed from user space after this
cpu_to_le16()...
> regmap_bulk_write(ctx->regmap, REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW,
> &le16val, 2);
> le16val = cpu_to_le16(mode->vdisplay);
> @@ -668,7 +676,8 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
> (mode->hsync_start - mode->hdisplay) / dual_factor);
> regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_FRONT_PORCH,
> mode->vsync_start - mode->vdisplay);
> - regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, 0x00);
> + regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN,
> + sn65dsi83_test_pattern ? REG_VID_CHA_TEST_PATTERN_EN : 0);
...but before this regmap_write(), the two registers affected by
sn65dsi83_test_pattern would be written with inconsistent values.
I'm resending with that fixed.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-02-26 16:16 ` [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support Luca Ceresoli
2026-02-27 10:41 ` Marek Vasut
2026-02-27 12:57 ` Luca Ceresoli
@ 2026-04-08 15:40 ` Louis Chauvet
2026-04-08 16:13 ` Luca Ceresoli
2 siblings, 1 reply; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 15:40 UTC (permalink / raw)
To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel
On 2/26/26 17:16, Luca Ceresoli wrote:
> Generation of a test pattern output is a useful tool for panel bringup and
> debugging, and very simple to support with this chip.
>
> The value of REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW needs to be divided by two
> for the test pattern to work in dual LVDS mode. While not clearly stated in
> the datasheet, this is needed according to the DSI Tuner [0] output. And
> some dual-LVDS panels refuse to show any picture without this division by
> two.
>
> [0] https://www.ti.com/tool/DSI-TUNER
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/ti-sn65dsi83.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> index 17a885244e1e..ddc8b5e1dd15 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> @@ -114,6 +114,7 @@
> #define REG_VID_CHA_HORIZONTAL_FRONT_PORCH 0x38
> #define REG_VID_CHA_VERTICAL_FRONT_PORCH 0x3a
> #define REG_VID_CHA_TEST_PATTERN 0x3c
> +#define REG_VID_CHA_TEST_PATTERN_EN BIT(4)
> /* IRQ registers */
> #define REG_IRQ_GLOBAL 0xe0
> #define REG_IRQ_GLOBAL_IRQ_EN BIT(0)
> @@ -134,6 +135,9 @@
> #define REG_IRQ_STAT_CHA_SOT_BIT_ERR BIT(2)
> #define REG_IRQ_STAT_CHA_PLL_UNLOCK BIT(0)
>
> +static bool sn65dsi83_test_pattern;
> +module_param_named(test_pattern, sn65dsi83_test_pattern, bool, 0644);
> +
> enum sn65dsi83_channel {
> CHANNEL_A,
> CHANNEL_B
> @@ -645,7 +649,11 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
> REG_LVDS_LANE_CHB_LVDS_TERM : 0));
> regmap_write(ctx->regmap, REG_LVDS_CM, 0x00);
>
> - le16val = cpu_to_le16(mode->hdisplay);
> + /*
> + * Active line length needs to be halved for test pattern
> + * generation in dual LVDS output.
> + */
> + le16val = cpu_to_le16(mode->hdisplay / (sn65dsi83_test_pattern ? 2 : 1));
This will always half the line length, even for "mono" LVDS output no?
From the comment I expect something like
if (dual && test_pattern)
val = hdisplay/2
else
val = hdisplay
> regmap_bulk_write(ctx->regmap, REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW,
> &le16val, 2);
> le16val = cpu_to_le16(mode->vdisplay);
> @@ -668,7 +676,8 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
> (mode->hsync_start - mode->hdisplay) / dual_factor);
> regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_FRONT_PORCH,
> mode->vsync_start - mode->vdisplay);
> - regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, 0x00);
> + regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN,
> + sn65dsi83_test_pattern ? REG_VID_CHA_TEST_PATTERN_EN : 0);
>
(sn65dsi83_test_pattern is not "atomic", but you already saw it)
> /* Enable PLL */
> regmap_write(ctx->regmap, REG_RC_PLL_EN, REG_RC_PLL_EN_PLL_EN);
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support
2026-04-08 15:40 ` Louis Chauvet
@ 2026-04-08 16:13 ` Luca Ceresoli
0 siblings, 0 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-08 16:13 UTC (permalink / raw)
To: Louis Chauvet, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Frieder Schrempf, Marek Vasut, Linus Walleij
Cc: Thomas Petazzoni, dri-devel, linux-kernel
Hi Louis,
On Wed Apr 8, 2026 at 5:40 PM CEST, Louis Chauvet wrote:
>> @@ -645,7 +649,11 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
>> REG_LVDS_LANE_CHB_LVDS_TERM : 0));
>> regmap_write(ctx->regmap, REG_LVDS_CM, 0x00);
>>
>> - le16val = cpu_to_le16(mode->hdisplay);
>> + /*
>> + * Active line length needs to be halved for test pattern
>> + * generation in dual LVDS output.
>> + */
>> + le16val = cpu_to_le16(mode->hdisplay / (sn65dsi83_test_pattern ? 2 : 1));
>
> This will always half the line length, even for "mono" LVDS output no?
> From the comment I expect something like
>
> if (dual && test_pattern)
> val = hdisplay/2
> else
> val = hdisplay
Aargh, my bad! I think what my brain wanted to write was rather:
le16val = cpu_to_le16(mode->hdisplay / (sn65dsi83_test_pattern ? dual_factor : 1));
^^^^^^^^^^^
which is equivalent to your code. Will fix in v3.
Thanks for the thourough review!
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: (subset) [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern
2026-02-26 16:16 [PATCH 0/3] drm/bridge: ti-sn65dsi83: two fixes + add test pattern Luca Ceresoli
` (2 preceding siblings ...)
2026-02-26 16:16 ` [PATCH 3/3] drm/bridge: ti-sn65dsi83: add test pattern generation support Luca Ceresoli
@ 2026-03-09 22:11 ` Luca Ceresoli
3 siblings, 0 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-03-09 22:11 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Frieder Schrempf,
Marek Vasut, Linus Walleij, Luca Ceresoli
Cc: Thomas Petazzoni, dri-devel, linux-kernel, stable
On Thu, 26 Feb 2026 17:16:43 +0100, Luca Ceresoli wrote:
> This series fixes two bugs in the driver code and adds support for enabling
> the test pattern output from userspace.
>
>
Applied, thanks!
[1/3] drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding
commit: 2f22702dc0fee06a240404e0f7ead5b789b253d8
[2/3] drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output
commit: d0d727746944096a6681dc6adb5f123fc5aa018d
Best regards,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
^ permalink raw reply [flat|nested] 15+ messages in thread