summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2013-05-30 22:53:53 +0300
committerImre Deak <imre.deak@intel.com>2013-06-06 01:43:50 +0300
commit3a2aed1f30ea0e4373fa93eab8cb33cd8dd98670 (patch)
tree0ce19233d3d816e9a1b635ef969092919f18a955 /lib
parent18bf2e6b343512cf829e8ff8eebd0958bbb59b51 (diff)
lib: move connector_type_str and co to drmtest
These are used by multiple test cases, so make them shared. Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c54
-rw-r--r--lib/drmtest.h3
2 files changed, 57 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index d17dbb02..3c4812f0 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1023,6 +1023,60 @@ void kmstest_remove_fb(int fd, int fb_id)
do_or_die(drmModeRmFB(fd, fb_id));
}
+struct type_name {
+ int type;
+ const char *name;
+};
+
+#define type_name_fn(res) \
+const char * kmstest_##res##_str(int type) { \
+ unsigned int i; \
+ for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \
+ if (res##_names[i].type == type) \
+ return res##_names[i].name; \
+ } \
+ return "(invalid)"; \
+}
+
+struct type_name encoder_type_names[] = {
+ { DRM_MODE_ENCODER_NONE, "none" },
+ { DRM_MODE_ENCODER_DAC, "DAC" },
+ { DRM_MODE_ENCODER_TMDS, "TMDS" },
+ { DRM_MODE_ENCODER_LVDS, "LVDS" },
+ { DRM_MODE_ENCODER_TVDAC, "TVDAC" },
+};
+
+type_name_fn(encoder_type)
+
+struct type_name connector_status_names[] = {
+ { DRM_MODE_CONNECTED, "connected" },
+ { DRM_MODE_DISCONNECTED, "disconnected" },
+ { DRM_MODE_UNKNOWNCONNECTION, "unknown" },
+};
+
+type_name_fn(connector_status)
+
+struct type_name connector_type_names[] = {
+ { DRM_MODE_CONNECTOR_Unknown, "unknown" },
+ { DRM_MODE_CONNECTOR_VGA, "VGA" },
+ { DRM_MODE_CONNECTOR_DVII, "DVI-I" },
+ { DRM_MODE_CONNECTOR_DVID, "DVI-D" },
+ { DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
+ { DRM_MODE_CONNECTOR_Composite, "composite" },
+ { DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
+ { DRM_MODE_CONNECTOR_LVDS, "LVDS" },
+ { DRM_MODE_CONNECTOR_Component, "component" },
+ { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
+ { DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort" },
+ { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
+ { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
+ { DRM_MODE_CONNECTOR_TV, "TV" },
+ { DRM_MODE_CONNECTOR_eDP, "Embedded DisplayPort" },
+};
+
+type_name_fn(connector_type)
+
+
void kmstest_dump_mode(drmModeModeInfo *mode)
{
printf(" %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d\n",
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 7202ad50..38aeb9d3 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -119,6 +119,9 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
void kmstest_remove_fb(int fd, int fb_id);
void kmstest_dump_mode(drmModeModeInfo *mode);
int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
+const char *kmstest_encoder_type_str(int type);
+const char *kmstest_connector_status_str(int type);
+const char *kmstest_connector_type_str(int type);
inline static void _do_or_die(const char *function, int line, int ret)
{