summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>2018-12-13 16:37:38 +0100
committerPaul Kocialkowski <paul.kocialkowski@bootlin.com>2019-02-26 09:45:54 +0100
commit562f51cea4abd49208a7876facb711c1a13b0650 (patch)
tree9e1ede3ebff6794a7df9c382fe301026124ff3d9
parent5b39b1c6c6883a971c1d4134809b4b84805fdd4b (diff)
lib/igt_kms: Add helpers to count and iterate planes from pipe
This introduces helpers that allow counting how many planes of a given type are present from a pipe and getting the n-th plane of a given type. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
-rw-r--r--lib/igt_kms.c48
-rw-r--r--lib/igt_kms.h3
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 761bb1937..5bde391fd 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2279,6 +2279,54 @@ igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type)
return &pipe->planes[plane_idx];
}
+/**
+ * igt_pipe_count_plane_type:
+ * @pipe: Target pipe
+ * @plane_type: Cursor, primary or an overlay plane
+ *
+ * Counts the number of planes of type @plane_type for the provided @pipe.
+ *
+ * Returns: The number of planes that match the requested plane type
+ */
+int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type)
+{
+ int i, count = 0;
+
+ for(i = 0; i < pipe->n_planes; i++)
+ if (pipe->planes[i].type == plane_type)
+ count++;
+
+ return count;
+}
+
+/**
+ * igt_pipe_get_plane_type_index:
+ * @pipe: Target pipe
+ * @plane_type: Cursor, primary or an overlay plane
+ * @index: the index of the plane among planes of the same type
+ *
+ * Get the @index th plane of type @plane_type for the provided @pipe.
+ *
+ * Returns: The @index th plane that matches the requested plane type
+ */
+igt_plane_t *igt_pipe_get_plane_type_index(igt_pipe_t *pipe, int plane_type,
+ int index)
+{
+ int i, type_index = 0;
+
+ for(i = 0; i < pipe->n_planes; i++) {
+ if (pipe->planes[i].type != plane_type)
+ continue;
+
+ if (type_index == index)
+ return &pipe->planes[i];
+
+ type_index++;
+ }
+
+ return NULL;
+}
+
static bool output_is_internal_panel(igt_output_t *output)
{
switch (output->config.connector->connector_type) {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 5755b160d..df8b07c13 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -407,6 +407,9 @@ igt_output_t *igt_output_from_connector(igt_display_t *display,
drmModeConnector *connector);
igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type);
+int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type);
+igt_plane_t *igt_pipe_get_plane_type_index(igt_pipe_t *pipe, int plane_type,
+ int index);
igt_output_t *igt_get_single_output_for_pipe(igt_display_t *display, enum pipe pipe);
void igt_pipe_request_out_fence(igt_pipe_t *pipe);