Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / drm / i830_drv.h
index c3cab2d..85bc5be 100644 (file)
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the next
  * paragraph) shall be included in all copies or substantial portions of the
  * Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 #ifndef _I830_DRV_H_
 #define _I830_DRV_H_
 
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR          "VA Linux Systems Inc."
+
+#define DRIVER_NAME            "i830"
+#define DRIVER_DESC            "Intel 830M"
+#define DRIVER_DATE            "20021108"
+
+/* Interface history:
+ *
+ * 1.1: Original.
+ * 1.2: ?
+ * 1.3: New irq emit/wait ioctls.
+ *      New pageflip ioctl.
+ *      New getparam ioctl.
+ *      State for texunits 3&4 in sarea.
+ *      New (alternative) layout for texture state.
+ */
+#define DRIVER_MAJOR           1
+#define DRIVER_MINOR           3
+#define DRIVER_PATCHLEVEL      2
+
+/* Driver will work either way: IRQ's save cpu time when waiting for
+ * the card, but are subject to subtle interactions between bios,
+ * hardware and the driver.
+ */
+/* XXX: Add vblank support? */
+#define USE_IRQS 0
+
 typedef struct drm_i830_buf_priv {
-       u32 *in_use;
-       int my_use_idx;
+       u32 *in_use;
+       int my_use_idx;
        int currently_mapped;
        void __user *virtual;
        void *kernel_virtual;
 } drm_i830_buf_priv_t;
 
-typedef struct _drm_i830_ring_buffer{
+typedef struct _drm_i830_ring_buffer {
        int tail_mask;
        unsigned long Start;
        unsigned long End;
@@ -56,17 +86,17 @@ typedef struct drm_i830_private {
        drm_map_t *mmio_map;
 
        drm_i830_sarea_t *sarea_priv;
-       drm_i830_ring_buffer_t ring;
+       drm_i830_ring_buffer_t ring;
 
-       void * hw_status_page;
-       unsigned long counter;
+       void *hw_status_page;
+       unsigned long counter;
 
        dma_addr_t dma_status_page;
 
        drm_buf_t *mmap_buffer;
-       
+
        u32 front_di1, back_di1, zi1;
-       
+
        int back_offset;
        int depth_offset;
        int front_offset;
@@ -83,75 +113,38 @@ typedef struct drm_i830_private {
        int page_flipping;
 
        wait_queue_head_t irq_queue;
-       atomic_t irq_received;
-       atomic_t irq_emitted;
+       atomic_t irq_received;
+       atomic_t irq_emitted;
 
        int use_mi_batchbuffer_start;
 
 } drm_i830_private_t;
 
-                               /* i830_dma.c */
-extern int  i830_dma_schedule(drm_device_t *dev, int locked);
-extern int  i830_getbuf(struct inode *inode, struct file *filp,
-                       unsigned int cmd, unsigned long arg);
-extern int  i830_dma_init(struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg);
-extern int  i830_dma_cleanup(drm_device_t *dev);
-extern int  i830_flush_ioctl(struct inode *inode, struct file *filp,
-                            unsigned int cmd, unsigned long arg);
-extern void i830_reclaim_buffers(struct file *filp);
-extern int  i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
-                       unsigned long arg);
-extern int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
-extern int i830_copybuf(struct inode *inode, struct file *filp, 
-                       unsigned int cmd, unsigned long arg);
-extern int i830_docopy(struct inode *inode, struct file *filp, 
-                      unsigned int cmd, unsigned long arg);
-
-extern void i830_dma_quiescent(drm_device_t *dev);
-
-extern int i830_dma_vertex(struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg);
-
-extern int i830_swap_bufs(struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg);
-
-extern int i830_clear_bufs(struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg);
-
-extern int i830_flip_bufs(struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg);
-
-extern int i830_getparam( struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg );
-
-extern int i830_setparam( struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg );
+extern drm_ioctl_desc_t i830_ioctls[];
+extern int i830_max_ioctl;
 
 /* i830_irq.c */
-extern int i830_irq_emit( struct inode *inode, struct file *filp, 
-                         unsigned int cmd, unsigned long arg );
-extern int i830_irq_wait( struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg );
-extern int i830_wait_irq(drm_device_t *dev, int irq_nr);
-extern int i830_emit_irq(drm_device_t *dev);
-
-extern irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS );
-extern void i830_driver_irq_preinstall( drm_device_t *dev );
-extern void i830_driver_irq_postinstall( drm_device_t *dev );
-extern void i830_driver_irq_uninstall( drm_device_t *dev );
-
-#define I830_BASE(reg)         ((unsigned long) \
-                               dev_priv->mmio_map->handle)
-#define I830_ADDR(reg)         (I830_BASE(reg) + reg)
-#define I830_DEREF(reg)                *(__volatile__ unsigned int *)I830_ADDR(reg)
-#define I830_READ(reg)         readl((volatile u32 *)I830_ADDR(reg))
-#define I830_WRITE(reg,val)    writel(val, (volatile u32 *)I830_ADDR(reg))
-#define I830_DEREF16(reg)      *(__volatile__ u16 *)I830_ADDR(reg)
-#define I830_READ16(reg)       I830_DEREF16(reg)
-#define I830_WRITE16(reg,val)  do { I830_DEREF16(reg) = val; } while (0)
-
+extern int i830_irq_emit(struct inode *inode, struct file *filp,
+                        unsigned int cmd, unsigned long arg);
+extern int i830_irq_wait(struct inode *inode, struct file *filp,
+                        unsigned int cmd, unsigned long arg);
 
+extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS);
+extern void i830_driver_irq_preinstall(drm_device_t * dev);
+extern void i830_driver_irq_postinstall(drm_device_t * dev);
+extern void i830_driver_irq_uninstall(drm_device_t * dev);
+extern int i830_driver_load(struct drm_device *, unsigned long flags);
+extern void i830_driver_preclose(drm_device_t * dev, DRMFILE filp);
+extern void i830_driver_lastclose(drm_device_t * dev);
+extern void i830_driver_reclaim_buffers_locked(drm_device_t * dev,
+                                              struct file *filp);
+extern int i830_driver_dma_quiescent(drm_device_t * dev);
+extern int i830_driver_device_is_agp(drm_device_t * dev);
+
+#define I830_READ(reg)          DRM_READ32(dev_priv->mmio_map, reg)
+#define I830_WRITE(reg,val)     DRM_WRITE32(dev_priv->mmio_map, reg, val)
+#define I830_READ16(reg)        DRM_READ16(dev_priv->mmio_map, reg)
+#define I830_WRITE16(reg,val)   DRM_WRITE16(dev_priv->mmio_map, reg, val)
 
 #define I830_VERBOSE 0
 
@@ -170,7 +163,6 @@ extern void i830_driver_irq_uninstall( drm_device_t *dev );
        virt = dev_priv->ring.virtual_start;            \
 } while (0)
 
-
 #define OUT_RING(n) do {                                       \
        if (I830_VERBOSE) printk("   OUT_RING %x\n", (int)(n)); \
        *(volatile unsigned int *)(virt + outring) = n;         \
@@ -186,8 +178,7 @@ extern void i830_driver_irq_uninstall( drm_device_t *dev );
        I830_WRITE(LP_RING + RING_TAIL, outring);                       \
 } while(0)
 
-extern int i830_wait_ring(drm_device_t *dev, int n, const char *caller);
-
+extern int i830_wait_ring(drm_device_t * dev, int n, const char *caller);
 
 #define GFX_OP_USER_INTERRUPT          ((0<<29)|(2<<23))
 #define GFX_OP_BREAKPOINT_INTERRUPT    ((0<<29)|(1<<23))
@@ -202,7 +193,6 @@ extern int i830_wait_ring(drm_device_t *dev, int n, const char *caller);
 #define INST_OP_FLUSH        0x02000000
 #define INST_FLUSH_MAP_CACHE 0x00000001
 
-
 #define BB1_START_ADDR_MASK   (~0x7)
 #define BB1_PROTECTED         (1<<0)
 #define BB1_UNPROTECTED       (0<<0)
@@ -215,7 +205,6 @@ extern int i830_wait_ring(drm_device_t *dev, int n, const char *caller);
 
 #define I830_IRQ_RESERVED ((1<<13)|(3<<2))
 
-
 #define LP_RING                0x2030
 #define HP_RING                0x2040
 #define RING_TAIL                      0x00
@@ -227,7 +216,7 @@ extern int i830_wait_ring(drm_device_t *dev, int n, const char *caller);
 #define RING_START                     0x08
 #define START_ADDR             0x0xFFFFF000
 #define RING_LEN                       0x0C
-#define RING_NR_PAGES          0x001FF000 
+#define RING_NR_PAGES          0x001FF000
 #define RING_REPORT_MASK       0x00000006
 #define RING_REPORT_64K        0x00000002
 #define RING_REPORT_128K       0x00000004
@@ -293,10 +282,9 @@ extern int i830_wait_ring(drm_device_t *dev, int n, const char *caller);
 #define MI_BATCH_NON_SECURE    (1)
 
 #define MI_WAIT_FOR_EVENT       ((0x3<<23))
-#define MI_WAIT_FOR_PLANE_A_FLIP      (1<<2) 
-#define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1) 
+#define MI_WAIT_FOR_PLANE_A_FLIP      (1<<2)
+#define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
 
 #define MI_LOAD_SCAN_LINES_INCL  ((0x12<<23))
 
 #endif
-