Skip to contentSkip to conversation

drm/repaper: Use format helper for xrgb8888 to monochrome conversion

PATCH In review Javier Martinez Canillas 3 participants 4 messages Feb 23, 2022 – Feb 24, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/repaper: Use format helper for xrgb8888 to monochrome conversion

There is now a drm_fb_xrgb8888_to_mono_reversed() helper function to do format conversion from XRGB8888 to reversed monochrome.

Use that helper and remove the open coded version in the repaper driver.

---

This was only built tested because I don't have access to the hardware.

 drivers/gpu/drm/tiny/repaper.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/gpu/drm/tiny/repaper.c +1 -23
index 97a775c48cea..5c74e236b16d 100644
@@ -508,26 +508,6 @@ static void repaper_get_temperature(struct repaper_epd *epd)
 	epd->factored_stage_time = epd->stage_time * factor10x / 10;
 }
 
-static void repaper_gray8_to_mono_reversed(u8 *buf, u32 width, u32 height)
-{
-	u8 *gray8 = buf, *mono = buf;
-	int y, xb, i;
-
-	for (y = 0; y < height; y++)
-		for (xb = 0; xb < width / 8; xb++) {
-			u8 byte = 0x00;
-
-			for (i = 0; i < 8; i++) {
-				int x = xb * 8 + i;
-
-				byte >>= 1;
-				if (gray8[y * width + x] >> 7)
-					byte |= BIT(7);
-			}
-			*mono++ = byte;
-		}
-}
-
 static int repaper_fb_dirty(struct drm_framebuffer *fb)
 {
 	struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
@@ -560,12 +540,10 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb)
 	if (ret)
 		goto out_free;
 
-	drm_fb_xrgb8888_to_gray8(buf, 0, cma_obj->vaddr, fb, &clip);
+	drm_fb_xrgb8888_to_mono_reversed(buf, 0, cma_obj->vaddr, fb, &clip);
 
 	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 
-	repaper_gray8_to_mono_reversed(buf, fb->width, fb->height);
-
 	if (epd->partial) {
 		repaper_frame_data_repeat(epd, buf, epd->current_frame,
 					  REPAPER_NORMAL);
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi

Am 23.02.22 um 20:37 schrieb Javier Martinez Canillas:

Quoted 6 lines

There is now a drm_fb_xrgb8888_to_mono_reversed() helper function to do format conversion from XRGB8888 to reversed monochrome.

Use that helper and remove the open coded version in the repaper driver.

Looks good.

Quoted 52 lines

---

This was only built tested because I don't have access to the hardware.

  drivers/gpu/drm/tiny/repaper.c | 24 +-----------------------
  1 file changed, 1 insertion(+), 23 deletions(-)
drivers/gpu/drm/tiny/repaper.c +1 -23
index 97a775c48cea..5c74e236b16d 100644
@@ -508,26 +508,6 @@ static void repaper_get_temperature(struct repaper_epd *epd)
  	epd->factored_stage_time = epd->stage_time * factor10x / 10;
  }
 
-static void repaper_gray8_to_mono_reversed(u8 *buf, u32 width, u32 height)
-{
-	u8 *gray8 = buf, *mono = buf;
-	int y, xb, i;
-
-	for (y = 0; y < height; y++)
-		for (xb = 0; xb < width / 8; xb++) {
-			u8 byte = 0x00;
-
-			for (i = 0; i < 8; i++) {
-				int x = xb * 8 + i;
-
-				byte >>= 1;
-				if (gray8[y * width + x] >> 7)
-					byte |= BIT(7);
-			}
-			*mono++ = byte;
-		}
-}
-
  static int repaper_fb_dirty(struct drm_framebuffer *fb)
  {
  	struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
@@ -560,12 +540,10 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb)
  	if (ret)
  		goto out_free;
 
-	drm_fb_xrgb8888_to_gray8(buf, 0, cma_obj->vaddr, fb, &clip);
+	drm_fb_xrgb8888_to_mono_reversed(buf, 0, cma_obj->vaddr, fb, &clip);
 
  	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 
-	repaper_gray8_to_mono_reversed(buf, fb->width, fb->height);
-
  	if (epd->partial) {
  		repaper_frame_data_repeat(epd, buf, epd->current_frame,
  					  REPAPER_NORMAL);
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
Tested-by Reviewed-by on v1 1/1
#2 lore raw
In reply to Javier Martinez Canillas

Den 23.02.2022 20.37, skrev Javier Martinez Canillas:

Quoted 7 lines

There is now a drm_fb_xrgb8888_to_mono_reversed() helper function to do format conversion from XRGB8888 to reversed monochrome.

Use that helper and remove the open coded version in the repaper driver.

---

Do you have commit rights and will apply this patch?

Noralf.

#3 lore raw

Hello Noralf,

Quoted 6 lines · Noralf Trønnes

Den 23.02.2022 20.37, skrev Javier Martinez Canillas:

Quoted 3 lines

There is now a drm_fb_xrgb8888_to_mono_reversed() helper function to do format conversion from XRGB8888 to reversed monochrome.

Quoted 8 lines
Quoted 4 lines

Use that helper and remove the open coded version in the repaper driver.

---

Thanks a lot for testing and for your review.

Quoted 2 lines

Do you have commit rights and will apply this patch?

Yes, I do. Can apply this later today.

Best regards, --
Javier Martinez Canillas
Linux Engineering
Red Hat