Skip to contentSkip to conversation

drm/sun4i: dsi: Add burst mode support

PATCH Superseded Maxime Ripard 4 participants 18 messages Feb 8, 2019 – Mar 19, 2019

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm/sun4i: dsi: Add burst mode support

Hi,

Here is a series implementing the burst mode support for DSI.

It's been tested on an A33 board with the panel supported on the last patch, which should remove all quirks due to a different SoC from the equation.

Let me know what you think,
Maxime

Changes from v2:
- Change the start delay calculation according to the legacy driver in Allwinner's BSP
- Fixed the edge calculation to add the same parentheses around the factors
- Added a bunch of fixes to timings
- Added a patch to make hblk computation more accurate, and added a comment
- Renamed the panel to Ronbo and fixed a bunch of things
- Added the Reviewed-By

Konstantin Sudakov (2):
drm/sun4i: dsi: Add burst support
drm/panel: Add Ronbo RB070D30 panel

Maxime Ripard (7):
fixup! ARM: dts: sun8i-a33: bridgemate: Enable display support drm/sun4i: dsi: Restrict DSI tcon clock divider drm/sun4i: dsi: Change the start delay calculation drm/sun4i: dsi: Enforce boundaries on the start delay drm/sun4i: dsi: Fix front vs back porch calculation drm/sun4i: dsi: Fix DRQ calculation
drm/sun4i: dsi: Rework a bit the hblk calculation

 arch/arm/boot/dts/sun8i-a33-bridgemate-bm3.dts |   2 +-
 drivers/gpu/drm/panel/Kconfig                  |   9 +-
 drivers/gpu/drm/panel/Makefile                 |   1 +-
 drivers/gpu/drm/panel/panel-ronbo-rb070d30.c   | 262 ++++++++++++++++++-
 drivers/gpu/drm/sun4i/sun4i_tcon.c             |   4 +-
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c         | 183 ++++++++++---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h         |   2 +-
 7 files changed, 420 insertions(+), 43 deletions(-)
 create mode 100644 drivers/gpu/drm/panel/panel-ronbo-rb070d30.c

base-commit: f6028e7e48b0f3865b0837d400ca783d3d200b62

Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v2 1/9 fixup! ARM: dts: sun8i-a33: bridgemate: Enable display support

---
 arch/arm/boot/dts/sun8i-a33-bridgemate-bm3.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/sun8i-a33-bridgemate-bm3.dts +1 -1
index ea12d12bf221..c26316465dc0 100644
@@ -106,7 +106,7 @@
 	status = "okay";
 
 	panel@0 {
-		compatible = "rondo,rb070d30";
+		compatible = "ronbo,rb070d30";
 		reg = <0>;
 		power-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>;
 		updn-gpios = <&r_pio 0 7 GPIO_ACTIVE_HIGH>;
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH v2 1/9] fixup! ARM: dts: sun8i-a33: bridgemate: Enable display support

Quoted 3 lines · Maxime Ripard
---
 arch/arm/boot/dts/sun8i-a33-bridgemate-bm3.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Erm, that one should be ignored obviously...

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

PATCH v2 2/9 drm/sun4i: dsi: Restrict DSI tcon clock divider

In reply to Maxime Ripard

The current code allows the TCON clock divider to have a range between 4 and 127 when feeding the DSI controller.

The only display supported so far had a display clock rate that ended up using a divider of 4, but testing with other displays show that only 4 seems to be functional.

This also aligns with what Allwinner is doing in their BSP, so let's just hardcode that we want a divider of 4 when using the DSI output.

