Subversion Repositories Kolibri OS

Rev

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