aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_overlay.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-11-08 14:18:58 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2010-11-23 15:19:10 -0500
commit05394f3975dceb107a5e1393e2244946e5b43660 (patch)
tree2af73b6efec503ed4cd9c932018619bd28a1fe60 /drivers/gpu/drm/i915/intel_overlay.c
parent185cbcb304ba4dee55e39593fd86dcd7813f62ec (diff)
drm/i915: Use drm_i915_gem_object as the preferred type
A glorified s/obj_priv/obj/ with a net reduction of over a 100 lines and many characters! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_overlay.c')
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index ec8ffaccbbdb..af715cc03ee0 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -376,24 +376,23 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
376 376
377static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay) 377static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay)
378{ 378{
379 struct drm_gem_object *obj = &overlay->old_vid_bo->base; 379 struct drm_i915_gem_object *obj = overlay->old_vid_bo;
380 380
381 i915_gem_object_unpin(obj); 381 i915_gem_object_unpin(obj);
382 drm_gem_object_unreference(obj); 382 drm_gem_object_unreference(&obj->base);
383 383
384 overlay->old_vid_bo = NULL; 384 overlay->old_vid_bo = NULL;
385} 385}
386 386
387static void intel_overlay_off_tail(struct intel_overlay *overlay) 387static void intel_overlay_off_tail(struct intel_overlay *overlay)
388{ 388{
389 struct drm_gem_object *obj; 389 struct drm_i915_gem_object *obj = overlay->vid_bo;
390 390
391 /* never have the overlay hw on without showing a frame */ 391 /* never have the overlay hw on without showing a frame */
392 BUG_ON(!overlay->vid_bo); 392 BUG_ON(!overlay->vid_bo);
393 obj = &overlay->vid_bo->base;
394 393
395 i915_gem_object_unpin(obj); 394 i915_gem_object_unpin(obj);
396 drm_gem_object_unreference(obj); 395 drm_gem_object_unreference(&obj->base);
397 overlay->vid_bo = NULL; 396 overlay->vid_bo = NULL;
398 397
399 overlay->crtc->overlay = NULL; 398 overlay->crtc->overlay = NULL;
@@ -764,13 +763,12 @@ static u32 overlay_cmd_reg(struct put_image_params *params)
764} 763}
765 764
766static int intel_overlay_do_put_image(struct intel_overlay *overlay, 765static int intel_overlay_do_put_image(struct intel_overlay *overlay,
767 struct drm_gem_object *new_bo, 766 struct drm_i915_gem_object *new_bo,
768 struct put_image_params *params) 767 struct put_image_params *params)
769{ 768{
770 int ret, tmp_width; 769 int ret, tmp_width;
771 struct overlay_registers *regs; 770 struct overlay_registers *regs;
772 bool scale_changed = false; 771 bool scale_changed = false;
773 struct drm_i915_gem_object *bo_priv = to_intel_bo(new_bo);
774 struct drm_device *dev = overlay->dev; 772 struct drm_device *dev = overlay->dev;
775 773
776 BUG_ON(!mutex_is_locked(&dev->struct_mutex)); 774 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
@@ -825,7 +823,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
825 regs->SWIDTHSW = calc_swidthsw(overlay->dev, 823 regs->SWIDTHSW = calc_swidthsw(overlay->dev,
826 params->offset_Y, tmp_width); 824 params->offset_Y, tmp_width);
827 regs->SHEIGHT = params->src_h; 825 regs->SHEIGHT = params->src_h;
828 regs->OBUF_0Y = bo_priv->gtt_offset + params-> offset_Y; 826 regs->OBUF_0Y = new_bo->gtt_offset + params-> offset_Y;
829 regs->OSTRIDE = params->stride_Y; 827 regs->OSTRIDE = params->stride_Y;
830 828
831 if (params->format & I915_OVERLAY_YUV_PLANAR) { 829 if (params->format & I915_OVERLAY_YUV_PLANAR) {
@@ -839,8 +837,8 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
839 params->src_w/uv_hscale); 837 params->src_w/uv_hscale);
840 regs->SWIDTHSW |= max_t(u32, tmp_U, tmp_V) << 16; 838 regs->SWIDTHSW |= max_t(u32, tmp_U, tmp_V) << 16;
841 regs->SHEIGHT |= (params->src_h/uv_vscale) << 16; 839 regs->SHEIGHT |= (params->src_h/uv_vscale) << 16;
842 regs->OBUF_0U = bo_priv->gtt_offset + params->offset_U; 840 regs->OBUF_0U = new_bo->gtt_offset + params->offset_U;
843 regs->OBUF_0V = bo_priv->gtt_offset + params->offset_V; 841 regs->OBUF_0V = new_bo->gtt_offset + params->offset_V;
844 regs->OSTRIDE |= params->stride_UV << 16; 842 regs->OSTRIDE |= params->stride_UV << 16;
845 } 843 }
846 844
@@ -857,7 +855,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
857 goto out_unpin; 855 goto out_unpin;
858 856
859 overlay->old_vid_bo = overlay->vid_bo; 857 overlay->old_vid_bo = overlay->vid_bo;
860 overlay->vid_bo = to_intel_bo(new_bo); 858 overlay->vid_bo = new_bo;
861 859
862 return 0; 860 return 0;
863 861
@@ -970,7 +968,7 @@ static int check_overlay_scaling(struct put_image_params *rec)
970 968
971static int check_overlay_src(struct drm_device *dev, 969static int check_overlay_src(struct drm_device *dev,
972 struct drm_intel_overlay_put_image *rec, 970 struct drm_intel_overlay_put_image *rec,
973 struct drm_gem_object *new_bo) 971 struct drm_i915_gem_object *new_bo)
974{ 972{
975 int uv_hscale = uv_hsubsampling(rec->flags); 973 int uv_hscale = uv_hsubsampling(rec->flags);
976 int uv_vscale = uv_vsubsampling(rec->flags); 974 int uv_vscale = uv_vsubsampling(rec->flags);
@@ -1055,7 +1053,7 @@ static int check_overlay_src(struct drm_device *dev,
1055 return -EINVAL; 1053 return -EINVAL;
1056 1054
1057 tmp = rec->stride_Y*rec->src_height; 1055 tmp = rec->stride_Y*rec->src_height;
1058 if (rec->offset_Y + tmp > new_bo->size) 1056 if (rec->offset_Y + tmp > new_bo->base.size)
1059 return -EINVAL; 1057 return -EINVAL;
1060 break; 1058 break;
1061 1059
@@ -1066,12 +1064,12 @@ static int check_overlay_src(struct drm_device *dev,
1066 return -EINVAL; 1064 return -EINVAL;
1067 1065
1068 tmp = rec->stride_Y * rec->src_height; 1066 tmp = rec->stride_Y * rec->src_height;
1069 if (rec->offset_Y + tmp > new_bo->size) 1067 if (rec->offset_Y + tmp > new_bo->base.size)
1070 return -EINVAL; 1068 return -EINVAL;
1071 1069
1072 tmp = rec->stride_UV * (rec->src_height / uv_vscale); 1070 tmp = rec->stride_UV * (rec->src_height / uv_vscale);
1073 if (rec->offset_U + tmp > new_bo->size || 1071 if (rec->offset_U + tmp > new_bo->base.size ||
1074 rec->offset_V + tmp > new_bo->size) 1072 rec->offset_V + tmp > new_bo->base.size)
1075 return -EINVAL; 1073 return -EINVAL;
1076 break; 1074 break;
1077 } 1075 }
@@ -1114,7 +1112,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
1114 struct intel_overlay *overlay; 1112 struct intel_overlay *overlay;
1115 struct drm_mode_object *drmmode_obj; 1113 struct drm_mode_object *drmmode_obj;
1116 struct intel_crtc *crtc; 1114 struct intel_crtc *crtc;
1117 struct drm_gem_object *new_bo; 1115 struct drm_i915_gem_object *new_bo;
1118 struct put_image_params *params; 1116 struct put_image_params *params;
1119 int ret; 1117 int ret;
1120 1118
@@ -1153,8 +1151,8 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
1153 } 1151 }
1154 crtc = to_intel_crtc(obj_to_crtc(drmmode_obj)); 1152 crtc = to_intel_crtc(obj_to_crtc(drmmode_obj));
1155 1153
1156 new_bo = drm_gem_object_lookup(dev, file_priv, 1154 new_bo = to_intel_bo(drm_gem_object_lookup(dev, file_priv,
1157 put_image_rec->bo_handle); 1155 put_image_rec->bo_handle));
1158 if (!new_bo) { 1156 if (!new_bo) {
1159 ret = -ENOENT; 1157 ret = -ENOENT;
1160 goto out_free; 1158 goto out_free;
@@ -1245,7 +1243,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
1245out_unlock: 1243out_unlock:
1246 mutex_unlock(&dev->struct_mutex); 1244 mutex_unlock(&dev->struct_mutex);
1247 mutex_unlock(&dev->mode_config.mutex); 1245 mutex_unlock(&dev->mode_config.mutex);
1248 drm_gem_object_unreference_unlocked(new_bo); 1246 drm_gem_object_unreference_unlocked(&new_bo->base);
1249out_free: 1247out_free:
1250 kfree(params); 1248 kfree(params);
1251 1249
@@ -1398,7 +1396,7 @@ void intel_setup_overlay(struct drm_device *dev)
1398{ 1396{
1399 drm_i915_private_t *dev_priv = dev->dev_private; 1397 drm_i915_private_t *dev_priv = dev->dev_private;
1400 struct intel_overlay *overlay; 1398 struct intel_overlay *overlay;
1401 struct drm_gem_object *reg_bo; 1399 struct drm_i915_gem_object *reg_bo;
1402 struct overlay_registers *regs; 1400 struct overlay_registers *regs;
1403 int ret; 1401 int ret;
1404 1402
@@ -1413,7 +1411,7 @@ void intel_setup_overlay(struct drm_device *dev)
1413 reg_bo = i915_gem_alloc_object(dev, PAGE_SIZE); 1411 reg_bo = i915_gem_alloc_object(dev, PAGE_SIZE);
1414 if (!reg_bo) 1412 if (!reg_bo)
1415 goto out_free; 1413 goto out_free;
1416 overlay->reg_bo = to_intel_bo(reg_bo); 1414 overlay->reg_bo = reg_bo;
1417 1415
1418 if (OVERLAY_NEEDS_PHYSICAL(dev)) { 1416 if (OVERLAY_NEEDS_PHYSICAL(dev)) {
1419 ret = i915_gem_attach_phys_object(dev, reg_bo, 1417 ret = i915_gem_attach_phys_object(dev, reg_bo,
@@ -1423,14 +1421,14 @@ void intel_setup_overlay(struct drm_device *dev)
1423 DRM_ERROR("failed to attach phys overlay regs\n"); 1421 DRM_ERROR("failed to attach phys overlay regs\n");
1424 goto out_free_bo; 1422 goto out_free_bo;
1425 } 1423 }
1426 overlay->flip_addr = overlay->reg_bo->phys_obj->handle->busaddr; 1424 overlay->flip_addr = reg_bo->phys_obj->handle->busaddr;
1427 } else { 1425 } else {
1428 ret = i915_gem_object_pin(reg_bo, PAGE_SIZE, true); 1426 ret = i915_gem_object_pin(reg_bo, PAGE_SIZE, true);
1429 if (ret) { 1427 if (ret) {
1430 DRM_ERROR("failed to pin overlay register bo\n"); 1428 DRM_ERROR("failed to pin overlay register bo\n");
1431 goto out_free_bo; 1429 goto out_free_bo;
1432 } 1430 }
1433 overlay->flip_addr = overlay->reg_bo->gtt_offset; 1431 overlay->flip_addr = reg_bo->gtt_offset;
1434 1432
1435 ret = i915_gem_object_set_to_gtt_domain(reg_bo, true); 1433 ret = i915_gem_object_set_to_gtt_domain(reg_bo, true);
1436 if (ret) { 1434 if (ret) {
@@ -1462,7 +1460,7 @@ void intel_setup_overlay(struct drm_device *dev)
1462out_unpin_bo: 1460out_unpin_bo:
1463 i915_gem_object_unpin(reg_bo); 1461 i915_gem_object_unpin(reg_bo);
1464out_free_bo: 1462out_free_bo:
1465 drm_gem_object_unreference(reg_bo); 1463 drm_gem_object_unreference(&reg_bo->base);
1466out_free: 1464out_free:
1467 kfree(overlay); 1465 kfree(overlay);
1468 return; 1466 return;