---
 drivers/gpu/drm/sun4i/sun4i_tcon.c     | 4 ++--
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun4i_tcon.c +2 -2
index 0420f5c978b9..bee73ead732a 100644
@@ -341,8 +341,8 @@ static void sun4i_tcon0_mode_set_cpu(struct sun4i_tcon *tcon,
 	u32 block_space, start_delay;
 	u32 tcon_div;
 
-	tcon->dclk_min_div = 4;
-	tcon->dclk_max_div = 127;
+	tcon->dclk_min_div = SUN6I_DSI_TCON_DIV;
+	tcon->dclk_max_div = SUN6I_DSI_TCON_DIV;
 
 	sun4i_tcon0_mode_set_common(tcon, mode);
 
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +2 -0
index dbbc5b3ecbda..6d4a3c0fd9b5 100644
@@ -13,6 +13,8 @@
 #include <drm/drm_encoder.h>
 #include <drm/drm_mipi_dsi.h>
 
+#define SUN6I_DSI_TCON_DIV	4
+
 struct sun6i_dphy {
 	struct clk		*bus_clk;
 	struct clk		*mod_clk;
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH v2 3/9 drm/sun4i: dsi: Change the start delay calculation

In reply to Maxime Ripard

The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1.

That 1 is coming in the Allwinner BSP from an variable that is set to 1. However, if we look at the Allwinner BSP more closely, and especially in the "legacy" code for the display (in drivers/video/sunxi/legacy/), we can see that this variable is actually computed from the porches and the sync minus 10, clamped between 8 and 100.

This fixes the start delay symptom we've seen on some panels (vblank timeouts with vertical white stripes at the bottom of the panel).

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +3 -1
index 380fc527a707..9471fa695ec7 100644
@@ -357,7 +357,9 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
 static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
 					   struct drm_display_mode *mode)
 {
-	return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
+	u16 start = clamp(mode->vtotal - mode->vdisplay - 10, 8, 100);
+
+	return mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
 }
 
 static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH v2 3/9] drm/sun4i: dsi: Change the start delay calculation

Hi Maxime,

Quoted 24 lines · Maxime Ripard

The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1.

That 1 is coming in the Allwinner BSP from an variable that is set to 1. However, if we look at the Allwinner BSP more closely, and especially in the "legacy" code for the display (in drivers/video/sunxi/legacy/), we can see that this variable is actually computed from the porches and the sync minus 10, clamped between 8 and 100.

This fixes the start delay symptom we've seen on some panels (vblank timeouts with vertical white stripes at the bottom of the panel).

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +0 -0
index 380fc527a707..9471fa695ec7 100644

drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, · line 363

Quoted 8 lines
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +3 -1
@@ -357,7 +357,9 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
 static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
                                           struct drm_display_mode *mode)
 {
-       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
+       u16 start = clamp(mode->vtotal - mode->vdisplay - 10, 8, 100);
+
+       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
 }

As you stated in commit message about result as "active vertical size
+ Back porch" which indeed correct in reverse way of previous code. but the change seems incorrect to me.

=> mode->vtotal - (mode->vsync_end - mode->vdisplay) + start => mode->vtotal - (mode->vsync_end - mode->vdisplay) + (mode->vtotal - mode->vdisplay) # bypass 10 for now
=> mode->vtotal - mode->vsync_end + mode->vdisplay + mode->vtotal - mode->vdisplay
=> (mode->vtotal - mode->vsync_end) + mode->vtotal
=> Back porch + mode->vtotal

but not
=> Back porch + mode->vdisplay

Let me know if I'm wrong?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH v2 3/9] drm/sun4i: dsi: Change the start delay calculation

Quoted 48 lines · Jagan Teki

Hi Maxime,

Quoted 24 lines · Maxime Ripard

The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1.

That 1 is coming in the Allwinner BSP from an variable that is set to 1. However, if we look at the Allwinner BSP more closely, and especially in the "legacy" code for the display (in drivers/video/sunxi/legacy/), we can see that this variable is actually computed from the porches and the sync minus 10, clamped between 8 and 100.

This fixes the start delay symptom we've seen on some panels (vblank timeouts with vertical white stripes at the bottom of the panel).

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +0 -0
index 380fc527a707..9471fa695ec7 100644

drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, · line 363

Quoted 8 lines
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +3 -1
@@ -357,7 +357,9 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
 static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
                                           struct drm_display_mode *mode)
 {
-       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
+       u16 start = clamp(mode->vtotal - mode->vdisplay - 10, 8, 100);
+
+       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
 }

