From: chandra konduru <chandra.kond...@intel.com>

This patch is adding i-g-t plane scaling test case to test couple basic
display plane scaling usages. Additional test scenarios can be added later.

v2:
-Added iterative scaling to visually observe scaling (me)

v3:
-Added a flag to control primary plane scaling.

Signed-off-by: chandra konduru <chandra.kond...@intel.com>
---
 lib/igt_fb.h              |    4 +
 lib/igt_kms.c             |  122 +++++++++++++--
 lib/igt_kms.h             |    5 +
 tests/.gitignore          |    1 +
 tests/Android.mk          |    1 +
 tests/Makefile.sources    |    1 +
 tests/kms_plane_scaling.c |  370 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 488 insertions(+), 16 deletions(-)
 create mode 100644 tests/kms_plane_scaling.c

diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index d9fb6bb..c21d1d0 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -54,6 +54,10 @@ struct igt_fb {
        unsigned tiling;
        unsigned size;
        cairo_surface_t *cairo_surface;
+       uint32_t src_x;
+       uint32_t src_y;
+       uint32_t src_w;
+       uint32_t src_h;
 };
 
 enum igt_text_align {
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 72841ef..895830b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1299,6 +1299,14 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
        igt_display_t *display = output->display;
        uint32_t fb_id, crtc_id;
        int ret;
+       uint32_t src_x;
+       uint32_t src_y;
+       uint32_t src_w;
+       uint32_t src_h;
+       int32_t crtc_x;
+       int32_t crtc_y;
+       uint32_t crtc_w;
+       uint32_t crtc_h;
 
        igt_assert(plane->drm_plane);
 
@@ -1329,32 +1337,43 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
                                      IGT_FIXED(0,0) /* src_h */);
 
                CHECK_RETURN(ret, fail_on_error);
-       } else if (plane->fb_changed || plane->position_changed) {
+       } else if (plane->fb_changed || plane->position_changed ||
+               plane->size_changed) {
+               src_x = IGT_FIXED(plane->fb->src_x,0); /* src_x */
+               src_y = IGT_FIXED(plane->fb->src_y,0); /* src_y */
+               src_w = IGT_FIXED(plane->fb->src_w,0); /* src_w */
+               src_h = IGT_FIXED(plane->fb->src_h,0); /* src_h */
+               crtc_x = plane->crtc_x;
+               crtc_y = plane->crtc_y;
+               crtc_w = plane->crtc_w;
+               crtc_h = plane->crtc_h;
+
                LOG(display,
-                   "%s: SetPlane %s.%d, fb %u, position (%d, %d)\n",
+                   "%s: SetPlane %s.%d, fb %u, src = (%d, %d) "
+                       "%ux%u dst = (%u, %u) %ux%u\n",
                    igt_output_name(output),
                    kmstest_pipe_name(output->config.pipe),
                    plane->index,
                    fb_id,
-                   plane->crtc_x, plane->crtc_y);
+                   src_x >> 16, src_y >> 16, src_w >> 16, src_h >> 16,
+                   crtc_x, crtc_y, crtc_w, crtc_h);
 
                ret = drmModeSetPlane(display->drm_fd,
                                      plane->drm_plane->plane_id,
                                      crtc_id,
                                      fb_id,
                                      0,    /* flags */
-                                     plane->crtc_x, plane->crtc_y,
-                                     plane->crtc_w, plane->crtc_h,
-                                     IGT_FIXED(0,0), /* src_x */
-                                     IGT_FIXED(0,0), /* src_y */
-                                     IGT_FIXED(plane->fb->width,0), /* src_w */
-                                     IGT_FIXED(plane->fb->height,0) /* src_h 
*/);
+                                     crtc_x, crtc_y,
+                                     crtc_w, crtc_h,
+                                     src_x, src_y,
+                                     src_w, src_h);
 
                CHECK_RETURN(ret, fail_on_error);
        }
 
        plane->fb_changed = false;
        plane->position_changed = false;
