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
594}594}
595EXPORT_SYMBOL(drm_fb_blit_toio);595EXPORT_SYMBOL(drm_fb_blit_toio);
596 596
597static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned int pixels,597static void drm_fb_gray8_to_mono_line(u8 *dst, const u8 *src, unsigned int pixels,
598 unsigned int start_offset, unsigned int end_len)598 unsigned int start_offset, unsigned int end_len)
599{599{
600 unsigned int xb, i;600 unsigned int xb, i;
601 601
@@ -621,8 +621,8 @@ static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned · 19 unmodified lines
621}621}
622 622
623/**623/**
624 * drm_fb_xrgb8888_to_mono_reversed - Convert XRGB8888 to reversed monochrome624 * drm_fb_xrgb8888_to_mono - Convert XRGB8888 to monochrome
625 * @dst: reversed monochrome destination buffer625 * @dst: monochrome destination buffer (0=black, 1=white)
626 * @dst_pitch: Number of bytes between two consecutive scanlines within dst626 * @dst_pitch: Number of bytes between two consecutive scanlines within dst
627 * @src: XRGB8888 source buffer627 * @src: XRGB8888 source buffer
628 * @fb: DRM framebuffer628 * @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
633 * and use this function to convert to the native format.633 * and use this function to convert to the native format.
634 *634 *
635 * This function uses drm_fb_xrgb8888_to_gray8() to convert to grayscale and635 * 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.
637 */637 */
638void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const void *vaddr,638void 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)639 const struct drm_framebuffer *fb, const struct drm_rect *clip)
640{640{
641 unsigned int linepixels = drm_rect_width(clip);641 unsigned int linepixels = drm_rect_width(clip);
642 unsigned int lines = clip->y2 - clip->y1;642 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
652 return;652 return;
653 653
654 /*654 /*
655 * The reversed mono destination buffer contains 1 bit per pixel655 * The mono destination buffer contains 1 bit per pixel and
656 * and destination scanlines have to be in multiple of 8 pixels.656 * destination scanlines have to be in multiple of 8 pixels.
657 */657 */
658 if (!dst_pitch)658 if (!dst_pitch)
659 dst_pitch = DIV_ROUND_UP(linepixels, 8);659 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
664 * The cma memory is write-combined so reads are uncached.664 * The cma memory is write-combined so reads are uncached.
665 * Speed up by fetching one line at a time.665 * Speed up by fetching one line at a time.
666 *666 *
667 * Also, format conversion from XR24 to reversed monochrome667 * Also, format conversion from XR24 to monochrome are done
668 * are done line-by-line but are converted to 8-bit grayscale668 * line-by-line but are converted to 8-bit grayscale as an
669 * as an intermediate step.669 * intermediate step.
670 *670 *
671 * Allocate a buffer to be used for both copying from the cma671 * Allocate a buffer to be used for both copying from the cma
672 * memory and to store the intermediate grayscale line pixels.672 * 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
683 * are not aligned to multiple of 8.683 * are not aligned to multiple of 8.
684 *684 *
685 * Calculate if the start and end pixels are not aligned and set the685 * 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.
687 */687 */
688 start_offset = clip->x1 % 8;688 start_offset = clip->x1 % 8;
689 end_len = clip->x2 % 8;689 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
692 for (y = 0; y < lines; y++) {692 for (y = 0; y < lines; y++) {
693 src32 = memcpy(src32, vaddr, len_src32);693 src32 = memcpy(src32, vaddr, len_src32);
694 drm_fb_xrgb8888_to_gray8_line(gray8, src32, linepixels);694 drm_fb_xrgb8888_to_gray8_line(gray8, src32, linepixels);
695 drm_fb_gray8_to_mono_reversed_line(mono, gray8, dst_pitch,695 drm_fb_gray8_to_mono_line(mono, gray8, dst_pitch, start_offset, end_len);
696 start_offset, end_len);
697 vaddr += fb->pitches[0];696 vaddr += fb->pitches[0];
698 mono += dst_pitch;697 mono += dst_pitch;
699 }698 }
700 699
701 kfree(src32);700 kfree(src32);
702}701}
703EXPORT_SYMBOL(drm_fb_xrgb8888_to_mono_reversed);702EXPORT_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
458 if (!buf)458 if (!buf)
459 return -ENOMEM;459 return -ENOMEM;
460 460
461 drm_fb_xrgb8888_to_mono_reversed(buf, 0, vmap, fb, rect);461 drm_fb_xrgb8888_to_mono(buf, 0, vmap, fb, rect);
462 462
463 ssd130x_update_rect(ssd130x, buf, rect);463 ssd130x_update_rect(ssd130x, buf, rect);
464 464
drivers/gpu/drm/tiny/repaper.c+1−1
@@ -540,7 +540,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb) · 539 unmodified lines
540 if (ret)540 if (ret)
541 goto out_free;541 goto out_free;
542 542
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);
544 544
545 drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);545 drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
546 546
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
43 const void *vmap, const struct drm_framebuffer *fb,43 const void *vmap, const struct drm_framebuffer *fb,
44 const struct drm_rect *rect);44 const struct drm_rect *rect);
45 45
46void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const void *src,46void drm_fb_xrgb8888_to_mono(void *dst, unsigned int dst_pitch, const void *src,
47 const struct drm_framebuffer *fb,47 const struct drm_framebuffer *fb, const struct drm_rect *clip);
48 const struct drm_rect *clip);
49 48
50#endif /* __LINUX_DRM_FORMAT_HELPER_H */49#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