blob: e6a8ec647f8fc4b9040774bf9402477cfc5d1306 [file] [log] [blame]
Thomas Hellstrom6cd88312004-03-23 21:08:48 +00001/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#ifndef _VIA_DRM_H_
25#define _VIA_DRM_H_
26
27/* WARNING: These defines must be the same as what the Xserver uses.
28 * if you change them, you must change the defines in the Xserver.
29 */
30
31#ifndef _VIA_DEFINES_
32#define _VIA_DEFINES_
33
Thomas Hellstrom659e9a02006-02-17 17:25:41 +000034
Eric Anholt8c21b782005-08-15 18:07:12 +000035#if !defined(__KERNEL__) && !defined(_KERNEL)
Thomas Hellstromd2fd9202005-03-14 22:50:21 +000036#include "via_drmclient.h"
37#endif
38
Thomas Hellstrom2e0c2812006-01-06 11:57:40 +000039/*
40 * With the arrival of libdrm there is a need to version this file.
41 * As usual, bump MINOR for new features, MAJOR for changes that create
42 * backwards incompatibilities, (which should be avoided whenever possible).
Thomas Hellstrom2e0c2812006-01-06 11:57:40 +000043 */
44
Thomas Hellstrom6c041852007-02-02 09:15:44 +010045#define VIA_DRM_DRIVER_DATE "20070202"
Thomas Hellstrom659e9a02006-02-17 17:25:41 +000046
Thomas Hellstrom126673d2006-07-11 14:37:37 +000047#define VIA_DRM_DRIVER_MAJOR 2
Thomas Hellstrom2980ec22006-12-27 19:38:33 +010048#define VIA_DRM_DRIVER_MINOR 11
Thomas Hellstrom6c041852007-02-02 09:15:44 +010049#define VIA_DRM_DRIVER_PATCHLEVEL 1
Dave Airlie9b984b32006-08-19 17:59:18 +100050#define VIA_DRM_DRIVER_VERSION (((VIA_DRM_DRIVER_MAJOR) << 16) | (VIA_DRM_DRIVER_MINOR))
Thomas Hellstrom2e0c2812006-01-06 11:57:40 +000051
Dave Airlie7f6bf842007-11-05 12:42:22 +100052#define VIA_NR_SAREA_CLIPRECTS 8
Dave Airlie9b984b32006-08-19 17:59:18 +100053#define VIA_NR_XVMC_PORTS 10
54#define VIA_NR_XVMC_LOCKS 5
55#define VIA_MAX_CACHELINE_SIZE 64
Thomas Hellstrom6cd88312004-03-23 21:08:48 +000056#define XVMCLOCKPTR(saPriv,lockNo) \
Dave Airlieb95ac8b2007-07-16 11:22:15 +100057 ((volatile struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
Thomas Hellstromd2fd9202005-03-14 22:50:21 +000058 (VIA_MAX_CACHELINE_SIZE - 1)) & \
59 ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
60 VIA_MAX_CACHELINE_SIZE*(lockNo)))
Thomas Hellstrom6cd88312004-03-23 21:08:48 +000061#define VIA_NR_TEX_REGIONS 64
Thomas Hellstrome0f53e52007-02-16 20:22:24 +010062
Thomas Hellstrom6cd88312004-03-23 21:08:48 +000063#endif
64
Thomas Hellstrome0f53e52007-02-16 20:22:24 +010065#define DRM_VIA_FENCE_TYPE_ACCEL 0x00000002
Thomas Hellstrom6cd88312004-03-23 21:08:48 +000066
67/* VIA specific ioctls */
Jon Smirlfa6b1d12004-09-27 19:51:38 +000068#define DRM_VIA_ALLOCMEM 0x00
Dave Airlie9b984b32006-08-19 17:59:18 +100069#define DRM_VIA_FREEMEM 0x01
Jon Smirlfa6b1d12004-09-27 19:51:38 +000070#define DRM_VIA_AGP_INIT 0x02
Dave Airlie9b984b32006-08-19 17:59:18 +100071#define DRM_VIA_FB_INIT 0x03
Jon Smirlfa6b1d12004-09-27 19:51:38 +000072#define DRM_VIA_MAP_INIT 0x04
73#define DRM_VIA_DEC_FUTEX 0x05
74#define NOT_USED
75#define DRM_VIA_DMA_INIT 0x07
76#define DRM_VIA_CMDBUFFER 0x08
Dave Airlie9b984b32006-08-19 17:59:18 +100077#define DRM_VIA_FLUSH 0x09
78#define DRM_VIA_PCICMD 0x0a
Thomas Hellstromaff0a252004-12-13 13:53:12 +000079#define DRM_VIA_CMDBUF_SIZE 0x0b
Thomas Hellstrom532ccb92005-03-28 21:21:42 +000080#define NOT_USED
Dave Airlie9b984b32006-08-19 17:59:18 +100081#define DRM_VIA_WAIT_IRQ 0x0d
82#define DRM_VIA_DMA_BLIT 0x0e
Thomas Hellstrom903e5702005-09-25 12:54:12 +000083#define DRM_VIA_BLIT_SYNC 0x0f
Jon Smirlfa6b1d12004-09-27 19:51:38 +000084
Thomas Hellstromaff0a252004-12-13 13:53:12 +000085#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
86#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
87#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
88#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
89#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
90#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
91#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
92#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
93#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
94#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
95#define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
96 drm_via_cmdbuf_size_t)
Thomas Hellstrom532ccb92005-03-28 21:21:42 +000097#define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
Thomas Hellstrom903e5702005-09-25 12:54:12 +000098#define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
99#define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
Thomas Hellstromb0c73b72004-09-07 16:48:44 +0000100
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000101/* Indices into buf.Setup where various bits of state are mirrored per
102 * context and per buffer. These can be fired at the card as a unit,
103 * or in a piecewise fashion as required.
104 */
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000105
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000106#define VIA_TEX_SETUP_SIZE 8
107
108/* Flags for clear ioctl
109 */
110#define VIA_FRONT 0x1
111#define VIA_BACK 0x2
112#define VIA_DEPTH 0x4
113#define VIA_STENCIL 0x8
Thomas Hellstromb63b7712005-10-22 15:12:05 +0000114
115#define VIA_MEM_VIDEO 0 /* matches drm constant */
116#define VIA_MEM_AGP 1 /* matches drm constant */
Dave Airlie7f6bf842007-11-05 12:42:22 +1000117#define VIA_MEM_SYSTEM 2
Thomas Hellstromb63b7712005-10-22 15:12:05 +0000118#define VIA_MEM_MIXED 3
119#define VIA_MEM_UNKNOWN 4
120
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000121typedef struct {
Thomas Hellstromd24194e2004-10-08 21:11:02 +0000122 uint32_t offset;
123 uint32_t size;
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000124} drm_via_agp_t;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000125
126typedef struct {
Thomas Hellstromd24194e2004-10-08 21:11:02 +0000127 uint32_t offset;
128 uint32_t size;
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000129} drm_via_fb_t;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000130
131typedef struct {
Dave Airliefec94a82004-10-09 11:12:24 +0000132 uint32_t context;
Thomas Hellstromd24194e2004-10-08 21:11:02 +0000133 uint32_t type;
134 uint32_t size;
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000135 unsigned long index;
136 unsigned long offset;
137} drm_via_mem_t;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000138
139typedef struct _drm_via_init {
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000140 enum {
141 VIA_INIT_MAP = 0x01,
142 VIA_CLEANUP_MAP = 0x02
143 } func;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000144
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000145 unsigned long sarea_priv_offset;
146 unsigned long fb_offset;
147 unsigned long mmio_offset;
148 unsigned long agpAddr;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000149} drm_via_init_t;
150
151typedef struct _drm_via_futex {
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000152 enum {
153 VIA_FUTEX_WAIT = 0x00,
154 VIA_FUTEX_WAKE = 0X01
Thomas Hellstromd24194e2004-10-08 21:11:02 +0000155 } func;
156 uint32_t ms;
157 uint32_t lock;
158 uint32_t val;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000159} drm_via_futex_t;
160
Erdi Chen25e319c2004-08-24 01:44:37 +0000161typedef struct _drm_via_dma_init {
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000162 enum {
163 VIA_INIT_DMA = 0x01,
Thomas Hellstrom4f8fa602004-11-27 22:55:31 +0000164 VIA_CLEANUP_DMA = 0x02,
Dave Airlie9b984b32006-08-19 17:59:18 +1000165 VIA_DMA_INITIALIZED = 0x03
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000166 } func;
Erdi Chen25e319c2004-08-24 01:44:37 +0000167
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000168 unsigned long offset;
169 unsigned long size;
170 unsigned long reg_pause_addr;
Erdi Chen25e319c2004-08-24 01:44:37 +0000171} drm_via_dma_init_t;
172
173typedef struct _drm_via_cmdbuffer {
Thomas Hellstrom56711372005-07-15 21:22:51 +0000174 char __user *buf;
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000175 unsigned long size;
Erdi Chen25e319c2004-08-24 01:44:37 +0000176} drm_via_cmdbuffer_t;
177
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000178/* Warning: If you change the SAREA structure you must change the Xserver
179 * structure as well */
180
181typedef struct _drm_via_tex_region {
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000182 unsigned char next, prev; /* indices to form a circular LRU */
183 unsigned char inUse; /* owned by a client, or free? */
184 int age; /* tracked by clients to update local LRU's */
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000185} drm_via_tex_region_t;
186
187typedef struct _drm_via_sarea {
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000188 unsigned int dirty;
189 unsigned int nbox;
Dave Airlieb95ac8b2007-07-16 11:22:15 +1000190 struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000191 drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
192 int texAge; /* last time texture was uploaded */
193 int ctxOwner; /* last context to upload state */
194 int vertexPrim;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000195
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000196 /*
197 * Below is for XvMC.
198 * We want the lock integers alone on, and aligned to, a cache line.
199 * Therefore this somewhat strange construct.
200 */
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000201
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000202 char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000203
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000204 unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
205 unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
Dave Airlie7f6bf842007-11-05 12:42:22 +1000206 unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
Thomas Hellstrom6f6d2a52004-04-12 10:18:18 +0000207
Thomas Hellstromb63b7712005-10-22 15:12:05 +0000208 /* Used by the 3d driver only at this point, for pageflipping:
209 */
Dave Airlie9b984b32006-08-19 17:59:18 +1000210 unsigned int pfCurrentOffset;
Thomas Hellstrom6cd88312004-03-23 21:08:48 +0000211} drm_via_sarea_t;
212
Thomas Hellstromaff0a252004-12-13 13:53:12 +0000213typedef struct _drm_via_cmdbuf_size {
214 enum {
215 VIA_CMDBUF_SPACE = 0x01,
216 VIA_CMDBUF_LAG = 0x02
217 } func;
218 int wait;
219 uint32_t size;
220} drm_via_cmdbuf_size_t;
Thomas Hellstrom4f8fa602004-11-27 22:55:31 +0000221
Thomas Hellstrom532ccb92005-03-28 21:21:42 +0000222typedef enum {
223 VIA_IRQ_ABSOLUTE = 0x0,
224 VIA_IRQ_RELATIVE = 0x1,
225 VIA_IRQ_SIGNAL = 0x10000000,
226 VIA_IRQ_FORCE_SEQUENCE = 0x20000000
227} via_irq_seq_type_t;
228
229#define VIA_IRQ_FLAGS_MASK 0xF0000000
230
Dave Airlie5dc5c362007-11-22 16:10:36 +1000231enum drm_via_irqs {
Dave Airlie42cd50f2006-01-02 03:25:49 +0000232 drm_via_irq_hqv0 = 0,
233 drm_via_irq_hqv1,
234 drm_via_irq_dma0_dd,
235 drm_via_irq_dma0_td,
236 drm_via_irq_dma1_dd,
237 drm_via_irq_dma1_td,
238 drm_via_irq_num
239};
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000240
Dave Airlie5dc5c362007-11-22 16:10:36 +1000241struct drm_via_wait_irq_request {
Thomas Hellstrom532ccb92005-03-28 21:21:42 +0000242 unsigned irq;
243 via_irq_seq_type_t type;
244 uint32_t sequence;
245 uint32_t signal;
246};
247
248typedef union drm_via_irqwait {
249 struct drm_via_wait_irq_request request;
250 struct drm_wait_vblank_reply reply;
251} drm_via_irqwait_t;
Thomas Hellstrom4f8fa602004-11-27 22:55:31 +0000252
Dave Airlie7f6bf842007-11-05 12:42:22 +1000253typedef struct drm_via_blitsync {
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000254 uint32_t sync_handle;
255 unsigned engine;
256} drm_via_blitsync_t;
257
Dave Airlie7f6bf842007-11-05 12:42:22 +1000258/*
Thomas Hellstrom2e0c2812006-01-06 11:57:40 +0000259 * Below,"flags" is currently unused but will be used for possible future
Dave Airlie7f6bf842007-11-05 12:42:22 +1000260 * extensions like kernel space bounce buffers for bad alignments and
Thomas Hellstrom2e0c2812006-01-06 11:57:40 +0000261 * blit engine busy-wait polling for better latency in the absence of
262 * interrupts.
263 */
264
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000265typedef struct drm_via_dmablit {
Dave Airlie9b984b32006-08-19 17:59:18 +1000266 uint32_t num_lines;
267 uint32_t line_length;
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000268
Dave Airlie9b984b32006-08-19 17:59:18 +1000269 uint32_t fb_addr;
270 uint32_t fb_stride;
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000271
Dave Airlie9b984b32006-08-19 17:59:18 +1000272 unsigned char *mem_addr;
Dave Airlie5dc5c362007-11-22 16:10:36 +1000273 uint32_t mem_stride;
Dave Airlie7f6bf842007-11-05 12:42:22 +1000274
Dave Airlie5dc5c362007-11-22 16:10:36 +1000275 uint32_t flags;
Dave Airlie9b984b32006-08-19 17:59:18 +1000276 int to_fb;
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000277
Dave Airlie7f6bf842007-11-05 12:42:22 +1000278 drm_via_blitsync_t sync;
Thomas Hellstrom903e5702005-09-25 12:54:12 +0000279} drm_via_dmablit_t;
280
281
Jon Smirl9f9a8f12004-09-30 21:12:10 +0000282#endif /* _VIA_DRM_H_ */