drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
[safe/jmp/linux-2.6] / drivers / char / drm / drmP.h
index 9c53b88..9dd0760 100644 (file)
@@ -34,8 +34,6 @@
 #ifndef _DRM_P_H_
 #define _DRM_P_H_
 
-struct drm_file;
-
 /* If you want the memory alloc debug functionality, change define below */
 /* #define DEBUG_MEMORY */
 
@@ -82,6 +80,9 @@ struct drm_file;
 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
 #define __OS_HAS_MTRR (defined(CONFIG_MTRR))
 
+struct drm_file;
+struct drm_device;
+
 #include "drm_os_linux.h"
 #include "drm_hashtab.h"
 
@@ -233,12 +234,13 @@ struct drm_file;
  * \param dev DRM device.
  * \param filp file pointer of the caller.
  */
-#define LOCK_TEST_WITH_RETURN( dev, filp )                             \
+#define LOCK_TEST_WITH_RETURN( dev, file_priv )                                \
 do {                                                                   \
        if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) ||           \
-            dev->lock.filp != filp ) {                         \
-               DRM_ERROR( "%s called without lock held\n",             \
-                          __FUNCTION__ );                              \
+            dev->lock.file_priv != file_priv ) {                       \
+               DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\
+                          __FUNCTION__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\
+                          dev->lock.file_priv, file_priv );            \
                return -EINVAL;                                         \
        }                                                               \
 } while (0)
