[PATCH] drm: Pretty print out the reason for rejecting the mode

Chris Wilson chris at chris-wilson.co.uk
Tue Apr 5 13:50:15 PDT 2011


Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/drm_modes.c |   52 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 25bf873..b3e07ac 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -853,6 +853,52 @@ void drm_mode_validate_clocks(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_validate_clocks);
 
+static const char *mode_status_to_string(enum drm_mode_status status)
+{
+	const char *strings[] = {
+		[MODE_OK] = "OK",
+		[MODE_HSYNC] = "hsync out of range",
+		[MODE_VSYNC] = "vsync out of range",
+		[MODE_H_ILLEGAL] = "illegal horizontal timings",
+		[MODE_V_ILLEGAL] = "illegal vertical timings",
+		[MODE_BAD_WIDTH] = "requires an unsupported linepitch",
+		[MODE_NOMODE] = "no mode with a maching name",
+		[MODE_NO_INTERLACE] = "interlaced mode not supported",
+		[MODE_NO_DBLESCAN] = "doublescan mode not supported",
+		[MODE_NO_VSCAN] = "multiscan mode not supported",
+		[MODE_MEM] = "insufficient video memory",
+		[MODE_VIRTUAL_X] = "mode width too large for specified virtual size",
+		[MODE_VIRTUAL_Y] = "mode height too large for specified virtual size",
+		[MODE_MEM_VIRT] = "insufficient video memory given virtual size",
+		[MODE_NOCLOCK] = "no fixed clock available",
+		[MODE_CLOCK_HIGH] = "clock required is too high",
+		[MODE_CLOCK_LOW] = "clock required is too low",
+		[MODE_CLOCK_RANGE] = "clock/mode isn't in a ClockRange",
+		[MODE_BAD_HVALUE] = "horizontal timing was out of range",
+		[MODE_BAD_VVALUE] = "vertical timing was out of range",
+		[MODE_BAD_VSCAN] = "VScan value out of range",
+		[MODE_HSYNC_NARROW] = "horizontal sync too narrow",
+		[MODE_HSYNC_WIDE] = "horizontal sync too wide",
+		[MODE_HBLANK_NARROW] = "horizontal blanking too narrow",
+		[MODE_HBLANK_WIDE] = "horizontal blanking too wide",
+		[MODE_VSYNC_NARROW] = "vertical sync too narrow",
+		[MODE_VSYNC_WIDE] = "vertical sync too wide",
+		[MODE_VBLANK_NARROW] = "vertical blanking too narrow",
+		[MODE_VBLANK_WIDE] = "vertical blanking too wide",
+		[MODE_PANEL] = "exceeds panel dimensions",
+		[MODE_INTERLACE_WIDTH] = "width too large for interlaced mode",
+		[MODE_ONE_WIDTH] = "only one width is supported",
+		[MODE_ONE_HEIGHT] = "only one height is supported",
+		[MODE_ONE_SIZE] = "only one resolution is supported",
+		[MODE_NO_REDUCED] = "monitor doesn't accept reduced blanking",
+	};
+
+	if ((unsigned)status > ARRAY_SIZE(strings))
+		return "unknown";
+
+	return strings[status];
+}
+
 /**
  * drm_mode_prune_invalid - remove invalid modes from mode list
  * @dev: DRM device
@@ -876,8 +922,10 @@ void drm_mode_prune_invalid(struct drm_device *dev,
 			list_del(&mode->head);
 			if (verbose) {
 				drm_mode_debug_printmodeline(mode);
-				DRM_DEBUG_KMS("Not using %s mode %d\n",
-					mode->name, mode->status);
+				DRM_DEBUG_KMS("Not using %s mode: %s [%d]\n",
+					      mode->name,
+					      mode_status_to_string(mode->status),
+					      mode->status);
 			}
 			drm_mode_destroy(dev, mode);
 		}
-- 
1.7.4.1



More information about the dri-devel mailing list