diff mbox

[2/2] i-g-t: Adding display NV12 testcase

Message ID 1430536299-17547-3-git-send-email-chandra.konduru@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chandra Konduru May 2, 2015, 3:11 a.m. UTC
From: chandra konduru <chandra.konduru@intel.com>

This patch adds kms_nv12 test case. It covers testing NV12 in
all supported linear/tile-X/tile-Y/tile-Yf tile formats in
0 and 180 orientations. For each tiling format, it tests
various combinations of planes and scaling.

It has some very preliminary crc support and it is bit flaky.
Though I have seen once-in-a-while crc check failures, most of the
time they pass, so enabled by-default. If they cause headaches
they can be disabled as needed.

Signed-off-by: chandra konduru <chandra.konduru@intel.com>
---
 tests/.gitignore       |   1 +
 tests/Android.mk       |   1 +
 tests/Makefile.sources |   1 +
 tests/kms_nv12.c       | 529 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 532 insertions(+)
 create mode 100644 tests/kms_nv12.c

Comments

Daniel Vetter May 7, 2015, 6:48 a.m. UTC | #1
On Fri, May 01, 2015 at 08:11:39PM -0700, Chandra Konduru wrote:
> From: chandra konduru <chandra.konduru@intel.com>
> 
> This patch adds kms_nv12 test case. It covers testing NV12 in
> all supported linear/tile-X/tile-Y/tile-Yf tile formats in
> 0 and 180 orientations. For each tiling format, it tests
> various combinations of planes and scaling.
> 
> It has some very preliminary crc support and it is bit flaky.
> Though I have seen once-in-a-while crc check failures, most of the
> time they pass, so enabled by-default. If they cause headaches
> they can be disabled as needed.

Sporadic crc failures are probably watermark issues. Have you seen
underruns reported?
-Daniel

