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