Rev 3292 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3248 | Serge | 1 | |
2349 | Serge | 2 | #include |
3248 | Serge | 3 | #include "system.h" |
3068 | serge | 4 | |
2349 | Serge | 5 | |
3068 | serge | 6 | |
2349 | Serge | 7 | |
8 | |||
9 | #define SRV_GET_CAPS 3 |
||
10 | |||
11 | |||
3248 | Serge | 12 | #define SRV_DESTROY_SURFACE 11 |
3068 | serge | 13 | #define SRV_LOCK_SURFACE 12 |
3248 | Serge | 14 | #define SRV_UNLOCK_SURFACE 13 |
3068 | serge | 15 | #define SRV_RESIZE_SURFACE 14 |
16 | #define SRV_BLIT_BITMAP 15 |
||
17 | #define SRV_BLIT_TEXTURE 16 |
||
18 | #define SRV_BLIT_VIDEO 17 |
||
19 | |||
2415 | Serge | 20 | |
3248 | Serge | 21 | |
22 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
||
2349 | Serge | 23 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
24 | |||
25 | |||
3292 | Serge | 26 | void sna_fini(); |
27 | |||
2349 | Serge | 28 | |
3292 | Serge | 29 | void sna_destroy_bitmap(bitmap_t *bitmap); |
30 | void sna_lock_bitmap(bitmap_t *bitmap); |
||
31 | int sna_blit_copy(bitmap_t *src_bitmap, int dst_x, int dst_y, |
||
32 | int w, int h, int src_x, int src_y); |
||
33 | int sna_blit_tex(bitmap_t *src_bitmap, int dst_x, int dst_y, |
||
34 | int w, int h, int src_x, int src_y); |
||
35 | |||
3068 | serge | 36 | |
3292 | Serge | 37 | |
2349 | Serge | 38 | static uint32_t blit_caps; |
39 | static uint32_t screen_width; |
||
3068 | serge | 40 | static uint32_t screen_height; |
41 | |||
2349 | Serge | 42 | |
43 | { |
||
44 | unsigned handle; |
||
3068 | serge | 45 | unsigned io_code; |
46 | void *input; |
||
47 | int inp_size; |
||
48 | void *output; |
||
49 | int out_size; |
||
50 | }ioctl_t; |
||
51 | |||
52 | |||
53 | |||
54 | { |
||
55 | uint32_t idx; |
||
2349 | Serge | 56 | union |
57 | { |
||
58 | uint32_t opt[2]; |
||
59 | struct { |
||
60 | uint32_t max_tex_width; |
||
61 | uint32_t max_tex_height; |
||
62 | }cap1; |
||
63 | }; |
||
64 | }hwcaps_t; |
||
65 | |||
66 | |||
67 | { |
||
68 | uint32_t retval = 0; |
||
69 | asm volatile ("int $0x40" |
||
70 | :"=a"(retval) |
||
71 | :"a"(68),"b"(16),"c"(name) |
||
72 | :"memory"); |
||
73 | |||
74 | |||
75 | }; |
||
76 | |||
77 | |||
78 | { |
||
79 | int retval; |
||
80 | |||
81 | |||
82 | :"=a"(retval) |
||
83 | :"a"(68),"b"(17),"c"(io) |
||
84 | :"memory","cc"); |
||
85 | |||
86 | |||
87 | }; |
||
88 | |||
89 | |||
90 | |||
3248 | Serge | 91 | { |
2349 | Serge | 92 | uint32_t api_version; |
93 | uint32_t screensize; |
||
3068 | serge | 94 | hwcaps_t hwcaps; |
3248 | Serge | 95 | ioctl_t io; |
96 | |||
2349 | Serge | 97 | |
98 | |||
99 | |||
3068 | serge | 100 | screen_width = screensize >> 16; |
101 | screen_height = screensize & 0xFFFF; |
||
102 | |||
103 | |||
2349 | Serge | 104 | if(service == 0) |
105 | goto fail; |
||
106 | |||
107 | |||
108 | io.io_code = SRV_GETVERSION; |
||
109 | io.input = NULL; |
||
110 | io.inp_size = 0; |
||
111 | io.output = &api_version; |
||
112 | io.out_size = BUFFER_SIZE(1); |
||
113 | |||
114 | |||
115 | goto fail; |
||
116 | |||
117 | |||
118 | (DISPLAY_VERSION < (api_version >> 16))) |
||
119 | goto fail; |
||
120 | |||
121 | |||
3292 | Serge | 122 | /* |
2349 | Serge | 123 | * Let's see what this service can do |
124 | */ |
||
125 | hwcaps.idx = 0; |
||
126 | |||
127 | |||
128 | io.io_code = SRV_GET_CAPS; |
||
129 | io.input = &hwcaps; |
||
130 | io.inp_size = sizeof(hwcaps); |
||
131 | io.output = NULL; |
||
132 | io.out_size = 0; |
||
133 | |||
134 | |||
135 | goto fail; |
||
136 | |||
137 | |||
138 | |||
139 | |||
140 | |||
141 | |||
142 | printf("service caps %s%s%s\n", |
||
143 | (blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"", |
||
144 | (blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"", |
||
145 | (blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":""); |
||
146 | #endif |
||
3292 | Serge | 147 | |
2349 | Serge | 148 | |
3292 | Serge | 149 | |
150 | |||
151 | printf("service caps %s%s%s\n", |
||
152 | (blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"", |
||
153 | (blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"", |
||
154 | (blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":""); |
||
155 | |||
156 | |||
2349 | Serge | 157 | |
158 | |||
159 | service = 0; |
||
160 | return 0; |
||
161 | }; |
||
162 | |||
163 | |||
3292 | Serge | 164 | { |
165 | |||
166 | |||
167 | |||
168 | |||
169 | |||
2349 | Serge | 170 | |
3292 | Serge | 171 | |
2349 | Serge | 172 | { |
173 | // __asm__ __volatile__("int3"); |
||
174 | |||
175 | |||
176 | uint32_t pitch; |
||
177 | uint8_t *buffer; |
||
178 | |||
179 | |||
3292 | Serge | 180 | return sna_create_bitmap(bitmap); |
181 | |||
182 | |||
183 | // return sna_create_bitmap(bitmap); |
||
184 | |||
185 | |||
2349 | Serge | 186 | size = pitch * bitmap->height; |
187 | |||
188 | |||
189 | if( buffer ) |
||
190 | { |
||
191 | bitmap->handle = 0; |
||
192 | bitmap->pitch = pitch; |
||
193 | bitmap->data = buffer; |
||
194 | bitmap->flags = 0; |
||
3248 | Serge | 195 | return 0; |
2349 | Serge | 196 | }; |
197 | |||
198 | |||
199 | |||
200 | |||
201 | |||
3292 | Serge | 202 | |
2349 | Serge | 203 | |
204 | |||
3292 | Serge | 205 | { |
206 | if( bitmap->flags & (HW_BIT_BLIT | HW_TEX_BLIT )) |
||
207 | sna_destroy_bitmap(bitmap); |
||
208 | return 0; |
||
209 | }; |
||
210 | |||
211 | |||
2415 | Serge | 212 | { |
213 | // __asm__ __volatile__("int3"); |
||
214 | |||
215 | |||
3292 | Serge | 216 | sna_lock_bitmap(bitmap); |
217 | |||
2415 | Serge | 218 | |
3292 | Serge | 219 | }; |
2415 | Serge | 220 | |
221 | |||
2349 | Serge | 222 | int w, int h) |
223 | { |
||
224 | int err; |
||
3068 | serge | 225 | |
2349 | Serge | 226 | |
3292 | Serge | 227 | return sna_blit_tex(bitmap, dst_x, dst_y, w, h, 0, 0); |
228 | |||
2349 | Serge | 229 | |
230 | |||
3068 | serge | 231 | |
2349 | Serge | 232 | |
233 | bc.dsty = dst_y; |
||
234 | bc.w = w; |
||
235 | bc.h = h; |
||
236 | bc.srcx = 0; |
||
237 | bc.srcy = 0; |
||
238 | bc.srcw = w; |
||
239 | bc.srch = h; |
||
240 | bc.stride = bitmap->pitch; |
||
241 | bc.bitmap = bitmap->data; |
||
242 | |||
243 | |||
244 | "int $0x40" |
||
245 | :"=a"(err) |
||
3068 | serge | 246 | :"a"(73),"b"(0x00),"c"(&bc) |
247 | :"memory"); |
||
2693 | Serge | 248 | |
3248 | Serge | 249 | |
3068 | serge | 250 | }; |
2349 | Serge | 251 | |
252 | |||
253 | { |
||
254 | // __asm__ __volatile__("int3"); |
||
255 | |||
256 | |||
3248 | Serge | 257 | { |
2349 | Serge | 258 | struct __attribute__((packed)) |
3068 | serge | 259 | { |
260 | uint32_t handle; |
||
261 | char *data; |
||
262 | uint32_t new_w; |
||
263 | uint32_t new_h; |
||
264 | uint32_t pitch; |
||
265 | }io_14; |
||
266 | |||
267 | |||
268 | int err; |
||
269 | |||
270 | |||
271 | io_14.new_w = bitmap->width; |
||
272 | io_14.new_h = bitmap->height; |
||
273 | |||
274 | |||
275 | io.io_code = SRV_RESIZE_SURFACE; |
||
276 | io.input = &io_14; |
||
277 | io.inp_size = BUFFER_SIZE(5); |
||
278 | io.output = NULL; |
||
279 | io.out_size = 0; |
||
280 | |||
281 | |||
282 | if(err==0) |
||
283 | { |
||
3248 | Serge | 284 | bitmap->pitch = io_14.pitch; |
3068 | serge | 285 | bitmap->data = io_14.data; |
286 | }; |
||
287 | return err; |
||
288 | }; |
||
2349 | Serge | 289 | |
290 | |||
291 | uint32_t pitch; |
||
292 | uint8_t *buffer; |
||
293 | |||
294 | |||
295 | size = pitch * bitmap->height; |
||
296 | |||
297 | |||
298 | if( buffer ) |
||
299 | { |
||
300 | bitmap->handle = 0; |
||
301 | bitmap->pitch = pitch; |
||
302 | bitmap->data = buffer; |
||
303 | return 0; |
||
304 | }; |
||
305 | |||
306 | |||
307 | |||
308 | |||
309 | };> |
||
310 |