Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* i810_dma.c -- DMA support for the i810 -*- linux-c -*- |
| 2 | * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com |
| 3 | * |
| 4 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
| 5 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
| 6 | * All Rights Reserved. |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice (including the next |
| 16 | * paragraph) shall be included in all copies or substantial portions of the |
| 17 | * Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 23 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 25 | * DEALINGS IN THE SOFTWARE. |
| 26 | * |
| 27 | * Authors: Rickard E. (Rik) Faith <faith@valinux.com> |
| 28 | * Jeff Hartmann <jhartmann@valinux.com> |
| 29 | * Keith Whitwell <keith@tungstengraphics.com> |
| 30 | * |
| 31 | */ |
| 32 | |
| 33 | #include "drmP.h" |
| 34 | #include "drm.h" |
| 35 | #include "i810_drm.h" |
| 36 | #include "i810_drv.h" |
| 37 | #include <linux/interrupt.h> /* For task queue support */ |
| 38 | #include <linux/delay.h> |
| 39 | #include <linux/pagemap.h> |
| 40 | |
| 41 | #define I810_BUF_FREE 2 |
| 42 | #define I810_BUF_CLIENT 1 |
| 43 | #define I810_BUF_HARDWARE 0 |
| 44 | |
| 45 | #define I810_BUF_UNMAPPED 0 |
| 46 | #define I810_BUF_MAPPED 1 |
| 47 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 48 | static struct drm_buf *i810_freelist_get(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 50 | drm_device_dma_t *dma = dev->dma; |
| 51 | int i; |
| 52 | int used; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | /* Linear search might not be the best solution */ |
| 55 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 56 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 57 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 58 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | /* In use is already a pointer */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 60 | used = cmpxchg(buf_priv->in_use, I810_BUF_FREE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | I810_BUF_CLIENT); |
| 62 | if (used == I810_BUF_FREE) { |
| 63 | return buf; |
| 64 | } |
| 65 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 66 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /* This should only be called if the buffer is not sent to the hardware |
| 70 | * yet, the hardware updates in use for us once its on the ring buffer. |
| 71 | */ |
| 72 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 73 | static int i810_freelist_put(struct drm_device * dev, struct drm_buf * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 75 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 76 | int used; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 78 | /* In use is already a pointer */ |
| 79 | used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | if (used != I810_BUF_CLIENT) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 81 | DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx); |
| 82 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 85 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 88 | static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 90 | struct drm_file *priv = filp->private_data; |
| 91 | struct drm_device *dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 92 | drm_i810_private_t *dev_priv; |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 93 | struct drm_buf *buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | drm_i810_buf_priv_t *buf_priv; |
| 95 | |
| 96 | lock_kernel(); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 97 | dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | dev_priv = dev->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 99 | buf = dev_priv->mmap_buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | buf_priv = buf->dev_private; |
| 101 | |
| 102 | vma->vm_flags |= (VM_IO | VM_DONTCOPY); |
| 103 | vma->vm_file = filp; |
| 104 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 105 | buf_priv->currently_mapped = I810_BUF_MAPPED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | unlock_kernel(); |
| 107 | |
| 108 | if (io_remap_pfn_range(vma, vma->vm_start, |
Dave Airlie | 3d77461 | 2006-08-07 20:07:43 +1000 | [diff] [blame] | 109 | vma->vm_pgoff, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 110 | vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
| 111 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | return 0; |
| 113 | } |
| 114 | |
Arjan van de Ven | 2b8693c | 2007-02-12 00:55:32 -0800 | [diff] [blame] | 115 | static const struct file_operations i810_buffer_fops = { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 116 | .open = drm_open, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 117 | .release = drm_release, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 118 | .ioctl = drm_ioctl, |
| 119 | .mmap = i810_mmap_buffers, |
| 120 | .fasync = drm_fasync, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 121 | }; |
| 122 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 123 | static int i810_map_buffer(struct drm_buf * buf, struct file *filp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 125 | struct drm_file *priv = filp->private_data; |
| 126 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 128 | drm_i810_private_t *dev_priv = dev->dev_private; |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 129 | const struct file_operations *old_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | int retcode = 0; |
| 131 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 132 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | return -EINVAL; |
| 134 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 135 | down_write(¤t->mm->mmap_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | old_fops = filp->f_op; |
| 137 | filp->f_op = &i810_buffer_fops; |
| 138 | dev_priv->mmap_buffer = buf; |
| 139 | buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 140 | PROT_READ | PROT_WRITE, |
| 141 | MAP_SHARED, buf->bus_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | dev_priv->mmap_buffer = NULL; |
| 143 | filp->f_op = old_fops; |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 144 | if (IS_ERR(buf_priv->virtual)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | /* Real error */ |
| 146 | DRM_ERROR("mmap error\n"); |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 147 | retcode = PTR_ERR(buf_priv->virtual); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | buf_priv->virtual = NULL; |
| 149 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 150 | up_write(¤t->mm->mmap_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | return retcode; |
| 153 | } |
| 154 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 155 | static int i810_unmap_buffer(struct drm_buf * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | { |
| 157 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 158 | int retcode = 0; |
| 159 | |
| 160 | if (buf_priv->currently_mapped != I810_BUF_MAPPED) |
| 161 | return -EINVAL; |
| 162 | |
| 163 | down_write(¤t->mm->mmap_sem); |
| 164 | retcode = do_munmap(current->mm, |
| 165 | (unsigned long)buf_priv->virtual, |
| 166 | (size_t) buf->total); |
| 167 | up_write(¤t->mm->mmap_sem); |
| 168 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 169 | buf_priv->currently_mapped = I810_BUF_UNMAPPED; |
| 170 | buf_priv->virtual = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | return retcode; |
| 173 | } |
| 174 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 175 | static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | struct file *filp) |
| 177 | { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 178 | struct drm_buf *buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | drm_i810_buf_priv_t *buf_priv; |
| 180 | int retcode = 0; |
| 181 | |
| 182 | buf = i810_freelist_get(dev); |
| 183 | if (!buf) { |
| 184 | retcode = -ENOMEM; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 185 | DRM_DEBUG("retcode=%d\n", retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | return retcode; |
| 187 | } |
| 188 | |
| 189 | retcode = i810_map_buffer(buf, filp); |
| 190 | if (retcode) { |
| 191 | i810_freelist_put(dev, buf); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 192 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | return retcode; |
| 194 | } |
| 195 | buf->filp = filp; |
| 196 | buf_priv = buf->dev_private; |
| 197 | d->granted = 1; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 198 | d->request_idx = buf->idx; |
| 199 | d->request_size = buf->total; |
| 200 | d->virtual = buf_priv->virtual; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
| 202 | return retcode; |
| 203 | } |
| 204 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 205 | static int i810_dma_cleanup(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | { |
| 207 | drm_device_dma_t *dma = dev->dma; |
| 208 | |
| 209 | /* Make sure interrupts are disabled here because the uninstall ioctl |
| 210 | * may not have been called from userspace and after dev_private |
| 211 | * is freed, it's too late. |
| 212 | */ |
| 213 | if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled) |
| 214 | drm_irq_uninstall(dev); |
| 215 | |
| 216 | if (dev->dev_private) { |
| 217 | int i; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 218 | drm_i810_private_t *dev_priv = |
| 219 | (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | if (dev_priv->ring.virtual_start) { |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 222 | drm_core_ioremapfree(&dev_priv->ring.map, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 224 | if (dev_priv->hw_status_page) { |
| 225 | pci_free_consistent(dev->pdev, PAGE_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | dev_priv->hw_status_page, |
| 227 | dev_priv->dma_status_page); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 228 | /* Need to rewrite hardware status page */ |
| 229 | I810_WRITE(0x02080, 0x1ffff000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 231 | drm_free(dev->dev_private, sizeof(drm_i810_private_t), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | DRM_MEM_DRIVER); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 233 | dev->dev_private = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
| 235 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 236 | struct drm_buf *buf = dma->buflist[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 238 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 239 | if (buf_priv->kernel_virtual && buf->total) |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 240 | drm_core_ioremapfree(&buf_priv->map, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | return 0; |
| 244 | } |
| 245 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 246 | static int i810_wait_ring(struct drm_device * dev, int n) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 247 | { |
| 248 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 249 | drm_i810_ring_buffer_t *ring = &(dev_priv->ring); |
| 250 | int iters = 0; |
| 251 | unsigned long end; |
| 252 | unsigned int last_head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 253 | |
| 254 | end = jiffies + (HZ * 3); |
| 255 | while (ring->space < n) { |
| 256 | ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 257 | ring->space = ring->head - (ring->tail + 8); |
| 258 | if (ring->space < 0) |
| 259 | ring->space += ring->Size; |
| 260 | |
| 261 | if (ring->head != last_head) { |
| 262 | end = jiffies + (HZ * 3); |
| 263 | last_head = ring->head; |
| 264 | } |
| 265 | |
| 266 | iters++; |
| 267 | if (time_before(end, jiffies)) { |
| 268 | DRM_ERROR("space: %d wanted %d\n", ring->space, n); |
| 269 | DRM_ERROR("lockup\n"); |
| 270 | goto out_wait_ring; |
| 271 | } |
| 272 | udelay(1); |
| 273 | } |
| 274 | |
| 275 | out_wait_ring: |
| 276 | return iters; |
| 277 | } |
| 278 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 279 | static void i810_kernel_lost_context(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 280 | { |
| 281 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 282 | drm_i810_ring_buffer_t *ring = &(dev_priv->ring); |
| 283 | |
| 284 | ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 285 | ring->tail = I810_READ(LP_RING + RING_TAIL); |
| 286 | ring->space = ring->head - (ring->tail + 8); |
| 287 | if (ring->space < 0) |
| 288 | ring->space += ring->Size; |
| 289 | } |
| 290 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 291 | static int i810_freelist_init(struct drm_device * dev, drm_i810_private_t * dev_priv) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 292 | { |
| 293 | drm_device_dma_t *dma = dev->dma; |
| 294 | int my_idx = 24; |
| 295 | u32 *hw_status = (u32 *) (dev_priv->hw_status_page + my_idx); |
| 296 | int i; |
| 297 | |
| 298 | if (dma->buf_count > 1019) { |
| 299 | /* Not enough space in the status page for the freelist */ |
| 300 | return -EINVAL; |
| 301 | } |
| 302 | |
| 303 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 304 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 305 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 306 | |
| 307 | buf_priv->in_use = hw_status++; |
| 308 | buf_priv->my_use_idx = my_idx; |
| 309 | my_idx += 4; |
| 310 | |
| 311 | *buf_priv->in_use = I810_BUF_FREE; |
| 312 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 313 | buf_priv->map.offset = buf->bus_address; |
| 314 | buf_priv->map.size = buf->total; |
| 315 | buf_priv->map.type = _DRM_AGP; |
| 316 | buf_priv->map.flags = 0; |
| 317 | buf_priv->map.mtrr = 0; |
| 318 | |
| 319 | drm_core_ioremap(&buf_priv->map, dev); |
| 320 | buf_priv->kernel_virtual = buf_priv->map.handle; |
| 321 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 322 | } |
| 323 | return 0; |
| 324 | } |
| 325 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 326 | static int i810_dma_initialize(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 327 | drm_i810_private_t * dev_priv, |
| 328 | drm_i810_init_t * init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 330 | drm_map_list_t *r_list; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 331 | memset(dev_priv, 0, sizeof(drm_i810_private_t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 333 | list_for_each_entry(r_list, &dev->maplist, head) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | if (r_list->map && |
| 335 | r_list->map->type == _DRM_SHM && |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 336 | r_list->map->flags & _DRM_CONTAINS_LOCK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | dev_priv->sarea_map = r_list->map; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 338 | break; |
| 339 | } |
| 340 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | if (!dev_priv->sarea_map) { |
| 342 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 343 | i810_dma_cleanup(dev); |
| 344 | DRM_ERROR("can not find sarea!\n"); |
| 345 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | } |
| 347 | dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset); |
| 348 | if (!dev_priv->mmio_map) { |
| 349 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 350 | i810_dma_cleanup(dev); |
| 351 | DRM_ERROR("can not find mmio map!\n"); |
| 352 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | } |
Dave Airlie | d1f2b55 | 2005-08-05 22:11:22 +1000 | [diff] [blame] | 354 | dev->agp_buffer_token = init->buffers_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset); |
| 356 | if (!dev->agp_buffer_map) { |
| 357 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 358 | i810_dma_cleanup(dev); |
| 359 | DRM_ERROR("can not find dma buffer map!\n"); |
| 360 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | dev_priv->sarea_priv = (drm_i810_sarea_t *) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 364 | ((u8 *) dev_priv->sarea_map->handle + init->sarea_priv_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 366 | dev_priv->ring.Start = init->ring_start; |
| 367 | dev_priv->ring.End = init->ring_end; |
| 368 | dev_priv->ring.Size = init->ring_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 370 | dev_priv->ring.map.offset = dev->agp->base + init->ring_start; |
| 371 | dev_priv->ring.map.size = init->ring_size; |
| 372 | dev_priv->ring.map.type = _DRM_AGP; |
| 373 | dev_priv->ring.map.flags = 0; |
| 374 | dev_priv->ring.map.mtrr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 376 | drm_core_ioremap(&dev_priv->ring.map, dev); |
| 377 | |
| 378 | if (dev_priv->ring.map.handle == NULL) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 379 | dev->dev_private = (void *)dev_priv; |
| 380 | i810_dma_cleanup(dev); |
| 381 | DRM_ERROR("can not ioremap virtual address for" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | " ring buffer\n"); |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 383 | return DRM_ERR(ENOMEM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 386 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; |
| 387 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 388 | dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
| 390 | dev_priv->w = init->w; |
| 391 | dev_priv->h = init->h; |
| 392 | dev_priv->pitch = init->pitch; |
| 393 | dev_priv->back_offset = init->back_offset; |
| 394 | dev_priv->depth_offset = init->depth_offset; |
| 395 | dev_priv->front_offset = init->front_offset; |
| 396 | |
| 397 | dev_priv->overlay_offset = init->overlay_offset; |
| 398 | dev_priv->overlay_physical = init->overlay_physical; |
| 399 | |
| 400 | dev_priv->front_di1 = init->front_offset | init->pitch_bits; |
| 401 | dev_priv->back_di1 = init->back_offset | init->pitch_bits; |
| 402 | dev_priv->zi1 = init->depth_offset | init->pitch_bits; |
| 403 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 404 | /* Program Hardware Status Page */ |
| 405 | dev_priv->hw_status_page = |
| 406 | pci_alloc_consistent(dev->pdev, PAGE_SIZE, |
| 407 | &dev_priv->dma_status_page); |
| 408 | if (!dev_priv->hw_status_page) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | dev->dev_private = (void *)dev_priv; |
| 410 | i810_dma_cleanup(dev); |
| 411 | DRM_ERROR("Can not allocate hardware status page\n"); |
| 412 | return -ENOMEM; |
| 413 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 414 | memset(dev_priv->hw_status_page, 0, PAGE_SIZE); |
| 415 | DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
| 417 | I810_WRITE(0x02080, dev_priv->dma_status_page); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 418 | DRM_DEBUG("Enabled hardware status page\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 420 | /* Now we need to init our freelist */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | if (i810_freelist_init(dev, dev_priv) != 0) { |
| 422 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 423 | i810_dma_cleanup(dev); |
| 424 | DRM_ERROR("Not enough space in the status page for" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | " the freelist\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 426 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | } |
| 428 | dev->dev_private = (void *)dev_priv; |
| 429 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 430 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /* i810 DRM version 1.1 used a smaller init structure with different |
| 434 | * ordering of values than is currently used (drm >= 1.2). There is |
| 435 | * no defined way to detect the XFree version to correct this problem, |
| 436 | * however by checking using this procedure we can detect the correct |
| 437 | * thing to do. |
| 438 | * |
| 439 | * #1 Read the Smaller init structure from user-space |
| 440 | * #2 Verify the overlay_physical is a valid physical address, or NULL |
| 441 | * If it isn't then we have a v1.1 client. Fix up params. |
| 442 | * If it is, then we have a 1.2 client... get the rest of the data. |
| 443 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 444 | static int i810_dma_init_compat(drm_i810_init_t * init, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | { |
| 446 | |
| 447 | /* Get v1.1 init data */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 448 | if (copy_from_user(init, (drm_i810_pre12_init_t __user *) arg, |
| 449 | sizeof(drm_i810_pre12_init_t))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | return -EFAULT; |
| 451 | } |
| 452 | |
| 453 | if ((!init->overlay_physical) || (init->overlay_physical > 4096)) { |
| 454 | |
| 455 | /* This is a v1.2 client, just get the v1.2 init data */ |
| 456 | DRM_INFO("Using POST v1.2 init.\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 457 | if (copy_from_user(init, (drm_i810_init_t __user *) arg, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | sizeof(drm_i810_init_t))) { |
| 459 | return -EFAULT; |
| 460 | } |
| 461 | } else { |
| 462 | |
| 463 | /* This is a v1.1 client, fix the params */ |
| 464 | DRM_INFO("Using PRE v1.2 init.\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 465 | init->pitch_bits = init->h; |
| 466 | init->pitch = init->w; |
| 467 | init->h = init->overlay_physical; |
| 468 | init->w = init->overlay_offset; |
| 469 | init->overlay_physical = 0; |
| 470 | init->overlay_offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | static int i810_dma_init(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 477 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 479 | struct drm_file *priv = filp->private_data; |
| 480 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 481 | drm_i810_private_t *dev_priv; |
| 482 | drm_i810_init_t init; |
| 483 | int retcode = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
| 485 | /* Get only the init func */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 486 | if (copy_from_user |
| 487 | (&init, (void __user *)arg, sizeof(drm_i810_init_func_t))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | return -EFAULT; |
| 489 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 490 | switch (init.func) { |
| 491 | case I810_INIT_DMA: |
| 492 | /* This case is for backward compatibility. It |
| 493 | * handles XFree 4.1.0 and 4.2.0, and has to |
| 494 | * do some parameter checking as described below. |
| 495 | * It will someday go away. |
| 496 | */ |
| 497 | retcode = i810_dma_init_compat(&init, arg); |
| 498 | if (retcode) |
| 499 | return retcode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 501 | dev_priv = drm_alloc(sizeof(drm_i810_private_t), |
| 502 | DRM_MEM_DRIVER); |
| 503 | if (dev_priv == NULL) |
| 504 | return -ENOMEM; |
| 505 | retcode = i810_dma_initialize(dev, dev_priv, &init); |
| 506 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 508 | default: |
| 509 | case I810_INIT_DMA_1_4: |
| 510 | DRM_INFO("Using v1.4 init.\n"); |
| 511 | if (copy_from_user(&init, (drm_i810_init_t __user *) arg, |
| 512 | sizeof(drm_i810_init_t))) { |
| 513 | return -EFAULT; |
| 514 | } |
| 515 | dev_priv = drm_alloc(sizeof(drm_i810_private_t), |
| 516 | DRM_MEM_DRIVER); |
| 517 | if (dev_priv == NULL) |
| 518 | return -ENOMEM; |
| 519 | retcode = i810_dma_initialize(dev, dev_priv, &init); |
| 520 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 522 | case I810_CLEANUP_DMA: |
| 523 | DRM_INFO("DMA Cleanup\n"); |
| 524 | retcode = i810_dma_cleanup(dev); |
| 525 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 528 | return retcode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | } |
| 530 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | /* Most efficient way to verify state for the i810 is as it is |
| 532 | * emitted. Non-conformant state is silently dropped. |
| 533 | * |
| 534 | * Use 'volatile' & local var tmp to force the emitted values to be |
| 535 | * identical to the verified ones. |
| 536 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 537 | static void i810EmitContextVerified(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 538 | volatile unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 540 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | int i, j = 0; |
| 542 | unsigned int tmp; |
| 543 | RING_LOCALS; |
| 544 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 545 | BEGIN_LP_RING(I810_CTX_SETUP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 547 | OUT_RING(GFX_OP_COLOR_FACTOR); |
| 548 | OUT_RING(code[I810_CTXREG_CF1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 550 | OUT_RING(GFX_OP_STIPPLE); |
| 551 | OUT_RING(code[I810_CTXREG_ST1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 553 | for (i = 4; i < I810_CTX_SETUP_SIZE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | tmp = code[i]; |
| 555 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 556 | if ((tmp & (7 << 29)) == (3 << 29) && |
| 557 | (tmp & (0x1f << 24)) < (0x1d << 24)) { |
| 558 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | j++; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 560 | } else |
| 561 | printk("constext state dropped!!!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | if (j & 1) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 565 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
| 567 | ADVANCE_LP_RING(); |
| 568 | } |
| 569 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 570 | static void i810EmitTexVerified(struct drm_device * dev, volatile unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 572 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | int i, j = 0; |
| 574 | unsigned int tmp; |
| 575 | RING_LOCALS; |
| 576 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 577 | BEGIN_LP_RING(I810_TEX_SETUP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 579 | OUT_RING(GFX_OP_MAP_INFO); |
| 580 | OUT_RING(code[I810_TEXREG_MI1]); |
| 581 | OUT_RING(code[I810_TEXREG_MI2]); |
| 582 | OUT_RING(code[I810_TEXREG_MI3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 584 | for (i = 4; i < I810_TEX_SETUP_SIZE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | tmp = code[i]; |
| 586 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 587 | if ((tmp & (7 << 29)) == (3 << 29) && |
| 588 | (tmp & (0x1f << 24)) < (0x1d << 24)) { |
| 589 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | j++; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 591 | } else |
| 592 | printk("texture state dropped!!!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | if (j & 1) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 596 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
| 598 | ADVANCE_LP_RING(); |
| 599 | } |
| 600 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | /* Need to do some additional checking when setting the dest buffer. |
| 602 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 603 | static void i810EmitDestVerified(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 604 | volatile unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 606 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | unsigned int tmp; |
| 608 | RING_LOCALS; |
| 609 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 610 | BEGIN_LP_RING(I810_DEST_SETUP_SIZE + 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | |
| 612 | tmp = code[I810_DESTREG_DI1]; |
| 613 | if (tmp == dev_priv->front_di1 || tmp == dev_priv->back_di1) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 614 | OUT_RING(CMD_OP_DESTBUFFER_INFO); |
| 615 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 617 | DRM_DEBUG("bad di1 %x (allow %x or %x)\n", |
| 618 | tmp, dev_priv->front_di1, dev_priv->back_di1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
| 620 | /* invarient: |
| 621 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 622 | OUT_RING(CMD_OP_Z_BUFFER_INFO); |
| 623 | OUT_RING(dev_priv->zi1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 625 | OUT_RING(GFX_OP_DESTBUFFER_VARS); |
| 626 | OUT_RING(code[I810_DESTREG_DV1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 628 | OUT_RING(GFX_OP_DRAWRECT_INFO); |
| 629 | OUT_RING(code[I810_DESTREG_DR1]); |
| 630 | OUT_RING(code[I810_DESTREG_DR2]); |
| 631 | OUT_RING(code[I810_DESTREG_DR3]); |
| 632 | OUT_RING(code[I810_DESTREG_DR4]); |
| 633 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
| 635 | ADVANCE_LP_RING(); |
| 636 | } |
| 637 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 638 | static void i810EmitState(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 640 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 641 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | unsigned int dirty = sarea_priv->dirty; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 643 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | DRM_DEBUG("%s %x\n", __FUNCTION__, dirty); |
| 645 | |
| 646 | if (dirty & I810_UPLOAD_BUFFERS) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 647 | i810EmitDestVerified(dev, sarea_priv->BufferState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | sarea_priv->dirty &= ~I810_UPLOAD_BUFFERS; |
| 649 | } |
| 650 | |
| 651 | if (dirty & I810_UPLOAD_CTX) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 652 | i810EmitContextVerified(dev, sarea_priv->ContextState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | sarea_priv->dirty &= ~I810_UPLOAD_CTX; |
| 654 | } |
| 655 | |
| 656 | if (dirty & I810_UPLOAD_TEX0) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 657 | i810EmitTexVerified(dev, sarea_priv->TexState[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | sarea_priv->dirty &= ~I810_UPLOAD_TEX0; |
| 659 | } |
| 660 | |
| 661 | if (dirty & I810_UPLOAD_TEX1) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 662 | i810EmitTexVerified(dev, sarea_priv->TexState[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | sarea_priv->dirty &= ~I810_UPLOAD_TEX1; |
| 664 | } |
| 665 | } |
| 666 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | /* need to verify |
| 668 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 669 | static void i810_dma_dispatch_clear(struct drm_device * dev, int flags, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 670 | unsigned int clear_color, |
| 671 | unsigned int clear_zval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 673 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 674 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | int nbox = sarea_priv->nbox; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 676 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | int pitch = dev_priv->pitch; |
| 678 | int cpp = 2; |
| 679 | int i; |
| 680 | RING_LOCALS; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 681 | |
| 682 | if (dev_priv->current_page == 1) { |
| 683 | unsigned int tmp = flags; |
| 684 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | flags &= ~(I810_FRONT | I810_BACK); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 686 | if (tmp & I810_FRONT) |
| 687 | flags |= I810_BACK; |
| 688 | if (tmp & I810_BACK) |
| 689 | flags |= I810_FRONT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 692 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 694 | if (nbox > I810_NR_SAREA_CLIPRECTS) |
| 695 | nbox = I810_NR_SAREA_CLIPRECTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 697 | for (i = 0; i < nbox; i++, pbox++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | unsigned int x = pbox->x1; |
| 699 | unsigned int y = pbox->y1; |
| 700 | unsigned int width = (pbox->x2 - x) * cpp; |
| 701 | unsigned int height = pbox->y2 - y; |
| 702 | unsigned int start = y * pitch + x * cpp; |
| 703 | |
| 704 | if (pbox->x1 > pbox->x2 || |
| 705 | pbox->y1 > pbox->y2 || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 706 | pbox->x2 > dev_priv->w || pbox->y2 > dev_priv->h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | continue; |
| 708 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 709 | if (flags & I810_FRONT) { |
| 710 | BEGIN_LP_RING(6); |
| 711 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3); |
| 712 | OUT_RING(BR13_SOLID_PATTERN | (0xF0 << 16) | pitch); |
| 713 | OUT_RING((height << 16) | width); |
| 714 | OUT_RING(start); |
| 715 | OUT_RING(clear_color); |
| 716 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | ADVANCE_LP_RING(); |
| 718 | } |
| 719 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 720 | if (flags & I810_BACK) { |
| 721 | BEGIN_LP_RING(6); |
| 722 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3); |
| 723 | OUT_RING(BR13_SOLID_PATTERN | (0xF0 << 16) | pitch); |
| 724 | OUT_RING((height << 16) | width); |
| 725 | OUT_RING(dev_priv->back_offset + start); |
| 726 | OUT_RING(clear_color); |
| 727 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | ADVANCE_LP_RING(); |
| 729 | } |
| 730 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 731 | if (flags & I810_DEPTH) { |
| 732 | BEGIN_LP_RING(6); |
| 733 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3); |
| 734 | OUT_RING(BR13_SOLID_PATTERN | (0xF0 << 16) | pitch); |
| 735 | OUT_RING((height << 16) | width); |
| 736 | OUT_RING(dev_priv->depth_offset + start); |
| 737 | OUT_RING(clear_zval); |
| 738 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | ADVANCE_LP_RING(); |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 744 | static void i810_dma_dispatch_swap(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 746 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 747 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | int nbox = sarea_priv->nbox; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 749 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | int pitch = dev_priv->pitch; |
| 751 | int cpp = 2; |
| 752 | int i; |
| 753 | RING_LOCALS; |
| 754 | |
| 755 | DRM_DEBUG("swapbuffers\n"); |
| 756 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 757 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 759 | if (nbox > I810_NR_SAREA_CLIPRECTS) |
| 760 | nbox = I810_NR_SAREA_CLIPRECTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 762 | for (i = 0; i < nbox; i++, pbox++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | unsigned int w = pbox->x2 - pbox->x1; |
| 764 | unsigned int h = pbox->y2 - pbox->y1; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 765 | unsigned int dst = pbox->x1 * cpp + pbox->y1 * pitch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | unsigned int start = dst; |
| 767 | |
| 768 | if (pbox->x1 > pbox->x2 || |
| 769 | pbox->y1 > pbox->y2 || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 770 | pbox->x2 > dev_priv->w || pbox->y2 > dev_priv->h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | continue; |
| 772 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 773 | BEGIN_LP_RING(6); |
| 774 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4); |
| 775 | OUT_RING(pitch | (0xCC << 16)); |
| 776 | OUT_RING((h << 16) | (w * cpp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | if (dev_priv->current_page == 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 778 | OUT_RING(dev_priv->front_offset + start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 780 | OUT_RING(dev_priv->back_offset + start); |
| 781 | OUT_RING(pitch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | if (dev_priv->current_page == 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 783 | OUT_RING(dev_priv->back_offset + start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 785 | OUT_RING(dev_priv->front_offset + start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | ADVANCE_LP_RING(); |
| 787 | } |
| 788 | } |
| 789 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 790 | static void i810_dma_dispatch_vertex(struct drm_device * dev, |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 791 | struct drm_buf * buf, int discard, int used) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 793 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 795 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 796 | struct drm_clip_rect *box = sarea_priv->boxes; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 797 | int nbox = sarea_priv->nbox; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | unsigned long address = (unsigned long)buf->bus_address; |
| 799 | unsigned long start = address - dev->agp->base; |
| 800 | int i = 0; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 801 | RING_LOCALS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 803 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 805 | if (nbox > I810_NR_SAREA_CLIPRECTS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | nbox = I810_NR_SAREA_CLIPRECTS; |
| 807 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 808 | if (used > 4 * 1024) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | used = 0; |
| 810 | |
| 811 | if (sarea_priv->dirty) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 812 | i810EmitState(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
| 814 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) { |
| 815 | unsigned int prim = (sarea_priv->vertex_prim & PR_MASK); |
| 816 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 817 | *(u32 *) buf_priv->kernel_virtual = |
| 818 | ((GFX_OP_PRIMITIVE | prim | ((used / 4) - 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
| 820 | if (used & 4) { |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 821 | *(u32 *) ((char *) buf_priv->kernel_virtual + used) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | used += 4; |
| 823 | } |
| 824 | |
| 825 | i810_unmap_buffer(buf); |
| 826 | } |
| 827 | |
| 828 | if (used) { |
| 829 | do { |
| 830 | if (i < nbox) { |
| 831 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 832 | OUT_RING(GFX_OP_SCISSOR | SC_UPDATE_SCISSOR | |
| 833 | SC_ENABLE); |
| 834 | OUT_RING(GFX_OP_SCISSOR_INFO); |
| 835 | OUT_RING(box[i].x1 | (box[i].y1 << 16)); |
| 836 | OUT_RING((box[i].x2 - |
| 837 | 1) | ((box[i].y2 - 1) << 16)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | ADVANCE_LP_RING(); |
| 839 | } |
| 840 | |
| 841 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 842 | OUT_RING(CMD_OP_BATCH_BUFFER); |
| 843 | OUT_RING(start | BB1_PROTECTED); |
| 844 | OUT_RING(start + used - 4); |
| 845 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | ADVANCE_LP_RING(); |
| 847 | |
| 848 | } while (++i < nbox); |
| 849 | } |
| 850 | |
| 851 | if (discard) { |
| 852 | dev_priv->counter++; |
| 853 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 854 | (void)cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, |
| 855 | I810_BUF_HARDWARE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | |
| 857 | BEGIN_LP_RING(8); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 858 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 859 | OUT_RING(20); |
| 860 | OUT_RING(dev_priv->counter); |
| 861 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 862 | OUT_RING(buf_priv->my_use_idx); |
| 863 | OUT_RING(I810_BUF_FREE); |
| 864 | OUT_RING(CMD_REPORT_HEAD); |
| 865 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | ADVANCE_LP_RING(); |
| 867 | } |
| 868 | } |
| 869 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 870 | static void i810_dma_dispatch_flip(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 872 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | int pitch = dev_priv->pitch; |
| 874 | RING_LOCALS; |
| 875 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 876 | DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", |
| 877 | __FUNCTION__, |
| 878 | dev_priv->current_page, |
| 879 | dev_priv->sarea_priv->pf_current_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 881 | i810_kernel_lost_context(dev); |
| 882 | |
| 883 | BEGIN_LP_RING(2); |
| 884 | OUT_RING(INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); |
| 885 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | ADVANCE_LP_RING(); |
| 887 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 888 | BEGIN_LP_RING(I810_DEST_SETUP_SIZE + 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | /* On i815 at least ASYNC is buggy */ |
| 890 | /* pitch<<5 is from 11.2.8 p158, |
| 891 | its the pitch / 8 then left shifted 8, |
| 892 | so (pitch >> 3) << 8 */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 893 | OUT_RING(CMD_OP_FRONTBUFFER_INFO | (pitch << 5) /*| ASYNC_FLIP */ ); |
| 894 | if (dev_priv->current_page == 0) { |
| 895 | OUT_RING(dev_priv->back_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | dev_priv->current_page = 1; |
| 897 | } else { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 898 | OUT_RING(dev_priv->front_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | dev_priv->current_page = 0; |
| 900 | } |
| 901 | OUT_RING(0); |
| 902 | ADVANCE_LP_RING(); |
| 903 | |
| 904 | BEGIN_LP_RING(2); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 905 | OUT_RING(CMD_OP_WAIT_FOR_EVENT | WAIT_FOR_PLANE_A_FLIP); |
| 906 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | ADVANCE_LP_RING(); |
| 908 | |
| 909 | /* Increment the frame counter. The client-side 3D driver must |
| 910 | * throttle the framerate by waiting for this value before |
| 911 | * performing the swapbuffer ioctl. |
| 912 | */ |
| 913 | dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; |
| 914 | |
| 915 | } |
| 916 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 917 | static void i810_dma_quiescent(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 919 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 920 | RING_LOCALS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | |
| 922 | /* printk("%s\n", __FUNCTION__); */ |
| 923 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 924 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 926 | BEGIN_LP_RING(4); |
| 927 | OUT_RING(INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); |
| 928 | OUT_RING(CMD_REPORT_HEAD); |
| 929 | OUT_RING(0); |
| 930 | OUT_RING(0); |
| 931 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 933 | i810_wait_ring(dev, dev_priv->ring.Size - 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | } |
| 935 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 936 | static int i810_flush_queue(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 938 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | drm_device_dma_t *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 940 | int i, ret = 0; |
| 941 | RING_LOCALS; |
| 942 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | /* printk("%s\n", __FUNCTION__); */ |
| 944 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 945 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 947 | BEGIN_LP_RING(2); |
| 948 | OUT_RING(CMD_REPORT_HEAD); |
| 949 | OUT_RING(0); |
| 950 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 952 | i810_wait_ring(dev, dev_priv->ring.Size - 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 954 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 955 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 956 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | |
| 958 | int used = cmpxchg(buf_priv->in_use, I810_BUF_HARDWARE, |
| 959 | I810_BUF_FREE); |
| 960 | |
| 961 | if (used == I810_BUF_HARDWARE) |
| 962 | DRM_DEBUG("reclaimed from HARDWARE\n"); |
| 963 | if (used == I810_BUF_CLIENT) |
| 964 | DRM_DEBUG("still on client\n"); |
| 965 | } |
| 966 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 967 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | /* Must be called with the lock held */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 971 | static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | { |
| 973 | drm_device_dma_t *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 974 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 976 | if (!dma) |
| 977 | return; |
| 978 | if (!dev->dev_private) |
| 979 | return; |
| 980 | if (!dma->buflist) |
| 981 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 983 | i810_flush_queue(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | |
| 985 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 986 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 987 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | |
| 989 | if (buf->filp == filp && buf_priv) { |
| 990 | int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, |
| 991 | I810_BUF_FREE); |
| 992 | |
| 993 | if (used == I810_BUF_CLIENT) |
| 994 | DRM_DEBUG("reclaimed from client\n"); |
| 995 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 996 | buf_priv->currently_mapped = I810_BUF_UNMAPPED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | } |
| 998 | } |
| 999 | } |
| 1000 | |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 1001 | static int i810_flush_ioctl(struct inode *inode, struct file *filp, |
| 1002 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1004 | struct drm_file *priv = filp->private_data; |
| 1005 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | |
| 1007 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1008 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1009 | i810_flush_queue(dev); |
| 1010 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | } |
| 1012 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | static int i810_dma_vertex(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1014 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1016 | struct drm_file *priv = filp->private_data; |
| 1017 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | drm_device_dma_t *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1019 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
| 1020 | u32 *hw_status = dev_priv->hw_status_page; |
| 1021 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
| 1022 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | drm_i810_vertex_t vertex; |
| 1024 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1025 | if (copy_from_user |
| 1026 | (&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | return -EFAULT; |
| 1028 | |
| 1029 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1030 | |
| 1031 | DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", |
| 1032 | vertex.idx, vertex.used, vertex.discard); |
| 1033 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1034 | if (vertex.idx < 0 || vertex.idx > dma->buf_count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | return -EINVAL; |
| 1036 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1037 | i810_dma_dispatch_vertex(dev, |
| 1038 | dma->buflist[vertex.idx], |
| 1039 | vertex.discard, vertex.used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1041 | atomic_add(vertex.used, &dev->counts[_DRM_STAT_SECONDARY]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1043 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
| 1044 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | |
| 1046 | return 0; |
| 1047 | } |
| 1048 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | static int i810_clear_bufs(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1050 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1052 | struct drm_file *priv = filp->private_data; |
| 1053 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | drm_i810_clear_t clear; |
| 1055 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1056 | if (copy_from_user |
| 1057 | (&clear, (drm_i810_clear_t __user *) arg, sizeof(clear))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | return -EFAULT; |
| 1059 | |
| 1060 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1061 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1062 | /* GH: Someone's doing nasty things... */ |
| 1063 | if (!dev->dev_private) { |
| 1064 | return -EINVAL; |
| 1065 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1067 | i810_dma_dispatch_clear(dev, clear.flags, |
| 1068 | clear.clear_color, clear.clear_depth); |
| 1069 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
| 1072 | static int i810_swap_bufs(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1073 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1075 | struct drm_file *priv = filp->private_data; |
| 1076 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | |
| 1078 | DRM_DEBUG("i810_swap_bufs\n"); |
| 1079 | |
| 1080 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1081 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1082 | i810_dma_dispatch_swap(dev); |
| 1083 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | static int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1087 | unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1089 | struct drm_file *priv = filp->private_data; |
| 1090 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1091 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
| 1092 | u32 *hw_status = dev_priv->hw_status_page; |
| 1093 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
| 1094 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1096 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | return 0; |
| 1098 | } |
| 1099 | |
| 1100 | static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1101 | unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1103 | struct drm_file *priv = filp->private_data; |
| 1104 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1105 | int retcode = 0; |
| 1106 | drm_i810_dma_t d; |
| 1107 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
| 1108 | u32 *hw_status = dev_priv->hw_status_page; |
| 1109 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
| 1110 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1112 | if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | return -EFAULT; |
| 1114 | |
| 1115 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1116 | |
| 1117 | d.granted = 0; |
| 1118 | |
| 1119 | retcode = i810_dma_get_buffer(dev, &d, filp); |
| 1120 | |
| 1121 | DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", |
| 1122 | current->pid, retcode, d.granted); |
| 1123 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1124 | if (copy_to_user((void __user *) arg, &d, sizeof(d))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | return -EFAULT; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1126 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | |
| 1128 | return retcode; |
| 1129 | } |
| 1130 | |
| 1131 | static int i810_copybuf(struct inode *inode, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1132 | struct file *filp, unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | { |
| 1134 | /* Never copy - 2.4.x doesn't need it */ |
| 1135 | return 0; |
| 1136 | } |
| 1137 | |
| 1138 | static int i810_docopy(struct inode *inode, struct file *filp, unsigned int cmd, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1139 | unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | { |
| 1141 | /* Never copy - 2.4.x doesn't need it */ |
| 1142 | return 0; |
| 1143 | } |
| 1144 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame^] | 1145 | static void i810_dma_dispatch_mc(struct drm_device * dev, struct drm_buf * buf, int used, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1146 | unsigned int last_render) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | { |
| 1148 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1149 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 1150 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
| 1151 | unsigned long address = (unsigned long)buf->bus_address; |
| 1152 | unsigned long start = address - dev->agp->base; |
| 1153 | int u; |
| 1154 | RING_LOCALS; |
| 1155 | |
| 1156 | i810_kernel_lost_context(dev); |
| 1157 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1158 | u = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_HARDWARE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | if (u != I810_BUF_CLIENT) { |
| 1160 | DRM_DEBUG("MC found buffer that isn't mine!\n"); |
| 1161 | } |
| 1162 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1163 | if (used > 4 * 1024) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | used = 0; |
| 1165 | |
| 1166 | sarea_priv->dirty = 0x7f; |
| 1167 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1168 | DRM_DEBUG("dispatch mc addr 0x%lx, used 0x%x\n", address, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | |
| 1170 | dev_priv->counter++; |
| 1171 | DRM_DEBUG("dispatch counter : %ld\n", dev_priv->counter); |
| 1172 | DRM_DEBUG("i810_dma_dispatch_mc\n"); |
| 1173 | DRM_DEBUG("start : %lx\n", start); |
| 1174 | DRM_DEBUG("used : %d\n", used); |
| 1175 | DRM_DEBUG("start + used - 4 : %ld\n", start + used - 4); |
| 1176 | |
| 1177 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) { |
| 1178 | if (used & 4) { |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 1179 | *(u32 *) ((char *) buf_priv->virtual + used) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | used += 4; |
| 1181 | } |
| 1182 | |
| 1183 | i810_unmap_buffer(buf); |
| 1184 | } |
| 1185 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1186 | OUT_RING(CMD_OP_BATCH_BUFFER); |
| 1187 | OUT_RING(start | BB1_PROTECTED); |
| 1188 | OUT_RING(start + used - 4); |
| 1189 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | ADVANCE_LP_RING(); |
| 1191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | BEGIN_LP_RING(8); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1193 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 1194 | OUT_RING(buf_priv->my_use_idx); |
| 1195 | OUT_RING(I810_BUF_FREE); |
| 1196 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1198 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 1199 | OUT_RING(16); |
| 1200 | OUT_RING(last_render); |
| 1201 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | ADVANCE_LP_RING(); |
| 1203 | } |
| 1204 | |
| 1205 | static int i810_dma_mc(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1206 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1208 | struct drm_file *priv = filp->private_data; |
| 1209 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | drm_device_dma_t *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1211 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | u32 *hw_status = dev_priv->hw_status_page; |
| 1213 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1214 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | drm_i810_mc_t mc; |
| 1216 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1217 | if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | return -EFAULT; |
| 1219 | |
| 1220 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1221 | |
| 1222 | if (mc.idx >= dma->buf_count || mc.idx < 0) |
| 1223 | return -EINVAL; |
| 1224 | |
| 1225 | i810_dma_dispatch_mc(dev, dma->buflist[mc.idx], mc.used, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1226 | mc.last_render); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | |
| 1228 | atomic_add(mc.used, &dev->counts[_DRM_STAT_SECONDARY]); |
| 1229 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1230 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
| 1231 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
| 1233 | return 0; |
| 1234 | } |
| 1235 | |
| 1236 | static int i810_rstatus(struct inode *inode, struct file *filp, |
| 1237 | unsigned int cmd, unsigned long arg) |
| 1238 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1239 | struct drm_file *priv = filp->private_data; |
| 1240 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1241 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1243 | return (int)(((u32 *) (dev_priv->hw_status_page))[4]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | static int i810_ov0_info(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1247 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1249 | struct drm_file *priv = filp->private_data; |
| 1250 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1251 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | drm_i810_overlay_t data; |
| 1253 | |
| 1254 | data.offset = dev_priv->overlay_offset; |
| 1255 | data.physical = dev_priv->overlay_physical; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1256 | if (copy_to_user |
| 1257 | ((drm_i810_overlay_t __user *) arg, &data, sizeof(data))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | return -EFAULT; |
| 1259 | return 0; |
| 1260 | } |
| 1261 | |
| 1262 | static int i810_fstatus(struct inode *inode, struct file *filp, |
| 1263 | unsigned int cmd, unsigned long arg) |
| 1264 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1265 | struct drm_file *priv = filp->private_data; |
| 1266 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1267 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | |
| 1269 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1270 | |
| 1271 | return I810_READ(0x30008); |
| 1272 | } |
| 1273 | |
| 1274 | static int i810_ov0_flip(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1275 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1277 | struct drm_file *priv = filp->private_data; |
| 1278 | struct drm_device *dev = priv->head->dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1279 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | |
| 1281 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1282 | |
| 1283 | //Tell the overlay to update |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1284 | I810_WRITE(0x30000, dev_priv->overlay_physical | 0x80000000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | /* Not sure why this isn't set all the time: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1290 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1291 | static void i810_do_init_pageflip(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | { |
| 1293 | drm_i810_private_t *dev_priv = dev->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | DRM_DEBUG("%s\n", __FUNCTION__); |
| 1296 | dev_priv->page_flipping = 1; |
| 1297 | dev_priv->current_page = 0; |
| 1298 | dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; |
| 1299 | } |
| 1300 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1301 | static int i810_do_cleanup_pageflip(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | { |
| 1303 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1304 | |
| 1305 | DRM_DEBUG("%s\n", __FUNCTION__); |
| 1306 | if (dev_priv->current_page != 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1307 | i810_dma_dispatch_flip(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | |
| 1309 | dev_priv->page_flipping = 0; |
| 1310 | return 0; |
| 1311 | } |
| 1312 | |
| 1313 | static int i810_flip_bufs(struct inode *inode, struct file *filp, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1314 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1316 | struct drm_file *priv = filp->private_data; |
| 1317 | struct drm_device *dev = priv->head->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1319 | |
| 1320 | DRM_DEBUG("%s\n", __FUNCTION__); |
| 1321 | |
| 1322 | LOCK_TEST_WITH_RETURN(dev, filp); |
| 1323 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1324 | if (!dev_priv->page_flipping) |
| 1325 | i810_do_init_pageflip(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1326 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1327 | i810_dma_dispatch_flip(dev); |
| 1328 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | } |
| 1330 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1331 | int i810_driver_load(struct drm_device *dev, unsigned long flags) |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 1332 | { |
| 1333 | /* i810 has 4 more counters */ |
| 1334 | dev->counters += 4; |
| 1335 | dev->types[6] = _DRM_STAT_IRQ; |
| 1336 | dev->types[7] = _DRM_STAT_PRIMARY; |
| 1337 | dev->types[8] = _DRM_STAT_SECONDARY; |
| 1338 | dev->types[9] = _DRM_STAT_DMA; |
| 1339 | |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1343 | void i810_driver_lastclose(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1345 | i810_dma_cleanup(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | } |
| 1347 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1348 | void i810_driver_preclose(struct drm_device * dev, DRMFILE filp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | { |
| 1350 | if (dev->dev_private) { |
| 1351 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1352 | if (dev_priv->page_flipping) { |
| 1353 | i810_do_cleanup_pageflip(dev); |
| 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1358 | void i810_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | { |
| 1360 | i810_reclaim_buffers(dev, filp); |
| 1361 | } |
| 1362 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1363 | int i810_driver_dma_quiescent(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1365 | i810_dma_quiescent(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | return 0; |
| 1367 | } |
| 1368 | |
| 1369 | drm_ioctl_desc_t i810_ioctls[] = { |
Dave Airlie | a7a2cc3 | 2006-01-02 13:54:04 +1100 | [diff] [blame] | 1370 | [DRM_IOCTL_NR(DRM_I810_INIT)] = {i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
| 1371 | [DRM_IOCTL_NR(DRM_I810_VERTEX)] = {i810_dma_vertex, DRM_AUTH}, |
| 1372 | [DRM_IOCTL_NR(DRM_I810_CLEAR)] = {i810_clear_bufs, DRM_AUTH}, |
| 1373 | [DRM_IOCTL_NR(DRM_I810_FLUSH)] = {i810_flush_ioctl, DRM_AUTH}, |
| 1374 | [DRM_IOCTL_NR(DRM_I810_GETAGE)] = {i810_getage, DRM_AUTH}, |
| 1375 | [DRM_IOCTL_NR(DRM_I810_GETBUF)] = {i810_getbuf, DRM_AUTH}, |
| 1376 | [DRM_IOCTL_NR(DRM_I810_SWAP)] = {i810_swap_bufs, DRM_AUTH}, |
| 1377 | [DRM_IOCTL_NR(DRM_I810_COPY)] = {i810_copybuf, DRM_AUTH}, |
| 1378 | [DRM_IOCTL_NR(DRM_I810_DOCOPY)] = {i810_docopy, DRM_AUTH}, |
| 1379 | [DRM_IOCTL_NR(DRM_I810_OV0INFO)] = {i810_ov0_info, DRM_AUTH}, |
| 1380 | [DRM_IOCTL_NR(DRM_I810_FSTATUS)] = {i810_fstatus, DRM_AUTH}, |
| 1381 | [DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = {i810_ov0_flip, DRM_AUTH}, |
| 1382 | [DRM_IOCTL_NR(DRM_I810_MC)] = {i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
| 1383 | [DRM_IOCTL_NR(DRM_I810_RSTATUS)] = {i810_rstatus, DRM_AUTH}, |
| 1384 | [DRM_IOCTL_NR(DRM_I810_FLIP)] = {i810_flip_bufs, DRM_AUTH} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | }; |
| 1386 | |
| 1387 | int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); |
Dave Airlie | cda1738 | 2005-07-10 17:31:26 +1000 | [diff] [blame] | 1388 | |
| 1389 | /** |
| 1390 | * Determine if the device really is AGP or not. |
| 1391 | * |
| 1392 | * All Intel graphics chipsets are treated as AGP, even if they are really |
| 1393 | * PCI-e. |
| 1394 | * |
| 1395 | * \param dev The device to be tested. |
| 1396 | * |
| 1397 | * \returns |
| 1398 | * A value of 1 is always retured to indictate every i810 is AGP. |
| 1399 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1400 | int i810_driver_device_is_agp(struct drm_device * dev) |
Dave Airlie | cda1738 | 2005-07-10 17:31:26 +1000 | [diff] [blame] | 1401 | { |
| 1402 | return 1; |
| 1403 | } |