1 | #ifndef SH4PORT_H |
---|
2 | #define SH4PORT_H |
---|
3 | |
---|
4 | #include <bpamem.h> |
---|
5 | #include <libmmeimage.h> |
---|
6 | #include <linux/stmfb.h> |
---|
7 | |
---|
8 | void enablemanualblit() |
---|
9 | { |
---|
10 | } |
---|
11 | |
---|
12 | //flag 0 = no animation |
---|
13 | //flag 1 = animation |
---|
14 | void blitfb2(struct fb* fbnode, int flag) |
---|
15 | { |
---|
16 | int i = 0, max = 1, wstep = 0, hstep = 0, ret = 0; |
---|
17 | unsigned char buf[10]; |
---|
18 | |
---|
19 | if(fbnode == NULL) return; |
---|
20 | if(fbnode == fb) return; |
---|
21 | |
---|
22 | if(status.rguidfd > -1) |
---|
23 | { |
---|
24 | m_lock(&status.accelfbmutex, 16); |
---|
25 | |
---|
26 | int zlen = 0; |
---|
27 | char* zbuf = NULL; |
---|
28 | blitscale(0, 0, fbnode->width, fbnode->height, 440, 330, 1); |
---|
29 | ret = zip((char*)accelfb->fb, 440 * 330 * 4, &zbuf, &zlen, 1); |
---|
30 | |
---|
31 | if(ret == 0) |
---|
32 | { |
---|
33 | memset(buf, 0, 10); |
---|
34 | char* tmpnr = oitoa(zlen); |
---|
35 | memcpy(buf, tmpnr, strlen(tmpnr)); |
---|
36 | free(tmpnr); tmpnr = NULL; |
---|
37 | socksend(&status.rguidfd, buf, 10, 5000 * 1000); |
---|
38 | socksend(&status.rguidfd, (unsigned char*)zbuf, zlen, 5000 * 1000); |
---|
39 | } |
---|
40 | free(zbuf); zbuf = NULL; |
---|
41 | zlen = 0; |
---|
42 | |
---|
43 | m_unlock(&status.accelfbmutex, 16); |
---|
44 | } |
---|
45 | |
---|
46 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
47 | { |
---|
48 | m_lock(&status.accelfbmutex, 16); |
---|
49 | blitscale(0, 0, fbnode->width, fbnode->height, 320, 240, 1); |
---|
50 | if(writeFBfile.ActBuf == NULL) |
---|
51 | { |
---|
52 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
53 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
54 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
55 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
56 | } |
---|
57 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
58 | { |
---|
59 | if(writeFBfile.buf2 == NULL) |
---|
60 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
61 | memcpy(writeFBfile.buf2, accelfb->fb, 4 * 320 * 240); |
---|
62 | } |
---|
63 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
64 | { |
---|
65 | if(writeFBfile.buf1 == NULL) |
---|
66 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
67 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
68 | } |
---|
69 | m_unlock(&status.accelfbmutex, 16); |
---|
70 | } |
---|
71 | |
---|
72 | int mode3d = 0; |
---|
73 | char* mode3dstr = NULL; |
---|
74 | |
---|
75 | if(status.leftoffset != 0) blitrect(0, 0, status.leftoffset, fb->height, 0, 255, 2); |
---|
76 | if(status.rightoffset != 0) blitrect(fb->width - status.rightoffset, 0, status.rightoffset, fb->height, 0, 255, 2); |
---|
77 | if(status.topoffset != 0) blitrect(0, 0, fb->width, status.topoffset, 0, 255, 2); |
---|
78 | if(status.bottomoffset != 0) blitrect(0, fb->height - status.bottomoffset, fb->width, status.bottomoffset, 0, 255, 2); |
---|
79 | |
---|
80 | mode3dstr = getconfig("av_mode3d", NULL); |
---|
81 | if(ostrcmp(mode3dstr, "sbs") == 0) |
---|
82 | mode3d = 1; |
---|
83 | else if(ostrcmp(mode3dstr, "tab") == 0) |
---|
84 | mode3d = 2; |
---|
85 | |
---|
86 | STMFBIO_BLT_DATA bltData; |
---|
87 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
88 | |
---|
89 | bltData.operation = BLT_OP_COPY; |
---|
90 | bltData.srcOffset = fbnode->fb - fb->fb; |
---|
91 | bltData.srcPitch = fbnode->pitch; |
---|
92 | bltData.src_top = 0; |
---|
93 | bltData.src_left = 0; |
---|
94 | bltData.src_right = fbnode->width; |
---|
95 | bltData.src_bottom = fbnode->height; |
---|
96 | bltData.srcFormat = SURF_BGRA8888; |
---|
97 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
98 | |
---|
99 | bltData.dstOffset = 0; |
---|
100 | bltData.dstPitch = fb->pitch; |
---|
101 | bltData.dst_left = status.leftoffset; |
---|
102 | bltData.dst_top = status.topoffset; |
---|
103 | if(mode3d == 1) |
---|
104 | bltData.dst_right = (fb->width - status.rightoffset) / 2; |
---|
105 | else |
---|
106 | bltData.dst_right = fb->width - status.rightoffset; |
---|
107 | if(mode3d == 2) |
---|
108 | bltData.dst_bottom = (fb->height - status.bottomoffset) / 2; |
---|
109 | else |
---|
110 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
111 | bltData.dstFormat = SURF_BGRA8888; |
---|
112 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
113 | |
---|
114 | if(flag == 1 && status.screenanim > 0 && mode3d == 0) |
---|
115 | { |
---|
116 | int width = (fb->width - status.rightoffset) - status.leftoffset; |
---|
117 | int height = (fb->height - status.topoffset) - status.bottomoffset; |
---|
118 | max = 25; |
---|
119 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
120 | { |
---|
121 | bltData.dst_left = (width / 2) - 1; |
---|
122 | bltData.dst_right = (width / 2) + 1; |
---|
123 | } |
---|
124 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
125 | { |
---|
126 | bltData.dst_top = (height / 2) - 1; |
---|
127 | bltData.dst_bottom = (height / 2) + 1; |
---|
128 | } |
---|
129 | wstep = width / max; |
---|
130 | hstep = height / max; |
---|
131 | } |
---|
132 | |
---|
133 | for(i = 0; i < max; i++) |
---|
134 | { |
---|
135 | |
---|
136 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
137 | { |
---|
138 | int tmpleft = bltData.dst_left - wstep; |
---|
139 | int tmpright = bltData.dst_right + wstep; |
---|
140 | if(tmpleft < status.leftoffset) |
---|
141 | tmpleft = status.leftoffset; |
---|
142 | if(tmpright > fb->width - status.rightoffset) |
---|
143 | tmpright = fb->width - status.rightoffset; |
---|
144 | bltData.dst_left = tmpleft; |
---|
145 | bltData.dst_right = tmpright; |
---|
146 | } |
---|
147 | |
---|
148 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
149 | { |
---|
150 | int tmptop = bltData.dst_top - hstep; |
---|
151 | int tmpbottom = bltData.dst_bottom + hstep; |
---|
152 | if(tmptop < status.topoffset) |
---|
153 | tmptop = status.topoffset; |
---|
154 | if(tmpbottom > fb->height - status.bottomoffset) |
---|
155 | tmpbottom = fb->height - status.bottomoffset; |
---|
156 | bltData.dst_top = tmptop; |
---|
157 | bltData.dst_bottom = tmpbottom; |
---|
158 | } |
---|
159 | |
---|
160 | if(status.screenanim > 0) usleep(status.screenanimspeed * 1000); |
---|
161 | |
---|
162 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
163 | { |
---|
164 | perr("ioctl STMFBIO_BLT"); |
---|
165 | } |
---|
166 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
167 | { |
---|
168 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
169 | } |
---|
170 | |
---|
171 | if(mode3d != 0) |
---|
172 | { |
---|
173 | if(mode3d == 1) |
---|
174 | bltData.dst_left = 0 + status.leftoffset + ((fb->width - status.rightoffset) / 2); |
---|
175 | if(mode3d == 2) |
---|
176 | bltData.dst_top = 0 + status.topoffset + ((fb->height - status.bottomoffset) / 2); |
---|
177 | bltData.dst_right = fb->width - status.rightoffset; |
---|
178 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
179 | |
---|
180 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
181 | { |
---|
182 | perr("ioctl STMFBIO_BLT"); |
---|
183 | } |
---|
184 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
185 | { |
---|
186 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
187 | } |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | |
---|
192 | void setfbtransparent(int value) |
---|
193 | { |
---|
194 | struct stmfbio_var_screeninfo_ex varEx = {0}; |
---|
195 | |
---|
196 | varEx.layerid = 0; |
---|
197 | varEx.activate = STMFBIO_ACTIVATE_IMMEDIATE; |
---|
198 | varEx.caps = STMFBIO_VAR_CAPS_OPACITY; |
---|
199 | varEx.opacity = value; |
---|
200 | |
---|
201 | |
---|
202 | if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &varEx) < 0) |
---|
203 | perr("STMFBIO_SET_VAR_SCREENINFO_EX"); |
---|
204 | } |
---|
205 | |
---|
206 | int allocbpamem(size_t size, int *memfd, unsigned char **mem) |
---|
207 | { |
---|
208 | *memfd = open("/dev/bpamem0", O_RDWR); |
---|
209 | |
---|
210 | if(*memfd < 0) |
---|
211 | { |
---|
212 | err("cannot access /dev/bpamem0! err = %d", (int)*memfd); |
---|
213 | return -1; |
---|
214 | } |
---|
215 | |
---|
216 | BPAMemAllocMemData bpa_data; |
---|
217 | bpa_data.bpa_part = "LMI_VID"; |
---|
218 | bpa_data.mem_size = size; |
---|
219 | int res; |
---|
220 | res = ioctl(*memfd, BPAMEMIO_ALLOCMEM, &bpa_data); // request memory from bpamem |
---|
221 | if(res) |
---|
222 | { |
---|
223 | err("cannot alloc required bpa mem"); |
---|
224 | close(*memfd); |
---|
225 | return -1; |
---|
226 | } |
---|
227 | |
---|
228 | char* bpa_mem_device = NULL; |
---|
229 | bpa_mem_device = malloc(30); |
---|
230 | if(bpa_mem_device == NULL) |
---|
231 | { |
---|
232 | err("no mem"); |
---|
233 | return -1; |
---|
234 | } |
---|
235 | |
---|
236 | sprintf(bpa_mem_device, "/dev/bpamem%d", bpa_data.device_num); |
---|
237 | close(*memfd); |
---|
238 | |
---|
239 | *memfd = open(bpa_mem_device, O_RDWR); |
---|
240 | |
---|
241 | if(*memfd < 0) |
---|
242 | { |
---|
243 | free(bpa_mem_device); |
---|
244 | err("cannot access %s! err = %d", bpa_mem_device, (int)*memfd); |
---|
245 | return -1; |
---|
246 | } |
---|
247 | |
---|
248 | *mem = (unsigned char *)mmap(0, bpa_data.mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, *memfd, 0); |
---|
249 | |
---|
250 | if(*mem == MAP_FAILED) |
---|
251 | { |
---|
252 | err("could not map bpa mem"); |
---|
253 | free(bpa_mem_device); |
---|
254 | ioctl(*memfd, BPAMEMIO_FREEMEM); |
---|
255 | close(*memfd); |
---|
256 | return -1; |
---|
257 | } |
---|
258 | |
---|
259 | free(bpa_mem_device); |
---|
260 | return 0; |
---|
261 | } |
---|
262 | |
---|
263 | void freebpamem(int memfd, unsigned char* mem, size_t len) |
---|
264 | { |
---|
265 | munmap(mem, len); |
---|
266 | ioctl(memfd, BPAMEMIO_FREEMEM); |
---|
267 | close(memfd); |
---|
268 | } |
---|
269 | |
---|
270 | //mode 0: with fill (draw to skinfb) |
---|
271 | //mode 1: without fill (draw to skinfb) |
---|
272 | //mode 2: with fill (draw to fb) |
---|
273 | //mode 3: without fill (draw to fb) |
---|
274 | void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode) |
---|
275 | { |
---|
276 | unsigned long tmpcol; |
---|
277 | |
---|
278 | transparent = (transparent - 255) * -1; |
---|
279 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
280 | |
---|
281 | STMFBIO_BLT_DATA bltData; |
---|
282 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
283 | |
---|
284 | if(posx < 0) posx = 0; |
---|
285 | if(posy < 0) posy = 0; |
---|
286 | if(mode < 2) |
---|
287 | { |
---|
288 | if(posx > skinfb->width) posx = skinfb->width; |
---|
289 | if(posy > skinfb->height) posy = skinfb->height; |
---|
290 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
291 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
292 | } |
---|
293 | else |
---|
294 | { |
---|
295 | if(posx > fb->width) posx = fb->width; |
---|
296 | if(posy > fb->height) posy = fb->height; |
---|
297 | if(posx + width > fb->width) width = fb->width - posx; |
---|
298 | if(posy + height > fb->height) height = fb->height - posy; |
---|
299 | } |
---|
300 | |
---|
301 | if(width <= 0 || height <= 0) return; |
---|
302 | |
---|
303 | if(mode == 0 || mode == 2) |
---|
304 | bltData.operation = BLT_OP_FILL; |
---|
305 | else if(mode == 1 || mode == 3) |
---|
306 | bltData.operation = BLT_OP_DRAW_RECTANGLE; |
---|
307 | bltData.colour = tmpcol; |
---|
308 | bltData.srcFormat = SURF_ARGB8888; |
---|
309 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
310 | |
---|
311 | if(status.usedirectfb == 1) |
---|
312 | bltData.dstOffset = 0; |
---|
313 | else |
---|
314 | { |
---|
315 | if(mode < 2) |
---|
316 | bltData.dstOffset = fb->varfbsize; |
---|
317 | else |
---|
318 | bltData.dstOffset = 0; |
---|
319 | } |
---|
320 | if(mode < 2) |
---|
321 | bltData.dstPitch = skinfb->pitch; |
---|
322 | else |
---|
323 | bltData.dstPitch = fb->pitch; |
---|
324 | bltData.dst_top = posy; |
---|
325 | bltData.dst_left = posx; |
---|
326 | bltData.dst_bottom = posy + height; |
---|
327 | bltData.dst_right = posx + width; |
---|
328 | bltData.dstFormat = SURF_ARGB8888; |
---|
329 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
330 | |
---|
331 | if(ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
332 | { |
---|
333 | perr("ioctl STMFBIO_BLT"); |
---|
334 | } |
---|
335 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
336 | { |
---|
337 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
338 | } |
---|
339 | } |
---|
340 | |
---|
341 | int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd) |
---|
342 | { |
---|
343 | FILE *fp; |
---|
344 | unsigned int temp1, temp2, temp3, temp4; |
---|
345 | |
---|
346 | if(filename == NULL) return -1; |
---|
347 | |
---|
348 | debug(200, "hardware decode picture (%s)...", filename); |
---|
349 | |
---|
350 | if (!(fp = fopen(filename, "rb"))) |
---|
351 | return -1; |
---|
352 | |
---|
353 | if(get_jpeg_img_size(fp, &temp1, &temp2) != LIBMMEIMG_SUCCESS) |
---|
354 | return -1; |
---|
355 | |
---|
356 | *width = temp1; |
---|
357 | *height = temp2; |
---|
358 | *channels = 3; |
---|
359 | *rowbytes = *channels * temp1; |
---|
360 | |
---|
361 | if(allocbpamem(temp1 * temp2 * (*channels), memfd, mem) != 0) |
---|
362 | { |
---|
363 | fclose(fp); |
---|
364 | return -1; |
---|
365 | } |
---|
366 | |
---|
367 | temp3 = temp1; |
---|
368 | temp4 = temp2; |
---|
369 | |
---|
370 | if(temp3 > skinfb->width) temp3 = skinfb->width; |
---|
371 | if(temp4 > skinfb->height) temp4 = skinfb->height; |
---|
372 | |
---|
373 | if(decode_jpeg_noalloc(fp, temp1, temp2, 200, 200, (char *)*mem, 1) == LIBMMEIMG_SUCCESS) |
---|
374 | { |
---|
375 | fclose(fp); |
---|
376 | return 0; |
---|
377 | } |
---|
378 | |
---|
379 | fclose(fp); |
---|
380 | freebpamem(*memfd, *mem, temp1 * temp2 * (*channels)); |
---|
381 | err("hardware decode error"); |
---|
382 | |
---|
383 | return -1; |
---|
384 | } |
---|
385 | |
---|
386 | //flag 0: blit from accelfb to skinfb |
---|
387 | //flag 1: blit from skinfb to accelfb |
---|
388 | void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag) |
---|
389 | { |
---|
390 | STMFBIO_BLT_DATA blt_data; |
---|
391 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
392 | |
---|
393 | if(scalewidth == 0) scalewidth = width; |
---|
394 | if(scaleheight == 0) scaleheight = height; |
---|
395 | |
---|
396 | if(posx < 0) posx = 0; |
---|
397 | if(posx > skinfb->width) posx = skinfb->width; |
---|
398 | if(posy < 0) posy = 0; |
---|
399 | if(posy > skinfb->height) posy = skinfb->height; |
---|
400 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
401 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
402 | |
---|
403 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
404 | |
---|
405 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
406 | { |
---|
407 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
408 | return; |
---|
409 | } |
---|
410 | |
---|
411 | blt_data.operation = BLT_OP_COPY; |
---|
412 | |
---|
413 | if(flag == 0) |
---|
414 | { |
---|
415 | if(status.usedirectfb == 1) |
---|
416 | blt_data.srcOffset = fb->varfbsize; |
---|
417 | else |
---|
418 | blt_data.srcOffset = fb->varfbsize + skinfb->varfbsize; |
---|
419 | } |
---|
420 | else |
---|
421 | { |
---|
422 | if(status.usedirectfb == 1) |
---|
423 | blt_data.srcOffset = 0; |
---|
424 | else |
---|
425 | blt_data.srcOffset = fb->varfbsize; |
---|
426 | } |
---|
427 | |
---|
428 | blt_data.srcPitch = width * 4; |
---|
429 | blt_data.src_top = 0; |
---|
430 | blt_data.src_left = 0; |
---|
431 | blt_data.src_right = width; |
---|
432 | blt_data.src_bottom = height; |
---|
433 | blt_data.srcFormat = SURF_ARGB8888; |
---|
434 | blt_data.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
435 | |
---|
436 | if(flag == 0) |
---|
437 | { |
---|
438 | if(status.usedirectfb == 1) |
---|
439 | { |
---|
440 | blt_data.dstOffset = 0; |
---|
441 | blt_data.dstPitch = fb->pitch; |
---|
442 | } |
---|
443 | else |
---|
444 | { |
---|
445 | blt_data.dstOffset = fb->varfbsize; |
---|
446 | blt_data.dstPitch = skinfb->pitch; |
---|
447 | } |
---|
448 | } |
---|
449 | else |
---|
450 | { |
---|
451 | if(status.usedirectfb == 1) |
---|
452 | { |
---|
453 | blt_data.dstOffset = fb->varfbsize; |
---|
454 | blt_data.dstPitch = skinfb->pitch; |
---|
455 | } |
---|
456 | else |
---|
457 | { |
---|
458 | blt_data.dstOffset = fb->varfbsize + skinfb->varfbsize; |
---|
459 | blt_data.dstPitch = scalewidth * 4; |
---|
460 | } |
---|
461 | } |
---|
462 | |
---|
463 | blt_data.dst_left = posx; |
---|
464 | blt_data.dst_top = posy; |
---|
465 | blt_data.dst_right = posx + scalewidth; |
---|
466 | blt_data.dst_bottom = posy + scaleheight; |
---|
467 | blt_data.dstFormat = SURF_ARGB8888; |
---|
468 | blt_data.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
469 | |
---|
470 | if (ioctl(fb->fd, STMFBIO_BLT, &blt_data) < 0) |
---|
471 | { |
---|
472 | perr("ioctl STMFBIO_BLT"); |
---|
473 | } |
---|
474 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
475 | { |
---|
476 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
477 | } |
---|
478 | } |
---|
479 | |
---|
480 | void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight, int mwidth, int mheight, int halign, int valign) |
---|
481 | { |
---|
482 | STMFBIO_BLT_EXTERN_DATA blt_data; |
---|
483 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); |
---|
484 | |
---|
485 | //auto scale to mwidth / mheight |
---|
486 | if(scalewidth == 1 && scaleheight == 1) |
---|
487 | calcautoscale(width, height, mwidth, mheight, &scalewidth, &scaleheight); |
---|
488 | |
---|
489 | if(scalewidth == 0) scalewidth = width; |
---|
490 | if(scaleheight == 0) scaleheight = height; |
---|
491 | |
---|
492 | if(scalewidth > mwidth) scalewidth = mwidth; |
---|
493 | if(scaleheight > mheight) scaleheight = mheight; |
---|
494 | |
---|
495 | if(halign == CENTER) |
---|
496 | posx += mwidth / 2 - width / 2; |
---|
497 | else if(halign == RIGHT) |
---|
498 | posx += mwidth - width; |
---|
499 | if(valign == MIDDLE) |
---|
500 | posy += mheight / 2 - height / 2; |
---|
501 | else if(valign == BOTTOM) |
---|
502 | posy += mheight - height; |
---|
503 | |
---|
504 | blt_data.operation = BLT_OP_COPY; |
---|
505 | blt_data.ulFlags = 0; |
---|
506 | blt_data.srcOffset = 0; |
---|
507 | blt_data.srcPitch = width * 3; |
---|
508 | blt_data.dstOffset = 0; |
---|
509 | blt_data.dstPitch = skinfb->pitch; |
---|
510 | blt_data.src_top = 0; |
---|
511 | blt_data.src_left = 0; |
---|
512 | blt_data.src_right = width; |
---|
513 | blt_data.src_bottom = height; |
---|
514 | blt_data.dst_left = posx; |
---|
515 | blt_data.dst_top = posy; |
---|
516 | |
---|
517 | blt_data.dst_right = posx + scalewidth; |
---|
518 | blt_data.dst_bottom = posy + scaleheight; |
---|
519 | blt_data.srcFormat = SURF_BGR888; |
---|
520 | blt_data.dstFormat = SURF_ARGB8888; |
---|
521 | blt_data.srcMemBase = (char *)buf; |
---|
522 | blt_data.dstMemBase = (char *)skinfb->fb; |
---|
523 | blt_data.srcMemSize = width * height * 3; |
---|
524 | blt_data.dstMemSize = skinfb->pitch * skinfb->height; |
---|
525 | |
---|
526 | if(ioctl(skinfb->fd, STMFBIO_BLT_EXTERN, &blt_data) < 0) |
---|
527 | { |
---|
528 | err("ioctl STMFBIO_BLT_EXTERN"); |
---|
529 | } |
---|
530 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
531 | { |
---|
532 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
533 | } |
---|
534 | } |
---|
535 | |
---|
536 | void sighandler(int sig, struct sigcontext ctx) |
---|
537 | { |
---|
538 | debug(1000, "in"); |
---|
539 | switch(sig) |
---|
540 | { |
---|
541 | case SIGUSR1: |
---|
542 | { |
---|
543 | //todo all configs |
---|
544 | reloadconfig(status.configfile); |
---|
545 | reloadconfig(getconfig("ownconfig", NULL)); |
---|
546 | break; |
---|
547 | } |
---|
548 | case SIGSEGV: |
---|
549 | case SIGBUS: |
---|
550 | case SIGABRT: |
---|
551 | { |
---|
552 | /* sh4 |
---|
553 | unsigned long sc_regs[16]; |
---|
554 | unsigned long sc_pc; //programm counter register |
---|
555 | unsigned long sc_pr; //procedure register |
---|
556 | unsigned long sc_sr; //status register |
---|
557 | unsigned long sc_gbr; |
---|
558 | unsigned long sc_mach; |
---|
559 | unsigned long sc_macl; */ |
---|
560 | |
---|
561 | debugstack((void *)ctx.sc_pr, (void *)ctx.sc_pc); |
---|
562 | err("got signal %d, programm counter reg: 0x%lx, procedure reg: 0x%lx", sig, ctx.sc_pc, ctx.sc_pr); |
---|
563 | |
---|
564 | if(getconfigint("saverun", NULL) == 1 && status.longjumpbuf != NULL) |
---|
565 | siglongjmp(status.longjumpbuf, 1); |
---|
566 | else |
---|
567 | exit(100); |
---|
568 | break; |
---|
569 | } |
---|
570 | } |
---|
571 | debug(1000, "out"); |
---|
572 | } |
---|
573 | |
---|
574 | #endif |
---|