Skip to contentSkip to conversation

video: fbdev: ssd1307fb: Optimizations and improvements

PATCH RESEND Superseded Geert Uytterhoeven 3 participants 21 messages Jul 14, 2021 – Jul 20, 2021 Framebuffer layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover video: fbdev: ssd1307fb: Optimizations and improvements

Hi all,

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode. While many displays are smaller, and thus require less data to be transferred, 20 ms is still an optimistic value, as the actual data transfer may be much slower, especially on bitbanged I2C drivers. After this series, the amount of data transfer is reduced, as fillrect, copyarea, and imageblit only update the rectangle that changed.

This has been tested on an Adafruit FeatherWing OLED with an SSD1306 controller and a 128x32 OLED, connected to an OrangeCrab ECP5 FPGA board running a 64 MHz VexRiscv RISC-V softcore, where it reduced the CPU usage for blinking the cursor from more than 70% to ca. 10%.

Thanks for your comments!

Geert Uytterhoeven (5):
video: fbdev: ssd1307fb: Propagate errors via

    ssd1307fb_update_display()

video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()
video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()
video: fbdev: ssd1307fb: Optimize screen updates
video: fbdev: ssd1307fb: Cache address ranges

 drivers/video/fbdev/ssd1307fb.c | 143 +++++++++++++++++++++-----------
 1 file changed, 96 insertions(+), 47 deletions(-)
Signature · 12 lines
2.25.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
#1 lore raw

PATCH RESEND 1/5 video: fbdev: ssd1307fb: Propagate errors via ssd1307fb_update_display()

Make ssd1307fb_update_display() return an error code, so callers that can handle failures can propagate it.

---
 drivers/video/fbdev/ssd1307fb.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/video/fbdev/ssd1307fb.c +12 -6
index eda448b7a0c9d8ce..e6b6263e3bef847f 100644
@@ -152,17 +152,17 @@ static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd)
 	return ret;
 }
 
-static void ssd1307fb_update_display(struct ssd1307fb_par *par)
+static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 {
 	struct ssd1307fb_array *array;
 	u8 *vmem = par->info->screen_buffer;
 	unsigned int line_length = par->info->fix.line_length;
 	unsigned int pages = DIV_ROUND_UP(par->height, 8);
-	int i, j, k;
+	int ret, i, j, k;
 
 	array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
 	if (!array)
-		return;
+		return -ENOMEM;
 
 	/*
 	 * The screen is divided in pages, each having a height of 8
@@ -210,8 +210,9 @@ static void ssd1307fb_update_display(struct ssd1307fb_par *par)
 		}
 	}
 
-	ssd1307fb_write_array(par->client, array, par->width * pages);
+	ret = ssd1307fb_write_array(par->client, array, par->width * pages);
 	kfree(array);
+	return ret;
 }
 
 
@@ -222,6 +223,7 @@ static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf,
 	unsigned long total_size;
 	unsigned long p = *ppos;
 	void *dst;
+	int ret;
 
 	total_size = info->fix.smem_len;
 
@@ -239,7 +241,9 @@ static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf,
 	if (copy_from_user(dst, buf, count))
 		return -EFAULT;
 
-	ssd1307fb_update_display(par);
+	ret = ssd1307fb_update_display(par);
+	if (ret < 0)
+		return ret;
 
 	*ppos += count;
 
@@ -483,7 +487,9 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 		return ret;
 
 	/* Clear the screen */
-	ssd1307fb_update_display(par);
+	ret = ssd1307fb_update_display(par);
+	if (ret < 0)
+		return ret;
 
 	/* Turn on the display */
 	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON);
Signature · 1 line
2.25.1
#2 lore raw

PATCH RESEND 2/5 video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()

In reply to Geert Uytterhoeven

Simplify the nested loops to handle conversion from linear frame buffer to ssd1307 page layout:
1. Move last page handling one level up, as the value of "m" is the same inside a page,
2. array->data[] is filled linearly, so there is no need to recalculate array_idx over and over again; a simple increment is sufficient.

---
 drivers/video/fbdev/ssd1307fb.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/video/fbdev/ssd1307fb.c +10 -7
index e6b6263e3bef847f..6d7bd025bca1a175 100644
@@ -158,6 +158,7 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 	u8 *vmem = par->info->screen_buffer;
 	unsigned int line_length = par->info->fix.line_length;
 	unsigned int pages = DIV_ROUND_UP(par->height, 8);
+	u32 array_idx = 0;
 	int ret, i, j, k;
 
 	array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
@@ -194,19 +195,21 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 	 */
 
 	for (i = 0; i < pages; i++) {
+		int m = 8;
+
+		/* Last page may be partial */
+		if (i + 1 == pages && par->height % 8)
+			m = par->height % 8;
 		for (j = 0; j < par->width; j++) {
-			int m = 8;
-			u32 array_idx = i * par->width + j;
-			array->data[array_idx] = 0;
-			/* Last page may be partial */
-			if (i + 1 == pages && par->height % 8)
-				m = par->height % 8;
+			u8 data = 0;
+
 			for (k = 0; k < m; k++) {
 				u8 byte = vmem[(8 * i + k) * line_length +
 					       j / 8];
 				u8 bit = (byte >> (j % 8)) & 1;
-				array->data[array_idx] |= bit << k;
+				data |= bit << k;
 			}
+			array->data[array_idx++] = data;
 		}
 	}
 
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH resend 2/5] video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()

