* [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats @ 2025-05-30 14:05 Louis Chauvet 2025-05-30 14:05 ` [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks Louis Chauvet ` (7 more replies) 0 siblings, 8 replies; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:05 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet This series introduce a macro to generate a function to read simple formats. It avoid duplication of the same logic for similar formats. In addition, it also introduce multiple "easy" formats (rgb888 variants) and also 16 bits yuv support (P01* formats). PATCH 1 is the introduction of the macro and adaptation of the existing code to avoid duplication PATCH 2-5 introduce new formats with the help of this macro. PATCH 6 adds support for 16-bit yuv formats PATCH 7 introduces a macro to reduce code duplication between yuv formats PATCH 8 adds support for P01* formats I tested the implementation using kms_plane. Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- Changes in v4: - Update tests to test yuv 16 bits conversions, not only 8 bits - Link to v3: https://lore.kernel.org/r/20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com Changes in v3: - Rebased on new YUV iterations - Link to v2: https://lore.kernel.org/r/20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com Changes in v2: - Add proper casting/type to __le16 when needed to avoid warnings with sparse - Change the function argb_u16_from_yuv8888 to argb_u16_from_yuv161616 to support 16 bits values. - Add support for P010/P012/P016 format - Link to v1: https://lore.kernel.org/r/20240516-b4-new-color-formats-v1-0-74cf9fe07317@bootlin.com --- Louis Chauvet (8): drm/vkms: Create helpers macro to avoid code duplication in format callbacks drm/vkms: Add support for ARGB8888 formats drm/vkms: Add support for ARGB16161616 formats drm/vkms: Add support for RGB565 formats drm/vkms: Add support for RGB888 formats drm/vkms: Change YUV helpers to support u16 inputs for conversion drm/vkms: Create helper macro for YUV formats drm/vkms: Add P01* formats drivers/gpu/drm/vkms/tests/vkms_format_test.c | 103 ++++---- drivers/gpu/drm/vkms/vkms_formats.c | 341 +++++++++++++------------- drivers/gpu/drm/vkms/vkms_formats.h | 4 +- drivers/gpu/drm/vkms/vkms_plane.c | 15 +- 4 files changed, 244 insertions(+), 219 deletions(-) --- base-commit: 2271e0a20ef795838527815e057f5af206b69c87 change-id: 20240312-b4-new-color-formats-1be9d688b21a Best regards, -- Louis Chauvet <louis.chauvet@bootlin.com> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet @ 2025-05-30 14:05 ` Louis Chauvet 2025-06-11 19:51 ` Maíra Canal 2025-05-30 14:05 ` [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats Louis Chauvet ` (6 subsequent siblings) 7 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:05 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet The callback functions for line conversion are almost identical for some format. The generic READ_LINE macro generate all the required boilerplate to process a line. Two overrides of this macro have been added to avoid duplication of the same arguments every time. Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 186 ++++++++++++------------------------ 1 file changed, 59 insertions(+), 127 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 6d0227c6635a..a9c624081dac 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -292,6 +292,58 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, } EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); +/** + * READ_LINE() - Generic generator for a read_line function which can be used for format with one + * plane and a block_h == block_w == 1. + * + * @function_name: Function name to generate + * @pixel_name: Temporary pixel name used in the @__VA_ARGS__ parameters + * @pixel_type: Used to specify the type you want to cast the pixel pointer + * @callback: Callback to call for each pixels. This fonction should take @__VA_ARGS__ as parameter + * and return a pixel_argb_u16 + * @__VA_ARGS__: Argument to pass inside the callback. You can use @pixel_name to access current + * pixel. + */ +#define READ_LINE(function_name, pixel_name, pixel_type, callback, ...) \ +static void function_name(const struct vkms_plane_state *plane, int x_start, \ + int y_start, enum pixel_read_direction direction, int count, \ + struct pixel_argb_u16 out_pixel[]) \ +{ \ + struct pixel_argb_u16 *end = out_pixel + count; \ + int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); \ + u8 *src_pixels; \ + \ + packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); \ + \ + while (out_pixel < end) { \ + pixel_type *(pixel_name) = (pixel_type *)src_pixels; \ + *out_pixel = (callback)(__VA_ARGS__); \ + out_pixel += 1; \ + src_pixels += step; \ + } \ +} + +/** + * READ_LINE_ARGB8888() - Generic generator for ARGB8888 formats. + * The pixel type used is u8, so pixel_name[0]..pixel_name[n] are the n components of the pixel. + * + * @function_name: Function name to generate + * @pixel_name: temporary pixel to use in @a, @r, @g and @b parameters + * @a, @r, @g, @b: value of each channel + */ +#define READ_LINE_ARGB8888(function_name, pixel_name, a, r, g, b) \ + READ_LINE(function_name, pixel_name, u8, argb_u16_from_u8888, a, r, g, b) +/** + * READ_LINE_le16161616() - Generic generator for ARGB16161616 formats. + * The pixel type used is u16, so pixel_name[0]..pixel_name[n] are the n components of the pixel. + * + * @function_name: Function name to generate + * @pixel_name: temporary pixel to use in @a, @r, @g and @b parameters + * @a, @r, @g, @b: value of each channel + */ +#define READ_LINE_le16161616(function_name, pixel_name, a, r, g, b) \ + READ_LINE(function_name, pixel_name, __le16, argb_u16_from_le16161616, a, r, g, b) + /* * The following functions are read_line function for each pixel format supported by VKMS. * @@ -378,138 +430,18 @@ static void R4_read_line(const struct vkms_plane_state *plane, int x_start, Rx_read_line(plane, x_start, y_start, direction, count, out_pixel); } -static void R8_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); +READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0]) - while (out_pixel < end) { - *out_pixel = argb_u16_from_gray8(*src_pixels); - src_pixels += step; - out_pixel += 1; - } -} +READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) -static void ARGB8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, - enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); +READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); +READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) - while (out_pixel < end) { - u8 *px = (u8 *)src_pixels; - *out_pixel = argb_u16_from_u8888(px[3], px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void XRGB8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, - enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - u8 *px = (u8 *)src_pixels; - *out_pixel = argb_u16_from_u8888(255, px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void ABGR8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, - enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - u8 *px = (u8 *)src_pixels; - /* Switch blue and red pixels. */ - *out_pixel = argb_u16_from_u8888(px[3], px[0], px[1], px[2]); - out_pixel += 1; - src_pixels += step; - } -} - -static void ARGB16161616_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - u16 *px = (u16 *)src_pixels; - *out_pixel = argb_u16_from_u16161616(px[3], px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void XRGB16161616_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - __le16 *px = (__le16 *)src_pixels; - *out_pixel = argb_u16_from_le16161616(cpu_to_le16(0xFFFF), px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void RGB565_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - __le16 *px = (__le16 *)src_pixels; - - *out_pixel = argb_u16_from_RGB565(px); - out_pixel += 1; - src_pixels += step; - } -} +READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) /* * This callback can be used for YUV formats where U and V values are -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks 2025-05-30 14:05 ` [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks Louis Chauvet @ 2025-06-11 19:51 ` Maíra Canal 0 siblings, 0 replies; 21+ messages in thread From: Maíra Canal @ 2025-06-11 19:51 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee On 5/30/25 11:05, Louis Chauvet wrote: > The callback functions for line conversion are almost identical for > some format. The generic READ_LINE macro generate all the required > boilerplate to process a line. > > Two overrides of this macro have been added to avoid duplication of > the same arguments every time. > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Best Regards, - Maíra > --- > drivers/gpu/drm/vkms/vkms_formats.c | 186 ++++++++++++------------------------ > 1 file changed, 59 insertions(+), 127 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 6d0227c6635a..a9c624081dac 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -292,6 +292,58 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, > } > EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); > > +/** > + * READ_LINE() - Generic generator for a read_line function which can be used for format with one > + * plane and a block_h == block_w == 1. > + * > + * @function_name: Function name to generate > + * @pixel_name: Temporary pixel name used in the @__VA_ARGS__ parameters > + * @pixel_type: Used to specify the type you want to cast the pixel pointer > + * @callback: Callback to call for each pixels. This fonction should take @__VA_ARGS__ as parameter > + * and return a pixel_argb_u16 > + * @__VA_ARGS__: Argument to pass inside the callback. You can use @pixel_name to access current > + * pixel. > + */ > +#define READ_LINE(function_name, pixel_name, pixel_type, callback, ...) \ > +static void function_name(const struct vkms_plane_state *plane, int x_start, \ > + int y_start, enum pixel_read_direction direction, int count, \ > + struct pixel_argb_u16 out_pixel[]) \ > +{ \ > + struct pixel_argb_u16 *end = out_pixel + count; \ > + int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); \ > + u8 *src_pixels; \ > + \ > + packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); \ > + \ > + while (out_pixel < end) { \ > + pixel_type *(pixel_name) = (pixel_type *)src_pixels; \ > + *out_pixel = (callback)(__VA_ARGS__); \ > + out_pixel += 1; \ > + src_pixels += step; \ > + } \ > +} > + > +/** > + * READ_LINE_ARGB8888() - Generic generator for ARGB8888 formats. > + * The pixel type used is u8, so pixel_name[0]..pixel_name[n] are the n components of the pixel. > + * > + * @function_name: Function name to generate > + * @pixel_name: temporary pixel to use in @a, @r, @g and @b parameters > + * @a, @r, @g, @b: value of each channel > + */ > +#define READ_LINE_ARGB8888(function_name, pixel_name, a, r, g, b) \ > + READ_LINE(function_name, pixel_name, u8, argb_u16_from_u8888, a, r, g, b) > +/** > + * READ_LINE_le16161616() - Generic generator for ARGB16161616 formats. > + * The pixel type used is u16, so pixel_name[0]..pixel_name[n] are the n components of the pixel. > + * > + * @function_name: Function name to generate > + * @pixel_name: temporary pixel to use in @a, @r, @g and @b parameters > + * @a, @r, @g, @b: value of each channel > + */ > +#define READ_LINE_le16161616(function_name, pixel_name, a, r, g, b) \ > + READ_LINE(function_name, pixel_name, __le16, argb_u16_from_le16161616, a, r, g, b) > + > /* > * The following functions are read_line function for each pixel format supported by VKMS. > * > @@ -378,138 +430,18 @@ static void R4_read_line(const struct vkms_plane_state *plane, int x_start, > Rx_read_line(plane, x_start, y_start, direction, count, out_pixel); > } > > -static void R8_read_line(const struct vkms_plane_state *plane, int x_start, > - int y_start, enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > +READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0]) > > - while (out_pixel < end) { > - *out_pixel = argb_u16_from_gray8(*src_pixels); > - src_pixels += step; > - out_pixel += 1; > - } > -} > +READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) > +READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) > > -static void ARGB8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, > - enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > +READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) > +READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) > > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > +READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) > > - while (out_pixel < end) { > - u8 *px = (u8 *)src_pixels; > - *out_pixel = argb_u16_from_u8888(px[3], px[2], px[1], px[0]); > - out_pixel += 1; > - src_pixels += step; > - } > -} > - > -static void XRGB8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, > - enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > - > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > - > - while (out_pixel < end) { > - u8 *px = (u8 *)src_pixels; > - *out_pixel = argb_u16_from_u8888(255, px[2], px[1], px[0]); > - out_pixel += 1; > - src_pixels += step; > - } > -} > - > -static void ABGR8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, > - enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > - > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > - > - while (out_pixel < end) { > - u8 *px = (u8 *)src_pixels; > - /* Switch blue and red pixels. */ > - *out_pixel = argb_u16_from_u8888(px[3], px[0], px[1], px[2]); > - out_pixel += 1; > - src_pixels += step; > - } > -} > - > -static void ARGB16161616_read_line(const struct vkms_plane_state *plane, int x_start, > - int y_start, enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > - > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > - > - while (out_pixel < end) { > - u16 *px = (u16 *)src_pixels; > - *out_pixel = argb_u16_from_u16161616(px[3], px[2], px[1], px[0]); > - out_pixel += 1; > - src_pixels += step; > - } > -} > - > -static void XRGB16161616_read_line(const struct vkms_plane_state *plane, int x_start, > - int y_start, enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > - > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > - > - while (out_pixel < end) { > - __le16 *px = (__le16 *)src_pixels; > - *out_pixel = argb_u16_from_le16161616(cpu_to_le16(0xFFFF), px[2], px[1], px[0]); > - out_pixel += 1; > - src_pixels += step; > - } > -} > - > -static void RGB565_read_line(const struct vkms_plane_state *plane, int x_start, > - int y_start, enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - struct pixel_argb_u16 *end = out_pixel + count; > - u8 *src_pixels; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); > - > - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); > - > - while (out_pixel < end) { > - __le16 *px = (__le16 *)src_pixels; > - > - *out_pixel = argb_u16_from_RGB565(px); > - out_pixel += 1; > - src_pixels += step; > - } > -} > +READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) > > /* > * This callback can be used for YUV formats where U and V values are > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet 2025-05-30 14:05 ` [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks Louis Chauvet @ 2025-05-30 14:05 ` Louis Chauvet 2025-06-11 19:55 ` Maíra Canal 2025-05-30 14:05 ` [PATCH v4 3/8] drm/vkms: Add support for ARGB16161616 formats Louis Chauvet ` (5 subsequent siblings) 7 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:05 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet The formats XRGB8888 and ARGB8888 were already supported. Add the support for: - XBGR8888 - RGBX8888 - BGRX8888 - ABGR8888 - RGBA8888 - BGRA8888 Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 19 +++++++++++++++++-- drivers/gpu/drm/vkms/vkms_plane.c | 7 ++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index a9c624081dac..f5c52c3d10a3 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -432,9 +432,14 @@ static void R4_read_line(const struct vkms_plane_state *plane, int x_start, READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0]) +READ_LINE_ARGB8888(XBGR8888_read_line, px, 0xFF, px[0], px[1], px[2]) +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1]) +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3]) READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) +READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) +READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) @@ -644,10 +649,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) switch (format) { case DRM_FORMAT_ARGB8888: return &ARGB8888_read_line; - case DRM_FORMAT_XRGB8888: - return &XRGB8888_read_line; case DRM_FORMAT_ABGR8888: return &ABGR8888_read_line; + case DRM_FORMAT_BGRA8888: + return &BGRA8888_read_line; + case DRM_FORMAT_RGBA8888: + return &RGBA8888_read_line; + case DRM_FORMAT_XRGB8888: + return &XRGB8888_read_line; + case DRM_FORMAT_XBGR8888: + return &XBGR8888_read_line; + case DRM_FORMAT_RGBX8888: + return &RGBX8888_read_line; + case DRM_FORMAT_BGRX8888: + return &BGRX8888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_XRGB16161616: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e3fdd161d0f0..b7f498944c50 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -14,8 +14,13 @@ static const u32 vkms_formats[] = { DRM_FORMAT_ARGB8888, - DRM_FORMAT_XRGB8888, DRM_FORMAT_ABGR8888, + DRM_FORMAT_BGRA8888, + DRM_FORMAT_RGBA8888, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_XBGR8888, + DRM_FORMAT_RGBX8888, + DRM_FORMAT_BGRX8888, DRM_FORMAT_XRGB16161616, DRM_FORMAT_ARGB16161616, DRM_FORMAT_RGB565, -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats 2025-05-30 14:05 ` [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats Louis Chauvet @ 2025-06-11 19:55 ` Maíra Canal 2025-06-13 17:28 ` Louis Chauvet 0 siblings, 1 reply; 21+ messages in thread From: Maíra Canal @ 2025-06-11 19:55 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Hi Louis, On 5/30/25 11:05, Louis Chauvet wrote: > The formats XRGB8888 and ARGB8888 were already supported. > Add the support for: > - XBGR8888 > - RGBX8888 > - BGRX8888 > - ABGR8888 > - RGBA8888 > - BGRA8888 > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> > --- [...] > +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1]) > +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3]) How did you test those two formats? I noticed that IGT (kms_plane tests) doesn't test them. Best Regards, - Maíra > > READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) > READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) > +READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) > +READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) > > READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) > READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) > @@ -644,10 +649,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > switch (format) { > case DRM_FORMAT_ARGB8888: > return &ARGB8888_read_line; > - case DRM_FORMAT_XRGB8888: > - return &XRGB8888_read_line; > case DRM_FORMAT_ABGR8888: > return &ABGR8888_read_line; > + case DRM_FORMAT_BGRA8888: > + return &BGRA8888_read_line; > + case DRM_FORMAT_RGBA8888: > + return &RGBA8888_read_line; > + case DRM_FORMAT_XRGB8888: > + return &XRGB8888_read_line; > + case DRM_FORMAT_XBGR8888: > + return &XBGR8888_read_line; > + case DRM_FORMAT_RGBX8888: > + return &RGBX8888_read_line; > + case DRM_FORMAT_BGRX8888: > + return &BGRX8888_read_line; > case DRM_FORMAT_ARGB16161616: > return &ARGB16161616_read_line; > case DRM_FORMAT_XRGB16161616: > diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c > index e3fdd161d0f0..b7f498944c50 100644 > --- a/drivers/gpu/drm/vkms/vkms_plane.c > +++ b/drivers/gpu/drm/vkms/vkms_plane.c > @@ -14,8 +14,13 @@ > > static const u32 vkms_formats[] = { > DRM_FORMAT_ARGB8888, > - DRM_FORMAT_XRGB8888, > DRM_FORMAT_ABGR8888, > + DRM_FORMAT_BGRA8888, > + DRM_FORMAT_RGBA8888, > + DRM_FORMAT_XRGB8888, > + DRM_FORMAT_XBGR8888, > + DRM_FORMAT_RGBX8888, > + DRM_FORMAT_BGRX8888, > DRM_FORMAT_XRGB16161616, > DRM_FORMAT_ARGB16161616, > DRM_FORMAT_RGB565, > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats 2025-06-11 19:55 ` Maíra Canal @ 2025-06-13 17:28 ` Louis Chauvet 2025-06-21 10:52 ` Maíra Canal 0 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-06-13 17:28 UTC (permalink / raw) To: Maíra Canal, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Le 11/06/2025 à 21:55, Maíra Canal a écrit : > Hi Louis, > > On 5/30/25 11:05, Louis Chauvet wrote: >> The formats XRGB8888 and ARGB8888 were already supported. >> Add the support for: >> - XBGR8888 >> - RGBX8888 >> - BGRX8888 >> - ABGR8888 >> - RGBA8888 >> - BGRA8888 >> >> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> >> --- > > [...] > >> +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1]) >> +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3]) > > How did you test those two formats? I noticed that IGT (kms_plane tests) > doesn't test them. Hi Maíra, Thanks for your review! I wrote this a long time ago, so I don't remember. I was probably greedy and added all the "trivial" formats I was able to do and missed that this format was not tested. For this revision, I just started kms_plane to check if it was happy after the rebase, I did not check the formats one by one. Do you want me to remove those formats? I think it costs nothing to keep them, especially with the new READ_LINE_ARGB8888 macro, but I will comply if you think we should only merge tested formats. Thanks, Louis Chauvet > Best Regards, > - Maíra > >> >> READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) >> READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) >> +READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) >> +READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) >> >> READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) >> READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) >> @@ -644,10 +649,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) >> switch (format) { >> case DRM_FORMAT_ARGB8888: >> return &ARGB8888_read_line; >> - case DRM_FORMAT_XRGB8888: >> - return &XRGB8888_read_line; >> case DRM_FORMAT_ABGR8888: >> return &ABGR8888_read_line; >> + case DRM_FORMAT_BGRA8888: >> + return &BGRA8888_read_line; >> + case DRM_FORMAT_RGBA8888: >> + return &RGBA8888_read_line; >> + case DRM_FORMAT_XRGB8888: >> + return &XRGB8888_read_line; >> + case DRM_FORMAT_XBGR8888: >> + return &XBGR8888_read_line; >> + case DRM_FORMAT_RGBX8888: >> + return &RGBX8888_read_line; >> + case DRM_FORMAT_BGRX8888: >> + return &BGRX8888_read_line; >> case DRM_FORMAT_ARGB16161616: >> return &ARGB16161616_read_line; >> case DRM_FORMAT_XRGB16161616: >> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c >> index e3fdd161d0f0..b7f498944c50 100644 >> --- a/drivers/gpu/drm/vkms/vkms_plane.c >> +++ b/drivers/gpu/drm/vkms/vkms_plane.c >> @@ -14,8 +14,13 @@ >> >> static const u32 vkms_formats[] = { >> DRM_FORMAT_ARGB8888, >> - DRM_FORMAT_XRGB8888, >> DRM_FORMAT_ABGR8888, >> + DRM_FORMAT_BGRA8888, >> + DRM_FORMAT_RGBA8888, >> + DRM_FORMAT_XRGB8888, >> + DRM_FORMAT_XBGR8888, >> + DRM_FORMAT_RGBX8888, >> + DRM_FORMAT_BGRX8888, >> DRM_FORMAT_XRGB16161616, >> DRM_FORMAT_ARGB16161616, >> DRM_FORMAT_RGB565, >> > -- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats 2025-06-13 17:28 ` Louis Chauvet @ 2025-06-21 10:52 ` Maíra Canal 0 siblings, 0 replies; 21+ messages in thread From: Maíra Canal @ 2025-06-21 10:52 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Hi Louis, On 13/06/25 14:28, Louis Chauvet wrote: > > > Le 11/06/2025 à 21:55, Maíra Canal a écrit : >> Hi Louis, >> >> On 5/30/25 11:05, Louis Chauvet wrote: >>> The formats XRGB8888 and ARGB8888 were already supported. >>> Add the support for: >>> - XBGR8888 >>> - RGBX8888 >>> - BGRX8888 >>> - ABGR8888 >>> - RGBA8888 >>> - BGRA8888 >>> >>> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> >>> --- >> >> [...] >> >>> +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1]) >>> +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3]) >> >> How did you test those two formats? I noticed that IGT (kms_plane tests) >> doesn't test them. > > Hi Maíra, > > Thanks for your review! > > I wrote this a long time ago, so I don't remember. I was probably greedy > and added all the "trivial" formats I was able to do and missed that > this format was not tested. > > For this revision, I just started kms_plane to check if it was happy > after the rebase, I did not check the formats one by one. > > Do you want me to remove those formats? I think it costs nothing to keep > them, especially with the new READ_LINE_ARGB8888 macro, but I will > comply if you think we should only merge tested formats. If we don't have a use-case for those formats and we haven't tested them, I can't see a compelling reason to keep them. Otherwise, we might keep untested/unused code around that might stale over time. Best Regards, - Maíra > > Thanks, > Louis Chauvet > >> Best Regards, >> - Maíra >> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 3/8] drm/vkms: Add support for ARGB16161616 formats 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet 2025-05-30 14:05 ` [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks Louis Chauvet 2025-05-30 14:05 ` [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats Louis Chauvet @ 2025-05-30 14:05 ` Louis Chauvet 2025-06-11 19:57 ` Maíra Canal 2025-05-30 14:05 ` [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats Louis Chauvet ` (4 subsequent siblings) 7 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:05 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet The formats XRGB16161616 and ARGB16161616 were already supported. Add the support for: - ABGR16161616 - XBGR16161616 Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index f5c52c3d10a3..95771bff5202 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -442,7 +442,9 @@ READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) +READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) @@ -665,8 +667,12 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &BGRX8888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; + case DRM_FORMAT_ABGR16161616: + return &ABGR16161616_read_line; case DRM_FORMAT_XRGB16161616: return &XRGB16161616_read_line; + case DRM_FORMAT_XBGR16161616: + return &XBGR16161616_read_line; case DRM_FORMAT_RGB565: return &RGB565_read_line; case DRM_FORMAT_NV12: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index b7f498944c50..505847ec8508 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -22,7 +22,9 @@ static const u32 vkms_formats[] = { DRM_FORMAT_RGBX8888, DRM_FORMAT_BGRX8888, DRM_FORMAT_XRGB16161616, + DRM_FORMAT_XBGR16161616, DRM_FORMAT_ARGB16161616, + DRM_FORMAT_ABGR16161616, DRM_FORMAT_RGB565, DRM_FORMAT_NV12, DRM_FORMAT_NV16, -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 3/8] drm/vkms: Add support for ARGB16161616 formats 2025-05-30 14:05 ` [PATCH v4 3/8] drm/vkms: Add support for ARGB16161616 formats Louis Chauvet @ 2025-06-11 19:57 ` Maíra Canal 0 siblings, 0 replies; 21+ messages in thread From: Maíra Canal @ 2025-06-11 19:57 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee On 5/30/25 11:05, Louis Chauvet wrote: > The formats XRGB16161616 and ARGB16161616 were already supported. > Add the support for: > - ABGR16161616 > - XBGR16161616 > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Best Regards, - Maíra > --- > drivers/gpu/drm/vkms/vkms_formats.c | 6 ++++++ > drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ > 2 files changed, 8 insertions(+) > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index f5c52c3d10a3..95771bff5202 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -442,7 +442,9 @@ READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) > READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) > > READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) > +READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) > READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) > +READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) > > READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) > > @@ -665,8 +667,12 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > return &BGRX8888_read_line; > case DRM_FORMAT_ARGB16161616: > return &ARGB16161616_read_line; > + case DRM_FORMAT_ABGR16161616: > + return &ABGR16161616_read_line; > case DRM_FORMAT_XRGB16161616: > return &XRGB16161616_read_line; > + case DRM_FORMAT_XBGR16161616: > + return &XBGR16161616_read_line; > case DRM_FORMAT_RGB565: > return &RGB565_read_line; > case DRM_FORMAT_NV12: > diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c > index b7f498944c50..505847ec8508 100644 > --- a/drivers/gpu/drm/vkms/vkms_plane.c > +++ b/drivers/gpu/drm/vkms/vkms_plane.c > @@ -22,7 +22,9 @@ static const u32 vkms_formats[] = { > DRM_FORMAT_RGBX8888, > DRM_FORMAT_BGRX8888, > DRM_FORMAT_XRGB16161616, > + DRM_FORMAT_XBGR16161616, > DRM_FORMAT_ARGB16161616, > + DRM_FORMAT_ABGR16161616, > DRM_FORMAT_RGB565, > DRM_FORMAT_NV12, > DRM_FORMAT_NV16, > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet ` (2 preceding siblings ...) 2025-05-30 14:05 ` [PATCH v4 3/8] drm/vkms: Add support for ARGB16161616 formats Louis Chauvet @ 2025-05-30 14:05 ` Louis Chauvet 2025-06-11 20:02 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 5/8] drm/vkms: Add support for RGB888 formats Louis Chauvet ` (3 subsequent siblings) 7 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:05 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet The format RGB565 was already supported. Add the support for: - BGR565 Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 95771bff5202..2c5cc8d3a14c 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -259,6 +259,26 @@ static struct pixel_argb_u16 argb_u16_from_grayu16(u16 gray) return argb_u16_from_u16161616(0xFFFF, gray, gray, gray); } +static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) +{ + struct pixel_argb_u16 out_pixel; + + 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)); + + u16 rgb_565 = le16_to_cpu(*pixel); + s64 fp_b = drm_int2fixp((rgb_565 >> 11) & 0x1f); + s64 fp_g = drm_int2fixp((rgb_565 >> 5) & 0x3f); + s64 fp_r = drm_int2fixp(rgb_565 & 0x1f); + + out_pixel.a = (u16)0xffff; + out_pixel.b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); + out_pixel.g = drm_fixp2int_round(drm_fixp_mul(fp_g, fp_g_ratio)); + out_pixel.r = drm_fixp2int_round(drm_fixp_mul(fp_r, fp_rb_ratio)); + + return out_pixel; +} + VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, const struct conversion_matrix *matrix) { @@ -447,6 +467,7 @@ READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[ READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) +READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px) READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) @@ -675,6 +696,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &XBGR16161616_read_line; case DRM_FORMAT_RGB565: return &RGB565_read_line; + case DRM_FORMAT_BGR565: + return &BGR565_read_line; case DRM_FORMAT_NV12: case DRM_FORMAT_NV16: case DRM_FORMAT_NV24: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 505847ec8508..d3783a8f84c2 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -26,6 +26,7 @@ static const u32 vkms_formats[] = { DRM_FORMAT_ARGB16161616, DRM_FORMAT_ABGR16161616, DRM_FORMAT_RGB565, + DRM_FORMAT_BGR565, DRM_FORMAT_NV12, DRM_FORMAT_NV16, DRM_FORMAT_NV24, -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats 2025-05-30 14:05 ` [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats Louis Chauvet @ 2025-06-11 20:02 ` Maíra Canal 2025-06-13 17:38 ` Louis Chauvet 0 siblings, 1 reply; 21+ messages in thread From: Maíra Canal @ 2025-06-11 20:02 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Hi Louis, On 5/30/25 11:05, Louis Chauvet wrote: > The format RGB565 was already supported. Add the support for: > - BGR565 > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> > --- > drivers/gpu/drm/vkms/vkms_formats.c | 23 +++++++++++++++++++++++ > drivers/gpu/drm/vkms/vkms_plane.c | 1 + > 2 files changed, 24 insertions(+) > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 95771bff5202..2c5cc8d3a14c 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -259,6 +259,26 @@ static struct pixel_argb_u16 argb_u16_from_grayu16(u16 gray) > return argb_u16_from_u16161616(0xFFFF, gray, gray, gray); > } > > +static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) > +{ > + struct pixel_argb_u16 out_pixel; > + > + 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)); > + > + u16 rgb_565 = le16_to_cpu(*pixel); > + s64 fp_b = drm_int2fixp((rgb_565 >> 11) & 0x1f); > + s64 fp_g = drm_int2fixp((rgb_565 >> 5) & 0x3f); > + s64 fp_r = drm_int2fixp(rgb_565 & 0x1f); > + > + out_pixel.a = (u16)0xffff; > + out_pixel.b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); > + out_pixel.g = drm_fixp2int_round(drm_fixp_mul(fp_g, fp_g_ratio)); > + out_pixel.r = drm_fixp2int_round(drm_fixp_mul(fp_r, fp_rb_ratio)); > + > + return out_pixel; > +} Instead of writing `argb_u16_from_BGR565()` from scratch, I wonder if we could just call `argb_u16_from_RGB565()` and swap `out_pixel.b` with `out_pixel.r` . For me, it looks like a cleaner approach. Well, even without this suggestion, Reviewed-by: Maíra Canal <mcanal@igalia.com> Best Regards, - Maíra > + > VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, > const struct conversion_matrix *matrix) > { > @@ -447,6 +467,7 @@ READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[ > READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) > > READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) > +READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px) > > READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) > > @@ -675,6 +696,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > return &XBGR16161616_read_line; > case DRM_FORMAT_RGB565: > return &RGB565_read_line; > + case DRM_FORMAT_BGR565: > + return &BGR565_read_line; > case DRM_FORMAT_NV12: > case DRM_FORMAT_NV16: > case DRM_FORMAT_NV24: > diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c > index 505847ec8508..d3783a8f84c2 100644 > --- a/drivers/gpu/drm/vkms/vkms_plane.c > +++ b/drivers/gpu/drm/vkms/vkms_plane.c > @@ -26,6 +26,7 @@ static const u32 vkms_formats[] = { > DRM_FORMAT_ARGB16161616, > DRM_FORMAT_ABGR16161616, > DRM_FORMAT_RGB565, > + DRM_FORMAT_BGR565, > DRM_FORMAT_NV12, > DRM_FORMAT_NV16, > DRM_FORMAT_NV24, > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats 2025-06-11 20:02 ` Maíra Canal @ 2025-06-13 17:38 ` Louis Chauvet 0 siblings, 0 replies; 21+ messages in thread From: Louis Chauvet @ 2025-06-13 17:38 UTC (permalink / raw) To: Maíra Canal, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Le 11/06/2025 à 22:02, Maíra Canal a écrit : > Hi Louis, > > On 5/30/25 11:05, Louis Chauvet wrote: >> The format RGB565 was already supported. Add the support for: >> - BGR565 >> >> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> >> --- >> drivers/gpu/drm/vkms/vkms_formats.c | 23 +++++++++++++++++++++++ >> drivers/gpu/drm/vkms/vkms_plane.c | 1 + >> 2 files changed, 24 insertions(+) >> >> diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c >> index 95771bff5202..2c5cc8d3a14c 100644 >> --- a/drivers/gpu/drm/vkms/vkms_formats.c >> +++ b/drivers/gpu/drm/vkms/vkms_formats.c >> @@ -259,6 +259,26 @@ static struct pixel_argb_u16 argb_u16_from_grayu16(u16 gray) >> return argb_u16_from_u16161616(0xFFFF, gray, gray, gray); >> } >> >> +static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) >> +{ >> + struct pixel_argb_u16 out_pixel; >> + >> + 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)); >> + >> + u16 rgb_565 = le16_to_cpu(*pixel); >> + s64 fp_b = drm_int2fixp((rgb_565 >> 11) & 0x1f); >> + s64 fp_g = drm_int2fixp((rgb_565 >> 5) & 0x3f); >> + s64 fp_r = drm_int2fixp(rgb_565 & 0x1f); >> + >> + out_pixel.a = (u16)0xffff; >> + out_pixel.b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); >> + out_pixel.g = drm_fixp2int_round(drm_fixp_mul(fp_g, fp_g_ratio)); >> + out_pixel.r = drm_fixp2int_round(drm_fixp_mul(fp_r, fp_rb_ratio)); >> + >> + return out_pixel; >> +} > > Instead of writing `argb_u16_from_BGR565()` from scratch, I wonder if > we could just call `argb_u16_from_RGB565()` and swap `out_pixel.b` with > `out_pixel.r` . For me, it looks like a cleaner approach. Thanks for the suggestion, I was looking to avoid code repetition, but I did not think about this kind of "post-processing". I will do for the next revision. > Well, even without this suggestion, > > Reviewed-by: Maíra Canal <mcanal@igalia.com> > > Best Regards, > - Maíra > >> + >> VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, >> const struct conversion_matrix *matrix) >> { >> @@ -447,6 +467,7 @@ READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[ >> READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) >> >> READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) >> +READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px) >> >> READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) >> >> @@ -675,6 +696,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) >> return &XBGR16161616_read_line; >> case DRM_FORMAT_RGB565: >> return &RGB565_read_line; >> + case DRM_FORMAT_BGR565: >> + return &BGR565_read_line; >> case DRM_FORMAT_NV12: >> case DRM_FORMAT_NV16: >> case DRM_FORMAT_NV24: >> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c >> index 505847ec8508..d3783a8f84c2 100644 >> --- a/drivers/gpu/drm/vkms/vkms_plane.c >> +++ b/drivers/gpu/drm/vkms/vkms_plane.c >> @@ -26,6 +26,7 @@ static const u32 vkms_formats[] = { >> DRM_FORMAT_ARGB16161616, >> DRM_FORMAT_ABGR16161616, >> DRM_FORMAT_RGB565, >> + DRM_FORMAT_BGR565, >> DRM_FORMAT_NV12, >> DRM_FORMAT_NV16, >> DRM_FORMAT_NV24, >> > -- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 5/8] drm/vkms: Add support for RGB888 formats 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet ` (3 preceding siblings ...) 2025-05-30 14:05 ` [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats Louis Chauvet @ 2025-05-30 14:06 ` Louis Chauvet 2025-06-11 20:02 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion Louis Chauvet ` (2 subsequent siblings) 7 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:06 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet Add the support for: - RGB888 - BGR888 Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 7 +++++++ drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 2c5cc8d3a14c..5106441f916b 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -461,6 +461,9 @@ READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) +READ_LINE_ARGB8888(RGB888_read_line, px, 0xFF, px[2], px[1], px[0]) +READ_LINE_ARGB8888(BGR888_read_line, px, 0xFF, px[0], px[1], px[2]) + READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) @@ -686,6 +689,10 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &RGBX8888_read_line; case DRM_FORMAT_BGRX8888: return &BGRX8888_read_line; + case DRM_FORMAT_RGB888: + return RGB888_read_line; + case DRM_FORMAT_BGR888: + return BGR888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_ABGR16161616: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index d3783a8f84c2..e82b60fcda4b 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -21,6 +21,8 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XBGR8888, DRM_FORMAT_RGBX8888, DRM_FORMAT_BGRX8888, + DRM_FORMAT_RGB888, + DRM_FORMAT_BGR888, DRM_FORMAT_XRGB16161616, DRM_FORMAT_XBGR16161616, DRM_FORMAT_ARGB16161616, -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 5/8] drm/vkms: Add support for RGB888 formats 2025-05-30 14:06 ` [PATCH v4 5/8] drm/vkms: Add support for RGB888 formats Louis Chauvet @ 2025-06-11 20:02 ` Maíra Canal 0 siblings, 0 replies; 21+ messages in thread From: Maíra Canal @ 2025-06-11 20:02 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee On 5/30/25 11:06, Louis Chauvet wrote: > Add the support for: > - RGB888 > - BGR888 > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Best Regards, - Maíra > --- > drivers/gpu/drm/vkms/vkms_formats.c | 7 +++++++ > drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 2c5cc8d3a14c..5106441f916b 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -461,6 +461,9 @@ READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) > READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) > READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) > > +READ_LINE_ARGB8888(RGB888_read_line, px, 0xFF, px[2], px[1], px[0]) > +READ_LINE_ARGB8888(BGR888_read_line, px, 0xFF, px[0], px[1], px[2]) > + > READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) > READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) > READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) > @@ -686,6 +689,10 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > return &RGBX8888_read_line; > case DRM_FORMAT_BGRX8888: > return &BGRX8888_read_line; > + case DRM_FORMAT_RGB888: > + return RGB888_read_line; > + case DRM_FORMAT_BGR888: > + return BGR888_read_line; > case DRM_FORMAT_ARGB16161616: > return &ARGB16161616_read_line; > case DRM_FORMAT_ABGR16161616: > diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c > index d3783a8f84c2..e82b60fcda4b 100644 > --- a/drivers/gpu/drm/vkms/vkms_plane.c > +++ b/drivers/gpu/drm/vkms/vkms_plane.c > @@ -21,6 +21,8 @@ static const u32 vkms_formats[] = { > DRM_FORMAT_XBGR8888, > DRM_FORMAT_RGBX8888, > DRM_FORMAT_BGRX8888, > + DRM_FORMAT_RGB888, > + DRM_FORMAT_BGR888, > DRM_FORMAT_XRGB16161616, > DRM_FORMAT_XBGR16161616, > DRM_FORMAT_ARGB16161616, > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet ` (4 preceding siblings ...) 2025-05-30 14:06 ` [PATCH v4 5/8] drm/vkms: Add support for RGB888 formats Louis Chauvet @ 2025-05-30 14:06 ` Louis Chauvet 2025-06-11 20:24 ` Maíra Canal 2025-06-11 20:35 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats Louis Chauvet 2025-05-30 14:06 ` [PATCH v4 8/8] drm/vkms: Add P01* formats Louis Chauvet 7 siblings, 2 replies; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:06 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet Some YUV format uses 16 bit values, so change the helper function for conversion to support those new formats. Add support for the YUV format P010 Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/tests/vkms_format_test.c | 103 +++++++++++++------------- drivers/gpu/drm/vkms/vkms_formats.c | 26 ++++--- drivers/gpu/drm/vkms/vkms_formats.h | 4 +- 3 files changed, 68 insertions(+), 65 deletions(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c index 2e1daef94831..272e18a82f9c 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c @@ -23,7 +23,7 @@ MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); * machine endianness */ struct pixel_yuv_u8 { - u8 y, u, v; + u16 y, u, v; }; /* @@ -64,7 +64,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { * in_bits = 16, * in_legal = False, * in_int = True, - * out_bits = 8, + * out_bits = 16, * out_legal = False, * out_int = True) * @@ -76,13 +76,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { .range = DRM_COLOR_YCBCR_FULL_RANGE, .n_colors = 6, .colors = { - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, - { "red", { 0x4c, 0x55, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, - { "green", { 0x96, 0x2c, 0x15 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, - { "blue", { 0x1d, 0xff, 0x6b }, { 0xffff, 0x0000, 0x0000, 0xffff }}, - }, + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x4c8b, 0x54ce, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0x9645, 0x2b33, 0x14d1 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x1d2f, 0xffff, 0x6b2f }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + } }, /* * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, @@ -90,7 +90,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { * in_bits = 16, * in_legal = False, * in_int = True, - * out_bits = 8, + * out_bits = 16, * out_legal = True, * out_int = True) * Tests cases for color conversion generated by converting RGB @@ -101,13 +101,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { .range = DRM_COLOR_YCBCR_LIMITED_RANGE, .n_colors = 6, .colors = { - { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, - { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, - { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, - { "red", { 0x51, 0x5a, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, - { "green", { 0x91, 0x36, 0x22 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, - { "blue", { 0x29, 0xf0, 0x6e }, { 0xffff, 0x0000, 0x0000, 0xffff }}, - }, + { "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x517b, 0x5a34, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0x908e, 0x35cc, 0x2237 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x28f7, 0xf000, 0x6dc9 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + } }, /* * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, @@ -115,7 +115,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { * in_bits = 16, * in_legal = False, * in_int = True, - * out_bits = 8, + * out_bits = 16, * out_legal = False, * out_int = True) * Tests cases for color conversion generated by converting RGB @@ -126,21 +126,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { .range = DRM_COLOR_YCBCR_FULL_RANGE, .n_colors = 6, .colors = { - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, - { "red", { 0x36, 0x63, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, - { "green", { 0xb6, 0x1e, 0x0c }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, - { "blue", { 0x12, 0xff, 0x74 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, - }, + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x366d, 0x62ac, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xb717, 0x1d55, 0x0bbd }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x127c, 0xffff, 0x7443 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + } }, /* * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, * K=colour.WEIGHTS_YCBCR["ITU-R BT.709"], * in_bits = 16, - * int_legal = False, + * in_legal = False, * in_int = True, - * out_bits = 8, + * out_bits = 16, * out_legal = True, * out_int = True) * Tests cases for color conversion generated by converting RGB @@ -151,13 +151,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { .range = DRM_COLOR_YCBCR_LIMITED_RANGE, .n_colors = 6, .colors = { - { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, - { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, - { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, - { "red", { 0x3f, 0x66, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, - { "green", { 0xad, 0x2a, 0x1a }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, - { "blue", { 0x20, 0xf0, 0x76 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, - }, + { "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x3e8f, 0x6656, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xaca1, 0x29aa, 0x1a45 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x1fd0, 0xf000, 0x75bb }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + } }, /* * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, @@ -165,7 +165,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { * in_bits = 16, * in_legal = False, * in_int = True, - * out_bits = 8, + * out_bits = 16, * out_legal = False, * out_int = True) * Tests cases for color conversion generated by converting RGB @@ -176,13 +176,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { .range = DRM_COLOR_YCBCR_FULL_RANGE, .n_colors = 6, .colors = { - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, - { "red", { 0x43, 0x5c, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, - { "green", { 0xad, 0x24, 0x0b }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, - { "blue", { 0x0f, 0xff, 0x76 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, - }, + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x4340, 0x5c41, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xad91, 0x23bf, 0x0a4c }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x0f2e, 0xffff, 0x75b5 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + } }, /* * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, @@ -190,7 +190,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { * in_bits = 16, * in_legal = False, * in_int = True, - * out_bits = 8, + * out_bits = 16, * out_legal = True, * out_int = True) * Tests cases for color conversion generated by converting RGB @@ -201,13 +201,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { .range = DRM_COLOR_YCBCR_LIMITED_RANGE, .n_colors = 6, .colors = { - { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, - { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, - { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, - { "red", { 0x4a, 0x61, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, - { "green", { 0xa4, 0x2f, 0x19 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, - { "blue", { 0x1d, 0xf0, 0x77 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, - }, + { "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x4988, 0x60b9, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xa47b, 0x2f47, 0x1902 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x1cfd, 0xf000, 0x76fe }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + } }, }; @@ -236,7 +236,8 @@ static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test) get_conversion_matrix_to_argb_u16 (DRM_FORMAT_NV12, param->encoding, param->range, &matrix); - argb = argb_u16_from_yuv888(color->yuv.y, color->yuv.u, color->yuv.v, &matrix); + argb = argb_u16_from_yuv161616(&matrix, color->yuv.y, color->yuv.u, + color->yuv.v); KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.a, color->argb.a), 0x1ff, "On the A channel of the color %s expected 0x%04x, got 0x%04x", diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 5106441f916b..261e822e9618 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -279,16 +279,17 @@ static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) return out_pixel; } -VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, - const struct conversion_matrix *matrix) +VISIBLE_IF_KUNIT +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, + u16 y, u16 channel_1, u16 channel_2) { u16 r, g, b; s64 fp_y, fp_channel_1, fp_channel_2; s64 fp_r, fp_g, fp_b; - fp_y = drm_int2fixp(((int)y - matrix->y_offset) * 257); - fp_channel_1 = drm_int2fixp(((int)channel_1 - 128) * 257); - fp_channel_2 = drm_int2fixp(((int)channel_2 - 128) * 257); + fp_y = drm_int2fixp((int)y - matrix->y_offset * 257); + fp_channel_1 = drm_int2fixp((int)channel_1 - 128 * 257); + fp_channel_2 = drm_int2fixp((int)channel_2 - 128 * 257); fp_r = drm_fixp_mul(matrix->matrix[0][0], fp_y) + drm_fixp_mul(matrix->matrix[0][1], fp_channel_1) + @@ -310,7 +311,7 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, return argb_u16_from_u16161616(0xffff, r, g, b); } -EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv161616); /** * READ_LINE() - Generic generator for a read_line function which can be used for format with one @@ -504,8 +505,8 @@ static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; for (int i = 0; i < count; i++) { - *out_pixel = argb_u16_from_yuv888(y_plane[0], uv_plane[0], uv_plane[1], - conversion_matrix); + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, + uv_plane[0] * 257, uv_plane[1] * 257); out_pixel += 1; y_plane += step_y; if ((i + subsampling_offset + 1) % subsampling == 0) @@ -549,8 +550,9 @@ static void planar_yuv_read_line(const struct vkms_plane_state *plane, int x_sta const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; for (int i = 0; i < count; i++) { - *out_pixel = argb_u16_from_yuv888(*y_plane, *channel_1_plane, *channel_2_plane, - conversion_matrix); + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, + *y_plane * 257, *channel_1_plane * 257, + *channel_2_plane * 257); out_pixel += 1; y_plane += step_y; if ((i + subsampling_offset + 1) % subsampling == 0) { @@ -690,9 +692,9 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) case DRM_FORMAT_BGRX8888: return &BGRX8888_read_line; case DRM_FORMAT_RGB888: - return RGB888_read_line; + return &RGB888_read_line; case DRM_FORMAT_BGR888: - return BGR888_read_line; + return &BGR888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_ABGR16161616: diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index b4fe62ab9c65..eeb208cdd6b1 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -14,8 +14,8 @@ void get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encod struct conversion_matrix *matrix); #if IS_ENABLED(CONFIG_KUNIT) -struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, - const struct conversion_matrix *matrix); +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, + u16 y, u16 channel_1, u16 channel_2); #endif #endif /* _VKMS_FORMATS_H_ */ -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion 2025-05-30 14:06 ` [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion Louis Chauvet @ 2025-06-11 20:24 ` Maíra Canal 2025-06-13 18:44 ` Louis Chauvet 2025-06-11 20:35 ` Maíra Canal 1 sibling, 1 reply; 21+ messages in thread From: Maíra Canal @ 2025-06-11 20:24 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Hi Louis, On 5/30/25 11:06, Louis Chauvet wrote: > Some YUV format uses 16 bit values, so change the helper function for > conversion to support those new formats. > > Add support for the YUV format P010 Hum, I don't think this patch added support for P010. > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> > --- > drivers/gpu/drm/vkms/tests/vkms_format_test.c | 103 +++++++++++++------------- > drivers/gpu/drm/vkms/vkms_formats.c | 26 ++++--- > drivers/gpu/drm/vkms/vkms_formats.h | 4 +- > 3 files changed, 68 insertions(+), 65 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c > index 2e1daef94831..272e18a82f9c 100644 > --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c > +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c > @@ -23,7 +23,7 @@ MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); > * machine endianness > */ > struct pixel_yuv_u8 { > - u8 y, u, v; > + u16 y, u, v; > }; > > /* > @@ -64,7 +64,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > * in_bits = 16, > * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = False, > * out_int = True) > * > @@ -76,13 +76,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_FULL_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x4c, 0x55, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0x96, 0x2c, 0x15 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x1d, 0xff, 0x6b }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x4c8b, 0x54ce, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0x9645, 0x2b33, 0x14d1 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x1d2f, 0xffff, 0x6b2f }, { 0xffff, 0x0000, 0x0000, 0xffff }}, Is there an explicit need of those tabs? They make the line length exceed 100 columns. [...] > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 5106441f916b..261e822e9618 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -279,16 +279,17 @@ static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) > return out_pixel; > } > > -VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, > - const struct conversion_matrix *matrix) > +VISIBLE_IF_KUNIT > +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, > + u16 y, u16 channel_1, u16 channel_2) > { > u16 r, g, b; > s64 fp_y, fp_channel_1, fp_channel_2; > s64 fp_r, fp_g, fp_b; > > - fp_y = drm_int2fixp(((int)y - matrix->y_offset) * 257); > - fp_channel_1 = drm_int2fixp(((int)channel_1 - 128) * 257); > - fp_channel_2 = drm_int2fixp(((int)channel_2 - 128) * 257); > + fp_y = drm_int2fixp((int)y - matrix->y_offset * 257); > + fp_channel_1 = drm_int2fixp((int)channel_1 - 128 * 257); > + fp_channel_2 = drm_int2fixp((int)channel_2 - 128 * 257); > > fp_r = drm_fixp_mul(matrix->matrix[0][0], fp_y) + > drm_fixp_mul(matrix->matrix[0][1], fp_channel_1) + > @@ -310,7 +311,7 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, > > return argb_u16_from_u16161616(0xffff, r, g, b); > } > -EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); > +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv161616); > > /** > * READ_LINE() - Generic generator for a read_line function which can be used for format with one > @@ -504,8 +505,8 @@ static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int > const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; > > for (int i = 0; i < count; i++) { > - *out_pixel = argb_u16_from_yuv888(y_plane[0], uv_plane[0], uv_plane[1], > - conversion_matrix); > + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, > + uv_plane[0] * 257, uv_plane[1] * 257); > out_pixel += 1; > y_plane += step_y; > if ((i + subsampling_offset + 1) % subsampling == 0) > @@ -549,8 +550,9 @@ static void planar_yuv_read_line(const struct vkms_plane_state *plane, int x_sta > const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; > > for (int i = 0; i < count; i++) { > - *out_pixel = argb_u16_from_yuv888(*y_plane, *channel_1_plane, *channel_2_plane, > - conversion_matrix); > + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, > + *y_plane * 257, *channel_1_plane * 257, > + *channel_2_plane * 257); > out_pixel += 1; > y_plane += step_y; > if ((i + subsampling_offset + 1) % subsampling == 0) { > @@ -690,9 +692,9 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > case DRM_FORMAT_BGRX8888: > return &BGRX8888_read_line; > case DRM_FORMAT_RGB888: > - return RGB888_read_line; > + return &RGB888_read_line; > case DRM_FORMAT_BGR888: > - return BGR888_read_line; > + return &BGR888_read_line; This should be in the previous patch. Best Regards, - Maíra ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion 2025-06-11 20:24 ` Maíra Canal @ 2025-06-13 18:44 ` Louis Chauvet 0 siblings, 0 replies; 21+ messages in thread From: Louis Chauvet @ 2025-06-13 18:44 UTC (permalink / raw) To: Maíra Canal, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Le 11/06/2025 à 22:24, Maíra Canal a écrit : > Hi Louis, > > On 5/30/25 11:06, Louis Chauvet wrote: >> Some YUV format uses 16 bit values, so change the helper function for >> conversion to support those new formats. >> >> Add support for the YUV format P010 > > Hum, I don't think this patch added support for P010. Obviously not... It only adds support for 16 bits yuv conversions. >> >> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> >> --- >> drivers/gpu/drm/vkms/tests/vkms_format_test.c | 103 +++++++++++++------------- >> drivers/gpu/drm/vkms/vkms_formats.c | 26 ++++--- >> drivers/gpu/drm/vkms/vkms_formats.h | 4 +- >> 3 files changed, 68 insertions(+), 65 deletions(-) >> >> diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c >> index 2e1daef94831..272e18a82f9c 100644 >> --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c >> +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c >> @@ -23,7 +23,7 @@ MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); >> * machine endianness >> */ >> struct pixel_yuv_u8 { >> - u8 y, u, v; >> + u16 y, u, v; >> }; >> >> /* >> @@ -64,7 +64,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { >> * in_bits = 16, >> * in_legal = False, >> * in_int = True, >> - * out_bits = 8, >> + * out_bits = 16, >> * out_legal = False, >> * out_int = True) >> * >> @@ -76,13 +76,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { >> .range = DRM_COLOR_YCBCR_FULL_RANGE, >> .n_colors = 6, >> .colors = { >> - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, >> - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, >> - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, >> - { "red", { 0x4c, 0x55, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, >> - { "green", { 0x96, 0x2c, 0x15 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, >> - { "blue", { 0x1d, 0xff, 0x6b }, { 0xffff, 0x0000, 0x0000, 0xffff }}, >> - }, >> + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, >> + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, >> + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, >> + { "red", { 0x4c8b, 0x54ce, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, >> + { "green", { 0x9645, 0x2b33, 0x14d1 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, >> + { "blue", { 0x1d2f, 0xffff, 0x6b2f }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > > Is there an explicit need of those tabs? They make the line length > exceed 100 columns. No explicit need, I don't know how I missed the checkpatch warning... Fixed for v2. > [...] > >> diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c >> index 5106441f916b..261e822e9618 100644 >> --- a/drivers/gpu/drm/vkms/vkms_formats.c >> +++ b/drivers/gpu/drm/vkms/vkms_formats.c >> @@ -279,16 +279,17 @@ static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) >> return out_pixel; >> } >> >> -VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, >> - const struct conversion_matrix *matrix) >> +VISIBLE_IF_KUNIT >> +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, >> + u16 y, u16 channel_1, u16 channel_2) >> { >> u16 r, g, b; >> s64 fp_y, fp_channel_1, fp_channel_2; >> s64 fp_r, fp_g, fp_b; >> >> - fp_y = drm_int2fixp(((int)y - matrix->y_offset) * 257); >> - fp_channel_1 = drm_int2fixp(((int)channel_1 - 128) * 257); >> - fp_channel_2 = drm_int2fixp(((int)channel_2 - 128) * 257); >> + fp_y = drm_int2fixp((int)y - matrix->y_offset * 257); >> + fp_channel_1 = drm_int2fixp((int)channel_1 - 128 * 257); >> + fp_channel_2 = drm_int2fixp((int)channel_2 - 128 * 257); > > > fp_r = drm_fixp_mul(matrix->matrix[0][0], fp_y) + >> drm_fixp_mul(matrix->matrix[0][1], fp_channel_1) + >> @@ -310,7 +311,7 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, >> >> return argb_u16_from_u16161616(0xffff, r, g, b); >> } >> -EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); >> +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv161616); >> >> /** >> * READ_LINE() - Generic generator for a read_line function which can be used for format with one >> @@ -504,8 +505,8 @@ static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int >> const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; >> >> for (int i = 0; i < count; i++) { >> - *out_pixel = argb_u16_from_yuv888(y_plane[0], uv_plane[0], uv_plane[1], >> - conversion_matrix); >> + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, >> + uv_plane[0] * 257, uv_plane[1] * 257); >> out_pixel += 1; >> y_plane += step_y; >> if ((i + subsampling_offset + 1) % subsampling == 0) >> @@ -549,8 +550,9 @@ static void planar_yuv_read_line(const struct vkms_plane_state *plane, int x_sta >> const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; >> >> for (int i = 0; i < count; i++) { >> - *out_pixel = argb_u16_from_yuv888(*y_plane, *channel_1_plane, *channel_2_plane, >> - conversion_matrix); >> + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, >> + *y_plane * 257, *channel_1_plane * 257, >> + *channel_2_plane * 257); >> out_pixel += 1; >> y_plane += step_y; >> if ((i + subsampling_offset + 1) % subsampling == 0) { >> @@ -690,9 +692,9 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) >> case DRM_FORMAT_BGRX8888: >> return &BGRX8888_read_line; >> case DRM_FORMAT_RGB888: >> - return RGB888_read_line; >> + return &RGB888_read_line; >> case DRM_FORMAT_BGR888: >> - return BGR888_read_line; >> + return &BGR888_read_line; > > This should be in the previous patch. Fixed for v5. > Best Regards, > - Maíra > -- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion 2025-05-30 14:06 ` [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion Louis Chauvet 2025-06-11 20:24 ` Maíra Canal @ 2025-06-11 20:35 ` Maíra Canal 1 sibling, 0 replies; 21+ messages in thread From: Maíra Canal @ 2025-06-11 20:35 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Hi Louis, On 5/30/25 11:06, Louis Chauvet wrote: > Some YUV format uses 16 bit values, so change the helper function for > conversion to support those new formats. > > Add support for the YUV format P010 > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> > --- > drivers/gpu/drm/vkms/tests/vkms_format_test.c | 103 +++++++++++++------------- > drivers/gpu/drm/vkms/vkms_formats.c | 26 ++++--- > drivers/gpu/drm/vkms/vkms_formats.h | 4 +- > 3 files changed, 68 insertions(+), 65 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c > index 2e1daef94831..272e18a82f9c 100644 > --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c > +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c > @@ -23,7 +23,7 @@ MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); > * machine endianness > */ > struct pixel_yuv_u8 { I forgot about this nit. I believe you should changed it to `pixel_yuv_u16` now. Best Regards, - Maíra > - u8 y, u, v; > + u16 y, u, v; > }; > > /* > @@ -64,7 +64,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > * in_bits = 16, > * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = False, > * out_int = True) > * > @@ -76,13 +76,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_FULL_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x4c, 0x55, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0x96, 0x2c, 0x15 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x1d, 0xff, 0x6b }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x4c8b, 0x54ce, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0x9645, 0x2b33, 0x14d1 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x1d2f, 0xffff, 0x6b2f }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > + } > }, > /* > * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, > @@ -90,7 +90,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > * in_bits = 16, > * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = True, > * out_int = True) > * Tests cases for color conversion generated by converting RGB > @@ -101,13 +101,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_LIMITED_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x51, 0x5a, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0x91, 0x36, 0x22 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x29, 0xf0, 0x6e }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x517b, 0x5a34, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0x908e, 0x35cc, 0x2237 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x28f7, 0xf000, 0x6dc9 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > + } > }, > /* > * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, > @@ -115,7 +115,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > * in_bits = 16, > * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = False, > * out_int = True) > * Tests cases for color conversion generated by converting RGB > @@ -126,21 +126,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_FULL_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x36, 0x63, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0xb6, 0x1e, 0x0c }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x12, 0xff, 0x74 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x366d, 0x62ac, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0xb717, 0x1d55, 0x0bbd }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x127c, 0xffff, 0x7443 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > + } > }, > /* > * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, > * K=colour.WEIGHTS_YCBCR["ITU-R BT.709"], > * in_bits = 16, > - * int_legal = False, > + * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = True, > * out_int = True) > * Tests cases for color conversion generated by converting RGB > @@ -151,13 +151,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_LIMITED_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x3f, 0x66, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0xad, 0x2a, 0x1a }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x20, 0xf0, 0x76 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x3e8f, 0x6656, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0xaca1, 0x29aa, 0x1a45 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x1fd0, 0xf000, 0x75bb }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > + } > }, > /* > * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, > @@ -165,7 +165,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > * in_bits = 16, > * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = False, > * out_int = True) > * Tests cases for color conversion generated by converting RGB > @@ -176,13 +176,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_FULL_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x43, 0x5c, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0xad, 0x24, 0x0b }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x0f, 0xff, 0x76 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x4340, 0x5c41, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0xad91, 0x23bf, 0x0a4c }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x0f2e, 0xffff, 0x75b5 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > + } > }, > /* > * colour.RGB_to_YCbCr(<rgb color in 16 bit form>, > @@ -190,7 +190,7 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > * in_bits = 16, > * in_legal = False, > * in_int = True, > - * out_bits = 8, > + * out_bits = 16, > * out_legal = True, > * out_int = True) > * Tests cases for color conversion generated by converting RGB > @@ -201,13 +201,13 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > .range = DRM_COLOR_YCBCR_LIMITED_RANGE, > .n_colors = 6, > .colors = { > - { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > - { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > - { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > - { "red", { 0x4a, 0x61, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > - { "green", { 0xa4, 0x2f, 0x19 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > - { "blue", { 0x1d, 0xf0, 0x77 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > - }, > + { "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > + { "gray", { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > + { "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > + { "red", { 0x4988, 0x60b9, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > + { "green", { 0xa47b, 0x2f47, 0x1902 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > + { "blue", { 0x1cfd, 0xf000, 0x76fe }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > + } > }, > }; > > @@ -236,7 +236,8 @@ static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test) > get_conversion_matrix_to_argb_u16 > (DRM_FORMAT_NV12, param->encoding, param->range, &matrix); > > - argb = argb_u16_from_yuv888(color->yuv.y, color->yuv.u, color->yuv.v, &matrix); > + argb = argb_u16_from_yuv161616(&matrix, color->yuv.y, color->yuv.u, > + color->yuv.v); > > KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.a, color->argb.a), 0x1ff, > "On the A channel of the color %s expected 0x%04x, got 0x%04x", > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 5106441f916b..261e822e9618 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -279,16 +279,17 @@ static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) > return out_pixel; > } > > -VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, > - const struct conversion_matrix *matrix) > +VISIBLE_IF_KUNIT > +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, > + u16 y, u16 channel_1, u16 channel_2) > { > u16 r, g, b; > s64 fp_y, fp_channel_1, fp_channel_2; > s64 fp_r, fp_g, fp_b; > > - fp_y = drm_int2fixp(((int)y - matrix->y_offset) * 257); > - fp_channel_1 = drm_int2fixp(((int)channel_1 - 128) * 257); > - fp_channel_2 = drm_int2fixp(((int)channel_2 - 128) * 257); > + fp_y = drm_int2fixp((int)y - matrix->y_offset * 257); > + fp_channel_1 = drm_int2fixp((int)channel_1 - 128 * 257); > + fp_channel_2 = drm_int2fixp((int)channel_2 - 128 * 257); > > fp_r = drm_fixp_mul(matrix->matrix[0][0], fp_y) + > drm_fixp_mul(matrix->matrix[0][1], fp_channel_1) + > @@ -310,7 +311,7 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, > > return argb_u16_from_u16161616(0xffff, r, g, b); > } > -EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); > +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv161616); > > /** > * READ_LINE() - Generic generator for a read_line function which can be used for format with one > @@ -504,8 +505,8 @@ static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int > const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; > > for (int i = 0; i < count; i++) { > - *out_pixel = argb_u16_from_yuv888(y_plane[0], uv_plane[0], uv_plane[1], > - conversion_matrix); > + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, > + uv_plane[0] * 257, uv_plane[1] * 257); > out_pixel += 1; > y_plane += step_y; > if ((i + subsampling_offset + 1) % subsampling == 0) > @@ -549,8 +550,9 @@ static void planar_yuv_read_line(const struct vkms_plane_state *plane, int x_sta > const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; > > for (int i = 0; i < count; i++) { > - *out_pixel = argb_u16_from_yuv888(*y_plane, *channel_1_plane, *channel_2_plane, > - conversion_matrix); > + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, > + *y_plane * 257, *channel_1_plane * 257, > + *channel_2_plane * 257); > out_pixel += 1; > y_plane += step_y; > if ((i + subsampling_offset + 1) % subsampling == 0) { > @@ -690,9 +692,9 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > case DRM_FORMAT_BGRX8888: > return &BGRX8888_read_line; > case DRM_FORMAT_RGB888: > - return RGB888_read_line; > + return &RGB888_read_line; > case DRM_FORMAT_BGR888: > - return BGR888_read_line; > + return &BGR888_read_line; > case DRM_FORMAT_ARGB16161616: > return &ARGB16161616_read_line; > case DRM_FORMAT_ABGR16161616: > diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h > index b4fe62ab9c65..eeb208cdd6b1 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.h > +++ b/drivers/gpu/drm/vkms/vkms_formats.h > @@ -14,8 +14,8 @@ void get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encod > struct conversion_matrix *matrix); > > #if IS_ENABLED(CONFIG_KUNIT) > -struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, > - const struct conversion_matrix *matrix); > +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, > + u16 y, u16 channel_1, u16 channel_2); > #endif > > #endif /* _VKMS_FORMATS_H_ */ > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet ` (5 preceding siblings ...) 2025-05-30 14:06 ` [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion Louis Chauvet @ 2025-05-30 14:06 ` Louis Chauvet 2025-06-11 20:32 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 8/8] drm/vkms: Add P01* formats Louis Chauvet 7 siblings, 1 reply; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:06 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet The callback functions for line conversion are almost identical for semi-planar formats. The generic READ_LINE_YUV_SEMIPLANAR macro generate all the required boilerplate to process a line from a semi-planar format. Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 75 ++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 261e822e9618..8ecd75d063f4 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -485,35 +485,56 @@ READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) * - Convert YUV and YVU with the same function (a column swap is needed when setting up * plane->conversion_matrix) */ -static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - u8 *y_plane; - u8 *uv_plane; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, - &y_plane); - packed_pixels_addr_1x1(plane->frame_info, - x_start / plane->frame_info->fb->format->hsub, - y_start / plane->frame_info->fb->format->vsub, 1, - &uv_plane); - int step_y = get_block_step_bytes(plane->frame_info->fb, direction, 0); - int step_uv = get_block_step_bytes(plane->frame_info->fb, direction, 1); - int subsampling = get_subsampling(plane->frame_info->fb->format, direction); - int subsampling_offset = get_subsampling_offset(direction, x_start, y_start); - const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; - for (int i = 0; i < count; i++) { - *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, - uv_plane[0] * 257, uv_plane[1] * 257); - out_pixel += 1; - y_plane += step_y; - if ((i + subsampling_offset + 1) % subsampling == 0) - uv_plane += step_uv; - } +/** + * READ_LINE_YUV_SEMIPLANAR() - Generic generator for a read_line function which can be used for yuv + * formats with two planes and block_w == block_h == 1. + * + * @function_name: Function name to generate + * @pixel_1_name: temporary pixel name for the first plane used in the @__VA_ARGS__ parameters + * @pixel_2_name: temporary pixel name for the second plane used in the @__VA_ARGS__ parameters + * @pixel_1_type: Used to specify the type you want to cast the pixel pointer on the plane 1 + * @pixel_2_type: Used to specify the type you want to cast the pixel pointer on the plane 2 + * @callback: Callback to call for each pixels. This function should take + * (struct conversion_matrix*, @__VA_ARGS__) as parameter and return a pixel_argb_u16 + * @__VA_ARGS__: Argument to pass inside the callback. You can use @pixel_1_name and @pixel_2_name + * to access current pixel values + */ +#define READ_LINE_YUV_SEMIPLANAR(function_name, pixel_1_name, pixel_2_name, pixel_1_type, \ + pixel_2_type, callback, ...) \ +static void function_name(const struct vkms_plane_state *plane, int x_start, \ + int y_start, enum pixel_read_direction direction, int count, \ + struct pixel_argb_u16 out_pixel[]) \ +{ \ + u8 *plane_1; \ + u8 *plane_2; \ + \ + packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, \ + &plane_1); \ + packed_pixels_addr_1x1(plane->frame_info, \ + x_start / plane->frame_info->fb->format->hsub, \ + y_start / plane->frame_info->fb->format->vsub, 1, \ + &plane_2); \ + int step_1 = get_block_step_bytes(plane->frame_info->fb, direction, 0); \ + int step_2 = get_block_step_bytes(plane->frame_info->fb, direction, 1); \ + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); \ + int subsampling_offset = get_subsampling_offset(direction, x_start, y_start); \ + const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; \ + \ + for (int i = 0; i < count; i++) { \ + pixel_1_type *(pixel_1_name) = (pixel_1_type *)plane_1; \ + pixel_2_type *(pixel_2_name) = (pixel_2_type *)plane_2; \ + *out_pixel = (callback)(conversion_matrix, __VA_ARGS__); \ + out_pixel += 1; \ + plane_1 += step_1; \ + if ((i + subsampling_offset + 1) % subsampling == 0) \ + plane_2 += step_2; \ + } \ } +READ_LINE_YUV_SEMIPLANAR(YUV888_semiplanar_read_line, y, uv, u8, u8, argb_u16_from_yuv161616, + y[0] * 257, uv[0] * 257, uv[1] * 257) + /* * This callback can be used for YUV format where each color component is * stored in a different plane (often called planar formats). It will @@ -713,7 +734,7 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) case DRM_FORMAT_NV21: case DRM_FORMAT_NV61: case DRM_FORMAT_NV42: - return &semi_planar_yuv_read_line; + return &YUV888_semiplanar_read_line; case DRM_FORMAT_YUV420: case DRM_FORMAT_YUV422: case DRM_FORMAT_YUV444: -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats 2025-05-30 14:06 ` [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats Louis Chauvet @ 2025-06-11 20:32 ` Maíra Canal 0 siblings, 0 replies; 21+ messages in thread From: Maíra Canal @ 2025-06-11 20:32 UTC (permalink / raw) To: Louis Chauvet, Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee Hi Louis, On 5/30/25 11:06, Louis Chauvet wrote: > The callback functions for line conversion are almost identical for > semi-planar formats. The generic READ_LINE_YUV_SEMIPLANAR macro > generate all the required boilerplate to process a line from a > semi-planar format. > > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> > --- > drivers/gpu/drm/vkms/vkms_formats.c | 75 ++++++++++++++++++++++++------------- > 1 file changed, 48 insertions(+), 27 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 261e822e9618..8ecd75d063f4 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -485,35 +485,56 @@ READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) > * - Convert YUV and YVU with the same function (a column swap is needed when setting up > * plane->conversion_matrix) > */ > -static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int x_start, > - int y_start, enum pixel_read_direction direction, int count, > - struct pixel_argb_u16 out_pixel[]) > -{ > - u8 *y_plane; > - u8 *uv_plane; > - > - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, > - &y_plane); > - packed_pixels_addr_1x1(plane->frame_info, > - x_start / plane->frame_info->fb->format->hsub, > - y_start / plane->frame_info->fb->format->vsub, 1, > - &uv_plane); > - int step_y = get_block_step_bytes(plane->frame_info->fb, direction, 0); > - int step_uv = get_block_step_bytes(plane->frame_info->fb, direction, 1); > - int subsampling = get_subsampling(plane->frame_info->fb->format, direction); > - int subsampling_offset = get_subsampling_offset(direction, x_start, y_start); > - const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; > > - for (int i = 0; i < count; i++) { > - *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, > - uv_plane[0] * 257, uv_plane[1] * 257); > - out_pixel += 1; > - y_plane += step_y; > - if ((i + subsampling_offset + 1) % subsampling == 0) > - uv_plane += step_uv; > - } > +/** > + * READ_LINE_YUV_SEMIPLANAR() - Generic generator for a read_line function which can be used for yuv > + * formats with two planes and block_w == block_h == 1. > + * > + * @function_name: Function name to generate > + * @pixel_1_name: temporary pixel name for the first plane used in the @__VA_ARGS__ parameters s/temporary/Temporary > + * @pixel_2_name: temporary pixel name for the second plane used in the @__VA_ARGS__ parameters > + * @pixel_1_type: Used to specify the type you want to cast the pixel pointer on the plane 1 > + * @pixel_2_type: Used to specify the type you want to cast the pixel pointer on the plane 2 > + * @callback: Callback to call for each pixels. This function should take > + * (struct conversion_matrix*, @__VA_ARGS__) as parameter and return a pixel_argb_u16 s/struct conversion_matrix*/struct conversion_matrix * > + * @__VA_ARGS__: Argument to pass inside the callback. You can use @pixel_1_name and @pixel_2_name > + * to access current pixel values > + */ > +#define READ_LINE_YUV_SEMIPLANAR(function_name, pixel_1_name, pixel_2_name, pixel_1_type, \ > + pixel_2_type, callback, ...) \ > +static void function_name(const struct vkms_plane_state *plane, int x_start, \ > + int y_start, enum pixel_read_direction direction, int count, \ > + struct pixel_argb_u16 out_pixel[]) \ > +{ \ > + u8 *plane_1; \ > + u8 *plane_2; \ For now, how do you feel about keeping it as `y_plane` and `uv_plane`. For me, it has more semantic information and eases the understanding. With those nits, Reviewed-by: Maíra Canal <mcanal@igalia.com> Best Regards, - Maíra > + \ > + packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, \ > + &plane_1); \ > + packed_pixels_addr_1x1(plane->frame_info, \ > + x_start / plane->frame_info->fb->format->hsub, \ > + y_start / plane->frame_info->fb->format->vsub, 1, \ > + &plane_2); \ > + int step_1 = get_block_step_bytes(plane->frame_info->fb, direction, 0); \ > + int step_2 = get_block_step_bytes(plane->frame_info->fb, direction, 1); \ > + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); \ > + int subsampling_offset = get_subsampling_offset(direction, x_start, y_start); \ > + const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; \ > + \ > + for (int i = 0; i < count; i++) { \ > + pixel_1_type *(pixel_1_name) = (pixel_1_type *)plane_1; \ > + pixel_2_type *(pixel_2_name) = (pixel_2_type *)plane_2; \ > + *out_pixel = (callback)(conversion_matrix, __VA_ARGS__); \ > + out_pixel += 1; \ > + plane_1 += step_1; \ > + if ((i + subsampling_offset + 1) % subsampling == 0) \ > + plane_2 += step_2; \ > + } \ > } > > +READ_LINE_YUV_SEMIPLANAR(YUV888_semiplanar_read_line, y, uv, u8, u8, argb_u16_from_yuv161616, > + y[0] * 257, uv[0] * 257, uv[1] * 257) > + > /* > * This callback can be used for YUV format where each color component is > * stored in a different plane (often called planar formats). It will > @@ -713,7 +734,7 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) > case DRM_FORMAT_NV21: > case DRM_FORMAT_NV61: > case DRM_FORMAT_NV42: > - return &semi_planar_yuv_read_line; > + return &YUV888_semiplanar_read_line; > case DRM_FORMAT_YUV420: > case DRM_FORMAT_YUV422: > case DRM_FORMAT_YUV444: > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 8/8] drm/vkms: Add P01* formats 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet ` (6 preceding siblings ...) 2025-05-30 14:06 ` [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats Louis Chauvet @ 2025-05-30 14:06 ` Louis Chauvet 7 siblings, 0 replies; 21+ messages in thread From: Louis Chauvet @ 2025-05-30 14:06 UTC (permalink / raw) To: Melissa Wen, Maíra Canal, Haneen Mohammed, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rodrigo Siqueira, Simona Vetter Cc: dri-devel, arthurgrillo, linux-kernel, jeremie.dautheribes, miquel.raynal, thomas.petazzoni, seanpaul, nicolejadeyee, Louis Chauvet The formats NV 12/16/24/21/61/42 were already supported. Add support for: - P010 - P012 - P016 Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_formats.c | 7 ++++++- drivers/gpu/drm/vkms/vkms_plane.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 8ecd75d063f4..171ef4d8f19d 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -534,7 +534,8 @@ static void function_name(const struct vkms_plane_state *plane, int x_start, \ READ_LINE_YUV_SEMIPLANAR(YUV888_semiplanar_read_line, y, uv, u8, u8, argb_u16_from_yuv161616, y[0] * 257, uv[0] * 257, uv[1] * 257) - +READ_LINE_YUV_SEMIPLANAR(YUV161616_semiplanar_read_line, y, uv, u16, u16, argb_u16_from_yuv161616, + y[0], uv[0], uv[1]) /* * This callback can be used for YUV format where each color component is * stored in a different plane (often called planar formats). It will @@ -735,6 +736,10 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) case DRM_FORMAT_NV61: case DRM_FORMAT_NV42: return &YUV888_semiplanar_read_line; + case DRM_FORMAT_P010: + case DRM_FORMAT_P012: + case DRM_FORMAT_P016: + return &YUV161616_semiplanar_read_line; case DRM_FORMAT_YUV420: case DRM_FORMAT_YUV422: case DRM_FORMAT_YUV444: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e82b60fcda4b..4ab0fab4dd09 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -41,6 +41,9 @@ static const u32 vkms_formats[] = { DRM_FORMAT_YVU420, DRM_FORMAT_YVU422, DRM_FORMAT_YVU444, + DRM_FORMAT_P010, + DRM_FORMAT_P012, + DRM_FORMAT_P016, DRM_FORMAT_R1, DRM_FORMAT_R2, DRM_FORMAT_R4, -- 2.49.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-06-21 10:52 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-30 14:05 [PATCH v4 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet 2025-05-30 14:05 ` [PATCH v4 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks Louis Chauvet 2025-06-11 19:51 ` Maíra Canal 2025-05-30 14:05 ` [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats Louis Chauvet 2025-06-11 19:55 ` Maíra Canal 2025-06-13 17:28 ` Louis Chauvet 2025-06-21 10:52 ` Maíra Canal 2025-05-30 14:05 ` [PATCH v4 3/8] drm/vkms: Add support for ARGB16161616 formats Louis Chauvet 2025-06-11 19:57 ` Maíra Canal 2025-05-30 14:05 ` [PATCH v4 4/8] drm/vkms: Add support for RGB565 formats Louis Chauvet 2025-06-11 20:02 ` Maíra Canal 2025-06-13 17:38 ` Louis Chauvet 2025-05-30 14:06 ` [PATCH v4 5/8] drm/vkms: Add support for RGB888 formats Louis Chauvet 2025-06-11 20:02 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion Louis Chauvet 2025-06-11 20:24 ` Maíra Canal 2025-06-13 18:44 ` Louis Chauvet 2025-06-11 20:35 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats Louis Chauvet 2025-06-11 20:32 ` Maíra Canal 2025-05-30 14:06 ` [PATCH v4 8/8] drm/vkms: Add P01* formats Louis Chauvet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).