Subversion Repositories Kolibri OS

Rev

Rev 4372 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4372 Serge 1
 
2
3
 
4
#include 
5
#include 
6
#include 
7
#include "pixdriver.h"
4377 Serge 8
9
 
4372 Serge 10
11
 
12
13
 
14
 
15
16
 
17
#define SRV_GET_CAPS                3
18
19
 
20
#define __ALIGN_MASK(x,mask)  (((x)+(mask))&~(mask))
21
#define ALIGN(x,a)            __ALIGN_MASK(x,(typeof(x))(a)-1)
22
23
 
24
25
 
26
{
27
	uint32_t width;
28
	uint32_t height;
29
	void *data;
30
	uint32_t pitch;
31
	uint32_t bo;
32
	uint32_t bo_size;
33
	uint32_t flags;
34
} surface_t;
35
36
 
37
static uint32_t hw_caps;
38
static struct pix_driver pix_driver;
39
40
 
41
{
42
    void *lib;
43
    uint32_t (*drventry)(uint32_t service, struct pix_driver *driver);
44
45
 
46
	ioctl_t io;
47
48
 
49
		return caps & hw_caps;
50
51
 
52
	if (service == 0)
53
		goto fail;
54
55
 
56
	io.io_code = SRV_GETVERSION;
57
	io.input = NULL;
58
	io.inp_size = 0;
59
	io.output = &api_version;
60
	io.out_size = BUFFER_SIZE(1);
61
62
 
63
		goto fail;
64
65
 
66
		(DISPLAY_VERSION < (api_version >> 16)))
67
		goto fail;
68
69
 
70
    if(lib == 0)
71
        lib = load_library("intel-uxa.drv");
72
    if(lib == 0)
73
        goto fail;
74
75
 
76
77
 
78
        goto fail;
79
80
 
81
82
 
83
		printf("2D caps %s%s%s\n",
84
			   (hw_caps & HW_BIT_BLIT) != 0 ? "HW_BIT_BLIT " : "",
85
			   (hw_caps & HW_TEX_BLIT) != 0 ? "HW_TEX_BLIT " : "",
86
			   (hw_caps & HW_VID_BLIT) != 0 ? "HW_VID_BLIT " : "");
87
88
 
89
90
 
91
	service = 0;
92
	return 0;
93
};
94
95
 
96
{
97
	if (hw_caps != 0)
98
        pix_driver.fini();
99
};
100
101
 
102
{
103
	uint32_t size, bo_size;
104
	uint32_t pitch, max_pitch;
105
	void *buffer;
106
	surface_t *sf;
107
108
 
109
	bitmap->data = (void *) -1;
110
	bitmap->pitch = -1;
111
112
 
113
       return pix_driver.create_bitmap(bitmap);
114
115
 
116
	max_pitch = ALIGN(bitmap->max_width * 4, 16);
117
118
 
119
	bo_size = ALIGN(max_pitch * bitmap->max_height, 4096);
120
121
 
122
		bo_size = size;
123
124
 
125
	if (sf == NULL)
126
		return -1;
127
128
 
129
130
 
131
	{
132
		free(sf);
133
		return -1;
134
	};
135
136
 
137
	sf->height = bitmap->height;
138
	sf->data = buffer;
139
	sf->pitch = pitch;
140
	sf->bo = 0;
141
	sf->bo_size = bo_size;
142
	sf->flags = bitmap->flags;
143
144
 
145
146
 
147
//            bitmap, bitmap->handle, bitmap->data, bitmap->width, bitmap->height);
148
149
 
150
};
151
152
 
153
{
154
	surface_t *sf = to_surface(bitmap);
155
156
 
157
        return pix_driver.destroy_bitmap(bitmap);
158
159
 
160
	free(sf);
161
162
 
163
	bitmap->data = (void *) -1;
164
	bitmap->pitch = -1;
165
166
 
167
};
168
169
 
170
{
171
	surface_t *sf = to_surface(bitmap);
172
173
 
174
		return 0;
175
176
 
177
       return pix_driver.lock_bitmap(bitmap);
178
179
 
180
	bitmap->pitch = sf->pitch;
181
182
 
183
};
184
185
 
186
                int w, int h, int src_x, int src_y)
187
{
188
	struct blit_call bc;
189
	int ret;
190
191
 
192
193
 
194
        return pix_driver.blit(bitmap, 0, 0, dst_x, dst_y, w, h, src_x, src_y);
4377 Serge 195
4372 Serge 196
 
197
	bc.dsty     = dst_y;
198
	bc.w        = w;
199
	bc.h        = h;
200
	bc.srcx     = 0;
201
	bc.srcy     = 0;
202
	bc.srcw     = w;
203
	bc.srch     = h;
204
	bc.stride   = sf->pitch;
205
	bc.bitmap   = sf->data;
206
207
 
208
    "int $0x40":"=a"(ret):"a"(73), "b"(0x00),
209
	"c"(&bc):"memory");
210
211
 
212
	bitmap->pitch = -1;
213
214
 
215
};
216
217
 
218
{
219
	struct blit_call bc;
220
	int ret;
221
222
 
223
224
 
225
        return pix_driver.blit(bitmap, 1, 1, dst_x, dst_y, w, h, 0, 0);
4377 Serge 226
4372 Serge 227
 
228
	bc.dsty = dst_y;
229
	bc.w = w;
230
	bc.h = h;
231
	bc.srcx = 0;
232
	bc.srcy = 0;
233
	bc.srcw = w;
234
	bc.srch = h;
235
	bc.stride = sf->pitch;
236
	bc.bitmap = sf->data;
237
238
 
239
    "int $0x40":"=a"(ret):"a"(73), "b"(0x00),
240
	"c"(&bc):"memory");
241
242
 
243
	bitmap->pitch = -1;
244
245
 
246
};
247
248
 
249
{
250
	uint32_t size;
251
	uint32_t pitch;
252
253
 
254
255
 
256
257
 
258
        return pix_driver.resize_bitmap(bitmap);
259
260
 
261
	size = ALIGN(pitch * bitmap->height, 4096);
262
263
 
264
	bitmap->data = (void *) -1;
265
266
 
267
	{
268
		sf->data = user_realloc(sf->data, size);	/* grow buffer */
269
		if (sf->data == NULL)
270
			return -1;
271
272
 
273
	} else if (size < sf->bo_size)
274
		user_unmap(sf->data, size, sf->bo_size - size);	/* unmap unused pages */
275
276
 
277
	sf->height = bitmap->height;
278
	sf->pitch  = pitch;
279
280
 
281
};
282
283
 
284
{
285
    return 0;
286
}
287