aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_crtc.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ee63a123235c..0a22ef80d28e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3074,6 +3074,24 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
3074} 3074}
3075EXPORT_SYMBOL(drm_mode_connector_update_edid_property); 3075EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
3076 3076
3077static bool drm_property_change_is_valid(struct drm_property *property,
3078 __u64 value)
3079{
3080 if (property->flags & DRM_MODE_PROP_IMMUTABLE)
3081 return false;
3082 if (property->flags & DRM_MODE_PROP_RANGE) {
3083 if (value < property->values[0] || value > property->values[1])
3084 return false;
3085 return true;
3086 } else {
3087 int i;
3088 for (i = 0; i < property->num_values; i++)
3089 if (property->values[i] == value)
3090 return true;
3091 return false;
3092 }
3093}
3094
3077int drm_mode_connector_property_set_ioctl(struct drm_device *dev, 3095int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
3078 void *data, struct drm_file *file_priv) 3096 void *data, struct drm_file *file_priv)
3079{ 3097{
@@ -3110,28 +3128,9 @@ int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
3110 } 3128 }
3111 property = obj_to_property(obj); 3129 property = obj_to_property(obj);
3112 3130
3113 if (property->flags & DRM_MODE_PROP_IMMUTABLE) 3131 if (!drm_property_change_is_valid(property, out_resp->value))
3114 goto out; 3132 goto out;
3115 3133
3116 if (property->flags & DRM_MODE_PROP_RANGE) {
3117 if (out_resp->value < property->values[0])
3118 goto out;
3119
3120 if (out_resp->value > property->values[1])
3121 goto out;
3122 } else {
3123 int found = 0;
3124 for (i = 0; i < property->num_values; i++) {
3125 if (property->values[i] == out_resp->value) {
3126 found = 1;
3127 break;
3128 }
3129 }
3130 if (!found) {
3131 goto out;
3132 }
3133 }
3134
3135 /* Do DPMS ourselves */ 3134 /* Do DPMS ourselves */
3136 if (property == connector->dev->mode_config.dpms_property) { 3135 if (property == connector->dev->mode_config.dpms_property) {
3137 if (connector->funcs->dpms) 3136 if (connector->funcs->dpms)