From: Alex Hung <alex.hung@amd.com>
To: Harry Wentland <harry.wentland@amd.com>, igt-dev@lists.freedesktop.org
Subject: Re: [PATCH v3 07/12] lib/igt_color: Add YUV pixel reading support
Date: Sat, 25 Jul 2026 01:10:00 -0600 [thread overview]
Message-ID: <acb18562-50df-4111-8a04-1ec88493d216@amd.com> (raw)
In-Reply-To: <20260623175737.171142-8-harry.wentland@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
On 6/23/26 11:57, Harry Wentland wrote:
> Add functions to read YUV pixel values from framebuffers. Supports
> NV12 and P010 formats with proper handling of:
> - Multi-planar Y/UV data layout
> - 8-bit and 10-bit sample depths
> - Chroma subsampling
>
> This provides the foundation for YUV color transformation testing.
>
> Assisted-by: Claude:claude-sonnet-4-5
> Signed-off-by: Harry Wentland <harry.wentland@amd.com>
> ---
> lib/igt_color.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 72 insertions(+)
>
> diff --git a/lib/igt_color.c b/lib/igt_color.c
> index 8c405275acf8..a451f5642bac 100644
> --- a/lib/igt_color.c
> +++ b/lib/igt_color.c
> @@ -259,6 +259,78 @@ void igt_color_multiply_inv_125(igt_pixel_t *pixel)
> igt_color_multiply(pixel, 1 / 125.0f);
> }
>
> +/**
> + * igt_color_extract_yuv_pixel - Extract raw Y, U, V values from YUV buffer
> + * @fb: framebuffer
> + * @x: x coordinate
> + * @y: y coordinate
> + * @y_plane: pointer to Y plane
> + * @uv_plane: pointer to UV plane
> + * @y_stride: stride of Y plane
> + * @uv_stride: stride of UV plane
> + * @out_y: output Y value (raw, not normalized)
> + * @out_u: output U value (raw, not normalized)
> + * @out_v: output V value (raw, not normalized)
> + *
> + * Extracts raw Y, U, V component values from a YUV framebuffer at the given
> + * coordinates. Handles 4:2:0 subsampling for UV components. Values are raw
> + * (not normalized) and format-specific.
> + */
> +static void
> +igt_color_extract_yuv_pixel(igt_fb_t *fb, int x, int y,
> + uint8_t *y_plane, uint8_t *uv_plane,
> + int y_stride, int uv_stride,
> + uint32_t *out_y, uint32_t *out_u, uint32_t *out_v)
> +{
> + if (fb->drm_format == DRM_FORMAT_NV12) {
> + *out_y = y_plane[y * y_stride + x];
> + *out_u = uv_plane[(y / 2) * uv_stride + (x / 2) * 2 + 0];
> + *out_v = uv_plane[(y / 2) * uv_stride + (x / 2) * 2 + 1];
> + } else if (fb->drm_format == DRM_FORMAT_P010) {
> + uint16_t *y16 = (uint16_t *)y_plane;
> + uint16_t *uv16 = (uint16_t *)uv_plane;
> +
> + *out_y = y16[y * (y_stride / 2) + x];
> + *out_u = uv16[(y / 2) * (uv_stride / 2) + (x / 2) * 2 + 0];
> + *out_v = uv16[(y / 2) * (uv_stride / 2) + (x / 2) * 2 + 1];
> + } else {
> + igt_skip("YUV pixel format support not implemented");
> + }
> +}
> +
> +/**
> + * igt_color_yuv_to_pixel - Convert raw Y, U, V values to normalized pixel
> + * @drm_format: YUV format (NV12 or P010)
> + * @raw_y: raw Y value
> + * @raw_u: raw U value
> + * @raw_v: raw V value
> + * @pixel: output pixel structure
> + *
> + * Converts raw Y, U, V component values to a normalized igt_pixel_t structure.
> + * For NV12 (8-bit), normalizes by 255. For P010 (10-bit in upper bits),
> + * shifts and normalizes by 1023.
> + *
> + * Result: pixel->r = normalized Y, pixel->g = normalized U, pixel->b = normalized V
> + */
> +static void
> +igt_color_yuv_to_pixel(uint32_t drm_format, uint32_t raw_y, uint32_t raw_u,
> + uint32_t raw_v, igt_pixel_t *pixel)
> +{
> + if (drm_format == DRM_FORMAT_NV12) {
> + /* Normalize 8-bit values to [0.0, 1.0] */
> + pixel->r = raw_y / 255.0f;
> + pixel->g = raw_u / 255.0f;
> + pixel->b = raw_v / 255.0f;
> + } else if (drm_format == DRM_FORMAT_P010) {
> + /* P010 uses upper 10 bits of 16-bit value */
> + pixel->r = (raw_y >> 6) / 1023.0f;
> + pixel->g = (raw_u >> 6) / 1023.0f;
> + pixel->b = (raw_v >> 6) / 1023.0f;
> + } else {
> + igt_skip("YUV pixel format support not implemented");
> + }
> +}
> +
> static int
> igt_get_lut3d_index_blue_fast(int r, int g, int b, long dim, int components)
> {
next prev parent reply other threads:[~2026-07-25 7:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 17:57 [PATCH v3 00/12] YUV Conversion Colorop tests Harry Wentland
2026-06-23 17:57 ` [PATCH v3 01/12] include/drm-uapi: Add DRM_COLOROP_FIXED_MATRIX Harry Wentland
2026-07-25 6:52 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 02/12] lib/igt_kms: Add IGT_COLOROP_FIXED_MATRIX property Harry Wentland
2026-07-25 6:56 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 03/12] tests/kms_colorop_helper: Add Fixed Matrix colorop infrastructure Harry Wentland
2026-07-25 6:56 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 04/12] tests/kms_colorop_helper: Add helpers to get encoding/range from FIXED_MATRIX name Harry Wentland
2026-07-25 7:04 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 05/12] lib/igt_fb: Add YUV color pattern framebuffer support Harry Wentland
2026-07-25 7:05 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 06/12] lib/igt_color_encoding: Add XRGB2101010 format support Harry Wentland
2026-07-25 7:05 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 07/12] lib/igt_color: Add YUV pixel reading support Harry Wentland
2026-07-25 7:10 ` Alex Hung [this message]
2026-06-23 17:57 ` [PATCH v3 08/12] lib/igt_color: Refactor transform_pixels for input/output FBs and CSC Harry Wentland
2026-06-23 17:57 ` [PATCH v3 09/12] tests/kms_colorop: Add FIXED_MATRIX colorop tests Harry Wentland
2026-07-25 7:15 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 10/12] tests/kms_colorop: Keep CRTC active between YUV tests with temp FB Harry Wentland
2026-07-25 7:19 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 11/12] tests/kms_colorop: Add bypass transition tests Harry Wentland
2026-07-25 7:25 ` Alex Hung
2026-06-23 17:57 ` [PATCH v3 12/12] tests/kms_colorop: Increase VKMS bracket to 3 up Harry Wentland
2026-07-25 7:24 ` Alex Hung
2026-06-23 18:55 ` ✓ Xe.CI.BAT: success for YUV Conversion Colorop tests (rev2) Patchwork
2026-06-23 19:19 ` ✓ i915.CI.BAT: " Patchwork
2026-06-24 1:27 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-06-24 5:44 ` ✗ i915.CI.Full: " Patchwork
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=acb18562-50df-4111-8a04-1ec88493d216@amd.com \
--to=alex.hung@amd.com \
--cc=harry.wentland@amd.com \
--cc=igt-dev@lists.freedesktop.org \
/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