> 
> Signed-off-by: chandra konduru <chandra.konduru@intel.com>
> ---
>  tests/.gitignore       |   1 +
>  tests/Android.mk       |   1 +
>  tests/Makefile.sources |   1 +
>  tests/kms_nv12.c       | 529 +++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 532 insertions(+)
>  create mode 100644 tests/kms_nv12.c
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 796e330..35c0e6e 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -147,6 +147,7 @@ kms_vblank
>  kms_crtc_background_color
>  kms_plane_scaling
>  kms_panel_fitting
> +kms_nv12
>  pm_lpsp
>  pm_rc6_residency
>  pm_rpm
> diff --git a/tests/Android.mk b/tests/Android.mk
> index fac9931..c0c6383 100644
> --- a/tests/Android.mk
> +++ b/tests/Android.mk
> @@ -81,6 +81,7 @@ else
>      kms_pwrite_crc \
>      kms_pipe_b_c_ivb \
>      kms_legacy_colorkey
> +	kms_nv12 \
>      IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0
>  endif
>  
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 4cbc50d..b68224e 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -78,6 +78,7 @@ TESTS_progs_M = \
>  	kms_crtc_background_color \
>  	kms_plane_scaling \
>  	kms_panel_fitting \
> +	kms_nv12 \
>  	pm_lpsp \
>  	pm_rpm \
>  	pm_rps \
> diff --git a/tests/kms_nv12.c b/tests/kms_nv12.c
> new file mode 100644
> index 0000000..e88c934
> --- /dev/null
> +++ b/tests/kms_nv12.c
> @@ -0,0 +1,529 @@
> +/*
> + * 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;
> +	igt_crc_t crc1;
> +	igt_crc_t crc2;
> +	igt_pipe_crc_t *pipe_crc;
> +	int num_scalers;
> +
> +	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;
> +	int crc;
> +} data_t;
> +
> +#define IMG_FILE  "1080p-left.png"
> +#define SOLID_COLOR      0xFFFFFF       /* BGR 8bpc */
> +
> +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
> +paint_solid_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h,
> +	uint32_t color)
> +{
> +	cairo_t *cr;
> +	double r, g, b;
> +
> +	cr = igt_get_cairo_ctx(d->drm_fd, fb);
> +
> +	/* Paint with solid color */
> +	r = (double) (color & 0xFF) / 255.0;
> +	g = (double) ((color & 0xFF00) >> 8) / 255.0;
> +	b = (double) ((color & 0xFF0000) >> 16) / 255.0;
> +	igt_paint_color(cr, 0, 0, w, h, r, g, b);
> +
> +	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);
> +
> +	/* create the pipe_crc object for this pipe */
> +	igt_pipe_crc_free(data->pipe_crc);
> +	data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
> +
> +	/* 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_XRGB8888,
> +			LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
> +			&data->fb1);
> +	igt_assert(data->fb_id1);
> +
> +	paint_pattern(data, &data->fb1, mode->hdisplay, mode->vdisplay);
> +
> +	/*
> +	 * We always set the primary plane to actually enable the pipe as
> +	 * there's no way (that works) to light up a pipe with only a sprite
> +	 * plane enabled at the moment.
> +	 */
> +	if (!plane->is_primary) {
> +		igt_plane_t *primary;
> +
> +		primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
> +		igt_plane_set_fb(primary, &data->fb1);
> +	}
> +
> +	igt_plane_set_fb(plane, &data->fb1);
> +	if (s == COMMIT_LEGACY) {
> +		int ret;
> +		ret = drmModeSetCrtc(data->drm_fd,
> +				output->config.crtc->crtc_id,
> +				data->fb_id1,
> +				plane->pan_x, plane->pan_y,
> +				&output->id,
> +				1,
> +				mode);
> +		igt_assert(ret == 0);
> +	} else {
> +		igt_display_commit2(display, s);
> +	}
> +}
> +
> +static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
> +{
> +	igt_display_t *display = &data->display;
> +
> +	igt_pipe_crc_free(data->pipe_crc);
> +	data->pipe_crc = NULL;
> +
> +	if (data->fb_id1) {
> +		igt_remove_fb(data->drm_fd, &data->fb1);
> +		data->fb_id1 = 0;
> +	}
> +	if (data->fb_id2) {
> +		igt_remove_fb(data->drm_fd, &data->fb2);
> +		data->fb_id2 = 0;
> +	}
> +	if (data->fb_id3) {
> +		igt_remove_fb(data->drm_fd, &data->fb3);
> +		data->fb_id3 = 0;
> +	}
> +
> +	if (data->fb_id1_nv12) {
> +		igt_remove_fb(data->drm_fd, &data->fb1_nv12);
> +		data->fb_id1_nv12 = 0;
> +	}
> +
> +	if (data->fb_id2_nv12) {
> +		igt_remove_fb(data->drm_fd, &data->fb2_nv12);
> +		data->fb_id2_nv12 = 0;
> +	}
> +
> +	if (data->fb_id3_nv12) {
> +		igt_remove_fb(data->drm_fd, &data->fb3_nv12);
> +		data->fb_id3_nv12 = 0;
> +	}
> +
> +	if (!plane->is_primary) {
> +		igt_plane_t *primary;
> +
> +		primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
> +		igt_plane_set_fb(primary, NULL);
> +	}
> +
> +	igt_plane_set_fb(plane, NULL);
> +	igt_output_set_pipe(output, PIPE_ANY);
> +
> +	igt_display_commit2(display, COMMIT_UNIVERSAL);
> +}
> +
> +static void test_nv12_plane(data_t *d)
> +{
> +	igt_display_t *display = &d->display;
> +	igt_output_t *output;
> +	enum pipe pipe;
> +	int valid_tests = 0;
> +	int img_width;
> +	int img_height;
> +
> +	igt_require(d->display.has_universal_planes);
> +	igt_require(d->num_scalers);
> +
> +	for_each_connected_output(display, output) {
> +		drmModeModeInfo *mode;
> +		mode = igt_output_get_mode(output);
> +		pipe = output->config.pipe;
> +
> +		igt_output_set_pipe(output, pipe);
> +
> +		/* get planes */
> +		d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
> +		d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
> +		d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
> +
> +		/* set required rotation */
> +		igt_plane_set_rotation(d->plane1, d->rotation);
> +		igt_plane_set_rotation(d->plane2, d->rotation);
> +		igt_plane_set_rotation(d->plane3, d->rotation);
> +
> +		/* Set up display with plane 1 */
> +		prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_LEGACY);
> +
> +		/* allocate fb2, fb2_nv12, fb1_nv12 with image size */
> +		igt_get_image_size(IMG_FILE, &img_width, &img_height);
> +
> +		/* fb2 is in RGB format */
> +		d->fb_id2 = igt_create_fb(d->drm_fd,
> +				img_width, img_height,
> +				DRM_FORMAT_XRGB8888,
> +				d->tiled, /* tiled */
> +				&d->fb2);
> +		igt_assert(d->fb_id2);
> +
> +		/* fb1_nv12 is in NV12 format */
> +		d->fb_id1_nv12 = igt_create_fb(d->drm_fd,
> +				img_width, img_height,
> +				DRM_FORMAT_NV12,
> +				d->tiled, /* tiled */
> +				&d->fb1_nv12);
> +		igt_assert(d->fb_id1_nv12);
> +
> +		/* fb2_nv12 is in NV12 format */
> +		d->fb_id2_nv12 = igt_create_fb(d->drm_fd,
> +				img_width, img_height,
> +				DRM_FORMAT_NV12,
> +				d->tiled,
> +				&d->fb2_nv12);
> +		igt_assert(d->fb_id2_nv12);
> +
> +		/* fb3 is in RGB */
> +		d->fb_id3 = igt_create_fb(d->drm_fd,
> +				mode->hdisplay, mode->vdisplay,
> +				DRM_FORMAT_ARGB8888,
> +				d->tiled, /* tiled */
> +				&d->fb3);
> +		igt_assert(d->fb_id3);
> +
> +		if (d->crc) {
> +			/*
> +			 * CRC test:
> +			 * 1st CRC: plane 1: RGB FS, plane 2: RGB 19x10  --> CRC1
> +			 * 2nd CRC: plane 1: RGB FS, plane 2: NV12 19x10 --> CRC2
> +			 * make sure CRC1 == CRC2
> +			 *
> +			 * For CRCs to work, cannot use any image/data because
> +			 * chrome-upsampling can fail CRC comparison.
> +			 * Though it is a very basic, solid color is expected to work
> +			 */
> +			paint_solid_color(d, &d->fb2, d->fb2.width, d->fb2.height,
> +				SOLID_COLOR);
> +
> +			/* Setup to capture CRC1 when plane 2 is in RGB mode */
> +			igt_plane_set_fb(d->plane2, &d->fb2);
> +			igt_fb_set_position(&d->fb2, d->plane2, 0, 0);
> +			igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width, d->fb2.height);
> +			igt_plane_set_position(d->plane2, 0, 0);
> +			igt_plane_set_size(d->plane2, d->fb2.width, d->fb2.height);
> +			igt_display_commit2(display, COMMIT_UNIVERSAL);
> +			igt_pipe_crc_collect_crc(d->pipe_crc, &d->crc1);
> +
> +			/* Setup to capture CRC2 when plane 2 is in NV12 mode */
> +			igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb2_nv12, &d->fb2);
> +			igt_plane_set_fb(d->plane2, &d->fb2_nv12);
> +			igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
> +			igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
> +				d->fb2_nv12.height);
> +			igt_plane_set_position(d->plane2, 0, 0);
> +			igt_plane_set_size(d->plane2, d->fb2_nv12.width,d->fb2_nv12.height);
> +			igt_display_commit2(display, COMMIT_UNIVERSAL);
> +			igt_pipe_crc_collect_crc(d->pipe_crc, &d->crc2);
> +
> +			igt_assert_crc_equal(&d->crc1, &d->crc2);
> +		}
> +
> +		/*
> +		 * Non-CRC tests:
> +		 * Mimicing some not exactly but closer to some real usage
> +		 */
> +
> +		/* set up data for fb2: both fb1_nv12, fb2_nv12 uses this */
> +		paint_image(d, &d->fb2, img_width, img_height);
> +
> +		/* set up data in fb1_nv12: fb2 RGB-> fb1_nv12 */
> +		igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb1_nv12, &d->fb2);
> +
> +		/* set up data in fb2_nv12: fb2 RGB-> fb2_nv12 */
> +		igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb2_nv12, &d->fb2);
> +
> +		/* set up data in fb3 */
> +		paint_pattern(d, &d->fb3, d->fb3.width, d->fb3.height);
> +
> +		/* Set up fb2_nv12->plane2 mapping. */
> +		igt_plane_set_fb(d->plane2, &d->fb2_nv12);
> +		/* 2nd plane nv12 windowed - no scaling */
> +		igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
> +		igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
> +			d->fb2_nv12.height);
> +		igt_plane_set_position(d->plane2, 0, 0);
> +		igt_plane_set_size(d->plane2, d->fb2_nv12.width, d->fb2_nv12.height);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* Change primary plane to nv12 full screen: scaling + NV12 */
> +		igt_plane_set_fb(d->plane1, &d->fb1_nv12);
> +		igt_fb_set_position(&d->fb1_nv12, d->plane1, 0, 0);
> +		igt_fb_set_size(&d->fb1_nv12, d->plane1, d->fb1_nv12.width,
> +			d->fb1_nv12.height);
> +		igt_plane_set_position(d->plane1, 0, 0);
> +		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* Set up fb3->plane3 mapping. */
> +		igt_plane_set_fb(d->plane3, &d->fb3);
> +
> +		/* 3rd plane full screen - no scaling. */
> +		igt_fb_set_position(&d->fb3, d->plane3, 0, 0);
> +		igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width, d->fb3.height);
> +		igt_plane_set_position(d->plane3, 0, 0);
> +		igt_plane_set_size(d->plane3, d->fb3.width, d->fb3.height);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* 2nd plane nv12 up scaling */
> +		igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
> +		igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
> +			d->fb2_nv12.height);
> +		igt_plane_set_position(d->plane2, 100, 100);
> +		igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* 2nd plane nv12 down scaling */
> +		igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
> +		igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
> +			d->fb2_nv12.height);
> +		igt_plane_set_position(d->plane2, 1024, 0);
> +		igt_plane_set_size(d->plane2, d->fb2_nv12.width * 2/3,
> +			d->fb2_nv12.height * 2/3);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* Back to single plane mode  - rgb & no scaling */
> +		igt_plane_set_fb(d->plane1, &d->fb1);
> +		igt_plane_set_fb(d->plane2, NULL);
> +		igt_plane_set_fb(d->plane3, NULL);
> +		igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
> +		igt_fb_set_size(&d->fb1, d->plane1, mode->hdisplay, mode->vdisplay);
> +		igt_plane_set_position(d->plane1, 0, 0);
> +		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* single plane mode  - rgb & scaling */
> +		igt_plane_set_fb(d->plane1, &d->fb1);
> +		igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
> +		igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width/2, d->fb1.height/2);
> +		igt_plane_set_position(d->plane1, 0, 0);
> +		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		/* single plane mode  - nv12 & scaling */
> +		igt_plane_set_fb(d->plane1, &d->fb1_nv12);
> +		igt_fb_set_position(&d->fb1_nv12, d->plane1, 0, 0);
> +		igt_fb_set_size(&d->fb1_nv12, d->plane1, d->fb1_nv12.width,
> +			d->fb1_nv12.height);
> +		igt_plane_set_position(d->plane1, 0, 0);
> +		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
> +		igt_display_commit2(display, COMMIT_UNIVERSAL);
> +
> +		valid_tests++;
> +
> +		cleanup_crtc(d, output, d->plane1);
> +	}
> +	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
> +}
> +
> +static void test_nv12_unsupported_plane(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) {
> +		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);
> +		prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_LEGACY);
> +
> +		d->fb_id3_nv12 = igt_create_fb(d->drm_fd,
> +				1920, 1080,
> +				DRM_FORMAT_NV12,
> +				d->tiled,
> +				&d->fb3_nv12);
> +		igt_assert(d->fb_id3_nv12);
> +
> +		/* Set up fb3_nv12->plane3 mapping. */
> +		d->plane2 = igt_output_get_plane(output, IGT_PLANE_3);
> +		igt_plane_set_fb(d->plane3, &d->fb3_nv12);
> +
> +		/* 3rd plane nv12 windowed - no scaling */
> +		igt_fb_set_position(&d->fb3_nv12, d->plane3, 0, 0);
> +		igt_fb_set_size(&d->fb3_nv12, d->plane3, d->fb3_nv12.width,
> +			d->fb3_nv12.height);
> +		igt_plane_set_position(d->plane3, 0, 0);
> +		igt_plane_set_size(d->plane3, d->fb3_nv12.width, d->fb3_nv12.height);
> +
> +		/* Should fail because NV12 is not supported on plane 3 */
> +		igt_assert(igt_display_try_commit2(display, COMMIT_UNIVERSAL)
> +			== -EINVAL);
> +
> +		valid_tests++;
> +
> +		igt_plane_set_fb(d->plane3, NULL);
> +		cleanup_crtc(d, output, d->plane1);
> +	}
> +	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
> +}
> +
> +igt_main
> +{
> +	data_t data = {};
> +
> +	igt_skip_on_simulation();
> +
> +	igt_fixture {
> +		data.drm_fd = drm_open_any();
> +
> +		kmstest_set_vt_graphics_mode();
> +
> +		igt_require_pipe_crc();
> +
> +		igt_display_init(&data.display, data.drm_fd);
> +	}
> +	devid = intel_get_drm_devid(data.drm_fd);
> +
> +	data.num_scalers = intel_gen(devid) >= 9 ? 2 : 0;
> +
> +	data.crc = 1;
> +	data.rotation = IGT_ROTATION_0;
> +	igt_subtest_f("nv12-plane-linear") {
> +		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
> +		test_nv12_plane(&data);
> +	}
> +	igt_subtest_f("nv12-plane-tile-x") {
> +		data.tiled = LOCAL_I915_FORMAT_MOD_X_TILED;
> +		test_nv12_plane(&data);
> +	}
> +	igt_subtest_f("nv12-plane-tile-y") {
> +		data.tiled = LOCAL_I915_FORMAT_MOD_Y_TILED;
> +		test_nv12_plane(&data);
> +	}
> +	igt_subtest_f("nv12-plane-tile-yf") {
> +		data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED;
> +		test_nv12_plane(&data);
> +	}
> +
> +	data.rotation = IGT_ROTATION_180;
> +	igt_subtest_f("nv12-plane-linear-rot-180") {
> +		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
> +		test_nv12_plane(&data);
> +	}
> +	igt_subtest_f("nv12-plane-tile-x-rot-180") {
> +		data.tiled = LOCAL_I915_FORMAT_MOD_X_TILED;
> +		test_nv12_plane(&data);
> +	}
> +	igt_subtest_f("nv12-plane-tile-y-rot-180") {
> +		data.tiled = LOCAL_I915_FORMAT_MOD_Y_TILED;
> +		test_nv12_plane(&data);
> +	}
> +	igt_subtest_f("nv12-plane-tile-yf-rot-180") {
> +		data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED;
> +		test_nv12_plane(&data);
> +	}
> +
> +	igt_subtest_f("nv12-on-unsupported-plane") {
> +		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
> +		test_nv12_unsupported_plane(&data);
> +	}
> +
> +	igt_fixture {
> +		igt_display_fini(&data.display);
> +	}
> +}
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/tests/.gitignore b/tests/.gitignore
index 796e330..35c0e6e 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -147,6 +147,7 @@  kms_vblank
 kms_crtc_background_color
 kms_plane_scaling
 kms_panel_fitting
