Subversion Repositories Kolibri OS

Rev

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