Skip to contentSkip to conversation

drm/bridge: ti-sn65dsi86: Fix output polarity setting bug

PATCH In review Qiqi Zhang 4 participants 6 messages Nov 25, 2022 – Nov 30, 2022

Subsystems (4)
lore
Share & tools
lore

Qiqi Zhang

author
#0 lore raw

PATCH 1/1 drm/bridge: ti-sn65dsi86: Fix output polarity setting bug

According to the description in ti-sn65dsi86's datasheet:

CHA_HSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

CHA_VSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (Default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

We should only set these bits when the polarity is negative.

---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +2 -2
index 3c3561942eb6..eb24322df721 100644
@@ -931,9 +931,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata)
 		&pdata->bridge.encoder->crtc->state->adjusted_mode;
 	u8 hsync_polarity = 0, vsync_polarity = 0;
 
-	if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
 		hsync_polarity = CHA_HSYNC_POLARITY;
-	if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+	if (mode->flags & DRM_MODE_FLAG_NVSYNC)
 		vsync_polarity = CHA_VSYNC_POLARITY;
 
 	ti_sn65dsi86_write_u16(pdata, SN_CHA_ACTIVE_LINE_LENGTH_LOW_REG,
Signature · 1 line
2.25.1
#1 lore raw

Adding Tomi to the CC list. Tomi, would you be able to test this ?

Quoted 36 lines · Qiqi Zhang

According to the description in ti-sn65dsi86's datasheet:

CHA_HSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

CHA_VSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (Default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

We should only set these bits when the polarity is negative.

---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +2 -2
index 3c3561942eb6..eb24322df721 100644
@@ -931,9 +931,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata)
 		&pdata->bridge.encoder->crtc->state->adjusted_mode;
 	u8 hsync_polarity = 0, vsync_polarity = 0;
 
-	if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
 		hsync_polarity = CHA_HSYNC_POLARITY;
-	if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+	if (mode->flags & DRM_MODE_FLAG_NVSYNC)
 		vsync_polarity = CHA_VSYNC_POLARITY;
 
 	ti_sn65dsi86_write_u16(pdata, SN_CHA_ACTIVE_LINE_LENGTH_LOW_REG,
Signature · 3 lines
Regards,

Laurent Pinchart
reviewer Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Qiqi Zhang

Hi,

Quoted 26 lines · Qiqi Zhang

According to the description in ti-sn65dsi86's datasheet:

CHA_HSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

CHA_VSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (Default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

We should only set these bits when the polarity is negative.

---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +0 -0
index 3c3561942eb6..eb24322df721 100644

drivers/gpu/drm/bridge/ti-sn65dsi86.c static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata) · line 937

Quoted 9 lines
drivers/gpu/drm/bridge/ti-sn65dsi86.c +2 -2
@@ -931,9 +931,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata)
                &pdata->bridge.encoder->crtc->state->adjusted_mode;
        u8 hsync_polarity = 0, vsync_polarity = 0;
 
-       if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
                hsync_polarity = CHA_HSYNC_POLARITY;
-       if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
                vsync_polarity = CHA_VSYNC_POLARITY;

Looks right to me.

I've never seen the polarity matter for any eDP panels I've worked with, which presumably explains why this was wrong for so long. As far as I can tell, it's been wrong since the start. Probably you should have:

Fixes a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")

I put this on a sc7180-trogdor-lazor device and it didn't make anything worse. Since the sync polarity never mattered to begin with, I guess this isn't a surprise. ...so I guess that's a weak tested-by:

I'm happy to land this patch, but sounds like we're hoping to get extra testing so I'll hold off for now.

-Doug

Reviewed-by
#3 lore raw
Quoted 41 lines · Doug Anderson

Hi,

Quoted 26 lines · Qiqi Zhang

According to the description in ti-sn65dsi86's datasheet:

CHA_HSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

CHA_VSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (Default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

We should only set these bits when the polarity is negative.

---
  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +0 -0
index 3c3561942eb6..eb24322df721 100644

drivers/gpu/drm/bridge/ti-sn65dsi86.c static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata) · line 937

Quoted 9 lines
drivers/gpu/drm/bridge/ti-sn65dsi86.c +2 -2
@@ -931,9 +931,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata)
                 &pdata->bridge.encoder->crtc->state->adjusted_mode;
         u8 hsync_polarity = 0, vsync_polarity = 0;
 
-       if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
                 hsync_polarity = CHA_HSYNC_POLARITY;
-       if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
                 vsync_polarity = CHA_VSYNC_POLARITY;

Looks right to me.

Quoted 4 lines

I've never seen the polarity matter for any eDP panels I've worked with, which presumably explains why this was wrong for so long. As far

Afaik, DP doesn't have sync polarity as such (neither does DSI), and the sync polarity is just "metadata". So if you're in full-DP domain, I don't see why it would matter. I guess it becomes relevant when you convert from DP to some other bus format.

Quoted 5 lines

as I can tell, it's been wrong since the start. Probably you should have:

Fixes a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")
Quoted 8 lines