As you stated in commit message about result as "active vertical size
+ Back porch" which indeed correct in reverse way of previous code. but the change seems incorrect to me.

=> mode->vtotal - (mode->vsync_end - mode->vdisplay) + start => mode->vtotal - (mode->vsync_end - mode->vdisplay) + (mode->vtotal - mode->vdisplay) # bypass 10 for now
=> mode->vtotal - mode->vsync_end + mode->vdisplay + mode->vtotal - mode->vdisplay
=> (mode->vtotal - mode->vsync_end) + mode->vtotal
=> Back porch + mode->vtotal

Quoted 2 lines

but not
=> Back porch + mode->vdisplay

Why do you think it should be this result?

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH v2 3/9] drm/sun4i: dsi: Change the start delay calculation

Quoted 50 lines · Maxime Ripard
Quoted 48 lines · Jagan Teki

Hi Maxime,

Quoted 24 lines · Maxime Ripard

The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1.

That 1 is coming in the Allwinner BSP from an variable that is set to 1. However, if we look at the Allwinner BSP more closely, and especially in the "legacy" code for the display (in drivers/video/sunxi/legacy/), we can see that this variable is actually computed from the porches and the sync minus 10, clamped between 8 and 100.

This fixes the start delay symptom we've seen on some panels (vblank timeouts with vertical white stripes at the bottom of the panel).

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +0 -0
index 380fc527a707..9471fa695ec7 100644

drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, · line 363

Quoted 8 lines
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +3 -1
@@ -357,7 +357,9 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
 static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
                                           struct drm_display_mode *mode)
 {
-       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
+       u16 start = clamp(mode->vtotal - mode->vdisplay - 10, 8, 100);
+
+       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
 }

As you stated in commit message about result as "active vertical size
+ Back porch" which indeed correct in reverse way of previous code. but the change seems incorrect to me.

=> mode->vtotal - (mode->vsync_end - mode->vdisplay) + start => mode->vtotal - (mode->vsync_end - mode->vdisplay) + (mode->vtotal - mode->vdisplay) # bypass 10 for now
=> mode->vtotal - mode->vsync_end + mode->vdisplay + mode->vtotal - mode->vdisplay
=> (mode->vtotal - mode->vsync_end) + mode->vtotal
=> Back porch + mode->vtotal

Quoted 4 lines
Quoted 2 lines

but not
=> Back porch + mode->vdisplay

Why do you think it should be this result?

This is what the commit messages mentioned. which indeed true.

"The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1."

But the result of the logic is
=> Back porch + mode->vtotal
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH v2 3/9] drm/sun4i: dsi: Change the start delay calculation

Quoted 56 lines · Jagan Teki
Quoted 50 lines · Maxime Ripard
Quoted 48 lines · Jagan Teki

Hi Maxime,

Quoted 24 lines · Maxime Ripard

The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1.

That 1 is coming in the Allwinner BSP from an variable that is set to 1. However, if we look at the Allwinner BSP more closely, and especially in the "legacy" code for the display (in drivers/video/sunxi/legacy/), we can see that this variable is actually computed from the porches and the sync minus 10, clamped between 8 and 100.

This fixes the start delay symptom we've seen on some panels (vblank timeouts with vertical white stripes at the bottom of the panel).

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +0 -0
index 380fc527a707..9471fa695ec7 100644

drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, · line 363

Quoted 8 lines
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +3 -1
@@ -357,7 +357,9 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
 static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
                                           struct drm_display_mode *mode)
 {
-       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
+       u16 start = clamp(mode->vtotal - mode->vdisplay - 10, 8, 100);
+
+       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
 }

As you stated in commit message about result as "active vertical size
+ Back porch" which indeed correct in reverse way of previous code. but the change seems incorrect to me.

