[Intel-gfx] [PATCH igt 03/28] lib: Introduce symbolic names for display planes
Damien Lespiau
damien.lespiau at intel.com
Fri Feb 7 15:48:47 CET 2014
It'd be nice to have symbolic names for planes instead of using an index
in igt_output_get_plane().
We also namespace the enum to not conflict with anyone.
Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
lib/igt_display.h | 18 +++++++++---------
lib/igt_kms.c | 18 ++++++++++++++++--
lib/igt_kms.h | 2 +-
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/lib/igt_display.h b/lib/igt_display.h
index 84638b2..77a75a7 100644
--- a/lib/igt_display.h
+++ b/lib/igt_display.h
@@ -33,16 +33,16 @@ enum pipe {
};
#define pipe_name(p) ((p) + 'A')
-/* FIXME: i915_drm.h on Android pollutes the general namespace. */
-#undef PLANE_A
-#undef PLANE_B
-
-enum plane {
- PLANE_A = 0,
- PLANE_B,
- PLANE_C,
+/* 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_CURSOR,
};
-#define plane_name(p) ((p) + 'A')
+
+const char *plane_name(enum igt_plane p);
#define sprite_name(p, s) ((p) * dev_priv->num_plane + (s) + 'A')
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index dfa6b41..e3e902a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -764,6 +764,20 @@ void kmstest_free_connector_config(struct kmstest_connector_config *config)
drmModeFreeConnector(config->connector);
}
+const char *plane_name(enum igt_plane p)
+{
+ static const char *names[] = {
+ [IGT_PLANE_1] = "plane1",
+ [IGT_PLANE_2] = "plane2",
+ [IGT_PLANE_3] = "plane3",
+ [IGT_PLANE_CURSOR] = "cursor",
+ };
+
+ igt_assert(p < ARRAY_SIZE(names) && names[p]);
+
+ return names[p];
+}
+
/*
* A small modeset API
*/
@@ -1106,12 +1120,12 @@ static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, int index)
return &pipe->planes[index];
}
-igt_plane_t *igt_ouput_get_plane(igt_output_t *output, int index)
+igt_plane_t *igt_ouput_get_plane(igt_output_t *output, enum igt_plane plane)
{
igt_pipe_t *pipe;
pipe = igt_output_get_driving_pipe(output);
- return igt_pipe_get_plane(pipe, 0);
+ return igt_pipe_get_plane(pipe, plane);
}
void igt_plane_set_fb(igt_plane_t *plane, struct kmstest_fb *fb)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 901fc1a..80cdfb6 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -154,7 +154,7 @@ void igt_display_set_verbose(igt_display_t *display, bool verbose);
const char *igt_output_name(igt_output_t *output);
drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
-igt_plane_t *igt_ouput_get_plane(igt_output_t *output, int index);
+igt_plane_t *igt_ouput_get_plane(igt_output_t *output, enum igt_plane plane);
void igt_plane_set_fb(igt_plane_t *plane, struct kmstest_fb *fb);
--
1.8.3.1
More information about the Intel-gfx
mailing list