Hi Geert,

Quoted 34 lines · Geert Uytterhoeven

Simplify the nested loops to handle conversion from linear frame buffer to ssd1307 page layout:
1. Move last page handling one level up, as the value of "m" is the same inside a page,
2. array->data[] is filled linearly, so there is no need to recalculate array_idx over and over again; a simple increment is sufficient.

---
 drivers/video/fbdev/ssd1307fb.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/video/fbdev/ssd1307fb.c +6 -0
index e6b6263e3bef847f..6d7bd025bca1a175 100644
@@ -158,6 +158,7 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 	u8 *vmem = par->info->screen_buffer;
 	unsigned int line_length = par->info->fix.line_length;
 	unsigned int pages = DIV_ROUND_UP(par->height, 8);
+	u32 array_idx = 0;
 	int ret, i, j, k;
 
 	array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
@@ -194,19 +195,21 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 	 */
 
 	for (i = 0; i < pages; i++) {
+		int m = 8;
+
+		/* Last page may be partial */
+		if (i + 1 == pages && par->height % 8)
+			m = par->height % 8;

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 206

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +2 -6
 		for (j = 0; j < par->width; j++) {
-			int m = 8;
-			u32 array_idx = i * par->width + j;
-			array->data[array_idx] = 0;
-			/* Last page may be partial */
-			if (i + 1 == pages && par->height % 8)
-				m = par->height % 8;
+			u8 data = 0;
+
 			for (k = 0; k < m; k++) {

If the last page is partial then m will be less than 8 for all bytes in j = 0..par-width - but m should only be less than 8 for the last iteration of the loop.

Do I miss something or is the code buggy?

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 214

Quoted 9 lines
drivers/video/fbdev/ssd1307fb.c +2 -1
 				u8 byte = vmem[(8 * i + k) * line_length +
 					       j / 8];
 				u8 bit = (byte >> (j % 8)) & 1;
-				array->data[array_idx] |= bit << k;
+				data |= bit << k;
 			}
+			array->data[array_idx++] = data;
 		}
 	}

Sam

#4 lore raw

Re: [PATCH resend 2/5] video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()

Hi Sam,

Quoted 49 lines · Sam Ravnborg
Quoted 34 lines · Geert Uytterhoeven

Simplify the nested loops to handle conversion from linear frame buffer to ssd1307 page layout:
1. Move last page handling one level up, as the value of "m" is the same inside a page,
2. array->data[] is filled linearly, so there is no need to recalculate array_idx over and over again; a simple increment is sufficient.

---
 drivers/video/fbdev/ssd1307fb.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/video/fbdev/ssd1307fb.c +6 -0
index e6b6263e3bef847f..6d7bd025bca1a175 100644
@@ -158,6 +158,7 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
      u8 *vmem = par->info->screen_buffer;
      unsigned int line_length = par->info->fix.line_length;
      unsigned int pages = DIV_ROUND_UP(par->height, 8);
+     u32 array_idx = 0;
      int ret, i, j, k;
 
      array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
@@ -194,19 +195,21 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
       */
 
      for (i = 0; i < pages; i++) {
+             int m = 8;
+
+             /* Last page may be partial */
+             if (i + 1 == pages && par->height % 8)
+                     m = par->height % 8;

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 206

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +2 -6
              for (j = 0; j < par->width; j++) {
-                     int m = 8;
-                     u32 array_idx = i * par->width + j;
-                     array->data[array_idx] = 0;
-                     /* Last page may be partial */
-                     if (i + 1 == pages && par->height % 8)
-                             m = par->height % 8;
+                     u8 data = 0;
+
                      for (k = 0; k < m; k++) {

If the last page is partial then m will be less than 8 for all bytes in j = 0..par-width - but m should only be less than 8 for the last iteration of the loop.

Quoted 1 line

Do I miss something or is the code buggy?

"the loop" is the j-loop?
If m is less than 8 for the last page, it should be less than 8 for all iterations of j, as all last bytes in each "line" (visible row) are partial, cfr. the comments above the code, explaining the representation of the screen.

Quoted 9 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 214

Quoted 9 lines
drivers/video/fbdev/ssd1307fb.c +2 -1
                              u8 byte = vmem[(8 * i + k) * line_length +
                                             j / 8];
                              u8 bit = (byte >> (j % 8)) & 1;
-                             array->data[array_idx] |= bit << k;
+                             data |= bit << k;
                      }
+                     array->data[array_idx++] = data;
              }
      }

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Acked-by
#5 lore raw

Re: [PATCH resend 2/5] video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()

Hi Geert,

Quoted 52 lines · Geert Uytterhoeven

Hi Sam,

Quoted 49 lines · Sam Ravnborg
Quoted 34 lines · Geert Uytterhoeven

