Skip to contentSkip to conversation

lib/kms: Add a way to override an output's mode

PATCH In review Ander Conselvan de Oliveira 2 participants 5 messages Mar 30, 2015 – Mar 31, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/kms: Add a way to override an output's mode

So that it is possible to use a custom mode with the simplified mode set API.

v2: Add documentation for igt_output_override_mode(). (Thomas)

---
 lib/igt_kms.c | 18 ++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 21 insertions(+)
lib/igt_kms.c +18 -0
index 6cb1f08..9cdb204 100644
@@ -905,6 +905,9 @@ static void igt_output_refresh(igt_output_t *output)
 	if (!output->valid)
 		return;
 
+	if (output->use_override_mode)
+		output->config.default_mode = output->override_mode;
+
 	if (!output->name) {
 		drmModeConnector *c = output->config.connector;
 
@@ -1656,6 +1659,21 @@ drmModeModeInfo *igt_output_get_mode(igt_output_t *output)
 	return &output->config.default_mode;
 }
 
+/**
+ * igt_output_override_mode:
+ * @output: Output of which the mode will be overriden
+ * @mode: New mode
+ *
+ * Overrides the output's mode with @mode, so that it is used instead of the
+ * mode obtained with get connectors. Note that the mode is used without
+ * checking if the output supports it, so this might lead to unexpect results.
+ */
+void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode)
+{
+	output->override_mode = *mode;
+	output->use_override_mode = true;
+}
+
 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 {
 	igt_display_t *display = output->display;
lib/igt_kms.h +3 -0
index 565df14..067402c 100644
@@ -217,6 +217,8 @@ typedef struct {
 	char *name;
 	bool valid;
 	unsigned long pending_crtc_idx_mask;
+	bool use_override_mode;
+	drmModeModeInfo override_mode;
 } igt_output_t;
 
 struct igt_display {
@@ -239,6 +241,7 @@ int  igt_display_get_n_pipes(igt_display_t *display);
 
 const char *igt_output_name(igt_output_t *output);
 drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
+void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode);
 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
 igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane);
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 tests: Add test for pipe B and C interactions in IVB

The tests exercise different combinations of enabling pipe B with modes that require more than 2 lanes and then enabling pipe C.

v2: Added a couple more tests for different pipe transitions. (Ander)
Use custom modes to make the test reliable. (Daniel)

v3: Add IGT_TEST_DESCRIPTION. (Thomas)
Add test to .gitignore. (Thomas)
Rename test to kms_pipe_b_c_ivb. (Ander)

---
 tests/.gitignore         |   1 +
 tests/Makefile.sources   |   1 +
 tests/kms_pipe_b_c_ivb.c | 290 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 292 insertions(+)
 create mode 100644 tests/kms_pipe_b_c_ivb.c
tests/.gitignore +1 -0
index 843db4a..1f0e2d1 100644
@@ -132,6 +132,7 @@ kms_flip_event_leak
 kms_flip_tiling
 kms_force_connector
 kms_mmio_vs_cs_flip
+kms_pipe_b_c_ivb
 kms_pipe_crc_basic
 kms_plane
 kms_psr_sink_crc
tests/Makefile.sources +1 -0
index 0a974a6..93e05e4 100644
@@ -75,6 +75,7 @@ TESTS_progs_M = \
 	kms_flip_tiling \
 	kms_flip_event_leak \
 	kms_mmio_vs_cs_flip \
+	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
 	kms_psr_sink_crc \
tests/kms_pipe_b_c_ivb.c new file +290 -0

290 lines not on this page · raw message

Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH i-g-t 2/2] tests: Add test for pipe B and C interactions in IVB

Quoted 306 lines · Ander Conselvan de Oliveira

The tests exercise different combinations of enabling pipe B with modes that require more than 2 lanes and then enabling pipe C.

v2: Added a couple more tests for different pipe transitions. (Ander)
Use custom modes to make the test reliable. (Daniel)

