Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* i830_dma.c -- DMA support for the I830 -*- 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: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 14 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 18 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * Abraham vd Merwe <abraham@2d3d.co.za> |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include "drmP.h" |
| 35 | #include "drm.h" |
| 36 | #include "i830_drm.h" |
| 37 | #include "i830_drv.h" |
| 38 | #include <linux/interrupt.h> /* For task queue support */ |
Harvey Harrison | 2153430 | 2008-02-13 15:03:17 -0800 | [diff] [blame] | 39 | #include <linux/pagemap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/delay.h> |
| 41 | #include <asm/uaccess.h> |
| 42 | |
| 43 | #define I830_BUF_FREE 2 |
| 44 | #define I830_BUF_CLIENT 1 |
Dave Airlie | bc5f452 | 2007-11-05 12:50:58 +1000 | [diff] [blame] | 45 | #define I830_BUF_HARDWARE 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | #define I830_BUF_UNMAPPED 0 |
| 48 | #define I830_BUF_MAPPED 1 |
| 49 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 50 | static struct drm_buf *i830_freelist_get(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 52 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 53 | int i; |
| 54 | int used; |
| 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | /* Linear search might not be the best solution */ |
| 57 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 58 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 59 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 60 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | /* In use is already a pointer */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 62 | used = cmpxchg(buf_priv->in_use, I830_BUF_FREE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | I830_BUF_CLIENT); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 64 | if (used == I830_BUF_FREE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | return buf; |
| 66 | } |
| 67 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 68 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /* This should only be called if the buffer is not sent to the hardware |
| 72 | * yet, the hardware updates in use for us once its on the ring buffer. |
| 73 | */ |
| 74 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 75 | static int i830_freelist_put(struct drm_device * dev, struct drm_buf * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 77 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
| 78 | int used; |
| 79 | |
| 80 | /* In use is already a pointer */ |
| 81 | used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, I830_BUF_FREE); |
| 82 | if (used != I830_BUF_CLIENT) { |
| 83 | DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx); |
| 84 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 86 | |
| 87 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 90 | static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 92 | struct drm_file *priv = filp->private_data; |
| 93 | struct drm_device *dev; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 94 | drm_i830_private_t *dev_priv; |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 95 | struct drm_buf *buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | drm_i830_buf_priv_t *buf_priv; |
| 97 | |
| 98 | lock_kernel(); |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 99 | dev = priv->minor->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | dev_priv = dev->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 101 | buf = dev_priv->mmap_buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | vma->vm_flags |= (VM_IO | VM_DONTCOPY); |
| 105 | vma->vm_file = filp; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 106 | |
| 107 | buf_priv->currently_mapped = I830_BUF_MAPPED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | unlock_kernel(); |
| 109 | |
| 110 | if (io_remap_pfn_range(vma, vma->vm_start, |
Dave Airlie | 3d77461 | 2006-08-07 20:07:43 +1000 | [diff] [blame] | 111 | vma->vm_pgoff, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 112 | vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
| 113 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | return 0; |
| 115 | } |
| 116 | |
Arjan van de Ven | 2b8693c | 2007-02-12 00:55:32 -0800 | [diff] [blame] | 117 | static const struct file_operations i830_buffer_fops = { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 118 | .open = drm_open, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 119 | .release = drm_release, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 120 | .ioctl = drm_ioctl, |
| 121 | .mmap = i830_mmap_buffers, |
| 122 | .fasync = drm_fasync, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 123 | }; |
| 124 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 125 | static int i830_map_buffer(struct drm_buf * buf, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 127 | struct drm_device *dev = file_priv->minor->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 129 | drm_i830_private_t *dev_priv = dev->dev_private; |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 130 | const struct file_operations *old_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | unsigned long virtual; |
| 132 | int retcode = 0; |
| 133 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 134 | if (buf_priv->currently_mapped == I830_BUF_MAPPED) |
| 135 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 137 | down_write(¤t->mm->mmap_sem); |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 138 | old_fops = file_priv->filp->f_op; |
| 139 | file_priv->filp->f_op = &i830_buffer_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | dev_priv->mmap_buffer = buf; |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 141 | virtual = do_mmap(file_priv->filp, 0, buf->total, PROT_READ | PROT_WRITE, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 142 | MAP_SHARED, buf->bus_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | dev_priv->mmap_buffer = NULL; |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 144 | file_priv->filp->f_op = old_fops; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 145 | if (IS_ERR((void *)virtual)) { /* ugh */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | /* Real error */ |
| 147 | DRM_ERROR("mmap error\n"); |
Denis Vlasenko | c7aed17 | 2006-08-16 11:54:07 +1000 | [diff] [blame] | 148 | retcode = PTR_ERR((void *)virtual); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | buf_priv->virtual = NULL; |
| 150 | } else { |
| 151 | buf_priv->virtual = (void __user *)virtual; |
| 152 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 153 | up_write(¤t->mm->mmap_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | return retcode; |
| 156 | } |
| 157 | |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 158 | static int i830_unmap_buffer(struct drm_buf * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | { |
| 160 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
| 161 | int retcode = 0; |
| 162 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 163 | if (buf_priv->currently_mapped != I830_BUF_MAPPED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | return -EINVAL; |
| 165 | |
| 166 | down_write(¤t->mm->mmap_sem); |
| 167 | retcode = do_munmap(current->mm, |
| 168 | (unsigned long)buf_priv->virtual, |
| 169 | (size_t) buf->total); |
| 170 | up_write(¤t->mm->mmap_sem); |
| 171 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 172 | buf_priv->currently_mapped = I830_BUF_UNMAPPED; |
| 173 | buf_priv->virtual = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | return retcode; |
| 176 | } |
| 177 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 178 | static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 179 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 181 | struct drm_buf *buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | drm_i830_buf_priv_t *buf_priv; |
| 183 | int retcode = 0; |
| 184 | |
| 185 | buf = i830_freelist_get(dev); |
| 186 | if (!buf) { |
| 187 | retcode = -ENOMEM; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 188 | DRM_DEBUG("retcode=%d\n", retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | return retcode; |
| 190 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 191 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 192 | retcode = i830_map_buffer(buf, file_priv); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 193 | if (retcode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | i830_freelist_put(dev, buf); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 195 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | return retcode; |
| 197 | } |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 198 | buf->file_priv = file_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 199 | buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | d->granted = 1; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 201 | d->request_idx = buf->idx; |
| 202 | d->request_size = buf->total; |
| 203 | d->virtual = buf_priv->virtual; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | |
| 205 | return retcode; |
| 206 | } |
| 207 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 208 | static int i830_dma_cleanup(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 210 | struct drm_device_dma *dma = dev->dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
| 212 | /* Make sure interrupts are disabled here because the uninstall ioctl |
| 213 | * may not have been called from userspace and after dev_private |
| 214 | * is freed, it's too late. |
| 215 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 216 | if (dev->irq_enabled) |
| 217 | drm_irq_uninstall(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
| 219 | if (dev->dev_private) { |
| 220 | int i; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 221 | drm_i830_private_t *dev_priv = |
| 222 | (drm_i830_private_t *) dev->dev_private; |
| 223 | |
| 224 | if (dev_priv->ring.virtual_start) { |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 225 | drm_core_ioremapfree(&dev_priv->ring.map, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 227 | if (dev_priv->hw_status_page) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | pci_free_consistent(dev->pdev, PAGE_SIZE, |
| 229 | dev_priv->hw_status_page, |
| 230 | dev_priv->dma_status_page); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 231 | /* Need to rewrite hardware status page */ |
| 232 | I830_WRITE(0x02080, 0x1ffff000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 235 | drm_free(dev->dev_private, sizeof(drm_i830_private_t), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | DRM_MEM_DRIVER); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 237 | dev->dev_private = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
| 239 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 240 | struct drm_buf *buf = dma->buflist[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 242 | if (buf_priv->kernel_virtual && buf->total) |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 243 | drm_core_ioremapfree(&buf_priv->map, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 246 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 249 | int i830_wait_ring(struct drm_device * dev, int n, const char *caller) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 251 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 252 | drm_i830_ring_buffer_t *ring = &(dev_priv->ring); |
| 253 | int iters = 0; |
| 254 | unsigned long end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | unsigned int last_head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 256 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 257 | end = jiffies + (HZ * 3); |
| 258 | while (ring->space < n) { |
| 259 | ring->head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 260 | ring->space = ring->head - (ring->tail + 8); |
| 261 | if (ring->space < 0) |
| 262 | ring->space += ring->Size; |
| 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | if (ring->head != last_head) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 265 | end = jiffies + (HZ * 3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | last_head = ring->head; |
| 267 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 268 | |
| 269 | iters++; |
| 270 | if (time_before(end, jiffies)) { |
| 271 | DRM_ERROR("space: %d wanted %d\n", ring->space, n); |
| 272 | DRM_ERROR("lockup\n"); |
| 273 | goto out_wait_ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
| 275 | udelay(1); |
| 276 | dev_priv->sarea_priv->perf_boxes |= I830_BOX_WAIT; |
| 277 | } |
| 278 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 279 | out_wait_ring: |
| 280 | return iters; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 283 | static void i830_kernel_lost_context(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 285 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 286 | drm_i830_ring_buffer_t *ring = &(dev_priv->ring); |
| 287 | |
| 288 | ring->head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR; |
| 289 | ring->tail = I830_READ(LP_RING + RING_TAIL) & TAIL_ADDR; |
| 290 | ring->space = ring->head - (ring->tail + 8); |
| 291 | if (ring->space < 0) |
| 292 | ring->space += ring->Size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
| 294 | if (ring->head == ring->tail) |
| 295 | dev_priv->sarea_priv->perf_boxes |= I830_BOX_RING_EMPTY; |
| 296 | } |
| 297 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 298 | static int i830_freelist_init(struct drm_device * dev, drm_i830_private_t * dev_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 300 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 301 | int my_idx = 36; |
| 302 | u32 *hw_status = (u32 *) (dev_priv->hw_status_page + my_idx); |
| 303 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 305 | if (dma->buf_count > 1019) { |
| 306 | /* Not enough space in the status page for the freelist */ |
| 307 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 310 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 311 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 312 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 314 | buf_priv->in_use = hw_status++; |
| 315 | buf_priv->my_use_idx = my_idx; |
| 316 | my_idx += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 318 | *buf_priv->in_use = I830_BUF_FREE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 320 | buf_priv->map.offset = buf->bus_address; |
| 321 | buf_priv->map.size = buf->total; |
| 322 | buf_priv->map.type = _DRM_AGP; |
| 323 | buf_priv->map.flags = 0; |
| 324 | buf_priv->map.mtrr = 0; |
| 325 | |
| 326 | drm_core_ioremap(&buf_priv->map, dev); |
| 327 | buf_priv->kernel_virtual = buf_priv->map.handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | return 0; |
| 330 | } |
| 331 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 332 | static int i830_dma_initialize(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 333 | drm_i830_private_t * dev_priv, |
| 334 | drm_i830_init_t * init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | { |
Dave Airlie | 5591051 | 2007-07-11 16:53:40 +1000 | [diff] [blame] | 336 | struct drm_map_list *r_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 338 | memset(dev_priv, 0, sizeof(drm_i830_private_t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 340 | list_for_each_entry(r_list, &dev->maplist, head) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 341 | if (r_list->map && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | r_list->map->type == _DRM_SHM && |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 343 | r_list->map->flags & _DRM_CONTAINS_LOCK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | dev_priv->sarea_map = r_list->map; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 345 | break; |
| 346 | } |
| 347 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 349 | if (!dev_priv->sarea_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | dev->dev_private = (void *)dev_priv; |
| 351 | i830_dma_cleanup(dev); |
| 352 | DRM_ERROR("can not find sarea!\n"); |
| 353 | return -EINVAL; |
| 354 | } |
| 355 | dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 356 | if (!dev_priv->mmio_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | dev->dev_private = (void *)dev_priv; |
| 358 | i830_dma_cleanup(dev); |
| 359 | DRM_ERROR("can not find mmio map!\n"); |
| 360 | return -EINVAL; |
| 361 | } |
Dave Airlie | d1f2b55 | 2005-08-05 22:11:22 +1000 | [diff] [blame] | 362 | dev->agp_buffer_token = init->buffers_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 364 | if (!dev->agp_buffer_map) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | dev->dev_private = (void *)dev_priv; |
| 366 | i830_dma_cleanup(dev); |
| 367 | DRM_ERROR("can not find dma buffer map!\n"); |
| 368 | return -EINVAL; |
| 369 | } |
| 370 | |
| 371 | dev_priv->sarea_priv = (drm_i830_sarea_t *) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 372 | ((u8 *) dev_priv->sarea_map->handle + init->sarea_priv_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 374 | dev_priv->ring.Start = init->ring_start; |
| 375 | dev_priv->ring.End = init->ring_end; |
| 376 | dev_priv->ring.Size = init->ring_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 378 | dev_priv->ring.map.offset = dev->agp->base + init->ring_start; |
| 379 | dev_priv->ring.map.size = init->ring_size; |
| 380 | dev_priv->ring.map.type = _DRM_AGP; |
| 381 | dev_priv->ring.map.flags = 0; |
| 382 | dev_priv->ring.map.mtrr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 384 | drm_core_ioremap(&dev_priv->ring.map, dev); |
| 385 | |
| 386 | if (dev_priv->ring.map.handle == NULL) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 387 | dev->dev_private = (void *)dev_priv; |
| 388 | i830_dma_cleanup(dev); |
| 389 | DRM_ERROR("can not ioremap virtual address for" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | " ring buffer\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 391 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Dave Airlie | b9094d3 | 2007-01-08 21:31:13 +1100 | [diff] [blame] | 394 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; |
| 395 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 396 | dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; |
| 397 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | dev_priv->w = init->w; |
| 399 | dev_priv->h = init->h; |
| 400 | dev_priv->pitch = init->pitch; |
| 401 | dev_priv->back_offset = init->back_offset; |
| 402 | dev_priv->depth_offset = init->depth_offset; |
| 403 | dev_priv->front_offset = init->front_offset; |
| 404 | |
| 405 | dev_priv->front_di1 = init->front_offset | init->pitch_bits; |
| 406 | dev_priv->back_di1 = init->back_offset | init->pitch_bits; |
| 407 | dev_priv->zi1 = init->depth_offset | init->pitch_bits; |
| 408 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 409 | DRM_DEBUG("front_di1 %x\n", dev_priv->front_di1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | DRM_DEBUG("back_offset %x\n", dev_priv->back_offset); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 411 | DRM_DEBUG("back_di1 %x\n", dev_priv->back_di1); |
| 412 | DRM_DEBUG("pitch_bits %x\n", init->pitch_bits); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
| 414 | dev_priv->cpp = init->cpp; |
| 415 | /* We are using separate values as placeholders for mechanisms for |
| 416 | * private backbuffer/depthbuffer usage. |
| 417 | */ |
| 418 | |
| 419 | dev_priv->back_pitch = init->back_pitch; |
| 420 | dev_priv->depth_pitch = init->depth_pitch; |
| 421 | dev_priv->do_boxes = 0; |
| 422 | dev_priv->use_mi_batchbuffer_start = 0; |
| 423 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 424 | /* Program Hardware Status Page */ |
| 425 | dev_priv->hw_status_page = |
| 426 | pci_alloc_consistent(dev->pdev, PAGE_SIZE, |
| 427 | &dev_priv->dma_status_page); |
| 428 | if (!dev_priv->hw_status_page) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | dev->dev_private = (void *)dev_priv; |
| 430 | i830_dma_cleanup(dev); |
| 431 | DRM_ERROR("Can not allocate hardware status page\n"); |
| 432 | return -ENOMEM; |
| 433 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 434 | memset(dev_priv->hw_status_page, 0, PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 436 | |
| 437 | I830_WRITE(0x02080, dev_priv->dma_status_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | DRM_DEBUG("Enabled hardware status page\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 439 | |
| 440 | /* Now we need to init our freelist */ |
| 441 | if (i830_freelist_init(dev, dev_priv) != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | dev->dev_private = (void *)dev_priv; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 443 | i830_dma_cleanup(dev); |
| 444 | DRM_ERROR("Not enough space in the status page for" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | " the freelist\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 446 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | } |
| 448 | dev->dev_private = (void *)dev_priv; |
| 449 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 450 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | } |
| 452 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 453 | static int i830_dma_init(struct drm_device *dev, void *data, |
| 454 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 456 | drm_i830_private_t *dev_priv; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 457 | drm_i830_init_t *init = data; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 458 | int retcode = 0; |
| 459 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 460 | switch (init->func) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 461 | case I830_INIT_DMA: |
| 462 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), |
| 463 | DRM_MEM_DRIVER); |
| 464 | if (dev_priv == NULL) |
| 465 | return -ENOMEM; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 466 | retcode = i830_dma_initialize(dev, dev_priv, init); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 467 | break; |
| 468 | case I830_CLEANUP_DMA: |
| 469 | retcode = i830_dma_cleanup(dev); |
| 470 | break; |
| 471 | default: |
| 472 | retcode = -EINVAL; |
| 473 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 475 | |
| 476 | return retcode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16)) |
| 480 | #define ST1_ENABLE (1<<16) |
| 481 | #define ST1_MASK (0xffff) |
| 482 | |
| 483 | /* Most efficient way to verify state for the i830 is as it is |
| 484 | * emitted. Non-conformant state is silently dropped. |
| 485 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 486 | static void i830EmitContextVerified(struct drm_device * dev, unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 488 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | int i, j = 0; |
| 490 | unsigned int tmp; |
| 491 | RING_LOCALS; |
| 492 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 493 | BEGIN_LP_RING(I830_CTX_SETUP_SIZE + 4); |
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 | for (i = 0; i < I830_CTXREG_BLENDCOLR0; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | tmp = code[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 497 | if ((tmp & (7 << 29)) == CMD_3D && |
| 498 | (tmp & (0x1f << 24)) < (0x1d << 24)) { |
| 499 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | j++; |
| 501 | } else { |
| 502 | DRM_ERROR("Skipping %d\n", i); |
| 503 | } |
| 504 | } |
| 505 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 506 | OUT_RING(STATE3D_CONST_BLEND_COLOR_CMD); |
| 507 | OUT_RING(code[I830_CTXREG_BLENDCOLR]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | j += 2; |
| 509 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 510 | for (i = I830_CTXREG_VF; i < I830_CTXREG_MCSB0; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | tmp = code[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 512 | if ((tmp & (7 << 29)) == CMD_3D && |
| 513 | (tmp & (0x1f << 24)) < (0x1d << 24)) { |
| 514 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | j++; |
| 516 | } else { |
| 517 | DRM_ERROR("Skipping %d\n", i); |
| 518 | } |
| 519 | } |
| 520 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 521 | OUT_RING(STATE3D_MAP_COORD_SETBIND_CMD); |
| 522 | OUT_RING(code[I830_CTXREG_MCSB1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | j += 2; |
| 524 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 525 | if (j & 1) |
| 526 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | |
| 528 | ADVANCE_LP_RING(); |
| 529 | } |
| 530 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 531 | static void i830EmitTexVerified(struct drm_device * dev, unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 533 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | int i, j = 0; |
| 535 | unsigned int tmp; |
| 536 | RING_LOCALS; |
| 537 | |
| 538 | if (code[I830_TEXREG_MI0] == GFX_OP_MAP_INFO || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 539 | (code[I830_TEXREG_MI0] & ~(0xf * LOAD_TEXTURE_MAP0)) == |
| 540 | (STATE3D_LOAD_STATE_IMMEDIATE_2 | 4)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 542 | BEGIN_LP_RING(I830_TEX_SETUP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 544 | OUT_RING(code[I830_TEXREG_MI0]); /* TM0LI */ |
| 545 | OUT_RING(code[I830_TEXREG_MI1]); /* TM0S0 */ |
| 546 | OUT_RING(code[I830_TEXREG_MI2]); /* TM0S1 */ |
| 547 | OUT_RING(code[I830_TEXREG_MI3]); /* TM0S2 */ |
| 548 | OUT_RING(code[I830_TEXREG_MI4]); /* TM0S3 */ |
| 549 | OUT_RING(code[I830_TEXREG_MI5]); /* TM0S4 */ |
| 550 | |
| 551 | for (i = 6; i < I830_TEX_SETUP_SIZE; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | tmp = code[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 553 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | j++; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 555 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 557 | if (j & 1) |
| 558 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
| 560 | ADVANCE_LP_RING(); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 561 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | printk("rejected packet %x\n", code[0]); |
| 563 | } |
| 564 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 565 | static void i830EmitTexBlendVerified(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 566 | unsigned int *code, unsigned int num) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 568 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | int i, j = 0; |
| 570 | unsigned int tmp; |
| 571 | RING_LOCALS; |
| 572 | |
| 573 | if (!num) |
| 574 | return; |
| 575 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 576 | BEGIN_LP_RING(num + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 578 | for (i = 0; i < num; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | tmp = code[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 580 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | j++; |
| 582 | } |
| 583 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 584 | if (j & 1) |
| 585 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | |
| 587 | ADVANCE_LP_RING(); |
| 588 | } |
| 589 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 590 | static void i830EmitTexPalette(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 591 | unsigned int *palette, int number, int is_shared) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 593 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | int i; |
| 595 | RING_LOCALS; |
| 596 | |
| 597 | return; |
| 598 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 599 | BEGIN_LP_RING(258); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 601 | if (is_shared == 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | OUT_RING(CMD_OP_MAP_PALETTE_LOAD | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 603 | MAP_PALETTE_NUM(0) | MAP_PALETTE_BOTH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | } else { |
| 605 | OUT_RING(CMD_OP_MAP_PALETTE_LOAD | MAP_PALETTE_NUM(number)); |
| 606 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 607 | for (i = 0; i < 256; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | OUT_RING(palette[i]); |
| 609 | } |
| 610 | OUT_RING(0); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 611 | /* KW: WHERE IS THE ADVANCE_LP_RING? This is effectively a noop! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | */ |
| 613 | } |
| 614 | |
| 615 | /* Need to do some additional checking when setting the dest buffer. |
| 616 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 617 | static void i830EmitDestVerified(struct drm_device * dev, unsigned int *code) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 618 | { |
| 619 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | unsigned int tmp; |
| 621 | RING_LOCALS; |
| 622 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 623 | BEGIN_LP_RING(I830_DEST_SETUP_SIZE + 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
| 625 | tmp = code[I830_DESTREG_CBUFADDR]; |
| 626 | if (tmp == dev_priv->front_di1 || tmp == dev_priv->back_di1) { |
| 627 | if (((int)outring) & 8) { |
| 628 | OUT_RING(0); |
| 629 | OUT_RING(0); |
| 630 | } |
| 631 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 632 | OUT_RING(CMD_OP_DESTBUFFER_INFO); |
| 633 | OUT_RING(BUF_3D_ID_COLOR_BACK | |
| 634 | BUF_3D_PITCH(dev_priv->back_pitch * dev_priv->cpp) | |
| 635 | BUF_3D_USE_FENCE); |
| 636 | OUT_RING(tmp); |
| 637 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 639 | OUT_RING(CMD_OP_DESTBUFFER_INFO); |
| 640 | OUT_RING(BUF_3D_ID_DEPTH | BUF_3D_USE_FENCE | |
| 641 | BUF_3D_PITCH(dev_priv->depth_pitch * dev_priv->cpp)); |
| 642 | OUT_RING(dev_priv->zi1); |
| 643 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | } else { |
| 645 | DRM_ERROR("bad di1 %x (allow %x or %x)\n", |
| 646 | tmp, dev_priv->front_di1, dev_priv->back_di1); |
| 647 | } |
| 648 | |
| 649 | /* invarient: |
| 650 | */ |
| 651 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 652 | OUT_RING(GFX_OP_DESTBUFFER_VARS); |
| 653 | OUT_RING(code[I830_DESTREG_DV1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 655 | OUT_RING(GFX_OP_DRAWRECT_INFO); |
| 656 | OUT_RING(code[I830_DESTREG_DR1]); |
| 657 | OUT_RING(code[I830_DESTREG_DR2]); |
| 658 | OUT_RING(code[I830_DESTREG_DR3]); |
| 659 | OUT_RING(code[I830_DESTREG_DR4]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
| 661 | /* Need to verify this */ |
| 662 | tmp = code[I830_DESTREG_SENABLE]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 663 | if ((tmp & ~0x3) == GFX_OP_SCISSOR_ENABLE) { |
| 664 | OUT_RING(tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | } else { |
| 666 | DRM_ERROR("bad scissor enable\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 667 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | } |
| 669 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 670 | OUT_RING(GFX_OP_SCISSOR_RECT); |
| 671 | OUT_RING(code[I830_DESTREG_SR1]); |
| 672 | OUT_RING(code[I830_DESTREG_SR2]); |
| 673 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | |
| 675 | ADVANCE_LP_RING(); |
| 676 | } |
| 677 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 678 | static void i830EmitStippleVerified(struct drm_device * dev, unsigned int *code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 680 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | RING_LOCALS; |
| 682 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 683 | BEGIN_LP_RING(2); |
| 684 | OUT_RING(GFX_OP_STIPPLE); |
| 685 | OUT_RING(code[1]); |
| 686 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | } |
| 688 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 689 | static void i830EmitState(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 691 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 692 | drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | unsigned int dirty = sarea_priv->dirty; |
| 694 | |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 695 | DRM_DEBUG("%s %x\n", __func__, dirty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
| 697 | if (dirty & I830_UPLOAD_BUFFERS) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 698 | i830EmitDestVerified(dev, sarea_priv->BufferState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | sarea_priv->dirty &= ~I830_UPLOAD_BUFFERS; |
| 700 | } |
| 701 | |
| 702 | if (dirty & I830_UPLOAD_CTX) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 703 | i830EmitContextVerified(dev, sarea_priv->ContextState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | sarea_priv->dirty &= ~I830_UPLOAD_CTX; |
| 705 | } |
| 706 | |
| 707 | if (dirty & I830_UPLOAD_TEX0) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 708 | i830EmitTexVerified(dev, sarea_priv->TexState[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | sarea_priv->dirty &= ~I830_UPLOAD_TEX0; |
| 710 | } |
| 711 | |
| 712 | if (dirty & I830_UPLOAD_TEX1) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 713 | i830EmitTexVerified(dev, sarea_priv->TexState[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | sarea_priv->dirty &= ~I830_UPLOAD_TEX1; |
| 715 | } |
| 716 | |
| 717 | if (dirty & I830_UPLOAD_TEXBLEND0) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 718 | i830EmitTexBlendVerified(dev, sarea_priv->TexBlendState[0], |
| 719 | sarea_priv->TexBlendStateWordsUsed[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | sarea_priv->dirty &= ~I830_UPLOAD_TEXBLEND0; |
| 721 | } |
| 722 | |
| 723 | if (dirty & I830_UPLOAD_TEXBLEND1) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 724 | i830EmitTexBlendVerified(dev, sarea_priv->TexBlendState[1], |
| 725 | sarea_priv->TexBlendStateWordsUsed[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | sarea_priv->dirty &= ~I830_UPLOAD_TEXBLEND1; |
| 727 | } |
| 728 | |
| 729 | if (dirty & I830_UPLOAD_TEX_PALETTE_SHARED) { |
| 730 | i830EmitTexPalette(dev, sarea_priv->Palette[0], 0, 1); |
| 731 | } else { |
| 732 | if (dirty & I830_UPLOAD_TEX_PALETTE_N(0)) { |
| 733 | i830EmitTexPalette(dev, sarea_priv->Palette[0], 0, 0); |
| 734 | sarea_priv->dirty &= ~I830_UPLOAD_TEX_PALETTE_N(0); |
| 735 | } |
| 736 | if (dirty & I830_UPLOAD_TEX_PALETTE_N(1)) { |
| 737 | i830EmitTexPalette(dev, sarea_priv->Palette[1], 1, 0); |
| 738 | sarea_priv->dirty &= ~I830_UPLOAD_TEX_PALETTE_N(1); |
| 739 | } |
| 740 | |
| 741 | /* 1.3: |
| 742 | */ |
| 743 | #if 0 |
| 744 | if (dirty & I830_UPLOAD_TEX_PALETTE_N(2)) { |
| 745 | i830EmitTexPalette(dev, sarea_priv->Palette2[0], 0, 0); |
| 746 | sarea_priv->dirty &= ~I830_UPLOAD_TEX_PALETTE_N(2); |
| 747 | } |
| 748 | if (dirty & I830_UPLOAD_TEX_PALETTE_N(3)) { |
| 749 | i830EmitTexPalette(dev, sarea_priv->Palette2[1], 1, 0); |
| 750 | sarea_priv->dirty &= ~I830_UPLOAD_TEX_PALETTE_N(2); |
| 751 | } |
| 752 | #endif |
| 753 | } |
| 754 | |
| 755 | /* 1.3: |
| 756 | */ |
| 757 | if (dirty & I830_UPLOAD_STIPPLE) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 758 | i830EmitStippleVerified(dev, sarea_priv->StippleState); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | sarea_priv->dirty &= ~I830_UPLOAD_STIPPLE; |
| 760 | } |
| 761 | |
| 762 | if (dirty & I830_UPLOAD_TEX2) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 763 | i830EmitTexVerified(dev, sarea_priv->TexState2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | sarea_priv->dirty &= ~I830_UPLOAD_TEX2; |
| 765 | } |
| 766 | |
| 767 | if (dirty & I830_UPLOAD_TEX3) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 768 | i830EmitTexVerified(dev, sarea_priv->TexState3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | sarea_priv->dirty &= ~I830_UPLOAD_TEX3; |
| 770 | } |
| 771 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | if (dirty & I830_UPLOAD_TEXBLEND2) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 773 | i830EmitTexBlendVerified(dev, |
| 774 | sarea_priv->TexBlendState2, |
| 775 | sarea_priv->TexBlendStateWordsUsed2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
| 777 | sarea_priv->dirty &= ~I830_UPLOAD_TEXBLEND2; |
| 778 | } |
| 779 | |
| 780 | if (dirty & I830_UPLOAD_TEXBLEND3) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 781 | i830EmitTexBlendVerified(dev, |
| 782 | sarea_priv->TexBlendState3, |
| 783 | sarea_priv->TexBlendStateWordsUsed3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | sarea_priv->dirty &= ~I830_UPLOAD_TEXBLEND3; |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | /* ================================================================ |
| 789 | * Performance monitoring functions |
| 790 | */ |
| 791 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 792 | static void i830_fill_box(struct drm_device * dev, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 793 | int x, int y, int w, int h, int r, int g, int b) |
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_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | u32 color; |
| 797 | unsigned int BR13, CMD; |
| 798 | RING_LOCALS; |
| 799 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 800 | BR13 = (0xF0 << 16) | (dev_priv->pitch * dev_priv->cpp) | (1 << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | CMD = XY_COLOR_BLT_CMD; |
| 802 | x += dev_priv->sarea_priv->boxes[0].x1; |
| 803 | y += dev_priv->sarea_priv->boxes[0].y1; |
| 804 | |
| 805 | if (dev_priv->cpp == 4) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 806 | BR13 |= (1 << 25); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | CMD |= (XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 808 | color = (((0xff) << 24) | (r << 16) | (g << 8) | b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | } else { |
| 810 | color = (((r & 0xf8) << 8) | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 811 | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | } |
| 813 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 814 | BEGIN_LP_RING(6); |
| 815 | OUT_RING(CMD); |
| 816 | OUT_RING(BR13); |
| 817 | OUT_RING((y << 16) | x); |
| 818 | OUT_RING(((y + h) << 16) | (x + w)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 820 | if (dev_priv->current_page == 1) { |
| 821 | OUT_RING(dev_priv->front_offset); |
| 822 | } else { |
| 823 | OUT_RING(dev_priv->back_offset); |
| 824 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 826 | OUT_RING(color); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | ADVANCE_LP_RING(); |
| 828 | } |
| 829 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 830 | static void i830_cp_performance_boxes(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 832 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 833 | |
| 834 | /* Purple box for page flipping |
| 835 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 836 | if (dev_priv->sarea_priv->perf_boxes & I830_BOX_FLIP) |
| 837 | i830_fill_box(dev, 4, 4, 8, 8, 255, 0, 255); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | |
| 839 | /* Red box if we have to wait for idle at any point |
| 840 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 841 | if (dev_priv->sarea_priv->perf_boxes & I830_BOX_WAIT) |
| 842 | i830_fill_box(dev, 16, 4, 8, 8, 255, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
| 844 | /* Blue box: lost context? |
| 845 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 846 | if (dev_priv->sarea_priv->perf_boxes & I830_BOX_LOST_CONTEXT) |
| 847 | i830_fill_box(dev, 28, 4, 8, 8, 0, 0, 255); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | |
| 849 | /* Yellow box for texture swaps |
| 850 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 851 | if (dev_priv->sarea_priv->perf_boxes & I830_BOX_TEXTURE_LOAD) |
| 852 | i830_fill_box(dev, 40, 4, 8, 8, 255, 255, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | |
| 854 | /* Green box if hardware never idles (as far as we can tell) |
| 855 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 856 | if (!(dev_priv->sarea_priv->perf_boxes & I830_BOX_RING_EMPTY)) |
| 857 | i830_fill_box(dev, 64, 4, 8, 8, 0, 255, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 859 | /* Draw bars indicating number of buffers allocated |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | * (not a great measure, easily confused) |
| 861 | */ |
| 862 | if (dev_priv->dma_used) { |
| 863 | int bar = dev_priv->dma_used / 10240; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 864 | if (bar > 100) |
| 865 | bar = 100; |
| 866 | if (bar < 1) |
| 867 | bar = 1; |
| 868 | i830_fill_box(dev, 4, 16, bar, 4, 196, 128, 128); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | dev_priv->dma_used = 0; |
| 870 | } |
| 871 | |
| 872 | dev_priv->sarea_priv->perf_boxes = 0; |
| 873 | } |
| 874 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 875 | static void i830_dma_dispatch_clear(struct drm_device * dev, int flags, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | unsigned int clear_color, |
| 877 | unsigned int clear_zval, |
| 878 | unsigned int clear_depthmask) |
| 879 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 880 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 881 | drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | int nbox = sarea_priv->nbox; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 883 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | int pitch = dev_priv->pitch; |
| 885 | int cpp = dev_priv->cpp; |
| 886 | int i; |
| 887 | unsigned int BR13, CMD, D_CMD; |
| 888 | RING_LOCALS; |
| 889 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 890 | if (dev_priv->current_page == 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | unsigned int tmp = flags; |
| 892 | |
| 893 | flags &= ~(I830_FRONT | I830_BACK); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 894 | if (tmp & I830_FRONT) |
| 895 | flags |= I830_BACK; |
| 896 | if (tmp & I830_BACK) |
| 897 | flags |= I830_FRONT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | } |
| 899 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 900 | i830_kernel_lost_context(dev); |
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 | switch (cpp) { |
| 903 | case 2: |
| 904 | BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | D_CMD = CMD = XY_COLOR_BLT_CMD; |
| 906 | break; |
| 907 | case 4: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 908 | BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24) | (1 << 25); |
| 909 | CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | XY_COLOR_BLT_WRITE_RGB); |
| 911 | D_CMD = XY_COLOR_BLT_CMD; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 912 | if (clear_depthmask & 0x00ffffff) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | D_CMD |= XY_COLOR_BLT_WRITE_RGB; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 914 | if (clear_depthmask & 0xff000000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | D_CMD |= XY_COLOR_BLT_WRITE_ALPHA; |
| 916 | break; |
| 917 | default: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 918 | BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | D_CMD = CMD = XY_COLOR_BLT_CMD; |
| 920 | break; |
| 921 | } |
| 922 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 923 | if (nbox > I830_NR_SAREA_CLIPRECTS) |
| 924 | nbox = I830_NR_SAREA_CLIPRECTS; |
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 | for (i = 0; i < nbox; i++, pbox++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | if (pbox->x1 > pbox->x2 || |
| 928 | pbox->y1 > pbox->y2 || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 929 | pbox->x2 > dev_priv->w || pbox->y2 > dev_priv->h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | continue; |
| 931 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 932 | if (flags & I830_FRONT) { |
| 933 | DRM_DEBUG("clear front\n"); |
| 934 | BEGIN_LP_RING(6); |
| 935 | OUT_RING(CMD); |
| 936 | OUT_RING(BR13); |
| 937 | OUT_RING((pbox->y1 << 16) | pbox->x1); |
| 938 | OUT_RING((pbox->y2 << 16) | pbox->x2); |
| 939 | OUT_RING(dev_priv->front_offset); |
| 940 | OUT_RING(clear_color); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | ADVANCE_LP_RING(); |
| 942 | } |
| 943 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 944 | if (flags & I830_BACK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | DRM_DEBUG("clear back\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 946 | BEGIN_LP_RING(6); |
| 947 | OUT_RING(CMD); |
| 948 | OUT_RING(BR13); |
| 949 | OUT_RING((pbox->y1 << 16) | pbox->x1); |
| 950 | OUT_RING((pbox->y2 << 16) | pbox->x2); |
| 951 | OUT_RING(dev_priv->back_offset); |
| 952 | OUT_RING(clear_color); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | ADVANCE_LP_RING(); |
| 954 | } |
| 955 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 956 | if (flags & I830_DEPTH) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | DRM_DEBUG("clear depth\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 958 | BEGIN_LP_RING(6); |
| 959 | OUT_RING(D_CMD); |
| 960 | OUT_RING(BR13); |
| 961 | OUT_RING((pbox->y1 << 16) | pbox->x1); |
| 962 | OUT_RING((pbox->y2 << 16) | pbox->x2); |
| 963 | OUT_RING(dev_priv->depth_offset); |
| 964 | OUT_RING(clear_zval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | ADVANCE_LP_RING(); |
| 966 | } |
| 967 | } |
| 968 | } |
| 969 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 970 | static void i830_dma_dispatch_swap(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 972 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 973 | drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | int nbox = sarea_priv->nbox; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 975 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | int pitch = dev_priv->pitch; |
| 977 | int cpp = dev_priv->cpp; |
| 978 | int i; |
| 979 | unsigned int CMD, BR13; |
| 980 | RING_LOCALS; |
| 981 | |
| 982 | DRM_DEBUG("swapbuffers\n"); |
| 983 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 984 | i830_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | |
| 986 | if (dev_priv->do_boxes) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 987 | i830_cp_performance_boxes(dev); |
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 | switch (cpp) { |
| 990 | case 2: |
| 991 | BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | CMD = XY_SRC_COPY_BLT_CMD; |
| 993 | break; |
| 994 | case 4: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 995 | BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24) | (1 << 25); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | |
| 997 | XY_SRC_COPY_BLT_WRITE_RGB); |
| 998 | break; |
| 999 | default: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1000 | BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | CMD = XY_SRC_COPY_BLT_CMD; |
| 1002 | break; |
| 1003 | } |
| 1004 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1005 | if (nbox > I830_NR_SAREA_CLIPRECTS) |
| 1006 | nbox = I830_NR_SAREA_CLIPRECTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1008 | for (i = 0; i < nbox; i++, pbox++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | if (pbox->x1 > pbox->x2 || |
| 1010 | pbox->y1 > pbox->y2 || |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1011 | pbox->x2 > dev_priv->w || pbox->y2 > dev_priv->h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | continue; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1013 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n", |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1015 | pbox->x1, pbox->y1, pbox->x2, pbox->y2); |
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 | BEGIN_LP_RING(8); |
| 1018 | OUT_RING(CMD); |
| 1019 | OUT_RING(BR13); |
| 1020 | OUT_RING((pbox->y1 << 16) | pbox->x1); |
| 1021 | OUT_RING((pbox->y2 << 16) | pbox->x2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1023 | if (dev_priv->current_page == 0) |
| 1024 | OUT_RING(dev_priv->front_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1026 | OUT_RING(dev_priv->back_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1028 | OUT_RING((pbox->y1 << 16) | pbox->x1); |
| 1029 | OUT_RING(BR13 & 0xffff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1031 | if (dev_priv->current_page == 0) |
| 1032 | OUT_RING(dev_priv->back_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | else |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1034 | OUT_RING(dev_priv->front_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | |
| 1036 | ADVANCE_LP_RING(); |
| 1037 | } |
| 1038 | } |
| 1039 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1040 | static void i830_dma_dispatch_flip(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1042 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | RING_LOCALS; |
| 1044 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1045 | DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1046 | __func__, |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1047 | dev_priv->current_page, |
| 1048 | dev_priv->sarea_priv->pf_current_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1050 | i830_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | |
| 1052 | if (dev_priv->do_boxes) { |
| 1053 | dev_priv->sarea_priv->perf_boxes |= I830_BOX_FLIP; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1054 | i830_cp_performance_boxes(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1057 | BEGIN_LP_RING(2); |
| 1058 | OUT_RING(INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); |
| 1059 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | ADVANCE_LP_RING(); |
| 1061 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1062 | BEGIN_LP_RING(6); |
| 1063 | OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | ASYNC_FLIP); |
| 1064 | OUT_RING(0); |
| 1065 | if (dev_priv->current_page == 0) { |
| 1066 | OUT_RING(dev_priv->back_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | dev_priv->current_page = 1; |
| 1068 | } else { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1069 | OUT_RING(dev_priv->front_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | dev_priv->current_page = 0; |
| 1071 | } |
| 1072 | OUT_RING(0); |
| 1073 | ADVANCE_LP_RING(); |
| 1074 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1075 | BEGIN_LP_RING(2); |
| 1076 | OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP); |
| 1077 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | |
| 1080 | dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; |
| 1081 | } |
| 1082 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1083 | static void i830_dma_dispatch_vertex(struct drm_device * dev, |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 1084 | struct drm_buf * buf, int discard, int used) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1086 | drm_i830_private_t *dev_priv = dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1088 | drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv; |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1089 | struct drm_clip_rect *box = sarea_priv->boxes; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1090 | int nbox = sarea_priv->nbox; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | unsigned long address = (unsigned long)buf->bus_address; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1092 | unsigned long start = address - dev->agp->base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | int i = 0, u; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1094 | RING_LOCALS; |
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 | i830_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1098 | if (nbox > I830_NR_SAREA_CLIPRECTS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | nbox = I830_NR_SAREA_CLIPRECTS; |
| 1100 | |
| 1101 | if (discard) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1102 | u = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | I830_BUF_HARDWARE); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1104 | if (u != I830_BUF_CLIENT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | DRM_DEBUG("xxxx 2\n"); |
| 1106 | } |
| 1107 | } |
| 1108 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1109 | if (used > 4 * 1023) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | used = 0; |
| 1111 | |
| 1112 | if (sarea_priv->dirty) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1113 | i830EmitState(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1115 | DRM_DEBUG("dispatch vertex addr 0x%lx, used 0x%x nbox %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | address, used, nbox); |
| 1117 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1118 | dev_priv->counter++; |
| 1119 | DRM_DEBUG("dispatch counter : %ld\n", dev_priv->counter); |
| 1120 | DRM_DEBUG("i830_dma_dispatch\n"); |
| 1121 | DRM_DEBUG("start : %lx\n", start); |
| 1122 | DRM_DEBUG("used : %d\n", used); |
| 1123 | DRM_DEBUG("start + used - 4 : %ld\n", start + used - 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | |
| 1125 | if (buf_priv->currently_mapped == I830_BUF_MAPPED) { |
| 1126 | u32 *vp = buf_priv->kernel_virtual; |
| 1127 | |
| 1128 | vp[0] = (GFX_OP_PRIMITIVE | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1129 | sarea_priv->vertex_prim | ((used / 4) - 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | |
| 1131 | if (dev_priv->use_mi_batchbuffer_start) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1132 | vp[used / 4] = MI_BATCH_BUFFER_END; |
| 1133 | used += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | if (used & 4) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1137 | vp[used / 4] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | used += 4; |
| 1139 | } |
| 1140 | |
| 1141 | i830_unmap_buffer(buf); |
| 1142 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | if (used) { |
| 1145 | do { |
| 1146 | if (i < nbox) { |
| 1147 | BEGIN_LP_RING(6); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1148 | OUT_RING(GFX_OP_DRAWRECT_INFO); |
| 1149 | OUT_RING(sarea_priv-> |
| 1150 | BufferState[I830_DESTREG_DR1]); |
| 1151 | OUT_RING(box[i].x1 | (box[i].y1 << 16)); |
| 1152 | OUT_RING(box[i].x2 | (box[i].y2 << 16)); |
| 1153 | OUT_RING(sarea_priv-> |
| 1154 | BufferState[I830_DESTREG_DR4]); |
| 1155 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | ADVANCE_LP_RING(); |
| 1157 | } |
| 1158 | |
| 1159 | if (dev_priv->use_mi_batchbuffer_start) { |
| 1160 | BEGIN_LP_RING(2); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1161 | OUT_RING(MI_BATCH_BUFFER_START | (2 << 6)); |
| 1162 | OUT_RING(start | MI_BATCH_NON_SECURE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | ADVANCE_LP_RING(); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1164 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | BEGIN_LP_RING(4); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1166 | OUT_RING(MI_BATCH_BUFFER); |
| 1167 | OUT_RING(start | MI_BATCH_NON_SECURE); |
| 1168 | OUT_RING(start + used - 4); |
| 1169 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | ADVANCE_LP_RING(); |
| 1171 | } |
| 1172 | |
| 1173 | } while (++i < nbox); |
| 1174 | } |
| 1175 | |
| 1176 | if (discard) { |
| 1177 | dev_priv->counter++; |
| 1178 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1179 | (void)cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, |
| 1180 | I830_BUF_HARDWARE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | |
| 1182 | BEGIN_LP_RING(8); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1183 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 1184 | OUT_RING(20); |
| 1185 | OUT_RING(dev_priv->counter); |
| 1186 | OUT_RING(CMD_STORE_DWORD_IDX); |
| 1187 | OUT_RING(buf_priv->my_use_idx); |
| 1188 | OUT_RING(I830_BUF_FREE); |
| 1189 | OUT_RING(CMD_REPORT_HEAD); |
| 1190 | OUT_RING(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | ADVANCE_LP_RING(); |
| 1192 | } |
| 1193 | } |
| 1194 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1195 | static void i830_dma_quiescent(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1197 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 1198 | RING_LOCALS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1200 | i830_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1202 | BEGIN_LP_RING(4); |
| 1203 | OUT_RING(INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE); |
| 1204 | OUT_RING(CMD_REPORT_HEAD); |
| 1205 | OUT_RING(0); |
| 1206 | OUT_RING(0); |
| 1207 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1209 | i830_wait_ring(dev, dev_priv->ring.Size - 8, __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | } |
| 1211 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1212 | static int i830_flush_queue(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1214 | drm_i830_private_t *dev_priv = dev->dev_private; |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 1215 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1216 | int i, ret = 0; |
| 1217 | RING_LOCALS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1219 | i830_kernel_lost_context(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1221 | BEGIN_LP_RING(2); |
| 1222 | OUT_RING(CMD_REPORT_HEAD); |
| 1223 | OUT_RING(0); |
| 1224 | ADVANCE_LP_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1226 | i830_wait_ring(dev, dev_priv->ring.Size - 8, __func__); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1227 | |
| 1228 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 1229 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1230 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
| 1231 | |
| 1232 | int used = cmpxchg(buf_priv->in_use, I830_BUF_HARDWARE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | I830_BUF_FREE); |
| 1234 | |
| 1235 | if (used == I830_BUF_HARDWARE) |
| 1236 | DRM_DEBUG("reclaimed from HARDWARE\n"); |
| 1237 | if (used == I830_BUF_CLIENT) |
| 1238 | DRM_DEBUG("still on client\n"); |
| 1239 | } |
| 1240 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1241 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | /* Must be called with the lock held */ |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1245 | static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 1247 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1248 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1250 | if (!dma) |
| 1251 | return; |
| 1252 | if (!dev->dev_private) |
| 1253 | return; |
| 1254 | if (!dma->buflist) |
| 1255 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1257 | i830_flush_queue(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | |
| 1259 | for (i = 0; i < dma->buf_count; i++) { |
Dave Airlie | 056219e | 2007-07-11 16:17:42 +1000 | [diff] [blame] | 1260 | struct drm_buf *buf = dma->buflist[i]; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1261 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
| 1262 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1263 | if (buf->file_priv == file_priv && buf_priv) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1264 | int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | I830_BUF_FREE); |
| 1266 | |
| 1267 | if (used == I830_BUF_CLIENT) |
| 1268 | DRM_DEBUG("reclaimed from client\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1269 | if (buf_priv->currently_mapped == I830_BUF_MAPPED) |
| 1270 | buf_priv->currently_mapped = I830_BUF_UNMAPPED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | } |
| 1272 | } |
| 1273 | } |
| 1274 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1275 | static int i830_flush_ioctl(struct drm_device *dev, void *data, |
| 1276 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | { |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1278 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1280 | i830_flush_queue(dev); |
| 1281 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | } |
| 1283 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1284 | static int i830_dma_vertex(struct drm_device *dev, void *data, |
| 1285 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | { |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 1287 | struct drm_device_dma *dma = dev->dma; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1288 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
| 1289 | u32 *hw_status = dev_priv->hw_status_page; |
| 1290 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
| 1291 | dev_priv->sarea_priv; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1292 | drm_i830_vertex_t *vertex = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1294 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | |
| 1296 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1297 | vertex->idx, vertex->used, vertex->discard); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1299 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1300 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1302 | i830_dma_dispatch_vertex(dev, |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1303 | dma->buflist[vertex->idx], |
| 1304 | vertex->discard, vertex->used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1306 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
| 1307 | sarea_priv->last_dispatch = (int)hw_status[5]; |
| 1308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | return 0; |
| 1310 | } |
| 1311 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1312 | static int i830_clear_bufs(struct drm_device *dev, void *data, |
| 1313 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | { |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1315 | drm_i830_clear_t *clear = data; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1316 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1317 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | |
| 1319 | /* GH: Someone's doing nasty things... */ |
| 1320 | if (!dev->dev_private) { |
| 1321 | return -EINVAL; |
| 1322 | } |
| 1323 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1324 | i830_dma_dispatch_clear(dev, clear->flags, |
| 1325 | clear->clear_color, |
| 1326 | clear->clear_depth, clear->clear_depthmask); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1327 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | } |
| 1329 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1330 | static int i830_swap_bufs(struct drm_device *dev, void *data, |
| 1331 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | DRM_DEBUG("i830_swap_bufs\n"); |
| 1334 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1335 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1337 | i830_dma_dispatch_swap(dev); |
| 1338 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | } |
| 1340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | /* Not sure why this isn't set all the time: |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1342 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1343 | static void i830_do_init_pageflip(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | { |
| 1345 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 1346 | |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1347 | DRM_DEBUG("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | dev_priv->page_flipping = 1; |
| 1349 | dev_priv->current_page = 0; |
| 1350 | dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; |
| 1351 | } |
| 1352 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1353 | static int i830_do_cleanup_pageflip(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | { |
| 1355 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 1356 | |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1357 | DRM_DEBUG("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | if (dev_priv->current_page != 0) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1359 | i830_dma_dispatch_flip(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | |
| 1361 | dev_priv->page_flipping = 0; |
| 1362 | return 0; |
| 1363 | } |
| 1364 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1365 | static int i830_flip_bufs(struct drm_device *dev, void *data, |
| 1366 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 1369 | |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1370 | DRM_DEBUG("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1371 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1372 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1374 | if (!dev_priv->page_flipping) |
| 1375 | i830_do_init_pageflip(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1377 | i830_dma_dispatch_flip(dev); |
| 1378 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | } |
| 1380 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1381 | static int i830_getage(struct drm_device *dev, void *data, |
| 1382 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1384 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
| 1385 | u32 *hw_status = dev_priv->hw_status_page; |
| 1386 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
| 1387 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1389 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | return 0; |
| 1391 | } |
| 1392 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1393 | static int i830_getbuf(struct drm_device *dev, void *data, |
| 1394 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1396 | int retcode = 0; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1397 | drm_i830_dma_t *d = data; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1398 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
| 1399 | u32 *hw_status = dev_priv->hw_status_page; |
| 1400 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
| 1401 | dev_priv->sarea_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | |
| 1403 | DRM_DEBUG("getbuf\n"); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1404 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1405 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1406 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1407 | d->granted = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1409 | retcode = i830_dma_get_buffer(dev, d, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | |
| 1411 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", |
Pavel Emelyanov | ba25f9d | 2007-10-18 23:40:40 -0700 | [diff] [blame] | 1412 | task_pid_nr(current), retcode, d->granted); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1414 | sarea_priv->last_dispatch = (int)hw_status[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1415 | |
| 1416 | return retcode; |
| 1417 | } |
| 1418 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1419 | static int i830_copybuf(struct drm_device *dev, void *data, |
| 1420 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1421 | { |
| 1422 | /* Never copy - 2.4.x doesn't need it */ |
| 1423 | return 0; |
| 1424 | } |
| 1425 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1426 | static int i830_docopy(struct drm_device *dev, void *data, |
| 1427 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | { |
| 1429 | return 0; |
| 1430 | } |
| 1431 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1432 | static int i830_getparam(struct drm_device *dev, void *data, |
| 1433 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | drm_i830_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1436 | drm_i830_getparam_t *param = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | int value; |
| 1438 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1439 | if (!dev_priv) { |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1440 | DRM_ERROR("%s called with no initialization\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | return -EINVAL; |
| 1442 | } |
| 1443 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1444 | switch (param->param) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | case I830_PARAM_IRQ_ACTIVE: |
| 1446 | value = dev->irq_enabled; |
| 1447 | break; |
| 1448 | default: |
| 1449 | return -EINVAL; |
| 1450 | } |
| 1451 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1452 | if (copy_to_user(param->value, &value, sizeof(int))) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1453 | DRM_ERROR("copy_to_user\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | return -EFAULT; |
| 1455 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | return 0; |
| 1458 | } |
| 1459 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1460 | static int i830_setparam(struct drm_device *dev, void *data, |
| 1461 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | drm_i830_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1464 | drm_i830_setparam_t *param = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1466 | if (!dev_priv) { |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame^] | 1467 | DRM_ERROR("%s called with no initialization\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | return -EINVAL; |
| 1469 | } |
| 1470 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1471 | switch (param->param) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1473 | dev_priv->use_mi_batchbuffer_start = param->value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | break; |
| 1475 | default: |
| 1476 | return -EINVAL; |
| 1477 | } |
| 1478 | |
| 1479 | return 0; |
| 1480 | } |
| 1481 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1482 | int i830_driver_load(struct drm_device *dev, unsigned long flags) |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 1483 | { |
| 1484 | /* i830 has 4 more counters */ |
| 1485 | dev->counters += 4; |
| 1486 | dev->types[6] = _DRM_STAT_IRQ; |
| 1487 | dev->types[7] = _DRM_STAT_PRIMARY; |
| 1488 | dev->types[8] = _DRM_STAT_SECONDARY; |
| 1489 | dev->types[9] = _DRM_STAT_DMA; |
| 1490 | |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1494 | void i830_driver_lastclose(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1496 | i830_dma_cleanup(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | } |
| 1498 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1499 | void i830_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | { |
| 1501 | if (dev->dev_private) { |
| 1502 | drm_i830_private_t *dev_priv = dev->dev_private; |
| 1503 | if (dev_priv->page_flipping) { |
| 1504 | i830_do_cleanup_pageflip(dev); |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1509 | void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | { |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 1511 | i830_reclaim_buffers(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | } |
| 1513 | |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1514 | int i830_driver_dma_quiescent(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 1516 | i830_dma_quiescent(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | return 0; |
| 1518 | } |
| 1519 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 1520 | struct drm_ioctl_desc i830_ioctls[] = { |
| 1521 | DRM_IOCTL_DEF(DRM_I830_INIT, i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1522 | DRM_IOCTL_DEF(DRM_I830_VERTEX, i830_dma_vertex, DRM_AUTH), |
| 1523 | DRM_IOCTL_DEF(DRM_I830_CLEAR, i830_clear_bufs, DRM_AUTH), |
| 1524 | DRM_IOCTL_DEF(DRM_I830_FLUSH, i830_flush_ioctl, DRM_AUTH), |
| 1525 | DRM_IOCTL_DEF(DRM_I830_GETAGE, i830_getage, DRM_AUTH), |
| 1526 | DRM_IOCTL_DEF(DRM_I830_GETBUF, i830_getbuf, DRM_AUTH), |
| 1527 | DRM_IOCTL_DEF(DRM_I830_SWAP, i830_swap_bufs, DRM_AUTH), |
| 1528 | DRM_IOCTL_DEF(DRM_I830_COPY, i830_copybuf, DRM_AUTH), |
| 1529 | DRM_IOCTL_DEF(DRM_I830_DOCOPY, i830_docopy, DRM_AUTH), |
| 1530 | DRM_IOCTL_DEF(DRM_I830_FLIP, i830_flip_bufs, DRM_AUTH), |
| 1531 | DRM_IOCTL_DEF(DRM_I830_IRQ_EMIT, i830_irq_emit, DRM_AUTH), |
| 1532 | DRM_IOCTL_DEF(DRM_I830_IRQ_WAIT, i830_irq_wait, DRM_AUTH), |
| 1533 | DRM_IOCTL_DEF(DRM_I830_GETPARAM, i830_getparam, DRM_AUTH), |
| 1534 | DRM_IOCTL_DEF(DRM_I830_SETPARAM, i830_setparam, DRM_AUTH) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | }; |
| 1536 | |
| 1537 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); |
Dave Airlie | cda1738 | 2005-07-10 17:31:26 +1000 | [diff] [blame] | 1538 | |
| 1539 | /** |
| 1540 | * Determine if the device really is AGP or not. |
| 1541 | * |
| 1542 | * All Intel graphics chipsets are treated as AGP, even if they are really |
| 1543 | * PCI-e. |
| 1544 | * |
| 1545 | * \param dev The device to be tested. |
| 1546 | * |
| 1547 | * \returns |
| 1548 | * A value of 1 is always retured to indictate every i8xx is AGP. |
| 1549 | */ |
Dave Airlie | eddca55 | 2007-07-11 16:09:54 +1000 | [diff] [blame] | 1550 | int i830_driver_device_is_agp(struct drm_device * dev) |
Dave Airlie | cda1738 | 2005-07-10 17:31:26 +1000 | [diff] [blame] | 1551 | { |
| 1552 | return 1; |
| 1553 | } |