+       plane->size_changed = false;
 
        if (plane->rotation_changed) {
                igt_plane_set_property(plane, plane->rotation_property,
@@ -1449,7 +1468,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t 
*primary,
        igt_assert(!primary->rotation_changed);
 
        if (!primary->fb_changed && !primary->position_changed &&
-           !primary->panning_changed)
+               !primary->size_changed && !primary->panning_changed)
                return 0;
 
        crtc_id = output->config.crtc->crtc_id;
@@ -1496,6 +1515,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t 
*primary,
        primary->pipe->enabled = (fb_id != 0);
        primary->fb_changed = false;
        primary->position_changed = false;
+       primary->size_changed = false;
        primary->panning_changed = false;
 
        return 0;
@@ -1553,7 +1573,7 @@ static int igt_output_commit(igt_output_t *output,
        for (i = 0; i < pipe->n_planes; i++) {
                igt_plane_t *plane = &pipe->planes[i];
 
-               if (plane->fb_changed || plane->position_changed)
+               if (plane->fb_changed || plane->position_changed || 
plane->size_changed)
                        need_wait_for_vblank = true;
 
                ret = igt_plane_commit(plane, output, s, fail_on_error);
@@ -1722,7 +1742,22 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb 
*fb)
                plane->crtc_h = 0;
        }
 
+       if (fb) {
+               /* set default plane pos/size as fb size */
+               plane->crtc_x = 0;
+               plane->crtc_y = 0;
+               plane->crtc_w = fb->width;
+               plane->crtc_h = fb->height;
+
+               /* set default src pos/size as fb size */
+               fb->src_x = 0;
+               fb->src_y = 0;
+               fb->src_w = fb->width;
+               fb->src_h = fb->height;
+       }
+
        plane->fb_changed = true;
+       plane->size_changed = true;
 }
 
 void igt_plane_set_position(igt_plane_t *plane, int x, int y)
@@ -1739,21 +1774,76 @@ void igt_plane_set_position(igt_plane_t *plane, int x, 
int y)
        plane->position_changed = true;
 }
 
