mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices
@ 2026-06-22 12:26 Amit Barzilai
  2026-06-22 12:26 ` [PATCH 1/3] drm/ssd130x: fix column and row end address in partial updates for ssd132x Amit Barzilai
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Amit Barzilai @ 2026-06-22 12:26 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jocelyn Falempe, dri-devel, linux-kernel, Amit Barzilai

While working on adding SSD1351 support to the ssd130x driver - I
noticed that the area of the cursor was refreshing in a weird state.
I would fill the screen red while the flashing cursor was on the screen,
but the screen wouldn't refresh the entire 8x8 rectangle each flash. 

After reading the SSD1351, SSD1331 and SSD132x manuals and manual
testing on the SSD1351, I was able to be sure that the problem was the
end addresses of "Set Column/Row Address" being sent as relative addresses
instead of absolute addresses.

I assume these bugs went under the radar because testing would usually
be done where the dirty rectangles would start from the 0,0 coordinates.
In these situations, the bug would be invisable, since adresses relative
to 0 are the same as their absolute value.

It is important to note that I didn't test these changes on a SSD132x 
screen or a SSD133x screens, only on an SSD1351. Manual testing is
advised.

This series contains the fix for ssd132x_update_rect, a simple clean-up
patch for ssd132x_update_rect to keep the function clean, and the same
fix on ssd133x_update_rect.

Amit Barzilai (3):
  drm/ssd130x: fix column and row end address in partial updates for
    ssd132x
  drm/ssd130x: hoist column and row addresses out of repeated division
  drm/ssd130x: fix column and row end address in partial updates in
    ssd133x

 drivers/gpu/drm/solomon/ssd130x.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] drm/ssd130x: fix column and row end address in partial updates for ssd132x
  2026-06-22 12:26 [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Amit Barzilai
@ 2026-06-22 12:26 ` Amit Barzilai
  2026-06-22 12:26 ` [PATCH 2/3] drm/ssd130x: hoist column and row addresses out of repeated division Amit Barzilai
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Amit Barzilai @ 2026-06-22 12:26 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jocelyn Falempe, dri-devel, linux-kernel, Amit Barzilai, stable

On partial screen updates, SSD132X controllers expect to get the
rectangle addresses as arguments of the "Set Column Address" and "Set
Row Address" commands. Each command expects the start address and end
address of the row/column in absolute format, however the end
addresses were being sent in a relative format (relative to the start
address).

The relative end addresses work only when the start address is 0. In
those situations, there is no value difference between relative and
absolute addresses.

Fixes: fdd591e00a9c9 ("drm/ssd130x: Add support for the SSD132x OLED controller family")
Cc: stable@vger.kernel.org
Signed-off-by: Amit Barzilai <amit.barzilai22@gmail.com>
---
 drivers/gpu/drm/solomon/ssd130x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index c77455b1834d..77aa5585a46c 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -864,12 +864,13 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
 	 */
 
 	/* Set column start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, x / segment_width, columns - 1);
+	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, x / segment_width,
+				x / segment_width + columns - 1);
 	if (ret < 0)
 		return ret;
 
 	/* Set row start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, y, rows - 1);
+	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, y, y + rows - 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] drm/ssd130x: hoist column and row addresses out of repeated division
  2026-06-22 12:26 [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Amit Barzilai
  2026-06-22 12:26 ` [PATCH 1/3] drm/ssd130x: fix column and row end address in partial updates for ssd132x Amit Barzilai
