@@ -1025,6 +1025,7 @@ void i915_gem_object_unpin(struct drm_gem_object *obj);
int i915_gem_object_unbind(struct drm_gem_object *obj);
void i915_gem_release_mmap(struct drm_gem_object *obj);
void i915_gem_lastclose(struct drm_device *dev);
+int i915_gem_object_enable_scanout(struct drm_gem_object *obj);
/**
* Returns true if seq1 is later than seq2.
@@ -4028,6 +4028,26 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
}
int
+i915_gem_object_enable_scanout(struct drm_gem_object *obj)
+{
+ struct drm_device *dev = obj->dev;
+ struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
+ int type = IS_GEN6(dev) ? AGP_USER_UNCACHED_MEMORY : AGP_USER_MEMORY;
+
+ if (obj_priv->agp_type == type)
+ return 0;
+
+ if (obj_priv->gtt_space) {
+ int ret = i915_gem_object_unbind(obj);
+ if (ret)
+ return ret;
+ }
+
+ obj_priv->agp_type = type;
+ return 0;
+}
+
+int
i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
{
struct drm_device *dev = obj->dev;
@@ -1461,6 +1461,10 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev,
BUG();
}
+ ret = i915_gem_object_enable_scanout(obj);
+ if (ret)
+ return ret;
+
ret = i915_gem_object_pin(obj, alignment);
if (ret)
return ret;
@@ -5482,6 +5486,12 @@ intel_user_framebuffer_create(struct drm_device *dev,
if (!intel_fb)
return ERR_PTR(-ENOMEM);
+ ret = i915_gem_object_enable_scanout(obj);
+ if (ret) {
+ kfree(intel_fb);
+ return ERR_PTR(ret);
+ }
+
ret = intel_framebuffer_init(dev, intel_fb,
mode_cmd, obj);
if (ret) {