Simplify the nested loops to handle conversion from linear frame buffer to ssd1307 page layout:
1. Move last page handling one level up, as the value of "m" is the same inside a page,
2. array->data[] is filled linearly, so there is no need to recalculate array_idx over and over again; a simple increment is sufficient.

---
 drivers/video/fbdev/ssd1307fb.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/video/fbdev/ssd1307fb.c +6 -0
index e6b6263e3bef847f..6d7bd025bca1a175 100644
@@ -158,6 +158,7 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
      u8 *vmem = par->info->screen_buffer;
      unsigned int line_length = par->info->fix.line_length;
      unsigned int pages = DIV_ROUND_UP(par->height, 8);
+     u32 array_idx = 0;
      int ret, i, j, k;
 
      array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
@@ -194,19 +195,21 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
       */
 
      for (i = 0; i < pages; i++) {
+             int m = 8;
+
+             /* Last page may be partial */
+             if (i + 1 == pages && par->height % 8)
+                     m = par->height % 8;

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 206

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +2 -6
              for (j = 0; j < par->width; j++) {
-                     int m = 8;
-                     u32 array_idx = i * par->width + j;
-                     array->data[array_idx] = 0;
-                     /* Last page may be partial */
-                     if (i + 1 == pages && par->height % 8)
-                             m = par->height % 8;
+                     u8 data = 0;
+
                      for (k = 0; k < m; k++) {

If the last page is partial then m will be less than 8 for all bytes in j = 0..par-width - but m should only be less than 8 for the last iteration of the loop.

Quoted 7 lines
Quoted 1 line

Do I miss something or is the code buggy?

"the loop" is the j-loop?
If m is less than 8 for the last page, it should be less than 8 for all iterations of j, as all last bytes in each "line" (visible row) are partial, cfr. the comments above the code, explaining the representation of the screen.

OK, then the code works as intended. I had not read the comments and just assume it was only the last byte that was in need of a special treatment.
So code is fine:

Quoted 21 lines
Quoted 10 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 214

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +2 -1
                              u8 byte = vmem[(8 * i + k) * line_length +
                                             j / 8];
                              u8 bit = (byte >> (j % 8)) & 1;
-                             array->data[array_idx] |= bit << k;
+                             data |= bit << k;
                      }
+                     array->data[array_idx++] = data;
              }
      }

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#6 lore raw

PATCH RESEND 3/5 video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()

In reply to Geert Uytterhoeven

Extract the code to set the column and page ranges into a helper function.

---
 drivers/video/fbdev/ssd1307fb.c | 61 +++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 25 deletions(-)
drivers/video/fbdev/ssd1307fb.c +36 -25
index 6d7bd025bca1a175..cfa27ea0feab4f01 100644
@@ -152,6 +152,38 @@ static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd)
 	return ret;
 }
 
+static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
+				       u8 cols, u8 page_start, u8 pages)
+{
+	u8 col_end = col_start + cols - 1;
+	u8 page_end = page_start + pages - 1;
+	int ret;
+
+	/* Set column range */
+	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
+	if (ret < 0)
+		return ret;
+
+	ret = ssd1307fb_write_cmd(par->client, col_start);
+	if (ret < 0)
+		return ret;
+
+	ret = ssd1307fb_write_cmd(par->client, col_end);
+	if (ret < 0)
+		return ret;
+
+	/* Set page range */
+	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
+	if (ret < 0)
+		return ret;
+
+	ret = ssd1307fb_write_cmd(par->client, page_start);
+	if (ret < 0)
+		return ret;
+
+	return ssd1307fb_write_cmd(par->client, page_end);
+}
+
 static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 {
 	struct ssd1307fb_array *array;
@@ -461,31 +493,10 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 	if (ret < 0)
 		return ret;
 
-	/* Set column range */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client, par->col_offset);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client, par->col_offset + par->width - 1);
-	if (ret < 0)
-		return ret;
-
-	/* Set page range */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client, par->page_offset);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client,
-				  par->page_offset +
-				  DIV_ROUND_UP(par->height, 8) - 1);
+	/* Set column and page range */
+	ret = ssd1307fb_set_address_range(par, par->col_offset, par->width,
+					  par->page_offset,
+					  DIV_ROUND_UP(par->height, 8));
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.25.1
Acked-by on v1 3/5
#7 lore raw

Re: [PATCH resend 3/5] video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()

Hi Geert,

Quoted 13 lines · Geert Uytterhoeven

Extract the code to set the column and page ranges into a helper function.

---
 drivers/video/fbdev/ssd1307fb.c | 61 +++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 25 deletions(-)
drivers/video/fbdev/ssd1307fb.c +0 -0
index 6d7bd025bca1a175..cfa27ea0feab4f01 100644

drivers/video/fbdev/ssd1307fb.c static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd) · line 157

Quoted 6 lines
drivers/video/fbdev/ssd1307fb.c +3 -0
@@ -152,6 +152,38 @@ static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd)
 	return ret;
 }
 
