From: Robert Foss <robert.foss@collabora.com>
To: intel-gfx@lists.freedesktop.org,
Tomeu Vizoso <tomeu.vizoso@collabora.com>,
Maarten Lankhorst <maarten.lankhorst@intel.com>,
Gustavo Padovan <gustavo.padovan@collabora.com>,
Daniel Stone <daniels@collabora.com>,
Mika Kahola <mika.kahola@intel.com>
Subject: [PATCH i-g-t v1 04/32] lib/igt_kms: Implement dynamic plane count support
Date: Fri, 20 Jan 2017 12:45:26 -0500 [thread overview]
Message-ID: <20170120174554.14195-5-robert.foss@collabora.com> (raw)
In-Reply-To: <20170120174554.14195-1-robert.foss@collabora.com>
In upcoming drm-misc-next changes, the number of planes per pipe has
been increased as more than one primary plane can be associated with
a pipe.
The simple fix for this would be to simply bump hardcoded value for
number of frames per pipe.
But a better solution would be to add support for dynamic number of
planes per pipe to i-g-t.
Signed-off-by: Robert Foss <robert.foss@collabora.com>
---
lib/igt_kms.c | 157 +++++++++++++++++++++++++++++++++++++++-------------------
lib/igt_kms.h | 32 ++++--------
2 files changed, 114 insertions(+), 75 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 8fa40c28..58e62e2b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -347,24 +347,17 @@ int kmstest_pipe_to_index(char pipe)
*
* Returns: String represnting @pipe, e.g. "plane1".
*/
-const char *kmstest_plane_name(enum igt_plane plane)
+const char *kmstest_plane_type_name(int plane_type)
{
static const char *names[] = {
- [IGT_PLANE_1] = "plane1",
- [IGT_PLANE_2] = "plane2",
- [IGT_PLANE_3] = "plane3",
- [IGT_PLANE_4] = "plane4",
- [IGT_PLANE_5] = "plane5",
- [IGT_PLANE_6] = "plane6",
- [IGT_PLANE_7] = "plane7",
- [IGT_PLANE_8] = "plane8",
- [IGT_PLANE_9] = "plane9",
- [IGT_PLANE_CURSOR] = "cursor",
+ [DRM_PLANE_TYPE_OVERLAY] = "overlay",
+ [DRM_PLANE_TYPE_PRIMARY] = "primary",
+ [DRM_PLANE_TYPE_CURSOR] = "cursor",
};
- igt_assert(plane < ARRAY_SIZE(names) && names[plane]);
+ igt_assert(plane_type < ARRAY_SIZE(names) && names[plane_type]);
- return names[plane];
+ return names[plane_type];
}
static const char *mode_stereo_name(const drmModeModeInfo *mode)
@@ -1532,14 +1525,17 @@ void igt_display_init(igt_display_t *display, int drm_fd)
for (i = 0; i < display->n_pipes; i++) {
igt_pipe_t *pipe = &display->pipes[i];
igt_plane_t *plane;
- int p = IGT_PLANE_2;
+ int p = 1;
int j, type;
- uint8_t n_planes = 0;
+ uint8_t last_plane = 0, n_planes = 0;
uint64_t prop_value;
pipe->crtc_id = resources->crtcs[i];
pipe->display = display;
pipe->pipe = i;
+ pipe->plane_cursor = -1;
+ pipe->plane_primary = -1;
+ pipe->planes = NULL;
get_crtc_property(display->drm_fd, pipe->crtc_id,
"background_color",
@@ -1565,6 +1561,27 @@ void igt_display_init(igt_display_t *display, int drm_fd)
igt_atomic_fill_pipe_props(display, pipe, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names);
+ /* count number of valid planes */
+ for (j = 0; j < plane_resources->count_planes; j++) {
+ drmModePlane *drm_plane;
+
+ drm_plane = drmModeGetPlane(display->drm_fd,
+ plane_resources->planes[j]);
+ igt_assert(drm_plane);
+
+ if (!(drm_plane->possible_crtcs & (1 << i))) {
+ drmModeFreePlane(drm_plane);
+ continue;
+ }
+
+ n_planes++;
+ }
+
+ igt_assert_lte(0, n_planes);
+ pipe->planes = calloc(sizeof(igt_plane_t), n_planes);
+ igt_assert_f(pipe->planes, "Failed to allocate memory for %d planes\n", n_planes);
+ last_plane = n_planes - 1;
+
/* add the planes that can be used with that pipe */
for (j = 0; j < plane_resources->count_planes; j++) {
drmModePlane *drm_plane;
@@ -1582,21 +1599,24 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane_resources->planes[j]);
switch (type) {
case DRM_PLANE_TYPE_PRIMARY:
- plane = &pipe->planes[IGT_PLANE_PRIMARY];
- plane->is_primary = 1;
- plane->index = IGT_PLANE_PRIMARY;
+ if (pipe->plane_primary == -1) {
+ plane = &pipe->planes[0];
+ plane->index = 0;
+ pipe->plane_primary = 0;
+ } else {
+ plane = &pipe->planes[p];
+ plane->index = p++;
+ }
break;
case DRM_PLANE_TYPE_CURSOR:
- /*
- * Cursor should be the highest index in our
- * internal list, but we don't know what that
- * is yet. Just stick it in the last slot
- * for now and we'll move it later, if
- * necessary.
- */
- plane = &pipe->planes[IGT_PLANE_CURSOR];
- plane->is_cursor = 1;
- plane->index = IGT_PLANE_CURSOR;
+ if (pipe->plane_cursor == -1) {
+ plane = &pipe->planes[last_plane];
+ plane->index = last_plane;
+ pipe->plane_cursor = last_plane;
+ } else {
+ plane = &pipe->planes[p];
+ plane->index = p++;
+ }
display->has_cursor_plane = true;
break;
default:
@@ -1605,7 +1625,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
break;
}
- n_planes++;
+ plane->type = type;
plane->pipe = pipe;
plane->drm_plane = drm_plane;
@@ -1626,7 +1646,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
* At the bare minimum, we should expect to have a primary
* plane
*/
- igt_assert(pipe->planes[IGT_PLANE_PRIMARY].drm_plane);
+ igt_assert(pipe->planes[pipe->plane_primary].drm_plane);
if (display->has_cursor_plane) {
/*
@@ -1634,11 +1654,11 @@ void igt_display_init(igt_display_t *display, int drm_fd)
* only 1 sprite, that's the wrong slot and we need to
* move it down.
*/
- if (p != IGT_PLANE_CURSOR) {
+ if (p != last_plane) {
pipe->planes[p] =
- pipe->planes[IGT_PLANE_CURSOR];
+ pipe->planes[last_plane];
pipe->planes[p].index = p;
- memset(&pipe->planes[IGT_PLANE_CURSOR], 0,
+ memset(&pipe->planes[last_plane], 0,
sizeof *plane);
}
} else {
@@ -1646,7 +1666,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane = &pipe->planes[p];
plane->pipe = pipe;
plane->index = p;
- plane->is_cursor = true;
+ plane->type = DRM_PLANE_TYPE_CURSOR;
}
pipe->n_planes = n_planes;
@@ -1654,9 +1674,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)
for_each_plane_on_pipe(display, i, plane)
plane->fb_changed = true;
- /* make sure we don't overflow the plane array */
- igt_assert_lte(pipe->n_planes, IGT_MAX_PLANES);
-
pipe->mode_changed = true;
}
@@ -1709,6 +1726,9 @@ static void igt_pipe_fini(igt_pipe_t *pipe)
plane->drm_plane = NULL;
}
}
+
+ free(pipe->planes);
+ pipe->planes = NULL;
}
static void igt_output_fini(igt_output_t *output)
@@ -1797,20 +1817,41 @@ static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output)
return &display->pipes[pipe];
}
-static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, enum igt_plane plane)
+static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, int plane_idx)
{
- int idx;
+ igt_assert_f(plane_idx >= 0 && plane_idx < pipe->n_planes,
+ "Valid pipe->planes plane_idx not found, plane_idx=%d n_planes=%d",
+ plane_idx, pipe->n_planes);
- /* Cursor plane is always the highest index */
- if (plane == IGT_PLANE_CURSOR)
- idx = pipe->n_planes - 1;
- else {
- igt_assert_f(plane >= 0 && plane < (pipe->n_planes),
- "plane=%d\n", plane);
- idx = plane;
+ return &pipe->planes[plane_idx];
+}
+
+
+igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type)
+{
+ int i, plane_idx = -1;
+
+ switch(plane_type) {
+ case DRM_PLANE_TYPE_CURSOR:
+ plane_idx = pipe->plane_cursor;
+ break;
+ case DRM_PLANE_TYPE_PRIMARY:
+ plane_idx = pipe->plane_primary;
+ break;
+ case DRM_PLANE_TYPE_OVERLAY:
+ for(i = 0; i < pipe->n_planes; i++)
+ if (pipe->planes[i].type == DRM_PLANE_TYPE_OVERLAY)
+ plane_idx = i;
+ break;
+ default:
+ break;
}
- return &pipe->planes[idx];
+ igt_assert_f(plane_idx >= 0 && plane_idx < pipe->n_planes,
+ "Valid pipe->planes idx not found. plane_idx=%d plane_type=%d n_planes=%d\n",
+ plane_idx, plane_type, pipe->n_planes);
+
+ return &pipe->planes[plane_idx];
}
static igt_output_t *igt_pipe_get_output(igt_pipe_t *pipe)
@@ -2155,9 +2196,9 @@ static int igt_plane_commit(igt_plane_t *plane,
enum igt_commit_style s,
bool fail_on_error)
{
- if (plane->is_cursor && s == COMMIT_LEGACY) {
+ if (plane->type == DRM_PLANE_TYPE_CURSOR && s == COMMIT_LEGACY) {
return igt_cursor_commit_legacy(plane, pipe, fail_on_error);
- } else if (plane->is_primary && s == COMMIT_LEGACY) {
+ } else if (plane->type == DRM_PLANE_TYPE_PRIMARY && s == COMMIT_LEGACY) {
return igt_primary_plane_commit_legacy(plane, pipe,
fail_on_error);
} else {
@@ -2374,7 +2415,9 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)
plane->position_changed = false;
plane->size_changed = false;
- if (s != COMMIT_LEGACY || !(plane->is_primary || plane->is_cursor))
+ if (s != COMMIT_LEGACY ||
+ !(plane->type == DRM_PLANE_TYPE_PRIMARY ||
+ plane->type == DRM_PLANE_TYPE_CURSOR))
plane->rotation_changed = false;
}
}
@@ -2654,14 +2697,24 @@ void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode)
igt_require(output->config.atomic_props_connector[IGT_CONNECTOR_SCALING_MODE]);
}
-igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane)
+igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx)
+{
+ igt_pipe_t *pipe;
+
+ pipe = igt_output_get_driving_pipe(output);
+ igt_assert(pipe);
+
+ return igt_pipe_get_plane(pipe, plane_idx);
+}
+
+igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type)
{
igt_pipe_t *pipe;
pipe = igt_output_get_driving_pipe(output);
igt_assert(pipe);
- return igt_pipe_get_plane(pipe, plane);
+ return igt_pipe_get_plane_type(pipe, plane_type);
}
void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 859c79aa..dc172ec9 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -57,25 +57,7 @@ enum pipe {
I915_MAX_PIPES
};
const char *kmstest_pipe_name(enum pipe pipe);
-int kmstest_pipe_to_index(char pipe);
-
-/* We namespace this enum to not conflict with the Android i915_drm.h */
-enum igt_plane {
- IGT_PLANE_1 = 0,
- IGT_PLANE_PRIMARY = IGT_PLANE_1,
- IGT_PLANE_2,
- IGT_PLANE_3,
- IGT_PLANE_4,
- IGT_PLANE_5,
- IGT_PLANE_6,
- IGT_PLANE_7,
- IGT_PLANE_8,
- IGT_PLANE_9,
- IGT_PLANE_CURSOR, /* IGT_PLANE_CURSOR is always the last plane. */
- IGT_MAX_PLANES,
-};
-
-const char *kmstest_plane_name(enum igt_plane plane);
+const char *kmstest_plane_type_name(int plane_type);
enum port {
PORT_A = 0,
@@ -257,8 +239,7 @@ typedef struct {
igt_pipe_t *pipe;
int index;
/* capabilities */
- unsigned int is_primary : 1;
- unsigned int is_cursor : 1;
+ int type;
/* state tracking */
unsigned int fb_changed : 1;
unsigned int position_changed : 1;
@@ -293,8 +274,11 @@ struct igt_pipe {
igt_display_t *display;
enum pipe pipe;
bool enabled;
+
int n_planes;
- igt_plane_t planes[IGT_MAX_PLANES];
+ int plane_cursor;
+ int plane_primary;
+ igt_plane_t *planes;
uint32_t atomic_props_crtc[IGT_NUM_CRTC_PROPS];
@@ -354,7 +338,9 @@ 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);
void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode);
-igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane);
+igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx);
+igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type);
+igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type);
bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
uint32_t *prop_id, uint64_t *value,
drmModePropertyPtr *prop);
--
2.11.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-01-20 17:46 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 17:45 [PATCH i-g-t v1 00/32] lib/igt_kms: Implement dynamic plane count support Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 01/32] lib/igt_kms: Add index property to kmstest_plane struct Robert Foss
2017-01-23 10:21 ` Mika Kahola
2017-01-20 17:45 ` [PATCH i-g-t v1 02/32] lib/igt_kms: Avoid depencency on static plane count Robert Foss
2017-01-23 10:31 ` Mika Kahola
2017-01-20 17:45 ` [PATCH i-g-t v1 03/32] lib/igt_kms: Rename kmstest properties nplanes and plane Robert Foss
2017-01-23 10:33 ` Mika Kahola
2017-01-20 17:45 ` Robert Foss [this message]
2017-01-23 11:00 ` [PATCH i-g-t v1 04/32] lib/igt_kms: Implement dynamic plane count support Mika Kahola
2017-01-23 15:47 ` Robert Foss
2017-01-24 9:03 ` Petri Latvala
2017-01-20 17:45 ` [PATCH i-g-t v1 05/32] tests/kms_atomic_transition: Add support for dynamic number of planes Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 06/32] tests/kms_busy: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 07/32] tests/kms_chv_cursor_fail: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 08/32] tests/kms_crtc_background_color: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 09/32] tests/kms_cursor_crc: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 10/32] tests/kms_cursor_legacy: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 11/32] tests/kms_fbc_crc: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 12/32] tests/kms_fence_pin_leak: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 13/32] tests/kms_flip_event_leak: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 14/32] tests/kms_legacy_colorkey: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 15/32] tests/kms_mmap_write_crc: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 16/32] tests/kms_mmio_vs_cs_flip: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 17/32] tests/kms_panel_fitting: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 18/32] tests/kms_pipe_color: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 19/32] tests/kms_plane: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 20/32] tests/kms_plane_multiple: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 21/32] tests/kms_plane_scaling: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 22/32] tests/kms_properties: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 23/32] tests/kms_psr_sink_crc: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 24/32] tests/kms_pwrite_crc: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 25/32] tests/kms_rmfb: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 26/32] tests/kms_rotation_crc: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 27/32] tests/kms_sink_crc_basic: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 28/32] tests/kms_universal_plane: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 29/32] tests/kms_vblank: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 30/32] tests/prime_mmap_kms: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 31/32] tests/kms_ccs: " Robert Foss
2017-01-20 17:45 ` [PATCH i-g-t v1 32/32] tests/kms_plane_lowres: " Robert Foss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170120174554.14195-5-robert.foss@collabora.com \
--to=robert.foss@collabora.com \
--cc=daniels@collabora.com \
--cc=gustavo.padovan@collabora.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maarten.lankhorst@intel.com \
--cc=mika.kahola@intel.com \
--cc=tomeu.vizoso@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.