Subversion Repositories Kolibri OS

Rev

Rev 3258 | 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
 
3256 Serge 63
#define SRV_GET_PCI_INFO            20
64
#define SRV_GET_PARAM               21
65
#define SRV_I915_GEM_CREATE         22
66
#define SRV_DRM_GEM_CLOSE           23
67
#define SRV_I915_GEM_PIN            24
68
#define SRV_I915_GEM_SET_CACHEING   25
69
#define SRV_I915_GEM_GET_APERTURE   26
3258 Serge 70
#define SRV_I915_GEM_PWRITE         27
71
#define SRV_I915_GEM_BUSY           28
72
#define SRV_I915_GEM_SET_DOMAIN     29
73
#define SRV_I915_GEM_MMAP           30
3263 Serge 74
#define SRV_I915_GEM_THROTTLE       32
75
#define SRV_FBINFO                  33
76
#define SRV_I915_GEM_EXECBUFFER2    34
77
 
3258 Serge 78
#define SRV_I915_GEM_MMAP_GTT       31
3254 Serge 79
 
80
 
3258 Serge 81
#define DRM_IOCTL_GEM_CLOSE         SRV_DRM_GEM_CLOSE
3254 Serge 82
 
83
#define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) |    \
84
                                        ((type) << 16) |    \
85
                                        ((a) << 12)    |    \
86
                                        ((r) << 8) |        \
87
                                        ((g) << 4) |        \
88
                                        ((b)))
89
#define PIXMAN_TYPE_OTHER	0
90
#define PIXMAN_TYPE_A		1
91
#define PIXMAN_TYPE_ARGB	2
92
#define PIXMAN_TYPE_ABGR	3
93
#define PIXMAN_TYPE_COLOR	4
94
#define PIXMAN_TYPE_GRAY	5
95
#define PIXMAN_TYPE_YUY2	6
96
#define PIXMAN_TYPE_YV12	7
97
#define PIXMAN_TYPE_BGRA	8
98
#define PIXMAN_TYPE_RGBA	9
99
#define PIXMAN_TYPE_ARGB_SRGB	10
100
 
101
/* 32bpp formats */
102
typedef enum {
103
    PIXMAN_a8r8g8b8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
104
    PIXMAN_x8r8g8b8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
105
    PIXMAN_a8b8g8r8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
106
    PIXMAN_x8b8g8r8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
107
    PIXMAN_b8g8r8a8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8),
108
    PIXMAN_b8g8r8x8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8),
109
    PIXMAN_r8g8b8a8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8),
110
    PIXMAN_r8g8b8x8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8),
111
    PIXMAN_x14r6g6b6 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6),
112
    PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10),
113
    PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10),
114
    PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
115
    PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10)
116
 
117
} pixman_format_code_t;
118
 
119
 
120
typedef unsigned long   Picture;
121
typedef unsigned long   PictFormat;
122
 
123
typedef struct _Pixmap  *PixmapPtr;
124
typedef struct _Picture *PicturePtr;
125
 
126
typedef struct _Drawable {
127
    unsigned char type;         /* DRAWABLE_ */
128
    unsigned char class;        /* specific to type */
129
    unsigned char depth;
130
    unsigned char bitsPerPixel;
131
    unsigned int   id;           /* resource id */
132
    short x;                    /* window: screen absolute, pixmap: 0 */
133
    short y;                    /* window: screen absolute, pixmap: 0 */
134
    unsigned short width;
135
    unsigned short height;
136
} DrawableRec;
137
 
138
/*
139
 * PIXMAP -- device dependent
140
 */
141
 
142
typedef struct _Pixmap {
143
    DrawableRec drawable;
144
//    PrivateRec *devPrivates;
145
    int refcnt;
146
    int devKind;                /* This is the pitch of the pixmap, typically width*bpp/8. */
147
//    DevUnion devPrivate;        /* When !NULL, devPrivate.ptr points to the raw pixel data. */
148
#ifdef COMPOSITE
149
    short screen_x;
150
    short screen_y;
151
#endif
152
    unsigned usage_hint;        /* see CREATE_PIXMAP_USAGE_* */
153
 
154
    PixmapPtr master_pixmap;    /* pointer to master copy of pixmap for pixmap sharing */
155
} PixmapRec;
156
 
157
 
3263 Serge 158
struct sna_fb
159
{
160
    uint32_t  width;
161
    uint32_t  height;
162
    uint32_t  pitch;
163
    uint32_t  tiling;
164
 
165
    struct kgem_bo *fb_bo;
166
};
3254 Serge 167
 
