mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maíra Canal" <mcanal@igalia.com>
To: Louis Chauvet <louis.chauvet@bootlin.com>,
	Melissa Wen <melissa.srw@gmail.com>,
	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 v5 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion
Date: Fri, 27 Jun 2025 10:38:34 -0300	[thread overview]
Message-ID: <0f6d0cd2-8b1f-4401-87ef-9bc6f9eff720@igalia.com> (raw)
In-Reply-To: <20250627-b4-new-color-formats-v5-6-94452f119c72@bootlin.com>

Hi Louis,

On 27/06/25 06:12, Louis Chauvet wrote:
> Some YUV format uses 16 bit values, so change the helper function for
> conversion to support those new formats.
> 
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>> ---
>   drivers/gpu/drm/vkms/tests/vkms_format_test.c | 139 +++++++++++++-------------
>   drivers/gpu/drm/vkms/vkms_formats.c           |  22 ++--
>   drivers/gpu/drm/vkms/vkms_formats.h           |   4 +-
>   3 files changed, 84 insertions(+), 81 deletions(-)
> 

[...]

>   
>   /*
> - * vkms_format_test_yuv_u8_to_argb_u16 - Testing the conversion between YUV
> + * vkms_format_test_yuv_u16_to_argb_u16 - Testing the conversion between YUV
>    * colors to ARGB colors in VKMS
>    *
>    * This test will use the functions get_conversion_matrix_to_argb_u16 and
>    * argb_u16_from_yuv888 to convert YUV colors (stored in

s/argb_u16_from_yuv888/argb_u16_from_yuv161616

> - * yuv_u8_to_argb_u16_cases) into ARGB colors.
> + * yuv_u16_to_argb_u16_cases) into ARGB colors.
>    *
>    * The conversion between YUV and RGB is not totally reversible, so there may be
>    * some difference between the expected value and the result.
>    * In addition, there may be some rounding error as the input color is 8 bits

 From what I understand the input color now is 16 bits as well. Please,
update the comment.

Sorry, I missed those nits in the first review. Apart from that,

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra

>    * and output color is 16 bits.
>    */
> -static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test)
> +static void vkms_format_test_yuv_u16_to_argb_u16(struct kunit *test)
>   {
> -	const struct yuv_u8_to_argb_u16_case *param = test->param_value;
> +	const struct yuv_u16_to_argb_u16_case *param = test->param_value;
>   	struct pixel_argb_u16 argb;
>   
>   	for (size_t i = 0; i < param->n_colors; i++) {
> @@ -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",
> @@ -253,19 +254,19 @@ static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test)
>   	}
>   }
>   
> -static void vkms_format_test_yuv_u8_to_argb_u16_case_desc(struct yuv_u8_to_argb_u16_case *t,
> -							  char *desc)
> +static void vkms_format_test_yuv_u16_to_argb_u16_case_desc(struct yuv_u16_to_argb_u16_case *t,
> +							   char *desc)
>   {
>   	snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s - %s",
>   		 drm_get_color_encoding_name(t->encoding), drm_get_color_range_name(t->range));
>   }
>   
> -KUNIT_ARRAY_PARAM(yuv_u8_to_argb_u16, yuv_u8_to_argb_u16_cases,
> -		  vkms_format_test_yuv_u8_to_argb_u16_case_desc
> +KUNIT_ARRAY_PARAM(yuv_u16_to_argb_u16, yuv_u16_to_argb_u16_cases,
> +		  vkms_format_test_yuv_u16_to_argb_u16_case_desc
>   );
>   
>   static struct kunit_case vkms_format_test_cases[] = {
> -	KUNIT_CASE_PARAM(vkms_format_test_yuv_u8_to_argb_u16, yuv_u8_to_argb_u16_gen_params),
> +	KUNIT_CASE_PARAM(vkms_format_test_yuv_u16_to_argb_u16, yuv_u16_to_argb_u16_gen_params),
>   	{}
>   };
>   
> diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
> index 5b50e8622521..03eb73f4caef 100644
> --- a/drivers/gpu/drm/vkms/vkms_formats.c
> +++ b/drivers/gpu/drm/vkms/vkms_formats.c
> @@ -269,16 +269,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) +
> @@ -300,7 +301,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
> @@ -492,8 +493,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)
> @@ -537,8 +538,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) {
> 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_ */
> 


  reply	other threads:[~2025-06-27 13:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27  9:12 [PATCH v5 0/8] drm/vkms: Add support for multiple plane formats Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 2/8] drm/vkms: Add support for ARGB8888 formats Louis Chauvet
2025-06-27 13:17   ` Maíra Canal
2025-06-27 13:21     ` Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 3/8] drm/vkms: Add support for ARGB16161616 formats Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 4/8] drm/vkms: Add support for RGB565 formats Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 5/8] drm/vkms: Add support for RGB888 formats Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion Louis Chauvet
2025-06-27 13:38   ` Maíra Canal [this message]
2025-06-27  9:12 ` [PATCH v5 7/8] drm/vkms: Create helper macro for YUV formats Louis Chauvet
2025-06-27  9:12 ` [PATCH v5 8/8] drm/vkms: Add P01* formats Louis Chauvet
2025-06-27 13:21   ` Maíra Canal

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=0f6d0cd2-8b1f-4401-87ef-9bc6f9eff720@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=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®