1 | #ifndef MIPSELPORT_H |
---|
2 | #define MIPSELPORT_H |
---|
3 | |
---|
4 | #ifndef FBIO_BLIT |
---|
5 | //#define FBIO_SET_MANUAL_BLIT _IOW('F', 0x20, __u32) |
---|
6 | #define FBIO_SET_MANUAL_BLIT _IOW('F', 0x21, __u8) |
---|
7 | #define FBIO_BLIT 0x22 |
---|
8 | #endif |
---|
9 | |
---|
10 | #ifndef FBIO_WAITFORVSYNC |
---|
11 | #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32) |
---|
12 | #endif |
---|
13 | |
---|
14 | unsigned char *lfb = NULL; |
---|
15 | int g_manual_blit = 0; |
---|
16 | struct fb_fix_screeninfo fix_screeninfo; |
---|
17 | struct fb_var_screeninfo var_screeninfo; |
---|
18 | |
---|
19 | int setmixer(struct dvbdev* node, int left, int right) |
---|
20 | { |
---|
21 | return audiosetmixer(node, left, right); |
---|
22 | } |
---|
23 | |
---|
24 | int setencoding(struct channel* chnode, struct dvbdev* videonode) |
---|
25 | { |
---|
26 | int ret = 1; |
---|
27 | if(chnode == NULL) return ret; |
---|
28 | |
---|
29 | switch(chnode->videocodec) |
---|
30 | { |
---|
31 | case MPEGV: |
---|
32 | ret = videosetstreamtype(videonode, 0); |
---|
33 | break; |
---|
34 | case MPEG4V: |
---|
35 | ret = videosetstreamtype(videonode, 4); |
---|
36 | break; |
---|
37 | case H264: |
---|
38 | ret = videosetstreamtype(videonode, 1); |
---|
39 | break; |
---|
40 | case VC1: |
---|
41 | ret = videosetstreamtype(videonode, 3); |
---|
42 | break; |
---|
43 | default: |
---|
44 | ret = videosetstreamtype(videonode, 0); |
---|
45 | } |
---|
46 | return ret; |
---|
47 | } |
---|
48 | |
---|
49 | int videodiscontinuityskip(struct dvbdev* node, int flag) |
---|
50 | { |
---|
51 | return 0; |
---|
52 | } |
---|
53 | |
---|
54 | void fbsave() |
---|
55 | { |
---|
56 | } |
---|
57 | |
---|
58 | void fbrestore() |
---|
59 | { |
---|
60 | } |
---|
61 | |
---|
62 | void setfbvarsize(struct fb* newnode) |
---|
63 | { |
---|
64 | if(newnode != NULL) |
---|
65 | newnode->varfbsize = 1920 * 1080 * newnode->colbytes; |
---|
66 | // newnode->varfbsize = 1920 * 1080 * (newnode->colbytes * 8); |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | void enablemanualblit() |
---|
71 | { |
---|
72 | unsigned char tmp = 1; |
---|
73 | if (ioctl(fb->fd, FBIO_SET_MANUAL_BLIT, &tmp)<0) |
---|
74 | perror("FBIO_SET_MANUAL_BLIT"); |
---|
75 | else |
---|
76 | g_manual_blit = 1; |
---|
77 | } |
---|
78 | |
---|
79 | void disablemanualblit() |
---|
80 | { |
---|
81 | unsigned char tmp = 0; |
---|
82 | if (ioctl(fb->fd, FBIO_SET_MANUAL_BLIT, &tmp)<0) |
---|
83 | perror("FBIO_SET_MANUAL_BLIT"); |
---|
84 | else |
---|
85 | g_manual_blit = 0; |
---|
86 | } |
---|
87 | |
---|
88 | void blit() |
---|
89 | { |
---|
90 | if (g_manual_blit == 1) { |
---|
91 | if (ioctl(fb->fd, FBIO_BLIT) < 0) |
---|
92 | perror("FBIO_BLIT"); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | int waitvsync() |
---|
97 | { |
---|
98 | int c = 0; |
---|
99 | return ioctl(fb->fd, FBIO_WAITFORVSYNC, &c); |
---|
100 | } |
---|
101 | |
---|
102 | void fbsetoffset(int x, int y) |
---|
103 | { |
---|
104 | struct fb_var_screeninfo var_screeninfo; |
---|
105 | |
---|
106 | var_screeninfo.xoffset = x; |
---|
107 | var_screeninfo.yoffset = y; |
---|
108 | |
---|
109 | if(ioctl(fb->fd, FBIOPAN_DISPLAY, &var_screeninfo) < 0) |
---|
110 | { |
---|
111 | perr("FBIOPAN_DISPLAY"); |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | //flag 0 = no animation |
---|
116 | //flag 1 = animation |
---|
117 | void blitfb2(struct fb* fbnode, int flag) |
---|
118 | { |
---|
119 | struct fb_var_screeninfo var_screeninfo; |
---|
120 | |
---|
121 | var_screeninfo.xres_virtual = fb->width; |
---|
122 | var_screeninfo.xres = fb->width; |
---|
123 | var_screeninfo.yres_virtual = fb->height * 2; |
---|
124 | var_screeninfo.yres = fb->height; |
---|
125 | var_screeninfo.height = 0; |
---|
126 | var_screeninfo.width = 0; |
---|
127 | var_screeninfo.xoffset = 0; |
---|
128 | var_screeninfo.yoffset = 0; |
---|
129 | var_screeninfo.bits_per_pixel = fb->colbytes * 8; |
---|
130 | |
---|
131 | switch(fb->colbytes) |
---|
132 | { |
---|
133 | case 2: |
---|
134 | var_screeninfo.transp.offset = 15; |
---|
135 | var_screeninfo.transp.length = 1; |
---|
136 | var_screeninfo.red.offset = 10; |
---|
137 | var_screeninfo.red.length = 5; |
---|
138 | var_screeninfo.green.offset = 5; |
---|
139 | var_screeninfo.green.length = 5; |
---|
140 | var_screeninfo.blue.offset = 0; |
---|
141 | var_screeninfo.blue.length = 5; |
---|
142 | break; |
---|
143 | case 4: |
---|
144 | var_screeninfo.transp.offset = 24; |
---|
145 | var_screeninfo.transp.length = 8; |
---|
146 | var_screeninfo.red.offset = 16; |
---|
147 | var_screeninfo.red.length = 8; |
---|
148 | var_screeninfo.green.offset = 8; |
---|
149 | var_screeninfo.green.length = 8; |
---|
150 | var_screeninfo.blue.offset = 0; |
---|
151 | var_screeninfo.blue.length = 8; |
---|
152 | break; |
---|
153 | } |
---|
154 | |
---|
155 | debug(100, "FB: line_length %d", fix_screeninfo.line_length); |
---|
156 | debug(100, "FB: var_screeninfo.xres %d", var_screeninfo.xres); |
---|
157 | debug(100, "FB: var_screeninfo.yres %d", var_screeninfo.yres); |
---|
158 | debug(100, "FB: var_screeninfo.xres_virt %d", var_screeninfo.xres_virtual); |
---|
159 | debug(100, "FB: var_screeninfo.yres_virt %d", var_screeninfo.yres_virtual); |
---|
160 | debug(100, "FB: var_screeninfo.xoffset %d", var_screeninfo.xoffset); |
---|
161 | debug(100, "FB: var_screeninfo.yoffset %d", var_screeninfo.yoffset); |
---|
162 | debug(100, "FB: var_screeninfo.bits_per_pixel %d", var_screeninfo.bits_per_pixel); |
---|
163 | debug(100, "FB: var_screeninfo.grayscale %d", var_screeninfo.grayscale); |
---|
164 | |
---|
165 | if(ioctl(fb->fd, FBIOPUT_VSCREENINFO, &var_screeninfo) < 0) |
---|
166 | { |
---|
167 | var_screeninfo.yres_virtual = fb->height; |
---|
168 | if(ioctl(fb->fd, FBIOPUT_VSCREENINFO, &var_screeninfo) < 0) |
---|
169 | { |
---|
170 | perr("FBIOPUT_VSCREENINFO"); |
---|
171 | } |
---|
172 | debug(100, "FB: double buffering not available"); |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | debug(100, "FB: double buffering available!"); |
---|
177 | } |
---|
178 | |
---|
179 | ioctl(fb->fd, FBIOGET_VSCREENINFO, &var_screeninfo); |
---|
180 | // if ((var_screeninfo.xres!=fb->width) && (var_screeninfo.yres!=fb->height) && (var_screeninfo.bits_per_pixel!=fb->colbytes)) |
---|
181 | // { |
---|
182 | debug(100, "SetMode failed: wanted: %dx%dx%d, got %dx%dx%d", |
---|
183 | fb->width, fb->height, fb->colbytes, |
---|
184 | var_screeninfo.xres, var_screeninfo.yres, var_screeninfo.bits_per_pixel); |
---|
185 | // } |
---|
186 | /* |
---|
187 | int xRes, yRes, stride, bpp; |
---|
188 | |
---|
189 | xRes=var_screeninfo.xres; |
---|
190 | yRes=var_screeninfo.yres; |
---|
191 | bpp=var_screeninfo.bits_per_pixel; |
---|
192 | // fb_fix_screeninfo fix; |
---|
193 | // struct fb_fix_screeninfo fix_screeninfo; |
---|
194 | if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fix_screeninfo)<0) |
---|
195 | { |
---|
196 | perror("FBIOGET_FSCREENINFO"); |
---|
197 | printf("fb failed\n"); |
---|
198 | } |
---|
199 | stride=fix_screeninfo.line_length; |
---|
200 | memset(lfb, 0, stride*yRes); |
---|
201 | */ |
---|
202 | blit(); |
---|
203 | |
---|
204 | /* |
---|
205 | int i = 0, max = 1, wstep = 0, hstep = 0, ret = 0; |
---|
206 | unsigned char buf[10]; |
---|
207 | |
---|
208 | if(fbnode == NULL) return; |
---|
209 | #ifndef NOHWBLIT |
---|
210 | if(fbnode == fb) return; |
---|
211 | |
---|
212 | if(status.rguidfd > -1) |
---|
213 | { |
---|
214 | m_lock(&status.accelfbmutex, 16); |
---|
215 | |
---|
216 | int zlen = 0; |
---|
217 | char* zbuf = NULL; |
---|
218 | blitscale(0, 0, fbnode->width, fbnode->height, 440, 330, 1); |
---|
219 | ret = ozip((char*)accelfb->fb, 440 * 330 * 4, &zbuf, &zlen, 1); |
---|
220 | |
---|
221 | if(ret == 0) |
---|
222 | { |
---|
223 | memset(buf, 0, 10); |
---|
224 | char* tmpnr = oitoa(zlen); |
---|
225 | memcpy(buf, tmpnr, strlen(tmpnr)); |
---|
226 | free(tmpnr); tmpnr = NULL; |
---|
227 | socksend(&status.rguidfd, buf, 10, 5000 * 1000); |
---|
228 | socksend(&status.rguidfd, (unsigned char*)zbuf, zlen, 5000 * 1000); |
---|
229 | } |
---|
230 | free(zbuf); zbuf = NULL; |
---|
231 | zlen = 0; |
---|
232 | |
---|
233 | m_unlock(&status.accelfbmutex, 16); |
---|
234 | } |
---|
235 | |
---|
236 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
237 | { |
---|
238 | m_lock(&status.accelfbmutex, 16); |
---|
239 | blitscale(0, 0, fbnode->width, fbnode->height, 320, 240, 1); |
---|
240 | if(writeFBfile.ActBuf == NULL) |
---|
241 | { |
---|
242 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
243 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
244 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
245 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
246 | } |
---|
247 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
248 | { |
---|
249 | if(writeFBfile.buf2 == NULL) |
---|
250 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
251 | memcpy(writeFBfile.buf2, accelfb->fb, 4 * 320 * 240); |
---|
252 | } |
---|
253 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
254 | { |
---|
255 | if(writeFBfile.buf1 == NULL) |
---|
256 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
257 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
258 | } |
---|
259 | m_unlock(&status.accelfbmutex, 16); |
---|
260 | } |
---|
261 | |
---|
262 | int mode3d = 0, leftoffset = 0, rightoffset = 0, topoffset = 0, bottomoffset = 0; |
---|
263 | char* mode3dstr = NULL; |
---|
264 | |
---|
265 | if(status.leftoffset != 0) blitrect(0, 0, status.leftoffset, fb->height, 0, 255, 2); |
---|
266 | if(status.rightoffset != 0) blitrect(fb->width - status.rightoffset, 0, status.rightoffset, fb->height, 0, 255, 2); |
---|
267 | if(status.topoffset != 0) blitrect(0, 0, fb->width, status.topoffset, 0, 255, 2); |
---|
268 | if(status.bottomoffset != 0) blitrect(0, fb->height - status.bottomoffset, fb->width, status.bottomoffset, 0, 255, 2); |
---|
269 | |
---|
270 | mode3dstr = getconfig("av_mode3d", NULL); |
---|
271 | if(ostrcmp(mode3dstr, "sbs") == 0) |
---|
272 | mode3d = 1; |
---|
273 | else if(ostrcmp(mode3dstr, "tab") == 0) |
---|
274 | mode3d = 2; |
---|
275 | |
---|
276 | STMFBIO_BLT_DATA bltData; |
---|
277 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
278 | |
---|
279 | bltData.operation = BLT_OP_COPY; |
---|
280 | bltData.srcOffset = fbnode->fb - fb->fb; |
---|
281 | bltData.srcPitch = fbnode->pitch; |
---|
282 | bltData.src_top = 0; |
---|
283 | bltData.src_left = 0; |
---|
284 | bltData.src_right = fbnode->width; |
---|
285 | bltData.src_bottom = fbnode->height; |
---|
286 | bltData.srcFormat = SURF_BGRA8888; |
---|
287 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
288 | |
---|
289 | bltData.dstOffset = 0; |
---|
290 | bltData.dstPitch = fb->pitch; |
---|
291 | bltData.dst_left = status.leftoffset; |
---|
292 | bltData.dst_top = status.topoffset; |
---|
293 | if(mode3d == 1) |
---|
294 | bltData.dst_right = (fb->width - status.rightoffset) / 2; |
---|
295 | else |
---|
296 | bltData.dst_right = fb->width - status.rightoffset; |
---|
297 | if(mode3d == 2) |
---|
298 | bltData.dst_bottom = (fb->height - status.bottomoffset) / 2; |
---|
299 | else |
---|
300 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
301 | bltData.dstFormat = SURF_BGRA8888; |
---|
302 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
303 | |
---|
304 | if(flag == 1 && status.screenanim > 0 && mode3d == 0) |
---|
305 | { |
---|
306 | int width = (fb->width - status.rightoffset) - status.leftoffset; |
---|
307 | int height = (fb->height - status.topoffset) - status.bottomoffset; |
---|
308 | max = 25; |
---|
309 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
310 | { |
---|
311 | bltData.dst_left = (width / 2) - 1; |
---|
312 | bltData.dst_right = (width / 2) + 1; |
---|
313 | } |
---|
314 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
315 | { |
---|
316 | bltData.dst_top = (height / 2) - 1; |
---|
317 | bltData.dst_bottom = (height / 2) + 1; |
---|
318 | } |
---|
319 | wstep = width / max; |
---|
320 | hstep = height / max; |
---|
321 | } |
---|
322 | |
---|
323 | for(i = 0; i < max; i++) |
---|
324 | { |
---|
325 | |
---|
326 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
327 | { |
---|
328 | int tmpleft = bltData.dst_left - wstep; |
---|
329 | int tmpright = bltData.dst_right + wstep; |
---|
330 | if(tmpleft < status.leftoffset) |
---|
331 | tmpleft = status.leftoffset; |
---|
332 | if(tmpright > fb->width - status.rightoffset) |
---|
333 | tmpright = fb->width - status.rightoffset; |
---|
334 | bltData.dst_left = tmpleft; |
---|
335 | bltData.dst_right = tmpright; |
---|
336 | } |
---|
337 | |
---|
338 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
339 | { |
---|
340 | int tmptop = bltData.dst_top - hstep; |
---|
341 | int tmpbottom = bltData.dst_bottom + hstep; |
---|
342 | if(tmptop < status.topoffset) |
---|
343 | tmptop = status.topoffset; |
---|
344 | if(tmpbottom > fb->height - status.bottomoffset) |
---|
345 | tmpbottom = fb->height - status.bottomoffset; |
---|
346 | bltData.dst_top = tmptop; |
---|
347 | bltData.dst_bottom = tmpbottom; |
---|
348 | } |
---|
349 | |
---|
350 | if(status.screenanim > 0) usleep(status.screenanimspeed * 1000); |
---|
351 | |
---|
352 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
353 | { |
---|
354 | perr("ioctl STMFBIO_BLT"); |
---|
355 | } |
---|
356 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
357 | { |
---|
358 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
359 | } |
---|
360 | |
---|
361 | if(mode3d != 0) |
---|
362 | { |
---|
363 | if(mode3d == 1) |
---|
364 | bltData.dst_left = 0 + status.leftoffset + ((fb->width - status.rightoffset) / 2); |
---|
365 | if(mode3d == 2) |
---|
366 | bltData.dst_top = 0 + status.topoffset + ((fb->height - status.bottomoffset) / 2); |
---|
367 | bltData.dst_right = fb->width - status.rightoffset; |
---|
368 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
369 | |
---|
370 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
371 | { |
---|
372 | perr("ioctl STMFBIO_BLT"); |
---|
373 | } |
---|
374 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
375 | { |
---|
376 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
377 | } |
---|
378 | } |
---|
379 | } |
---|
380 | #else |
---|
381 | #ifdef NOFB |
---|
382 | if(status.rguidfd > -1) |
---|
383 | { |
---|
384 | char* buf = NULL; |
---|
385 | buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0); |
---|
386 | if(buf != NULL) |
---|
387 | { |
---|
388 | socksend(&status.rguidfd, (unsigned char*)buf, 320 * 240 * 4, 5000 * 1000); |
---|
389 | free(buf); buf = NULL; |
---|
390 | } |
---|
391 | } |
---|
392 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
393 | { |
---|
394 | char* buf = NULL; |
---|
395 | buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0); |
---|
396 | if(buf != NULL) |
---|
397 | { |
---|
398 | if(writeFBfile.ActBuf == NULL) |
---|
399 | { |
---|
400 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
401 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
402 | memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240); |
---|
403 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
404 | } |
---|
405 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
406 | { |
---|
407 | if(writeFBfile.buf2 == NULL) |
---|
408 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
409 | memcpy(writeFBfile.buf2, (unsigned char*)buf, 4 * 320 * 240); |
---|
410 | } |
---|
411 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
412 | { |
---|
413 | if(writeFBfile.buf1 == NULL) |
---|
414 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
415 | memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240); |
---|
416 | } |
---|
417 | //fb2png((unsigned char*)buf, 320, 240, "/tmp/titanlcd.png"); |
---|
418 | free(buf); buf = NULL; |
---|
419 | } |
---|
420 | } |
---|
421 | |
---|
422 | if(fbnode != fb) |
---|
423 | { |
---|
424 | for(i = 0; i < fbnode->height; i++) |
---|
425 | { |
---|
426 | memcpy(fb->fb + (i * fb->pitch), fbnode->fb + (i * fbnode->pitch), fbnode->width * fbnode->colbytes); |
---|
427 | } |
---|
428 | } |
---|
429 | system("killall -9 xloadimage"); |
---|
430 | |
---|
431 | FILE *fd; |
---|
432 | fd=fopen("titan.png", "w"); |
---|
433 | fwrite(fb->fb, fb->varfbsize, 1, fd); |
---|
434 | fclose(fd); |
---|
435 | |
---|
436 | system("fbgrab -f titan.png -w 1280 -h 720 -b 32 titan1.png > /dev/null"); |
---|
437 | system("xloadimage titan1.png > /dev/null &"); |
---|
438 | #endif |
---|
439 | #endif |
---|
440 | */ |
---|
441 | } |
---|
442 | |
---|
443 | void setfbtransparent(int value) |
---|
444 | { |
---|
445 | /* |
---|
446 | #ifndef SIMULATE |
---|
447 | struct stmfbio_var_screeninfo_ex varEx = {0}; |
---|
448 | |
---|
449 | varEx.layerid = 0; |
---|
450 | varEx.activate = STMFBIO_ACTIVATE_IMMEDIATE; |
---|
451 | varEx.caps = STMFBIO_VAR_CAPS_OPACITY; |
---|
452 | varEx.opacity = value; |
---|
453 | |
---|
454 | |
---|
455 | if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &varEx) < 0) |
---|
456 | perr("STMFBIO_SET_VAR_SCREENINFO_EX"); |
---|
457 | #endif |
---|
458 | */ |
---|
459 | } |
---|
460 | |
---|
461 | int allocbpamem(size_t size, int *memfd, unsigned char **mem) |
---|
462 | { |
---|
463 | return -1; |
---|
464 | } |
---|
465 | |
---|
466 | void freebpamem(int memfd, unsigned char* mem, size_t len) |
---|
467 | { |
---|
468 | } |
---|
469 | |
---|
470 | //mode 0: with fill (draw to skinfb) |
---|
471 | //mode 1: without fill (draw to skinfb) |
---|
472 | //mode 2: with fill (draw to fb) |
---|
473 | //mode 3: without fill (draw to fb) |
---|
474 | void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode) |
---|
475 | { |
---|
476 | int y, x; |
---|
477 | unsigned long tmpcol; |
---|
478 | struct fb* tmpfb = NULL; |
---|
479 | |
---|
480 | if(posx < 0) posx = 0; |
---|
481 | if(posy < 0) posy = 0; |
---|
482 | if(mode < 2) |
---|
483 | tmpfb = skinfb; |
---|
484 | else |
---|
485 | tmpfb = fb; |
---|
486 | |
---|
487 | if(posx > tmpfb->width) posx = tmpfb->width; |
---|
488 | if(posy > tmpfb->height) posy = tmpfb->height; |
---|
489 | if(posx + width > tmpfb->width) width = tmpfb->width - posx; |
---|
490 | if(posy + height > tmpfb->height) height = tmpfb->height - posy; |
---|
491 | |
---|
492 | if(width <= 0 || height <= 0) return; |
---|
493 | |
---|
494 | transparent = (transparent - 255) * -1; |
---|
495 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
496 | |
---|
497 | if(mode == 0 || mode == 2) |
---|
498 | { |
---|
499 | int yend = (posy + height) * tmpfb->width; |
---|
500 | posy *= tmpfb->width; |
---|
501 | int xend = posx + width; |
---|
502 | int xlen = (xend - posx) * tmpfb->colbytes; |
---|
503 | int r = 0; |
---|
504 | unsigned char* from = tmpfb->fb + (posy + posx) * tmpfb->colbytes; |
---|
505 | |
---|
506 | for(y = posy; y < yend; y += tmpfb->width) |
---|
507 | { |
---|
508 | if(r == 0) |
---|
509 | { |
---|
510 | r = 1; |
---|
511 | for(x = posx; x < xend; x++) |
---|
512 | drawpixelfastfb(tmpfb, x, y, tmpcol); |
---|
513 | } |
---|
514 | else |
---|
515 | memcpy(tmpfb->fb + (y + posx) * tmpfb->colbytes, from, xlen); |
---|
516 | } |
---|
517 | } |
---|
518 | else if(mode == 1 || mode == 3) |
---|
519 | { |
---|
520 | //topline |
---|
521 | for(x = 0; x < width; x++) |
---|
522 | drawpixelfb(tmpfb, posx + x, posy, tmpcol); |
---|
523 | //bottomline |
---|
524 | for(x = 0; x < width; x++) |
---|
525 | drawpixelfb(tmpfb, posx + x, posy + height - 1, tmpcol); |
---|
526 | //leftline |
---|
527 | for(y = 0; y < height; y++) |
---|
528 | drawpixelfb(tmpfb, posx, posy + y, tmpcol); |
---|
529 | //rightline |
---|
530 | for(y = 0; y < height; y++) |
---|
531 | drawpixelfb(tmpfb, posx + width - 1, posy + y, tmpcol); |
---|
532 | } |
---|
533 | |
---|
534 | /* |
---|
535 | unsigned long tmpcol; |
---|
536 | |
---|
537 | transparent = (transparent - 255) * -1; |
---|
538 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
539 | |
---|
540 | STMFBIO_BLT_DATA bltData; |
---|
541 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
542 | |
---|
543 | if(posx < 0) posx = 0; |
---|
544 | if(posy < 0) posy = 0; |
---|
545 | if(mode < 2) |
---|
546 | { |
---|
547 | if(posx > skinfb->width) posx = skinfb->width; |
---|
548 | if(posy > skinfb->height) posy = skinfb->height; |
---|
549 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
550 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
551 | } |
---|
552 | else |
---|
553 | { |
---|
554 | if(posx > fb->width) posx = fb->width; |
---|
555 | if(posy > fb->height) posy = fb->height; |
---|
556 | if(posx + width > fb->width) width = fb->width - posx; |
---|
557 | if(posy + height > fb->height) height = fb->height - posy; |
---|
558 | } |
---|
559 | |
---|
560 | if(width <= 0 || height <= 0) return; |
---|
561 | |
---|
562 | if(mode == 0 || mode == 2) |
---|
563 | bltData.operation = BLT_OP_FILL; |
---|
564 | else if(mode == 1 || mode == 3) |
---|
565 | bltData.operation = BLT_OP_DRAW_RECTANGLE; |
---|
566 | bltData.colour = tmpcol; |
---|
567 | bltData.srcFormat = SURF_ARGB8888; |
---|
568 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
569 | |
---|
570 | if(status.usedirectfb == 1) |
---|
571 | bltData.dstOffset = 0; |
---|
572 | else |
---|
573 | { |
---|
574 | if(mode < 2) |
---|
575 | bltData.dstOffset = fb->varfbsize; |
---|
576 | else |
---|
577 | bltData.dstOffset = 0; |
---|
578 | } |
---|
579 | if(mode < 2) |
---|
580 | bltData.dstPitch = skinfb->pitch; |
---|
581 | else |
---|
582 | bltData.dstPitch = fb->pitch; |
---|
583 | bltData.dst_top = posy; |
---|
584 | bltData.dst_left = posx; |
---|
585 | bltData.dst_bottom = posy + height; |
---|
586 | bltData.dst_right = posx + width; |
---|
587 | bltData.dstFormat = SURF_ARGB8888; |
---|
588 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
589 | |
---|
590 | if(ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
591 | { |
---|
592 | perr("ioctl STMFBIO_BLT"); |
---|
593 | } |
---|
594 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
595 | { |
---|
596 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
597 | } |
---|
598 | */ |
---|
599 | } |
---|
600 | |
---|
601 | int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd) |
---|
602 | { |
---|
603 | /* |
---|
604 | #ifndef SIMULATE |
---|
605 | FILE *fp; |
---|
606 | unsigned int temp1, temp2; |
---|
607 | |
---|
608 | if(filename == NULL) return -1; |
---|
609 | |
---|
610 | debug(200, "hardware decode picture (%s)...", filename); |
---|
611 | |
---|
612 | if (!(fp = fopen(filename, "rb"))) |
---|
613 | return -1; |
---|
614 | |
---|
615 | if(get_jpeg_img_size(fp, &temp1, &temp2) != LIBMMEIMG_SUCCESS) |
---|
616 | return -1; |
---|
617 | |
---|
618 | *width = temp1; |
---|
619 | *height = temp2; |
---|
620 | *channels = 3; |
---|
621 | *rowbytes = *channels * temp1; |
---|
622 | |
---|
623 | if(allocbpamem(temp1 * temp2 * (*channels), memfd, mem) != 0) |
---|
624 | { |
---|
625 | fclose(fp); |
---|
626 | return -1; |
---|
627 | } |
---|
628 | |
---|
629 | if(decode_jpeg_noalloc(fp, temp1, temp2, temp1, temp2, (char *)*mem, 1) == LIBMMEIMG_SUCCESS) |
---|
630 | { |
---|
631 | fclose(fp); |
---|
632 | return 0; |
---|
633 | } |
---|
634 | |
---|
635 | fclose(fp); |
---|
636 | freebpamem(*memfd, *mem, temp1 * temp2 * (*channels)); |
---|
637 | err("hardware decode error"); |
---|
638 | #endif |
---|
639 | return -1; |
---|
640 | */ |
---|
641 | } |
---|
642 | |
---|
643 | //flag 0: blit from accelfb to skinfb |
---|
644 | //flag 1: blit from skinfb to accelfb |
---|
645 | void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag) |
---|
646 | { |
---|
647 | /* |
---|
648 | #ifndef SIMULATE |
---|
649 | STMFBIO_BLT_DATA blt_data; |
---|
650 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
651 | |
---|
652 | if(scalewidth == 0) scalewidth = width; |
---|
653 | if(scaleheight == 0) scaleheight = height; |
---|
654 | |
---|
655 | if(posx < 0) posx = 0; |
---|
656 | if(posx > skinfb->width) posx = skinfb->width; |
---|
657 | if(posy < 0) posy = 0; |
---|
658 | if(posy > skinfb->height) posy = skinfb->height; |
---|
659 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
660 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
661 | |
---|
662 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
663 | |
---|
664 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
665 | { |
---|
666 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
667 | return; |
---|
668 | } |
---|
669 | |
---|
670 | blt_data.operation = BLT_OP_COPY; |
---|
671 | |
---|
672 | if(flag == 0) |
---|
673 | { |
---|
674 | if(status.usedirectfb == 1) |
---|
675 | blt_data.srcOffset = fb->varfbsize; |
---|
676 | else |
---|
677 | blt_data.srcOffset = fb->varfbsize + skinfb->varfbsize; |
---|
678 | } |
---|
679 | else |
---|
680 | { |
---|
681 | if(status.usedirectfb == 1) |
---|
682 | blt_data.srcOffset = 0; |
---|
683 | else |
---|
684 | blt_data.srcOffset = fb->varfbsize; |
---|
685 | } |
---|
686 | |
---|
687 | blt_data.srcPitch = width * 4; |
---|
688 | blt_data.src_top = 0; |
---|
689 | blt_data.src_left = 0; |
---|
690 | blt_data.src_right = width; |
---|
691 | blt_data.src_bottom = height; |
---|
692 | blt_data.srcFormat = SURF_ARGB8888; |
---|
693 | blt_data.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
694 | |
---|
695 | if(flag == 0) |
---|
696 | { |
---|
697 | if(status.usedirectfb == 1) |
---|
698 | { |
---|
699 | blt_data.dstOffset = 0; |
---|
700 | blt_data.dstPitch = fb->pitch; |
---|
701 | } |
---|
702 | else |
---|
703 | { |
---|
704 | blt_data.dstOffset = fb->varfbsize; |
---|
705 | blt_data.dstPitch = skinfb->pitch; |
---|
706 | } |
---|
707 | } |
---|
708 | else |
---|
709 | { |
---|
710 | if(status.usedirectfb == 1) |
---|
711 | { |
---|
712 | blt_data.dstOffset = fb->varfbsize; |
---|
713 | blt_data.dstPitch = skinfb->pitch; |
---|
714 | } |
---|
715 | else |
---|
716 | { |
---|
717 | blt_data.dstOffset = fb->varfbsize + skinfb->varfbsize; |
---|
718 | blt_data.dstPitch = scalewidth * 4; |
---|
719 | } |
---|
720 | } |
---|
721 | |
---|
722 | blt_data.dst_left = posx; |
---|
723 | blt_data.dst_top = posy; |
---|
724 | blt_data.dst_right = posx + scalewidth; |
---|
725 | blt_data.dst_bottom = posy + scaleheight; |
---|
726 | blt_data.dstFormat = SURF_ARGB8888; |
---|
727 | blt_data.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
728 | |
---|
729 | if (ioctl(fb->fd, STMFBIO_BLT, &blt_data) < 0) |
---|
730 | { |
---|
731 | perr("ioctl STMFBIO_BLT"); |
---|
732 | } |
---|
733 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
734 | { |
---|
735 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
736 | } |
---|
737 | #endif |
---|
738 | */ |
---|
739 | } |
---|
740 | |
---|
741 | 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) |
---|
742 | //void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight) |
---|
743 | { |
---|
744 | /* |
---|
745 | #ifndef SIMULATE |
---|
746 | STMFBIO_BLT_EXTERN_DATA blt_data; |
---|
747 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); |
---|
748 | |
---|
749 | blt_data.operation = BLT_OP_COPY; |
---|
750 | blt_data.ulFlags = 0; |
---|
751 | blt_data.srcOffset = 0; |
---|
752 | blt_data.srcPitch = width * 3; |
---|
753 | blt_data.dstOffset = 0; |
---|
754 | blt_data.dstPitch = skinfb->pitch; |
---|
755 | blt_data.src_top = 0; |
---|
756 | blt_data.src_left = 0; |
---|
757 | blt_data.src_right = width; |
---|
758 | blt_data.src_bottom = height; |
---|
759 | blt_data.dst_left = posx; |
---|
760 | blt_data.dst_top = posy; |
---|
761 | |
---|
762 | if(scalewidth == 0) scalewidth = width; |
---|
763 | if(scaleheight == 0) scaleheight = height; |
---|
764 | |
---|
765 | blt_data.dst_right = posx + scalewidth; |
---|
766 | blt_data.dst_bottom = posy + scaleheight; |
---|
767 | blt_data.srcFormat = SURF_BGR888; |
---|
768 | blt_data.dstFormat = SURF_ARGB8888; |
---|
769 | blt_data.srcMemBase = (char *)buf; |
---|
770 | blt_data.dstMemBase = (char *)skinfb->fb; |
---|
771 | blt_data.srcMemSize = width * height * 3; |
---|
772 | blt_data.dstMemSize = skinfb->pitch * skinfb->height; |
---|
773 | |
---|
774 | if(ioctl(skinfb->fd, STMFBIO_BLT_EXTERN, &blt_data) < 0) |
---|
775 | { |
---|
776 | err("ioctl STMFBIO_BLT_EXTERN"); |
---|
777 | } |
---|
778 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
779 | { |
---|
780 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
781 | } |
---|
782 | #endif |
---|
783 | */ |
---|
784 | } |
---|
785 | |
---|
786 | void initsignal(struct sigaction* sa) |
---|
787 | { |
---|
788 | sigaction(SIGILL, sa, NULL); |
---|
789 | sigaction(SIGBUS, sa, NULL); |
---|
790 | sigaction(SIGFPE, sa, NULL); |
---|
791 | sigaction(SIGUSR1, sa, NULL); |
---|
792 | sigaction(SIGSEGV, sa, NULL); |
---|
793 | sigaction(SIGUSR2, sa, NULL); |
---|
794 | sigaction(SIGPIPE, sa, NULL); |
---|
795 | sigaction(SIGALRM, sa, NULL); |
---|
796 | // sigaction(SIGSTKFLT, sa, NULL); |
---|
797 | sigaction(SIGABRT, sa, NULL); |
---|
798 | |
---|
799 | signal(SIGHUP, SIG_IGN); |
---|
800 | signal(SIGINT, SIG_IGN); |
---|
801 | signal(SIGTRAP, SIG_IGN); |
---|
802 | signal(SIGXCPU, SIG_IGN); |
---|
803 | signal(SIGXFSZ, SIG_IGN); |
---|
804 | signal(SIGVTALRM, SIG_IGN); |
---|
805 | signal(SIGPROF, SIG_IGN); |
---|
806 | signal(SIGPOLL, SIG_IGN); |
---|
807 | signal(SIGRTMAX, SIG_IGN); |
---|
808 | signal(SIGPWR, SIG_IGN); |
---|
809 | signal(SIGSYS, SIG_IGN); |
---|
810 | } |
---|
811 | |
---|
812 | void sighandler(int sig, struct sigcontext ctx) |
---|
813 | { |
---|
814 | switch(sig) |
---|
815 | { |
---|
816 | case SIGALRM: |
---|
817 | { |
---|
818 | err("got signal sigalrm but ignore it"); |
---|
819 | break; |
---|
820 | } |
---|
821 | case SIGPIPE: |
---|
822 | { |
---|
823 | err("got signal sigpipe but ignore it"); |
---|
824 | break; |
---|
825 | } |
---|
826 | case SIGUSR1: |
---|
827 | { |
---|
828 | //todo all configs |
---|
829 | reloadconfig(status.configfile); |
---|
830 | reloadconfig(getconfig("ownconfig", NULL)); |
---|
831 | break; |
---|
832 | } |
---|
833 | case SIGUSR2: //called if hanging mainthread detect |
---|
834 | { |
---|
835 | debugstack(sig, NULL, NULL); |
---|
836 | break; |
---|
837 | } |
---|
838 | case SIGILL: |
---|
839 | case SIGBUS: |
---|
840 | case SIGFPE: |
---|
841 | case SIGSEGV: |
---|
842 | // case SIGSTKFLT: |
---|
843 | { |
---|
844 | /* |
---|
845 | #ifdef SIMULATE |
---|
846 | //intel |
---|
847 | debugstack((void *)ctx.eip, NULL); |
---|
848 | err("got signal %d, fault address 0x%lx from 0x%lx", sig, ctx.cr2, ctx.eip); |
---|
849 | #else |
---|
850 | // sh4 |
---|
851 | //unsigned long sc_regs[16]; |
---|
852 | //unsigned long sc_pc; //programm counter register |
---|
853 | //unsigned long sc_pr; //procedure register |
---|
854 | //unsigned long sc_sr; //status register |
---|
855 | //unsigned long sc_gbr; |
---|
856 | //unsigned long sc_mach; |
---|
857 | //unsigned long sc_macl; |
---|
858 | |
---|
859 | debugstack(sig, (void *)ctx.sc_pr, (void *)ctx.sc_pc); |
---|
860 | err("got signal %d (%s), programm counter reg: 0x%lx, procedure reg: 0x%lx", sig, strsignal(sig), ctx.sc_pc, ctx.sc_pr); |
---|
861 | #endif |
---|
862 | */ |
---|
863 | if(getconfigint("saverun", NULL) == 1 && status.longjumpbuf != NULL) |
---|
864 | siglongjmp(status.longjumpbuf, 999); |
---|
865 | else |
---|
866 | exit(100); |
---|
867 | break; |
---|
868 | } |
---|
869 | } |
---|
870 | } |
---|
871 | |
---|
872 | int setvmpeg(struct dvbdev* node, int value, int flag) |
---|
873 | { |
---|
874 | debug(1000, "in"); |
---|
875 | char* vmpegdev = NULL, *tmpstr = NULL, *buf = NULL; |
---|
876 | int ret = 0; |
---|
877 | |
---|
878 | if(node == NULL) return 1; |
---|
879 | if(flag == 0) vmpegdev = getconfig("vmpegleftdev", NULL); |
---|
880 | if(flag == 1) vmpegdev = getconfig("vmpegtopdev", NULL); |
---|
881 | if(flag == 2) vmpegdev = getconfig("vmpegwidthdev", NULL); |
---|
882 | if(flag == 3) vmpegdev = getconfig("vmpegheightdev", NULL); |
---|
883 | |
---|
884 | if(vmpegdev != NULL) |
---|
885 | { |
---|
886 | buf = malloc(MINMALLOC); |
---|
887 | if(buf == NULL) |
---|
888 | { |
---|
889 | err("no mem"); |
---|
890 | return 1; |
---|
891 | } |
---|
892 | |
---|
893 | tmpstr = malloc(10); |
---|
894 | if(tmpstr == NULL) |
---|
895 | { |
---|
896 | err("no mem"); |
---|
897 | free(buf); |
---|
898 | return 1; |
---|
899 | } |
---|
900 | |
---|
901 | snprintf(buf, MINMALLOC, vmpegdev, node->devnr); |
---|
902 | snprintf(tmpstr, 10, "%x", value); |
---|
903 | debug(100, "set %s to %s", buf, tmpstr); |
---|
904 | status.tvpic = 1; |
---|
905 | ret = writesys(buf, tmpstr, 1); |
---|
906 | |
---|
907 | free(tmpstr); |
---|
908 | free(buf); |
---|
909 | return ret; |
---|
910 | } |
---|
911 | |
---|
912 | debug(1000, "out"); |
---|
913 | return 0; |
---|
914 | } |
---|
915 | |
---|
916 | //flag 0: wh = width |
---|
917 | //flag 1: wh = height |
---|
918 | int setvmpegrect(struct dvbdev* node, int left, int top, int wh, int flag) |
---|
919 | { |
---|
920 | int ret = 0; |
---|
921 | |
---|
922 | if(flag == 0) |
---|
923 | { |
---|
924 | ret = setvmpeg(node, wh, 2); |
---|
925 | ret = setvmpeg(node, wh / 1.4, 3); |
---|
926 | } |
---|
927 | if(flag == 1) |
---|
928 | { |
---|
929 | ret = setvmpeg(node, wh, 3); |
---|
930 | ret = setvmpeg(node, wh * 1.3, 2); |
---|
931 | } |
---|
932 | |
---|
933 | ret = setvmpeg(node, left, 0); |
---|
934 | ret = setvmpeg(node, top, 1); |
---|
935 | |
---|
936 | return ret; |
---|
937 | } |
---|
938 | |
---|
939 | int resetvmpeg(struct dvbdev* node) |
---|
940 | { |
---|
941 | int ret = 0; |
---|
942 | |
---|
943 | ret = setvmpeg(node, 0, 0); |
---|
944 | ret = setvmpeg(node, 0, 1); |
---|
945 | ret = setvmpeg(node, 0, 2); |
---|
946 | ret = setvmpeg(node, 0, 3); |
---|
947 | |
---|
948 | return ret; |
---|
949 | } |
---|
950 | |
---|
951 | int resettvpic() |
---|
952 | { |
---|
953 | /* |
---|
954 | if(status.tvpic == 1 && status.aktservice != NULL) |
---|
955 | { |
---|
956 | status.tvpic = 0; |
---|
957 | resetvmpeg(status.aktservice->videodev); |
---|
958 | } |
---|
959 | */ |
---|
960 | int ret = 0; |
---|
961 | |
---|
962 | if(status.tvpic > 0 && status.aktservice != NULL) |
---|
963 | { |
---|
964 | status.tvpic = 0; |
---|
965 | ret = resetvmpeg(status.aktservice->videodev); |
---|
966 | } |
---|
967 | |
---|
968 | return ret; |
---|
969 | } |
---|
970 | |
---|
971 | #endif |
---|