+static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
+				       u8 cols, u8 page_start, u8 pages)
+{

Bikeshedding, but I think a dedicated function for col_range and another for page_range had been simpler to read.

With or wihout this change:

Sam

Quoted 70 lines
drivers/video/fbdev/ssd1307fb.c +33 -25
+	u8 col_end = col_start + cols - 1;
+	u8 page_end = page_start + pages - 1;
+	int ret;
+
+	/* Set column range */
+	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
+	if (ret < 0)
+		return ret;
+
+	ret = ssd1307fb_write_cmd(par->client, col_start);
+	if (ret < 0)
+		return ret;
+
+	ret = ssd1307fb_write_cmd(par->client, col_end);
+	if (ret < 0)
+		return ret;
+
+	/* Set page range */
+	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
+	if (ret < 0)
+		return ret;
+
+	ret = ssd1307fb_write_cmd(par->client, page_start);
+	if (ret < 0)
+		return ret;
+
+	return ssd1307fb_write_cmd(par->client, page_end);
+}
+
 static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 {
 	struct ssd1307fb_array *array;
@@ -461,31 +493,10 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 	if (ret < 0)
 		return ret;
 
-	/* Set column range */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client, par->col_offset);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client, par->col_offset + par->width - 1);
-	if (ret < 0)
-		return ret;
-
-	/* Set page range */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client, par->page_offset);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd1307fb_write_cmd(par->client,
-				  par->page_offset +
-				  DIV_ROUND_UP(par->height, 8) - 1);
+	/* Set column and page range */
+	ret = ssd1307fb_set_address_range(par, par->col_offset, par->width,
+					  par->page_offset,
+					  DIV_ROUND_UP(par->height, 8));
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH resend 3/5] video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()

Hi Sam,

Quoted 17 lines · Sam Ravnborg
Quoted 16 lines · Geert Uytterhoeven

Extract the code to set the column and page ranges into a helper function.

---
 drivers/video/fbdev/ssd1307fb.c | 61 +++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 25 deletions(-)
drivers/video/fbdev/ssd1307fb.c +0 -0
index 6d7bd025bca1a175..cfa27ea0feab4f01 100644
@@ -152,6 +152,38 @@ static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd)
      return ret;
 }
 
Quoted 5 lines

drivers/video/fbdev/ssd1307fb.c static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd) · line 157

Quoted 3 lines
drivers/video/fbdev/ssd1307fb.c +3 -0
+static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
+                                    u8 cols, u8 page_start, u8 pages)
+{

Bikeshedding, but I think a dedicated function for col_range and another for page_range had been simpler to read.

I agree.
Originally, before I removed the call during initialization, there were two calls to this function, so it made sense to have a single function.

Quoted 2 lines

With or wihout this change:

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw

PATCH RESEND 4/5 video: fbdev: ssd1307fb: Optimize screen updates

In reply to Geert Uytterhoeven

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode.

Reduce the amount of transferred data by only updating the rectangle that changed. Remove the call to ssd1307fb_set_address_range() during initialization, as ssd1307fb_update_rect() now takes care of that.

Note that for now the optimized operation is only used for fillrect, copyarea, and imageblit, which are used by fbcon.

---
 drivers/video/fbdev/ssd1307fb.c | 43 ++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/video/fbdev/ssd1307fb.c +26 -17
index cfa27ea0feab4f01..8e3d4be74723b9bf 100644
@@ -184,16 +184,18 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
 	return ssd1307fb_write_cmd(par->client, page_end);
 }
 
