Fixed off by one errors in clipping.
[mesa.git] / src / mesa / drivers / dri / unichrome / via_common.h
1 /*
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
34 #define VIA_DMA_BUF_ORDER 12
35 #define VIA_DMA_BUF_SZ (1 << VIA_DMA_BUF_ORDER)
36 #define VIA_DMA_BUF_NR 256
37 #define VIA_NR_SAREA_CLIPRECTS 8
38
39 #define VIA_NR_TEX_REGIONS 64
40 #define VIA_LOG_MIN_TEX_REGION_SIZE 16
41 #endif
42
43 #define VIA_UPLOAD_TEX0IMAGE 0x1
44 #define VIA_UPLOAD_TEX1IMAGE 0x2
45 #define VIA_UPLOAD_CTX 0x4
46 #define VIA_UPLOAD_BUFFERS 0x8
47 #define VIA_UPLOAD_TEX0 0x10
48 #define VIA_UPLOAD_TEX1 0x20
49 #define VIA_UPLOAD_CLIPRECTS 0x40
50 /*#define VIA_UPLOAD_ALL 0xff*/
51
52 /* VIA specific ioctls */
53 #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t)
54 #define DRM_IOCTL_VIA_FREEMEM DRM_IOW(0x41, drm_via_mem_t)
55 #define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(0x42, drm_via_agp_t)
56 #define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(0x43, drm_via_fb_t)
57 #define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(0x44, drm_via_init_t)
58 #define DRM_IOCTL_VIA_FLUSH_AGP DRM_IOW(0x45, drm_via_flush_agp_t)
59 #define DRM_IOCTL_VIA_FLUSH_SYS DRM_IOW(0x46, drm_via_flush_sys_t)
60
61 #define VIA_TEX_SETUP_SIZE 8
62
63 #define VIA_FRONT 0x1
64 #define VIA_BACK 0x2
65 #define VIA_DEPTH 0x4
66 #define VIA_STENCIL 0x8
67 #define VIDEO 0
68 #define AGP 1
69 typedef struct {
70 unsigned int offset;
71 unsigned int size;
72 } drm_via_agp_t;
73
74 typedef struct {
75 unsigned int offset;
76 unsigned int size;
77 } drm_via_fb_t;
78
79 typedef struct {
80 unsigned int context;
81 unsigned int type;
82 unsigned int size;
83 unsigned long index;
84 unsigned long offset;
85 } drm_via_mem_t;
86
87 typedef struct _drm_via_init {
88 enum {
89 VIA_INIT_MAP = 0x01,
90 VIA_CLEANUP_MAP = 0x02
91 } func;
92 unsigned long sarea_priv_offset;
93 unsigned long fb_offset;
94 unsigned long mmio_offset;
95 unsigned long agpAddr;
96 } drm_via_init_t;
97
98
99 typedef struct _drm_via_tex_region {
100 unsigned char next, prev;
101 unsigned char inUse;
102 int age;
103 } drm_via_tex_region_t;
104
105 typedef struct _drm_via_sarea {
106 unsigned int dirty;
107 unsigned int nbox;
108 drm_clip_rect_t boxes[VIA_NR_SAREA_CLIPRECTS];
109 drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
110 int texAge;
111 int ctxOwner;
112 int vertexPrim;
113 } drm_via_sarea_t;
114
115 typedef struct _drm_via_flush_agp {
116 unsigned int offset;
117 unsigned int size;
118 unsigned int index;
119 int discard;
120 } drm_via_flush_agp_t;
121
122 typedef struct _drm_via_flush_sys {
123 unsigned int offset;
124 unsigned int size;
125 unsigned long index;
126 int discard;
127 } drm_via_flush_sys_t;
128
129 #ifdef __KERNEL__
130 int via_fb_init(struct inode *inode, struct file *filp, unsigned int cmd,
131 unsigned long arg);
132 int via_mem_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
133 unsigned long arg);
134 int via_mem_free(struct inode *inode, struct file *filp, unsigned int cmd,
135 unsigned long arg);
136 int via_agp_init(struct inode *inode, struct file *filp, unsigned int cmd,
137 unsigned long arg);
138 int via_dma_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
139 unsigned long arg);
140 int via_dma_free(struct inode *inode, struct file *filp, unsigned int cmd,
141 unsigned long arg);
142 int via_map_init(struct inode *inode, struct file *filp, unsigned int cmd,
143 unsigned long arg);
144 int via_flush_agp(struct inode *inode, struct file *filp, unsigned int cmd,
145 unsigned long arg);
146 int via_flush_sys(struct inode *inode, struct file *filp, unsigned int cmd,
147 unsigned long arg);
148 #endif
149 #endif /* _VIA_DRM_H_ */