[igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.

Sharma, Swati2 swati2.sharma at intel.com
Wed Feb 6 14:21:48 UTC 2019


On 06-Feb-19 12:17 PM, Sharma, Swati2 wrote:

>
> On 05-Feb-19 8:01 PM, Maarten Lankhorst wrote:
>> Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>>> 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 at 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:
>> Can I get the full IGT / dmesg logs? I can't see what the fb 
>> dimensions they are.
>
> IGT Logs:
>
> (kms_plane:4960) INFO: Testing format Y210 (0x30313259) on A.0
> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(width=3200, 
> height=1800, format=0x30313259, tiling=0x0, size=0)
> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, 
> pitch=12800)
> (kms_plane:4960) ioctl_wrappers-DEBUG: Test requirement passed: 
> igt_has_fb_modifiers(fd)
> (kms_plane:4960) igt_fb-CRITICAL: Test assertion failure function 
> igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
> (kms_plane:4960) 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:4960) igt_fb-CRITICAL: Last errno: 22, Invalid argument
> (kms_plane:4960) igt_core-INFO: Stack trace:
> (kms_plane:4960) igt_core-INFO:   #0 ../lib/igt_core.c:1474 
> __igt_fail_assert()
> (kms_plane:4960) igt_core-INFO:   #1 ../lib/igt_fb.c:1053 
> igt_create_fb_with_bo_size()
> (kms_plane:4960) igt_core-INFO:   #2 ../lib/igt_fb.c:1078 igt_create_fb()
> (kms_plane:4960) igt_core-INFO:   #3 ../lib/igt_fb.c:1113 
> igt_create_color_fb()
> (kms_plane:4960) igt_core-INFO:   #4 ../tests/kms_plane.c:417 
> test_format_plane_color()
> (kms_plane:4960) igt_core-INFO:   #5 ../tests/kms_plane.c:556 
> test_format_plane()
> (kms_plane:4960) igt_core-INFO:   #6 ../tests/kms_plane.c:587 
> test_pixel_formats()
> (kms_plane:4960) igt_core-INFO:   #7 ../tests/kms_plane.c:602 
> run_tests_for_pipe_plane()
> (kms_plane:4960) igt_core-INFO:   #8 ../tests/kms_plane.c:657 
> __real_main642()
> (kms_plane:4960) igt_core-INFO:   #9 ../tests/kms_plane.c:642 main()
> (kms_plane:4960) igt_core-INFO:   #10 ../csu/libc-start.c:325 
> __libc_start_main()
> (kms_plane:4960) igt_core-INFO:   #11 [_start+0x29]
> (kms_plane:4960) igt_core-INFO:   #12 [<unknown>+0x0]
> ****  END  ****
>
> Dmesg Logs: Attached y210_dmesg_failure.txt
>
Same failure exists for all the Y2xx formats Y210/Y212/Y216.
>>
>> ~Maarten
>>
>>
>> _______________________________________________
>> igt-dev mailing list
>> igt-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/igt-dev
-- 
Thanks and Regards, Swati
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20190206/10d7f687/attachment-0001.html>


More information about the igt-dev mailing list