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> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 39 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/pagemap.h> |
| 41 | |
| 42 | #define I810_BUF_FREE 2 |
| 43 | #define I810_BUF_CLIENT 1 |
Dave Airlie | bc5f452 | 2007-11-05 12:50:58 +1000 | [diff] [blame] | 44 | #define I810_BUF_HARDWARE 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
| 46 | #define I810_BUF_UNMAPPED 0 |
| 47 | #define I810_BUF_MAPPED 1 |
| 48 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 49 | static struct drm_buf *i810_freelist_get(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 51 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 52 | int i; |
| 53 | int used; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /* Linear search might not be the best solution */ |
| 56 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 57 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 58 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 59 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | /* In use is already a pointer */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 61 | used = cmpxchg(buf_priv->in_use, I810_BUF_FREE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | I810_BUF_CLIENT); |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 63 | if (used == I810_BUF_FREE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | return buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [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 | |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 96 | dev = priv->minor->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | dev_priv = dev->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 98 | buf = dev_priv->mmap_buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | buf_priv = buf->dev_private; |
| 100 | |
| 101 | vma->vm_flags |= (VM_IO | VM_DONTCOPY); |
| 102 | vma->vm_file = filp; |
| 103 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 104 | buf_priv->currently_mapped = I810_BUF_MAPPED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | if (io_remap_pfn_range(vma, vma->vm_start, |
Dave Airlie | 3d77461 | 2006-08-07 20:07:43 +1000 | [diff] [blame] | 107 | vma->vm_pgoff, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 108 | vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
| 109 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | return 0; |
| 111 | } |
| 112 | |
Arjan van de Ven | 2b8693c | 2007-02-12 00:55:32 -0800 | [diff] [blame] | 113 | static const struct file_operations i810_buffer_fops = { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 114 | .open = drm_open, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 115 | .release = drm_release, |
Arnd Bergmann | 1f692a1 | 2011-01-25 23:17:15 +0100 | [diff] [blame] | 116 | .unlocked_ioctl = drm_ioctl, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 117 | .mmap = i810_mmap_buffers, |
| 118 | .fasync = drm_fasync, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 119 | .llseek = noop_llseek, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 120 | }; |
| 121 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 122 | static int i810_map_buffer(struct drm_buf *buf, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 124 | struct drm_device *dev = file_priv->minor->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 126 | drm_i810_private_t *dev_priv = dev->dev_private; |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 127 | const struct file_operations *old_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | int retcode = 0; |
| 129 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 130 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | return -EINVAL; |
| 132 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 133 | down_write(¤t->mm->mmap_sem); |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 134 | old_fops = file_priv->filp->f_op; |
| 135 | file_priv->filp->f_op = &i810_buffer_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | dev_priv->mmap_buffer = buf; |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 137 | buf_priv->virtual = (void *)do_mmap(file_priv->filp, 0, buf->total, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 138 | PROT_READ | PROT_WRITE, |
| 139 | MAP_SHARED, buf->bus_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | dev_priv->mmap_buffer = NULL; |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 141 | file_priv->filp->f_op = old_fops; |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 142 | if (IS_ERR(buf_priv->virtual)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | /* Real error */ |
| 144 | DRM_ERROR("mmap error\n"); |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 145 | retcode = PTR_ERR(buf_priv->virtual); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | buf_priv->virtual = NULL; |
| 147 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 148 | up_write(¤t->mm->mmap_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
| 150 | return retcode; |
| 151 | } |
| 152 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 153 | static int i810_unmap_buffer(struct drm_buf *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | { |
| 155 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 156 | int retcode = 0; |
| 157 | |
| 158 | if (buf_priv->currently_mapped != I810_BUF_MAPPED) |
| 159 | return -EINVAL; |
| 160 | |
| 161 | down_write(¤t->mm->mmap_sem); |
| 162 | retcode = do_munmap(current->mm, |
| 163 | (unsigned long)buf_priv->virtual, |
| 164 | (size_t) buf->total); |
| 165 | up_write(¤t->mm->mmap_sem); |
| 166 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 167 | buf_priv->currently_mapped = I810_BUF_UNMAPPED; |
| 168 | buf_priv->virtual = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
| 170 | return retcode; |
| 171 | } |
| 172 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 173 | static int i810_dma_get_buffer(struct drm_device *dev, drm_i810_dma_t *d, |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 174 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 176 | struct drm_buf *buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | drm_i810_buf_priv_t *buf_priv; |
| 178 | int retcode = 0; |
| 179 | |
| 180 | buf = i810_freelist_get(dev); |
| 181 | if (!buf) { |
| 182 | retcode = -ENOMEM; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 183 | DRM_DEBUG("retcode=%d\n", retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | return retcode; |
| 185 | } |
| 186 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 187 | retcode = i810_map_buffer(buf, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | if (retcode) { |
| 189 | i810_freelist_put(dev, buf); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 190 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | return retcode; |
| 192 | } |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 193 | buf->file_priv = file_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | buf_priv = buf->dev_private; |
| 195 | d->granted = 1; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 196 | d->request_idx = buf->idx; |
| 197 | d->request_size = buf->total; |
| 198 | d->virtual = buf_priv->virtual; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | return retcode; |
| 201 | } |
| 202 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 203 | static int i810_dma_cleanup(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 205 | struct drm_device_dma *dma = dev->dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
| 207 | /* Make sure interrupts are disabled here because the uninstall ioctl |
| 208 | * may not have been called from userspace and after dev_private |
| 209 | * is freed, it's too late. |
| 210 | */ |
| 211 | if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled) |
| 212 | drm_irq_uninstall(dev); |
| 213 | |
| 214 | if (dev->dev_private) { |
| 215 | int i; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 216 | drm_i810_private_t *dev_priv = |
| 217 | (drm_i810_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 219 | if (dev_priv->ring.virtual_start) |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 220 | drm_core_ioremapfree(&dev_priv->ring.map, dev); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 221 | if (dev_priv->hw_status_page) { |
| 222 | pci_free_consistent(dev->pdev, PAGE_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | dev_priv->hw_status_page, |
| 224 | dev_priv->dma_status_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
Eric Anholt | 9a298b2 | 2009-03-24 12:23:04 -0700 | [diff] [blame] | 226 | kfree(dev->dev_private); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 227 | dev->dev_private = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 230 | struct drm_buf *buf = dma->buflist[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 232 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 233 | if (buf_priv->kernel_virtual && buf->total) |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 234 | drm_core_ioremapfree(&buf_priv->map, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | return 0; |
| 238 | } |
| 239 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 240 | static int i810_wait_ring(struct drm_device *dev, int n) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 241 | { |
| 242 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 243 | drm_i810_ring_buffer_t *ring = &(dev_priv->ring); |
| 244 | int iters = 0; |
| 245 | unsigned long end; |
| 246 | unsigned int last_head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 247 | |
| 248 | end = jiffies + (HZ * 3); |
| 249 | while (ring->space < n) { |
| 250 | ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 251 | ring->space = ring->head - (ring->tail + 8); |
| 252 | if (ring->space < 0) |
| 253 | ring->space += ring->Size; |
| 254 | |
| 255 | if (ring->head != last_head) { |
| 256 | end = jiffies + (HZ * 3); |
| 257 | last_head = ring->head; |
| 258 | } |
| 259 | |
| 260 | iters++; |
| 261 | if (time_before(end, jiffies)) { |
| 262 | DRM_ERROR("space: %d wanted %d\n", ring->space, n); |
| 263 | DRM_ERROR("lockup\n"); |
| 264 | goto out_wait_ring; |
| 265 | } |
| 266 | udelay(1); |
| 267 | } |
| 268 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 269 | out_wait_ring: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 270 | return iters; |
| 271 | } |
| 272 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 273 | static void i810_kernel_lost_context(struct drm_device *dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 274 | { |
| 275 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 276 | drm_i810_ring_buffer_t *ring = &(dev_priv->ring); |
| 277 | |
| 278 | ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 279 | ring->tail = I810_READ(LP_RING + RING_TAIL); |
| 280 | ring->space = ring->head - (ring->tail + 8); |
| 281 | if (ring->space < 0) |
| 282 | ring->space += ring->Size; |
| 283 | } |
| 284 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 285 | 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] | 286 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 287 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 288 | int my_idx = 24; |
| 289 | u32 *hw_status = (u32 *) (dev_priv->hw_status_page + my_idx); |
| 290 | int i; |
| 291 | |
| 292 | if (dma->buf_count > 1019) { |
| 293 | /* Not enough space in the status page for the freelist */ |
| 294 | return -EINVAL; |
| 295 | } |
| 296 | |
| 297 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 298 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 299 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 300 | |
| 301 | buf_priv->in_use = hw_status++; |
| 302 | buf_priv->my_use_idx = my_idx; |
| 303 | my_idx += 4; |
| 304 | |
| 305 | *buf_priv->in_use = I810_BUF_FREE; |
| 306 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 307 | buf_priv->map.offset = buf->bus_address; |
| 308 | buf_priv->map.size = buf->total; |
| 309 | buf_priv->map.type = _DRM_AGP; |
| 310 | buf_priv->map.flags = 0; |
| 311 | buf_priv->map.mtrr = 0; |
| 312 | |
| 313 | drm_core_ioremap(&buf_priv->map, dev); |
| 314 | buf_priv->kernel_virtual = buf_priv->map.handle; |
| 315 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 316 | } |
| 317 | return 0; |
| 318 | } |
| 319 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 320 | static int i810_dma_initialize(struct drm_device *dev, |
| 321 | drm_i810_private_t *dev_priv, |
| 322 | drm_i810_init_t *init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | { |
Dave Airlie | 5591051 | 2007-07-11 16:53:40 +1000 | [diff] [blame] | 324 | struct drm_map_list *r_list; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 325 | memset(dev_priv, 0, sizeof(drm_i810_private_t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 327 | list_for_each_entry(r_list, &dev->maplist, head) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | if (r_list->map && |
| 329 | r_list->map->type == _DRM_SHM && |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 330 | r_list->map->flags & _DRM_CONTAINS_LOCK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | dev_priv->sarea_map = r_list->map; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 332 | break; |
| 333 | } |
| 334 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (!dev_priv->sarea_map) { |
| 336 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 337 | i810_dma_cleanup(dev); |
| 338 | DRM_ERROR("can not find sarea!\n"); |
| 339 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | } |
| 341 | dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset); |
| 342 | if (!dev_priv->mmio_map) { |
| 343 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 344 | i810_dma_cleanup(dev); |
| 345 | DRM_ERROR("can not find mmio map!\n"); |
| 346 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
Dave Airlie | d1f2b55 | 2005-08-05 22:11:22 +1000 | [diff] [blame] | 348 | dev->agp_buffer_token = init->buffers_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset); |
| 350 | if (!dev->agp_buffer_map) { |
| 351 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 352 | i810_dma_cleanup(dev); |
| 353 | DRM_ERROR("can not find dma buffer map!\n"); |
| 354 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | dev_priv->sarea_priv = (drm_i810_sarea_t *) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 358 | ((u8 *) dev_priv->sarea_map->handle + init->sarea_priv_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 360 | dev_priv->ring.Start = init->ring_start; |
| 361 | dev_priv->ring.End = init->ring_end; |
| 362 | dev_priv->ring.Size = init->ring_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 364 | dev_priv->ring.map.offset = dev->agp->base + init->ring_start; |
| 365 | dev_priv->ring.map.size = init->ring_size; |
| 366 | dev_priv->ring.map.type = _DRM_AGP; |
| 367 | dev_priv->ring.map.flags = 0; |
| 368 | dev_priv->ring.map.mtrr = 0; |
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 | drm_core_ioremap(&dev_priv->ring.map, dev); |
| 371 | |
| 372 | if (dev_priv->ring.map.handle == NULL) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 373 | dev->dev_private = (void *)dev_priv; |
| 374 | i810_dma_cleanup(dev); |
| 375 | DRM_ERROR("can not ioremap virtual address for" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | " ring buffer\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 377 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 380 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; |
| 381 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 382 | dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
| 384 | dev_priv->w = init->w; |
| 385 | dev_priv->h = init->h; |
| 386 | dev_priv->pitch = init->pitch; |
| 387 | dev_priv->back_offset = init->back_offset; |
| 388 | dev_priv->depth_offset = init->depth_offset; |
| 389 | dev_priv->front_offset = init->front_offset; |
| 390 | |
| 391 | dev_priv->overlay_offset = init->overlay_offset; |
| 392 | dev_priv->overlay_physical = init->overlay_physical; |
| 393 | |
| 394 | dev_priv->front_di1 = init->front_offset | init->pitch_bits; |
| 395 | dev_priv->back_di1 = init->back_offset | init->pitch_bits; |
| 396 | dev_priv->zi1 = init->depth_offset | init->pitch_bits; |
| 397 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 398 | /* Program Hardware Status Page */ |
| 399 | dev_priv->hw_status_page = |
| 400 | pci_alloc_consistent(dev->pdev, PAGE_SIZE, |
| 401 | &dev_priv->dma_status_page); |
| 402 | if (!dev_priv->hw_status_page) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | dev->dev_private = (void *)dev_priv; |
| 404 | i810_dma_cleanup(dev); |
| 405 | DRM_ERROR("Can not allocate hardware status page\n"); |
| 406 | return -ENOMEM; |
| 407 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 408 | memset(dev_priv->hw_status_page, 0, PAGE_SIZE); |
| 409 | DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | |
| 411 | I810_WRITE(0x02080, dev_priv->dma_status_page); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 412 | DRM_DEBUG("Enabled hardware status page\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 414 | /* Now we need to init our freelist */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | if (i810_freelist_init(dev, dev_priv) != 0) { |
| 416 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 417 | i810_dma_cleanup(dev); |
| 418 | DRM_ERROR("Not enough space in the status page for" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | " the freelist\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 420 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
| 422 | dev->dev_private = (void *)dev_priv; |
| 423 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 424 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 427 | static int i810_dma_init(struct drm_device *dev, void *data, |
| 428 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 430 | drm_i810_private_t *dev_priv; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 431 | drm_i810_init_t *init = data; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 432 | int retcode = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 434 | switch (init->func) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 435 | case I810_INIT_DMA_1_4: |
| 436 | DRM_INFO("Using v1.4 init.\n"); |
Eric Anholt | 9a298b2 | 2009-03-24 12:23:04 -0700 | [diff] [blame] | 437 | dev_priv = kmalloc(sizeof(drm_i810_private_t), GFP_KERNEL); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 438 | if (dev_priv == NULL) |
| 439 | return -ENOMEM; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 440 | retcode = i810_dma_initialize(dev, dev_priv, init); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 441 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 443 | case I810_CLEANUP_DMA: |
| 444 | DRM_INFO("DMA Cleanup\n"); |
| 445 | retcode = i810_dma_cleanup(dev); |
| 446 | break; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 447 | default: |
| 448 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 451 | return retcode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | /* Most efficient way to verify state for the i810 is as it is |
| 455 | * emitted. Non-conformant state is silently dropped. |
| 456 | * |
| 457 | * Use 'volatile' & local var tmp to force the emitted values to be |
| 458 | * identical to the verified ones. |
| 459 | */ |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 460 | static void i810EmitContextVerified(struct drm_device *dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 461 | volatile unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 463 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | int i, j = 0; |
| 465 | unsigned int tmp; |
| 466 | RING_LOCALS; |
| 467 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 468 | BEGIN_LP_RING(I810_CTX_SETUP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 470 | OUT_RING(GFX_OP_COLOR_FACTOR); |
| 471 | OUT_RING(code[I810_CTXREG_CF1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 473 | OUT_RING(GFX_OP_STIPPLE); |
| 474 | OUT_RING(code[I810_CTXREG_ST1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 476 | for (i = 4; i < I810_CTX_SETUP_SIZE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | tmp = code[i]; |
| 478 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 479 | if ((tmp & (7 << 29)) == (3 << 29) && |
| 480 | (tmp & (0x1f << 24)) < (0x1d << 24)) { |
| 481 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | j++; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 483 | } else |
| 484 | printk("constext state dropped!!!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | if (j & 1) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 488 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
| 490 | ADVANCE_LP_RING(); |
| 491 | } |
| 492 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 493 | static void i810EmitTexVerified(struct drm_device *dev, volatile unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 495 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | int i, j = 0; |
| 497 | unsigned int tmp; |
| 498 | RING_LOCALS; |
| 499 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 500 | BEGIN_LP_RING(I810_TEX_SETUP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 502 | OUT_RING(GFX_OP_MAP_INFO); |
| 503 | OUT_RING(code[I810_TEXREG_MI1]); |
| 504 | OUT_RING(code[I810_TEXREG_MI2]); |
| 505 | OUT_RING(code[I810_TEXREG_MI3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 507 | for (i = 4; i < I810_TEX_SETUP_SIZE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | tmp = code[i]; |
| 509 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 510 | if ((tmp & (7 << 29)) == (3 << 29) && |
| 511 | (tmp & (0x1f << 24)) < (0x1d << 24)) { |
| 512 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | j++; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 514 | } else |
| 515 | printk("texture state dropped!!!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | if (j & 1) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 519 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | |
| 521 | ADVANCE_LP_RING(); |
| 522 | } |
| 523 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | /* Need to do some additional checking when setting the dest buffer. |
| 525 | */ |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 526 | static void i810EmitDestVerified(struct drm_device *dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 527 | volatile unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 529 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | unsigned int tmp; |
| 531 | RING_LOCALS; |
| 532 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 533 | BEGIN_LP_RING(I810_DEST_SETUP_SIZE + 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
| 535 | tmp = code[I810_DESTREG_DI1]; |
| 536 | if (tmp == dev_priv->front_di1 || tmp == dev_priv->back_di1) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 537 | OUT_RING(CMD_OP_DESTBUFFER_INFO); |
| 538 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | } else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 540 | DRM_DEBUG("bad di1 %x (allow %x or %x)\n", |
| 541 | tmp, dev_priv->front_di1, dev_priv->back_di1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | |
| 543 | /* invarient: |
| 544 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 545 | OUT_RING(CMD_OP_Z_BUFFER_INFO); |
| 546 | OUT_RING(dev_priv->zi1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 548 | OUT_RING(GFX_OP_DESTBUFFER_VARS); |
| 549 | OUT_RING(code[I810_DESTREG_DV1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 551 | OUT_RING(GFX_OP_DRAWRECT_INFO); |
| 552 | OUT_RING(code[I810_DESTREG_DR1]); |
| 553 | OUT_RING(code[I810_DESTREG_DR2]); |
| 554 | OUT_RING(code[I810_DESTREG_DR3]); |
| 555 | OUT_RING(code[I810_DESTREG_DR4]); |
| 556 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
| 558 | ADVANCE_LP_RING(); |
| 559 | } |
| 560 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 561 | static void i810EmitState(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 563 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 564 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | unsigned int dirty = sarea_priv->dirty; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 566 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 567 | DRM_DEBUG("%x\n", dirty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
| 569 | if (dirty & I810_UPLOAD_BUFFERS) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 570 | i810EmitDestVerified(dev, sarea_priv->BufferState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | sarea_priv->dirty &= ~I810_UPLOAD_BUFFERS; |
| 572 | } |
| 573 | |
| 574 | if (dirty & I810_UPLOAD_CTX) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 575 | i810EmitContextVerified(dev, sarea_priv->ContextState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | sarea_priv->dirty &= ~I810_UPLOAD_CTX; |
| 577 | } |
| 578 | |
| 579 | if (dirty & I810_UPLOAD_TEX0) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 580 | i810EmitTexVerified(dev, sarea_priv->TexState[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | sarea_priv->dirty &= ~I810_UPLOAD_TEX0; |
| 582 | } |
| 583 | |
| 584 | if (dirty & I810_UPLOAD_TEX1) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 585 | i810EmitTexVerified(dev, sarea_priv->TexState[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | sarea_priv->dirty &= ~I810_UPLOAD_TEX1; |
| 587 | } |
| 588 | } |
| 589 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | /* need to verify |
| 591 | */ |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 592 | static void i810_dma_dispatch_clear(struct drm_device *dev, int flags, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 593 | unsigned int clear_color, |
| 594 | unsigned int clear_zval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 596 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 597 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | int nbox = sarea_priv->nbox; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 599 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | int pitch = dev_priv->pitch; |
| 601 | int cpp = 2; |
| 602 | int i; |
| 603 | RING_LOCALS; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 604 | |
| 605 | if (dev_priv->current_page == 1) { |
| 606 | unsigned int tmp = flags; |
| 607 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | flags &= ~(I810_FRONT | I810_BACK); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 609 | if (tmp & I810_FRONT) |
| 610 | flags |= I810_BACK; |
| 611 | if (tmp & I810_BACK) |
| 612 | flags |= I810_FRONT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 615 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 617 | if (nbox > I810_NR_SAREA_CLIPRECTS) |
| 618 | nbox = I810_NR_SAREA_CLIPRECTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 620 | for (i = 0; i < nbox; i++, pbox++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | unsigned int x = pbox->x1; |
| 622 | unsigned int y = pbox->y1; |
| 623 | unsigned int width = (pbox->x2 - x) * cpp; |
| 624 | unsigned int height = pbox->y2 - y; |
| 625 | unsigned int start = y * pitch + x * cpp; |
| 626 | |
| 627 | if (pbox->x1 > pbox->x2 || |
| 628 | pbox->y1 > pbox->y2 || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 629 | pbox->x2 > dev_priv->w || pbox->y2 > dev_priv->h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | continue; |
| 631 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 632 | if (flags & I810_FRONT) { |
| 633 | BEGIN_LP_RING(6); |
| 634 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3); |
| 635 | OUT_RING(BR13_SOLID_PATTERN | (0xF0 << 16) | pitch); |
| 636 | OUT_RING((height << 16) | width); |
| 637 | OUT_RING(start); |
| 638 | OUT_RING(clear_color); |
| 639 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | ADVANCE_LP_RING(); |
| 641 | } |
| 642 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 643 | if (flags & I810_BACK) { |
| 644 | BEGIN_LP_RING(6); |
| 645 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3); |
| 646 | OUT_RING(BR13_SOLID_PATTERN | (0xF0 << 16) | pitch); |
| 647 | OUT_RING((height << 16) | width); |
| 648 | OUT_RING(dev_priv->back_offset + start); |
| 649 | OUT_RING(clear_color); |
| 650 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | ADVANCE_LP_RING(); |
| 652 | } |
| 653 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 654 | if (flags & I810_DEPTH) { |
| 655 | BEGIN_LP_RING(6); |
| 656 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3); |
| 657 | OUT_RING(BR13_SOLID_PATTERN | (0xF0 << 16) | pitch); |
| 658 | OUT_RING((height << 16) | width); |
| 659 | OUT_RING(dev_priv->depth_offset + start); |
| 660 | OUT_RING(clear_zval); |
| 661 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | ADVANCE_LP_RING(); |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 667 | static void i810_dma_dispatch_swap(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 669 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 670 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | int nbox = sarea_priv->nbox; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 672 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | int pitch = dev_priv->pitch; |
| 674 | int cpp = 2; |
| 675 | int i; |
| 676 | RING_LOCALS; |
| 677 | |
| 678 | DRM_DEBUG("swapbuffers\n"); |
| 679 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 680 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 682 | if (nbox > I810_NR_SAREA_CLIPRECTS) |
| 683 | nbox = I810_NR_SAREA_CLIPRECTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 685 | for (i = 0; i < nbox; i++, pbox++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | unsigned int w = pbox->x2 - pbox->x1; |
| 687 | unsigned int h = pbox->y2 - pbox->y1; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 688 | unsigned int dst = pbox->x1 * cpp + pbox->y1 * pitch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | unsigned int start = dst; |
| 690 | |
| 691 | if (pbox->x1 > pbox->x2 || |
| 692 | pbox->y1 > pbox->y2 || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 693 | pbox->x2 > dev_priv->w || pbox->y2 > dev_priv->h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | continue; |
| 695 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 696 | BEGIN_LP_RING(6); |
| 697 | OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4); |
| 698 | OUT_RING(pitch | (0xCC << 16)); |
| 699 | OUT_RING((h << 16) | (w * cpp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | if (dev_priv->current_page == 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 701 | OUT_RING(dev_priv->front_offset + start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 703 | OUT_RING(dev_priv->back_offset + start); |
| 704 | OUT_RING(pitch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | if (dev_priv->current_page == 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 706 | OUT_RING(dev_priv->back_offset + start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 708 | OUT_RING(dev_priv->front_offset + start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | ADVANCE_LP_RING(); |
| 710 | } |
| 711 | } |
| 712 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 713 | static void i810_dma_dispatch_vertex(struct drm_device *dev, |
| 714 | struct drm_buf *buf, int discard, int used) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 716 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 718 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 719 | struct drm_clip_rect *box = sarea_priv->boxes; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 720 | int nbox = sarea_priv->nbox; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | unsigned long address = (unsigned long)buf->bus_address; |
| 722 | unsigned long start = address - dev->agp->base; |
| 723 | int i = 0; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 724 | RING_LOCALS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 726 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 728 | if (nbox > I810_NR_SAREA_CLIPRECTS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | nbox = I810_NR_SAREA_CLIPRECTS; |
| 730 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 731 | if (used > 4 * 1024) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | used = 0; |
| 733 | |
| 734 | if (sarea_priv->dirty) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 735 | i810EmitState(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | |
| 737 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) { |
| 738 | unsigned int prim = (sarea_priv->vertex_prim & PR_MASK); |
| 739 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 740 | *(u32 *) buf_priv->kernel_virtual = |
| 741 | ((GFX_OP_PRIMITIVE | prim | ((used / 4) - 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | |
| 743 | if (used & 4) { |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 744 | *(u32 *) ((char *) buf_priv->kernel_virtual + used) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | used += 4; |
| 746 | } |
| 747 | |
| 748 | i810_unmap_buffer(buf); |
| 749 | } |
| 750 | |
| 751 | if (used) { |
| 752 | do { |
| 753 | if (i < nbox) { |
| 754 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 755 | OUT_RING(GFX_OP_SCISSOR | SC_UPDATE_SCISSOR | |
| 756 | SC_ENABLE); |
| 757 | OUT_RING(GFX_OP_SCISSOR_INFO); |
| 758 | OUT_RING(box[i].x1 | (box[i].y1 << 16)); |
| 759 | OUT_RING((box[i].x2 - |
| 760 | 1) | ((box[i].y2 - 1) << 16)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | ADVANCE_LP_RING(); |
| 762 | } |
| 763 | |
| 764 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 765 | OUT_RING(CMD_OP_BATCH_BUFFER); |
| 766 | OUT_RING(start | BB1_PROTECTED); |
| 767 | OUT_RING(start + used - 4); |
| 768 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | ADVANCE_LP_RING(); |
| 770 | |
| 771 | } while (++i < nbox); |
| 772 | } |
| 773 | |
| 774 | if (discard) { |
| 775 | dev_priv->counter++; |
| 776 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 777 | (void)cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, |
| 778 | I810_BUF_HARDWARE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | |
| 780 | BEGIN_LP_RING(8); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 781 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 782 | OUT_RING(20); |
| 783 | OUT_RING(dev_priv->counter); |
| 784 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 785 | OUT_RING(buf_priv->my_use_idx); |
| 786 | OUT_RING(I810_BUF_FREE); |
| 787 | OUT_RING(CMD_REPORT_HEAD); |
| 788 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | ADVANCE_LP_RING(); |
| 790 | } |
| 791 | } |
| 792 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 793 | static void i810_dma_dispatch_flip(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 795 | drm_i810_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | int pitch = dev_priv->pitch; |
| 797 | RING_LOCALS; |
| 798 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 799 | DRM_DEBUG("page=%d pfCurrentPage=%d\n", |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 800 | dev_priv->current_page, |
| 801 | dev_priv->sarea_priv->pf_current_page); |
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); |
| 804 | |
| 805 | BEGIN_LP_RING(2); |
| 806 | OUT_RING(INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); |
| 807 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | ADVANCE_LP_RING(); |
| 809 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 810 | BEGIN_LP_RING(I810_DEST_SETUP_SIZE + 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | /* On i815 at least ASYNC is buggy */ |
| 812 | /* pitch<<5 is from 11.2.8 p158, |
| 813 | its the pitch / 8 then left shifted 8, |
| 814 | so (pitch >> 3) << 8 */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 815 | OUT_RING(CMD_OP_FRONTBUFFER_INFO | (pitch << 5) /*| ASYNC_FLIP */ ); |
| 816 | if (dev_priv->current_page == 0) { |
| 817 | OUT_RING(dev_priv->back_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | dev_priv->current_page = 1; |
| 819 | } else { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 820 | OUT_RING(dev_priv->front_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | dev_priv->current_page = 0; |
| 822 | } |
| 823 | OUT_RING(0); |
| 824 | ADVANCE_LP_RING(); |
| 825 | |
| 826 | BEGIN_LP_RING(2); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 827 | OUT_RING(CMD_OP_WAIT_FOR_EVENT | WAIT_FOR_PLANE_A_FLIP); |
| 828 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | ADVANCE_LP_RING(); |
| 830 | |
| 831 | /* Increment the frame counter. The client-side 3D driver must |
| 832 | * throttle the framerate by waiting for this value before |
| 833 | * performing the swapbuffer ioctl. |
| 834 | */ |
| 835 | dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; |
| 836 | |
| 837 | } |
| 838 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 839 | static void i810_dma_quiescent(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 841 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 842 | RING_LOCALS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 844 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 846 | BEGIN_LP_RING(4); |
| 847 | OUT_RING(INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); |
| 848 | OUT_RING(CMD_REPORT_HEAD); |
| 849 | OUT_RING(0); |
| 850 | OUT_RING(0); |
| 851 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 853 | i810_wait_ring(dev, dev_priv->ring.Size - 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | } |
| 855 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 856 | static int i810_flush_queue(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 858 | drm_i810_private_t *dev_priv = dev->dev_private; |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 859 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 860 | int i, ret = 0; |
| 861 | RING_LOCALS; |
| 862 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 863 | i810_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 865 | BEGIN_LP_RING(2); |
| 866 | OUT_RING(CMD_REPORT_HEAD); |
| 867 | OUT_RING(0); |
| 868 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 870 | i810_wait_ring(dev, dev_priv->ring.Size - 8); |
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 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 873 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 874 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | |
| 876 | int used = cmpxchg(buf_priv->in_use, I810_BUF_HARDWARE, |
| 877 | I810_BUF_FREE); |
| 878 | |
| 879 | if (used == I810_BUF_HARDWARE) |
| 880 | DRM_DEBUG("reclaimed from HARDWARE\n"); |
| 881 | if (used == I810_BUF_CLIENT) |
| 882 | DRM_DEBUG("still on client\n"); |
| 883 | } |
| 884 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 885 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | /* Must be called with the lock held */ |
Daniel Vetter | 87499ff | 2011-10-25 23:51:24 +0200 | [diff] [blame] | 889 | void i810_driver_reclaim_buffers(struct drm_device *dev, |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 890 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 892 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 893 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 895 | if (!dma) |
| 896 | return; |
| 897 | if (!dev->dev_private) |
| 898 | return; |
| 899 | if (!dma->buflist) |
| 900 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 902 | i810_flush_queue(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | |
| 904 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 905 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 906 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 908 | if (buf->file_priv == file_priv && buf_priv) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, |
| 910 | I810_BUF_FREE); |
| 911 | |
| 912 | if (used == I810_BUF_CLIENT) |
| 913 | DRM_DEBUG("reclaimed from client\n"); |
| 914 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 915 | buf_priv->currently_mapped = I810_BUF_UNMAPPED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | } |
| 917 | } |
| 918 | } |
| 919 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 920 | static int i810_flush_ioctl(struct drm_device *dev, void *data, |
| 921 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | { |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 923 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 925 | i810_flush_queue(dev); |
| 926 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | } |
| 928 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 929 | static int i810_dma_vertex(struct drm_device *dev, void *data, |
| 930 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 932 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 933 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
| 934 | u32 *hw_status = dev_priv->hw_status_page; |
| 935 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
| 936 | dev_priv->sarea_priv; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 937 | drm_i810_vertex_t *vertex = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 939 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 941 | DRM_DEBUG("idx %d used %d discard %d\n", |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 942 | vertex->idx, vertex->used, vertex->discard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 944 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | return -EINVAL; |
| 946 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 947 | i810_dma_dispatch_vertex(dev, |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 948 | dma->buflist[vertex->idx], |
| 949 | vertex->discard, vertex->used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 951 | atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 953 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
| 954 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
| 956 | return 0; |
| 957 | } |
| 958 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 959 | static int i810_clear_bufs(struct drm_device *dev, void *data, |
| 960 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | { |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 962 | drm_i810_clear_t *clear = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 964 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 966 | /* GH: Someone's doing nasty things... */ |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 967 | if (!dev->dev_private) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 968 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 970 | i810_dma_dispatch_clear(dev, clear->flags, |
| 971 | clear->clear_color, clear->clear_depth); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 972 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 975 | static int i810_swap_bufs(struct drm_device *dev, void *data, |
| 976 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 978 | DRM_DEBUG("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 980 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 982 | i810_dma_dispatch_swap(dev); |
| 983 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | } |
| 985 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 986 | static int i810_getage(struct drm_device *dev, void *data, |
| 987 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 989 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
| 990 | u32 *hw_status = dev_priv->hw_status_page; |
| 991 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
| 992 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 994 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | return 0; |
| 996 | } |
| 997 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 998 | static int i810_getbuf(struct drm_device *dev, void *data, |
| 999 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1001 | int retcode = 0; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1002 | drm_i810_dma_t *d = data; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1003 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
| 1004 | u32 *hw_status = dev_priv->hw_status_page; |
| 1005 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
| 1006 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1008 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1010 | d->granted = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1012 | retcode = i810_dma_get_buffer(dev, d, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | |
| 1014 | DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", |
Pavel Emelyanov | ba25f9d | 2007-10-18 23:40:40 -0700 | [diff] [blame] | 1015 | task_pid_nr(current), retcode, d->granted); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1017 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | |
| 1019 | return retcode; |
| 1020 | } |
| 1021 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1022 | static int i810_copybuf(struct drm_device *dev, void *data, |
| 1023 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | { |
| 1025 | /* Never copy - 2.4.x doesn't need it */ |
| 1026 | return 0; |
| 1027 | } |
| 1028 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1029 | static int i810_docopy(struct drm_device *dev, void *data, |
| 1030 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | { |
| 1032 | /* Never copy - 2.4.x doesn't need it */ |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1036 | 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] | 1037 | unsigned int last_render) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | { |
| 1039 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1040 | drm_i810_buf_priv_t *buf_priv = buf->dev_private; |
| 1041 | drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; |
| 1042 | unsigned long address = (unsigned long)buf->bus_address; |
| 1043 | unsigned long start = address - dev->agp->base; |
| 1044 | int u; |
| 1045 | RING_LOCALS; |
| 1046 | |
| 1047 | i810_kernel_lost_context(dev); |
| 1048 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1049 | u = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_HARDWARE); |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1050 | if (u != I810_BUF_CLIENT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | DRM_DEBUG("MC found buffer that isn't mine!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1053 | if (used > 4 * 1024) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | used = 0; |
| 1055 | |
| 1056 | sarea_priv->dirty = 0x7f; |
| 1057 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 1058 | DRM_DEBUG("addr 0x%lx, used 0x%x\n", address, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | |
| 1060 | dev_priv->counter++; |
| 1061 | DRM_DEBUG("dispatch counter : %ld\n", dev_priv->counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | DRM_DEBUG("start : %lx\n", start); |
| 1063 | DRM_DEBUG("used : %d\n", used); |
| 1064 | DRM_DEBUG("start + used - 4 : %ld\n", start + used - 4); |
| 1065 | |
| 1066 | if (buf_priv->currently_mapped == I810_BUF_MAPPED) { |
| 1067 | if (used & 4) { |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 1068 | *(u32 *) ((char *) buf_priv->virtual + used) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | used += 4; |
| 1070 | } |
| 1071 | |
| 1072 | i810_unmap_buffer(buf); |
| 1073 | } |
| 1074 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1075 | OUT_RING(CMD_OP_BATCH_BUFFER); |
| 1076 | OUT_RING(start | BB1_PROTECTED); |
| 1077 | OUT_RING(start + used - 4); |
| 1078 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | ADVANCE_LP_RING(); |
| 1080 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | BEGIN_LP_RING(8); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1082 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 1083 | OUT_RING(buf_priv->my_use_idx); |
| 1084 | OUT_RING(I810_BUF_FREE); |
| 1085 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1087 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 1088 | OUT_RING(16); |
| 1089 | OUT_RING(last_render); |
| 1090 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | ADVANCE_LP_RING(); |
| 1092 | } |
| 1093 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1094 | static int i810_dma_mc(struct drm_device *dev, void *data, |
| 1095 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 1097 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1098 | 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] | 1099 | u32 *hw_status = dev_priv->hw_status_page; |
| 1100 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1101 | dev_priv->sarea_priv; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1102 | drm_i810_mc_t *mc = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1104 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1106 | if (mc->idx >= dma->buf_count || mc->idx < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | return -EINVAL; |
| 1108 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1109 | i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used, |
| 1110 | mc->last_render); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1112 | atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1114 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
| 1115 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | |
| 1117 | return 0; |
| 1118 | } |
| 1119 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1120 | static int i810_rstatus(struct drm_device *dev, void *data, |
| 1121 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1123 | 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] | 1124 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1125 | return (int)(((u32 *) (dev_priv->hw_status_page))[4]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | } |
| 1127 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1128 | static int i810_ov0_info(struct drm_device *dev, void *data, |
| 1129 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1131 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1132 | drm_i810_overlay_t *ov = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1134 | ov->offset = dev_priv->overlay_offset; |
| 1135 | ov->physical = dev_priv->overlay_physical; |
| 1136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | return 0; |
| 1138 | } |
| 1139 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1140 | static int i810_fstatus(struct drm_device *dev, void *data, |
| 1141 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1143 | 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] | 1144 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1145 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | return I810_READ(0x30008); |
| 1147 | } |
| 1148 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1149 | static int i810_ov0_flip(struct drm_device *dev, void *data, |
| 1150 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1152 | 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] | 1153 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1154 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1156 | /* Tell the overlay to update */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1157 | I810_WRITE(0x30000, dev_priv->overlay_physical | 0x80000000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | |
| 1159 | return 0; |
| 1160 | } |
| 1161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | /* Not sure why this isn't set all the time: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1163 | */ |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1164 | static void i810_do_init_pageflip(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | { |
| 1166 | drm_i810_private_t *dev_priv = dev->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1167 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 1168 | DRM_DEBUG("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | dev_priv->page_flipping = 1; |
| 1170 | dev_priv->current_page = 0; |
| 1171 | dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; |
| 1172 | } |
| 1173 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1174 | static int i810_do_cleanup_pageflip(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | { |
| 1176 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1177 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 1178 | DRM_DEBUG("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | if (dev_priv->current_page != 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1180 | i810_dma_dispatch_flip(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | |
| 1182 | dev_priv->page_flipping = 0; |
| 1183 | return 0; |
| 1184 | } |
| 1185 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1186 | static int i810_flip_bufs(struct drm_device *dev, void *data, |
| 1187 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | drm_i810_private_t *dev_priv = dev->dev_private; |
| 1190 | |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 1191 | DRM_DEBUG("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1193 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1195 | if (!dev_priv->page_flipping) |
| 1196 | i810_do_init_pageflip(dev); |
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 | i810_dma_dispatch_flip(dev); |
| 1199 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1202 | int i810_driver_load(struct drm_device *dev, unsigned long flags) |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 1203 | { |
| 1204 | /* i810 has 4 more counters */ |
| 1205 | dev->counters += 4; |
| 1206 | dev->types[6] = _DRM_STAT_IRQ; |
| 1207 | dev->types[7] = _DRM_STAT_PRIMARY; |
| 1208 | dev->types[8] = _DRM_STAT_SECONDARY; |
| 1209 | dev->types[9] = _DRM_STAT_DMA; |
| 1210 | |
| 1211 | return 0; |
| 1212 | } |
| 1213 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1214 | void i810_driver_lastclose(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1216 | i810_dma_cleanup(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | } |
| 1218 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1219 | void i810_driver_preclose(struct drm_device *dev, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | { |
| 1221 | if (dev->dev_private) { |
| 1222 | drm_i810_private_t *dev_priv = dev->dev_private; |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1223 | if (dev_priv->page_flipping) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | i810_do_cleanup_pageflip(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | |
Daniel Vetter | 87499ff | 2011-10-25 23:51:24 +0200 | [diff] [blame] | 1227 | if (file_priv->master && file_priv->master->lock.hw_lock) { |
| 1228 | drm_idlelock_take(&file_priv->master->lock); |
| 1229 | i810_driver_reclaim_buffers(dev, file_priv); |
| 1230 | drm_idlelock_release(&file_priv->master->lock); |
| 1231 | } else { |
| 1232 | /* master disappeared, clean up stuff anyway and hope nothing |
| 1233 | * goes wrong */ |
| 1234 | i810_driver_reclaim_buffers(dev, file_priv); |
| 1235 | } |
| 1236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | } |
| 1238 | |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1239 | int i810_driver_dma_quiescent(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1241 | i810_dma_quiescent(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | return 0; |
| 1243 | } |
| 1244 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1245 | struct drm_ioctl_desc i810_ioctls[] = { |
Dave Airlie | 1b2f148 | 2010-08-14 20:20:34 +1000 | [diff] [blame] | 1246 | DRM_IOCTL_DEF_DRV(I810_INIT, i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED), |
| 1247 | DRM_IOCTL_DEF_DRV(I810_VERTEX, i810_dma_vertex, DRM_AUTH|DRM_UNLOCKED), |
| 1248 | DRM_IOCTL_DEF_DRV(I810_CLEAR, i810_clear_bufs, DRM_AUTH|DRM_UNLOCKED), |
| 1249 | DRM_IOCTL_DEF_DRV(I810_FLUSH, i810_flush_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 1250 | DRM_IOCTL_DEF_DRV(I810_GETAGE, i810_getage, DRM_AUTH|DRM_UNLOCKED), |
| 1251 | DRM_IOCTL_DEF_DRV(I810_GETBUF, i810_getbuf, DRM_AUTH|DRM_UNLOCKED), |
| 1252 | DRM_IOCTL_DEF_DRV(I810_SWAP, i810_swap_bufs, DRM_AUTH|DRM_UNLOCKED), |
| 1253 | DRM_IOCTL_DEF_DRV(I810_COPY, i810_copybuf, DRM_AUTH|DRM_UNLOCKED), |
| 1254 | DRM_IOCTL_DEF_DRV(I810_DOCOPY, i810_docopy, DRM_AUTH|DRM_UNLOCKED), |
| 1255 | DRM_IOCTL_DEF_DRV(I810_OV0INFO, i810_ov0_info, DRM_AUTH|DRM_UNLOCKED), |
| 1256 | DRM_IOCTL_DEF_DRV(I810_FSTATUS, i810_fstatus, DRM_AUTH|DRM_UNLOCKED), |
| 1257 | DRM_IOCTL_DEF_DRV(I810_OV0FLIP, i810_ov0_flip, DRM_AUTH|DRM_UNLOCKED), |
| 1258 | DRM_IOCTL_DEF_DRV(I810_MC, i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED), |
| 1259 | DRM_IOCTL_DEF_DRV(I810_RSTATUS, i810_rstatus, DRM_AUTH|DRM_UNLOCKED), |
| 1260 | DRM_IOCTL_DEF_DRV(I810_FLIP, i810_flip_bufs, DRM_AUTH|DRM_UNLOCKED), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | }; |
| 1262 | |
| 1263 | int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); |
Dave Airlie | cda1738 | 2005-07-10 17:31:26 +1000 | [diff] [blame] | 1264 | |
| 1265 | /** |
| 1266 | * Determine if the device really is AGP or not. |
| 1267 | * |
| 1268 | * All Intel graphics chipsets are treated as AGP, even if they are really |
| 1269 | * PCI-e. |
| 1270 | * |
| 1271 | * \param dev The device to be tested. |
| 1272 | * |
| 1273 | * \returns |
| 1274 | * A value of 1 is always retured to indictate every i810 is AGP. |
| 1275 | */ |
Nicolas Kaiser | aca791c | 2010-07-14 21:54:13 +0200 | [diff] [blame] | 1276 | int i810_driver_device_is_agp(struct drm_device *dev) |
Dave Airlie | cda1738 | 2005-07-10 17:31:26 +1000 | [diff] [blame] | 1277 | { |
| 1278 | return 1; |
| 1279 | } |