History

drm/format-helper: Rename drm_fb_xrgb8888_to_mono_reversed()

There is no "reversed" handling in drm_fb_xrgb8888_to_mono_reversed(): the function just converts from color to grayscale, and reduces the number of grayscale levels from 256 to 2 (i.e. brightness 0-127 is mapped to 0, 128-255 to 1). All "reversed" handling is done in the repaper driver, where this function originated. Hence make this clear by renaming drm_fb_xrgb8888_to_mono_reversed() to drm_fb_xrgb8888_to_mono(), and documenting the black/white pixel mapping.

Geert Uytterhoeven committed 4 years ago

Commit 9b13a3f1 parent aa457ff4 files · +19 −21Browse files

Unified · Split

4 files
  1. drivers/gpu/drm/drm_format_helper.c +15 −16
  2. drivers/gpu/drm/solomon/ssd130x.c +1 −1
  3. drivers/gpu/drm/tiny/repaper.c +1 −1
  4. include/drm/drm_format_helper.h +2 −3
drivers/gpu/drm/drm_format_helper.c+15−16
@@ -594,8 +594,8 @@ int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · 593 unmodified lines
594594 }
595595 EXPORT_SYMBOL(drm_fb_blit_toio);
596596
597−static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned int pixels,
598− unsigned int start_offset, unsigned int end_len)
597+static void drm_fb_gray8_to_mono_line(u8 *dst, const u8 *src, unsigned int pixels,
598+ unsigned int start_offset, unsigned int end_len)
599599 {
600600 unsigned int xb, i;
601601
@@ -621,8 +621,8 @@ static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned · 19 unmodified lines
621621 }
622622
623623 /**
624− * drm_fb_xrgb8888_to_mono_reversed - Convert XRGB8888 to reversed monochrome
625− * @dst: reversed monochrome destination buffer
624+ * drm_fb_xrgb8888_to_mono - Convert XRGB8888 to monochrome
625+ * @dst: monochrome destination buffer (0=black, 1=white)
626626 * @dst_pitch: Number of bytes between two consecutive scanlines within dst
627627 * @src: XRGB8888 source buffer
628628 * @fb: DRM framebuffer
@@ -633,10 +633,10 @@ static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned · 4 unmodified lines
633633 * and use this function to convert to the native format.
634634 *
635635 * This function uses drm_fb_xrgb8888_to_gray8() to convert to grayscale and
636− * then the result is converted from grayscale to reversed monohrome.
636+ * then the result is converted from grayscale to monochrome.
637637 */
638−void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const void *vaddr,
639− const struct drm_framebuffer *fb, const struct drm_rect *clip)
638+void drm_fb_xrgb8888_to_mono(void *dst, unsigned int dst_pitch, const void *vaddr,
639+ const struct drm_framebuffer *fb, const struct drm_rect *clip)
640640 {
641641 unsigned int linepixels = drm_rect_width(clip);
642642 unsigned int lines = clip->y2 - clip->y1;
@@ -652,8 +652,8 @@ void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const v · 9 unmodified lines
652652 return;
653653
654654 /*
655− * The reversed mono destination buffer contains 1 bit per pixel
656− * and destination scanlines have to be in multiple of 8 pixels.
655+ * The mono destination buffer contains 1 bit per pixel and
656+ * destination scanlines have to be in multiple of 8 pixels.
657657 */
658658 if (!dst_pitch)
659659 dst_pitch = DIV_ROUND_UP(linepixels, 8);
@@ -664,9 +664,9 @@ void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const v · 4 unmodified lines
664664 * The cma memory is write-combined so reads are uncached.
665665 * Speed up by fetching one line at a time.
666666 *
667− * Also, format conversion from XR24 to reversed monochrome
668− * are done line-by-line but are converted to 8-bit grayscale
669− * as an intermediate step.
667+ * Also, format conversion from XR24 to monochrome are done
668+ * line-by-line but are converted to 8-bit grayscale as an
669+ * intermediate step.
670670 *
671671 * Allocate a buffer to be used for both copying from the cma
672672 * memory and to store the intermediate grayscale line pixels.
@@ -683,7 +683,7 @@ void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const v · 10 unmodified lines
683683 * are not aligned to multiple of 8.
684684 *
685685 * Calculate if the start and end pixels are not aligned and set the
686− * offsets for the reversed mono line conversion function to adjust.
686+ * offsets for the mono line conversion function to adjust.
687687 */
688688 start_offset = clip->x1 % 8;
689689 end_len = clip->x2 % 8;
@@ -692,12 +692,11 @@ void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const v · 2 unmodified lines
692692 for (y = 0; y < lines; y++) {
693693 src32 = memcpy(src32, vaddr, len_src32);
694694 drm_fb_xrgb8888_to_gray8_line(gray8, src32, linepixels);
695− drm_fb_gray8_to_mono_reversed_line(mono, gray8, dst_pitch,
696− start_offset, end_len);
695+ drm_fb_gray8_to_mono_line(mono, gray8, dst_pitch, start_offset, end_len);
697696 vaddr += fb->pitches[0];
698697 mono += dst_pitch;
699698 }
700699
701700 kfree(src32);
702701 }
703−EXPORT_SYMBOL(drm_fb_xrgb8888_to_mono_reversed);
702+EXPORT_SYMBOL(drm_fb_xrgb8888_to_mono);
drivers/gpu/drm/solomon/ssd130x.c+1−1
@@ -458,7 +458,7 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct dma_buf · 457 unmodified lines
458458 if (!buf)
459459 return -ENOMEM;
460460
461− drm_fb_xrgb8888_to_mono_reversed(buf, 0, vmap, fb, rect);
461+ drm_fb_xrgb8888_to_mono(buf, 0, vmap, fb, rect);
462462
463463 ssd130x_update_rect(ssd130x, buf, rect);
464464
drivers/gpu/drm/tiny/repaper.c+1−1
@@ -540,7 +540,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb) · 539 unmodified lines
540540 if (ret)
541541 goto out_free;
542542
543− drm_fb_xrgb8888_to_mono_reversed(buf, 0, cma_obj->vaddr, fb, &clip);
543+ drm_fb_xrgb8888_to_mono(buf, 0, cma_obj->vaddr, fb, &clip);
544544
545545 drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
546546
include/drm/drm_format_helper.h+2−3
@@ -43,8 +43,7 @@ int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · 42 unmodified lines
4343 const void *vmap, const struct drm_framebuffer *fb,
4444 const struct drm_rect *rect);
4545
46−void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const void *src,
47− const struct drm_framebuffer *fb,
48− const struct drm_rect *clip);
46+void drm_fb_xrgb8888_to_mono(void *dst, unsigned int dst_pitch, const void *src,
47+ const struct drm_framebuffer *fb, const struct drm_rect *clip);
4948
5049 #endif /* __LINUX_DRM_FORMAT_HELPER_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t