[Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
From: chandra konduruThis patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling. v2: -Added 90/270 tests (me) -took out crc test as it isn't adding much value due to chroma upsampling (me) v3: -Make --list-subtests option work (Tvrtko) -Make nv12 unsupported test run properly either as a sub test or along with all other tests (me) -Added nv12 fb with invalid params (Daniel) v4: -Avoid modeset for invalid tests (Daniel) v5: -Added negative nv12 addfb tests for modifier and stride alignment (me) Signed-off-by: chandra konduru --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 761 + 3 files changed, 763 insertions(+) create mode 100644 tests/kms_nv12.c diff --git a/tests/.gitignore b/tests/.gitignore index d6d05ff..2de4712 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency diff --git a/tests/Makefile.sources b/tests/Makefile.sources index ef69299..a7804fa 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \ diff --git a/tests/kms_nv12.c b/tests/kms_nv12.c new file mode 100644 index 000..bad6862 --- /dev/null +++ b/tests/kms_nv12.c @@ -0,0 +1,761 @@ +/* + * Copyright © 2013,2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include +#include +#include + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" +#include "intel_chipset.h" +#include "ioctl_wrappers.h" + +IGT_TEST_DESCRIPTION("Test display NV12 support"); + +uint32_t devid; +typedef struct { + int drm_fd; + igt_display_t display; + int num_scalers; + int num_planes; + + struct igt_fb fb1; + struct igt_fb fb1_nv12; + struct igt_fb fb2; + struct igt_fb fb2_nv12; + struct igt_fb fb3; + struct igt_fb fb3_nv12; + int fb_id1; + int fb_id1_nv12; + int fb_id2; + int fb_id2_nv12; + int fb_id3; + int fb_id3_nv12; + + igt_plane_t *plane1; + igt_plane_t *plane2; + igt_plane_t *plane3; + + uint64_t tiled; + int rotation; +} data_t; + +typedef struct { + int width; + int height; +} res_t; + +#define IMG_FILE "1080p-left.png" + +static void +paint_pattern(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d->drm_fd, fb); + igt_paint_test_pattern(cr, w, h); + cairo_destroy(cr); +} + +static void +paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d->drm_fd, fb); + igt_paint_image(cr, IMG_FILE, 0, 0, w, h); + cairo_destroy(cr); +} + +static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, + igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s) +{ + igt_display_t *display = >display; + + igt_output_set_pipe(output, pipe); + + /* before allocating, free if any older fb */ + if (data->fb_id1) { + igt_remove_fb(data->drm_fd, >fb1); + data->fb_id1 = 0; + } + + /* allocate fb for plane 1 */ + data->fb_id1 = igt_create_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB, + data->tiled,
[Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
From: chandra konduruThis patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling. v2: -Added 90/270 tests (me) -took out crc test as it isn't adding much value due to chroma upsampling (me) v3: -Make --list-subtests option work (Tvrtko) -Make nv12 unsupported test run properly either as a sub test or along with all other tests (me) -Added nv12 fb with invalid params (Daniel) v4: -Avoid modeset for invalid tests (Daniel) Signed-off-by: chandra konduru --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 753 + 3 files changed, 755 insertions(+) create mode 100644 tests/kms_nv12.c diff --git a/tests/.gitignore b/tests/.gitignore index d6d05ff..2de4712 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency diff --git a/tests/Makefile.sources b/tests/Makefile.sources index ef69299..a7804fa 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \ diff --git a/tests/kms_nv12.c b/tests/kms_nv12.c new file mode 100644 index 000..61f826a --- /dev/null +++ b/tests/kms_nv12.c @@ -0,0 +1,753 @@ +/* + * Copyright © 2013,2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include +#include +#include + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" +#include "intel_chipset.h" +#include "ioctl_wrappers.h" + +IGT_TEST_DESCRIPTION("Test display NV12 support"); + +uint32_t devid; +typedef struct { + int drm_fd; + igt_display_t display; + int num_scalers; + int num_planes; + + struct igt_fb fb1; + struct igt_fb fb1_nv12; + struct igt_fb fb2; + struct igt_fb fb2_nv12; + struct igt_fb fb3; + struct igt_fb fb3_nv12; + int fb_id1; + int fb_id1_nv12; + int fb_id2; + int fb_id2_nv12; + int fb_id3; + int fb_id3_nv12; + + igt_plane_t *plane1; + igt_plane_t *plane2; + igt_plane_t *plane3; + + uint64_t tiled; + int rotation; +} data_t; + +typedef struct { + int width; + int height; +} res_t; + +#define IMG_FILE "1080p-left.png" + +static void +paint_pattern(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d->drm_fd, fb); + igt_paint_test_pattern(cr, w, h); + cairo_destroy(cr); +} + +static void +paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d->drm_fd, fb); + igt_paint_image(cr, IMG_FILE, 0, 0, w, h); + cairo_destroy(cr); +} + +static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, + igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s) +{ + igt_display_t *display = >display; + + igt_output_set_pipe(output, pipe); + + /* before allocating, free if any older fb */ + if (data->fb_id1) { + igt_remove_fb(data->drm_fd, >fb1); + data->fb_id1 = 0; + } + + /* allocate fb for plane 1 */ + data->fb_id1 = igt_create_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB, + data->tiled, /* tiled */ + >fb1); + igt_assert(data->fb_id1);
Re: [Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
> > > > + > > > > + /* redo AddFB */ > > > > + memset(, 0, sizeof(f)); > > > > + > > > > + f.width = d->fb1_nv12.width; > > > > + f.height = d->fb1_nv12.height; > > > > + f.pixel_format = d->fb1_nv12.drm_format; > > > > + f.flags = LOCAL_DRM_MODE_FB_MODIFIERS; > > > > + f.handles[0] = d->fb1_nv12.gem_handle; > > > > + f.pitches[0] = d->fb1_nv12.stride; > > > > + f.modifier[0] = LOCAL_I915_FORMAT_MOD_Yf_TILED; > > > > + f.modifier[1] = LOCAL_I915_FORMAT_MOD_Yf_TILED; > > > > + > > > > + /* test invalid uv start */ > > > > + f.handles[1] = d->fb1_nv12.gem_handle; > > > > + f.pitches[1] = d->fb1_nv12.stride; > > > > + f.offsets[1] = 0; /* invalid uv start */ > > > > + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, > > > ) != 0); > > > > > > For such simple invalid input paramaters tests the usual approach is to > > > split them out. Also you don't have to do a modeset for addfb (which will > > > speed things up). Essentially each block with an igt_assert should be its > > > own subtest. > > > -Daniel > > > > > > > If each block is split into it's own subtest, if one runs just a subtest > > and without a modeset, I don't know in which state the system is to start > > the test and doing a modeset will start with a known state. > > ADDFB ioctl doesn't need any known modeset state at all, and that seems to > be the only ioctl you do. Which means you really don't need to do a > modeset (it's just overhead). See e.g. the other addfb testcases we have > in kms_addfb_basic.c. > -Daniel I see your point. will check on that and make any necessary updates. ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
On Thu, Aug 27, 2015 at 01:51:52AM +, Konduru, Chandra wrote: > > > +static void test_nv12_invalid_fb_params(data_t *d) > > > +{ > > > + igt_display_t *display = >display; > > > + igt_output_t *output; > > > + enum pipe pipe; > > > + int valid_tests = 0; > > > + > > > + igt_require(d->display.has_universal_planes); > > > + igt_require(d->num_scalers); > > > + > > > + for_each_connected_output(display, output) { > > > + struct local_drm_mode_fb_cmd2 f; > > > + int fd = d->drm_fd; > > > + drmModeModeInfo *mode; > > > + > > > + mode = igt_output_get_mode(output); > > > + pipe = output->config.pipe; > > > + > > > + igt_output_set_pipe(output, pipe); > > > + > > > + /* Set up display with plane 1 */ > > > + d->plane1 = igt_output_get_plane(output, > > IGT_PLANE_PRIMARY); > > > + igt_plane_set_rotation(d->plane1, IGT_ROTATION_0); > > > + prepare_crtc(d, output, pipe, d->plane1, mode, > > COMMIT_LEGACY); > > > + > > > + /* use igt helper to create bo and addfb tile-Yf, this should > > > pass > > */ > > > + d->fb_id1_nv12 = igt_create_fb(d->drm_fd, > > > + 1920, 1080, > > > + DRM_FORMAT_NV12, > > > + LOCAL_I915_FORMAT_MOD_Yf_TILED, > > > + >fb1_nv12); > > > + igt_assert(d->fb_id1_nv12); > > > + > > > + /* now remove fb but keep bo to redo addfb */ > > > + drmModeRmFB(d->drm_fd, d->fb_id1_nv12); > > > + > > > + /* redo AddFB */ > > > + memset(, 0, sizeof(f)); > > > + > > > + f.width = d->fb1_nv12.width; > > > + f.height = d->fb1_nv12.height; > > > + f.pixel_format = d->fb1_nv12.drm_format; > > > + f.flags = LOCAL_DRM_MODE_FB_MODIFIERS; > > > + f.handles[0] = d->fb1_nv12.gem_handle; > > > + f.pitches[0] = d->fb1_nv12.stride; > > > + f.modifier[0] = LOCAL_I915_FORMAT_MOD_Yf_TILED; > > > + f.modifier[1] = LOCAL_I915_FORMAT_MOD_Yf_TILED; > > > + > > > + /* test invalid uv start */ > > > + f.handles[1] = d->fb1_nv12.gem_handle; > > > + f.pitches[1] = d->fb1_nv12.stride; > > > + f.offsets[1] = 0; /* invalid uv start */ > > > + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, > > ) != 0); > > > > For such simple invalid input paramaters tests the usual approach is to > > split them out. Also you don't have to do a modeset for addfb (which will > > speed things up). Essentially each block with an igt_assert should be its > > own subtest. > > -Daniel > > > > If each block is split into it's own subtest, if one runs just a subtest > and without a modeset, I don't know in which state the system is to start > the test and doing a modeset will start with a known state. ADDFB ioctl doesn't need any known modeset state at all, and that seems to be the only ioctl you do. Which means you really don't need to do a modeset (it's just overhead). See e.g. the other addfb testcases we have in kms_addfb_basic.c. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
On Wed, Aug 19, 2015 at 06:05:25PM -0700, Chandra Konduru wrote: From: chandra konduru chandra.kond...@intel.com This patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling. v2: -Added 90/270 tests (me) -took out crc test as it isn't adding much value due to chroma upsampling (me) v3: -Make --list-subtests option work (Tvrtko) -Make nv12 unsupported test run properly either as a sub test or along with all other tests (me) -Added nv12 fb with invalid params (Daniel) Signed-off-by: chandra konduru chandra.kond...@intel.com --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 759 + 3 files changed, 761 insertions(+) create mode 100644 tests/kms_nv12.c diff --git a/tests/.gitignore b/tests/.gitignore index d6d05ff..2de4712 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency diff --git a/tests/Makefile.sources b/tests/Makefile.sources index ef69299..a7804fa 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \ diff --git a/tests/kms_nv12.c b/tests/kms_nv12.c new file mode 100644 index 000..9f90a85 --- /dev/null +++ b/tests/kms_nv12.c @@ -0,0 +1,759 @@ +/* + * Copyright © 2013,2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include math.h +#include fcntl.h +#include sys/stat.h + +#include drmtest.h +#include igt_debugfs.h +#include igt_kms.h +#include igt_core.h +#include intel_chipset.h +#include ioctl_wrappers.h + +IGT_TEST_DESCRIPTION(Test display NV12 support); + +uint32_t devid; +typedef struct { + int drm_fd; + igt_display_t display; + int num_scalers; + int num_planes; + + struct igt_fb fb1; + struct igt_fb fb1_nv12; + struct igt_fb fb2; + struct igt_fb fb2_nv12; + struct igt_fb fb3; + struct igt_fb fb3_nv12; + int fb_id1; + int fb_id1_nv12; + int fb_id2; + int fb_id2_nv12; + int fb_id3; + int fb_id3_nv12; + + igt_plane_t *plane1; + igt_plane_t *plane2; + igt_plane_t *plane3; + + uint64_t tiled; + int rotation; +} data_t; + +typedef struct { + int width; + int height; +} res_t; + +#define IMG_FILE 1080p-left.png + +static void +paint_pattern(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d-drm_fd, fb); + igt_paint_test_pattern(cr, w, h); + cairo_destroy(cr); +} + +static void +paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d-drm_fd, fb); + igt_paint_image(cr, IMG_FILE, 0, 0, w, h); + cairo_destroy(cr); +} + +static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, + igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s) +{ + igt_display_t *display = data-display; + + igt_output_set_pipe(output, pipe); + + /* before allocating, free if any older fb */ + if (data-fb_id1) { + igt_remove_fb(data-drm_fd, data-fb1); + data-fb_id1 = 0; + } + + /* allocate fb for plane 1 */ + data-fb_id1 = igt_create_fb(data-drm_fd, + mode-hdisplay, mode-vdisplay, + DRM_FORMAT_XRGB, +
Re: [Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
+static void test_nv12_invalid_fb_params(data_t *d) +{ + igt_display_t *display = d-display; + igt_output_t *output; + enum pipe pipe; + int valid_tests = 0; + + igt_require(d-display.has_universal_planes); + igt_require(d-num_scalers); + + for_each_connected_output(display, output) { + struct local_drm_mode_fb_cmd2 f; + int fd = d-drm_fd; + drmModeModeInfo *mode; + + mode = igt_output_get_mode(output); + pipe = output-config.pipe; + + igt_output_set_pipe(output, pipe); + + /* Set up display with plane 1 */ + d-plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY); + igt_plane_set_rotation(d-plane1, IGT_ROTATION_0); + prepare_crtc(d, output, pipe, d-plane1, mode, COMMIT_LEGACY); + + /* use igt helper to create bo and addfb tile-Yf, this should pass */ + d-fb_id1_nv12 = igt_create_fb(d-drm_fd, + 1920, 1080, + DRM_FORMAT_NV12, + LOCAL_I915_FORMAT_MOD_Yf_TILED, + d-fb1_nv12); + igt_assert(d-fb_id1_nv12); + + /* now remove fb but keep bo to redo addfb */ + drmModeRmFB(d-drm_fd, d-fb_id1_nv12); + + /* redo AddFB */ + memset(f, 0, sizeof(f)); + + f.width = d-fb1_nv12.width; + f.height = d-fb1_nv12.height; + f.pixel_format = d-fb1_nv12.drm_format; + f.flags = LOCAL_DRM_MODE_FB_MODIFIERS; + f.handles[0] = d-fb1_nv12.gem_handle; + f.pitches[0] = d-fb1_nv12.stride; + f.modifier[0] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + f.modifier[1] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + + /* test invalid uv start */ + f.handles[1] = d-fb1_nv12.gem_handle; + f.pitches[1] = d-fb1_nv12.stride; + f.offsets[1] = 0; /* invalid uv start */ + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, f) != 0); For such simple invalid input paramaters tests the usual approach is to split them out. Also you don't have to do a modeset for addfb (which will speed things up). Essentially each block with an igt_assert should be its own subtest. -Daniel If each block is split into it's own subtest, if one runs just a subtest and without a modeset, I don't know in which state the system is to start the test and doing a modeset will start with a known state. ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
From: chandra konduru chandra.kond...@intel.com This patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling. v2: -Added 90/270 tests (me) -took out crc test as it isn't adding much value due to chroma upsampling (me) v3: -Make --list-subtests option work (Tvrtko) -Make nv12 unsupported test run properly either as a sub test or along with all other tests (me) -Added nv12 fb with invalid params (Daniel) Signed-off-by: chandra konduru chandra.kond...@intel.com --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 759 + 3 files changed, 761 insertions(+) create mode 100644 tests/kms_nv12.c diff --git a/tests/.gitignore b/tests/.gitignore index d6d05ff..2de4712 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency diff --git a/tests/Makefile.sources b/tests/Makefile.sources index ef69299..a7804fa 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \ diff --git a/tests/kms_nv12.c b/tests/kms_nv12.c new file mode 100644 index 000..9f90a85 --- /dev/null +++ b/tests/kms_nv12.c @@ -0,0 +1,759 @@ +/* + * Copyright © 2013,2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include math.h +#include fcntl.h +#include sys/stat.h + +#include drmtest.h +#include igt_debugfs.h +#include igt_kms.h +#include igt_core.h +#include intel_chipset.h +#include ioctl_wrappers.h + +IGT_TEST_DESCRIPTION(Test display NV12 support); + +uint32_t devid; +typedef struct { + int drm_fd; + igt_display_t display; + int num_scalers; + int num_planes; + + struct igt_fb fb1; + struct igt_fb fb1_nv12; + struct igt_fb fb2; + struct igt_fb fb2_nv12; + struct igt_fb fb3; + struct igt_fb fb3_nv12; + int fb_id1; + int fb_id1_nv12; + int fb_id2; + int fb_id2_nv12; + int fb_id3; + int fb_id3_nv12; + + igt_plane_t *plane1; + igt_plane_t *plane2; + igt_plane_t *plane3; + + uint64_t tiled; + int rotation; +} data_t; + +typedef struct { + int width; + int height; +} res_t; + +#define IMG_FILE 1080p-left.png + +static void +paint_pattern(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d-drm_fd, fb); + igt_paint_test_pattern(cr, w, h); + cairo_destroy(cr); +} + +static void +paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d-drm_fd, fb); + igt_paint_image(cr, IMG_FILE, 0, 0, w, h); + cairo_destroy(cr); +} + +static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, + igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s) +{ + igt_display_t *display = data-display; + + igt_output_set_pipe(output, pipe); + + /* before allocating, free if any older fb */ + if (data-fb_id1) { + igt_remove_fb(data-drm_fd, data-fb1); + data-fb_id1 = 0; + } + + /* allocate fb for plane 1 */ + data-fb_id1 = igt_create_fb(data-drm_fd, + mode-hdisplay, mode-vdisplay, + DRM_FORMAT_XRGB, + data-tiled, /* tiled */ + data-fb1); + igt_assert(data-fb_id1); + + paint_pattern(data, data-fb1,