lib: Introduce symbolic names for display planes

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>
This commit is contained in:
Damien Lespiau 2014-02-02 17:48:24 +00:00
parent 417987353e
commit 09e84cee8b
3 changed files with 26 additions and 12 deletions

View 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')

View 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)

View 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);