=> mode->vtotal - (mode->vsync_end - mode->vdisplay) + start => mode->vtotal - (mode->vsync_end - mode->vdisplay) + (mode->vtotal - mode->vdisplay) # bypass 10 for now
=> mode->vtotal - mode->vsync_end + mode->vdisplay + mode->vtotal - mode->vdisplay
=> (mode->vtotal - mode->vsync_end) + mode->vtotal
=> Back porch + mode->vtotal

Quoted 4 lines
Quoted 2 lines

but not
=> Back porch + mode->vdisplay

Why do you think it should be this result?

Quoted 8 lines

This is what the commit messages mentioned. which indeed true.

"The current calculation for the video start delay in the current DSI driver is that it is the total vertical size, minus the front porch and sync length, plus 1. This equals to the active vertical size plus the back porch plus 1."

But the result of the logic is
=> Back porch + mode->vtotal

Again, that commit was assuming that the back porch contained the sync period, which doesn't seem to be the case. So I'll ask again, what makes you say this isn't true?

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

PATCH v2 4/9 drm/sun4i: dsi: Enforce boundaries on the start delay

In reply to Maxime Ripard

The Allwinner BSP makes sure that we don't end up with a null start delay or with a delay larger than vtotal.

The former condition is likely to happen now with the reworked start delay, so make sure we enforce the same boundaries.

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +5 -1
index 9471fa695ec7..506f2e8cf454 100644
@@ -358,8 +358,12 @@ static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
 					   struct drm_display_mode *mode)
 {
 	u16 start = clamp(mode->vtotal - mode->vdisplay - 10, 8, 100);
+	u16 delay = mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
 
-	return mode->vtotal - (mode->vsync_end - mode->vdisplay) + start;
+	if (delay > mode->vtotal)
+		delay = delay % mode->vtotal;
+
+	return max_t(u16, delay, 1);
 }
 
 static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH v2 5/9 drm/sun4i: dsi: Fix front vs back porch calculation

In reply to Maxime Ripard

Since I always confuse the back and front porches, a few miscalculation slipped through. Fix them.

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +4 -4
index 506f2e8cf454..2518a0d7567c 100644
@@ -477,7 +477,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
 	 */
 #define HBP_PACKET_OVERHEAD	6
 	hbp = max((unsigned int)HBP_PACKET_OVERHEAD,
-		  (mode->hsync_start - mode->hdisplay) * Bpp - HBP_PACKET_OVERHEAD);
+		  (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD);
 
 	/*
 	 * The frontporch is set using a blanking packet (4 bytes +
@@ -485,7 +485,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
 	 */
 #define HFP_PACKET_OVERHEAD	6
 	hfp = max((unsigned int)HFP_PACKET_OVERHEAD,
-		  (mode->htotal - mode->hsync_end) * Bpp - HFP_PACKET_OVERHEAD);
+		  (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD);
 
 	/*
 	 * hblk seems to be the line + porches length.
@@ -531,8 +531,8 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
 	regmap_write(dsi->regs, SUN6I_DSI_BASIC_SIZE0_REG,
 		     SUN6I_DSI_BASIC_SIZE0_VSA(mode->vsync_end -
 					       mode->vsync_start) |
-		     SUN6I_DSI_BASIC_SIZE0_VBP(mode->vsync_start -
-					       mode->vdisplay));
+		     SUN6I_DSI_BASIC_SIZE0_VBP(mode->vtotal -
+					       mode->vsync_end));
 
 	regmap_write(dsi->regs, SUN6I_DSI_BASIC_SIZE1_REG,
 		     SUN6I_DSI_BASIC_SIZE1_VACT(mode->vdisplay) |
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH v2 6/9 drm/sun4i: dsi: Fix DRQ calculation

In reply to Maxime Ripard

The DRQ calculation code in the Allwinner BSP uses the vertical front porch value as the condition, but we're using the video back porch.

Since I always confuse the two, and I'm the original author of that code, I guess I deserved a brown paper bag.

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +2 -2
index 2518a0d7567c..8e6392831e9d 100644
@@ -372,9 +372,9 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,
 	struct mipi_dsi_device *device = dsi->device;
 	u32 val = 0;
 
-	if ((mode->hsync_end - mode->hdisplay) > 20) {
+	if ((mode->hsync_start - mode->hdisplay) > 20) {
 		/* Maaaaaagic */