@@ -263,8 +265,8 @@ do {                                                                        \
  * \param cmd command.
  * \param arg argument.
  */
-typedef int drm_ioctl_t(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
+typedef int drm_ioctl_t(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
 
 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
                               unsigned long arg);
@@ -273,10 +275,18 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
 #define        DRM_MASTER      0x2
 #define DRM_ROOT_ONLY  0x4
 
-typedef struct drm_ioctl_desc {
+struct drm_ioctl_desc {
+       unsigned int cmd;
        drm_ioctl_t *func;
        int flags;
-} drm_ioctl_desc_t;
+};
+
+/**
+ * Creates a driver or general drm_ioctl_desc array entry for the given
+ * ioctl, for use by drm_ioctl().
+ */
+#define DRM_IOCTL_DEF(ioctl, func, flags) \
+       [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags}
 
 struct drm_magic_entry {
        struct list_head head;
@@ -559,7 +569,7 @@ struct drm_driver {
        void (*postclose) (struct drm_device *, struct drm_file *);
        void (*lastclose) (struct drm_device *);
        int (*unload) (struct drm_device *);
-       int (*dma_ioctl) (DRM_IOCTL_ARGS);
+       int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
        void (*dma_ready) (struct drm_device *);
        int (*dma_quiescent) (struct drm_device *);
        int (*context_ctor) (struct drm_device *dev, int context);
@@ -610,7 +620,7 @@ struct drm_driver {
 
        u32 driver_features;
        int dev_priv_size;
-       drm_ioctl_desc_t *ioctls;
+       struct drm_ioctl_desc *ioctls;
        int num_ioctls;
        struct file_operations fops;
        struct pci_driver pci_driver;
@@ -854,70 +864,70 @@ extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
 extern int drm_unbind_agp(DRM_AGP_MEM * handle);
 
                                /* Misc. IOCTL support (drm_ioctl.h) */
-extern int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv,
-                           unsigned int cmd, unsigned long arg);
-extern int drm_getunique(struct inode *inode, struct drm_file *file_priv,
-                        unsigned int cmd, unsigned long arg);
-extern int drm_setunique(struct inode *inode, struct drm_file *file_priv,
-                        unsigned int cmd, unsigned long arg);
-extern int drm_getmap(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_getclient(struct inode *inode, struct drm_file *file_priv,
-                        unsigned int cmd, unsigned long arg);
-extern int drm_getstats(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern int drm_setversion(struct inode *inode, struct drm_file *file_priv,
-                         unsigned int cmd, unsigned long arg);
-extern int drm_noop(struct inode *inode, struct drm_file *file_priv,
-                   unsigned int cmd, unsigned long arg);
+extern int drm_irq_by_busid(struct drm_device *dev, void *data,
+                           struct drm_file *file_priv);
+extern int drm_getunique(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv);
+extern int drm_setunique(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv);
+extern int drm_getmap(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_getclient(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv);
+extern int drm_getstats(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern int drm_setversion(struct drm_device *dev, void *data,
+                         struct drm_file *file_priv);
+extern int drm_noop(struct drm_device *dev, void *data,
+                   struct drm_file *file_priv);
 
                                /* Context IOCTL support (drm_context.h) */
-extern int drm_resctx(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_addctx(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_modctx(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_getctx(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
-                        unsigned int cmd, unsigned long arg);
-extern int drm_newctx(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
-                    unsigned int cmd, unsigned long arg);
+extern int drm_resctx(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_addctx(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_modctx(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_getctx(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_switchctx(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv);
+extern int drm_newctx(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_rmctx(struct drm_device *dev, void *data,
+                    struct drm_file *file_priv);
 
 extern int drm_ctxbitmap_init(struct drm_device *dev);
 extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
 extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
 
-extern int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
-                          unsigned int cmd, unsigned long arg);
-extern int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
-                          unsigned int cmd, unsigned long arg);
+extern int drm_setsareactx(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv);
+extern int drm_getsareactx(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv);
 
                                /* Drawable IOCTL support (drm_drawable.h) */
-extern int drm_adddraw(struct inode *inode, struct drm_file *file_priv,
-                      unsigned int cmd, unsigned long arg);
-extern int drm_rmdraw(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
-extern int drm_update_drawable_info(struct inode *inode, struct drm_file *file_priv,
-                      unsigned int cmd, unsigned long arg);
+extern int drm_adddraw(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv);
+extern int drm_rmdraw(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+extern int drm_update_drawable_info(struct drm_device *dev, void *data,
+                                   struct drm_file *file_priv);
 extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
                                                  drm_drawable_t id);
 extern void drm_drawable_free_all(struct drm_device *dev);
 
                                /* Authentication IOCTL support (drm_auth.h) */
-extern int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
-                        unsigned int cmd, unsigned long arg);
+extern int drm_getmagic(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern int drm_authmagic(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv);
 
                                /* Locking IOCTL support (drm_lock.h) */
-extern int drm_lock(struct inode *inode, struct drm_file *file_priv,
-                   unsigned int cmd, unsigned long arg);
-extern int drm_unlock(struct inode *inode, struct drm_file *file_priv,
-                     unsigned int cmd, unsigned long arg);
+extern int drm_lock(struct drm_device *dev, void *data,
+                   struct drm_file *file_priv);
+extern int drm_unlock(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
 extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
 extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
 extern void drm_idlelock_take(struct drm_lock_data *lock_data);
@@ -928,7 +938,7 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data);
  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  */
 
-extern int drm_i_have_hw_lock(struct drm_file *file_priv);
+extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
 
                                /* Buffer management support (drm_bufs.h) */
 extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
@@ -936,24 +946,23 @@ extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request
 extern int drm_addmap(struct drm_device *dev, unsigned int offset,
                      unsigned int size, enum drm_map_type type,
                      enum drm_map_flags flags, drm_local_map_t ** map_ptr);
-extern int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv,
-                           unsigned int cmd, unsigned long arg);
-extern int drm_rmmap(struct drm_device *dev, drm_local_map_t * map);
-extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t * map);
-extern int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv,
-                          unsigned int cmd, unsigned long arg);
-
+extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
+                           struct drm_file *file_priv);
+extern int drm_rmmap(struct drm_device *dev, drm_local_map_t *map);
+extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map);
+extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv);
+extern int drm_addbufs(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv);
+extern int drm_infobufs(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern int drm_markbufs(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern int drm_freebufs(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern int drm_mapbufs(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv);
 extern int drm_order(unsigned long size);
-extern int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
-                      unsigned int cmd, unsigned long arg);
-extern int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
-                      unsigned int cmd, unsigned long arg);
 extern unsigned long drm_get_resource_start(struct drm_device *dev,
                                            unsigned int resource);
 extern unsigned long drm_get_resource_len(struct drm_device *dev,
@@ -967,16 +976,16 @@ extern void drm_core_reclaim_buffers(struct drm_device *dev,
                                     struct drm_file *filp);
 
                                /* IRQ support (drm_irq.h) */
-extern int drm_control(struct inode *inode, struct drm_file *file_priv,
-                      unsigned int cmd, unsigned long arg);
+extern int drm_control(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv);
 extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
 extern int drm_irq_uninstall(struct drm_device *dev);
 extern void drm_driver_irq_preinstall(struct drm_device *dev);
 extern void drm_driver_irq_postinstall(struct drm_device *dev);
 extern void drm_driver_irq_uninstall(struct drm_device *dev);
 
-extern int drm_wait_vblank(struct inode *inode, struct drm_file *file_priv,
-                          unsigned int cmd, unsigned long arg);
+extern int drm_wait_vblank(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv);
 extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
 extern void drm_vbl_send_signals(struct drm_device *dev);
 extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_device*));
@@ -984,31 +993,30 @@ extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_de
                                /* AGP/GART support (drm_agpsupport.h) */
 extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
 extern int drm_agp_acquire(struct drm_device *dev);
-extern int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
-                                unsigned int cmd, unsigned long arg);
+extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
+                                struct drm_file *file_priv);
 extern int drm_agp_release(struct drm_device *dev);
-extern int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
-                                unsigned int cmd, unsigned long arg);
+extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
+                                struct drm_file *file_priv);
 extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
-extern int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
-                               unsigned int cmd, unsigned long arg);
-extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info * info);
-extern int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
-                             unsigned int cmd, unsigned long arg);
+extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv);
+extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
+extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
 extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
-extern int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
-                        unsigned int cmd, unsigned long arg);
+extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv);
 extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
-extern int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
+extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
 extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
-extern int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
-                         unsigned int cmd, unsigned long arg);
+extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
+                         struct drm_file *file_priv);
 extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
-extern int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge,
-                                           size_t pages, u32 type);
+extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type);
 extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
 extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
 extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
@@ -1037,10 +1045,11 @@ extern int drm_proc_cleanup(int minor,
 
                                /* Scatter Gather Support (drm_scatter.h) */
 extern void drm_sg_cleanup(struct drm_sg_mem * entry);
-extern int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
-                       unsigned int cmd, unsigned long arg);
-extern int drm_sg_free(struct inode *inode, struct drm_file *file_priv,
-                      unsigned int cmd, unsigned long arg);
+extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv);
+extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
+extern int drm_sg_free(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv);
 
                               /* ATI PCIGART support (ati_pcigart.h) */
 extern int drm_ati_pcigart_init(struct drm_device *dev,