aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-12-17 06:56:23 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-12-17 12:29:35 -0500
commitabc0b1447d4974963548777a5ba4a4457c82c426 (patch)
tree37d56dd85aefc2ec4f297268b11242e3ddbf89fa
parent05acaec334fcc1132d1e48c5042e044651e0b75b (diff)
drm: Perform basic sanity checks on probed modes
Make sure the timings of probed modes at least pass some very basic sanity checks. The checks include: - clock,hdisplay,vdisplay are non zero - sync pulse fits within the blanking period - htotal,vtotal are big enough I have not checked all the drivers to see if the modes the generate might violate these constraints. I'm hoping not, because that would mean either abandoning the idea of doing this from the core code, or fixing the drivers. I'm not entirely sure about limiting the sync pulse to the blanking period. Intel hardware doesn't support such things, but some other hardware might. However at least HDMI doesn't allow having sync pulse edges within the active period, so I'm thinking the check is probably OK to have in the common code. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_modes.c32
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c5
-rw-r--r--include/drm/drm_modes.h1
3 files changed, 37 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 19188667f928..11cc4deca55b 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -906,6 +906,38 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
906EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); 906EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
907 907
908/** 908/**
909 * drm_mode_validate_basic - make sure the mode is somewhat sane
910 * @mode: mode to check
911 *
912 * Check that the mode timings are at least somewhat reasonable.
913 * Any hardware specific limits are left up for each driver to check.
914 *
915 * Returns:
916 * The mode status
917 */
918enum drm_mode_status
919drm_mode_validate_basic(const struct drm_display_mode *mode)
920{
921 if (mode->clock == 0)
922 return MODE_CLOCK_LOW;
923
924 if (mode->hdisplay == 0 ||
925 mode->hsync_start < mode->hdisplay ||
926 mode->hsync_end < mode->hsync_start ||
927 mode->htotal < mode->hsync_end)
928 return MODE_H_ILLEGAL;
929
930 if (mode->vdisplay == 0 ||
931 mode->vsync_start < mode->vdisplay ||
932 mode->vsync_end < mode->vsync_start ||
933 mode->vtotal < mode->vsync_end)
934 return MODE_V_ILLEGAL;
935
936 return MODE_OK;
937}
938EXPORT_SYMBOL(drm_mode_validate_basic);
939
940/**
909 * drm_mode_validate_size - make sure modes adhere to size constraints 941 * drm_mode_validate_size - make sure modes adhere to size constraints
910 * @mode: mode to check 942 * @mode: mode to check
911 * @maxX: maximum width 943 * @maxX: maximum width
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 2161d8ed7c65..2fbdcca7ca9a 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -167,7 +167,10 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
167 mode_flags |= DRM_MODE_FLAG_3D_MASK; 167 mode_flags |= DRM_MODE_FLAG_3D_MASK;
168 168
169 list_for_each_entry(mode, &connector->modes, head) { 169 list_for_each_entry(mode, &connector->modes, head) {
170 mode->status = drm_mode_validate_size(mode, maxX, maxY); 170 mode->status = drm_mode_validate_basic(mode);
171
172 if (mode->status == MODE_OK)
173 mode->status = drm_mode_validate_size(mode, maxX, maxY);
171 174
172 if (mode->status == MODE_OK) 175 if (mode->status == MODE_OK)
173 mode->status = drm_mode_validate_flag(mode, mode_flags); 176 mode->status = drm_mode_validate_flag(mode, mode_flags);
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 6c531140d458..a36a5bfce2f5 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -217,6 +217,7 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
217 const struct drm_display_mode *mode2); 217 const struct drm_display_mode *mode2);
218 218
219/* for use by the crtc helper probe functions */ 219/* for use by the crtc helper probe functions */
220enum drm_mode_status drm_mode_validate_basic(const struct drm_display_mode *mode);
220enum drm_mode_status drm_mode_validate_size(const struct drm_display_mode *mode, 221enum drm_mode_status drm_mode_validate_size(const struct drm_display_mode *mode,
221 int maxX, int maxY); 222 int maxX, int maxY);
222void drm_mode_prune_invalid(struct drm_device *dev, 223void drm_mode_prune_invalid(struct drm_device *dev,