-		u16 drq = (mode->hsync_end - mode->hdisplay) - 20;
+		u16 drq = (mode->hsync_start - mode->hdisplay) - 20;
 
 		drq *= mipi_dsi_pixel_format_to_bpp(device->format);
 		drq /= 32;
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH v2 7/9 drm/sun4i: dsi: Rework a bit the hblk calculation

In reply to Maxime Ripard

It turns out that the hblk calculation actually follows a similar pattern than the other packets. Rework a bit the calculation and add a comment.

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +6 -2
index 8e6392831e9d..e0288e7dc64e 100644
@@ -488,9 +488,13 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
 		  (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD);
 
 	/*
-	 * hblk seems to be the line + porches length.
+	 * The blanking is set using a sync event (4 bytes) and a
+	 * blanking packet (4 bytes + payload + 2 bytes). Its minimal
+	 * size is therefore 10 bytes.
 	 */
-	hblk = mode->htotal * Bpp - hsa;
+#define HBLK_PACKET_OVERHEAD	10
+	hblk = max((unsigned int)HBLK_PACKET_OVERHEAD,
+		   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - HBLK_PACKET_OVERHEAD);
 
 	/*
 	 * And I'm not entirely sure what vblk is about. The driver in
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH v2 8/9 drm/sun4i: dsi: Add burst support

In reply to Maxime Ripard

From: Konstantin Sudakov <[email protected]>

The current driver doesn't support the DSI burst operation mode.

Let's add the needed quirks to make it work.

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 171 ++++++++++++++++++++------
 1 file changed, 132 insertions(+), 39 deletions(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +132 -39
index e0288e7dc64e..4cb715dc9100 100644
@@ -23,7 +23,9 @@
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_panel.h>
 
+#include "sun4i_crtc.h"
 #include "sun4i_drv.h"
+#include "sun4i_tcon.h"
 #include "sun6i_mipi_dsi.h"
 
 #include <video/mipi_display.h>
@@ -32,6 +34,8 @@
 #define SUN6I_DSI_CTL_EN			BIT(0)
 
 #define SUN6I_DSI_BASIC_CTL_REG		0x00c
+#define SUN6I_DSI_BASIC_CTL_TRAIL_INV(n)		(((n) & 0xf) << 4)
+#define SUN6I_DSI_BASIC_CTL_TRAIL_FILL		BIT(3)
 #define SUN6I_DSI_BASIC_CTL_HBP_DIS		BIT(2)
 #define SUN6I_DSI_BASIC_CTL_HSA_HSE_DIS		BIT(1)
 #define SUN6I_DSI_BASIC_CTL_VIDEO_BURST		BIT(0)
@@ -152,6 +156,8 @@
 
 #define SUN6I_DSI_CMD_TX_REG(n)		(0x300 + (n) * 0x04)
 
+#define SUN6I_DSI_SYNC_POINT		40
+
 enum sun6i_dsi_start_inst {
 	DSI_START_LPRX,
 	DSI_START_LPTX,
@@ -366,13 +372,70 @@ static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
 	return max_t(u16, delay, 1);
 }
 
+static u16 sun6i_dsi_get_line_num(struct sun6i_dsi *dsi,
+				  struct drm_display_mode *mode)
+{
+	struct mipi_dsi_device *device = dsi->device;
+	unsigned Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8;
+
+	return mode->htotal * Bpp / device->lanes;
+}
+
+static u16 sun6i_dsi_get_drq_edge0(struct sun6i_dsi *dsi,
+				   struct drm_display_mode *mode,
+				   u16 line_num, u16 edge1)
+{
+	u16 edge0 = edge1;
+
+	edge0 += (mode->hdisplay + 40) * SUN6I_DSI_TCON_DIV / 8;
+
+	if (edge0 > line_num)
+		return edge0 - line_num;
+
+	return 1;
+}
+
+static u16 sun6i_dsi_get_drq_edge1(struct sun6i_dsi *dsi,
+				   struct drm_display_mode *mode,
+				   u16 line_num)
+{
+	struct mipi_dsi_device *device = dsi->device;
+	unsigned Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8;
+	unsigned hbp = mode->htotal - mode->hsync_end;
+	u16 edge1;
+
+	edge1 = SUN6I_DSI_SYNC_POINT;
+	edge1 += (mode->hdisplay + hbp + 20) * Bpp / device->lanes;
+
+	if (edge1 > line_num)
+		return line_num;
+
+	return edge1;
+}
+
 static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,
 				  struct drm_display_mode *mode)
 {
 	struct mipi_dsi_device *device = dsi->device;
 	u32 val = 0;
 
-	if ((mode->hsync_start - mode->hdisplay) > 20) {
+	if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
+		u16 line_num = sun6i_dsi_get_line_num(dsi, mode);
+		u16 edge0, edge1;
+
+		edge1 = sun6i_dsi_get_drq_edge1(dsi, mode, line_num);
+		edge0 = sun6i_dsi_get_drq_edge0(dsi, mode, line_num, edge1);
+
+		regmap_write(dsi->regs, SUN6I_DSI_BURST_DRQ_REG,
+			     SUN6I_DSI_BURST_DRQ_EDGE0(edge0) |
+			     SUN6I_DSI_BURST_DRQ_EDGE1(edge1));
+
+		regmap_write(dsi->regs, SUN6I_DSI_BURST_LINE_REG,
+			     SUN6I_DSI_BURST_LINE_NUM(line_num) |
+			     SUN6I_DSI_BURST_LINE_SYNC_POINT(SUN6I_DSI_SYNC_POINT));
+
+		val = SUN6I_DSI_TCON_DRQ_ENABLE_MODE;
+	} else if ((mode->hsync_start - mode->hdisplay) > 20) {
 		/* Maaaaaagic */
 		u16 drq = (mode->hsync_start - mode->hdisplay) - 20;
 