I put this on a sc7180-trogdor-lazor device and it didn't make anything worse. Since the sync polarity never mattered to begin with, I guess this isn't a surprise. ...so I guess that's a weak tested-by:

I'm happy to land this patch, but sounds like we're hoping to get extra testing so I'll hold off for now.

Looks fine to me and works for me with my DP monitor.

Tomi

author
#4 lore raw

Hi,

Quoted 44 lines · on Nov. 29, 2022, 11:45 a.m. Tomi wrote:
Quoted 43 lines · Doug Anderson

Hi,

Quoted 26 lines · Qiqi Zhang

According to the description in ti-sn65dsi86's datasheet:

CHA_HSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

CHA_VSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (Default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

We should only set these bits when the polarity is negative.

---
  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +0 -0
index 3c3561942eb6..eb24322df721 100644

drivers/gpu/drm/bridge/ti-sn65dsi86.c static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata) · line 937

Quoted 9 lines
drivers/gpu/drm/bridge/ti-sn65dsi86.c +2 -2
@@ -931,9 +931,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata)
                 &pdata->bridge.encoder->crtc->state->adjusted_mode;
         u8 hsync_polarity = 0, vsync_polarity = 0;
 
-       if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
                 hsync_polarity = CHA_HSYNC_POLARITY;
-       if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
                 vsync_polarity = CHA_VSYNC_POLARITY;

Looks right to me.

Quoted 7 lines
Quoted 2 lines

I've never seen the polarity matter for any eDP panels I've worked with, which presumably explains why this was wrong for so long. As far

Afaik, DP doesn't have sync polarity as such (neither does DSI), and the sync polarity is just "metadata". So if you're in full-DP domain, I don't see why it would matter. I guess it becomes relevant when you convert from DP to some other bus format.

Just like Tomi said, the wrong polarity worked fine on my eDP panel(LP079QX1) and standard DP monitor, I didn't notice the polarity configuration problem here until my customer used the following solution and got a abnormal display:
GPU->mipi->eDP->DP->lvds->panel.

Quoted 4 lines
Quoted 4 lines

as I can tell, it's been wrong since the start. Probably you should have:

Fixes a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")

Doug you mean I need to update my commit message? It's my first time using kernel list and I'm a little confused about this.

Quoted 5 lines
Quoted 5 lines

I put this on a sc7180-trogdor-lazor device and it didn't make anything worse. Since the sync polarity never mattered to begin with, I guess this isn't a surprise. ...so I guess that's a weak tested-by:

Quoted 8 lines
Quoted 4 lines

I'm happy to land this patch, but sounds like we're hoping to get extra testing so I'll hold off for now.

Looks fine to me and works for me with my DP monitor.

-Eddy

reviewer
#5 lore raw

Hi,

Quoted 56 lines · Qiqi Zhang

Hi,

Quoted 44 lines · on Nov. 29, 2022, 11:45 a.m. Tomi wrote:
Quoted 43 lines · Doug Anderson

Hi,

Quoted 26 lines · Qiqi Zhang

According to the description in ti-sn65dsi86's datasheet:

CHA_HSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

CHA_VSYNC_POLARITY:
0 = Active High Pulse. Synchronization signal is high for the sync pulse width. (Default)
1 = Active Low Pulse. Synchronization signal is low for the sync pulse width.

We should only set these bits when the polarity is negative.

---
  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +0 -0
index 3c3561942eb6..eb24322df721 100644

drivers/gpu/drm/bridge/ti-sn65dsi86.c static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata) · line 937

Quoted 9 lines
drivers/gpu/drm/bridge/ti-sn65dsi86.c +2 -2
@@ -931,9 +931,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata)
                 &pdata->bridge.encoder->crtc->state->adjusted_mode;
         u8 hsync_polarity = 0, vsync_polarity = 0;
 
-       if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
                 hsync_polarity = CHA_HSYNC_POLARITY;
-       if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
                 vsync_polarity = CHA_VSYNC_POLARITY;

Looks right to me.

Quoted 7 lines
Quoted 2 lines

I've never seen the polarity matter for any eDP panels I've worked with, which presumably explains why this was wrong for so long. As far

Afaik, DP doesn't have sync polarity as such (neither does DSI), and the sync polarity is just "metadata". So if you're in full-DP domain, I don't see why it would matter. I guess it becomes relevant when you convert from DP to some other bus format.

Quoted 4 lines

Just like Tomi said, the wrong polarity worked fine on my eDP panel(LP079QX1) and standard DP monitor, I didn't notice the polarity configuration problem here until my customer used the following solution and got a abnormal display:
GPU->mipi->eDP->DP->lvds->panel.

Wow, that's convoluted, but makes sense. I think this fully explains why this is a problem for you but wasn't in the past.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

as I can tell, it's been wrong since the start. Probably you should have:

Fixes a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")

Doug you mean I need to update my commit message? It's my first time using kernel list and I'm a little confused about this.

Nah, I'll add it in and land it. OK, pushed to drm-misc-fixes:

8c115864501f drm/bridge: ti-sn65dsi86: Fix output polarity setting bug