From f8eb8c1cb4f453bdbe6a81815be8ecefba2084aa Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 28 Aug 2012 11:46:47 +1000 Subject: [PATCH] modesetting: add virtual connector support [airlied: also make sure we don't crash in future.] Signed-off-by: Alon Levy Signed-off-by: Dave Airlie --- hw/xfree86/drivers/modesetting/drmmode_display.c | 8 ++++++-- hw/xfree86/drivers/modesetting/drmmode_display.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 5e382650e..8d760c277 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -882,7 +882,8 @@ const char *output_names[] = { "None", "HDMI", "HDMI", "TV", - "eDP" + "eDP", + "Virtual" }; static void @@ -913,7 +914,10 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dv } /* need to do smart conversion here for compat with non-kms ATI driver */ - snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1); + if (koutput->connector_type >= MS_ARRAY_SIZE(output_names)) + snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1); + else + snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1); output = xf86OutputCreate (pScrn, &drmmode_output_funcs, name); if (!output) { diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h index 24f79607e..1d5522be0 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/modesetting/drmmode_display.h @@ -139,5 +139,7 @@ void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode, int *depth #define DRM_CAP_DUMB_PREFER_SHADOW 4 #endif +#define MS_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) + #endif