-static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x,
+				 unsigned int y, unsigned int width,
+				 unsigned int height)
 {
 	struct ssd1307fb_array *array;
 	u8 *vmem = par->info->screen_buffer;
 	unsigned int line_length = par->info->fix.line_length;
-	unsigned int pages = DIV_ROUND_UP(par->height, 8);
+	unsigned int pages = DIV_ROUND_UP(height + y % 8, 8);
 	u32 array_idx = 0;
 	int ret, i, j, k;
 
-	array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
+	array = ssd1307fb_alloc_array(width * pages, SSD1307FB_DATA);
 	if (!array)
 		return -ENOMEM;
 
@@ -226,13 +228,18 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 	 *  (5) A4 B4 C4 D4 E4 F4 G4 H4
 	 */
 
-	for (i = 0; i < pages; i++) {
+	ret = ssd1307fb_set_address_range(par, par->col_offset + x, width,
+					  par->page_offset + y / 8, pages);
+	if (ret < 0)
+		goto out_free;
+
+	for (i = y / 8; i < y / 8 + pages; i++) {
 		int m = 8;
 
 		/* Last page may be partial */
-		if (i + 1 == pages && par->height % 8)
+		if (8 * (i + 1) > par->height)
 			m = par->height % 8;
-		for (j = 0; j < par->width; j++) {
+		for (j = x; j < x + width; j++) {
 			u8 data = 0;
 
 			for (k = 0; k < m; k++) {
@@ -245,11 +252,17 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 		}
 	}
 
-	ret = ssd1307fb_write_array(par->client, array, par->width * pages);
+	ret = ssd1307fb_write_array(par->client, array, width * pages);
+
+out_free:
 	kfree(array);
 	return ret;
 }
 
+static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+{
+	return ssd1307fb_update_rect(par, 0, 0, par->width, par->height);
+}
 
 static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf,
 		size_t count, loff_t *ppos)
@@ -299,21 +312,24 @@ static void ssd1307fb_fillrect(struct fb_info *info, const struct fb_fillrect *r
 {
 	struct ssd1307fb_par *par = info->par;
 	sys_fillrect(info, rect);
-	ssd1307fb_update_display(par);
+	ssd1307fb_update_rect(par, rect->dx, rect->dy, rect->width,
+			      rect->height);
 }
 
 static void ssd1307fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 	struct ssd1307fb_par *par = info->par;
 	sys_copyarea(info, area);
-	ssd1307fb_update_display(par);
+	ssd1307fb_update_rect(par, area->dx, area->dy, area->width,
+			      area->height);
 }
 
 static void ssd1307fb_imageblit(struct fb_info *info, const struct fb_image *image)
 {
 	struct ssd1307fb_par *par = info->par;
 	sys_imageblit(info, image);
-	ssd1307fb_update_display(par);
+	ssd1307fb_update_rect(par, image->dx, image->dy, image->width,
+			      image->height);
 }
 
 static const struct fb_ops ssd1307fb_ops = {
@@ -493,13 +509,6 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 	if (ret < 0)
 		return ret;
 
-	/* Set column and page range */
-	ret = ssd1307fb_set_address_range(par, par->col_offset, par->width,
-					  par->page_offset,
-					  DIV_ROUND_UP(par->height, 8));
-	if (ret < 0)
-		return ret;
-
 	/* Clear the screen */
 	ret = ssd1307fb_update_display(par);
 	if (ret < 0)
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH resend 4/5] video: fbdev: ssd1307fb: Optimize screen updates

Hi Geert,

Quoted 24 lines · Geert Uytterhoeven

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode.

Reduce the amount of transferred data by only updating the rectangle that changed. Remove the call to ssd1307fb_set_address_range() during initialization, as ssd1307fb_update_rect() now takes care of that.

Note that for now the optimized operation is only used for fillrect, copyarea, and imageblit, which are used by fbcon.

---
 drivers/video/fbdev/ssd1307fb.c | 43 ++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/video/fbdev/ssd1307fb.c +0 -0
index cfa27ea0feab4f01..8e3d4be74723b9bf 100644
@@ -184,16 +184,18 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
 	return ssd1307fb_write_cmd(par->client, page_end);
 }
 

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start, · line 194

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +4 -2
-static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x,
+				 unsigned int y, unsigned int width,
+				 unsigned int height)
 {
 	struct ssd1307fb_array *array;
 	u8 *vmem = par->info->screen_buffer;
 	unsigned int line_length = par->info->fix.line_length;
-	unsigned int pages = DIV_ROUND_UP(par->height, 8);
+	unsigned int pages = DIV_ROUND_UP(height + y % 8, 8);

Add () like this - at least it helps me:

Quoted 18 lines
drivers/video/fbdev/ssd1307fb.c +4 -2
+	unsigned int pages = DIV_ROUND_UP((height + y) % 8, 8);
 
 
 	u32 array_idx = 0;
 	int ret, i, j, k;
 
-	array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA);
+	array = ssd1307fb_alloc_array(width * pages, SSD1307FB_DATA);
 	if (!array)
 		return -ENOMEM;
@@ -226,13 +228,18 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 	 *  (5) A4 B4 C4 D4 E4 F4 G4 H4
 	 */
 
