Lines Matching +full:min +full:- +full:pix +full:- +full:alignment
1 // SPDX-License-Identifier: GPL-2.0 or MIT
12 #include <linux/iosys-map.h>
24 * drm_format_conv_state_init - Initialize format-conversion state
32 state->tmp.mem = NULL; in drm_format_conv_state_init()
33 state->tmp.size = 0; in drm_format_conv_state_init()
34 state->tmp.preallocated = false; in drm_format_conv_state_init()
39 * drm_format_conv_state_copy - Copy format-conversion state
43 * Copies format-conversion state from @old_state to @state; except for
53 state->tmp.mem = NULL; in drm_format_conv_state_copy()
54 state->tmp.size = 0; in drm_format_conv_state_copy()
55 state->tmp.preallocated = false; in drm_format_conv_state_copy()
60 * drm_format_conv_state_reserve - Allocates storage for format conversion
61 * @state: The format-conversion state
78 if (new_size <= state->tmp.size) in drm_format_conv_state_reserve()
80 else if (state->tmp.preallocated) in drm_format_conv_state_reserve()
83 mem = krealloc(state->tmp.mem, new_size, flags); in drm_format_conv_state_reserve()
87 state->tmp.mem = mem; in drm_format_conv_state_reserve()
88 state->tmp.size = new_size; in drm_format_conv_state_reserve()
91 return state->tmp.mem; in drm_format_conv_state_reserve()
96 * drm_format_conv_state_release - Releases an format-conversion storage
97 * @state: The format-conversion state
99 * Releases the memory range references by the format-conversion state.
105 if (state->tmp.preallocated) in drm_format_conv_state_release()
108 kfree(state->tmp.mem); in drm_format_conv_state_release()
109 state->tmp.mem = NULL; in drm_format_conv_state_release()
110 state->tmp.size = 0; in drm_format_conv_state_release()
116 return clip->y1 * pitch + clip->x1 * cpp; in clip_offset()
120 * drm_fb_clip_offset - Returns the clipping rectangles byte-offset in a framebuffer
126 * The byte offset of the clip rectangle's top-left corner within the framebuffer.
131 return clip_offset(clip, pitch, format->cpp[0]); in drm_fb_clip_offset()
135 /* TODO: Make this function work with multi-plane formats. */
144 size_t sbuf_len = linepixels * fb->format->cpp[0]; in __drm_fb_xfrm()
150 * Some source buffers, such as DMA memory, use write-combine in __drm_fb_xfrm()
157 return -ENOMEM; in __drm_fb_xfrm()
162 vaddr += clip_offset(clip, fb->pitches[0], fb->format->cpp[0]); in __drm_fb_xfrm()
170 vaddr += fb->pitches[0]; in __drm_fb_xfrm()
177 /* TODO: Make this function work with multi-plane formats. */
187 size_t stmp_off = round_up(dbuf_len, ARCH_KMALLOC_MINALIGN); /* for sbuf alignment */ in __drm_fb_xfrm_toio()
188 size_t sbuf_len = linepixels * fb->format->cpp[0]; in __drm_fb_xfrm_toio()
201 return -ENOMEM; in __drm_fb_xfrm_toio()
205 vaddr += clip_offset(clip, fb->pitches[0], fb->format->cpp[0]); in __drm_fb_xfrm_toio()
214 vaddr += fb->pitches[0]; in __drm_fb_xfrm_toio()
221 /* TODO: Make this function work with multi-plane formats. */
248 * drm_fb_memcpy - Copy clip buffer
263 * top-left corner).
273 const struct drm_format_info *format = fb->format; in drm_fb_memcpy()
279 for (i = 0; i < format->num_planes; ++i) { in drm_fb_memcpy()
290 iosys_map_incr(&src_i, clip_offset(clip, fb->pitches[i], cpp_i)); in drm_fb_memcpy()
294 iosys_map_incr(&src_i, fb->pitches[i]); in drm_fb_memcpy()
322 * drm_fb_swab - Swap bytes into clip buffer
329 * @cached: Source buffer is mapped cached (eg. not write-combined)
332 * This function copies parts of a framebuffer to display memory and swaps per-pixel
341 * top-left corner).
348 const struct drm_format_info *format = fb->format; in drm_fb_swab()
360 drm_warn_once(fb->dev, "Format %p4cc has unsupported pixel size.\n", in drm_fb_swab()
361 &format->format); in drm_fb_swab()
374 u32 pix; in drm_fb_xrgb8888_to_rgb332_line() local
377 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_rgb332_line()
378 dbuf8[x] = ((pix & 0x00e00000) >> 16) | in drm_fb_xrgb8888_to_rgb332_line()
379 ((pix & 0x0000e000) >> 11) | in drm_fb_xrgb8888_to_rgb332_line()
380 ((pix & 0x000000c0) >> 6); in drm_fb_xrgb8888_to_rgb332_line()
385 * drm_fb_xrgb8888_to_rgb332 - Convert XRGB8888 to RGB332 clip buffer
401 * top-left corner).
424 u32 pix; in drm_fb_xrgb8888_to_rgb565_line() local
427 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_rgb565_line()
428 val16 = ((pix & 0x00F80000) >> 8) | in drm_fb_xrgb8888_to_rgb565_line()
429 ((pix & 0x0000FC00) >> 5) | in drm_fb_xrgb8888_to_rgb565_line()
430 ((pix & 0x000000F8) >> 3); in drm_fb_xrgb8888_to_rgb565_line()
443 u32 pix; in drm_fb_xrgb8888_to_rgb565_swab_line() local
446 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_rgb565_swab_line()
447 val16 = ((pix & 0x00F80000) >> 8) | in drm_fb_xrgb8888_to_rgb565_swab_line()
448 ((pix & 0x0000FC00) >> 5) | in drm_fb_xrgb8888_to_rgb565_swab_line()
449 ((pix & 0x000000F8) >> 3); in drm_fb_xrgb8888_to_rgb565_swab_line()
455 * drm_fb_xrgb8888_to_rgb565 - Convert XRGB8888 to RGB565 clip buffer
472 * top-left corner).
502 u32 pix; in drm_fb_xrgb8888_to_xrgb1555_line() local
505 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_xrgb1555_line()
506 val16 = ((pix & 0x00f80000) >> 9) | in drm_fb_xrgb8888_to_xrgb1555_line()
507 ((pix & 0x0000f800) >> 6) | in drm_fb_xrgb8888_to_xrgb1555_line()
508 ((pix & 0x000000f8) >> 3); in drm_fb_xrgb8888_to_xrgb1555_line()
514 * drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip buffer
530 * top-left corner).
554 u32 pix; in drm_fb_xrgb8888_to_argb1555_line() local
557 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_argb1555_line()
559 ((pix & 0x00f80000) >> 9) | in drm_fb_xrgb8888_to_argb1555_line()
560 ((pix & 0x0000f800) >> 6) | in drm_fb_xrgb8888_to_argb1555_line()
561 ((pix & 0x000000f8) >> 3); in drm_fb_xrgb8888_to_argb1555_line()
567 * drm_fb_xrgb8888_to_argb1555 - Convert XRGB8888 to ARGB1555 clip buffer
583 * top-left corner).
607 u32 pix; in drm_fb_xrgb8888_to_rgba5551_line() local
610 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_rgba5551_line()
611 val16 = ((pix & 0x00f80000) >> 8) | in drm_fb_xrgb8888_to_rgba5551_line()
612 ((pix & 0x0000f800) >> 5) | in drm_fb_xrgb8888_to_rgba5551_line()
613 ((pix & 0x000000f8) >> 2) | in drm_fb_xrgb8888_to_rgba5551_line()
620 * drm_fb_xrgb8888_to_rgba5551 - Convert XRGB8888 to RGBA5551 clip buffer
636 * top-left corner).
659 u32 pix; in drm_fb_xrgb8888_to_rgb888_line() local
662 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_rgb888_line()
663 /* write blue-green-red to output in little endianness */ in drm_fb_xrgb8888_to_rgb888_line()
664 *dbuf8++ = (pix & 0x000000FF) >> 0; in drm_fb_xrgb8888_to_rgb888_line()
665 *dbuf8++ = (pix & 0x0000FF00) >> 8; in drm_fb_xrgb8888_to_rgb888_line()
666 *dbuf8++ = (pix & 0x00FF0000) >> 16; in drm_fb_xrgb8888_to_rgb888_line()
671 * drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer
687 * top-left corner).
710 u32 pix; in drm_fb_xrgb8888_to_argb8888_line() local
713 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_argb8888_line()
714 pix |= GENMASK(31, 24); /* fill alpha bits */ in drm_fb_xrgb8888_to_argb8888_line()
715 dbuf32[x] = cpu_to_le32(pix); in drm_fb_xrgb8888_to_argb8888_line()
720 * drm_fb_xrgb8888_to_argb8888 - Convert XRGB8888 to ARGB8888 clip buffer
736 * top-left corner).
759 u32 pix; in drm_fb_xrgb8888_to_abgr8888_line() local
762 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_abgr8888_line()
763 pix = ((pix & 0x00ff0000) >> 16) << 0 | in drm_fb_xrgb8888_to_abgr8888_line()
764 ((pix & 0x0000ff00) >> 8) << 8 | in drm_fb_xrgb8888_to_abgr8888_line()
765 ((pix & 0x000000ff) >> 0) << 16 | in drm_fb_xrgb8888_to_abgr8888_line()
767 *dbuf32++ = cpu_to_le32(pix); in drm_fb_xrgb8888_to_abgr8888_line()
790 u32 pix; in drm_fb_xrgb8888_to_xbgr8888_line() local
793 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_xbgr8888_line()
794 pix = ((pix & 0x00ff0000) >> 16) << 0 | in drm_fb_xrgb8888_to_xbgr8888_line()
795 ((pix & 0x0000ff00) >> 8) << 8 | in drm_fb_xrgb8888_to_xbgr8888_line()
796 ((pix & 0x000000ff) >> 0) << 16 | in drm_fb_xrgb8888_to_xbgr8888_line()
797 ((pix & 0xff000000) >> 24) << 24; in drm_fb_xrgb8888_to_xbgr8888_line()
798 *dbuf32++ = cpu_to_le32(pix); in drm_fb_xrgb8888_to_xbgr8888_line()
822 u32 pix; in drm_fb_xrgb8888_to_xrgb2101010_line() local
825 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_xrgb2101010_line()
826 val32 = ((pix & 0x000000FF) << 2) | in drm_fb_xrgb8888_to_xrgb2101010_line()
827 ((pix & 0x0000FF00) << 4) | in drm_fb_xrgb8888_to_xrgb2101010_line()
828 ((pix & 0x00FF0000) << 6); in drm_fb_xrgb8888_to_xrgb2101010_line()
829 pix = val32 | ((val32 >> 8) & 0x00300C03); in drm_fb_xrgb8888_to_xrgb2101010_line()
830 *dbuf32++ = cpu_to_le32(pix); in drm_fb_xrgb8888_to_xrgb2101010_line()
835 * drm_fb_xrgb8888_to_xrgb2101010 - Convert XRGB8888 to XRGB2101010 clip buffer
851 * top-left corner).
876 u32 pix; in drm_fb_xrgb8888_to_argb2101010_line() local
879 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_argb2101010_line()
880 val32 = ((pix & 0x000000ff) << 2) | in drm_fb_xrgb8888_to_argb2101010_line()
881 ((pix & 0x0000ff00) << 4) | in drm_fb_xrgb8888_to_argb2101010_line()
882 ((pix & 0x00ff0000) << 6); in drm_fb_xrgb8888_to_argb2101010_line()
883 pix = GENMASK(31, 30) | /* set alpha bits */ in drm_fb_xrgb8888_to_argb2101010_line()
885 *dbuf32++ = cpu_to_le32(pix); in drm_fb_xrgb8888_to_argb2101010_line()
890 * drm_fb_xrgb8888_to_argb2101010 - Convert XRGB8888 to ARGB2101010 clip buffer
906 * top-left corner).
932 u32 pix = le32_to_cpu(sbuf32[x]); in drm_fb_xrgb8888_to_gray8_line() local
933 u8 r = (pix & 0x00ff0000) >> 16; in drm_fb_xrgb8888_to_gray8_line()
934 u8 g = (pix & 0x0000ff00) >> 8; in drm_fb_xrgb8888_to_gray8_line()
935 u8 b = pix & 0x000000ff; in drm_fb_xrgb8888_to_gray8_line()
943 * drm_fb_xrgb8888_to_gray8 - Convert XRGB8888 to grayscale
944 * @dst: Array of 8-bit grayscale destination buffers
959 * top-left corner).
966 * ITU BT.601 is being used for the RGB -> luma (brightness) conversion.
982 * drm_fb_blit - Copy parts of a framebuffer to display memory
983 * @dst: Array of display-memory addresses to copy to
1000 * top-left corner).
1004 * -EINVAL if the color-format conversion failed, or
1011 uint32_t fb_format = fb->format->format; in drm_fb_blit()
1059 drm_warn_once(fb->dev, "No conversion helper from %p4cc to %p4cc found.\n", in drm_fb_blit()
1062 return -EINVAL; in drm_fb_blit()
1072 unsigned int i, bits = min(pixels, 8U); in drm_fb_gray8_to_mono_line()
1075 for (i = 0; i < bits; i++, pixels--) { in drm_fb_gray8_to_mono_line()
1084 * drm_fb_xrgb8888_to_mono - Convert XRGB8888 to monochrome
1100 * top-left corner). The first pixel (upper left corner of the clip rectangle) will
1103 * be located at an x-coordinate that is a multiple of 8, then the caller must take
1123 unsigned int cpp = fb->format->cpp[0]; in drm_fb_xrgb8888_to_mono()
1125 struct drm_device *dev = fb->dev; in drm_fb_xrgb8888_to_mono()
1132 if (drm_WARN_ON(dev, fb->format->format != DRM_FORMAT_XRGB8888)) in drm_fb_xrgb8888_to_mono()
1146 * The dma memory is write-combined so reads are uncached. in drm_fb_xrgb8888_to_mono()
1150 * line-by-line but are converted to 8-bit grayscale as an in drm_fb_xrgb8888_to_mono()
1162 vaddr += clip_offset(clip, fb->pitches[0], cpp); in drm_fb_xrgb8888_to_mono()
1167 vaddr += fb->pitches[0]; in drm_fb_xrgb8888_to_mono()
1219 * drm_fb_build_fourcc_list - Filters a list of supported color formats against
1241 * The number of color-formats 4CC codes returned in @fourccs_out.
1269 * alpha formats that are non-alpha formats instead. So in drm_fb_build_fourcc_list()
1270 * replace alpha formats by non-alpha formats. in drm_fb_build_fourcc_list()
1274 if (is_listed_fourcc(fourccs_out, fourccs - fourccs_out, fourcc)) { in drm_fb_build_fourcc_list()
1294 if (is_listed_fourcc(fourccs_out, fourccs - fourccs_out, fourcc)) { in drm_fb_build_fourcc_list()
1307 return fourccs - fourccs_out; in drm_fb_build_fourcc_list()