@@ -389,8 +452,19 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,
 static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi,
 				      struct drm_display_mode *mode)
 {
+	struct mipi_dsi_device *device = dsi->device;
 	u16 delay = 50 - 1;
 
+	if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
+		delay = (mode->htotal - mode->hdisplay) * 150;
+		delay /= (mode->clock / 1000) * 8;
+		delay -= 50;
+	}
+
+	regmap_write(dsi->regs, SUN6I_DSI_INST_LOOP_SEL_REG,
+			 2 << (4 * DSI_INST_ID_LP11) |
+			 3 << (4 * DSI_INST_ID_DLY));
+
 	regmap_write(dsi->regs, SUN6I_DSI_INST_LOOP_NUM_REG(0),
 		     SUN6I_DSI_INST_LOOP_NUM_N0(50 - 1) |
 		     SUN6I_DSI_INST_LOOP_NUM_N1(delay));
@@ -457,52 +531,71 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
 	struct mipi_dsi_device *device = dsi->device;
 	unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8;
 	u16 hbp, hfp, hsa, hblk, vblk;
+	u32 basic_ctl = 0;
 	size_t bytes;
 	u8 *buffer;
 
 	/* Do all timing calculations up front to allocate buffer space */
 
-	/*
-	 * A sync period is composed of a blanking packet (4 bytes +
-	 * payload + 2 bytes) and a sync event packet (4 bytes). Its
-	 * minimal size is therefore 10 bytes
-	 */
+	if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
+		hsa = 0;
+		hbp = 0;
+		hfp = 0;
+		hblk = mode->hdisplay * Bpp;
+		vblk = 0;
+		basic_ctl = SUN6I_DSI_BASIC_CTL_VIDEO_BURST |
+			    SUN6I_DSI_BASIC_CTL_HSA_HSE_DIS |
+			    SUN6I_DSI_BASIC_CTL_HBP_DIS;
+
+		if (device->lanes == 4)
+			basic_ctl |= SUN6I_DSI_BASIC_CTL_TRAIL_FILL |
+				     SUN6I_DSI_BASIC_CTL_TRAIL_INV(0xc);
+	} else {
+		/*
+		 * A sync period is composed of a blanking packet (4
+		 * bytes + payload + 2 bytes) and a sync event packet
+		 * (4 bytes). Its minimal size is therefore 10 bytes
+		 */
 #define HSA_PACKET_OVERHEAD	10
-	hsa = max((unsigned int)HSA_PACKET_OVERHEAD,
-		  (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD);
-
-	/*
-	 * The backporch is set using a blanking packet (4 bytes +
-	 * payload + 2 bytes). Its minimal size is therefore 6 bytes
-	 */
+		hsa = max((unsigned int)HSA_PACKET_OVERHEAD,
+			  (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD);
+
+		/*
+		 * The backporch is set using a blanking packet (4
+		 * bytes + payload + 2 bytes). Its minimal size is
+		 * therefore 6 bytes
+		 */
 #define HBP_PACKET_OVERHEAD	6
-	hbp = max((unsigned int)HBP_PACKET_OVERHEAD,
-		  (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD);
-
-	/*
-	 * The frontporch is set using a blanking packet (4 bytes +
-	 * payload + 2 bytes). Its minimal size is therefore 6 bytes
-	 */
+		hbp = max((unsigned int)HBP_PACKET_OVERHEAD,
+			  (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD);
+
+		/*
+		 * The frontporch is set using a blanking packet (4
+		 * bytes + payload + 2 bytes). Its minimal size is
+		 * therefore 6 bytes
+		 */
 #define HFP_PACKET_OVERHEAD	6
-	hfp = max((unsigned int)HFP_PACKET_OVERHEAD,
-		  (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD);
-
-	/*
-	 * The blanking is set using a sync event (4 bytes) and a
-	 * blanking packet (4 bytes + payload + 2 bytes). Its minimal
-	 * size is therefore 10 bytes.
-	 */
+		hfp = max((unsigned int)HFP_PACKET_OVERHEAD,
+			  (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD);
+
+		/*
+		 * The blanking is set using a sync event (4 bytes)
+		 * and a blanking packet (4 bytes + payload + 2
+		 * bytes). Its minimal size is therefore 10 bytes.
+		 */
 #define HBLK_PACKET_OVERHEAD	10
-	hblk = max((unsigned int)HBLK_PACKET_OVERHEAD,
-		   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - HBLK_PACKET_OVERHEAD);
-
-	/*
-	 * And I'm not entirely sure what vblk is about. The driver in
-	 * Allwinner BSP is using a rather convoluted calculation
-	 * there only for 4 lanes. However, using 0 (the !4 lanes
-	 * case) even with a 4 lanes screen seems to work...
-	 */
-	vblk = 0;
+		hblk = max((unsigned int)HBLK_PACKET_OVERHEAD,
+			   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp -
+			   HBLK_PACKET_OVERHEAD);
+
+		/*
+		 * And I'm not entirely sure what vblk is about. The driver in
+		 * Allwinner BSP is using a rather convoluted calculation
+		 * there only for 4 lanes. However, using 0 (the !4 lanes
+		 * case) even with a 4 lanes screen seems to work...
+		 */
+		vblk = 0;
+	}
 
 	/* How many bytes do we need to send all payloads? */
 	bytes = max_t(size_t, max(max(hfp, hblk), max(hsa, hbp)), vblk);
@@ -510,7 +603,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
 	if (WARN_ON(!buffer))
 		return;
 
-	regmap_write(dsi->regs, SUN6I_DSI_BASIC_CTL_REG, 0);
+	regmap_write(dsi->regs, SUN6I_DSI_BASIC_CTL_REG, basic_ctl);
 
 	regmap_write(dsi->regs, SUN6I_DSI_SYNC_HSS_REG,
 		     sun6i_dsi_build_sync_pkt(MIPI_DSI_H_SYNC_START,
Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw

PATCH v2 9/9 drm/panel: Add Ronbo RB070D30 panel

In reply to Maxime Ripard

From: Konstantin Sudakov <[email protected]>

The Ronbo RB070D30 panel is a MIPI-DSI panel based on a Fitipower EK79007 controller and a 1024x600 panel.

---
 drivers/gpu/drm/panel/Kconfig                |   9 +-
 drivers/gpu/drm/panel/Makefile               |   1 +-
 drivers/gpu/drm/panel/panel-ronbo-rb070d30.c | 262 ++++++++++++++++++++-
 3 files changed, 272 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-ronbo-rb070d30.c
drivers/gpu/drm/panel/Kconfig +9 -0
index 3f3537719beb..870dcdbf2601 100644
@@ -138,6 +138,15 @@ config DRM_PANEL_RAYDIUM_RM68200
 	  Say Y here if you want to enable support for Raydium RM68200
 	  720x1280 DSI video mode panel.
 
+config DRM_PANEL_RONBO_RB070D30
+	tristate "Ronbo Electronics RB070D30 panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for Ronbo Electronics
+	  RB070D30 1024x600 DSI panel.
+
 config DRM_PANEL_SAMSUNG_S6D16D0
 	tristate "Samsung S6D16D0 DSI video mode panel"
 	depends on OF
drivers/gpu/drm/panel/Makefile +1 -0
index 4396658a7996..4a103d346809 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o
 obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o
 obj-$(CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN) += panel-raspberrypi-touchscreen.o
 obj-$(CONFIG_DRM_PANEL_RAYDIUM_RM68200) += panel-raydium-rm68200.o
+obj-$(CONFIG_DRM_PANEL_RONBO_RB070D30) += panel-ronbo-rb070d30.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D16D0) += panel-samsung-s6d16d0.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
drivers/gpu/drm/panel/panel-ronbo-rb070d30.c new file +262 -0

262 lines not on this page · raw message

Signature · 5 lines
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw

PATCH v2 9/9 drm/panel: Add Ronbo RB070D30 panel

Hello, Maxime!

drivers/gpu/drm/panel/panel-ronbo-rb070d30.c line 140

Quoted 7 lines
drivers/gpu/drm/panel/panel-ronbo-rb070d30.c new file +7 -0
+mode = drm_mode_duplicate(panel->drm, &default_mode);
+if (!mode) {
+DRM_DEV_ERROR(&ctx->dsi->dev,
+      "Failed to add mode " DRM_MODE_FMT "\n",
+      DRM_MODE_ARG(mode));
+return -EINVAL;
+}

Just small fix: DRM_MODE_ARG(mode) -> DRM_MODE_ARG(&default_mode). The "mode" variable is NULL, it leads to the UB.

#16 lore raw

Re: [PATCH v2 9/9] drm/panel: Add Ronbo RB070D30 panel

hi,

Quoted 12 lines · Konstantin Sudakov

Hello, Maxime!

drivers/gpu/drm/panel/panel-ronbo-rb070d30.c line 140

Quoted 7 lines
drivers/gpu/drm/panel/panel-ronbo-rb070d30.c new file +7 -0
+mode = drm_mode_duplicate(panel->drm, &default_mode);
+if (!mode) {
+DRM_DEV_ERROR(&ctx->dsi->dev,
+      "Failed to add mode " DRM_MODE_FMT "\n",
+      DRM_MODE_ARG(mode));
+return -EINVAL;
+}

Just small fix: DRM_MODE_ARG(mode) -> DRM_MODE_ARG(&default_mode). The "mode" variable is NULL, it leads to the UB.

Good catch, thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v2 9/9
#17 lore raw

Re: [PATCH v2 9/9] drm/panel: Add Ronbo RB070D30 panel

In reply to Maxime Ripard

Hi Maxime,

Quoted 7 lines · Maxime Ripard

From: Konstantin Sudakov <[email protected]>

The Ronbo RB070D30 panel is a MIPI-DSI panel based on a Fitipower EK79007 controller and a 1024x600 panel.

Driver looks good, no further comments.

With the issue pointed out by Konstantin you can add my:

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel