[PATCH i-g-t] lib/igt_kms: Move SDR/HDR plane check to library
Mika Kahola
mika.kahola at intel.com
Tue Sep 22 10:52:34 UTC 2020
Mixing SDR and HDR planes results in a CRC mismatch, so use the first
SDR/HDR plane as the main plane matching the SDR/HDR type of the sprite
plane under test. This check is in use on kms_ccs and kms_plane_lowres
tests. To clean up code base, let's move these functions as library
routines in igt_kms.c and igt_kms.h
Signed-off-by: Mika Kahola <mika.kahola at intel.com>
---
lib/igt_kms.c | 34 ++++++++++++++++++++++++++++++++++
lib/igt_kms.h | 5 +++++
tests/kms_ccs.c | 32 ++++----------------------------
tests/kms_plane_lowres.c | 36 ++----------------------------------
4 files changed, 45 insertions(+), 62 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4023811a..e130235e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1781,6 +1781,40 @@ static void igt_plane_reset(igt_plane_t *plane)
plane->gem_handle = 0;
}
+igt_plane_t *igt_first_sdr_plane(igt_output_t *output, uint32_t devid)
+{
+ int index;
+
+ index = intel_gen(devid) <= 9 ? 0 : SDR_PLANE_BASE;
+
+ return igt_output_get_plane(output, index);
+}
+
+static bool is_sdr_plane(const igt_plane_t *plane, uint32_t devid)
+{
+ if (intel_gen(devid) <= 9)
+ return true;
+
+ return plane->index >= SDR_PLANE_BASE;
+}
+
+/*
+* Mixing SDR and HDR planes results in a CRC mismatch, so use the first
+* SDR/HDR plane as the main plane matching the SDR/HDR type of the sprite
+* plane under test.
+*/
+igt_plane_t *igt_get_primary_plane(igt_plane_t *plane,
+ uint32_t format,
+ igt_output_t *output,
+ uint32_t devid)
+{
+ if (plane && is_sdr_plane(plane, devid) &&
+ igt_format_is_yuv(format))
+ return igt_first_sdr_plane(output, devid);
+
+ return igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+}
+
static void igt_pipe_reset(igt_pipe_t *pipe)
{
igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_MODE_ID, 0);
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index f41eadaf..a52f6ab1 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -284,6 +284,8 @@ enum igt_atomic_plane_properties {
IGT_NUM_PLANE_PROPS
};
+#define SDR_PLANE_BASE 3
+
/**
* igt_plane_prop_names
*
@@ -440,6 +442,9 @@ igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type);
int igt_output_count_plane_type(igt_output_t *output, int plane_type);
igt_plane_t *igt_output_get_plane_type_index(igt_output_t *output,
int plane_type, int index);
+igt_plane_t *igt_first_sdr_plane(igt_output_t *output, uint32_t devid);
+igt_plane_t *igt_get_primary_plane(igt_plane_t *plane, uint32_t format,
+ igt_output_t *output, uint32_t devid);
igt_output_t *igt_output_from_connector(igt_display_t *display,
drmModeConnector *connector);
void igt_output_refresh(igt_output_t *output);
diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
index b60e4908..849b6068 100644
--- a/tests/kms_ccs.c
+++ b/tests/kms_ccs.c
@@ -24,8 +24,6 @@
#include "igt.h"
-#define SDR_PLANE_BASE 3
-
IGT_TEST_DESCRIPTION("Test render compression (RC), in which the main surface "
"is complemented by a color control surface (CCS) that "
"the display uses to interpret the compressed data.");
@@ -62,6 +60,7 @@ typedef struct {
igt_pipe_crc_t *pipe_crc;
uint32_t format;
uint64_t ccs_modifier;
+ int devid;
} data_t;
static const struct {
@@ -263,35 +262,11 @@ static void generate_fb(data_t *data, struct igt_fb *fb,
fb->fb_id = f.fb_id;
}
-static igt_plane_t *first_sdr_plane(data_t *data)
-{
- return igt_output_get_plane(data->output, SDR_PLANE_BASE);
-}
-
-static bool is_sdr_plane(const igt_plane_t *plane)
-{
- return plane->index >= SDR_PLANE_BASE;
-}
-
-/*
- * Mixing SDR and HDR planes results in a CRC mismatch, so use the first
- * SDR/HDR plane as the main plane matching the SDR/HDR type of the sprite
- * plane under test.
- */
-static igt_plane_t *compatible_main_plane(data_t *data)
-{
- if (data->plane && is_sdr_plane(data->plane) &&
- igt_format_is_yuv(data->format))
- return first_sdr_plane(data);
-
- return igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
-}
-
static bool try_config(data_t *data, enum test_fb_flags fb_flags,
igt_crc_t *crc)
{
igt_display_t *display = &data->display;
- igt_plane_t *primary = compatible_main_plane(data);
+ igt_plane_t *primary = igt_get_primary_plane(data->plane, data->format, data->output, data->devid);
drmModeModeInfo *drm_mode = igt_output_get_mode(data->output);
int fb_width = drm_mode->hdisplay;
enum igt_commit_style commit;
@@ -467,7 +442,8 @@ igt_main_args("c", NULL, help_str, opt_handler, NULL)
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
- igt_require(intel_gen(intel_get_drm_devid(data.drm_fd)) >= 9);
+ data.devid = intel_get_drm_devid(data.drm_fd);
+ igt_require(intel_gen(data.devid) >= 9);
kmstest_set_vt_graphics_mode();
igt_require_pipe_crc(data.drm_fd);
diff --git a/tests/kms_plane_lowres.c b/tests/kms_plane_lowres.c
index a5af1f8a..0f716869 100644
--- a/tests/kms_plane_lowres.c
+++ b/tests/kms_plane_lowres.c
@@ -32,7 +32,6 @@
IGT_TEST_DESCRIPTION("Test atomic mode setting with a plane by switching between high and low resolutions");
-#define SDR_PLANE_BASE 3
#define SIZE 64
typedef struct {
@@ -81,43 +80,12 @@ get_lowres_mode(int drmfd, igt_output_t *output,
return *mode;
}
-static igt_plane_t *first_sdr_plane(igt_output_t *output, uint32_t devid)
-{
- int index;
-
- index = intel_gen(devid) <= 9 ? 0 : SDR_PLANE_BASE;
-
- return igt_output_get_plane(output, index);
-}
-
-static bool is_sdr_plane(const igt_plane_t *plane, uint32_t devid)
-{
- if (intel_gen(devid) <= 9)
- return true;
-
- return plane->index >= SDR_PLANE_BASE;
-}
-/*
- * Mixing SDR and HDR planes results in a CRC mismatch, so use the first
- * SDR/HDR plane as the main plane matching the SDR/HDR type of the sprite
- * plane under test.
- */
-static igt_plane_t *compatible_main_plane(igt_plane_t *plane,
- igt_output_t *output,
- uint32_t devid)
-{
- if (is_sdr_plane(plane, devid))
- return first_sdr_plane(output, devid);
-
- return igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
-}
-
static bool setup_plane(data_t *data, igt_plane_t *plane)
{
struct igt_fb *fb;
if (plane->type == DRM_PLANE_TYPE_PRIMARY ||
- plane == first_sdr_plane(data->output, data->devid) ||
+ plane == igt_first_sdr_plane(data->output, data->devid) ||
plane->type == DRM_PLANE_TYPE_CURSOR)
return false;
@@ -173,7 +141,7 @@ test_planes_on_pipe_with_output(data_t *data, igt_plane_t *plane, uint64_t modif
igt_output_set_pipe(data->output, data->pipe);
- primary = compatible_main_plane(plane, data->output, data->devid);
+ primary = igt_get_primary_plane(plane, DRM_FORMAT_XRGB8888, data->output, data->devid);
mode = igt_output_get_mode(data->output);
mode_lowres = get_lowres_mode(data->drm_fd, data->output, mode);
--
2.25.1
More information about the Intel-gfx-trybot
mailing list