Re: [PATCH v3 05/12] lib/igt_fb: Add YUV color pattern framebuffer support
Alex Hung <[email protected]> Sat, 25 Jul 2026 01:05:01 -0600
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <[email protected]> |
Reviewed-by: Alex Hung <[email protected]> On 6/23/26 11:57, Harry Wentland wrote: > Add igt_create_color_pattern_fb_yuv() function to create test pattern > framebuffers in YUV formats. This extends the existing color pattern > functionality to support YUV testing, handling proper conversion from > RGB test patterns to YUV color spaces with correct encoding and range. > > Assisted-by: Claude:claude-sonnet-4-5 > Signed-off-by: Harry Wentland <[email protected]> > --- > lib/igt_fb.c | 41 +++++++++++++++++++++++++++++++++++++++++ > lib/igt_fb.h | 6 ++++++ > 2 files changed, 47 insertions(+) > > diff --git a/lib/igt_fb.c b/lib/igt_fb.c > index e623b2f64d7c..6c3b9b0b9208 100644 > --- a/lib/igt_fb.c > +++ b/lib/igt_fb.c > @@ -2403,6 +2403,47 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, > return fb_id; > } > > +/** > + * igt_create_color_pattern_fb_yuv: > + * @fd: open drm file descriptor > + * @width: width of the framebuffer in pixel > + * @height: height of the framebuffer in pixel > + * @format: drm fourcc pixel format code > + * @modifier: tiling layout of the framebuffer > + * @color_encoding: color encoding for YUV formats (e.g., BT.601, BT.709, BT.2020) > + * @color_range: color range for YUV formats (limited or full range) > + * @r: red value to use as background, 0.0 for black, 1.0 for red > + * @g: green value to use as background, 0.0 for black, 1.0 for green > + * @b: blue value to use as background, 0.0 for black, 1.0 for blue > + * @fb: pointer to an #igt_fb structure > + * > + * This creates a framebuffer for YUV formats with the specified color encoding > + * and range. Cairo is used to draw the background color and test pattern, with > + * automatic RGB to YUV conversion based on the specified encoding and range. > + * > + * Returns: > + * The kms id of the created framebuffer on success or a negative error code on > + * failure. > + */ > +unsigned int igt_create_color_pattern_fb_yuv(int fd, int width, int height, > + uint32_t format, uint64_t modifier, > + enum igt_color_encoding color_encoding, > + enum igt_color_range color_range, > + double r, double g, double b, > + struct igt_fb *fb /* out */) > +{ > + unsigned int fb_id; > + > + fb_id = igt_create_fb_with_bo_size(fd, width, height, format, modifier, > + color_encoding, color_range, > + fb, 0, 0); > + igt_assert(fb_id); > + > + igt_paint_test_pattern_color_fb(fd, fb, r, g, b); > + > + return fb_id; > +} > + > /** > * igt_create_image_fb: > * @drm_fd: open drm file descriptor > diff --git a/lib/igt_fb.h b/lib/igt_fb.h > index 8e5907dabed4..213e2d77795d 100644 > --- a/lib/igt_fb.h > +++ b/lib/igt_fb.h > @@ -153,6 +153,12 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, > uint32_t format, uint64_t modifier, > double r, double g, double b, > struct igt_fb *fb /* out */); > +unsigned int igt_create_color_pattern_fb_yuv(int fd, int width, int height, > + uint32_t format, uint64_t modifier, > + enum igt_color_encoding color_encoding, > + enum igt_color_range color_range, > + double r, double g, double b, > + struct igt_fb *fb /* out */); > unsigned int igt_create_image_fb(int drm_fd, int width, int height, > uint32_t format, uint64_t modifier, > const char *filename,