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