+kms_nv12
 pm_lpsp
 pm_rc6_residency
 pm_rpm
diff --git a/tests/Android.mk b/tests/Android.mk
index fac9931..c0c6383 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -81,6 +81,7 @@  else
     kms_pwrite_crc \
     kms_pipe_b_c_ivb \
     kms_legacy_colorkey
+	kms_nv12 \
     IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0
 endif
 
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 4cbc50d..b68224e 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -78,6 +78,7 @@  TESTS_progs_M = \
 	kms_crtc_background_color \
 	kms_plane_scaling \
 	kms_panel_fitting \
+	kms_nv12 \
 	pm_lpsp \
 	pm_rpm \
 	pm_rps \
diff --git a/tests/kms_nv12.c b/tests/kms_nv12.c
new file mode 100644
index 0000000..e88c934
--- /dev/null
+++ b/tests/kms_nv12.c
@@ -0,0 +1,529 @@ 
+/*
+ * 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;
+	igt_crc_t crc1;
+	igt_crc_t crc2;
+	igt_pipe_crc_t *pipe_crc;
+	int num_scalers;
+
+	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;
+	int crc;
+} data_t;
+
+#define IMG_FILE  "1080p-left.png"
+#define SOLID_COLOR      0xFFFFFF       /* BGR 8bpc */
+
+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
+paint_solid_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h,
+	uint32_t color)
+{
+	cairo_t *cr;
+	double r, g, b;
+
+	cr = igt_get_cairo_ctx(d->drm_fd, fb);
+
+	/* Paint with solid color */
+	r = (double) (color & 0xFF) / 255.0;
+	g = (double) ((color & 0xFF00) >> 8) / 255.0;
+	b = (double) ((color & 0xFF0000) >> 16) / 255.0;
+	igt_paint_color(cr, 0, 0, w, h, r, g, b);
+
+	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);
+
+	/* create the pipe_crc object for this pipe */
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	/* 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_XRGB8888,
+			LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
+			&data->fb1);
+	igt_assert(data->fb_id1);
+
+	paint_pattern(data, &data->fb1, mode->hdisplay, mode->vdisplay);
+
+	/*
+	 * We always set the primary plane to actually enable the pipe as
+	 * there's no way (that works) to light up a pipe with only a sprite
+	 * plane enabled at the moment.
+	 */
+	if (!plane->is_primary) {
+		igt_plane_t *primary;
+
+		primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+		igt_plane_set_fb(primary, &data->fb1);
+	}
+
+	igt_plane_set_fb(plane, &data->fb1);
+	if (s == COMMIT_LEGACY) {
+		int ret;
+		ret = drmModeSetCrtc(data->drm_fd,
+				output->config.crtc->crtc_id,
+				data->fb_id1,
+				plane->pan_x, plane->pan_y,
+				&output->id,
+				1,
+				mode);
+		igt_assert(ret == 0);
+	} else {
+		igt_display_commit2(display, s);
+	}
+}
+
+static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = NULL;
+
+	if (data->fb_id1) {
+		igt_remove_fb(data->drm_fd, &data->fb1);
+		data->fb_id1 = 0;
+	}
+	if (data->fb_id2) {
+		igt_remove_fb(data->drm_fd, &data->fb2);
+		data->fb_id2 = 0;
+	}
+	if (data->fb_id3) {
+		igt_remove_fb(data->drm_fd, &data->fb3);
+		data->fb_id3 = 0;
+	}
+
+	if (data->fb_id1_nv12) {
+		igt_remove_fb(data->drm_fd, &data->fb1_nv12);
+		data->fb_id1_nv12 = 0;
+	}
+
+	if (data->fb_id2_nv12) {
+		igt_remove_fb(data->drm_fd, &data->fb2_nv12);
+		data->fb_id2_nv12 = 0;
+	}
+
+	if (data->fb_id3_nv12) {
+		igt_remove_fb(data->drm_fd, &data->fb3_nv12);
+		data->fb_id3_nv12 = 0;
+	}
+
+	if (!plane->is_primary) {
+		igt_plane_t *primary;
+
+		primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+		igt_plane_set_fb(primary, NULL);
+	}
+
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_ANY);
+
+	igt_display_commit2(display, COMMIT_UNIVERSAL);
+}
+
+static void test_nv12_plane(data_t *d)
+{
+	igt_display_t *display = &d->display;
+	igt_output_t *output;
+	enum pipe pipe;
+	int valid_tests = 0;
+	int img_width;
+	int img_height;
+
+	igt_require(d->display.has_universal_planes);
+	igt_require(d->num_scalers);
+
+	for_each_connected_output(display, output) {
+		drmModeModeInfo *mode;
+		mode = igt_output_get_mode(output);
+		pipe = output->config.pipe;
+
+		igt_output_set_pipe(output, pipe);
+
+		/* get planes */
+		d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+		d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
+		d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
+
+		/* set required rotation */
+		igt_plane_set_rotation(d->plane1, d->rotation);
+		igt_plane_set_rotation(d->plane2, d->rotation);
+		igt_plane_set_rotation(d->plane3, d->rotation);
+
+		/* Set up display with plane 1 */
+		prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_LEGACY);
+
+		/* allocate fb2, fb2_nv12, fb1_nv12 with image size */
+		igt_get_image_size(IMG_FILE, &img_width, &img_height);
+
+		/* fb2 is in RGB format */
+		d->fb_id2 = igt_create_fb(d->drm_fd,
+				img_width, img_height,
+				DRM_FORMAT_XRGB8888,
+				d->tiled, /* tiled */
+				&d->fb2);
+		igt_assert(d->fb_id2);
+
+		/* fb1_nv12 is in NV12 format */
+		d->fb_id1_nv12 = igt_create_fb(d->drm_fd,
+				img_width, img_height,
+				DRM_FORMAT_NV12,
+				d->tiled, /* tiled */
+				&d->fb1_nv12);
+		igt_assert(d->fb_id1_nv12);
+
+		/* fb2_nv12 is in NV12 format */
+		d->fb_id2_nv12 = igt_create_fb(d->drm_fd,
+				img_width, img_height,
+				DRM_FORMAT_NV12,
+				d->tiled,
+				&d->fb2_nv12);
+		igt_assert(d->fb_id2_nv12);
+
+		/* fb3 is in RGB */
+		d->fb_id3 = igt_create_fb(d->drm_fd,
+				mode->hdisplay, mode->vdisplay,
+				DRM_FORMAT_ARGB8888,
+				d->tiled, /* tiled */
+				&d->fb3);
+		igt_assert(d->fb_id3);
+
+		if (d->crc) {
+			/*
+			 * CRC test:
+			 * 1st CRC: plane 1: RGB FS, plane 2: RGB 19x10  --> CRC1
+			 * 2nd CRC: plane 1: RGB FS, plane 2: NV12 19x10 --> CRC2
+			 * make sure CRC1 == CRC2
+			 *
+			 * For CRCs to work, cannot use any image/data because
+			 * chrome-upsampling can fail CRC comparison.
+			 * Though it is a very basic, solid color is expected to work
+			 */
+			paint_solid_color(d, &d->fb2, d->fb2.width, d->fb2.height,
+				SOLID_COLOR);
+
+			/* Setup to capture CRC1 when plane 2 is in RGB mode */
+			igt_plane_set_fb(d->plane2, &d->fb2);
+			igt_fb_set_position(&d->fb2, d->plane2, 0, 0);
+			igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width, d->fb2.height);
+			igt_plane_set_position(d->plane2, 0, 0);
+			igt_plane_set_size(d->plane2, d->fb2.width, d->fb2.height);
+			igt_display_commit2(display, COMMIT_UNIVERSAL);
+			igt_pipe_crc_collect_crc(d->pipe_crc, &d->crc1);
+
+			/* Setup to capture CRC2 when plane 2 is in NV12 mode */
+			igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb2_nv12, &d->fb2);
+			igt_plane_set_fb(d->plane2, &d->fb2_nv12);
+			igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
+			igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
+				d->fb2_nv12.height);
+			igt_plane_set_position(d->plane2, 0, 0);
+			igt_plane_set_size(d->plane2, d->fb2_nv12.width,d->fb2_nv12.height);
+			igt_display_commit2(display, COMMIT_UNIVERSAL);
+			igt_pipe_crc_collect_crc(d->pipe_crc, &d->crc2);
+
+			igt_assert_crc_equal(&d->crc1, &d->crc2);
+		}
+
+		/*
+		 * Non-CRC tests:
+		 * Mimicing some not exactly but closer to some real usage
+		 */
+
+		/* set up data for fb2: both fb1_nv12, fb2_nv12 uses this */
+		paint_image(d, &d->fb2, img_width, img_height);
+
+		/* set up data in fb1_nv12: fb2 RGB-> fb1_nv12 */
+		igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb1_nv12, &d->fb2);
+
+		/* set up data in fb2_nv12: fb2 RGB-> fb2_nv12 */
+		igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb2_nv12, &d->fb2);
+
+		/* set up data in fb3 */
+		paint_pattern(d, &d->fb3, d->fb3.width, d->fb3.height);
+
+		/* Set up fb2_nv12->plane2 mapping. */
+		igt_plane_set_fb(d->plane2, &d->fb2_nv12);
+		/* 2nd plane nv12 windowed - no scaling */
+		igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
+		igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
+			d->fb2_nv12.height);
+		igt_plane_set_position(d->plane2, 0, 0);
+		igt_plane_set_size(d->plane2, d->fb2_nv12.width, d->fb2_nv12.height);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* Change primary plane to nv12 full screen: scaling + NV12 */
+		igt_plane_set_fb(d->plane1, &d->fb1_nv12);
+		igt_fb_set_position(&d->fb1_nv12, d->plane1, 0, 0);
+		igt_fb_set_size(&d->fb1_nv12, d->plane1, d->fb1_nv12.width,
+			d->fb1_nv12.height);
+		igt_plane_set_position(d->plane1, 0, 0);
+		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* Set up fb3->plane3 mapping. */
+		igt_plane_set_fb(d->plane3, &d->fb3);
+
+		/* 3rd plane full screen - no scaling. */
+		igt_fb_set_position(&d->fb3, d->plane3, 0, 0);
+		igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width, d->fb3.height);
+		igt_plane_set_position(d->plane3, 0, 0);
+		igt_plane_set_size(d->plane3, d->fb3.width, d->fb3.height);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* 2nd plane nv12 up scaling */
+		igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
+		igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
+			d->fb2_nv12.height);
+		igt_plane_set_position(d->plane2, 100, 100);
+		igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* 2nd plane nv12 down scaling */
+		igt_fb_set_position(&d->fb2_nv12, d->plane2, 0, 0);
+		igt_fb_set_size(&d->fb2_nv12, d->plane2, d->fb2_nv12.width,
+			d->fb2_nv12.height);
+		igt_plane_set_position(d->plane2, 1024, 0);
+		igt_plane_set_size(d->plane2, d->fb2_nv12.width * 2/3,
+			d->fb2_nv12.height * 2/3);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* Back to single plane mode  - rgb & no scaling */
+		igt_plane_set_fb(d->plane1, &d->fb1);
+		igt_plane_set_fb(d->plane2, NULL);
+		igt_plane_set_fb(d->plane3, NULL);
+		igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
+		igt_fb_set_size(&d->fb1, d->plane1, mode->hdisplay, mode->vdisplay);
+		igt_plane_set_position(d->plane1, 0, 0);
+		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* single plane mode  - rgb & scaling */
+		igt_plane_set_fb(d->plane1, &d->fb1);
+		igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
+		igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width/2, d->fb1.height/2);
+		igt_plane_set_position(d->plane1, 0, 0);
+		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		/* single plane mode  - nv12 & scaling */
+		igt_plane_set_fb(d->plane1, &d->fb1_nv12);
+		igt_fb_set_position(&d->fb1_nv12, d->plane1, 0, 0);
+		igt_fb_set_size(&d->fb1_nv12, d->plane1, d->fb1_nv12.width,
+			d->fb1_nv12.height);
+		igt_plane_set_position(d->plane1, 0, 0);
+		igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		valid_tests++;
+
+		cleanup_crtc(d, output, d->plane1);
+	}
+	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
+}
+
+static void test_nv12_unsupported_plane(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) {
+		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);
+		prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_LEGACY);
+
+		d->fb_id3_nv12 = igt_create_fb(d->drm_fd,
+				1920, 1080,
+				DRM_FORMAT_NV12,
+				d->tiled,
+				&d->fb3_nv12);
+		igt_assert(d->fb_id3_nv12);
+
+		/* Set up fb3_nv12->plane3 mapping. */
+		d->plane2 = igt_output_get_plane(output, IGT_PLANE_3);
+		igt_plane_set_fb(d->plane3, &d->fb3_nv12);
+
+		/* 3rd plane nv12 windowed - no scaling */
+		igt_fb_set_position(&d->fb3_nv12, d->plane3, 0, 0);
+		igt_fb_set_size(&d->fb3_nv12, d->plane3, d->fb3_nv12.width,
+			d->fb3_nv12.height);
+		igt_plane_set_position(d->plane3, 0, 0);
+		igt_plane_set_size(d->plane3, d->fb3_nv12.width, d->fb3_nv12.height);
+
+		/* Should fail because NV12 is not supported on plane 3 */
+		igt_assert(igt_display_try_commit2(display, COMMIT_UNIVERSAL)
+			== -EINVAL);
+
+		valid_tests++;
+
+		igt_plane_set_fb(d->plane3, NULL);
+		cleanup_crtc(d, output, d->plane1);
+	}
+	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
+}
+
+igt_main
+{
+	data_t data = {};
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		data.drm_fd = drm_open_any();
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_require_pipe_crc();
+
+		igt_display_init(&data.display, data.drm_fd);
+	}
+	devid = intel_get_drm_devid(data.drm_fd);
+
+	data.num_scalers = intel_gen(devid) >= 9 ? 2 : 0;
+
+	data.crc = 1;
+	data.rotation = IGT_ROTATION_0;
+	igt_subtest_f("nv12-plane-linear") {
+		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
+		test_nv12_plane(&data);
+	}
+	igt_subtest_f("nv12-plane-tile-x") {
+		data.tiled = LOCAL_I915_FORMAT_MOD_X_TILED;
+		test_nv12_plane(&data);
+	}
+	igt_subtest_f("nv12-plane-tile-y") {
+		data.tiled = LOCAL_I915_FORMAT_MOD_Y_TILED;
+		test_nv12_plane(&data);
+	}
+	igt_subtest_f("nv12-plane-tile-yf") {
+		data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED;
+		test_nv12_plane(&data);
+	}
+
+	data.rotation = IGT_ROTATION_180;
+	igt_subtest_f("nv12-plane-linear-rot-180") {
+		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
+		test_nv12_plane(&data);
+	}
+	igt_subtest_f("nv12-plane-tile-x-rot-180") {
+		data.tiled = LOCAL_I915_FORMAT_MOD_X_TILED;
+		test_nv12_plane(&data);
+	}
+	igt_subtest_f("nv12-plane-tile-y-rot-180") {
+		data.tiled = LOCAL_I915_FORMAT_MOD_Y_TILED;
+		test_nv12_plane(&data);
+	}
+	igt_subtest_f("nv12-plane-tile-yf-rot-180") {
+		data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED;
+		test_nv12_plane(&data);
+	}
+
+	igt_subtest_f("nv12-on-unsupported-plane") {
+		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
+		test_nv12_unsupported_plane(&data);
+	}
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
+}