drm/modesetting: pass object handle to driver !bo
authorDave Airlie <airlied@redhat.com>
Wed, 4 Jun 2008 03:00:31 +0000 (13:00 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 4 Jun 2008 03:00:31 +0000 (13:00 +1000)
linux-core/drm_crtc.c
linux-core/drm_crtc.h
linux-core/drm_crtc_helper.c
linux-core/drm_crtc_helper.h
linux-core/intel_display.c

index 7f84392..4f2297a 100644 (file)
@@ -619,53 +619,6 @@ int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_gro
 }
 
 /**
- * drm_get_buffer_object - find the buffer object for a given handle
- * @dev: DRM device
- * @bo: pointer to caller's buffer_object pointer
- * @handle: handle to lookup
- *
- * LOCKING:
- * Must take @dev's struct_mutex to protect buffer object lookup.
- *
- * Given @handle, lookup the buffer object in @dev and put it in the caller's
- * @bo pointer.
- *
- * RETURNS:
- * Zero on success, -EINVAL if the handle couldn't be found.
- */
-static int drm_get_buffer_object(struct drm_device *dev, struct drm_buffer_object **bo, unsigned long handle)
-{
-       struct drm_user_object *uo;
-       struct drm_hash_item *hash;
-       int ret;
-
-       *bo = NULL;
-
-       mutex_lock(&dev->struct_mutex);
-       ret = drm_ht_find_item(&dev->object_hash, handle, &hash);
-       if (ret) {
-               DRM_ERROR("Couldn't find handle.\n");
-               ret = -EINVAL;
-               goto out_err;
-       }
-
-       uo = drm_hash_entry(hash, struct drm_user_object, hash);
-       if (uo->type != drm_buffer_type) {
-               ret = -EINVAL;
-               goto out_err;
-       }
-       
-       *bo = drm_user_object_entry(uo, struct drm_buffer_object, base);
-       ret = 0;
-out_err:
-       mutex_unlock(&dev->struct_mutex);
-       return ret;
-}
-
-
-
-
-/**
  * drm_mode_config_cleanup - free up DRM mode_config info
  * @dev: DRM device
  *
@@ -1328,17 +1281,8 @@ int drm_mode_cursor_ioctl(struct drm_device *dev,
 
        if (req->flags & DRM_MODE_CURSOR_BO) {
                /* Turn of the cursor if handle is 0 */
-               if (req->handle)
-                       ret = drm_get_buffer_object(dev, &bo, req->handle);
-
-               if (ret) {
-                       DRM_ERROR("invalid buffer id\n");
-                       ret = -EINVAL;
-                       goto out;
-               }
-
                if (crtc->funcs->cursor_set) {
-                       ret = crtc->funcs->cursor_set(crtc, bo, req->width, req->height);
+                       ret = crtc->funcs->cursor_set(crtc, req->handle, req->width, req->height);
                } else {
                        DRM_ERROR("crtc does not support cursor\n");
                        ret = -EFAULT;
index 5c2d0b3..c92c59b 100644 (file)
@@ -332,7 +332,7 @@ struct drm_crtc_funcs {
        void (*restore)(struct drm_crtc *crtc); /* resume? */
 
        /* cursor controls */
-       int (*cursor_set)(struct drm_crtc *crtc, struct drm_buffer_object *bo,
+       int (*cursor_set)(struct drm_crtc *crtc, uint32_t buffer_handle,
                          uint32_t width, uint32_t height);
        int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
 
index f35c0a4..58d21b9 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * Copyright (c) 2006-2007 Intel Corporation
+/* (c) 2006-2007 Intel Corporation
  * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
  *
  * DRM core CRTC related functions
@@ -763,3 +761,48 @@ int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
        return 0;
 }
 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
+
+/**
+ * drm_get_buffer_object - find the buffer object for a given handle
+ * @dev: DRM device
+ * @bo: pointer to caller's buffer_object pointer
+ * @handle: handle to lookup
+ *
+ * LOCKING:
+ * Must take @dev's struct_mutex to protect buffer object lookup.
+ *
+ * Given @handle, lookup the buffer object in @dev and put it in the caller's
+ * @bo pointer.
+ *
+ * RETURNS:
+ * Zero on success, -EINVAL if the handle couldn't be found.
+ */
+int drm_get_buffer_object(struct drm_device *dev, struct drm_buffer_object **bo, unsigned long handle)
+{
+       struct drm_user_object *uo;
+       struct drm_hash_item *hash;
+       int ret;
+
+       *bo = NULL;
+
+       mutex_lock(&dev->struct_mutex);
+       ret = drm_ht_find_item(&dev->object_hash, handle, &hash);
+       if (ret) {
+               DRM_ERROR("Couldn't find handle.\n");
+               ret = -EINVAL;
+               goto out_err;
+       }
+
+       uo = drm_hash_entry(hash, struct drm_user_object, hash);
+       if (uo->type != drm_buffer_type) {
+               ret = -EINVAL;
+               goto out_err;
+       }
+       
+       *bo = drm_user_object_entry(uo, struct drm_buffer_object, base);
+       ret = 0;
+out_err:
+       mutex_unlock(&dev->struct_mutex);
+       return ret;
+}
+EXPORT_SYMBOL(drm_get_buffer_object);
index 460fd0d..7b7f23d 100644 (file)
@@ -91,6 +91,6 @@ static inline void drm_connector_helper_add(struct drm_connector *connector, con
        connector->helper_private = (void *)funcs;
 }
 
-
+extern int drm_get_buffer_object(struct drm_device *dev, struct drm_buffer_object **bo, unsigned long handle);
 
 #endif
index 529cae1..3f5afac 100644 (file)
@@ -972,22 +972,24 @@ void intel_crtc_load_lut(struct drm_crtc *crtc)
 }
 
 static int intel_crtc_cursor_set(struct drm_crtc *crtc,
-                                struct drm_buffer_object *bo,
+                                uint32_t handle,
                                 uint32_t width, uint32_t height)
 {
        struct drm_device *dev = crtc->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       struct drm_buffer_object *bo;
        int pipe = intel_crtc->pipe;
        uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
        uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
        uint32_t temp;
+       int ret;
        size_t addr;
 
        DRM_DEBUG("\n");
 
        /* if we want to turn of the cursor ignore width and height */
-       if (!bo) {
+       if (!handle) {
                DRM_DEBUG("cursor off\n");
                /* turn of the cursor */
                temp = 0;
@@ -1004,6 +1006,11 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
+       ret = drm_get_buffer_object(dev, &bo, handle);
+       if (ret) {
+               return -EINVAL;
+       }
+
        if ((bo->mem.flags & DRM_BO_MASK_MEM) != DRM_BO_FLAG_MEM_VRAM) {
                DRM_ERROR("buffer needs to be in VRAM\n");
                return -ENOMEM;