drm: Reject stereo modes with an unknown layout
authorDamien Lespiau <damien.lespiau@intel.com>
Fri, 27 Sep 2013 11:11:50 +0000 (12:11 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 1 Oct 2013 05:45:45 +0000 (07:45 +0200)
The kernel shouldn't accept invalid modes, just say No.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_crtc.c
include/drm/drm_crtc.h
include/uapi/drm/drm_mode.h

index 2ce80ed55b083051d83c0888f09867b3a34f6057..d7a8370e3cdc4a5881e3c1b28ba74d089f18a8fc 100644 (file)
@@ -1319,6 +1319,9 @@ static int drm_crtc_convert_umode(struct drm_display_mode *out,
        if (in->clock > INT_MAX || in->vrefresh > INT_MAX)
                return -ERANGE;
 
+       if ((in->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX)
+               return -EINVAL;
+
        out->clock = in->clock;
        out->hdisplay = in->hdisplay;
        out->hsync_start = in->hsync_start;
index eb6b8dc971d9519ba250be88b26d7399a6ec1afe..50cedadc9fcc05c33a209ffd19be4be440233c23 100644 (file)
@@ -128,6 +128,8 @@ enum drm_mode_status {
 #define CRTC_INTERLACE_HALVE_V (1 << 0) /* halve V values for interlacing */
 #define CRTC_STEREO_DOUBLE     (1 << 1) /* adjust timings for stereo modes */
 
+#define DRM_MODE_FLAG_3D_MAX   DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
+
 struct drm_display_mode {
        /* Header */
        struct list_head head;
index 7980f89940700b190df28f147ed8d03d58263a08..c2c4ace3db610abc481240031a396ca76eabcaec 100644 (file)
 #define DRM_MODE_FLAG_PIXMUX                   (1<<11)
 #define DRM_MODE_FLAG_DBLCLK                   (1<<12)
 #define DRM_MODE_FLAG_CLKDIV2                  (1<<13)
+ /*
+  * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
+  * (define not exposed to user space).
+  */
 #define DRM_MODE_FLAG_3D_MASK                  (0x1f<<14)
 #define  DRM_MODE_FLAG_3D_NONE                 (0<<14)
 #define  DRM_MODE_FLAG_3D_FRAME_PACKING                (1<<14)