v3: Add IGT_TEST_DESCRIPTION. (Thomas)
Add test to .gitignore. (Thomas)
Rename test to kms_pipe_b_c_ivb. (Ander)

---
 tests/.gitignore         |   1 +
 tests/Makefile.sources   |   1 +
 tests/kms_pipe_b_c_ivb.c | 290 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 292 insertions(+)
 create mode 100644 tests/kms_pipe_b_c_ivb.c
tests/.gitignore +1 -0
index 843db4a..1f0e2d1 100644
@@ -132,6 +132,7 @@ kms_flip_event_leak
 kms_flip_tiling
 kms_force_connector
 kms_mmio_vs_cs_flip
+kms_pipe_b_c_ivb
 kms_pipe_crc_basic
 kms_plane
 kms_psr_sink_crc
tests/Makefile.sources +1 -0
index 0a974a6..93e05e4 100644
@@ -75,6 +75,7 @@ TESTS_progs_M = \
        kms_flip_tiling \
        kms_flip_event_leak \
        kms_mmio_vs_cs_flip \
+       kms_pipe_b_c_ivb \
        kms_pipe_crc_basic \
        kms_plane \
        kms_psr_sink_crc \
tests/kms_pipe_b_c_ivb.c new file +260 -0
new file mode 100644
index 0000000..74d84f1
@@ -0,0 +1,290 @@
+/*
+ * Copyright © 2015 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.
+ *
+ * Authors:
+ *   Ander Conselvan de Oliveira <[email protected]>
+ */
+
+#include "drmtest.h"
+#include "igt_kms.h"
+#include "intel_chipset.h"
+
+IGT_TEST_DESCRIPTION(
+"Exercise the FDI lane bifurcation code for IVB in the kernel by setting"
+"different combinations of modes for pipes B and C.");
+
+typedef struct {
+       int drm_fd;
+       igt_display_t display;
+} data_t;
+
+drmModeModeInfo mode_3_lanes = {
+       .clock = 173000,
+       .hdisplay = 1920,
+       .hsync_start = 2048,
+       .hsync_end = 2248,
+       .htotal = 2576,
+       .vdisplay = 1080,
+       .vsync_start = 1083,
+       .vsync_end = 1088,
+       .vtotal = 1120,
+       .vrefresh = 60,
+       .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC,
+       .name = "3_lanes",
+};
+
+drmModeModeInfo mode_2_lanes = {
+       .clock = 138500,
+       .hdisplay = 1920,
+       .hsync_start = 1968,
+       .hsync_end = 2000,
+       .htotal = 2080,
+       .vdisplay = 1080,
+       .vsync_start = 1083,
+       .vsync_end = 1088,
+       .vtotal = 1111,
+       .vrefresh = 60,
+       .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
+       .name = "2_lanes",
+};
+
+static int
+disable_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_plane_t *primary;
+
+       igt_output_set_pipe(output, pipe);
+       primary = igt_output_get_plane(output, 0);
+       igt_plane_set_fb(primary, NULL);
+       return igt_display_commit(&data->display);
+}
+
+static int
+set_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_plane_t *primary;
+       drmModeModeInfo *mode;
+       struct igt_fb fb;
+       int fb_id;
+
+       igt_output_set_pipe(output, pipe);
+
+       mode = igt_output_get_mode(output);
+
+       primary = igt_output_get_plane(output, 0);
+
+       fb_id = igt_create_color_fb(data->drm_fd,
+                                   mode->hdisplay, mode->vdisplay,
+                                   DRM_FORMAT_XRGB8888, I915_TILING_NONE,
+                                   1.0, 1.0, 1.0, &fb);
+       igt_assert(fb_id >= 0);
+
+       igt_plane_set_fb(primary, &fb);
+       return igt_display_try_commit2(&data->display, COMMIT_LEGACY);
+}
+
+static int
+set_big_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_output_override_mode(output, &mode_3_lanes);
+       return set_mode_on_pipe(data, pipe, output);
+}
+
+static int
+set_normal_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_output_override_mode(output, &mode_2_lanes);
+       return set_mode_on_pipe(data, pipe, output);
+}
+
+static void
+find_outputs(data_t *data, igt_output_t **output1, igt_output_t **output2)
+{
+       int count = 0;
+       igt_output_t *output;
+
+       *output1 = NULL;
+       *output2 = NULL;
+
+       for_each_connected_output(&data->display, output) {
+               if (!(*output1))
+                       *output1 = output;
+               else if (!(*output2))
+                       *output2 = output;
+
+               igt_output_set_pipe(output, PIPE_ANY);
+               count++;
+       }
+
+       igt_skip_on_f(count < 2, "Not enough connected outputs\n");
+}
+
+static void
+test_dpms(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       kmstest_set_connector_dpms(data->drm_fd, output1->config.connector, DRM_MODE_DPMS_OFF);
+
+       ret = set_big_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret != 0);
+}
+
+static void
+test_lane_reduction(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+}
+
+static void
+test_disable_pipe_B(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = disable_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+}
+
+static void
+test_from_C_to_B_with_3_lanes(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+
+       ret = disable_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+}
+
+static void
+test_fail_enable_pipe_C_while_B_has_3_lanes(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret != 0);
+}
+
+static data_t data;
+igt_main
+{
+       int devid;
+
+       igt_skip_on_simulation();

tests/kms_pipe_b_c_ivb.c line 270

Quoted 10 lines
tests/kms_pipe_b_c_ivb.c new file +10 -0
+
+       igt_fixture {
+               data.drm_fd = drm_open_any_master();
+               devid = intel_get_drm_devid(data.drm_fd);
+
+               kmstest_set_vt_graphics_mode();
+               igt_display_init(&data.display, data.drm_fd);
+       }
+
+       igt_skip_on(!IS_IVYBRIDGE(devid));

This needs to go inside an igt_fixture block so that subtest enumeration works correctly.

Quoted 21 lines
tests/kms_pipe_b_c_ivb.c new file +20 -1
+
+       igt_subtest("pipe-B-dpms-off-modeset-pipe-C")
+               test_dpms(&data);
+
+       igt_subtest("pipe-B-double-modeset-then-modeset-pipe-C")
+               test_lane_reduction(&data);
+
+       igt_subtest("disable-pipe-B-enable-pipe-C")
+               test_disable_pipe_B(&data);
+
+       igt_subtest("from-pipe-C-to-B-with-3-lanes")
+               test_from_C_to_B_with_3_lanes(&data);
+
+       igt_subtest("enable-pipe-C-while-B-has-3-lanes")
+               test_fail_enable_pipe_C_while_B_has_3_lanes(&data);
+
+       igt_fixture {
+               igt_display_fini(&data.display);
+       }
+}
--
Quoted 2 lines

