blob: cc0ffa9abd00da2ff0504679bad6f32b04f0d561 [file] [log] [blame]
Dave Airlie22f579c2005-06-28 22:48:56 +10001/* via_dma.c -- DMA support for the VIA Unichrome/Pro
Dave Airlieb5e89ed2005-09-25 14:28:13 +10002 *
Dave Airlie22f579c2005-06-28 22:48:56 +10003 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Copyright 2004 Digeo, Inc., Palo Alto, CA, U.S.A.
7 * All Rights Reserved.
Dave Airlieb5e89ed2005-09-25 14:28:13 +10008 *
Dave Airlie22f579c2005-06-28 22:48:56 +10009 * Copyright 2004 The Unichrome project.
10 * All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sub license,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice (including the
20 * next paragraph) shall be included in all copies or substantial portions
21 * of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
Dave Airlieb5e89ed2005-09-25 14:28:13 +100026 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
27 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
28 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
Dave Airlie22f579c2005-06-28 22:48:56 +100029 * USE OR OTHER DEALINGS IN THE SOFTWARE.
30 *
Dave Airlieb5e89ed2005-09-25 14:28:13 +100031 * Authors:
32 * Tungsten Graphics,
33 * Erdi Chen,
Dave Airlie22f579c2005-06-28 22:48:56 +100034 * Thomas Hellstrom.
35 */
36
37#include "drmP.h"
38#include "drm.h"
39#include "via_drm.h"
40#include "via_drv.h"
41#include "via_3d_reg.h"
42
43#define CMDBUF_ALIGNMENT_SIZE (0x100)
44#define CMDBUF_ALIGNMENT_MASK (0x0ff)
45
46/* defines for VIA 3D registers */
47#define VIA_REG_STATUS 0x400
48#define VIA_REG_TRANSET 0x43C
49#define VIA_REG_TRANSPACE 0x440
50
51/* VIA_REG_STATUS(0x400): Engine Status */
52#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
53#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
54#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
55#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
56
57#define SetReg2DAGP(nReg, nData) { \
58 *((uint32_t *)(vb)) = ((nReg) >> 2) | HALCYON_HEADER1; \
59 *((uint32_t *)(vb) + 1) = (nData); \
60 vb = ((uint32_t *)vb) + 2; \
Nicolas Kaiser58c1e852010-07-11 15:32:42 +020061 dev_priv->dma_low += 8; \
Dave Airlie22f579c2005-06-28 22:48:56 +100062}
63
Dave Airlieb5e89ed2005-09-25 14:28:13 +100064#define via_flush_write_combine() DRM_MEMORYBARRIER()
Dave Airlie22f579c2005-06-28 22:48:56 +100065
Nicolas Kaiser58c1e852010-07-11 15:32:42 +020066#define VIA_OUT_RING_QW(w1, w2) do { \
Dave Airlie22f579c2005-06-28 22:48:56 +100067 *vb++ = (w1); \
68 *vb++ = (w2); \
Nicolas Kaiser58c1e852010-07-11 15:32:42 +020069 dev_priv->dma_low += 8; \
70} while (0)
Dave Airlie22f579c2005-06-28 22:48:56 +100071
Nicolas Kaiser58c1e852010-07-11 15:32:42 +020072static void via_cmdbuf_start(drm_via_private_t *dev_priv);
73static void via_cmdbuf_pause(drm_via_private_t *dev_priv);
74static void via_cmdbuf_reset(drm_via_private_t *dev_priv);
75static void via_cmdbuf_rewind(drm_via_private_t *dev_priv);
76static int via_wait_idle(drm_via_private_t *dev_priv);
77static void via_pad_cache(drm_via_private_t *dev_priv, int qwords);
Dave Airlie22f579c2005-06-28 22:48:56 +100078
79/*
80 * Free space in command buffer.
81 */
82
Nicolas Kaiser58c1e852010-07-11 15:32:42 +020083static uint32_t via_cmdbuf_space(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +100084{
Dave Airlieb5e89ed2005-09-25 14:28:13 +100085 uint32_t agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
Dave Airlie22f579c2005-06-28 22:48:56 +100086 uint32_t hw_addr = *(dev_priv->hw_addr_ptr) - agp_base;
Dave Airlieb5e89ed2005-09-25 14:28:13 +100087
88 return ((hw_addr <= dev_priv->dma_low) ?
89 (dev_priv->dma_high + hw_addr - dev_priv->dma_low) :
Dave Airlie22f579c2005-06-28 22:48:56 +100090 (hw_addr - dev_priv->dma_low));
91}
92
93/*
94 * How much does the command regulator lag behind?
95 */
96
Nicolas Kaiser58c1e852010-07-11 15:32:42 +020097static uint32_t via_cmdbuf_lag(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +100098{
Dave Airlieb5e89ed2005-09-25 14:28:13 +100099 uint32_t agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
Dave Airlie22f579c2005-06-28 22:48:56 +1000100 uint32_t hw_addr = *(dev_priv->hw_addr_ptr) - agp_base;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000101
102 return ((hw_addr <= dev_priv->dma_low) ?
103 (dev_priv->dma_low - hw_addr) :
Dave Airlie22f579c2005-06-28 22:48:56 +1000104 (dev_priv->dma_wrap + dev_priv->dma_low - hw_addr));
105}
106
107/*
108 * Check that the given size fits in the buffer, otherwise wait.
109 */
110
111static inline int
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200112via_cmdbuf_wait(drm_via_private_t *dev_priv, unsigned int size)
Dave Airlie22f579c2005-06-28 22:48:56 +1000113{
114 uint32_t agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
115 uint32_t cur_addr, hw_addr, next_addr;
116 volatile uint32_t *hw_addr_ptr;
117 uint32_t count;
118 hw_addr_ptr = dev_priv->hw_addr_ptr;
119 cur_addr = dev_priv->dma_low;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000120 next_addr = cur_addr + size + 512 * 1024;
Dave Airlie22f579c2005-06-28 22:48:56 +1000121 count = 1000000;
122 do {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000123 hw_addr = *hw_addr_ptr - agp_base;
Dave Airlie22f579c2005-06-28 22:48:56 +1000124 if (count-- == 0) {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000125 DRM_ERROR
126 ("via_cmdbuf_wait timed out hw %x cur_addr %x next_addr %x\n",
127 hw_addr, cur_addr, next_addr);
Dave Airlie22f579c2005-06-28 22:48:56 +1000128 return -1;
129 }
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000130 if ((cur_addr < hw_addr) && (next_addr >= hw_addr))
131 msleep(1);
Dave Airlie22f579c2005-06-28 22:48:56 +1000132 } while ((cur_addr < hw_addr) && (next_addr >= hw_addr));
133 return 0;
134}
135
Dave Airlie22f579c2005-06-28 22:48:56 +1000136/*
137 * Checks whether buffer head has reach the end. Rewind the ring buffer
138 * when necessary.
139 *
140 * Returns virtual pointer to ring buffer.
141 */
142
143static inline uint32_t *via_check_dma(drm_via_private_t * dev_priv,
144 unsigned int size)
145{
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000146 if ((dev_priv->dma_low + size + 4 * CMDBUF_ALIGNMENT_SIZE) >
147 dev_priv->dma_high) {
Dave Airlie22f579c2005-06-28 22:48:56 +1000148 via_cmdbuf_rewind(dev_priv);
149 }
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200150 if (via_cmdbuf_wait(dev_priv, size) != 0)
Dave Airlie22f579c2005-06-28 22:48:56 +1000151 return NULL;
Dave Airlie22f579c2005-06-28 22:48:56 +1000152
153 return (uint32_t *) (dev_priv->dma_ptr + dev_priv->dma_low);
154}
155
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200156int via_dma_cleanup(struct drm_device *dev)
Dave Airlie22f579c2005-06-28 22:48:56 +1000157{
158 if (dev->dev_private) {
159 drm_via_private_t *dev_priv =
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000160 (drm_via_private_t *) dev->dev_private;
Dave Airlie22f579c2005-06-28 22:48:56 +1000161
162 if (dev_priv->ring.virtual_start) {
163 via_cmdbuf_reset(dev_priv);
164
165 drm_core_ioremapfree(&dev_priv->ring.map, dev);
166 dev_priv->ring.virtual_start = NULL;
167 }
168
169 }
170
171 return 0;
172}
173
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200174static int via_initialize(struct drm_device *dev,
175 drm_via_private_t *dev_priv,
176 drm_via_dma_init_t *init)
Dave Airlie22f579c2005-06-28 22:48:56 +1000177{
178 if (!dev_priv || !dev_priv->mmio) {
179 DRM_ERROR("via_dma_init called before via_map_init\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000180 return -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000181 }
182
183 if (dev_priv->ring.virtual_start != NULL) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000184 DRM_ERROR("called again without calling cleanup\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000185 return -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000186 }
187
188 if (!dev->agp || !dev->agp->base) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000189 DRM_ERROR("called with no agp memory available\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000190 return -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000191 }
192
Thomas Hellstrom756db732007-02-08 12:57:40 +1100193 if (dev_priv->chipset == VIA_DX9_0) {
194 DRM_ERROR("AGP DMA is not supported on this chip\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000195 return -EINVAL;
Thomas Hellstrom756db732007-02-08 12:57:40 +1100196 }
197
Dave Airlie22f579c2005-06-28 22:48:56 +1000198 dev_priv->ring.map.offset = dev->agp->base + init->offset;
199 dev_priv->ring.map.size = init->size;
200 dev_priv->ring.map.type = 0;
201 dev_priv->ring.map.flags = 0;
202 dev_priv->ring.map.mtrr = 0;
203
204 drm_core_ioremap(&dev_priv->ring.map, dev);
205
206 if (dev_priv->ring.map.handle == NULL) {
207 via_dma_cleanup(dev);
208 DRM_ERROR("can not ioremap virtual address for"
209 " ring buffer\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000210 return -ENOMEM;
Dave Airlie22f579c2005-06-28 22:48:56 +1000211 }
212
213 dev_priv->ring.virtual_start = dev_priv->ring.map.handle;
214
215 dev_priv->dma_ptr = dev_priv->ring.virtual_start;
216 dev_priv->dma_low = 0;
217 dev_priv->dma_high = init->size;
218 dev_priv->dma_wrap = init->size;
219 dev_priv->dma_offset = init->offset;
220 dev_priv->last_pause_ptr = NULL;
Dave Airlie92514242005-11-12 21:52:46 +1100221 dev_priv->hw_addr_ptr =
222 (volatile uint32_t *)((char *)dev_priv->mmio->handle +
223 init->reg_pause_addr);
Dave Airlie22f579c2005-06-28 22:48:56 +1000224
225 via_cmdbuf_start(dev_priv);
226
227 return 0;
228}
229
Eric Anholtc153f452007-09-03 12:06:45 +1000230static int via_dma_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000231{
Dave Airlie22f579c2005-06-28 22:48:56 +1000232 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000233 drm_via_dma_init_t *init = data;
Dave Airlie22f579c2005-06-28 22:48:56 +1000234 int retcode = 0;
235
Eric Anholtc153f452007-09-03 12:06:45 +1000236 switch (init->func) {
Dave Airlie22f579c2005-06-28 22:48:56 +1000237 case VIA_INIT_DMA:
Dave Airlie92514242005-11-12 21:52:46 +1100238 if (!DRM_SUSER(DRM_CURPROC))
Eric Anholt20caafa2007-08-25 19:22:43 +1000239 retcode = -EPERM;
Dave Airlie22f579c2005-06-28 22:48:56 +1000240 else
Eric Anholtc153f452007-09-03 12:06:45 +1000241 retcode = via_initialize(dev, dev_priv, init);
Dave Airlie22f579c2005-06-28 22:48:56 +1000242 break;
243 case VIA_CLEANUP_DMA:
Dave Airlie92514242005-11-12 21:52:46 +1100244 if (!DRM_SUSER(DRM_CURPROC))
Eric Anholt20caafa2007-08-25 19:22:43 +1000245 retcode = -EPERM;
Dave Airlie22f579c2005-06-28 22:48:56 +1000246 else
247 retcode = via_dma_cleanup(dev);
248 break;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000249 case VIA_DMA_INITIALIZED:
250 retcode = (dev_priv->ring.virtual_start != NULL) ?
Eric Anholt20caafa2007-08-25 19:22:43 +1000251 0 : -EFAULT;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000252 break;
Dave Airlie22f579c2005-06-28 22:48:56 +1000253 default:
Eric Anholt20caafa2007-08-25 19:22:43 +1000254 retcode = -EINVAL;
Dave Airlie22f579c2005-06-28 22:48:56 +1000255 break;
256 }
257
258 return retcode;
259}
260
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200261static int via_dispatch_cmdbuffer(struct drm_device *dev, drm_via_cmdbuffer_t *cmd)
Dave Airlie22f579c2005-06-28 22:48:56 +1000262{
263 drm_via_private_t *dev_priv;
264 uint32_t *vb;
265 int ret;
266
267 dev_priv = (drm_via_private_t *) dev->dev_private;
268
269 if (dev_priv->ring.virtual_start == NULL) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000270 DRM_ERROR("called without initializing AGP ring buffer.\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000271 return -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000272 }
273
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200274 if (cmd->size > VIA_PCI_BUF_SIZE)
Eric Anholt20caafa2007-08-25 19:22:43 +1000275 return -ENOMEM;
Dave Airlie22f579c2005-06-28 22:48:56 +1000276
277 if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size))
Eric Anholt20caafa2007-08-25 19:22:43 +1000278 return -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000279
280 /*
281 * Running this function on AGP memory is dead slow. Therefore
282 * we run it on a temporary cacheable system memory buffer and
283 * copy it to AGP memory when ready.
284 */
285
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000286 if ((ret =
287 via_verify_command_stream((uint32_t *) dev_priv->pci_buf,
288 cmd->size, dev, 1))) {
Dave Airlie22f579c2005-06-28 22:48:56 +1000289 return ret;
290 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000291
Dave Airlie22f579c2005-06-28 22:48:56 +1000292 vb = via_check_dma(dev_priv, (cmd->size < 0x100) ? 0x102 : cmd->size);
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200293 if (vb == NULL)
Eric Anholt20caafa2007-08-25 19:22:43 +1000294 return -EAGAIN;
Dave Airlie22f579c2005-06-28 22:48:56 +1000295
296 memcpy(vb, dev_priv->pci_buf, cmd->size);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000297
Dave Airlie22f579c2005-06-28 22:48:56 +1000298 dev_priv->dma_low += cmd->size;
299
300 /*
301 * Small submissions somehow stalls the CPU. (AGP cache effects?)
302 * pad to greater size.
303 */
304
305 if (cmd->size < 0x100)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000306 via_pad_cache(dev_priv, (0x100 - cmd->size) >> 3);
Dave Airlie22f579c2005-06-28 22:48:56 +1000307 via_cmdbuf_pause(dev_priv);
308
309 return 0;
310}
311
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200312int via_driver_dma_quiescent(struct drm_device *dev)
Dave Airlie22f579c2005-06-28 22:48:56 +1000313{
314 drm_via_private_t *dev_priv = dev->dev_private;
315
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200316 if (!via_wait_idle(dev_priv))
Eric Anholt20caafa2007-08-25 19:22:43 +1000317 return -EBUSY;
Dave Airlie22f579c2005-06-28 22:48:56 +1000318 return 0;
319}
320
Eric Anholtc153f452007-09-03 12:06:45 +1000321static int via_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000322{
Dave Airlie22f579c2005-06-28 22:48:56 +1000323
Eric Anholt6c340ea2007-08-25 20:23:09 +1000324 LOCK_TEST_WITH_RETURN(dev, file_priv);
Dave Airlie22f579c2005-06-28 22:48:56 +1000325
326 return via_driver_dma_quiescent(dev);
327}
328
Eric Anholtc153f452007-09-03 12:06:45 +1000329static int via_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000330{
Eric Anholtc153f452007-09-03 12:06:45 +1000331 drm_via_cmdbuffer_t *cmdbuf = data;
Dave Airlie22f579c2005-06-28 22:48:56 +1000332 int ret;
333
Eric Anholt6c340ea2007-08-25 20:23:09 +1000334 LOCK_TEST_WITH_RETURN(dev, file_priv);
Dave Airlie22f579c2005-06-28 22:48:56 +1000335
Márton Németh3e684ea2008-01-24 15:58:57 +1000336 DRM_DEBUG("buf %p size %lu\n", cmdbuf->buf, cmdbuf->size);
Dave Airlie22f579c2005-06-28 22:48:56 +1000337
Eric Anholtc153f452007-09-03 12:06:45 +1000338 ret = via_dispatch_cmdbuffer(dev, cmdbuf);
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200339 return ret;
Dave Airlie22f579c2005-06-28 22:48:56 +1000340}
341
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200342static int via_dispatch_pci_cmdbuffer(struct drm_device *dev,
343 drm_via_cmdbuffer_t *cmd)
Dave Airlie22f579c2005-06-28 22:48:56 +1000344{
345 drm_via_private_t *dev_priv = dev->dev_private;
346 int ret;
347
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200348 if (cmd->size > VIA_PCI_BUF_SIZE)
Eric Anholt20caafa2007-08-25 19:22:43 +1000349 return -ENOMEM;
Dave Airlie22f579c2005-06-28 22:48:56 +1000350 if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size))
Eric Anholt20caafa2007-08-25 19:22:43 +1000351 return -EFAULT;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000352
353 if ((ret =
354 via_verify_command_stream((uint32_t *) dev_priv->pci_buf,
355 cmd->size, dev, 0))) {
Dave Airlie22f579c2005-06-28 22:48:56 +1000356 return ret;
357 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000358
359 ret =
360 via_parse_command_stream(dev, (const uint32_t *)dev_priv->pci_buf,
361 cmd->size);
Dave Airlie22f579c2005-06-28 22:48:56 +1000362 return ret;
363}
364
Eric Anholtc153f452007-09-03 12:06:45 +1000365static int via_pci_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000366{
Eric Anholtc153f452007-09-03 12:06:45 +1000367 drm_via_cmdbuffer_t *cmdbuf = data;
Dave Airlie22f579c2005-06-28 22:48:56 +1000368 int ret;
369
Eric Anholt6c340ea2007-08-25 20:23:09 +1000370 LOCK_TEST_WITH_RETURN(dev, file_priv);
Dave Airlie22f579c2005-06-28 22:48:56 +1000371
Márton Németh3e684ea2008-01-24 15:58:57 +1000372 DRM_DEBUG("buf %p size %lu\n", cmdbuf->buf, cmdbuf->size);
Dave Airlie22f579c2005-06-28 22:48:56 +1000373
Eric Anholtc153f452007-09-03 12:06:45 +1000374 ret = via_dispatch_pci_cmdbuffer(dev, cmdbuf);
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200375 return ret;
Dave Airlie22f579c2005-06-28 22:48:56 +1000376}
377
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200378static inline uint32_t *via_align_buffer(drm_via_private_t *dev_priv,
Dave Airlie22f579c2005-06-28 22:48:56 +1000379 uint32_t * vb, int qw_count)
380{
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200381 for (; qw_count > 0; --qw_count)
Dave Airlie22f579c2005-06-28 22:48:56 +1000382 VIA_OUT_RING_QW(HC_DUMMY, HC_DUMMY);
Dave Airlie22f579c2005-06-28 22:48:56 +1000383 return vb;
384}
385
Dave Airlie22f579c2005-06-28 22:48:56 +1000386/*
Joe Perches8dfba4d2008-02-03 17:11:42 +0200387 * This function is used internally by ring buffer management code.
Dave Airlie22f579c2005-06-28 22:48:56 +1000388 *
389 * Returns virtual pointer to ring buffer.
390 */
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200391static inline uint32_t *via_get_dma(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000392{
393 return (uint32_t *) (dev_priv->dma_ptr + dev_priv->dma_low);
394}
395
396/*
397 * Hooks a segment of data into the tail of the ring-buffer by
398 * modifying the pause address stored in the buffer itself. If
399 * the regulator has already paused, restart it.
400 */
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200401static int via_hook_segment(drm_via_private_t *dev_priv,
Dave Airlie22f579c2005-06-28 22:48:56 +1000402 uint32_t pause_addr_hi, uint32_t pause_addr_lo,
403 int no_pci_fire)
404{
405 int paused, count;
406 volatile uint32_t *paused_at = dev_priv->last_pause_ptr;
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200407 uint32_t reader, ptr;
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000408 uint32_t diff;
Dave Airlie22f579c2005-06-28 22:48:56 +1000409
410 paused = 0;
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000411 via_flush_write_combine();
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200412 (void) *(volatile uint32_t *)(via_get_dma(dev_priv) - 1);
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000413
Thomas Hellstromef68d292007-05-08 15:48:39 +1000414 *paused_at = pause_addr_lo;
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000415 via_flush_write_combine();
Thomas Hellstromef68d292007-05-08 15:48:39 +1000416 (void) *paused_at;
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000417
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000418 reader = *(dev_priv->hw_addr_ptr);
419 ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) +
420 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000421
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000422 dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1;
Dave Airlie22f579c2005-06-28 22:48:56 +1000423
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000424 /*
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200425 * If there is a possibility that the command reader will
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000426 * miss the new pause address and pause on the old one,
427 * In that case we need to program the new start address
428 * using PCI.
429 */
430
431 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
432 count = 10000000;
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200433 while (diff == 0 && count--) {
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000434 paused = (VIA_READ(0x41c) & 0x80000000);
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200435 if (paused)
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000436 break;
437 reader = *(dev_priv->hw_addr_ptr);
438 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
Dave Airlie22f579c2005-06-28 22:48:56 +1000439 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000440
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000441 paused = VIA_READ(0x41c) & 0x80000000;
442
Dave Airlie22f579c2005-06-28 22:48:56 +1000443 if (paused && !no_pci_fire) {
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000444 reader = *(dev_priv->hw_addr_ptr);
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000445 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
446 diff &= (dev_priv->dma_high - 1);
447 if (diff != 0 && diff < (dev_priv->dma_high >> 1)) {
448 DRM_ERROR("Paused at incorrect address. "
449 "0x%08x, 0x%08x 0x%08x\n",
450 ptr, reader, dev_priv->dma_diff);
451 } else if (diff == 0) {
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000452 /*
453 * There is a concern that these writes may stall the PCI bus
454 * if the GPU is not idle. However, idling the GPU first
455 * doesn't make a difference.
456 */
Dave Airlie22f579c2005-06-28 22:48:56 +1000457
Dave Airlie22f579c2005-06-28 22:48:56 +1000458 VIA_WRITE(VIA_REG_TRANSET, (HC_ParaType_PreCR << 16));
459 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_hi);
460 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_lo);
Thomas Hellstrom76f62552007-01-08 21:03:23 +1100461 VIA_READ(VIA_REG_TRANSPACE);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000462 }
Dave Airlie22f579c2005-06-28 22:48:56 +1000463 }
464 return paused;
465}
466
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200467static int via_wait_idle(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000468{
469 int count = 10000000;
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000470
Roel Kluind9c6f542009-04-16 22:57:46 +0200471 while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && --count)
472 ;
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000473
Roel Kluind9c6f542009-04-16 22:57:46 +0200474 while (count && (VIA_READ(VIA_REG_STATUS) &
Dave Airlie22f579c2005-06-28 22:48:56 +1000475 (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY |
Roel Kluind9c6f542009-04-16 22:57:46 +0200476 VIA_3D_ENG_BUSY)))
477 --count;
Dave Airlie22f579c2005-06-28 22:48:56 +1000478 return count;
479}
480
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200481static uint32_t *via_align_cmd(drm_via_private_t *dev_priv, uint32_t cmd_type,
482 uint32_t addr, uint32_t *cmd_addr_hi,
483 uint32_t *cmd_addr_lo, int skip_wait)
Dave Airlie22f579c2005-06-28 22:48:56 +1000484{
485 uint32_t agp_base;
486 uint32_t cmd_addr, addr_lo, addr_hi;
487 uint32_t *vb;
488 uint32_t qw_pad_count;
489
490 if (!skip_wait)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000491 via_cmdbuf_wait(dev_priv, 2 * CMDBUF_ALIGNMENT_SIZE);
Dave Airlie22f579c2005-06-28 22:48:56 +1000492
493 vb = via_get_dma(dev_priv);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000494 VIA_OUT_RING_QW(HC_HEADER2 | ((VIA_REG_TRANSET >> 2) << 12) |
495 (VIA_REG_TRANSPACE >> 2), HC_ParaType_PreCR << 16);
Dave Airlie22f579c2005-06-28 22:48:56 +1000496 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
497 qw_pad_count = (CMDBUF_ALIGNMENT_SIZE >> 3) -
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000498 ((dev_priv->dma_low & CMDBUF_ALIGNMENT_MASK) >> 3);
Dave Airlie22f579c2005-06-28 22:48:56 +1000499
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000500 cmd_addr = (addr) ? addr :
501 agp_base + dev_priv->dma_low - 8 + (qw_pad_count << 3);
Dave Airlie22f579c2005-06-28 22:48:56 +1000502 addr_lo = ((HC_SubA_HAGPBpL << 24) | (cmd_type & HC_HAGPBpID_MASK) |
503 (cmd_addr & HC_HAGPBpL_MASK));
504 addr_hi = ((HC_SubA_HAGPBpH << 24) | (cmd_addr >> 24));
505
506 vb = via_align_buffer(dev_priv, vb, qw_pad_count - 1);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000507 VIA_OUT_RING_QW(*cmd_addr_hi = addr_hi, *cmd_addr_lo = addr_lo);
Dave Airlie22f579c2005-06-28 22:48:56 +1000508 return vb;
509}
510
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200511static void via_cmdbuf_start(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000512{
513 uint32_t pause_addr_lo, pause_addr_hi;
514 uint32_t start_addr, start_addr_lo;
515 uint32_t end_addr, end_addr_lo;
516 uint32_t command;
517 uint32_t agp_base;
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000518 uint32_t ptr;
519 uint32_t reader;
520 int count;
Dave Airlie22f579c2005-06-28 22:48:56 +1000521
Dave Airlie22f579c2005-06-28 22:48:56 +1000522 dev_priv->dma_low = 0;
523
524 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
525 start_addr = agp_base;
526 end_addr = agp_base + dev_priv->dma_high;
527
528 start_addr_lo = ((HC_SubA_HAGPBstL << 24) | (start_addr & 0xFFFFFF));
529 end_addr_lo = ((HC_SubA_HAGPBendL << 24) | (end_addr & 0xFFFFFF));
530 command = ((HC_SubA_HAGPCMNT << 24) | (start_addr >> 24) |
531 ((end_addr & 0xff000000) >> 16));
532
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000533 dev_priv->last_pause_ptr =
534 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0,
535 &pause_addr_hi, &pause_addr_lo, 1) - 1;
Dave Airlie22f579c2005-06-28 22:48:56 +1000536
537 via_flush_write_combine();
Thomas Hellstromef68d292007-05-08 15:48:39 +1000538 (void) *(volatile uint32_t *)dev_priv->last_pause_ptr;
Dave Airlie22f579c2005-06-28 22:48:56 +1000539
540 VIA_WRITE(VIA_REG_TRANSET, (HC_ParaType_PreCR << 16));
541 VIA_WRITE(VIA_REG_TRANSPACE, command);
542 VIA_WRITE(VIA_REG_TRANSPACE, start_addr_lo);
543 VIA_WRITE(VIA_REG_TRANSPACE, end_addr_lo);
544
545 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_hi);
546 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_lo);
Thomas Hellstrom76f62552007-01-08 21:03:23 +1100547 DRM_WRITEMEMORYBARRIER();
Dave Airlie22f579c2005-06-28 22:48:56 +1000548 VIA_WRITE(VIA_REG_TRANSPACE, command | HC_HAGPCMNT_MASK);
Thomas Hellstrom76f62552007-01-08 21:03:23 +1100549 VIA_READ(VIA_REG_TRANSPACE);
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000550
551 dev_priv->dma_diff = 0;
552
553 count = 10000000;
554 while (!(VIA_READ(0x41c) & 0x80000000) && count--);
555
556 reader = *(dev_priv->hw_addr_ptr);
557 ptr = ((volatile char *)dev_priv->last_pause_ptr - dev_priv->dma_ptr) +
558 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
559
560 /*
561 * This is the difference between where we tell the
562 * command reader to pause and where it actually pauses.
563 * This differs between hw implementation so we need to
564 * detect it.
565 */
566
567 dev_priv->dma_diff = ptr - reader;
Dave Airlie22f579c2005-06-28 22:48:56 +1000568}
569
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200570static void via_pad_cache(drm_via_private_t *dev_priv, int qwords)
Dave Airlie22f579c2005-06-28 22:48:56 +1000571{
572 uint32_t *vb;
573
574 via_cmdbuf_wait(dev_priv, qwords + 2);
575 vb = via_get_dma(dev_priv);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000576 VIA_OUT_RING_QW(HC_HEADER2, HC_ParaType_NotTex << 16);
577 via_align_buffer(dev_priv, vb, qwords);
Dave Airlie22f579c2005-06-28 22:48:56 +1000578}
579
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200580static inline void via_dummy_bitblt(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000581{
582 uint32_t *vb = via_get_dma(dev_priv);
583 SetReg2DAGP(0x0C, (0 | (0 << 16)));
584 SetReg2DAGP(0x10, 0 | (0 << 16));
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000585 SetReg2DAGP(0x0, 0x1 | 0x2000 | 0xAA000000);
Dave Airlie22f579c2005-06-28 22:48:56 +1000586}
587
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200588static void via_cmdbuf_jump(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000589{
590 uint32_t agp_base;
591 uint32_t pause_addr_lo, pause_addr_hi;
592 uint32_t jump_addr_lo, jump_addr_hi;
593 volatile uint32_t *last_pause_ptr;
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000594 uint32_t dma_low_save1, dma_low_save2;
Dave Airlie22f579c2005-06-28 22:48:56 +1000595
596 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000597 via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi,
Dave Airlie22f579c2005-06-28 22:48:56 +1000598 &jump_addr_lo, 0);
Dave Airlie22f579c2005-06-28 22:48:56 +1000599
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000600 dev_priv->dma_wrap = dev_priv->dma_low;
Dave Airlie22f579c2005-06-28 22:48:56 +1000601
602 /*
603 * Wrap command buffer to the beginning.
604 */
605
606 dev_priv->dma_low = 0;
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200607 if (via_cmdbuf_wait(dev_priv, CMDBUF_ALIGNMENT_SIZE) != 0)
Dave Airlie22f579c2005-06-28 22:48:56 +1000608 DRM_ERROR("via_cmdbuf_jump failed\n");
Dave Airlie22f579c2005-06-28 22:48:56 +1000609
610 via_dummy_bitblt(dev_priv);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000611 via_dummy_bitblt(dev_priv);
Dave Airlie22f579c2005-06-28 22:48:56 +1000612
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000613 last_pause_ptr =
614 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
615 &pause_addr_lo, 0) - 1;
616 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
Dave Airlie22f579c2005-06-28 22:48:56 +1000617 &pause_addr_lo, 0);
618
619 *last_pause_ptr = pause_addr_lo;
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000620 dma_low_save1 = dev_priv->dma_low;
Dave Airlie22f579c2005-06-28 22:48:56 +1000621
Thomas Hellstromf0fb6d772008-03-17 10:07:20 +1000622 /*
623 * Now, set a trap that will pause the regulator if it tries to rerun the old
624 * command buffer. (Which may happen if via_hook_segment detecs a command regulator pause
625 * and reissues the jump command over PCI, while the regulator has already taken the jump
626 * and actually paused at the current buffer end).
627 * There appears to be no other way to detect this condition, since the hw_addr_pointer
628 * does not seem to get updated immediately when a jump occurs.
629 */
630
631 last_pause_ptr =
632 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
633 &pause_addr_lo, 0) - 1;
634 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
635 &pause_addr_lo, 0);
636 *last_pause_ptr = pause_addr_lo;
637
638 dma_low_save2 = dev_priv->dma_low;
639 dev_priv->dma_low = dma_low_save1;
640 via_hook_segment(dev_priv, jump_addr_hi, jump_addr_lo, 0);
641 dev_priv->dma_low = dma_low_save2;
642 via_hook_segment(dev_priv, pause_addr_hi, pause_addr_lo, 0);
Dave Airlie22f579c2005-06-28 22:48:56 +1000643}
644
Thomas Hellstroma0a6dd02007-05-08 15:47:41 +1000645
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200646static void via_cmdbuf_rewind(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000647{
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000648 via_cmdbuf_jump(dev_priv);
Dave Airlie22f579c2005-06-28 22:48:56 +1000649}
650
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200651static void via_cmdbuf_flush(drm_via_private_t *dev_priv, uint32_t cmd_type)
Dave Airlie22f579c2005-06-28 22:48:56 +1000652{
653 uint32_t pause_addr_lo, pause_addr_hi;
654
655 via_align_cmd(dev_priv, cmd_type, 0, &pause_addr_hi, &pause_addr_lo, 0);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000656 via_hook_segment(dev_priv, pause_addr_hi, pause_addr_lo, 0);
Dave Airlie22f579c2005-06-28 22:48:56 +1000657}
658
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200659static void via_cmdbuf_pause(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000660{
661 via_cmdbuf_flush(dev_priv, HC_HAGPBpID_PAUSE);
662}
663
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200664static void via_cmdbuf_reset(drm_via_private_t *dev_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000665{
666 via_cmdbuf_flush(dev_priv, HC_HAGPBpID_STOP);
667 via_wait_idle(dev_priv);
668}
669
670/*
671 * User interface to the space and lag functions.
672 */
673
Eric Anholtc153f452007-09-03 12:06:45 +1000674static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *file_priv)
Dave Airlie22f579c2005-06-28 22:48:56 +1000675{
Eric Anholtc153f452007-09-03 12:06:45 +1000676 drm_via_cmdbuf_size_t *d_siz = data;
Dave Airlie22f579c2005-06-28 22:48:56 +1000677 int ret = 0;
678 uint32_t tmp_size, count;
679 drm_via_private_t *dev_priv;
680
Márton Németh3e684ea2008-01-24 15:58:57 +1000681 DRM_DEBUG("\n");
Eric Anholt6c340ea2007-08-25 20:23:09 +1000682 LOCK_TEST_WITH_RETURN(dev, file_priv);
Dave Airlie22f579c2005-06-28 22:48:56 +1000683
684 dev_priv = (drm_via_private_t *) dev->dev_private;
685
686 if (dev_priv->ring.virtual_start == NULL) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000687 DRM_ERROR("called without initializing AGP ring buffer.\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000688 return -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000689 }
690
Dave Airlie22f579c2005-06-28 22:48:56 +1000691 count = 1000000;
Eric Anholtc153f452007-09-03 12:06:45 +1000692 tmp_size = d_siz->size;
693 switch (d_siz->func) {
Dave Airlie22f579c2005-06-28 22:48:56 +1000694 case VIA_CMDBUF_SPACE:
Eric Anholtc153f452007-09-03 12:06:45 +1000695 while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size)
Roel Kluind9c6f542009-04-16 22:57:46 +0200696 && --count) {
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200697 if (!d_siz->wait)
Dave Airlie22f579c2005-06-28 22:48:56 +1000698 break;
Dave Airlie22f579c2005-06-28 22:48:56 +1000699 }
700 if (!count) {
701 DRM_ERROR("VIA_CMDBUF_SPACE timed out.\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000702 ret = -EAGAIN;
Dave Airlie22f579c2005-06-28 22:48:56 +1000703 }
704 break;
705 case VIA_CMDBUF_LAG:
Eric Anholtc153f452007-09-03 12:06:45 +1000706 while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size)
Roel Kluind9c6f542009-04-16 22:57:46 +0200707 && --count) {
Nicolas Kaiser58c1e852010-07-11 15:32:42 +0200708 if (!d_siz->wait)
Dave Airlie22f579c2005-06-28 22:48:56 +1000709 break;
Dave Airlie22f579c2005-06-28 22:48:56 +1000710 }
711 if (!count) {
712 DRM_ERROR("VIA_CMDBUF_LAG timed out.\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000713 ret = -EAGAIN;
Dave Airlie22f579c2005-06-28 22:48:56 +1000714 }
715 break;
716 default:
Eric Anholt20caafa2007-08-25 19:22:43 +1000717 ret = -EFAULT;
Dave Airlie22f579c2005-06-28 22:48:56 +1000718 }
Eric Anholtc153f452007-09-03 12:06:45 +1000719 d_siz->size = tmp_size;
Dave Airlie22f579c2005-06-28 22:48:56 +1000720
Dave Airlie22f579c2005-06-28 22:48:56 +1000721 return ret;
722}
Dave Airlie92514242005-11-12 21:52:46 +1100723
Eric Anholtc153f452007-09-03 12:06:45 +1000724struct drm_ioctl_desc via_ioctls[] = {
Dave Airlie1b2f1482010-08-14 20:20:34 +1000725 DRM_IOCTL_DEF_DRV(VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH),
726 DRM_IOCTL_DEF_DRV(VIA_FREEMEM, via_mem_free, DRM_AUTH),
727 DRM_IOCTL_DEF_DRV(VIA_AGP_INIT, via_agp_init, DRM_AUTH|DRM_MASTER),
728 DRM_IOCTL_DEF_DRV(VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER),
729 DRM_IOCTL_DEF_DRV(VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER),
730 DRM_IOCTL_DEF_DRV(VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH),
731 DRM_IOCTL_DEF_DRV(VIA_DMA_INIT, via_dma_init, DRM_AUTH),
732 DRM_IOCTL_DEF_DRV(VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH),
733 DRM_IOCTL_DEF_DRV(VIA_FLUSH, via_flush_ioctl, DRM_AUTH),
734 DRM_IOCTL_DEF_DRV(VIA_PCICMD, via_pci_cmdbuffer, DRM_AUTH),
735 DRM_IOCTL_DEF_DRV(VIA_CMDBUF_SIZE, via_cmdbuf_size, DRM_AUTH),
736 DRM_IOCTL_DEF_DRV(VIA_WAIT_IRQ, via_wait_irq, DRM_AUTH),
737 DRM_IOCTL_DEF_DRV(VIA_DMA_BLIT, via_dma_blit, DRM_AUTH),
738 DRM_IOCTL_DEF_DRV(VIA_BLIT_SYNC, via_dma_blit_sync, DRM_AUTH)
Dave Airlie92514242005-11-12 21:52:46 +1100739};
740
741int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls);