Rev 3299 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3254 | Serge | 1 | /************************************************************************** |
2 | |||
3 | Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. |
||
4 | Copyright © 2002 David Dawes |
||
5 | |||
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 |
||
10 | "Software"), to deal in the Software without restriction, including |
||
11 | without limitation the rights to use, copy, modify, merge, publish, |
||
12 | distribute, sub license, and/or sell copies of the Software, and to |
||
13 | permit persons to whom the Software is furnished to do so, subject to |
||
14 | the following conditions: |
||
15 | |||
16 | The above copyright notice and this permission notice (including the |
||
17 | next paragraph) shall be included in all copies or substantial portions |
||
18 | of the Software. |
||
19 | |||
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||
21 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
||
23 | IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR |
||
24 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||
25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||
26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
27 | |||
28 | **************************************************************************/ |
||
29 | |||
30 | /* |
||
31 | * Authors: |
||
32 | * Keith Whitwell |
||
33 | * David Dawes |
||
34 | * |
||
35 | */ |
||
36 | |||
37 | #ifndef _SNA_H_ |
||
38 | #define _SNA_H_ |
||
39 | |||
40 | #ifdef HAVE_CONFIG_H |
||
41 | #include "config.h" |
||
42 | #endif |
||
43 | |||
44 | #include |
||
45 | #include |
||
46 | #include |
||
3263 | Serge | 47 | #include |
3254 | Serge | 48 | |
49 | #include "intel_driver.h" |
||
50 | #include "pciaccess.h" |
||
51 | |||
52 | #include "compiler.h" |
||
53 | |||
54 | //#define DBG(x) |
||
55 | //#define DBG(x) ErrorF x |
||
56 | |||
57 | #define assert(x) |
||
58 | |||
59 | |||
3258 | Serge | 60 | int drmIoctl(int fd, unsigned long request, void *arg); |
3254 | Serge | 61 | |
3258 | Serge | 62 | |
3254 | Serge | 63 | #define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ |
64 | ((type) << 16) | \ |
||
65 | ((a) << 12) | \ |
||
66 | ((r) << 8) | \ |
||
67 | ((g) << 4) | \ |
||
68 | ((b))) |
||
69 | #define PIXMAN_TYPE_OTHER 0 |
||
70 | #define PIXMAN_TYPE_A 1 |
||
71 | #define PIXMAN_TYPE_ARGB 2 |
||
72 | #define PIXMAN_TYPE_ABGR 3 |
||
73 | #define PIXMAN_TYPE_COLOR 4 |
||
74 | #define PIXMAN_TYPE_GRAY 5 |
||
75 | #define PIXMAN_TYPE_YUY2 6 |
||
76 | #define PIXMAN_TYPE_YV12 7 |
||
77 | #define PIXMAN_TYPE_BGRA 8 |
||
78 | #define PIXMAN_TYPE_RGBA 9 |
||
79 | #define PIXMAN_TYPE_ARGB_SRGB 10 |
||
80 | |||
81 | /* 32bpp formats */ |
||
82 | typedef enum { |
||
83 | PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8), |
||
84 | PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8), |
||
85 | PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8), |
||
86 | PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8), |
||
87 | PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8), |
||
88 | PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8), |
||
89 | PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8), |
||
90 | PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8), |
||
91 | PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6), |
||
92 | PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), |
||
93 | PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), |
||
94 | PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), |
||
3278 | Serge | 95 | PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), |
3254 | Serge | 96 | |
3278 | Serge | 97 | PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0) |
98 | |||
3254 | Serge | 99 | } pixman_format_code_t; |
100 | |||
3278 | Serge | 101 | typedef enum _PictFormatShort { |
3254 | Serge | 102 | |
3278 | Serge | 103 | PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, |
104 | PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, |
||
105 | PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, |
||
106 | PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, |
||
107 | PICT_b8g8r8a8 = PIXMAN_b8g8r8a8, |
||
108 | PICT_b8g8r8x8 = PIXMAN_b8g8r8x8, |
||
109 | |||
110 | /* 8bpp formats */ |
||
111 | PICT_a8 = PIXMAN_a8, |
||
112 | |||
113 | /* 4bpp formats */ |
||
114 | } PictFormatShort; |
||
115 | |||
3291 | Serge | 116 | #define PIXMAN_FORMAT_A(f) (((f) >> 12) & 0x0f) |
3299 | Serge | 117 | #define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff) |
3291 | Serge | 118 | |
119 | #define PICT_FORMAT_A(f) PIXMAN_FORMAT_A(f) |
||
120 | |||
3278 | Serge | 121 | #define RepeatNone 0 |
122 | #define RepeatNormal 1 |
||
123 | #define RepeatPad 2 |
||
124 | #define RepeatReflect 3 |
||
125 | |||
126 | #define PictFilterNearest 0 |
||
127 | #define PictFilterBilinear 1 |
||
128 | |||
129 | #define PictFilterFast 2 |
||
130 | #define PictFilterGood 3 |
||
131 | #define PictFilterBest 4 |
||
132 | |||
133 | #define PictFilterConvolution 5 |
||
134 | |||
135 | typedef int32_t pixman_fixed_16_16_t; |
||
136 | typedef pixman_fixed_16_16_t pixman_fixed_t; |
||
137 | |||
138 | struct pixman_transform |
||
139 | { |
||
140 | pixman_fixed_t matrix[3][3]; |
||
141 | }; |
||
142 | |||
3254 | Serge | 143 | typedef unsigned long Picture; |
144 | typedef unsigned long PictFormat; |
||
145 | |||
146 | typedef struct _Pixmap *PixmapPtr; |
||
147 | typedef struct _Picture *PicturePtr; |
||
3278 | Serge | 148 | typedef struct _Drawable *DrawablePtr; |
149 | typedef struct _PictFormat *PictFormatPtr; |
||
3254 | Serge | 150 | |
3278 | Serge | 151 | typedef struct pixman_transform PictTransform, *PictTransformPtr; |
152 | |||
153 | |||
154 | |||
3254 | Serge | 155 | typedef struct _Drawable { |
156 | unsigned char type; /* DRAWABLE_ |
||
157 | unsigned char class; /* specific to type */ |
||
158 | unsigned char depth; |
||
159 | unsigned char bitsPerPixel; |
||
160 | unsigned int id; /* resource id */ |
||
161 | short x; /* window: screen absolute, pixmap: 0 */ |
||
162 | short y; /* window: screen absolute, pixmap: 0 */ |
||
163 | unsigned short width; |
||
164 | unsigned short height; |
||
165 | } DrawableRec; |
||
166 | |||
167 | /* |
||
168 | * PIXMAP -- device dependent |
||
169 | */ |
||
170 | |||
171 | typedef struct _Pixmap { |
||
172 | DrawableRec drawable; |
||
173 | // PrivateRec *devPrivates; |
||
174 | int refcnt; |
||
175 | int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */ |
||
176 | // DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */ |
||
177 | #ifdef COMPOSITE |
||
178 | short screen_x; |
||
179 | short screen_y; |
||
180 | #endif |
||
181 | unsigned usage_hint; /* see CREATE_PIXMAP_USAGE_* */ |
||
182 | |||
183 | PixmapPtr master_pixmap; /* pointer to master copy of pixmap for pixmap sharing */ |
||
184 | } PixmapRec; |
||
185 | |||
3278 | Serge | 186 | typedef struct _PictFormat { |
187 | uint32_t id; |
||
188 | uint32_t format; /* except bpp */ |
||
189 | unsigned char type; |
||
190 | unsigned char depth; |
||
191 | // DirectFormatRec direct; |
||
192 | // IndexFormatRec index; |
||
193 | } PictFormatRec; |
||
3254 | Serge | 194 | |
3278 | Serge | 195 | typedef struct _Picture { |
196 | DrawablePtr pDrawable; |
||
197 | // PictFormatPtr pFormat; |
||
198 | PictFormatShort format; /* PICT_FORMAT */ |
||
199 | int refcnt; |
||
200 | uint32_t id; |
||
201 | unsigned int repeat:1; |
||
202 | unsigned int graphicsExposures:1; |
||
203 | unsigned int subWindowMode:1; |
||
204 | unsigned int polyEdge:1; |
||
205 | unsigned int polyMode:1; |
||
206 | unsigned int freeCompClip:1; |
||
207 | unsigned int clientClipType:2; |
||
208 | unsigned int componentAlpha:1; |
||
209 | unsigned int repeatType:2; |
||
210 | unsigned int filter:3; |
||
211 | // unsigned int stateChanges:CPLastBit; |
||
212 | // unsigned int unused:18 - CPLastBit; |
||
213 | |||
214 | // PicturePtr alphaMap; |
||
215 | |||
216 | // PictTransform *transform; |
||
217 | |||
218 | // SourcePictPtr pSourcePict; |
||
219 | // xFixed *filter_params; |
||
220 | // int filter_nparams; |
||
221 | } PictureRec; |
||
222 | |||
223 | #define PolyModePrecise 0 |
||
224 | #define PolyModeImprecise 1 |
||
225 | |||
226 | |||
3263 | Serge | 227 | struct sna_fb |
228 | { |
||
229 | uint32_t width; |
||
230 | uint32_t height; |
||
231 | uint32_t pitch; |
||
232 | uint32_t tiling; |
||
233 | |||
234 | struct kgem_bo *fb_bo; |
||
235 | }; |
||
3254 | Serge | 236 | |
237 | struct pixman_box16 |
||
238 | { |
||
239 | int16_t x1, y1, x2, y2; |
||
240 | }; |
||
241 | |||
242 | typedef struct pixman_box16 BoxRec; |
||
243 | typedef unsigned int CARD32; |
||
244 | typedef unsigned short CARD16; |
||
245 | |||
246 | #include "sna_render.h" |
||
247 | #include "kgem.h" |
||
248 | |||
249 | #define GXclear 0x0 |
||
250 | #define GXcopy 0x3 |
||
251 | |||
252 | #define PictOpClear 0 |
||
253 | #define PictOpSrc 1 |
||
254 | #define PictOpDst 2 |
||
255 | #define PictOpOver 3 |
||
256 | #define PictOpOverReverse 4 |
||
257 | #define PictOpIn 5 |
||
258 | #define PictOpInReverse 6 |
||
259 | #define PictOpOut 7 |
||
260 | #define PictOpOutReverse 8 |
||
261 | #define PictOpAtop 9 |
||
262 | #define PictOpAtopReverse 10 |
||
263 | #define PictOpXor 11 |
||
264 | #define PictOpAdd 12 |
||
265 | #define PictOpSaturate 13 |
||
266 | #define PictOpMaximum 13 |
||
267 | |||
268 | |||
269 | |||
270 | struct sna { |
||
271 | unsigned flags; |
||
272 | #define SNA_NO_WAIT 0x1 |
||
273 | #define SNA_NO_FLIP 0x2 |
||
274 | #define SNA_TRIPLE_BUFFER 0x4 |
||
275 | #define SNA_TEAR_FREE 0x10 |
||
276 | #define SNA_FORCE_SHADOW 0x20 |
||
277 | |||
278 | struct list flush_pixmaps; |
||
279 | struct list active_pixmaps; |
||
280 | |||
281 | |||
282 | |||
283 | // int vblank_interval; |
||
284 | |||
285 | // struct list deferred_free; |
||
286 | // struct list dirty_pixmaps; |
||
287 | // struct list active_pixmaps; |
||
288 | // struct list inactive_clock[2]; |
||
289 | |||
290 | unsigned int tiling; |
||
291 | #define SNA_TILING_DISABLE 0x0 |
||
292 | #define SNA_TILING_FB 0x1 |
||
293 | #define SNA_TILING_2D 0x2 |
||
294 | #define SNA_TILING_ALL (~0) |
||
295 | |||
296 | struct pci_device *PciInfo; |
||
297 | const struct intel_device_info *info; |
||
298 | |||
299 | // PicturePtr clear; |
||
300 | struct { |
||
301 | uint32_t fill_bo; |
||
302 | uint32_t fill_pixel; |
||
303 | uint32_t fill_alu; |
||
304 | } blt_state; |
||
305 | union { |
||
306 | // struct gen2_render_state gen2; |
||
3280 | Serge | 307 | struct gen3_render_state gen3; |
308 | struct gen4_render_state gen4; |
||
309 | struct gen5_render_state gen5; |
||
3254 | Serge | 310 | struct gen6_render_state gen6; |
311 | struct gen7_render_state gen7; |
||
312 | } render_state; |
||
313 | |||
314 | |||
315 | /* Broken-out options. */ |
||
316 | // OptionInfoPtr Options; |
||
317 | |||
318 | /* Driver phase/state information */ |
||
319 | // Bool suspended; |
||
320 | |||
321 | struct kgem kgem; |
||
322 | struct sna_render render; |
||
323 | |||
324 | #if DEBUG_MEMORY |
||
325 | struct { |
||
326 | int shadow_pixels_allocs; |
||
327 | int cpu_bo_allocs; |
||
328 | size_t shadow_pixels_bytes; |
||
329 | size_t cpu_bo_bytes; |
||
330 | } debug_memory; |
||
331 | #endif |
||
332 | }; |
||
333 | |||
3280 | Serge | 334 | static inline struct sna * |
335 | to_sna_from_kgem(struct kgem *kgem) |
||
336 | { |
||
337 | return container_of(kgem, struct sna, kgem); |
||
338 | } |
||
3254 | Serge | 339 | |
340 | #ifndef ARRAY_SIZE |
||
341 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) |
||
342 | #endif |
||
343 | |||
344 | #ifndef ALIGN |
||
345 | #define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1)) |
||
346 | #endif |
||
347 | |||
348 | #ifndef MIN |
||
349 | #define MIN(a,b) ((a) <= (b) ? (a) : (b)) |
||
350 | #endif |
||
351 | |||
352 | #ifndef MAX |
||
353 | #define MAX(a,b) ((a) >= (b) ? (a) : (b)) |
||
354 | #endif |
||
355 | #endif /* _SNA_H */=>><>><>><>><>><> |