2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

PATCH v4 1/1 tests: Add test for pipe B and C interactions in IVB

The tests exercise different combinations of enabling pipe B with modes that require more than 2 lanes and then enabling pipe C.

v2: Added a couple more tests for different pipe transitions. (Ander)
Use custom modes to make the test reliable. (Daniel)

v3: Add IGT_TEST_DESCRIPTION. (Thomas)
Rename test to kms_pipe_b_c_ivb. (Ander)

v4: Fix subtest enumeration. (Thomas)

---
 tests/.gitignore         |   1 +
 tests/Makefile.sources   |   1 +
 tests/kms_pipe_b_c_ivb.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 291 insertions(+)
 create mode 100644 tests/kms_pipe_b_c_ivb.c
tests/.gitignore +1 -0
index 843db4a..1f0e2d1 100644
@@ -132,6 +132,7 @@ kms_flip_event_leak
 kms_flip_tiling
 kms_force_connector
 kms_mmio_vs_cs_flip
+kms_pipe_b_c_ivb
 kms_pipe_crc_basic
 kms_plane
 kms_psr_sink_crc
tests/Makefile.sources +1 -0
index 0a974a6..93e05e4 100644
@@ -75,6 +75,7 @@ TESTS_progs_M = \
 	kms_flip_tiling \
 	kms_flip_event_leak \
 	kms_mmio_vs_cs_flip \
