[igt-dev] [PATCH i-g-t v2 10/13] igt: fb: Add a bunch of new YUV formats
Paul Kocialkowski
paul.kocialkowski at bootlin.com
Thu Jan 10 10:45:00 UTC 2019
On Tue, 2019-01-08 at 16:19 +0100, Maxime Ripard wrote:
> Thanks to the previous reworks, we can now add new YUV formats pretty
> easily. This patch adds support for the NV12, NV16, NV21, NV61, YUV420,
> YVU420, YUV422 and YVU422 formats.
>
> Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
> ---
> lib/igt_fb.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 98 insertions(+), 2 deletions(-)
>
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 386908b72782..9ceeb824fff4 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -150,6 +150,21 @@ static const struct format_desc_struct {
> .num_planes = 2, .plane_bpp = { 8, 16, },
> .hsub = 2, .vsub = 2,
> },
> + { .name = "NV16", .depth = -1, .drm_id = DRM_FORMAT_NV16,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 2, .plane_bpp = { 8, 16, },
> + .hsub = 2, .vsub = 1,
> + },
> + { .name = "NV21", .depth = -1, .drm_id = DRM_FORMAT_NV21,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 2, .plane_bpp = { 8, 16, },
> + .hsub = 2, .vsub = 2,
> + },
> + { .name = "NV61", .depth = -1, .drm_id = DRM_FORMAT_NV61,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 2, .plane_bpp = { 8, 16, },
> + .hsub = 2, .vsub = 1,
> + },
> { .name = "YUYV", .depth = -1, .drm_id = DRM_FORMAT_YUYV,
> .cairo_id = CAIRO_FORMAT_RGB24,
> .num_planes = 1, .plane_bpp = { 16, },
> @@ -170,6 +185,26 @@ static const struct format_desc_struct {
> .num_planes = 1, .plane_bpp = { 16, },
> .hsub = 2, .vsub = 1,
> },
> + { .name = "YU12", .depth = -1, .drm_id = DRM_FORMAT_YUV420,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 3, .plane_bpp = { 8, 8, 8, },
> + .hsub = 2, .vsub = 2,
> + },
> + { .name = "YU16", .depth = -1, .drm_id = DRM_FORMAT_YUV422,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 3, .plane_bpp = { 8, 8, 8, },
> + .hsub = 2, .vsub = 1,
> + },
> + { .name = "YV12", .depth = -1, .drm_id = DRM_FORMAT_YVU420,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 3, .plane_bpp = { 8, 8, 8, },
> + .hsub = 2, .vsub = 2,
> + },
> + { .name = "YV16", .depth = -1, .drm_id = DRM_FORMAT_YVU422,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 3, .plane_bpp = { 8, 8, 8, },
> + .hsub = 2, .vsub = 1,
> + },
> };
> #define for_each_format(f) \
> for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
> @@ -1590,10 +1625,21 @@ static void get_yuv_parameters(struct igt_fb *fb, struct yuv_parameters *params)
>
> switch (fb->drm_format) {
> case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV61:
> params->y_inc = 1;
> params->uv_inc = 2;
> break;
>
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YVU422:
> + params->y_inc = 1;
> + params->uv_inc = 1;
> + break;
> +
> case DRM_FORMAT_YUYV:
> case DRM_FORMAT_YVYU:
> case DRM_FORMAT_UYVY:
> @@ -1610,6 +1656,13 @@ static void get_yuv_parameters(struct igt_fb *fb, struct yuv_parameters *params)
>
> switch (fb->drm_format) {
> case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV61:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YVU422:
> params->y_stride = fb->strides[0];
> params->uv_stride = fb->strides[1];
> break;
> @@ -1626,11 +1679,33 @@ static void get_yuv_parameters(struct igt_fb *fb, struct yuv_parameters *params)
>
> switch (fb->drm_format) {
> case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV16:
> params->y_offset = fb->offsets[0];
> params->u_offset = fb->offsets[1];
> params->v_offset = fb->offsets[1] + 1;
> break;
>
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV61:
> + params->y_offset = fb->offsets[0];
> + params->u_offset = fb->offsets[1] + 1;
> + params->v_offset = fb->offsets[1];
> + break;
> +
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YUV422:
> + params->y_offset = fb->offsets[0];
> + params->u_offset = fb->offsets[1];
> + params->v_offset = fb->offsets[2];
> + break;
> +
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YVU422:
> + params->y_offset = fb->offsets[0];
> + params->u_offset = fb->offsets[2];
> + params->v_offset = fb->offsets[1];
> + break;
> +
> case DRM_FORMAT_YUYV:
> params->y_offset = fb->offsets[0];
> params->u_offset = fb->offsets[0] + 1;
> @@ -1857,9 +1932,16 @@ static void fb_convert(struct fb_convert *cvt)
> switch (cvt->src.fb->drm_format) {
> case DRM_FORMAT_XYUV8888:
> case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV61:
> case DRM_FORMAT_UYVY:
> case DRM_FORMAT_VYUY:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YUV422:
> case DRM_FORMAT_YUYV:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YVU422:
> case DRM_FORMAT_YVYU:
> convert_yuv_to_rgb24(cvt);
> return;
> @@ -1868,10 +1950,17 @@ static void fb_convert(struct fb_convert *cvt)
> switch (cvt->dst.fb->drm_format) {
> case DRM_FORMAT_XYUV8888:
> case DRM_FORMAT_NV12:
> - case DRM_FORMAT_YUYV:
> - case DRM_FORMAT_YVYU:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV61:
> case DRM_FORMAT_UYVY:
> case DRM_FORMAT_VYUY:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YUYV:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YVU422:
> + case DRM_FORMAT_YVYU:
> convert_rgb24_to_yuv(cvt);
> return;
> }
> @@ -2218,6 +2307,13 @@ bool igt_format_is_yuv(uint32_t drm_format)
> {
> switch (drm_format) {
> case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV61:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YVU422:
> case DRM_FORMAT_YUYV:
> case DRM_FORMAT_YVYU:
> case DRM_FORMAT_UYVY:
--
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
More information about the igt-dev
mailing list