diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2023-07-17 15:37:56 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2023-07-17 15:37:57 +0200 |
commit | 6c7f27441d6af776a89147027c6f4a11c0162c64 (patch) | |
tree | fc6f19c0b243dd77de3f270e1c2e8a41be086531 /drivers/gpu/drm/vkms/vkms_formats.c | |
parent | fdf0eaf11452d72945af31804e2a1048ee1b574c (diff) | |
parent | 36672dda2eb715af99e9abbcdc400d46598b691c (diff) |
Merge tag 'drm-misc-next-2023-07-13' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
drm-misc-next for v6.6:
UAPI Changes:
* fbdev:
* Make fbdev userspace interfaces optional; only leaves the
framebuffer console active
* prime:
* Support dma-buf self-import for all drivers automatically: improves
support for many userspace compositors
Cross-subsystem Changes:
* backlight:
* Fix interaction with fbdev in several drivers
* base: Convert struct platform.remove to return void; part of a larger,
tree-wide effort
* dma-buf: Acquire reservation lock for mmap() in exporters; part
of an on-going effort to simplify locking around dma-bufs
* fbdev:
* Use Linux device instead of fbdev device in many places
* Use deferred-I/O helper macros in various drivers
* i2c: Convert struct i2c from .probe_new to .probe; part of a larger,
tree-wide effort
* video:
* Avoid including <linux/screen_info.h>
Core Changes:
* atomic:
* Improve logging
* prime:
* Remove struct drm_driver.gem_prime_mmap plus driver updates: all
drivers now implement this callback with drm_gem_prime_mmap()
* gem:
* Support execution contexts: provides locking over multiple GEM
objects
* ttm:
* Support init_on_free
* Swapout fixes
Driver Changes:
* accel:
* ivpu: MMU updates; Support debugfs
* ast:
* Improve device-model detection
* Cleanups
* bridge:
* dw-hdmi: Improve support for YUV420 bus format
* dw-mipi-dsi: Fix enable/disable of DSI controller
* lt9611uxc: Use MODULE_FIRMWARE()
* ps8640: Remove broken EDID code
* samsung-dsim: Fix command transfer
* tc358764: Handle HS/VS polarity; Use BIT() macro; Various cleanups
* Cleanups
* ingenic:
* Kconfig REGMAP fixes
* loongson:
* Support display controller
* mgag200:
* Minor fixes
* mxsfb:
* Support disabling overlay planes
* nouveau:
* Improve VRAM detection
* Various fixes and cleanups
* panel:
* panel-edp: Support AUO B116XAB01.4
* Support Visionox R66451 plus DT bindings
* Cleanups
* ssd130x:
* Support per-controller default resolution plus DT bindings
* Reduce memory-allocation overhead
* Cleanups
* tidss:
* Support TI AM625 plus DT bindings
* Implement new connector model plus driver updates
* vkms
* Improve write-back support
* Documentation fixes
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
From: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230713090830.GA23281@linux-uq9g
Diffstat (limited to 'drivers/gpu/drm/vkms/vkms_formats.c')
-rw-r--r-- | drivers/gpu/drm/vkms/vkms_formats.c | 153 |
1 files changed, 70 insertions, 83 deletions
diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 5945da0beba6..36046b12f296 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -111,6 +111,19 @@ static void RGB565_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) out_pixel->b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); } +/** + * vkms_compose_row - compose a single row of a plane + * @stage_buffer: output line with the composed pixels + * @plane: state of the plane that is being composed + * @y: y coordinate of the row + * + * This function composes a single row of a plane. It gets the source pixels + * through the y coordinate (see get_packed_src_addr()) and goes linearly + * through the source pixel, reading the pixels and converting it to + * ARGB16161616 (see the pixel_read() callback). For rotate-90 and rotate-270, + * the source pixels are not traversed linearly. The source pixels are queried + * on each iteration in order to traverse the pixels vertically. + */ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; @@ -137,107 +150,81 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state * They are used in the `compose_active_planes` to convert and store a line * from the src_buffer to the writeback buffer. */ -static void argb_u16_to_ARGB8888(struct vkms_frame_info *frame_info, - const struct line_buffer *src_buffer, int y) +static void argb_u16_to_ARGB8888(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { - int x_dst = frame_info->dst.x1; - u8 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); - struct pixel_argb_u16 *in_pixels = src_buffer->pixels; - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - src_buffer->n_pixels); - - for (size_t x = 0; x < x_limit; x++, dst_pixels += 4) { - /* - * This sequence below is important because the format's byte order is - * in little-endian. In the case of the ARGB8888 the memory is - * organized this way: - * - * | Addr | = blue channel - * | Addr + 1 | = green channel - * | Addr + 2 | = Red channel - * | Addr + 3 | = Alpha channel - */ - dst_pixels[3] = DIV_ROUND_CLOSEST(in_pixels[x].a, 257); - dst_pixels[2] = DIV_ROUND_CLOSEST(in_pixels[x].r, 257); - dst_pixels[1] = DIV_ROUND_CLOSEST(in_pixels[x].g, 257); - dst_pixels[0] = DIV_ROUND_CLOSEST(in_pixels[x].b, 257); - } + /* + * This sequence below is important because the format's byte order is + * in little-endian. In the case of the ARGB8888 the memory is + * organized this way: + * + * | Addr | = blue channel + * | Addr + 1 | = green channel + * | Addr + 2 | = Red channel + * | Addr + 3 | = Alpha channel + */ + dst_pixels[3] = DIV_ROUND_CLOSEST(in_pixel->a, 257); + dst_pixels[2] = DIV_ROUND_CLOSEST(in_pixel->r, 257); + dst_pixels[1] = DIV_ROUND_CLOSEST(in_pixel->g, 257); + dst_pixels[0] = DIV_ROUND_CLOSEST(in_pixel->b, 257); } -static void argb_u16_to_XRGB8888(struct vkms_frame_info *frame_info, - const struct line_buffer *src_buffer, int y) +static void argb_u16_to_XRGB8888(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { - int x_dst = frame_info->dst.x1; - u8 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); - struct pixel_argb_u16 *in_pixels = src_buffer->pixels; - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - src_buffer->n_pixels); - - for (size_t x = 0; x < x_limit; x++, dst_pixels += 4) { - dst_pixels[3] = 0xff; - dst_pixels[2] = DIV_ROUND_CLOSEST(in_pixels[x].r, 257); - dst_pixels[1] = DIV_ROUND_CLOSEST(in_pixels[x].g, 257); - dst_pixels[0] = DIV_ROUND_CLOSEST(in_pixels[x].b, 257); - } + dst_pixels[3] = 0xff; + dst_pixels[2] = DIV_ROUND_CLOSEST(in_pixel->r, 257); + dst_pixels[1] = DIV_ROUND_CLOSEST(in_pixel->g, 257); + dst_pixels[0] = DIV_ROUND_CLOSEST(in_pixel->b, 257); } -static void argb_u16_to_ARGB16161616(struct vkms_frame_info *frame_info, - const struct line_buffer *src_buffer, int y) +static void argb_u16_to_ARGB16161616(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { - int x_dst = frame_info->dst.x1; - u16 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); - struct pixel_argb_u16 *in_pixels = src_buffer->pixels; - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - src_buffer->n_pixels); - - for (size_t x = 0; x < x_limit; x++, dst_pixels += 4) { - dst_pixels[3] = cpu_to_le16(in_pixels[x].a); - dst_pixels[2] = cpu_to_le16(in_pixels[x].r); - dst_pixels[1] = cpu_to_le16(in_pixels[x].g); - dst_pixels[0] = cpu_to_le16(in_pixels[x].b); - } + u16 *pixels = (u16 *)dst_pixels; + + pixels[3] = cpu_to_le16(in_pixel->a); + pixels[2] = cpu_to_le16(in_pixel->r); + pixels[1] = cpu_to_le16(in_pixel->g); + pixels[0] = cpu_to_le16(in_pixel->b); } -static void argb_u16_to_XRGB16161616(struct vkms_frame_info *frame_info, - const struct line_buffer *src_buffer, int y) +static void argb_u16_to_XRGB16161616(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { - int x_dst = frame_info->dst.x1; - u16 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); - struct pixel_argb_u16 *in_pixels = src_buffer->pixels; - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - src_buffer->n_pixels); - - for (size_t x = 0; x < x_limit; x++, dst_pixels += 4) { - dst_pixels[3] = 0xffff; - dst_pixels[2] = cpu_to_le16(in_pixels[x].r); - dst_pixels[1] = cpu_to_le16(in_pixels[x].g); - dst_pixels[0] = cpu_to_le16(in_pixels[x].b); - } + u16 *pixels = (u16 *)dst_pixels; + + pixels[3] = 0xffff; + pixels[2] = cpu_to_le16(in_pixel->r); + pixels[1] = cpu_to_le16(in_pixel->g); + pixels[0] = cpu_to_le16(in_pixel->b); } -static void argb_u16_to_RGB565(struct vkms_frame_info *frame_info, - const struct line_buffer *src_buffer, int y) +static void argb_u16_to_RGB565(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { - int x_dst = frame_info->dst.x1; - u16 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); - struct pixel_argb_u16 *in_pixels = src_buffer->pixels; - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - src_buffer->n_pixels); + u16 *pixels = (u16 *)dst_pixels; s64 fp_rb_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(31)); s64 fp_g_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(63)); - for (size_t x = 0; x < x_limit; x++, dst_pixels++) { - s64 fp_r = drm_int2fixp(in_pixels[x].r); - s64 fp_g = drm_int2fixp(in_pixels[x].g); - s64 fp_b = drm_int2fixp(in_pixels[x].b); + s64 fp_r = drm_int2fixp(in_pixel->r); + s64 fp_g = drm_int2fixp(in_pixel->g); + s64 fp_b = drm_int2fixp(in_pixel->b); - u16 r = drm_fixp2int_round(drm_fixp_div(fp_r, fp_rb_ratio)); - u16 g = drm_fixp2int_round(drm_fixp_div(fp_g, fp_g_ratio)); - u16 b = drm_fixp2int_round(drm_fixp_div(fp_b, fp_rb_ratio)); + u16 r = drm_fixp2int(drm_fixp_div(fp_r, fp_rb_ratio)); + u16 g = drm_fixp2int(drm_fixp_div(fp_g, fp_g_ratio)); + u16 b = drm_fixp2int(drm_fixp_div(fp_b, fp_rb_ratio)); - *dst_pixels = cpu_to_le16(r << 11 | g << 5 | b); - } + *pixels = cpu_to_le16(r << 11 | g << 5 | b); +} + +void vkms_writeback_row(struct vkms_writeback_job *wb, + const struct line_buffer *src_buffer, int y) +{ + struct vkms_frame_info *frame_info = &wb->wb_frame_info; + int x_dst = frame_info->dst.x1; + u8 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); + struct pixel_argb_u16 *in_pixels = src_buffer->pixels; + int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), src_buffer->n_pixels); + + for (size_t x = 0; x < x_limit; x++, dst_pixels += frame_info->cpp) + wb->pixel_write(dst_pixels, &in_pixels[x]); } void *get_pixel_conversion_function(u32 format) @@ -258,7 +245,7 @@ void *get_pixel_conversion_function(u32 format) } } -void *get_line_to_frame_function(u32 format) +void *get_pixel_write_function(u32 format) { switch (format) { case DRM_FORMAT_ARGB8888: |