168
struct pixman_box16
169
{
170
    int16_t x1, y1, x2, y2;
171
};
172
 
173
typedef struct pixman_box16 BoxRec;
174
typedef unsigned int   CARD32;
175
typedef unsigned short CARD16;
176
 
177
#include "sna_render.h"
178
#include "kgem.h"
179
 
180
#define GXclear                 0x0
181
#define GXcopy                  0x3
182
 
183
#define PictOpClear             0
184
#define PictOpSrc               1
185
#define PictOpDst               2
186
#define PictOpOver              3
187
#define PictOpOverReverse       4
188
#define PictOpIn                5
189
#define PictOpInReverse         6
190
#define PictOpOut               7
191
#define PictOpOutReverse        8
192
#define PictOpAtop              9
193
#define PictOpAtopReverse       10
194
#define PictOpXor               11
195
#define PictOpAdd               12
196
#define PictOpSaturate          13
197
#define PictOpMaximum           13
198
 
199
 
200
 
201
struct sna {
202
    unsigned flags;
203
#define SNA_NO_WAIT		0x1
204
#define SNA_NO_FLIP		0x2
205
#define SNA_TRIPLE_BUFFER	0x4
206
#define SNA_TEAR_FREE		0x10
207
#define SNA_FORCE_SHADOW	0x20
208
 
209
	struct list flush_pixmaps;
210
	struct list active_pixmaps;
211
 
212
 
213
 
214
//    int vblank_interval;
215
 
216
//    struct list deferred_free;
217
//    struct list dirty_pixmaps;
218
//    struct list active_pixmaps;
219
//    struct list inactive_clock[2];
220
 
221
    unsigned int tiling;
222
#define SNA_TILING_DISABLE  0x0
223
#define SNA_TILING_FB       0x1
224
#define SNA_TILING_2D       0x2
225
#define SNA_TILING_ALL     (~0)
226
 
227
	struct pci_device *PciInfo;
228
	const struct intel_device_info *info;
229
 
230
//    PicturePtr clear;
231
    struct {
232
        uint32_t fill_bo;
233
        uint32_t fill_pixel;
234
        uint32_t fill_alu;
235
    } blt_state;
236
    union {
237
//        struct gen2_render_state gen2;
238
//        struct gen3_render_state gen3;
239
//        struct gen4_render_state gen4;
240
//        struct gen5_render_state gen5;
241
        struct gen6_render_state gen6;
242
		struct gen7_render_state gen7;
243
    } render_state;
244
 
245
 
246
    /* Broken-out options. */
247
//    OptionInfoPtr Options;
248
 
249
    /* Driver phase/state information */
250
//    Bool suspended;
251
 
252
    struct kgem kgem;
253
    struct sna_render render;
254
 
255
#if DEBUG_MEMORY
256
	struct {
257
	       int shadow_pixels_allocs;
258
	       int cpu_bo_allocs;
259
	       size_t shadow_pixels_bytes;
260
	       size_t cpu_bo_bytes;
261
	} debug_memory;
262
#endif
263
};
264
 
265
static inline int vertex_space(struct sna *sna)
266
{
267
    return sna->render.vertex_size - sna->render.vertex_used;
268
}
269
 
270
static inline void vertex_emit(struct sna *sna, float v)
271
{
272
    assert(sna->render.vertex_used < sna->render.vertex_size);
273
    sna->render.vertices[sna->render.vertex_used++] = v;
274
}
275
 
276
static inline void vertex_emit_2s(struct sna *sna, int16_t x, int16_t y)
277
{
278
    int16_t *v = (int16_t *)&sna->render.vertices[sna->render.vertex_used++];
279
    assert(sna->render.vertex_used <= sna->render.vertex_size);
280
    v[0] = x;
281
    v[1] = y;
282
}
283
 
284
static inline void batch_emit(struct sna *sna, uint32_t dword)
285
{
286
    assert(sna->kgem.mode != KGEM_NONE);
287
    assert(sna->kgem.nbatch + KGEM_BATCH_RESERVED < sna->kgem.surface);
288
    sna->kgem.batch[sna->kgem.nbatch++] = dword;
289
}
290
 
291
#ifndef ARRAY_SIZE
292
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
293
#endif
294
 
295
#ifndef ALIGN
296
#define ALIGN(i,m)	(((i) + (m) - 1) & ~((m) - 1))
297
#endif
298
 
299
#ifndef MIN
300
#define MIN(a,b)	((a) <= (b) ? (a) : (b))
301
#endif
302
 
303
#ifndef MAX
304
#define MAX(a,b)	((a) >= (b) ? (a) : (b))
305
#endif
306
#endif /* _SNA_H */