* [PATCH] drm/modes: Print the mode status in human readable form
@ 2015-02-02 17:13 ville.syrjala
2015-02-02 17:56 ` Alex Deucher
0 siblings, 1 reply; 3+ messages in thread
From: ville.syrjala @ 2015-02-02 17:13 UTC (permalink / raw)
To: dri-devel
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Currently when a mode is rejected the reason is printed as a raw number.
Having to manually decode that to a enum drm_mode_status value is
tiresome. Have the code do the decoding instead and print the result
in a human readable format.
Just having an array of strings indexed with the mode status doesn't
work since the enum includes negative values. So we offset the status
by +3 which makes all the indexes non-negative. Also add a bit of
paranoia into the code to catch out of bounds accesses in case
someone adds more enum values but forgets to update the code.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/drm_modes.c | 61 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 20d977a..487d0e3 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1011,6 +1011,62 @@ drm_mode_validate_size(const struct drm_display_mode *mode,
}
EXPORT_SYMBOL(drm_mode_validate_size);
+#define MODE_STATUS(status) [MODE_ ## status + 3] = #status
+
+static const char * const drm_mode_status_names[] = {
+ MODE_STATUS(OK),
+ MODE_STATUS(HSYNC),
+ MODE_STATUS(VSYNC),
+ MODE_STATUS(H_ILLEGAL),
+ MODE_STATUS(V_ILLEGAL),
+ MODE_STATUS(BAD_WIDTH),
+ MODE_STATUS(NOMODE),
+ MODE_STATUS(NO_INTERLACE),
+ MODE_STATUS(NO_DBLESCAN),
+ MODE_STATUS(NO_VSCAN),
+ MODE_STATUS(MEM),
+ MODE_STATUS(VIRTUAL_X),
+ MODE_STATUS(VIRTUAL_Y),
+ MODE_STATUS(MEM_VIRT),
+ MODE_STATUS(NOCLOCK),
+ MODE_STATUS(CLOCK_HIGH),
+ MODE_STATUS(CLOCK_LOW),
+ MODE_STATUS(CLOCK_RANGE),
+ MODE_STATUS(BAD_HVALUE),
+ MODE_STATUS(BAD_VVALUE),
+ MODE_STATUS(BAD_VSCAN),
+ MODE_STATUS(HSYNC_NARROW),
+ MODE_STATUS(HSYNC_WIDE),
+ MODE_STATUS(HBLANK_NARROW),
+ MODE_STATUS(HBLANK_WIDE),
+ MODE_STATUS(VSYNC_NARROW),
+ MODE_STATUS(VSYNC_WIDE),
+ MODE_STATUS(VBLANK_NARROW),
+ MODE_STATUS(VBLANK_WIDE),
+ MODE_STATUS(PANEL),
+ MODE_STATUS(INTERLACE_WIDTH),
+ MODE_STATUS(ONE_WIDTH),
+ MODE_STATUS(ONE_HEIGHT),
+ MODE_STATUS(ONE_SIZE),
+ MODE_STATUS(NO_REDUCED),
+ MODE_STATUS(NO_STEREO),
+ MODE_STATUS(UNVERIFIED),
+ MODE_STATUS(BAD),
+ MODE_STATUS(ERROR),
+};
+
+#undef MODE_STATUS
+
+static const char *drm_get_mode_status_name(enum drm_mode_status status)
+{
+ int index = status + 3;
+
+ if (WARN_ON(index < 0 || index >= ARRAY_SIZE(drm_mode_status_names)))
+ return "";
+
+ return drm_mode_status_names[index];
+}
+
/**
* drm_mode_prune_invalid - remove invalid modes from mode list
* @dev: DRM device
@@ -1032,8 +1088,9 @@ 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\n",
+ mode->name,
+ drm_get_mode_status_name(mode->status));
}
drm_mode_destroy(dev, mode);
}
--
2.0.5
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/modes: Print the mode status in human readable form
2015-02-02 17:13 [PATCH] drm/modes: Print the mode status in human readable form ville.syrjala
@ 2015-02-02 17:56 ` Alex Deucher
2015-02-03 9:07 ` Daniel Vetter
0 siblings, 1 reply; 3+ messages in thread
From: Alex Deucher @ 2015-02-02 17:56 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: Maling list - DRI developers
On Mon, Feb 2, 2015 at 12:13 PM, <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Currently when a mode is rejected the reason is printed as a raw number.
> Having to manually decode that to a enum drm_mode_status value is
> tiresome. Have the code do the decoding instead and print the result
> in a human readable format.
>
> Just having an array of strings indexed with the mode status doesn't
> work since the enum includes negative values. So we offset the status
> by +3 which makes all the indexes non-negative. Also add a bit of
> paranoia into the code to catch out of bounds accesses in case
> someone adds more enum values but forgets to update the code.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/drm_modes.c | 61 +++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 59 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 20d977a..487d0e3 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1011,6 +1011,62 @@ drm_mode_validate_size(const struct drm_display_mode *mode,
> }
> EXPORT_SYMBOL(drm_mode_validate_size);
>
> +#define MODE_STATUS(status) [MODE_ ## status + 3] = #status
> +
> +static const char * const drm_mode_status_names[] = {
> + MODE_STATUS(OK),
> + MODE_STATUS(HSYNC),
> + MODE_STATUS(VSYNC),
> + MODE_STATUS(H_ILLEGAL),
> + MODE_STATUS(V_ILLEGAL),
> + MODE_STATUS(BAD_WIDTH),
> + MODE_STATUS(NOMODE),
> + MODE_STATUS(NO_INTERLACE),
> + MODE_STATUS(NO_DBLESCAN),
> + MODE_STATUS(NO_VSCAN),
> + MODE_STATUS(MEM),
> + MODE_STATUS(VIRTUAL_X),
> + MODE_STATUS(VIRTUAL_Y),
> + MODE_STATUS(MEM_VIRT),
> + MODE_STATUS(NOCLOCK),
> + MODE_STATUS(CLOCK_HIGH),
> + MODE_STATUS(CLOCK_LOW),
> + MODE_STATUS(CLOCK_RANGE),
> + MODE_STATUS(BAD_HVALUE),
> + MODE_STATUS(BAD_VVALUE),
> + MODE_STATUS(BAD_VSCAN),
> + MODE_STATUS(HSYNC_NARROW),
> + MODE_STATUS(HSYNC_WIDE),
> + MODE_STATUS(HBLANK_NARROW),
> + MODE_STATUS(HBLANK_WIDE),
> + MODE_STATUS(VSYNC_NARROW),
> + MODE_STATUS(VSYNC_WIDE),
> + MODE_STATUS(VBLANK_NARROW),
> + MODE_STATUS(VBLANK_WIDE),
> + MODE_STATUS(PANEL),
> + MODE_STATUS(INTERLACE_WIDTH),
> + MODE_STATUS(ONE_WIDTH),
> + MODE_STATUS(ONE_HEIGHT),
> + MODE_STATUS(ONE_SIZE),
> + MODE_STATUS(NO_REDUCED),
> + MODE_STATUS(NO_STEREO),
> + MODE_STATUS(UNVERIFIED),
> + MODE_STATUS(BAD),
> + MODE_STATUS(ERROR),
> +};
> +
> +#undef MODE_STATUS
> +
> +static const char *drm_get_mode_status_name(enum drm_mode_status status)
> +{
> + int index = status + 3;
> +
> + if (WARN_ON(index < 0 || index >= ARRAY_SIZE(drm_mode_status_names)))
> + return "";
> +
> + return drm_mode_status_names[index];
> +}
> +
> /**
> * drm_mode_prune_invalid - remove invalid modes from mode list
> * @dev: DRM device
> @@ -1032,8 +1088,9 @@ 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\n",
> + mode->name,
> + drm_get_mode_status_name(mode->status));
> }
> drm_mode_destroy(dev, mode);
> }
> --
> 2.0.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/modes: Print the mode status in human readable form
2015-02-02 17:56 ` Alex Deucher
@ 2015-02-03 9:07 ` Daniel Vetter
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2015-02-03 9:07 UTC (permalink / raw)
To: Alex Deucher; +Cc: Maling list - DRI developers
On Mon, Feb 02, 2015 at 12:56:26PM -0500, Alex Deucher wrote:
> On Mon, Feb 2, 2015 at 12:13 PM, <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Currently when a mode is rejected the reason is printed as a raw number.
> > Having to manually decode that to a enum drm_mode_status value is
> > tiresome. Have the code do the decoding instead and print the result
> > in a human readable format.
> >
> > Just having an array of strings indexed with the mode status doesn't
> > work since the enum includes negative values. So we offset the status
> > by +3 which makes all the indexes non-negative. Also add a bit of
> > paranoia into the code to catch out of bounds accesses in case
> > someone adds more enum values but forgets to update the code.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Merged to my drm-misc branch.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-03 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 17:13 [PATCH] drm/modes: Print the mode status in human readable form ville.syrjala
2015-02-02 17:56 ` Alex Deucher
2015-02-03 9:07 ` Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.