@ 2026-06-22 12:26 ` Amit Barzilai
  2026-06-22 12:26 ` [PATCH 3/3] drm/ssd130x: fix column and row end address in partial updates in ssd133x Amit Barzilai
  2026-07-01 13:23 ` [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Javier Martinez Canillas
  3 siblings, 0 replies; 6+ messages in thread
From: Amit Barzilai @ 2026-06-22 12:26 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jocelyn Falempe, dri-devel, linux-kernel, Amit Barzilai

The ssd132x_update_rect had to calculate the column address twice in
the same function by dividing the byte address and the segment_width.
Optimize this by hoisting the result into a col variable.

Renamed the "y" variable to "row" to match the change made in the x
axis.

Signed-off-by: Amit Barzilai <amit.barzilai22@gmail.com>
---
 drivers/gpu/drm/solomon/ssd130x.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index 77aa5585a46c..fee35496a324 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -835,9 +835,9 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
 			       struct drm_rect *rect, u8 *buf,
 			       u8 *data_array)
 {
-	unsigned int x = rect->x1;
-	unsigned int y = rect->y1;
 	unsigned int segment_width = SSD132X_SEGMENT_WIDTH;
+	unsigned int col = rect->x1 / segment_width;
+	unsigned int row = rect->y1;
 	unsigned int width = drm_rect_width(rect);
 	unsigned int height = drm_rect_height(rect);
 	unsigned int columns = DIV_ROUND_UP(width, segment_width);
@@ -847,7 +847,7 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
 	unsigned int i, j;
 	int ret;
 
-	drm_WARN_ONCE(drm, x % segment_width != 0, "x must be aligned to screen segment\n");
+	drm_WARN_ONCE(drm, rect->x1 % segment_width != 0, "x must be aligned to screen segment\n");
 
 	/*
 	 * The screen is divided in Segment and Common outputs, where
@@ -864,13 +864,12 @@ static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
 	 */
 
 	/* Set column start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, x / segment_width,
-				x / segment_width + columns - 1);
+	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, col, col + columns - 1);
 	if (ret < 0)
 		return ret;
 
 	/* Set row start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, y, y + rows - 1);
+	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, row, row + rows - 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] drm/ssd130x: fix column and row end address in partial updates in ssd133x
  2026-06-22 12:26 [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Amit Barzilai
  2026-06-22 12:26 ` [PATCH 1/3] drm/ssd130x: fix column and row end address in partial updates for ssd132x Amit Barzilai
  2026-06-22 12:26 ` [PATCH 2/3] drm/ssd130x: hoist column and row addresses out of repeated division Amit Barzilai
@ 2026-06-22 12:26 ` Amit Barzilai
  2026-07-01 13:23 ` [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Javier Martinez Canillas
  3 siblings, 0 replies; 6+ messages in thread
From: Amit Barzilai @ 2026-06-22 12:26 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jocelyn Falempe, dri-devel, linux-kernel, Amit Barzilai, stable

On partial screen updates, SSD133X controllers expect to get the
rectangle addresses as arguments of the "Set Column Address" and "Set
Row Address" commands. Each command expects the start address and end
address of the row/column in absolute format, however the end
addresses were being sent in a relative format (relative to the start
address).

The relative end addresses work only when the start address is 0. In
those situations, there is no value difference between relative and
absolute addresses.

Fixes: b4299c936d8fd ("drm/ssd130x: Add support for the SSD133x OLED controller family")
Cc: stable@vger.kernel.org
Signed-off-by: Amit Barzilai <amit.barzilai22@gmail.com>
---
 drivers/gpu/drm/solomon/ssd130x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index fee35496a324..4e4b879d8b24 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -915,12 +915,12 @@ static int ssd133x_update_rect(struct ssd130x_device *ssd130x,
 	 */
 
 	/* Set column start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD133X_SET_COL_RANGE, x, columns - 1);
+	ret = ssd130x_write_cmd(ssd130x, 3, SSD133X_SET_COL_RANGE, x, x + columns - 1);
 	if (ret < 0)
 		return ret;
 
 	/* Set row start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD133X_SET_ROW_RANGE, y, rows - 1);
+	ret = ssd130x_write_cmd(ssd130x, 3, SSD133X_SET_ROW_RANGE, y, y + rows - 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices
  2026-06-22 12:26 [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Amit Barzilai
                   ` (2 preceding siblings ...)
  2026-06-22 12:26 ` [PATCH 3/3] drm/ssd130x: fix column and row end address in partial updates in ssd133x Amit Barzilai
@ 2026-07-01 13:23 ` Javier Martinez Canillas
  2026-07-06 10:41   ` Javier Martinez Canillas
  3 siblings, 1 reply; 6+ messages in thread
From: Javier Martinez Canillas @ 2026-07-01 13:23 UTC (permalink / raw)
  To: Amit Barzilai, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jocelyn Falempe, dri-devel, linux-kernel, Amit Barzilai

Amit Barzilai <amit.barzilai22@gmail.com> writes:

Hello Amit,

Thanks for your patches.

> While working on adding SSD1351 support to the ssd130x driver - I
> noticed that the area of the cursor was refreshing in a weird state.
> I would fill the screen red while the flashing cursor was on the screen,
> but the screen wouldn't refresh the entire 8x8 rectangle each flash. 
>
> After reading the SSD1351, SSD1331 and SSD132x manuals and manual
> testing on the SSD1351, I was able to be sure that the problem was the
> end addresses of "Set Column/Row Address" being sent as relative addresses
> instead of absolute addresses.
>

Indeed.

> I assume these bugs went under the radar because testing would usually
> be done where the dirty rectangles would start from the 0,0 coordinates.
> In these situations, the bug would be invisable, since adresses relative
> to 0 are the same as their absolute value.
>

Yes, I believe that was the case. Thanks a lot for fixing these issues!

> It is important to note that I didn't test these changes on a SSD132x 
> scree0n or a SSD133x screens, only on an SSD1351. Manual testing is
> advised.
>
> This series contains the fix for ssd132x_update_rect, a simple clean-up
> patch for ssd132x_update_rect to keep the function clean, and the same
> fix on ssd133x_update_rect.
>

For the whole series:

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

I plan to push them to drm-misc-next rather than to drm-misc-fixes, since
these have been long standing bugs and the changes are likely to conflict
with your SSD1351 patches that are in-flight.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices
  2026-07-01 13:23 ` [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Javier Martinez Canillas
@ 2026-07-06 10:41   ` Javier Martinez Canillas
  0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2026-07-06 10:41 UTC (permalink / raw)
  To: Amit Barzilai, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Jocelyn Falempe, dri-devel, linux-kernel, Amit Barzilai

Javier Martinez Canillas <javierm@redhat.com> writes:

> Amit Barzilai <amit.barzilai22@gmail.com> writes:
>
> Hello Amit,
>
> Thanks for your patches.
>
>> While working on adding SSD1351 support to the ssd130x driver - I
>> noticed that the area of the cursor was refreshing in a weird state.
>> I would fill the screen red while the flashing cursor was on the screen,
>> but the screen wouldn't refresh the entire 8x8 rectangle each flash. 
>>
>> After reading the SSD1351, SSD1331 and SSD132x manuals and manual
>> testing on the SSD1351, I was able to be sure that the problem was the
>> end addresses of "Set Column/Row Address" being sent as relative addresses
>> instead of absolute addresses.
>>

[...]

> For the whole series:
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>
> I plan to push them to drm-misc-next rather than to drm-misc-fixes, since
> these have been long standing bugs and the changes are likely to conflict
> with your SSD1351 patches that are in-flight.

Pushed to drm-misc (drm-misc-next). Thanks!

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-06 10:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 12:26 [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Amit Barzilai
2026-06-22 12:26 ` [PATCH 1/3] drm/ssd130x: fix column and row end address in partial updates for ssd132x Amit Barzilai
2026-06-22 12:26 ` [PATCH 2/3] drm/ssd130x: hoist column and row addresses out of repeated division Amit Barzilai
2026-06-22 12:26 ` [PATCH 3/3] drm/ssd130x: fix column and row end address in partial updates in ssd133x Amit Barzilai
2026-07-01 13:23 ` [PATCH 0/3] drm/ssd130x: fix column and row end address in partial updates of ssd132x and ssd133x devices Javier Martinez Canillas
2026-07-06 10:41   ` Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®