+	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
 	kms_psr_sink_crc \
tests/kms_pipe_b_c_ivb.c new file +289 -0

289 lines not on this page · raw message

Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH v4] tests: Add test for pipe B and C interactions in IVB

Quoted 10 lines · Ander Conselvan de Oliveira

The tests exercise different combinations of enabling pipe B with modes that require more than 2 lanes and then enabling pipe C.

v2: Added a couple more tests for different pipe transitions. (Ander)
Use custom modes to make the test reliable. (Daniel)

v3: Add IGT_TEST_DESCRIPTION. (Thomas)
Rename test to kms_pipe_b_c_ivb. (Ander)

v4: Fix subtest enumeration. (Thomas)

Thanks, patches pushed and signed-off-by added as discussed.

Quoted 327 lines
---
 tests/.gitignore         |   1 +
 tests/Makefile.sources   |   1 +
 tests/kms_pipe_b_c_ivb.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 291 insertions(+)
 create mode 100644 tests/kms_pipe_b_c_ivb.c
tests/.gitignore +1 -0
index 843db4a..1f0e2d1 100644
@@ -132,6 +132,7 @@ kms_flip_event_leak
 kms_flip_tiling
 kms_force_connector
 kms_mmio_vs_cs_flip
+kms_pipe_b_c_ivb
 kms_pipe_crc_basic
 kms_plane
 kms_psr_sink_crc
tests/Makefile.sources +1 -0
index 0a974a6..93e05e4 100644
@@ -75,6 +75,7 @@ TESTS_progs_M = \
        kms_flip_tiling \
        kms_flip_event_leak \
        kms_mmio_vs_cs_flip \
+       kms_pipe_b_c_ivb \
        kms_pipe_crc_basic \
        kms_plane \
        kms_psr_sink_crc \
