public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Sharma, Swati2" <swati2.sharma@intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
Date: Tue, 5 Feb 2019 18:44:40 +0530	[thread overview]
Message-ID: <8d6ab2f0-afbb-6b74-9cf5-877576974320@intel.com> (raw)
In-Reply-To: <20190201111544.7920-3-maarten.lankhorst@linux.intel.com>


On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
> Those formats are packed like YUYV, but only 16 bits per component.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>   include/drm-uapi/drm_fourcc.h |   6 +-
>   lib/igt_color_encoding.c      |   3 +
>   lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>   3 files changed, 154 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
> index c9a5e5787031..8f1b5f832a09 100644
> --- a/include/drm-uapi/drm_fourcc.h
> +++ b/include/drm-uapi/drm_fourcc.h
> @@ -149,10 +149,14 @@ extern "C" {
>   #define DRM_FORMAT_YVYU		fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
>   #define DRM_FORMAT_UYVY		fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
>   #define DRM_FORMAT_VYUY		fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
> -
>   #define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
>   #define DRM_FORMAT_XYUV8888	fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
>   
> +/* Like YUYV, but 16 bpc, lowest bits unused like in DRM_FORMAT_P01X */
> +#define DRM_FORMAT_Y210		fourcc_code('Y', '2', '1', '0')
> +#define DRM_FORMAT_Y212		fourcc_code('Y', '2', '1', '2')
> +#define DRM_FORMAT_Y216		fourcc_code('Y', '2', '1', '6')
> +
>   /*
>    * packed YCbCr420 2x2 tiled formats
>    * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index b7a12a1e07f7..6f82fcec62e4 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -144,6 +144,9 @@ static const struct color_encoding_format {
>   	{ DRM_FORMAT_P010, 65472.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
>   	{ DRM_FORMAT_P012, 65520.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
>   	{ DRM_FORMAT_P016, 65535.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
> +	{ DRM_FORMAT_Y210, 65472.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
> +	{ DRM_FORMAT_Y212, 65520.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
> +	{ DRM_FORMAT_Y216, 65535.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
>   };
>   
>   static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 8bd0420fc2e4..c14cc10d1b73 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>   	  .cairo_id = CAIRO_FORMAT_RGB24,
>   	  .num_planes = 1, .plane_bpp = { 16, },
>   	},
> +	{ .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
> +	{ .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
> +	{ .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
>   	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>   	  .cairo_id = CAIRO_FORMAT_RGB96F,
>   	  .num_planes = 2, .plane_bpp = { 16, 32 },
> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>   					fb->offsets[1] / sizeof(wchar_t));
>   				wmemset(ptr + fb->offsets[1], 0x80008000,
>   					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
> +			case DRM_FORMAT_Y210:
> +			case DRM_FORMAT_Y212:
> +			case DRM_FORMAT_Y216:
> +				wmemset(ptr + fb->offsets[0],
> +					full_range ? 0x80000000 : 0x80001000,
> +					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
> +				break;
>   			}
>   			gem_munmap(ptr, fb->size);

Hi Maarten,

While testing Y210 pixel format, IGT is failing with debug message 
showing igt_create_fb() failure

(kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function 
igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
(kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, 
fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, 
fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
(kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument

dmesg showing bad pitch 12800 for Y210 pixel format

[  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for 
plane 0
[  634.104444] [IGT] kms_plane: exiting, ret=99

Can you please confirm whether changes needs to be done from igt or some 
issue with Y2xx driver patches?

> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>   	}
>   }
>   
> +
> +static void convert_Y21X_to_float(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	const uint16_t *yuyv;
> +	uint16_t *buf;
> +	float *ptr = cvt->dst.ptr;
> +	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
> +	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->src.fb->color_encoding,
> +						    cvt->src.fb->color_range);
> +
> +	igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
> +		    cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
> +		    cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
> +		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
> +
> +	yuyv = buf = convert_src_get(cvt);
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width / 2; j++) {
> +			/* Convert 2x1 pixel blocks */
> +			struct igt_vec4 yuv[2];
> +			struct igt_vec4 rgb[2];
> +
> +			yuv[0].d[0] = yuyv[j * 4 + 0];
> +			yuv[1].d[0] = yuyv[j * 4 + 2];
> +			yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
> +			yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
> +			yuv[0].d[3] = yuv[1].d[3] = 1.0f;
> +
> +			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
> +			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
> +
> +			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
> +			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
> +		}
> +
> +		if (cvt->dst.fb->width & 1) {
> +			struct igt_vec4 yuv;
> +			struct igt_vec4 rgb;
> +
> +			yuv.d[0] = yuyv[j * 4 + 0];
> +			yuv.d[1] = yuyv[j * 4 + 1];
> +			yuv.d[2] = yuyv[j * 4 + 3];
> +			yuv.d[3] = 1.0f;
> +
> +			rgb = igt_matrix_transform(&m, &yuv);
> +
> +			write_rgbf(&ptr[j * 6 + 0], &rgb);
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +
> +	convert_src_put(cvt, buf);
> +}
> +
> +static void convert_float_to_Y21X(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	uint16_t *yuyv = cvt->dst.ptr;
> +	const float *ptr = cvt->src.ptr;
> +	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
> +	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->dst.fb->color_encoding,
> +						    cvt->dst.fb->color_range);
> +
> +	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
> +		   (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
> +		    cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
> +		    cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width / 2; j++) {
> +			/* Convert 2x1 pixel blocks */
> +			struct igt_vec4 rgb[2];
> +			struct igt_vec4 yuv[2];
> +
> +			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
> +			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
> +
> +			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
> +			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
> +
> +			yuyv[j * 4 + 0] = yuv[0].d[0];
> +			yuyv[j * 4 + 2] = yuv[1].d[0];
> +			yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
> +			yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
> +		}
> +
> +		if (cvt->dst.fb->width & 1) {
> +			struct igt_vec4 rgb;
> +			struct igt_vec4 yuv;
> +
> +			read_rgbf(&rgb, &ptr[j * 6 + 0]);
> +
> +			yuv = igt_matrix_transform(&m, &rgb);
> +
> +			yuyv[j * 4 + 0] = yuv.d[0];
> +			yuyv[j * 4 + 1] = yuv.d[1];
> +			yuyv[j * 4 + 3] = yuv.d[2];
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +}
> +
>   static void convert_pixman(struct fb_convert *cvt)
>   {
>   	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>   		case DRM_FORMAT_P016:
>   			convert_p01X_to_float(cvt);
>   			return;
> +		case DRM_FORMAT_Y210:
> +		case DRM_FORMAT_Y212:
> +		case DRM_FORMAT_Y216:
> +			convert_Y21X_to_float(cvt);
> +			return;
>   		}
>   	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>   		switch (cvt->dst.fb->drm_format) {
> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>   		case DRM_FORMAT_P016:
>   			convert_float_to_p01X(cvt);
>   			return;
> +		case DRM_FORMAT_Y210:
> +		case DRM_FORMAT_Y212:
> +		case DRM_FORMAT_Y216:
> +			convert_float_to_Y21X(cvt);
> +			return;
>   		}
>   	}
>   
> @@ -2583,6 +2726,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
>   	case DRM_FORMAT_P010:
>   	case DRM_FORMAT_P012:
>   	case DRM_FORMAT_P016:
> +	case DRM_FORMAT_Y210:
> +	case DRM_FORMAT_Y212:
> +	case DRM_FORMAT_Y216:
>   	case DRM_FORMAT_YUYV:
>   	case DRM_FORMAT_YVYU:
>   	case DRM_FORMAT_UYVY:

-- 
Thanks and Regards,
Swati

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-02-05 13:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
2019-02-04 12:46   ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2 Maarten Lankhorst
2019-02-04 14:09     ` Sharma, Swati2
2019-02-04 14:49       ` Maarten Lankhorst
2019-02-05 15:08       ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v3 Maarten Lankhorst
2019-02-04 13:22   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Sharma, Swati2
2019-02-04 17:06     ` Maarten Lankhorst
2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well Maarten Lankhorst
2019-02-05 13:14   ` Sharma, Swati2 [this message]
2019-02-05 14:31     ` Maarten Lankhorst
2019-02-06  6:47       ` Sharma, Swati2
2019-02-06 14:21         ` Sharma, Swati2
2019-02-06 15:05           ` Maarten Lankhorst
2019-02-07  6:23             ` Sharma, Swati2
2019-02-07  8:15               ` Maarten Lankhorst
2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats Maarten Lankhorst
2019-02-06 14:26   ` Sharma, Swati2
2019-02-01 11:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes Patchwork
2019-02-04 13:17 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev2) Patchwork
2019-02-05 15:19 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev3) 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=8d6ab2f0-afbb-6b74-9cf5-877576974320@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    /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