Commit 60fc332c authored by Chris Wilson's avatar Chris Wilson

drm/i915/overlay: Tidy attribute checking.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8d74f656
...@@ -1314,6 +1314,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, ...@@ -1314,6 +1314,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
ret = -EINVAL;
if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) { if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) {
attrs->color_key = overlay->color_key; attrs->color_key = overlay->color_key;
attrs->brightness = overlay->brightness; attrs->brightness = overlay->brightness;
...@@ -1328,29 +1329,18 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, ...@@ -1328,29 +1329,18 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
attrs->gamma4 = I915_READ(OGAMC4); attrs->gamma4 = I915_READ(OGAMC4);
attrs->gamma5 = I915_READ(OGAMC5); attrs->gamma5 = I915_READ(OGAMC5);
} }
ret = 0;
} else { } else {
overlay->color_key = attrs->color_key; if (attrs->brightness < -128 || attrs->brightness > 127)
if (attrs->brightness >= -128 && attrs->brightness <= 127) {
overlay->brightness = attrs->brightness;
} else {
ret = -EINVAL;
goto out_unlock; goto out_unlock;
} if (attrs->contrast > 255)
goto out_unlock;
if (attrs->contrast <= 255) { if (attrs->saturation > 1023)
overlay->contrast = attrs->contrast;
} else {
ret = -EINVAL;
goto out_unlock; goto out_unlock;
}
if (attrs->saturation <= 1023) { overlay->color_key = attrs->color_key;
overlay->brightness = attrs->brightness;
overlay->contrast = attrs->contrast;
overlay->saturation = attrs->saturation; overlay->saturation = attrs->saturation;
} else {
ret = -EINVAL;
goto out_unlock;
}
regs = intel_overlay_map_regs(overlay); regs = intel_overlay_map_regs(overlay);
if (!regs) { if (!regs) {
...@@ -1363,10 +1353,8 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, ...@@ -1363,10 +1353,8 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
intel_overlay_unmap_regs(overlay); intel_overlay_unmap_regs(overlay);
if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) { if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) {
if (!IS_I9XX(dev)) { if (!IS_I9XX(dev))
ret = -EINVAL;
goto out_unlock; goto out_unlock;
}
if (overlay->active) { if (overlay->active) {
ret = -EBUSY; ret = -EBUSY;
...@@ -1374,7 +1362,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, ...@@ -1374,7 +1362,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
} }
ret = check_gamma(attrs); ret = check_gamma(attrs);
if (ret != 0) if (ret)
goto out_unlock; goto out_unlock;
I915_WRITE(OGAMC0, attrs->gamma0); I915_WRITE(OGAMC0, attrs->gamma0);
...@@ -1384,9 +1372,9 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, ...@@ -1384,9 +1372,9 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
I915_WRITE(OGAMC4, attrs->gamma4); I915_WRITE(OGAMC4, attrs->gamma4);
I915_WRITE(OGAMC5, attrs->gamma5); I915_WRITE(OGAMC5, attrs->gamma5);
} }
ret = 0;
} }
ret = 0;
out_unlock: out_unlock:
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&dev->mode_config.mutex);
......
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