Commit 3f8bc370 authored by Kristian Høgsberg's avatar Kristian Høgsberg Committed by Dave Airlie

drm/i915: Pin cursor bo and unpin old bo when setting cursor.

We also didn't track the cursor bo before and would leak a reference
when the cursor image was change.
Signed-off-by: default avatarKristian Høgsberg <krh@redhat.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent 9bb2d6f9
...@@ -986,19 +986,17 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -986,19 +986,17 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
uint32_t base = (pipe == 0) ? CURABASE : CURBBASE; uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
uint32_t temp; uint32_t temp;
size_t addr; size_t addr;
int ret;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
/* if we want to turn off the cursor ignore width and height */ /* if we want to turn off the cursor ignore width and height */
if (!handle) { if (!handle) {
DRM_DEBUG("cursor off\n"); DRM_DEBUG("cursor off\n");
/* turn of the cursor */ temp = CURSOR_MODE_DISABLE;
temp = 0; addr = 0;
temp |= CURSOR_MODE_DISABLE; bo = NULL;
goto finish;
I915_WRITE(control, temp);
I915_WRITE(base, 0);
return 0;
} }
/* Currently we only support 64x64 cursors */ /* Currently we only support 64x64 cursors */
...@@ -1025,15 +1023,30 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1025,15 +1023,30 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
addr = obj_priv->gtt_offset; addr = obj_priv->gtt_offset;
} }
intel_crtc->cursor_addr = addr; ret = i915_gem_object_pin(bo, PAGE_SIZE);
if (ret) {
DRM_ERROR("failed to pin cursor bo\n");
drm_gem_object_unreference(bo);
return ret;
}
temp = 0; temp = 0;
/* set the pipe for the cursor */ /* set the pipe for the cursor */
temp |= (pipe << 28); temp |= (pipe << 28);
temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
finish:
I915_WRITE(control, temp); I915_WRITE(control, temp);
I915_WRITE(base, addr); I915_WRITE(base, addr);
if (intel_crtc->cursor_bo) {
i915_gem_object_unpin(intel_crtc->cursor_bo);
drm_gem_object_unreference(intel_crtc->cursor_bo);
}
intel_crtc->cursor_addr = addr;
intel_crtc->cursor_bo = bo;
return 0; return 0;
} }
......
...@@ -88,6 +88,7 @@ struct intel_crtc { ...@@ -88,6 +88,7 @@ struct intel_crtc {
struct drm_crtc base; struct drm_crtc base;
int pipe; int pipe;
int plane; int plane;
struct drm_gem_object *cursor_bo;
uint32_t cursor_addr; uint32_t cursor_addr;
u8 lut_r[256], lut_g[256], lut_b[256]; u8 lut_r[256], lut_g[256], lut_b[256];
int dpms_mode; int dpms_mode;
......
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