Commit 05acaec3 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

drm: Reorganize probed mode validation

Make drm_mode_validate_size() and drm_mode_validate_flag() deal with a
single mode instead of having each iterate through the mode list.

The hope is that in the future we might be able to share various mode
validation functions between modeset and get_modes.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent ef21bf73
...@@ -907,8 +907,7 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); ...@@ -907,8 +907,7 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
/** /**
* drm_mode_validate_size - make sure modes adhere to size constraints * drm_mode_validate_size - make sure modes adhere to size constraints
* @dev: DRM device * @mode: mode to check
* @mode_list: list of modes to check
* @maxX: maximum width * @maxX: maximum width
* @maxY: maximum height * @maxY: maximum height
* *
...@@ -916,20 +915,21 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); ...@@ -916,20 +915,21 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
* limitations of the DRM device/connector. If a mode is too big its status * limitations of the DRM device/connector. If a mode is too big its status
* member is updated with the appropriate validation failure code. The list * member is updated with the appropriate validation failure code. The list
* itself is not changed. * itself is not changed.
*
* Returns:
* The mode status
*/ */
void drm_mode_validate_size(struct drm_device *dev, enum drm_mode_status
struct list_head *mode_list, drm_mode_validate_size(const struct drm_display_mode *mode,
int maxX, int maxY) int maxX, int maxY)
{ {
struct drm_display_mode *mode; if (maxX > 0 && mode->hdisplay > maxX)
return MODE_VIRTUAL_X;
list_for_each_entry(mode, mode_list, head) { if (maxY > 0 && mode->vdisplay > maxY)
if (maxX > 0 && mode->hdisplay > maxX) return MODE_VIRTUAL_Y;
mode->status = MODE_VIRTUAL_X;
if (maxY > 0 && mode->vdisplay > maxY) return MODE_OK;
mode->status = MODE_VIRTUAL_Y;
}
} }
EXPORT_SYMBOL(drm_mode_validate_size); EXPORT_SYMBOL(drm_mode_validate_size);
......
...@@ -58,28 +58,23 @@ ...@@ -58,28 +58,23 @@
static bool drm_kms_helper_poll = true; static bool drm_kms_helper_poll = true;
module_param_named(poll, drm_kms_helper_poll, bool, 0600); module_param_named(poll, drm_kms_helper_poll, bool, 0600);
static void drm_mode_validate_flag(struct drm_connector *connector, static enum drm_mode_status
int flags) drm_mode_validate_flag(const struct drm_display_mode *mode,
int flags)
{ {
struct drm_display_mode *mode; if ((mode->flags & DRM_MODE_FLAG_INTERLACE) &&
!(flags & DRM_MODE_FLAG_INTERLACE))
return MODE_NO_INTERLACE;
if (flags == (DRM_MODE_FLAG_DBLSCAN | DRM_MODE_FLAG_INTERLACE | if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) &&
DRM_MODE_FLAG_3D_MASK)) !(flags & DRM_MODE_FLAG_DBLSCAN))
return; return MODE_NO_DBLESCAN;
list_for_each_entry(mode, &connector->modes, head) { if ((mode->flags & DRM_MODE_FLAG_3D_MASK) &&
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !(flags & DRM_MODE_FLAG_3D_MASK))
!(flags & DRM_MODE_FLAG_INTERLACE)) return MODE_NO_STEREO;
mode->status = MODE_NO_INTERLACE;
if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) &&
!(flags & DRM_MODE_FLAG_DBLSCAN))
mode->status = MODE_NO_DBLESCAN;
if ((mode->flags & DRM_MODE_FLAG_3D_MASK) &&
!(flags & DRM_MODE_FLAG_3D_MASK))
mode->status = MODE_NO_STEREO;
}
return; return MODE_OK;
} }
static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector) static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector)
...@@ -164,18 +159,19 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect ...@@ -164,18 +159,19 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
drm_mode_connector_list_update(connector, merge_type_bits); drm_mode_connector_list_update(connector, merge_type_bits);
if (maxX && maxY)
drm_mode_validate_size(dev, &connector->modes, maxX, maxY);
if (connector->interlace_allowed) if (connector->interlace_allowed)
mode_flags |= DRM_MODE_FLAG_INTERLACE; mode_flags |= DRM_MODE_FLAG_INTERLACE;
if (connector->doublescan_allowed) if (connector->doublescan_allowed)
mode_flags |= DRM_MODE_FLAG_DBLSCAN; mode_flags |= DRM_MODE_FLAG_DBLSCAN;
if (connector->stereo_allowed) if (connector->stereo_allowed)
mode_flags |= DRM_MODE_FLAG_3D_MASK; mode_flags |= DRM_MODE_FLAG_3D_MASK;
drm_mode_validate_flag(connector, mode_flags);
list_for_each_entry(mode, &connector->modes, head) { list_for_each_entry(mode, &connector->modes, head) {
mode->status = drm_mode_validate_size(mode, maxX, maxY);
if (mode->status == MODE_OK)
mode->status = drm_mode_validate_flag(mode, mode_flags);
if (mode->status == MODE_OK && connector_funcs->mode_valid) if (mode->status == MODE_OK && connector_funcs->mode_valid)
mode->status = connector_funcs->mode_valid(connector, mode->status = connector_funcs->mode_valid(connector,
mode); mode);
......
...@@ -217,9 +217,8 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, ...@@ -217,9 +217,8 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
const struct drm_display_mode *mode2); const struct drm_display_mode *mode2);
/* for use by the crtc helper probe functions */ /* for use by the crtc helper probe functions */
void drm_mode_validate_size(struct drm_device *dev, enum drm_mode_status drm_mode_validate_size(const struct drm_display_mode *mode,
struct list_head *mode_list, int maxX, int maxY);
int maxX, int maxY);
void drm_mode_prune_invalid(struct drm_device *dev, void drm_mode_prune_invalid(struct drm_device *dev,
struct list_head *mode_list, bool verbose); struct list_head *mode_list, bool verbose);
void drm_mode_sort(struct list_head *mode_list); void drm_mode_sort(struct list_head *mode_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment