lib: Introduce symbolic names for display planes
authorDamien Lespiau <damien.lespiau@intel.com>
Sun, 2 Feb 2014 17:48:24 +0000 (17:48 +0000)
committerDamien Lespiau <damien.lespiau@intel.com>
Tue, 11 Feb 2014 13:50:16 +0000 (13:50 +0000)
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@intel.com>
lib/igt_display.h
lib/igt_kms.c
lib/igt_kms.h

index 84638b2..77a75a7 100644 (file)
@@ -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')
 
index 4f3ea32..ab02c28 100644 (file)
@@ -765,6 +765,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
  */
@@ -1107,12 +1121,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)
index 901fc1a..80cdfb6 100644 (file)
@@ -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);