-	for (i = 0; i < pages; i++) {
+	ret = ssd1307fb_set_address_range(par, par->col_offset + x, width,
+					  par->page_offset + y / 8, pages);

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 241

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +5 -1
+	if (ret < 0)
+		goto out_free;
+
+	for (i = y / 8; i < y / 8 + pages; i++) {
 		int m = 8;
 
 		/* Last page may be partial */
-		if (i + 1 == pages && par->height % 8)
+		if (8 * (i + 1) > par->height)
 			m = par->height % 8;

As before, this looks wrong to me.

Sam

Quoted 68 lines
drivers/video/fbdev/ssd1307fb.c +14 -12
-		for (j = 0; j < par->width; j++) {
+		for (j = x; j < x + width; j++) {
 			u8 data = 0;
 
 			for (k = 0; k < m; k++) {
@@ -245,11 +252,17 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
 		}
 	}
 
-	ret = ssd1307fb_write_array(par->client, array, par->width * pages);
+	ret = ssd1307fb_write_array(par->client, array, width * pages);
+
+out_free:
 	kfree(array);
 	return ret;
 }
 
+static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+{
+	return ssd1307fb_update_rect(par, 0, 0, par->width, par->height);
+}
 
 static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf,
 		size_t count, loff_t *ppos)
@@ -299,21 +312,24 @@ static void ssd1307fb_fillrect(struct fb_info *info, const struct fb_fillrect *r
 {
 	struct ssd1307fb_par *par = info->par;
 	sys_fillrect(info, rect);
-	ssd1307fb_update_display(par);
+	ssd1307fb_update_rect(par, rect->dx, rect->dy, rect->width,
+			      rect->height);
 }
 
 static void ssd1307fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 	struct ssd1307fb_par *par = info->par;
 	sys_copyarea(info, area);
-	ssd1307fb_update_display(par);
+	ssd1307fb_update_rect(par, area->dx, area->dy, area->width,
+			      area->height);
 }
 
 static void ssd1307fb_imageblit(struct fb_info *info, const struct fb_image *image)
 {
 	struct ssd1307fb_par *par = info->par;
 	sys_imageblit(info, image);
-	ssd1307fb_update_display(par);
+	ssd1307fb_update_rect(par, image->dx, image->dy, image->width,
+			      image->height);
 }
 
 static const struct fb_ops ssd1307fb_ops = {
@@ -493,13 +509,6 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 	if (ret < 0)
 		return ret;
 
-	/* Set column and page range */
-	ret = ssd1307fb_set_address_range(par, par->col_offset, par->width,
-					  par->page_offset,
-					  DIV_ROUND_UP(par->height, 8));
-	if (ret < 0)
-		return ret;
-
 	/* Clear the screen */
 	ret = ssd1307fb_update_display(par);
 	if (ret < 0)
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH resend 4/5] video: fbdev: ssd1307fb: Optimize screen updates

Hi Sam,

Quoted 20 lines · Sam Ravnborg
Quoted 19 lines · Geert Uytterhoeven

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode.

Reduce the amount of transferred data by only updating the rectangle that changed. Remove the call to ssd1307fb_set_address_range() during initialization, as ssd1307fb_update_rect() now takes care of that.

Note that for now the optimized operation is only used for fillrect, copyarea, and imageblit, which are used by fbcon.

drivers/video/fbdev/ssd1307fb.c +0 -0
@@ -184,16 +184,18 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
      return ssd1307fb_write_cmd(par->client, page_end);
 }
 
Quoted 13 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start, · line 194

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +4 -2
-static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x,
+                              unsigned int y, unsigned int width,
+                              unsigned int height)
 {
      struct ssd1307fb_array *array;
      u8 *vmem = par->info->screen_buffer;
      unsigned int line_length = par->info->fix.line_length;
-     unsigned int pages = DIV_ROUND_UP(par->height, 8);
+     unsigned int pages = DIV_ROUND_UP(height + y % 8, 8);

Add () like this - at least it helps me:

Quoted 1 line
drivers/video/fbdev/ssd1307fb.c +1 -0
+     unsigned int pages = DIV_ROUND_UP((height + y) % 8, 8);

Thanks, that's actually a genuine bug.

Quoted 13 lines
Quoted 13 lines
drivers/video/fbdev/ssd1307fb.c +6 -1
@@ -226,13 +228,18 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par)
       *  (5) A4 B4 C4 D4 E4 F4 G4 H4
       */
 
-     for (i = 0; i < pages; i++) {
+     ret = ssd1307fb_set_address_range(par, par->col_offset + x, width,
+                                       par->page_offset + y / 8, pages);
+     if (ret < 0)
+             goto out_free;
+
+     for (i = y / 8; i < y / 8 + pages; i++) {
              int m = 8;
 
Quoted 5 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_update_display(struct ssd1307fb_par *par) · line 241

Quoted 4 lines
drivers/video/fbdev/ssd1307fb.c +1 -1
              /* Last page may be partial */
-             if (i + 1 == pages && par->height % 8)
+             if (8 * (i + 1) > par->height)
                      m = par->height % 8;

As before, this looks wrong to me.

Let's sort that out in the other thread...

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#12 lore raw

Re: [PATCH resend 4/5] video: fbdev: ssd1307fb: Optimize screen updates

Hi Sam,

Quoted 33 lines · Geert Uytterhoeven
Quoted 32 lines · Sam Ravnborg
Quoted 19 lines · Geert Uytterhoeven

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode.

Reduce the amount of transferred data by only updating the rectangle that changed. Remove the call to ssd1307fb_set_address_range() during initialization, as ssd1307fb_update_rect() now takes care of that.

Note that for now the optimized operation is only used for fillrect, copyarea, and imageblit, which are used by fbcon.

drivers/video/fbdev/ssd1307fb.c +0 -0
@@ -184,16 +184,18 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
      return ssd1307fb_write_cmd(par->client, page_end);
 }
 

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start, · line 194

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +4 -2
-static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x,
+                              unsigned int y, unsigned int width,
+                              unsigned int height)
 {
      struct ssd1307fb_array *array;
      u8 *vmem = par->info->screen_buffer;
      unsigned int line_length = par->info->fix.line_length;
-     unsigned int pages = DIV_ROUND_UP(par->height, 8);
+     unsigned int pages = DIV_ROUND_UP(height + y % 8, 8);

Add () like this - at least it helps me:

Quoted 3 lines
Quoted 1 line

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start, · line 195

Quoted 1 line
drivers/video/fbdev/ssd1307fb.c +1 -0
+     unsigned int pages = DIV_ROUND_UP((height + y) % 8, 8);

Thanks, that's actually a genuine bug.

No it's not "(height + y) % 8" is wrong.

Better if I reorder the operands like below?

    unsigned int pages = DIV_ROUND_UP(y % 8 + height, 8);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#13 lore raw

Re: [PATCH resend 4/5] video: fbdev: ssd1307fb: Optimize screen updates

Quoted 38 lines · Geert Uytterhoeven

Hi Sam,

Quoted 35 lines · Geert Uytterhoeven
Quoted 33 lines · Sam Ravnborg
Quoted 19 lines · Geert Uytterhoeven

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode.

Reduce the amount of transferred data by only updating the rectangle that changed. Remove the call to ssd1307fb_set_address_range() during initialization, as ssd1307fb_update_rect() now takes care of that.

Note that for now the optimized operation is only used for fillrect, copyarea, and imageblit, which are used by fbcon.

drivers/video/fbdev/ssd1307fb.c +0 -0
@@ -184,16 +184,18 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
      return ssd1307fb_write_cmd(par->client, page_end);
 }
 

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start, · line 194