tests/kms_pipe_b_c_ivb.c new file +289 -1
new file mode 100644
index 0000000..b6e234c
@@ -0,0 +1,289 @@
+/*
+ * Copyright © 2015 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.
+ *
+ * Authors:
+ *   Ander Conselvan de Oliveira <[email protected]>
+ */
+
+#include "drmtest.h"
+#include "igt_kms.h"
+#include "intel_chipset.h"
+
+IGT_TEST_DESCRIPTION(
+"Exercise the FDI lane bifurcation code for IVB in the kernel by setting"
+"different combinations of modes for pipes B and C.");
+
+typedef struct {
+       int drm_fd;
+       igt_display_t display;
+} data_t;
+
+drmModeModeInfo mode_3_lanes = {
+       .clock = 173000,
+       .hdisplay = 1920,
+       .hsync_start = 2048,
+       .hsync_end = 2248,
+       .htotal = 2576,
+       .vdisplay = 1080,
+       .vsync_start = 1083,
+       .vsync_end = 1088,
+       .vtotal = 1120,
+       .vrefresh = 60,
+       .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC,
+       .name = "3_lanes",
+};
+
+drmModeModeInfo mode_2_lanes = {
+       .clock = 138500,
+       .hdisplay = 1920,
+       .hsync_start = 1968,
+       .hsync_end = 2000,
+       .htotal = 2080,
+       .vdisplay = 1080,
+       .vsync_start = 1083,
+       .vsync_end = 1088,
+       .vtotal = 1111,
+       .vrefresh = 60,
+       .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
+       .name = "2_lanes",
+};
+
+static int
+disable_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_plane_t *primary;
+
+       igt_output_set_pipe(output, pipe);
+       primary = igt_output_get_plane(output, 0);
+       igt_plane_set_fb(primary, NULL);
+       return igt_display_commit(&data->display);
+}
+
+static int
+set_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_plane_t *primary;
+       drmModeModeInfo *mode;
+       struct igt_fb fb;
+       int fb_id;
+
+       igt_output_set_pipe(output, pipe);
+
+       mode = igt_output_get_mode(output);
+
+       primary = igt_output_get_plane(output, 0);
+
+       fb_id = igt_create_color_fb(data->drm_fd,
+                                   mode->hdisplay, mode->vdisplay,
+                                   DRM_FORMAT_XRGB8888, I915_TILING_NONE,
+                                   1.0, 1.0, 1.0, &fb);
+       igt_assert(fb_id >= 0);
+
+       igt_plane_set_fb(primary, &fb);
+       return igt_display_try_commit2(&data->display, COMMIT_LEGACY);
+}
+
+static int
+set_big_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_output_override_mode(output, &mode_3_lanes);
+       return set_mode_on_pipe(data, pipe, output);
+}
+
+static int
+set_normal_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+       igt_output_override_mode(output, &mode_2_lanes);
+       return set_mode_on_pipe(data, pipe, output);
+}
+
+static void
+find_outputs(data_t *data, igt_output_t **output1, igt_output_t **output2)
+{
+       int count = 0;
+       igt_output_t *output;
+
+       *output1 = NULL;
+       *output2 = NULL;
+
+       for_each_connected_output(&data->display, output) {
+               if (!(*output1))
+                       *output1 = output;
+               else if (!(*output2))
+                       *output2 = output;
+
+               igt_output_set_pipe(output, PIPE_ANY);
+               count++;
+       }
+
+       igt_skip_on_f(count < 2, "Not enough connected outputs\n");
+}
+
+static void
+test_dpms(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       kmstest_set_connector_dpms(data->drm_fd, output1->config.connector, DRM_MODE_DPMS_OFF);
+
+       ret = set_big_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret != 0);
+}
+
+static void
+test_lane_reduction(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+}
+
+static void
+test_disable_pipe_B(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = disable_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+}
+
+static void
+test_from_C_to_B_with_3_lanes(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+
+       ret = disable_pipe(data, PIPE_C, output2);
+       igt_assert(ret == 0);
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+}
+
+static void
+test_fail_enable_pipe_C_while_B_has_3_lanes(data_t *data)
+{
+       igt_output_t *output1, *output2;
+       int ret;
+
+       find_outputs(data, &output1, &output2);
+
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+       igt_info("Pipe %s will use connector %s\n",
+                kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+
+       ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+       igt_assert(ret == 0);
+
+       ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+       igt_assert(ret != 0);
+}
+
+static data_t data;
+igt_main
+{
+       int devid;
+
+       igt_skip_on_simulation();
+
+       igt_fixture {
+               data.drm_fd = drm_open_any_master();
+               devid = intel_get_drm_devid(data.drm_fd);
+               igt_skip_on(!IS_IVYBRIDGE(devid));
+
+               kmstest_set_vt_graphics_mode();
+               igt_display_init(&data.display, data.drm_fd);
+       }
+
+       igt_subtest("pipe-B-dpms-off-modeset-pipe-C")
+               test_dpms(&data);
+
+       igt_subtest("pipe-B-double-modeset-then-modeset-pipe-C")
+               test_lane_reduction(&data);
+
+       igt_subtest("disable-pipe-B-enable-pipe-C")
+               test_disable_pipe_B(&data);
+
+       igt_subtest("from-pipe-C-to-B-with-3-lanes")
+               test_from_C_to_B_with_3_lanes(&data);
+
+       igt_subtest("enable-pipe-C-while-B-has-3-lanes")
+               test_fail_enable_pipe_C_while_B_has_3_lanes(&data);
+
+       igt_fixture {
+               igt_display_fini(&data.display);
+       }
+}
--
Quoted 2 lines

2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx