aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorPaulo Zanoni <paulo.r.zanoni@intel.com>2012-05-15 17:08:59 -0400
committerDave Airlie <airlied@redhat.com>2012-05-17 06:10:55 -0400
commit26a3481586eb1918a75d338e31c990deab06fb5b (patch)
tree7e3856ac64385eca73191936b20d3b5d2d070bd5 /drivers/gpu/drm/drm_crtc.c
parent4ab2c7f15423f313187b310a48ee0ac631c414f1 (diff)
drm: add drm_property_change_is_valid
Move code from drm_mode_connector_property_set_ioctl to a new function, so we can reuse this code when we add crtc properties. Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com> Reviewed-by: Rob Clark <rob.clark@linaro.org> Tested-by: Rob Clark <rob.clark@linaro.org> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-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)