diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-12 05:44:45 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-08 05:23:43 -0400 |
commit | 60fc332cb5ab19e5a86d696b210df65814b2ad8a (patch) | |
tree | 6e765e4a35983bb1668967256a10502313896919 /drivers | |
parent | 8d74f656dd78ae1ba813389cd46197c6329696bc (diff) |
drm/i915/overlay: Tidy attribute checking.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/intel_overlay.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c index 0c13e1b88cbe..ab2a8cad8129 100644 --- a/drivers/gpu/drm/i915/intel_overlay.c +++ b/drivers/gpu/drm/i915/intel_overlay.c | |||
@@ -1314,10 +1314,11 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, | |||
1314 | mutex_lock(&dev->mode_config.mutex); | 1314 | mutex_lock(&dev->mode_config.mutex); |
1315 | mutex_lock(&dev->struct_mutex); | 1315 | mutex_lock(&dev->struct_mutex); |
1316 | 1316 | ||
1317 | ret = -EINVAL; | ||
1317 | if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) { | 1318 | if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) { |
1318 | attrs->color_key = overlay->color_key; | 1319 | attrs->color_key = overlay->color_key; |
1319 | attrs->brightness = overlay->brightness; | 1320 | attrs->brightness = overlay->brightness; |
1320 | attrs->contrast = overlay->contrast; | 1321 | attrs->contrast = overlay->contrast; |
1321 | attrs->saturation = overlay->saturation; | 1322 | attrs->saturation = overlay->saturation; |
1322 | 1323 | ||
1323 | if (IS_I9XX(dev)) { | 1324 | if (IS_I9XX(dev)) { |
@@ -1328,29 +1329,18 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, | |||
1328 | attrs->gamma4 = I915_READ(OGAMC4); | 1329 | attrs->gamma4 = I915_READ(OGAMC4); |
1329 | attrs->gamma5 = I915_READ(OGAMC5); | 1330 | attrs->gamma5 = I915_READ(OGAMC5); |
1330 | } | 1331 | } |
1331 | ret = 0; | ||
1332 | } else { | 1332 | } else { |
1333 | overlay->color_key = attrs->color_key; | 1333 | if (attrs->brightness < -128 || attrs->brightness > 127) |
1334 | if (attrs->brightness >= -128 && attrs->brightness <= 127) { | ||
1335 | overlay->brightness = attrs->brightness; | ||
1336 | } else { | ||
1337 | ret = -EINVAL; | ||
1338 | goto out_unlock; | 1334 | goto out_unlock; |
1339 | } | 1335 | if (attrs->contrast > 255) |
1340 | |||
1341 | if (attrs->contrast <= 255) { | ||
1342 | overlay->contrast = attrs->contrast; | ||
1343 | } else { | ||
1344 | ret = -EINVAL; | ||
1345 | goto out_unlock; | 1336 | goto out_unlock; |
1346 | } | 1337 | if (attrs->saturation > 1023) |
1347 | |||
1348 | if (attrs->saturation <= 1023) { | ||
1349 | overlay->saturation = attrs->saturation; | ||
1350 | } else { | ||
1351 | ret = -EINVAL; | ||
1352 | goto out_unlock; | 1338 | goto out_unlock; |
1353 | } | 1339 | |
1340 | overlay->color_key = attrs->color_key; | ||
1341 | overlay->brightness = attrs->brightness; | ||
1342 | overlay->contrast = attrs->contrast; | ||
1343 | overlay->saturation = attrs->saturation; | ||
1354 | 1344 | ||
1355 | regs = intel_overlay_map_regs(overlay); | 1345 | regs = intel_overlay_map_regs(overlay); |
1356 | if (!regs) { | 1346 | if (!regs) { |
@@ -1363,10 +1353,8 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, | |||
1363 | intel_overlay_unmap_regs(overlay); | 1353 | intel_overlay_unmap_regs(overlay); |
1364 | 1354 | ||
1365 | if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) { | 1355 | if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) { |
1366 | if (!IS_I9XX(dev)) { | 1356 | if (!IS_I9XX(dev)) |
1367 | ret = -EINVAL; | ||
1368 | goto out_unlock; | 1357 | goto out_unlock; |
1369 | } | ||
1370 | 1358 | ||
1371 | if (overlay->active) { | 1359 | if (overlay->active) { |
1372 | ret = -EBUSY; | 1360 | ret = -EBUSY; |
@@ -1374,7 +1362,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, | |||
1374 | } | 1362 | } |
1375 | 1363 | ||
1376 | ret = check_gamma(attrs); | 1364 | ret = check_gamma(attrs); |
1377 | if (ret != 0) | 1365 | if (ret) |
1378 | goto out_unlock; | 1366 | goto out_unlock; |
1379 | 1367 | ||
1380 | I915_WRITE(OGAMC0, attrs->gamma0); | 1368 | I915_WRITE(OGAMC0, attrs->gamma0); |
@@ -1384,9 +1372,9 @@ int intel_overlay_attrs(struct drm_device *dev, void *data, | |||
1384 | I915_WRITE(OGAMC4, attrs->gamma4); | 1372 | I915_WRITE(OGAMC4, attrs->gamma4); |
1385 | I915_WRITE(OGAMC5, attrs->gamma5); | 1373 | I915_WRITE(OGAMC5, attrs->gamma5); |
1386 | } | 1374 | } |
1387 | ret = 0; | ||
1388 | } | 1375 | } |
1389 | 1376 | ||
1377 | ret = 0; | ||
1390 | out_unlock: | 1378 | out_unlock: |
1391 | mutex_unlock(&dev->struct_mutex); | 1379 | mutex_unlock(&dev->struct_mutex); |
1392 | mutex_unlock(&dev->mode_config.mutex); | 1380 | mutex_unlock(&dev->mode_config.mutex); |