From: "Maíra Canal" <mcanal@igalia.com>
To: "Louis Chauvet" <louis.chauvet@bootlin.com>,
"Melissa Wen" <melissa.srw@gmail.com>,
"Maíra Canal" <mairacanal@riseup.net>,
"Haneen Mohammed" <hamohammed.sa@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Rodrigo Siqueira" <siqueira@igalia.com>,
"Simona Vetter" <simona.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net,
linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com,
miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com,
seanpaul@google.com, nicolejadeyee@google.com
Subject: Re: [PATCH v4 7/8] drm/vkms: Create helper macro for YUV formats
Date: Wed, 11 Jun 2025 17:32:25 -0300 [thread overview]
Message-ID: <87cc0c8e-5c25-49d1-88a5-52cc263c7c5f@igalia.com> (raw)
In-Reply-To: <20250530-b4-new-color-formats-v4-7-ef5f9f48376c@bootlin.com>
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:
>
next prev parent reply other threads:[~2025-06-11 20:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-05-30 14:06 ` [PATCH v4 8/8] drm/vkms: Add P01* formats Louis Chauvet
2026-08-13 15:19 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cc0c8e-5c25-49d1-88a5-52cc263c7c5f@igalia.com \
--to=mcanal@igalia.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=jeremie.dautheribes@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=melissa.srw@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=nicolejadeyee@google.com \
--cc=seanpaul@google.com \
--cc=simona.vetter@ffwll.ch \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®