diff mbox

drm: Pretty print out the reason for rejecting the mode

Message ID 1302036615-14998-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson April 5, 2011, 8:50 p.m. UTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/drm_modes.c |   52 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 2 deletions(-)

Comments

Marcin Ślusarz April 5, 2011, 9:06 p.m. UTC | #1
2011/4/5 Chris Wilson <chris@chris-wilson.co.uk>:
> Signed-off-by: Chris Wilson <chris@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[] = {

+ static?

> +               [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",

s/maching/matching/

> +               [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);
>                }
> --
Julien Cristau April 5, 2011, 9:39 p.m. UTC | #2
On Tue, Apr  5, 2011 at 21:50:15 +0100, Chris Wilson wrote:

> +	if ((unsigned)status > ARRAY_SIZE(strings))

off by one?

> +		return "unknown";
> +
> +	return strings[status];
> +}
> +

Cheers,
Julien
Chris Wilson April 5, 2011, 9:41 p.m. UTC | #3
On Tue, 5 Apr 2011 23:39:19 +0200, Julien Cristau <jcristau@debian.org> wrote:
> On Tue, Apr  5, 2011 at 21:50:15 +0100, Chris Wilson wrote:
> 
> > +	if ((unsigned)status > ARRAY_SIZE(strings))
> 
> off by one?

And didn't check for holes.

/me wishes he never sent this momentarily useful bit of code. ;-)
-Chris
Henri Verbeet April 6, 2011, 2:10 p.m. UTC | #4
On 5 April 2011 23:06, Marcin ?lusarz <marcin.slusarz@gmail.com> wrote:
>> +static const char *mode_status_to_string(enum drm_mode_status status)
>> +{
>> +       const char *strings[] = {
>
> + static?
>
You'd probably even want that to be "static const char * const strings[]".
Alex Deucher April 6, 2011, 2:32 p.m. UTC | #5
On Tue, Apr 5, 2011 at 5:41 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Tue, 5 Apr 2011 23:39:19 +0200, Julien Cristau <jcristau@debian.org> wrote:
>> On Tue, Apr  5, 2011 at 21:50:15 +0100, Chris Wilson wrote:
>>
>> > +   if ((unsigned)status > ARRAY_SIZE(strings))
>>
>> off by one?
>
> And didn't check for holes.
>
> /me wishes he never sent this momentarily useful bit of code. ;-)

I think it's still useful if we can get it fixed up.  I've recently
run into some cases on radeon where this would be helpful.

Alex

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
diff mbox

Patch

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