From: "Lisovskiy, Stanislav" <stanislav.lisovskiy@intel.com>
To: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Cc: "Syrjala, Ville" <ville.syrjala@intel.com>,
"Peres, Martin" <martin.peres@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t v12] lib/igt_fb: Added XYUV format support for testing
Date: Mon, 29 Oct 2018 13:01:27 +0000 [thread overview]
Message-ID: <68f73edbd3863bdccfcb0bf105bed68bb20b9804.camel@intel.com> (raw)
In-Reply-To: <20181024124311.26288-1-stanislav.lisovskiy@intel.com>
On Wed, 2018-10-24 at 15:43 +0300, Stanislav Lisovskiy wrote:
> XYUV format support has been added to DRM, modified
> IGT to reflect those changes.
>
> v2: Fixed merge conflict, started to use new yuv<=>rgb
> conversion functions.
>
> v3: Fixed kms_available_modes_crc test to support new XYUV
> format. Fixed a problem, where test complains that two
> outputs might use same pipe at the same time.
>
> v4: Fixed convertion procedure in igt_fb to support XYUV
> properly.
>
> v5: Fixed a coding typo.
>
> v6: Set depth equal to -1 for XYUV format in order to prevent
> it to be used by igt_bpp_depth_to_drm_format, as we do not
> want YUV formats to be used in that case.
>
> v7: Fix "black" color initialization for create_bo_for_fb with
> proper value. Changed naming "planar_stride" to "xyuv_stride".
>
> v8: Change naming from DRM_FORMAT_XYUV to DRM_FORMAT_XYUV8888
>
> v9: Fixed compilation errors by rebasing to recent master.
>
> v10: Adding reference to correspondent kernel commit with the new
> format
> in include/drm-uapi
>
> v11: Removed unnecessary sizeof's in rgb <=> yuv444 convert
> functions.
>
> v12: Rebased against master branch, fixed rebase conflict caused by
> new fb_convert functions. Removed drm kernel commit reference
> as it is still not merged, so doesn't make sense to use it.
>
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> ---
> include/drm-uapi/drm_fourcc.h | 1 +
> lib/igt_fb.c | 89
> +++++++++++++++++++++++++++++++++++
> 2 files changed, 90 insertions(+)
>
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-
> uapi/drm_fourcc.h
> index e04613d3..03e5466c 100644
> --- a/include/drm-uapi/drm_fourcc.h
> +++ b/include/drm-uapi/drm_fourcc.h
> @@ -112,6 +112,7 @@ extern "C" {
> #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 */
>
> /*
> * 2 plane RGB + A
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 5dca1cfa..4700b152 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -102,6 +102,10 @@ static const struct format_desc_struct {
> .pixman_id = PIXMAN_r8g8b8,
> .num_planes = 1, .plane_bpp = { 24, },
> },
> + { .name = "XYUV8888", .depth = -1, .drm_id =
> DRM_FORMAT_XYUV8888,
> + .cairo_id = CAIRO_FORMAT_RGB24,
> + .num_planes = 1, .plane_bpp = { 32, },
> + },
> { .name = "XRGB8888", .depth = 24, .drm_id =
> DRM_FORMAT_XRGB8888,
> .cairo_id = CAIRO_FORMAT_RGB24,
> .pixman_id = PIXMAN_x8r8g8b8,
> @@ -496,6 +500,10 @@ static int create_bo_for_fb(struct igt_fb *fb)
> 0x80,
> fb->strides[1] * fb-
> >plane_height[1]);
> break;
> + case DRM_FORMAT_XYUV8888:
> + wmemset(ptr + fb->offsets[0],
> full_range ? 0x00008080 : 0x00108080,
> + fb->strides[0] * fb-
> >plane_height[0] / sizeof(wchar_t));
> + break;
> case DRM_FORMAT_YUYV:
> case DRM_FORMAT_YVYU:
> wmemset(ptr + fb->offsets[0],
> @@ -1622,6 +1630,79 @@ static void convert_nv12_to_rgb24(struct
> fb_convert *cvt)
> free(buf);
> }
>
> +static void convert_yuv444_to_rgb24(struct fb_convert *cvt)
> +{
> + int i, j;
> + uint8_t *yuv24;
> + uint8_t *rgb24 = cvt->dst.ptr;
> + unsigned rgb24_stride = cvt->dst.fb->strides[0], xyuv_stride
> = cvt->src.fb->strides[0];
> + uint8_t *buf = malloc(cvt->src.fb->size);
> + struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb-
> >color_encoding,
> + cvt->src.fb-
> >color_range);
> +
> + /*
> + * Reading from the BO is awfully slow because of lack of
> read caching,
> + * it's faster to copy the whole BO to a temporary buffer
> and convert
> + * from there.
> + */
> + igt_memcpy_from_wc(buf, cvt->src.ptr + cvt->src.fb-
> >offsets[0], cvt->src.fb->size);
> + yuv24 = buf;
> +
> + for (i = 0; i < cvt->dst.fb->height; i++) {
> + for (j = 0; j < cvt->dst.fb->width; j++) {
> + float y, u, v;
> + struct igt_vec4 yuv;
> + struct igt_vec4 rgb;
> +
> + v = yuv24[i * xyuv_stride + j * 4];
> + u = yuv24[i * xyuv_stride + j * 4 + 1];
> + y = yuv24[i * xyuv_stride + j * 4 + 2];
> + yuv.d[0] = y;
> + yuv.d[1] = u;
> + yuv.d[2] = v;
> + yuv.d[3] = 1.0f;
> +
> + rgb = igt_matrix_transform(&m, &yuv);
> +
> + write_rgb(&rgb24[i * rgb24_stride + j * 4],
> &rgb);
> + }
> + }
> +
> + free(buf);
> +}
> +
> +
> +static void convert_rgb24_to_yuv444(struct fb_convert *cvt)
> +{
> + int i, j;
> + uint8_t *rgb24;
> + uint8_t *yuv444 = cvt->dst.ptr + cvt->dst.fb->offsets[0];
> + unsigned int rgb24_stride = cvt->src.fb->strides[0],
> xyuv_stride = cvt->dst.fb->strides[0];
> + struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb-
> >color_encoding,
> + cvt->dst.fb-
> >color_range);
> +
> + rgb24 = cvt->src.ptr;
> +
> + igt_assert_f(cvt->dst.fb->drm_format == DRM_FORMAT_XYUV8888,
> + "Conversion not implemented for !XYUV packed
> formats\n");
> +
> + for (i = 0; i < cvt->dst.fb->height; i++) {
> + for (j = 0; j < cvt->dst.fb->width; j++) {
> + struct igt_vec4 rgb;
> + struct igt_vec4 yuv;
> + float y, u, v;
> +
> + read_rgb(&rgb, &rgb24[i * rgb24_stride + j *
> 4]);
> +
> + yuv = igt_matrix_transform(&m, &rgb);
> +
> + yuv444[i * xyuv_stride + j * 4] = yuv.d[2];
> + yuv444[i * xyuv_stride + j * 4 + 1] =
> yuv.d[1];
> + yuv444[i * xyuv_stride + j * 4 + 2] =
> yuv.d[0];
> + }
> + }
> +}
> +
> static void convert_rgb24_to_nv12(struct fb_convert *cvt)
> {
> int i, j;
> @@ -1901,6 +1982,9 @@ static void fb_convert(struct fb_convert *cvt)
> return;
> } else if (cvt->dst.fb->drm_format == DRM_FORMAT_RGB888) {
> switch (cvt->src.fb->drm_format) {
> + case DRM_FORMAT_XYUV8888:
> + convert_yuv444_to_rgb24(cvt);
> + return;
> case DRM_FORMAT_NV12:
> convert_nv12_to_rgb24(cvt);
> return;
> @@ -1913,6 +1997,9 @@ static void fb_convert(struct fb_convert *cvt)
> }
> } else if (cvt->src.fb->drm_format == DRM_FORMAT_RGB888) {
> switch (cvt->dst.fb->drm_format) {
> + case DRM_FORMAT_XYUV8888:
> + convert_rgb24_to_yuv444(cvt);
> + return;
> case DRM_FORMAT_NV12:
> convert_rgb24_to_nv12(cvt);
> return;
> @@ -2003,6 +2090,7 @@ static void create_cairo_surface__convert(int
> fd, struct igt_fb *fb)
> blit,
> destroy_cairo_surface__convert);
> }
>
> +
> /**
> * igt_fb_map_buffer:
> * @fd: open drm file descriptor
> @@ -2268,6 +2356,7 @@ bool igt_format_is_yuv(uint32_t drm_format)
> case DRM_FORMAT_YVYU:
> case DRM_FORMAT_UYVY:
> case DRM_FORMAT_VYUY:
> + case DRM_FORMAT_XYUV8888:
> return true;
> default:
> return false;
Previous suggestions are fixed. Pinging for review.
--
Best Regards,
Lisovskiy Stanislav
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-10-29 13:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-24 12:43 [igt-dev] [PATCH i-g-t v12] lib/igt_fb: Added XYUV format support for testing Stanislav Lisovskiy
2018-10-24 15:53 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib/igt_fb: Added XYUV format support for testing (rev14) Patchwork
2018-10-29 13:01 ` Lisovskiy, Stanislav [this message]
2018-11-20 13:54 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2018-11-20 16:26 ` Patchwork
2018-11-20 19:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-11-21 0:53 ` Patchwork
-- strict thread matches above, loose matches on Subject: below --
2018-10-24 12:40 [igt-dev] [PATCH i-g-t v12] lib/igt_fb: Added XYUV format support for testing Stanislav Lisovskiy
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=68f73edbd3863bdccfcb0bf105bed68bb20b9804.camel@intel.com \
--to=stanislav.lisovskiy@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=martin.peres@intel.com \
--cc=ville.syrjala@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