Quoted 10 lines
drivers/video/fbdev/ssd1307fb.c +4 -2
-static int ssd1307fb_update_display(struct ssd1307fb_par *par)
+static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x,
+                              unsigned int y, unsigned int width,
+                              unsigned int height)
 {
      struct ssd1307fb_array *array;
      u8 *vmem = par->info->screen_buffer;
      unsigned int line_length = par->info->fix.line_length;
-     unsigned int pages = DIV_ROUND_UP(par->height, 8);
+     unsigned int pages = DIV_ROUND_UP(height + y % 8, 8);

Add () like this - at least it helps me:

Quoted 1 line
drivers/video/fbdev/ssd1307fb.c +1 -0
+     unsigned int pages = DIV_ROUND_UP((height + y) % 8, 8);
Quoted 7 lines
Quoted 1 line

Thanks, that's actually a genuine bug.

No it's not "(height + y) % 8" is wrong.

Better if I reorder the operands like below?

    unsigned int pages = DIV_ROUND_UP(y % 8 + height, 8);

Yep, then I would not be fooled so easy.

Sam

#14 lore raw

PATCH RESEND 5/5 video: fbdev: ssd1307fb: Cache address ranges

In reply to Geert Uytterhoeven

Cache the column and page ranges, to avoid doing unneeded I2C transfers when the values haven't changed.

---
 drivers/video/fbdev/ssd1307fb.c | 52 +++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 16 deletions(-)
drivers/video/fbdev/ssd1307fb.c +36 -16
index 8e3d4be74723b9bf..23b43ce479898813 100644
@@ -82,6 +82,11 @@ struct ssd1307fb_par {
 	struct regulator *vbat_reg;
 	u32 vcomh;
 	u32 width;
+	/* Cached address ranges */
+	u8 col_start;
+	u8 col_end;
+	u8 page_start;
+	u8 page_end;
 };
 
 struct ssd1307fb_array {
@@ -160,28 +165,43 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start,
 	int ret;
 
 	/* Set column range */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
-	if (ret < 0)
-		return ret;
+	if (col_start != par->col_start || col_end != par->col_end) {
+		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
+		if (ret < 0)
+			return ret;
 
-	ret = ssd1307fb_write_cmd(par->client, col_start);
-	if (ret < 0)
-		return ret;
+		ret = ssd1307fb_write_cmd(par->client, col_start);
+		if (ret < 0)
+			return ret;
 
-	ret = ssd1307fb_write_cmd(par->client, col_end);
-	if (ret < 0)
-		return ret;
+		ret = ssd1307fb_write_cmd(par->client, col_end);
+		if (ret < 0)
+			return ret;
+
+		par->col_start = col_start;
+		par->col_end = col_end;
+	}
 
 	/* Set page range */
-	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
-	if (ret < 0)
-		return ret;
+	if (page_start != par->page_start || page_end != par->page_end) {
+		ret = ssd1307fb_write_cmd(par->client,
+					  SSD1307FB_SET_PAGE_RANGE);
+		if (ret < 0)
+			return ret;
 
-	ret = ssd1307fb_write_cmd(par->client, page_start);
-	if (ret < 0)
-		return ret;
+		ret = ssd1307fb_write_cmd(par->client, page_start);
+		if (ret < 0)
+			return ret;
+
+		ret = ssd1307fb_write_cmd(par->client, page_end);
+		if (ret < 0)
+			return ret;
 
-	return ssd1307fb_write_cmd(par->client, page_end);
+		par->page_start = page_start;
+		par->page_end = page_end;
+	}
+
+	return 0;
 }
 
 static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x,
Signature · 1 line
2.25.1
#15 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 4 lines · Geert Uytterhoeven

Hi all,

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

What is required to to have a drm driver that could do the same?

Note: I will take a look at the patches a bit later.

Sam

#16 lore raw

Hi Sam,

Quoted 5 lines · Sam Ravnborg
Quoted 2 lines · Geert Uytterhoeven

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

What is required to to have a drm driver that could do the same?

Add monochrome support to DRM?

Quoted 1 line

Note: I will take a look at the patches a bit later.

TIA!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#17 lore raw
Quoted 11 lines · Geert Uytterhoeven

Hi Sam,

Quoted 5 lines · Sam Ravnborg
Quoted 2 lines · Geert Uytterhoeven

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

What is required to to have a drm driver that could do the same?

Add monochrome support to DRM?

I think the bits that are missing for that are
- wiring up the conversion from R* formats to their fbdev counterparts in the emulation helper (if you want to support userspace sending the native format directly through fbdev

Everything else is there and we have drivers doing this, e.g. drm/tiny/repaper.c.
-Daniel

Quoted 15 lines
Quoted 2 lines

Note: I will take a look at the patches a bit later.

TIA!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Acked-by on the v1 series
#18 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 21 lines · Geert Uytterhoeven

Hi all,

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode. While many displays are smaller, and thus require less data to be transferred, 20 ms is still an optimistic value, as the actual data transfer may be much slower, especially on bitbanged I2C drivers. After this series, the amount of data transfer is reduced, as fillrect, copyarea, and imageblit only update the rectangle that changed.

This has been tested on an Adafruit FeatherWing OLED with an SSD1306 controller and a 128x32 OLED, connected to an OrangeCrab ECP5 FPGA board running a 64 MHz VexRiscv RISC-V softcore, where it reduced the CPU usage for blinking the cursor from more than 70% to ca. 10%.

Thanks for your comments!

Quoted 7 lines

Geert Uytterhoeven (5):
video: fbdev: ssd1307fb: Propagate errors via

    ssd1307fb_update_display()

video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()
video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()
video: fbdev: ssd1307fb: Optimize screen updates
video: fbdev: ssd1307fb: Cache address ranges

A few comments left for a couple of patches.
The remaining patches are:

Do you have commit rights to drm-misc-next?

Sam

#19 lore raw

Hi Sam,

Quoted 28 lines · Sam Ravnborg
Quoted 19 lines · Geert Uytterhoeven

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode. While many displays are smaller, and thus require less data to be transferred, 20 ms is still an optimistic value, as the actual data transfer may be much slower, especially on bitbanged I2C drivers. After this series, the amount of data transfer is reduced, as fillrect, copyarea, and imageblit only update the rectangle that changed.

This has been tested on an Adafruit FeatherWing OLED with an SSD1306 controller and a 128x32 OLED, connected to an OrangeCrab ECP5 FPGA board running a 64 MHz VexRiscv RISC-V softcore, where it reduced the CPU usage for blinking the cursor from more than 70% to ca. 10%.

Thanks for your comments!

Quoted 7 lines

Geert Uytterhoeven (5):
video: fbdev: ssd1307fb: Propagate errors via

    ssd1307fb_update_display()

video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()
video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()
video: fbdev: ssd1307fb: Optimize screen updates
video: fbdev: ssd1307fb: Cache address ranges

Quoted 3 lines

A few comments left for a couple of patches.
The remaining patches are:

Thank you!

Quoted 1 line

Do you have commit rights to drm-misc-next?

No I have not (and I don't think I should).

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#20 lore raw

Hi Geert,

Quoted 35 lines · Geert Uytterhoeven

Hi Sam,

Quoted 28 lines · Sam Ravnborg
Quoted 19 lines · Geert Uytterhoeven

This patch series optimizes console operations on ssd1307fb, after the customary fixes and cleanups.

Currently, each screen update triggers an I2C transfer of all screen data, up to 1 KiB of data for a 128x64 display, which takes at least 20 ms in Fast mode. While many displays are smaller, and thus require less data to be transferred, 20 ms is still an optimistic value, as the actual data transfer may be much slower, especially on bitbanged I2C drivers. After this series, the amount of data transfer is reduced, as fillrect, copyarea, and imageblit only update the rectangle that changed.

This has been tested on an Adafruit FeatherWing OLED with an SSD1306 controller and a 128x32 OLED, connected to an OrangeCrab ECP5 FPGA board running a 64 MHz VexRiscv RISC-V softcore, where it reduced the CPU usage for blinking the cursor from more than 70% to ca. 10%.

Thanks for your comments!

Quoted 7 lines

Geert Uytterhoeven (5):
video: fbdev: ssd1307fb: Propagate errors via

    ssd1307fb_update_display()

video: fbdev: ssd1307fb: Simplify ssd1307fb_update_display()
video: fbdev: ssd1307fb: Extract ssd1307fb_set_address_range()
video: fbdev: ssd1307fb: Optimize screen updates
video: fbdev: ssd1307fb: Cache address ranges

Quoted 3 lines

A few comments left for a couple of patches.
The remaining patches are:

Quoted 5 lines

Thank you!

Quoted 1 line

Do you have commit rights to drm-misc-next?

No I have not (and I don't think I should).

I would love to have you around for the fbdev stuff, as you knows a ton more about fbdev than I do - I am just pretending.
And it would then be good if you could apply patches too. I for one may be off for shorter or longer periods as this is purely driven by interest.

Note: I assume you will resend the series - then I can apply.

Sam