+/**
+ * igt_plane_set_size:
+ * @plane: plane pointer for which size to be set
+ * @w: width
+ * @h: height
+ *
+ * This function sets width and height for requested plane.
+ * New size will be commited at plane commit time via
+ * drmModeSetPlane().
+ */
 void igt_plane_set_size(igt_plane_t *plane, int w, int h)
 {
        igt_pipe_t *pipe = plane->pipe;
        igt_display_t *display = pipe->display;
 
-       LOG(display, "%s.%d: plane_set_size(%d,%d)\n",
+       LOG(display, "%s.%d: plane_set_size (%dx%d)\n",
            kmstest_pipe_name(pipe->pipe), plane->index, w, h);
 
        plane->crtc_w = w;
        plane->crtc_h = h;
 
-       /*
-        * must be fb_changed so that legacy cursors call
-        * drmModeSetCursor() instead of drmModeMoveCursor()
-        */
+       plane->size_changed = true;
+}
+
+/**
+ * igt_fb_set_position:
+ * @fb: framebuffer pointer
+ * @x: X position
+ * @y: Y position
+ *
+ * This function sets position for requested framebuffer as src to plane.
+ * New position will be commited at plane commit time via drmModeSetPlane().
+ */
+void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,
+       uint32_t x, uint32_t y)
+{
+       igt_pipe_t *pipe = plane->pipe;
+       igt_display_t *display = pipe->display;
+
+       LOG(display, "%s.%d: fb_set_position(%d,%d)\n",
+           kmstest_pipe_name(pipe->pipe), plane->index, x, y);
+
+       fb->src_x = x;
+       fb->src_y = y;
+
+       plane->fb_changed = true;
+}
+
+/**
+ * igt_fb_set_position:
+ * @fb: framebuffer pointer
+ * @w: width
+ * @h: height
+ *
+ * This function sets fetch rect size from requested framebuffer as src
+ * to plane. New size will be commited at plane commit time via
+ * drmModeSetPlane().
+ */
+void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
+       uint32_t w, uint32_t h)
+{
+       igt_pipe_t *pipe = plane->pipe;
+       igt_display_t *display = pipe->display;
+
+       LOG(display, "%s.%d: fb_set_position(%dx%d)\n",
+           kmstest_pipe_name(pipe->pipe), plane->index, w, h);
+
+       fb->src_w = w;
+       fb->src_h = h;
+
        plane->fb_changed = true;
 }
 
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4fada1b..2dde5d3 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -181,6 +181,7 @@ typedef struct {
        unsigned int position_changed : 1;
        unsigned int panning_changed  : 1;
        unsigned int rotation_changed : 1;
+       unsigned int size_changed     : 1;
        /*
         * drm_plane can be NULL for primary and cursor planes (when not
         * using the atomic modeset API)
@@ -255,6 +256,10 @@ void igt_plane_set_size(igt_plane_t *plane, int w, int h);
 void igt_plane_set_panning(igt_plane_t *plane, int x, int y);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
 void igt_crtc_set_background(igt_pipe_t *pipe, uint64_t background);
+void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,
+       uint32_t x, uint32_t y);
+void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
+       uint32_t w, uint32_t h);
 
 void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
 
diff --git a/tests/.gitignore b/tests/.gitignore
index 69d2ba0..d1381cd 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -138,6 +138,7 @@ kms_setmode
 kms_sink_crc_basic
 kms_universal_plane
 kms_crtc_background_color
+kms_plane_scaling
 multi-tests.txt
 pm_lpsp
 pm_psr
diff --git a/tests/Android.mk b/tests/Android.mk
index 96a32b9..c024296 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -76,6 +76,7 @@ else
     kms_force_connector \
     kms_flip_event_leak \
     kms_crtc_background_color \
+    kms_plane_scaling \
     kms_pwrite_crc
     IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0
 endif
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 4f612e6..460df02 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -78,6 +78,7 @@ TESTS_progs_M = \
        kms_setmode \
        kms_universal_plane \
        kms_crtc_background_color \
+       kms_plane_scaling \
        pm_lpsp \
        pm_rpm \
        pm_rps \
diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
new file mode 100644
index 0000000..180ff5e
--- /dev/null
+++ b/tests/kms_plane_scaling.c
@@ -0,0 +1,370 @@
+/*
+ * 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 "drmtest.h"
+#include "igt_debugfs.h"
+#include "igt_kms.h"
+#include "igt_core.h"
+#include "intel_chipset.h"
+#include "igt_aux.h"
+
+IGT_TEST_DESCRIPTION("Test display plane scaling");
+
+typedef struct {
+       uint32_t devid;
+       int drm_fd;
+       igt_display_t display;
+       igt_crc_t ref_crc;
+       igt_pipe_crc_t *pipe_crc;
+
+       int image_w;
+       int image_h;
+
+       int num_scalers;
+
+       struct igt_fb fb1;
+       struct igt_fb fb2;
+       struct igt_fb fb3;
+       int fb_id1;
+       int fb_id2;
+       int fb_id3;
+
+       igt_plane_t *plane1;
+       igt_plane_t *plane2;
+       igt_plane_t *plane3;
+       igt_plane_t *plane4;
+} data_t;
+
+#define FILE_NAME   "1080p-left.png"
+
+static void
+paint_color(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, FILE_NAME, 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);
+
+       /* 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,
+                       true, /* tiled */
+                       &data->fb1);
+       igt_assert(data->fb_id1);
+
+       paint_color(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 (!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);
+}
+
+/* does iterative scaling on plane2 */
+static void iterate_plane_scaling(data_t *d, drmModeModeInfo *mode)
+{
+       igt_display_t *display = &d->display;
+
+       if (mode->hdisplay >= d->fb2.width) {
+               int w, h;
+               /* fixed fb */
+               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);
+
+               /* adjust plane size */
+               for (w = d->fb2.width; w <= mode->hdisplay; w+=10) {
+                       h = w * d->fb2.height / d->fb2.width;
+                       igt_plane_set_size(d->plane2, w, h);
+                       igt_display_commit2(display, COMMIT_UNIVERSAL);
+               }
+       } else {
+               int w, h;
+               /* fixed plane */
+               igt_plane_set_position(d->plane2, 0, 0);
+               igt_plane_set_size(d->plane2, mode->hdisplay, mode->vdisplay);
+               igt_fb_set_position(&d->fb2, d->plane2, 0, 0);
+
+               /* adjust fb size */
+               for (w = mode->hdisplay; w <= d->fb2.width; w+=10) {
+                       h = w * mode->hdisplay / mode->vdisplay;
+                       igt_fb_set_size(&d->fb2, d->plane2, w, h);
+                       igt_display_commit2(display, COMMIT_UNIVERSAL);
+               }
+       }
+}
+
+static void test_plane_scaling(data_t *d)
+{
+       igt_display_t *display = &d->display;
+       igt_output_t *output;
+       cairo_surface_t *image;
+       enum pipe pipe;
+       int valid_tests = 0;
+       int primary_plane_scaling = 0; /* For now */
+
+       igt_require(d->display.has_universal_planes);
+       igt_require(d->num_scalers);
+
+       for_each_connected_output(display, output) {
+               drmModeModeInfo *mode;
+
+               pipe = output->config.pipe;
+               igt_output_set_pipe(output, pipe);
+
+               mode = igt_output_get_mode(output);
+
+               /* allocate fb2 with image size */
+               image = cairo_image_surface_create_from_png(FILE_NAME);
+               igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
+               d->image_w = cairo_image_surface_get_width(image);
+               d->image_h = cairo_image_surface_get_height(image);
+               cairo_surface_destroy(image);
+
+               d->fb_id2 = igt_create_fb(d->drm_fd,
+                               d->image_w, d->image_h,
+                               DRM_FORMAT_XRGB8888,
+                               true, /* tiled */
+                               &d->fb2);
+               igt_assert(d->fb_id2);
+               paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);
+
+               d->fb_id3 = igt_create_fb(d->drm_fd,
+                               mode->hdisplay, mode->vdisplay,
+                               DRM_FORMAT_XRGB8888,
+                               true, /* tiled */
+                               &d->fb3);
+               igt_assert(d->fb_id3);
+               paint_color(d, &d->fb3, mode->hdisplay, mode->vdisplay);
+
+               /* 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_UNIVERSAL);
+
+               if (primary_plane_scaling) {
+                       /* Primary plane upscaling */
+                       igt_fb_set_position(&d->fb1, d->plane1, 100, 100);
+                       igt_fb_set_size(&d->fb1, d->plane1, 500, 500);
+                       igt_plane_set_position(d->plane1, 0, 0);
+                       igt_plane_set_size(d->plane1, mode->hdisplay, 
mode->vdisplay);
+                       igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+                       /* Primary plane 1:1 no scaling */
+                       igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
+                       igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, 
d->fb1.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 fb2->plane2 mapping. */
+               d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
+               igt_plane_set_fb(d->plane2, &d->fb2);
+
+               /* 2nd plane windowed */
+               igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
+               igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, 
d->fb2.height-200);
+               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);
+
+               iterate_plane_scaling(d, mode);
+
+               /* 2nd plane up scaling */
+               igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
+               igt_fb_set_size(&d->fb2, d->plane2, 500, 500);
+               igt_plane_set_position(d->plane2, 10, 10);
+               igt_plane_set_size(d->plane2, mode->hdisplay-20, 
mode->vdisplay-20);
+               igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+               /* 2nd plane downscaling */
+               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, 10, 10);
+               igt_plane_set_size(d->plane2, 500, 500 * 
d->fb2.height/d->fb2.width);
+               igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+               if (primary_plane_scaling) {
+                       /* Primary plane up scaling */
+                       igt_fb_set_position(&d->fb1, d->plane1, 100, 100);
+                       igt_fb_set_size(&d->fb1, d->plane1, 500, 500);
+                       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. */
+               d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
+               igt_plane_set_fb(d->plane3, &d->fb3);
+
+               /* 3rd plane windowed - no scaling */
+               igt_fb_set_position(&d->fb3, d->plane3, 100, 100);
+               igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-300, 
d->fb3.height-300);
+               igt_plane_set_position(d->plane3, 100, 100);
+               igt_plane_set_size(d->plane3, mode->hdisplay-300, 
mode->vdisplay-300);
+               igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+               /* Switch scaler from plane 2 to plane 3 */
+               igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
+               igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, 
d->fb2.height-200);
+               igt_plane_set_position(d->plane2, 100, 100);
+               igt_plane_set_size(d->plane2, d->fb2.width-200, 
d->fb2.height-200);
+
+               igt_fb_set_position(&d->fb3, d->plane3, 100, 100);
+               igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-400, 
d->fb3.height-400);
+               igt_plane_set_position(d->plane3, 10, 10);
+               igt_plane_set_size(d->plane3, mode->hdisplay-300, 
mode->vdisplay-300);
+               igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+               if (primary_plane_scaling) {
+                       /* Switch scaler from plane 1 to plane 2 */
+                       igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
+                       igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, 
d->fb1.height);
+                       igt_plane_set_position(d->plane1, 0, 0);
+                       igt_plane_set_size(d->plane1, mode->hdisplay, 
mode->vdisplay);
+
+                       igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
+                       igt_fb_set_size(&d->fb2, d->plane2, 
d->fb2.width-500,d->fb2.height-500);
+                       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);
+               }
+
+               /* back to single plane mode */
+               igt_plane_set_fb(d->plane2, NULL);
+               igt_plane_set_fb(d->plane3, NULL);
+               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");
+}
+
+igt_main
+{
+       data_t data = {};
+
+       igt_skip_on_simulation();
+
+
+       data.drm_fd = drm_open_any();
+       igt_require_pipe_crc();
+       igt_display_init(&data.display, data.drm_fd);
+       data.devid = intel_get_drm_devid(data.drm_fd);
+
+       data.num_scalers = intel_gen(data.devid) >= 9 ? 2 : 0;
+
+       igt_subtest("plane-scaling")
+               test_plane_scaling(&data);
+
+       igt_display_fini(&data.display);
+}
-- 
1.7.9.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to