Subversion Repositories Kolibri OS

Rev

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