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 | //fuer Funktion memcpy_word |
---|
15 | volatile char *memcpy_word_src; |
---|
16 | volatile char *memcpy_word_dest; |
---|
17 | volatile long memcpy_word_anzw = 0; |
---|
18 | |
---|
19 | //fuer Funktion memcpy_byte |
---|
20 | volatile char *memcpy_byte_src; |
---|
21 | volatile char *memcpy_byte_dest; |
---|
22 | volatile long memcpy_byte_anzb = 0; |
---|
23 | |
---|
24 | unsigned char *lfb = NULL; |
---|
25 | int g_manual_blit = 0; |
---|
26 | struct fb_fix_screeninfo fix_screeninfo; |
---|
27 | struct fb_var_screeninfo var_screeninfo; |
---|
28 | |
---|
29 | void memcpy_area(unsigned char* ziehlADDR, unsigned char* startADDR, long pxAbs, long hight, long widthAbs, long FBwidthAbs); |
---|
30 | |
---|
31 | int setmixer(struct dvbdev* node, int left, int right) |
---|
32 | { |
---|
33 | return audiosetmixer(node, left, right); |
---|
34 | } |
---|
35 | |
---|
36 | int setencoding(struct channel* chnode, struct dvbdev* videonode) |
---|
37 | { |
---|
38 | int ret = 1; |
---|
39 | if(chnode == NULL) return ret; |
---|
40 | |
---|
41 | switch(chnode->videocodec) |
---|
42 | { |
---|
43 | case MPEGV: |
---|
44 | ret = videosetstreamtype(videonode, 0); |
---|
45 | break; |
---|
46 | case MPEG4V: |
---|
47 | ret = videosetstreamtype(videonode, 4); |
---|
48 | break; |
---|
49 | case H264: |
---|
50 | ret = videosetstreamtype(videonode, 1); |
---|
51 | break; |
---|
52 | case VC1: |
---|
53 | ret = videosetstreamtype(videonode, 3); |
---|
54 | break; |
---|
55 | default: |
---|
56 | ret = videosetstreamtype(videonode, 0); |
---|
57 | } |
---|
58 | return ret; |
---|
59 | } |
---|
60 | |
---|
61 | int videodiscontinuityskip(struct dvbdev* node, int flag) |
---|
62 | { |
---|
63 | return 0; |
---|
64 | } |
---|
65 | |
---|
66 | void fbsave() |
---|
67 | { |
---|
68 | } |
---|
69 | |
---|
70 | void fbrestore() |
---|
71 | { |
---|
72 | } |
---|
73 | |
---|
74 | void setfbvarsize(struct fb* newnode) |
---|
75 | { |
---|
76 | if(newnode != NULL) |
---|
77 | newnode->varfbsize = 1920 * 1080 * newnode->colbytes; |
---|
78 | // newnode->varfbsize = 1920 * 1080 * (newnode->colbytes * 8); |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | void enablemanualblit() |
---|
83 | { |
---|
84 | unsigned char tmp = 1; |
---|
85 | if (ioctl(fb->fd, FBIO_SET_MANUAL_BLIT, &tmp)<0) |
---|
86 | perror("FBIO_SET_MANUAL_BLIT"); |
---|
87 | else |
---|
88 | g_manual_blit = 1; |
---|
89 | } |
---|
90 | |
---|
91 | void disablemanualblit() |
---|
92 | { |
---|
93 | unsigned char tmp = 0; |
---|
94 | if (ioctl(fb->fd, FBIO_SET_MANUAL_BLIT, &tmp)<0) |
---|
95 | perror("FBIO_SET_MANUAL_BLIT"); |
---|
96 | else |
---|
97 | g_manual_blit = 0; |
---|
98 | } |
---|
99 | |
---|
100 | void blit() |
---|
101 | { |
---|
102 | if (g_manual_blit == 1) { |
---|
103 | if (ioctl(fb->fd, FBIO_BLIT) < 0) |
---|
104 | perror("FBIO_BLIT"); |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | int waitvsync() |
---|
109 | { |
---|
110 | int c = 0; |
---|
111 | return ioctl(fb->fd, FBIO_WAITFORVSYNC, &c); |
---|
112 | } |
---|
113 | |
---|
114 | void fbsetoffset(int x, int y) |
---|
115 | { |
---|
116 | struct fb_var_screeninfo var_screeninfo; |
---|
117 | |
---|
118 | var_screeninfo.xoffset = x; |
---|
119 | var_screeninfo.yoffset = y; |
---|
120 | |
---|
121 | if(ioctl(fb->fd, FBIOPAN_DISPLAY, &var_screeninfo) < 0) |
---|
122 | { |
---|
123 | perr("FBIOPAN_DISPLAY"); |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | //flag 0 = no animation |
---|
128 | //flag 1 = animation |
---|
129 | void blitfb2(struct fb* fbnode, int flag) |
---|
130 | { |
---|
131 | struct fb_var_screeninfo var_screeninfo; |
---|
132 | |
---|
133 | var_screeninfo.xres_virtual = fb->width; |
---|
134 | var_screeninfo.xres = fb->width; |
---|
135 | var_screeninfo.yres_virtual = fb->height * 2; |
---|
136 | var_screeninfo.yres = fb->height; |
---|
137 | var_screeninfo.height = 0; |
---|
138 | var_screeninfo.width = 0; |
---|
139 | var_screeninfo.xoffset = 0; |
---|
140 | var_screeninfo.yoffset = 0; |
---|
141 | var_screeninfo.bits_per_pixel = fb->colbytes * 8; |
---|
142 | |
---|
143 | switch(fb->colbytes) |
---|
144 | { |
---|
145 | case 2: |
---|
146 | var_screeninfo.transp.offset = 15; |
---|
147 | var_screeninfo.transp.length = 1; |
---|
148 | var_screeninfo.red.offset = 10; |
---|
149 | var_screeninfo.red.length = 5; |
---|
150 | var_screeninfo.green.offset = 5; |
---|
151 | var_screeninfo.green.length = 5; |
---|
152 | var_screeninfo.blue.offset = 0; |
---|
153 | var_screeninfo.blue.length = 5; |
---|
154 | break; |
---|
155 | case 4: |
---|
156 | var_screeninfo.transp.offset = 24; |
---|
157 | var_screeninfo.transp.length = 8; |
---|
158 | var_screeninfo.red.offset = 16; |
---|
159 | var_screeninfo.red.length = 8; |
---|
160 | var_screeninfo.green.offset = 8; |
---|
161 | var_screeninfo.green.length = 8; |
---|
162 | var_screeninfo.blue.offset = 0; |
---|
163 | var_screeninfo.blue.length = 8; |
---|
164 | break; |
---|
165 | } |
---|
166 | |
---|
167 | debug(444, "FB: line_length %d", fix_screeninfo.line_length); |
---|
168 | debug(444, "FB: var_screeninfo.xres %d", var_screeninfo.xres); |
---|
169 | debug(444, "FB: var_screeninfo.yres %d", var_screeninfo.yres); |
---|
170 | debug(444, "FB: var_screeninfo.xres_virt %d", var_screeninfo.xres_virtual); |
---|
171 | debug(444, "FB: var_screeninfo.yres_virt %d", var_screeninfo.yres_virtual); |
---|
172 | debug(444, "FB: var_screeninfo.xoffset %d", var_screeninfo.xoffset); |
---|
173 | debug(444, "FB: var_screeninfo.yoffset %d", var_screeninfo.yoffset); |
---|
174 | debug(444, "FB: var_screeninfo.bits_per_pixel %d", var_screeninfo.bits_per_pixel); |
---|
175 | debug(444, "FB: var_screeninfo.grayscale %d", var_screeninfo.grayscale); |
---|
176 | |
---|
177 | if(ioctl(fb->fd, FBIOPUT_VSCREENINFO, &var_screeninfo) < 0) |
---|
178 | { |
---|
179 | var_screeninfo.yres_virtual = fb->height; |
---|
180 | if(ioctl(fb->fd, FBIOPUT_VSCREENINFO, &var_screeninfo) < 0) |
---|
181 | { |
---|
182 | perr("FBIOPUT_VSCREENINFO"); |
---|
183 | } |
---|
184 | debug(444, "FB: double buffering not available"); |
---|
185 | } |
---|
186 | else |
---|
187 | { |
---|
188 | debug(444, "FB: double buffering available!"); |
---|
189 | } |
---|
190 | |
---|
191 | ioctl(fb->fd, FBIOGET_VSCREENINFO, &var_screeninfo); |
---|
192 | if ((var_screeninfo.xres!=fb->width) && (var_screeninfo.yres!=fb->height) && (var_screeninfo.bits_per_pixel!=fb->colbytes)) |
---|
193 | { |
---|
194 | debug(444, "SetMode failed: wanted: %dx%dx%d, got %dx%dx%d", |
---|
195 | fb->width, fb->height, fb->colbytes, |
---|
196 | var_screeninfo.xres, var_screeninfo.yres, var_screeninfo.bits_per_pixel); |
---|
197 | } |
---|
198 | /* |
---|
199 | int xRes, yRes, stride, bpp; |
---|
200 | |
---|
201 | xRes=var_screeninfo.xres; |
---|
202 | yRes=var_screeninfo.yres; |
---|
203 | bpp=var_screeninfo.bits_per_pixel; |
---|
204 | // fb_fix_screeninfo fix; |
---|
205 | // struct fb_fix_screeninfo fix_screeninfo; |
---|
206 | if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fix_screeninfo)<0) |
---|
207 | { |
---|
208 | perror("FBIOGET_FSCREENINFO"); |
---|
209 | printf("fb failed\n"); |
---|
210 | } |
---|
211 | stride=fix_screeninfo.line_length; |
---|
212 | memset(lfb, 0, stride*yRes); |
---|
213 | */ |
---|
214 | blit(); |
---|
215 | |
---|
216 | /* |
---|
217 | int i = 0, max = 1, wstep = 0, hstep = 0, ret = 0; |
---|
218 | unsigned char buf[10]; |
---|
219 | |
---|
220 | if(fbnode == NULL) return; |
---|
221 | #ifndef NOHWBLIT |
---|
222 | if(fbnode == fb) return; |
---|
223 | |
---|
224 | if(status.rguidfd > -1) |
---|
225 | { |
---|
226 | m_lock(&status.accelfbmutex, 16); |
---|
227 | |
---|
228 | int zlen = 0; |
---|
229 | char* zbuf = NULL; |
---|
230 | blitscale(0, 0, fbnode->width, fbnode->height, 440, 330, 1); |
---|
231 | ret = ozip((char*)accelfb->fb, 440 * 330 * 4, &zbuf, &zlen, 1); |
---|
232 | |
---|
233 | if(ret == 0) |
---|
234 | { |
---|
235 | memset(buf, 0, 10); |
---|
236 | char* tmpnr = oitoa(zlen); |
---|
237 | memcpy(buf, tmpnr, strlen(tmpnr)); |
---|
238 | free(tmpnr); tmpnr = NULL; |
---|
239 | socksend(&status.rguidfd, buf, 10, 5000 * 1000); |
---|
240 | socksend(&status.rguidfd, (unsigned char*)zbuf, zlen, 5000 * 1000); |
---|
241 | } |
---|
242 | free(zbuf); zbuf = NULL; |
---|
243 | zlen = 0; |
---|
244 | |
---|
245 | m_unlock(&status.accelfbmutex, 16); |
---|
246 | } |
---|
247 | |
---|
248 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
249 | { |
---|
250 | m_lock(&status.accelfbmutex, 16); |
---|
251 | blitscale(0, 0, fbnode->width, fbnode->height, 320, 240, 1); |
---|
252 | if(writeFBfile.ActBuf == NULL) |
---|
253 | { |
---|
254 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
255 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
256 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
257 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
258 | } |
---|
259 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
260 | { |
---|
261 | if(writeFBfile.buf2 == NULL) |
---|
262 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
263 | memcpy(writeFBfile.buf2, accelfb->fb, 4 * 320 * 240); |
---|
264 | } |
---|
265 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
266 | { |
---|
267 | if(writeFBfile.buf1 == NULL) |
---|
268 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
269 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
270 | } |
---|
271 | m_unlock(&status.accelfbmutex, 16); |
---|
272 | } |
---|
273 | |
---|
274 | int mode3d = 0, leftoffset = 0, rightoffset = 0, topoffset = 0, bottomoffset = 0; |
---|
275 | char* mode3dstr = NULL; |
---|
276 | |
---|
277 | if(status.leftoffset != 0) blitrect(0, 0, status.leftoffset, fb->height, 0, 255, 2); |
---|
278 | if(status.rightoffset != 0) blitrect(fb->width - status.rightoffset, 0, status.rightoffset, fb->height, 0, 255, 2); |
---|
279 | if(status.topoffset != 0) blitrect(0, 0, fb->width, status.topoffset, 0, 255, 2); |
---|
280 | if(status.bottomoffset != 0) blitrect(0, fb->height - status.bottomoffset, fb->width, status.bottomoffset, 0, 255, 2); |
---|
281 | |
---|
282 | mode3dstr = getconfig("av_mode3d", NULL); |
---|
283 | if(ostrcmp(mode3dstr, "sbs") == 0) |
---|
284 | mode3d = 1; |
---|
285 | else if(ostrcmp(mode3dstr, "tab") == 0) |
---|
286 | mode3d = 2; |
---|
287 | |
---|
288 | STMFBIO_BLT_DATA bltData; |
---|
289 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
290 | |
---|
291 | bltData.operation = BLT_OP_COPY; |
---|
292 | bltData.srcOffset = fbnode->fb - fb->fb; |
---|
293 | bltData.srcPitch = fbnode->pitch; |
---|
294 | bltData.src_top = 0; |
---|
295 | bltData.src_left = 0; |
---|
296 | bltData.src_right = fbnode->width; |
---|
297 | bltData.src_bottom = fbnode->height; |
---|
298 | bltData.srcFormat = SURF_BGRA8888; |
---|
299 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
300 | |
---|
301 | bltData.dstOffset = 0; |
---|
302 | bltData.dstPitch = fb->pitch; |
---|
303 | bltData.dst_left = status.leftoffset; |
---|
304 | bltData.dst_top = status.topoffset; |
---|
305 | if(mode3d == 1) |
---|
306 | bltData.dst_right = (fb->width - status.rightoffset) / 2; |
---|
307 | else |
---|
308 | bltData.dst_right = fb->width - status.rightoffset; |
---|
309 | if(mode3d == 2) |
---|
310 | bltData.dst_bottom = (fb->height - status.bottomoffset) / 2; |
---|
311 | else |
---|
312 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
313 | bltData.dstFormat = SURF_BGRA8888; |
---|
314 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
315 | |
---|
316 | if(flag == 1 && status.screenanim > 0 && mode3d == 0) |
---|
317 | { |
---|
318 | int width = (fb->width - status.rightoffset) - status.leftoffset; |
---|
319 | int height = (fb->height - status.topoffset) - status.bottomoffset; |
---|
320 | max = 25; |
---|
321 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
322 | { |
---|
323 | bltData.dst_left = (width / 2) - 1; |
---|
324 | bltData.dst_right = (width / 2) + 1; |
---|
325 | } |
---|
326 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
327 | { |
---|
328 | bltData.dst_top = (height / 2) - 1; |
---|
329 | bltData.dst_bottom = (height / 2) + 1; |
---|
330 | } |
---|
331 | wstep = width / max; |
---|
332 | hstep = height / max; |
---|
333 | } |
---|
334 | |
---|
335 | for(i = 0; i < max; i++) |
---|
336 | { |
---|
337 | |
---|
338 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
339 | { |
---|
340 | int tmpleft = bltData.dst_left - wstep; |
---|
341 | int tmpright = bltData.dst_right + wstep; |
---|
342 | if(tmpleft < status.leftoffset) |
---|
343 | tmpleft = status.leftoffset; |
---|
344 | if(tmpright > fb->width - status.rightoffset) |
---|
345 | tmpright = fb->width - status.rightoffset; |
---|
346 | bltData.dst_left = tmpleft; |
---|
347 | bltData.dst_right = tmpright; |
---|
348 | } |
---|
349 | |
---|
350 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
351 | { |
---|
352 | int tmptop = bltData.dst_top - hstep; |
---|
353 | int tmpbottom = bltData.dst_bottom + hstep; |
---|
354 | if(tmptop < status.topoffset) |
---|
355 | tmptop = status.topoffset; |
---|
356 | if(tmpbottom > fb->height - status.bottomoffset) |
---|
357 | tmpbottom = fb->height - status.bottomoffset; |
---|
358 | bltData.dst_top = tmptop; |
---|
359 | bltData.dst_bottom = tmpbottom; |
---|
360 | } |
---|
361 | |
---|
362 | if(status.screenanim > 0) usleep(status.screenanimspeed * 1000); |
---|
363 | |
---|
364 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
365 | { |
---|
366 | perr("ioctl STMFBIO_BLT"); |
---|
367 | } |
---|
368 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
369 | { |
---|
370 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
371 | } |
---|
372 | |
---|
373 | if(mode3d != 0) |
---|
374 | { |
---|
375 | if(mode3d == 1) |
---|
376 | bltData.dst_left = 0 + status.leftoffset + ((fb->width - status.rightoffset) / 2); |
---|
377 | if(mode3d == 2) |
---|
378 | bltData.dst_top = 0 + status.topoffset + ((fb->height - status.bottomoffset) / 2); |
---|
379 | bltData.dst_right = fb->width - status.rightoffset; |
---|
380 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
381 | |
---|
382 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
383 | { |
---|
384 | perr("ioctl STMFBIO_BLT"); |
---|
385 | } |
---|
386 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
387 | { |
---|
388 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
389 | } |
---|
390 | } |
---|
391 | } |
---|
392 | #else |
---|
393 | #ifdef NOFB |
---|
394 | if(status.rguidfd > -1) |
---|
395 | { |
---|
396 | char* buf = NULL; |
---|
397 | buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0); |
---|
398 | if(buf != NULL) |
---|
399 | { |
---|
400 | socksend(&status.rguidfd, (unsigned char*)buf, 320 * 240 * 4, 5000 * 1000); |
---|
401 | free(buf); buf = NULL; |
---|
402 | } |
---|
403 | } |
---|
404 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
405 | { |
---|
406 | char* buf = NULL; |
---|
407 | buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0); |
---|
408 | if(buf != NULL) |
---|
409 | { |
---|
410 | if(writeFBfile.ActBuf == NULL) |
---|
411 | { |
---|
412 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
413 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
414 | memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240); |
---|
415 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
416 | } |
---|
417 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
418 | { |
---|
419 | if(writeFBfile.buf2 == NULL) |
---|
420 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
421 | memcpy(writeFBfile.buf2, (unsigned char*)buf, 4 * 320 * 240); |
---|
422 | } |
---|
423 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
424 | { |
---|
425 | if(writeFBfile.buf1 == NULL) |
---|
426 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
427 | memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240); |
---|
428 | } |
---|
429 | //fb2png((unsigned char*)buf, 320, 240, "/tmp/titanlcd.png"); |
---|
430 | free(buf); buf = NULL; |
---|
431 | } |
---|
432 | } |
---|
433 | |
---|
434 | if(fbnode != fb) |
---|
435 | { |
---|
436 | for(i = 0; i < fbnode->height; i++) |
---|
437 | { |
---|
438 | memcpy(fb->fb + (i * fb->pitch), fbnode->fb + (i * fbnode->pitch), fbnode->width * fbnode->colbytes); |
---|
439 | } |
---|
440 | } |
---|
441 | system("killall -9 xloadimage"); |
---|
442 | |
---|
443 | FILE *fd; |
---|
444 | fd=fopen("titan.png", "w"); |
---|
445 | fwrite(fb->fb, fb->varfbsize, 1, fd); |
---|
446 | fclose(fd); |
---|
447 | |
---|
448 | system("fbgrab -f titan.png -w 1280 -h 720 -b 32 titan1.png > /dev/null"); |
---|
449 | system("xloadimage titan1.png > /dev/null &"); |
---|
450 | #endif |
---|
451 | #endif |
---|
452 | */ |
---|
453 | } |
---|
454 | |
---|
455 | void setfbtransparent(int value) |
---|
456 | { |
---|
457 | char* transparentdev; |
---|
458 | |
---|
459 | transparentdev = getconfig("transparentdev", NULL); |
---|
460 | |
---|
461 | if(transparentdev != NULL /*&& checkdev(transparentdev)*/) |
---|
462 | { |
---|
463 | debug(100, "set %s to %d", transparentdev, value); |
---|
464 | writesysint(transparentdev, value, 1); |
---|
465 | return; |
---|
466 | } |
---|
467 | /* |
---|
468 | #ifndef SIMULATE |
---|
469 | struct stmfbio_var_screeninfo_ex varEx = {0}; |
---|
470 | |
---|
471 | varEx.layerid = 0; |
---|
472 | varEx.activate = STMFBIO_ACTIVATE_IMMEDIATE; |
---|
473 | varEx.caps = STMFBIO_VAR_CAPS_OPACITY; |
---|
474 | varEx.opacity = value; |
---|
475 | |
---|
476 | |
---|
477 | if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &varEx) < 0) |
---|
478 | perr("STMFBIO_SET_VAR_SCREENINFO_EX"); |
---|
479 | #endif |
---|
480 | */ |
---|
481 | } |
---|
482 | |
---|
483 | int allocbpamem(size_t size, int *memfd, unsigned char **mem) |
---|
484 | { |
---|
485 | return -1; |
---|
486 | } |
---|
487 | |
---|
488 | void freebpamem(int memfd, unsigned char* mem, size_t len) |
---|
489 | { |
---|
490 | } |
---|
491 | |
---|
492 | //mode 0: with fill (draw to skinfb) |
---|
493 | //mode 1: without fill (draw to skinfb) |
---|
494 | //mode 2: with fill (draw to fb) |
---|
495 | //mode 3: without fill (draw to fb) |
---|
496 | void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode) |
---|
497 | { |
---|
498 | int y, x; |
---|
499 | unsigned long tmpcol; |
---|
500 | struct fb* tmpfb = NULL; |
---|
501 | |
---|
502 | if(posx < 0) posx = 0; |
---|
503 | if(posy < 0) posy = 0; |
---|
504 | if(mode < 2) |
---|
505 | tmpfb = skinfb; |
---|
506 | else |
---|
507 | tmpfb = fb; |
---|
508 | |
---|
509 | if(posx > tmpfb->width) posx = tmpfb->width; |
---|
510 | if(posy > tmpfb->height) posy = tmpfb->height; |
---|
511 | if(posx + width > tmpfb->width) width = tmpfb->width - posx; |
---|
512 | if(posy + height > tmpfb->height) height = tmpfb->height - posy; |
---|
513 | |
---|
514 | if(width <= 0 || height <= 0) return; |
---|
515 | |
---|
516 | transparent = (transparent - 255) * -1; |
---|
517 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
518 | |
---|
519 | if(mode == 0 || mode == 2) |
---|
520 | { |
---|
521 | int yend = (posy + height) * tmpfb->width; |
---|
522 | posy *= tmpfb->width; |
---|
523 | int xend = posx + width; |
---|
524 | // int xlen = (xend - posx) * tmpfb->colbytes; |
---|
525 | int r = 0; |
---|
526 | unsigned char* from = tmpfb->fb + (posy + posx) * tmpfb->colbytes; |
---|
527 | |
---|
528 | for(y = posy; y < yend; y += tmpfb->width) |
---|
529 | { |
---|
530 | if(r == 0) |
---|
531 | { |
---|
532 | r = 1; |
---|
533 | for(x = posx; x < xend; x++) |
---|
534 | drawpixelfastfb(tmpfb, x, y, tmpcol); |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | //memcpy(tmpfb->fb + (y + posx) * tmpfb->colbytes, from, xlen); |
---|
539 | memcpy_area(tmpfb->fb + (y + posx) * tmpfb->colbytes, from, posx * 4, height-1, width*4, tmpfb->width*4); |
---|
540 | y = yend; |
---|
541 | } |
---|
542 | |
---|
543 | } |
---|
544 | } |
---|
545 | else if(mode == 1 || mode == 3) |
---|
546 | { |
---|
547 | //topline |
---|
548 | for(x = 0; x < width; x++) |
---|
549 | drawpixelfb(tmpfb, posx + x, posy, tmpcol); |
---|
550 | //bottomline |
---|
551 | for(x = 0; x < width; x++) |
---|
552 | drawpixelfb(tmpfb, posx + x, posy + height - 1, tmpcol); |
---|
553 | //leftline |
---|
554 | for(y = 0; y < height; y++) |
---|
555 | drawpixelfb(tmpfb, posx, posy + y, tmpcol); |
---|
556 | //rightline |
---|
557 | for(y = 0; y < height; y++) |
---|
558 | drawpixelfb(tmpfb, posx + width - 1, posy + y, tmpcol); |
---|
559 | } |
---|
560 | |
---|
561 | /* |
---|
562 | unsigned long tmpcol; |
---|
563 | |
---|
564 | transparent = (transparent - 255) * -1; |
---|
565 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
566 | |
---|
567 | STMFBIO_BLT_DATA bltData; |
---|
568 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
569 | |
---|
570 | if(posx < 0) posx = 0; |
---|
571 | if(posy < 0) posy = 0; |
---|
572 | if(mode < 2) |
---|
573 | { |
---|
574 | if(posx > skinfb->width) posx = skinfb->width; |
---|
575 | if(posy > skinfb->height) posy = skinfb->height; |
---|
576 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
577 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
578 | } |
---|
579 | else |
---|
580 | { |
---|
581 | if(posx > fb->width) posx = fb->width; |
---|
582 | if(posy > fb->height) posy = fb->height; |
---|
583 | if(posx + width > fb->width) width = fb->width - posx; |
---|
584 | if(posy + height > fb->height) height = fb->height - posy; |
---|
585 | } |
---|
586 | |
---|
587 | if(width <= 0 || height <= 0) return; |
---|
588 | |
---|
589 | if(mode == 0 || mode == 2) |
---|
590 | bltData.operation = BLT_OP_FILL; |
---|
591 | else if(mode == 1 || mode == 3) |
---|
592 | bltData.operation = BLT_OP_DRAW_RECTANGLE; |
---|
593 | bltData.colour = tmpcol; |
---|
594 | bltData.srcFormat = SURF_ARGB8888; |
---|
595 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
596 | |
---|
597 | if(status.usedirectfb == 1) |
---|
598 | bltData.dstOffset = 0; |
---|
599 | else |
---|
600 | { |
---|
601 | if(mode < 2) |
---|
602 | bltData.dstOffset = fb->varfbsize; |
---|
603 | else |
---|
604 | bltData.dstOffset = 0; |
---|
605 | } |
---|
606 | if(mode < 2) |
---|
607 | bltData.dstPitch = skinfb->pitch; |
---|
608 | else |
---|
609 | bltData.dstPitch = fb->pitch; |
---|
610 | bltData.dst_top = posy; |
---|
611 | bltData.dst_left = posx; |
---|
612 | bltData.dst_bottom = posy + height; |
---|
613 | bltData.dst_right = posx + width; |
---|
614 | bltData.dstFormat = SURF_ARGB8888; |
---|
615 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
616 | |
---|
617 | if(ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
618 | { |
---|
619 | perr("ioctl STMFBIO_BLT"); |
---|
620 | } |
---|
621 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
622 | { |
---|
623 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
624 | } |
---|
625 | */ |
---|
626 | } |
---|
627 | |
---|
628 | int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd) |
---|
629 | { |
---|
630 | /* |
---|
631 | #ifndef SIMULATE |
---|
632 | FILE *fp; |
---|
633 | unsigned int temp1, temp2; |
---|
634 | |
---|
635 | if(filename == NULL) return -1; |
---|
636 | |
---|
637 | debug(200, "hardware decode picture (%s)...", filename); |
---|
638 | |
---|
639 | if (!(fp = fopen(filename, "rb"))) |
---|
640 | return -1; |
---|
641 | |
---|
642 | if(get_jpeg_img_size(fp, &temp1, &temp2) != LIBMMEIMG_SUCCESS) |
---|
643 | return -1; |
---|
644 | |
---|
645 | *width = temp1; |
---|
646 | *height = temp2; |
---|
647 | *channels = 3; |
---|
648 | *rowbytes = *channels * temp1; |
---|
649 | |
---|
650 | if(allocbpamem(temp1 * temp2 * (*channels), memfd, mem) != 0) |
---|
651 | { |
---|
652 | fclose(fp); |
---|
653 | return -1; |
---|
654 | } |
---|
655 | |
---|
656 | if(decode_jpeg_noalloc(fp, temp1, temp2, temp1, temp2, (char *)*mem, 1) == LIBMMEIMG_SUCCESS) |
---|
657 | { |
---|
658 | fclose(fp); |
---|
659 | return 0; |
---|
660 | } |
---|
661 | |
---|
662 | fclose(fp); |
---|
663 | freebpamem(*memfd, *mem, temp1 * temp2 * (*channels)); |
---|
664 | err("hardware decode error"); |
---|
665 | #endif |
---|
666 | return -1; |
---|
667 | */ |
---|
668 | return -1; |
---|
669 | } |
---|
670 | |
---|
671 | //flag 0: blit from accelfb to skinfb |
---|
672 | //flag 1: blit from skinfb to accelfb |
---|
673 | void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag) |
---|
674 | { |
---|
675 | #ifndef SIMULATE |
---|
676 | #ifdef BLITHELP |
---|
677 | unsigned char *quelle = NULL; |
---|
678 | unsigned char *ziehl = NULL; |
---|
679 | unsigned char *helpbuf = NULL; |
---|
680 | int zpitch = 0; |
---|
681 | int zheight = 0; |
---|
682 | |
---|
683 | if(scalewidth == 0) scalewidth = width; |
---|
684 | if(scaleheight == 0) scaleheight = height; |
---|
685 | |
---|
686 | if(posx < 0) posx = 0; |
---|
687 | if(posx > skinfb->width) posx = skinfb->width; |
---|
688 | if(posy < 0) posy = 0; |
---|
689 | if(posy > skinfb->height) posy = skinfb->height; |
---|
690 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
691 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
692 | |
---|
693 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
694 | |
---|
695 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
696 | { |
---|
697 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
698 | return; |
---|
699 | } |
---|
700 | if(flag == 0) |
---|
701 | { |
---|
702 | quelle = accelfb->fb; |
---|
703 | ziehl = skinfb->fb + (posy * skinfb->pitch) + (posx*4); |
---|
704 | zpitch = skinfb->pitch; |
---|
705 | zheight = skinfb->height; |
---|
706 | } |
---|
707 | else |
---|
708 | { |
---|
709 | quelle = skinfb->fb; |
---|
710 | ziehl = accelfb->fb + (posy * accelfb->pitch) + (posx*4); |
---|
711 | zpitch = accelfb->pitch; |
---|
712 | zheight = accelfb->height; |
---|
713 | } |
---|
714 | helpbuf = scale(quelle, width, height, 4, scalewidth, scaleheight, 0); |
---|
715 | |
---|
716 | size_t helpb = 0; |
---|
717 | size_t helpz = 0; |
---|
718 | size_t help = 0; |
---|
719 | |
---|
720 | while(helpz < scaleheight && helpz < (zheight - posy)) { |
---|
721 | memcpy(ziehl[help], helpbuf[helpb], scalewidth*4); |
---|
722 | help = help + zpitch; |
---|
723 | helpb = helpb + scalewidth*4; |
---|
724 | helpz = helpz + 1; |
---|
725 | } |
---|
726 | |
---|
727 | free(helpbuf); |
---|
728 | if(flag == 0) |
---|
729 | blit(); |
---|
730 | |
---|
731 | #endif |
---|
732 | |
---|
733 | /* |
---|
734 | STMFBIO_BLT_DATA blt_data; |
---|
735 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
736 | |
---|
737 | if(scalewidth == 0) scalewidth = width; |
---|
738 | if(scaleheight == 0) scaleheight = height; |
---|
739 | |
---|
740 | if(posx < 0) posx = 0; |
---|
741 | if(posx > skinfb->width) posx = skinfb->width; |
---|
742 | if(posy < 0) posy = 0; |
---|
743 | if(posy > skinfb->height) posy = skinfb->height; |
---|
744 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
745 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
746 | |
---|
747 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
748 | |
---|
749 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
750 | { |
---|
751 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
752 | return; |
---|
753 | } |
---|
754 | |
---|
755 | blt_data.operation = BLT_OP_COPY; |
---|
756 | |
---|
757 | if(flag == 0) |
---|
758 | { |
---|
759 | if(status.usedirectfb == 1) |
---|
760 | blt_data.srcOffset = fb->varfbsize; |
---|
761 | else |
---|
762 | blt_data.srcOffset = fb->varfbsize + skinfb->varfbsize; |
---|
763 | } |
---|
764 | else |
---|
765 | { |
---|
766 | if(status.usedirectfb == 1) |
---|
767 | blt_data.srcOffset = 0; |
---|
768 | else |
---|
769 | blt_data.srcOffset = fb->varfbsize; |
---|
770 | } |
---|
771 | |
---|
772 | blt_data.srcPitch = width * 4; |
---|
773 | blt_data.src_top = 0; |
---|
774 | blt_data.src_left = 0; |
---|
775 | blt_data.src_right = width; |
---|
776 | blt_data.src_bottom = height; |
---|
777 | blt_data.srcFormat = SURF_ARGB8888; |
---|
778 | blt_data.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
779 | |
---|
780 | if(flag == 0) |
---|
781 | { |
---|
782 | if(status.usedirectfb == 1) |
---|
783 | { |
---|
784 | blt_data.dstOffset = 0; |
---|
785 | blt_data.dstPitch = fb->pitch; |
---|
786 | } |
---|
787 | else |
---|
788 | { |
---|
789 | blt_data.dstOffset = fb->varfbsize; |
---|
790 | blt_data.dstPitch = skinfb->pitch; |
---|
791 | } |
---|
792 | } |
---|
793 | else |
---|
794 | { |
---|
795 | if(status.usedirectfb == 1) |
---|
796 | { |
---|
797 | blt_data.dstOffset = fb->varfbsize; |
---|
798 | blt_data.dstPitch = skinfb->pitch; |
---|
799 | } |
---|
800 | else |
---|
801 | { |
---|
802 | blt_data.dstOffset = fb->varfbsize + skinfb->varfbsize; |
---|
803 | blt_data.dstPitch = scalewidth * 4; |
---|
804 | } |
---|
805 | } |
---|
806 | |
---|
807 | blt_data.dst_left = posx; |
---|
808 | blt_data.dst_top = posy; |
---|
809 | blt_data.dst_right = posx + scalewidth; |
---|
810 | blt_data.dst_bottom = posy + scaleheight; |
---|
811 | blt_data.dstFormat = SURF_ARGB8888; |
---|
812 | blt_data.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
813 | |
---|
814 | if (ioctl(fb->fd, STMFBIO_BLT, &blt_data) < 0) |
---|
815 | { |
---|
816 | perr("ioctl STMFBIO_BLT"); |
---|
817 | } |
---|
818 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
819 | { |
---|
820 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
821 | } |
---|
822 | */ |
---|
823 | #endif |
---|
824 | } |
---|
825 | |
---|
826 | 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) |
---|
827 | //void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight) |
---|
828 | { |
---|
829 | #ifndef SIMULATE |
---|
830 | #ifdef BLITHELP |
---|
831 | unsigned char *helpbuf = NULL; |
---|
832 | unsigned char *framebuf = NULL; |
---|
833 | |
---|
834 | if(scalewidth != 0 || scaleheight != 0) { |
---|
835 | helpbuf = scale(buf, width, height, 3, scalewidth, scaleheight, 1); |
---|
836 | if(helpbuf == NULL) |
---|
837 | return; |
---|
838 | } |
---|
839 | else { |
---|
840 | helpbuf = buf; |
---|
841 | scalewidth = width; |
---|
842 | scaleheight = height; |
---|
843 | } |
---|
844 | size_t helpb = 0; |
---|
845 | size_t helpz = 0; |
---|
846 | size_t help = 0; |
---|
847 | |
---|
848 | framebuf = skinfb->fb; |
---|
849 | framebuf = framebuf + (posy * skinfb->pitch) + (posx*4); |
---|
850 | |
---|
851 | while(helpz < scaleheight && helpz < (skinfb->height - posy)) { |
---|
852 | help = 0; |
---|
853 | while(help < (scalewidth*4) && help < (skinfb->pitch - (posx*4))) { |
---|
854 | framebuf[help+0] = helpbuf[helpb+2]; |
---|
855 | framebuf[help+1] = helpbuf[helpb+1]; |
---|
856 | framebuf[help+2] = helpbuf[helpb+0]; |
---|
857 | framebuf[help+3] = 0xff; |
---|
858 | help = help + 4; |
---|
859 | helpb = helpb + 3; |
---|
860 | } |
---|
861 | if(help >= (skinfb->pitch - (posx*4))) |
---|
862 | helpb = (helpz+1) * (scalewidth*3); |
---|
863 | framebuf = framebuf + skinfb->pitch; |
---|
864 | helpz = helpz + 1; |
---|
865 | } |
---|
866 | free(helpbuf); |
---|
867 | blit(); |
---|
868 | #endif |
---|
869 | |
---|
870 | /* |
---|
871 | STMFBIO_BLT_EXTERN_DATA blt_data; |
---|
872 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); |
---|
873 | |
---|
874 | blt_data.operation = BLT_OP_COPY; |
---|
875 | blt_data.ulFlags = 0; |
---|
876 | blt_data.srcOffset = 0; |
---|
877 | blt_data.srcPitch = width * 3; |
---|
878 | blt_data.dstOffset = 0; |
---|
879 | blt_data.dstPitch = skinfb->pitch; |
---|
880 | blt_data.src_top = 0; |
---|
881 | blt_data.src_left = 0; |
---|
882 | blt_data.src_right = width; |
---|
883 | blt_data.src_bottom = height; |
---|
884 | blt_data.dst_left = posx; |
---|
885 | blt_data.dst_top = posy; |
---|
886 | |
---|
887 | if(scalewidth == 0) scalewidth = width; |
---|
888 | if(scaleheight == 0) scaleheight = height; |
---|
889 | |
---|
890 | blt_data.dst_right = posx + scalewidth; |
---|
891 | blt_data.dst_bottom = posy + scaleheight; |
---|
892 | blt_data.srcFormat = SURF_BGR888; |
---|
893 | blt_data.dstFormat = SURF_ARGB8888; |
---|
894 | blt_data.srcMemBase = (char *)buf; |
---|
895 | blt_data.dstMemBase = (char *)skinfb->fb; |
---|
896 | blt_data.srcMemSize = width * height * 3; |
---|
897 | blt_data.dstMemSize = skinfb->pitch * skinfb->height; |
---|
898 | |
---|
899 | if(ioctl(skinfb->fd, STMFBIO_BLT_EXTERN, &blt_data) < 0) |
---|
900 | { |
---|
901 | err("ioctl STMFBIO_BLT_EXTERN"); |
---|
902 | } |
---|
903 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
904 | { |
---|
905 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
906 | } |
---|
907 | */ |
---|
908 | |
---|
909 | #endif |
---|
910 | } |
---|
911 | |
---|
912 | void initsignal(struct sigaction* sa) |
---|
913 | { |
---|
914 | sigaction(SIGILL, sa, NULL); |
---|
915 | sigaction(SIGBUS, sa, NULL); |
---|
916 | sigaction(SIGFPE, sa, NULL); |
---|
917 | sigaction(SIGUSR1, sa, NULL); |
---|
918 | sigaction(SIGSEGV, sa, NULL); |
---|
919 | sigaction(SIGUSR2, sa, NULL); |
---|
920 | sigaction(SIGPIPE, sa, NULL); |
---|
921 | sigaction(SIGALRM, sa, NULL); |
---|
922 | // sigaction(SIGSTKFLT, sa, NULL); |
---|
923 | sigaction(SIGABRT, sa, NULL); |
---|
924 | |
---|
925 | signal(SIGHUP, SIG_IGN); |
---|
926 | signal(SIGINT, SIG_IGN); |
---|
927 | signal(SIGTRAP, SIG_IGN); |
---|
928 | signal(SIGXCPU, SIG_IGN); |
---|
929 | signal(SIGXFSZ, SIG_IGN); |
---|
930 | signal(SIGVTALRM, SIG_IGN); |
---|
931 | signal(SIGPROF, SIG_IGN); |
---|
932 | signal(SIGPOLL, SIG_IGN); |
---|
933 | signal(SIGRTMAX, SIG_IGN); |
---|
934 | signal(SIGPWR, SIG_IGN); |
---|
935 | signal(SIGSYS, SIG_IGN); |
---|
936 | } |
---|
937 | |
---|
938 | void sighandler(int sig, struct sigcontext ctx) |
---|
939 | { |
---|
940 | switch(sig) |
---|
941 | { |
---|
942 | case SIGALRM: |
---|
943 | { |
---|
944 | err("got signal sigalrm but ignore it"); |
---|
945 | break; |
---|
946 | } |
---|
947 | case SIGPIPE: |
---|
948 | { |
---|
949 | err("got signal sigpipe but ignore it"); |
---|
950 | break; |
---|
951 | } |
---|
952 | case SIGUSR1: |
---|
953 | { |
---|
954 | //todo all configs |
---|
955 | reloadconfig(status.configfile); |
---|
956 | reloadconfig(getconfig("ownconfig", NULL)); |
---|
957 | break; |
---|
958 | } |
---|
959 | case SIGUSR2: //called if hanging mainthread detect |
---|
960 | { |
---|
961 | debugstack(sig, NULL, NULL); |
---|
962 | break; |
---|
963 | } |
---|
964 | case SIGILL: |
---|
965 | case SIGBUS: |
---|
966 | case SIGFPE: |
---|
967 | case SIGSEGV: |
---|
968 | // case SIGSTKFLT: |
---|
969 | { |
---|
970 | /* |
---|
971 | #ifdef SIMULATE |
---|
972 | //intel |
---|
973 | debugstack((void *)ctx.eip, NULL); |
---|
974 | err("got signal %d, fault address 0x%lx from 0x%lx", sig, ctx.cr2, ctx.eip); |
---|
975 | #else |
---|
976 | // sh4 |
---|
977 | //unsigned long sc_regs[16]; |
---|
978 | //unsigned long sc_pc; //programm counter register |
---|
979 | //unsigned long sc_pr; //procedure register |
---|
980 | //unsigned long sc_sr; //status register |
---|
981 | //unsigned long sc_gbr; |
---|
982 | //unsigned long sc_mach; |
---|
983 | //unsigned long sc_macl; |
---|
984 | |
---|
985 | debugstack(sig, (void *)ctx.sc_pr, (void *)ctx.sc_pc); |
---|
986 | err("got signal %d (%s), programm counter reg: 0x%lx, procedure reg: 0x%lx", sig, strsignal(sig), ctx.sc_pc, ctx.sc_pr); |
---|
987 | #endif |
---|
988 | */ |
---|
989 | if(getconfigint("saverun", NULL) == 1 && status.longjumpbuf != NULL) |
---|
990 | siglongjmp(status.longjumpbuf, 999); |
---|
991 | else |
---|
992 | exit(100); |
---|
993 | break; |
---|
994 | } |
---|
995 | } |
---|
996 | } |
---|
997 | |
---|
998 | int setvmpeg(struct dvbdev* node, int value, int flag) |
---|
999 | { |
---|
1000 | debug(4440, "in"); |
---|
1001 | char* vmpegdev = NULL, *tmpstr = NULL, *buf = NULL; |
---|
1002 | int ret = 0; |
---|
1003 | |
---|
1004 | if(node == NULL) return 1; |
---|
1005 | if(flag == 0) vmpegdev = getconfig("vmpegleftdev", NULL); |
---|
1006 | if(flag == 1) vmpegdev = getconfig("vmpegtopdev", NULL); |
---|
1007 | if(flag == 2) vmpegdev = getconfig("vmpegwidthdev", NULL); |
---|
1008 | if(flag == 3) vmpegdev = getconfig("vmpegheightdev", NULL); |
---|
1009 | if(flag == 99) vmpegdev = getconfig("vmpegapplydev", NULL); |
---|
1010 | |
---|
1011 | if(vmpegdev != NULL) |
---|
1012 | { |
---|
1013 | buf = malloc(MINMALLOC); |
---|
1014 | if(buf == NULL) |
---|
1015 | { |
---|
1016 | err("no mem"); |
---|
1017 | return 1; |
---|
1018 | } |
---|
1019 | |
---|
1020 | tmpstr = malloc(10); |
---|
1021 | if(tmpstr == NULL) |
---|
1022 | { |
---|
1023 | err("no mem"); |
---|
1024 | free(buf); |
---|
1025 | return 1; |
---|
1026 | } |
---|
1027 | |
---|
1028 | snprintf(buf, MINMALLOC, vmpegdev, node->devnr); |
---|
1029 | snprintf(tmpstr, 10, "%x", value); |
---|
1030 | debug(444, "set %s to %s", buf, tmpstr); |
---|
1031 | status.tvpic = 1; |
---|
1032 | ret = writesys(buf, tmpstr, 1); |
---|
1033 | |
---|
1034 | free(tmpstr); |
---|
1035 | free(buf); |
---|
1036 | return ret; |
---|
1037 | } |
---|
1038 | |
---|
1039 | debug(4440, "out"); |
---|
1040 | return 0; |
---|
1041 | } |
---|
1042 | |
---|
1043 | //flag 0: wh = width |
---|
1044 | //flag 1: wh = height |
---|
1045 | int setvmpegrect(struct dvbdev* node, int left, int top, int wh, int flag) |
---|
1046 | { |
---|
1047 | int ret = 0; |
---|
1048 | |
---|
1049 | if(flag == 0) |
---|
1050 | { |
---|
1051 | ret = setvmpeg(node, wh, 2); |
---|
1052 | ret = setvmpeg(node, wh / 1.4, 3); |
---|
1053 | } |
---|
1054 | if(flag == 1) |
---|
1055 | { |
---|
1056 | ret = setvmpeg(node, wh, 3); |
---|
1057 | ret = setvmpeg(node, wh * 1.3, 2); |
---|
1058 | } |
---|
1059 | |
---|
1060 | ret = setvmpeg(node, left, 0); |
---|
1061 | ret = setvmpeg(node, top, 1); |
---|
1062 | |
---|
1063 | setvmpeg(node, 0, 99); |
---|
1064 | |
---|
1065 | return ret; |
---|
1066 | } |
---|
1067 | |
---|
1068 | int resetvmpeg(struct dvbdev* node) |
---|
1069 | { |
---|
1070 | int ret = 0; |
---|
1071 | |
---|
1072 | ret = setvmpeg(node, 0, 0); |
---|
1073 | ret = setvmpeg(node, 0, 1); |
---|
1074 | ret = setvmpeg(node, 0, 2); |
---|
1075 | ret = setvmpeg(node, 0, 3); |
---|
1076 | |
---|
1077 | ret = setvmpeg(node, 0, 99); |
---|
1078 | |
---|
1079 | return ret; |
---|
1080 | } |
---|
1081 | |
---|
1082 | int resettvpic() |
---|
1083 | { |
---|
1084 | /* |
---|
1085 | if(status.tvpic == 1 && status.aktservice != NULL) |
---|
1086 | { |
---|
1087 | status.tvpic = 0; |
---|
1088 | resetvmpeg(status.aktservice->videodev); |
---|
1089 | } |
---|
1090 | */ |
---|
1091 | int ret = 0; |
---|
1092 | |
---|
1093 | if(status.tvpic > 0 && status.aktservice != NULL) |
---|
1094 | { |
---|
1095 | status.tvpic = 0; |
---|
1096 | ret = resetvmpeg(status.aktservice->videodev); |
---|
1097 | } |
---|
1098 | |
---|
1099 | return ret; |
---|
1100 | } |
---|
1101 | |
---|
1102 | int cagetslotinfo(struct dvbdev* node, ca_slot_info_t* info) |
---|
1103 | { |
---|
1104 | int ret = 0; |
---|
1105 | |
---|
1106 | if(node == NULL || info == NULL) |
---|
1107 | { |
---|
1108 | err("NULL detect"); |
---|
1109 | return 1; |
---|
1110 | } |
---|
1111 | |
---|
1112 | struct pollfd fds; |
---|
1113 | |
---|
1114 | fds.fd = node->fd; |
---|
1115 | fds.events = POLLOUT | POLLPRI | POLLIN; |
---|
1116 | |
---|
1117 | info->flags = 0; |
---|
1118 | |
---|
1119 | ret = TEMP_FAILURE_RETRY(poll(&fds, 1, 1000)); |
---|
1120 | |
---|
1121 | if(ret < 0) |
---|
1122 | { |
---|
1123 | err("poll data"); |
---|
1124 | return 1; //error |
---|
1125 | } |
---|
1126 | else if(ret == 0) |
---|
1127 | return 0; //timeout |
---|
1128 | else if(ret > 0) |
---|
1129 | { |
---|
1130 | if(fds.revents & POLLOUT) |
---|
1131 | info->flags = CA_CI_MODULE_READY; |
---|
1132 | if(fds.revents & POLLIN) |
---|
1133 | info->flags = CA_CI_MODULE_READY; |
---|
1134 | if(fds.revents & POLLPRI) |
---|
1135 | info->flags = 0; |
---|
1136 | } |
---|
1137 | |
---|
1138 | return 0; |
---|
1139 | } |
---|
1140 | |
---|
1141 | void memcpy_word(char* dest, char* src, long anzw) |
---|
1142 | { |
---|
1143 | // Folgende Werte müssen volatile definiert sein |
---|
1144 | // char* memcpy_word_src ---> pointer Quelle |
---|
1145 | // char* memcpy_word_dest ---> pointer Ziehl |
---|
1146 | // long memcpy_word_anzw ---> Anzahl der Wörter (4 byte) die kopiert werden sollen. |
---|
1147 | |
---|
1148 | memcpy_word_src = src; |
---|
1149 | memcpy_word_dest = dest; |
---|
1150 | memcpy_word_anzw = anzw; |
---|
1151 | |
---|
1152 | asm( |
---|
1153 | " lw $8, memcpy_word_src \n" |
---|
1154 | " lw $9, memcpy_word_dest \n" |
---|
1155 | " lw $10, memcpy_word_anzw \n" |
---|
1156 | " addi $10, $10, -1 \n" |
---|
1157 | "loop1: \n" |
---|
1158 | " lw $11, ($8) \n" |
---|
1159 | " sw $11, ($9) \n" |
---|
1160 | " addi $8, $8, 4 \n" |
---|
1161 | " addi $9, $9, 4 \n" |
---|
1162 | " addi $10, $10, -1 \n" |
---|
1163 | " bgez $10, loop1 \n" |
---|
1164 | ); |
---|
1165 | } |
---|
1166 | |
---|
1167 | void memcpy_byte(char* dest, char* src, long anzb) |
---|
1168 | { |
---|
1169 | // Folgende Werte müssen volatile definiert sein |
---|
1170 | // char* memcpy_byte_src ---> pointer Quelle |
---|
1171 | // char* memcpy_byte_dest ---> pointer Ziehl |
---|
1172 | // long memcpy_byte_anzb ---> Anzahl bytes die kopiert werden sollen. |
---|
1173 | |
---|
1174 | memcpy_byte_src = src; |
---|
1175 | memcpy_byte_dest = dest; |
---|
1176 | memcpy_byte_anzb = anzb; |
---|
1177 | |
---|
1178 | asm ( |
---|
1179 | " li $12, 4 \n" |
---|
1180 | " lw $8, memcpy_byte_src \n" |
---|
1181 | " lw $9, memcpy_byte_dest \n" |
---|
1182 | " lw $10, memcpy_byte_anzb \n" |
---|
1183 | "word: \n" |
---|
1184 | " bltu $10, $12, byte \n" |
---|
1185 | " lw $11, ($8) \n" |
---|
1186 | " sw $11, ($9) \n" |
---|
1187 | " addi $8, $8, 4 \n" |
---|
1188 | " addi $9, $9, 4 \n" |
---|
1189 | " addi $10, $10, -4 \n" |
---|
1190 | " b word \n" |
---|
1191 | "byte: \n" |
---|
1192 | " beqz $10, end \n" |
---|
1193 | " lb $11, ($8) \n" |
---|
1194 | " sb $11, ($9) \n" |
---|
1195 | " addi $8, $8, 1 \n" |
---|
1196 | " addi $9, $9, 1 \n" |
---|
1197 | " addi $10, $10, -1 \n" |
---|
1198 | " b byte \n" |
---|
1199 | "end: \n" |
---|
1200 | " nop \n" |
---|
1201 | ); |
---|
1202 | } |
---|
1203 | |
---|
1204 | |
---|
1205 | void memcpy_area(unsigned char* ziehlADDR, unsigned char* startADDR, long pxAbs, long hight, long widthAbs, long FBwidthAbs) |
---|
1206 | { |
---|
1207 | |
---|
1208 | asm( |
---|
1209 | |
---|
1210 | " lw $t3, %[ziehlADDR] \n" |
---|
1211 | " lw $t4, %[startADDR] \n" |
---|
1212 | " lw $t5, %[pxAbs] \n" |
---|
1213 | " lw $t6, %[widthAbs] \n" |
---|
1214 | " lw $t7, %[FBwidthAbs] \n" |
---|
1215 | " lw $t8, %[hight] \n" |
---|
1216 | |
---|
1217 | " move $t0, $t4 # Temp-startADDR \n" |
---|
1218 | " move $t1, $t6 # Temp-widthAbs \n" |
---|
1219 | " add $t2, $t5, $t6 \n" |
---|
1220 | " sub $t7, $t7, $t2 # Diff withAbs und FBwidthAbs \n" |
---|
1221 | |
---|
1222 | "p3NewLine2: \n" |
---|
1223 | " beqz $t8, p3End \n" |
---|
1224 | "p3NextWord: \n" |
---|
1225 | " beqz $t1, p3NewLine1 \n" |
---|
1226 | " lw $t9, ($t0) \n" |
---|
1227 | " sw $t9, ($t3) \n" |
---|
1228 | " addi $t0, 4 \n" |
---|
1229 | " addi $t3, 4 \n" |
---|
1230 | " addi $t1, -4 \n" |
---|
1231 | " b p3NextWord \n" |
---|
1232 | |
---|
1233 | |
---|
1234 | "p3NewLine1: \n" |
---|
1235 | " move $t0, $t4 \n" |
---|
1236 | " move $t1, $t6 \n" |
---|
1237 | " add $t3, $t3, $t7 \n" |
---|
1238 | " add $t3, $t3, $t5 \n" |
---|
1239 | " addi $t8, -1 \n" |
---|
1240 | " b p3NewLine2 \n" |
---|
1241 | |
---|
1242 | "p3End: \n" |
---|
1243 | " nop \n" |
---|
1244 | ::[ziehlADDR] "m" (ziehlADDR), [startADDR] "m" (startADDR), [pxAbs] "m" (pxAbs), [widthAbs] "m" (widthAbs), [FBwidthAbs] "m" (FBwidthAbs), [hight] "m" (hight) |
---|
1245 | ); |
---|
1246 | |
---|
1247 | return; |
---|
1248 | } |
---|
1249 | |
---|
1250 | int setfbosddev(char* dev, int value) |
---|
1251 | { |
---|
1252 | char* tmpstr = NULL; |
---|
1253 | int ret = 0; |
---|
1254 | |
---|
1255 | tmpstr = malloc(10); |
---|
1256 | if(tmpstr == NULL) |
---|
1257 | { |
---|
1258 | err("no mem"); |
---|
1259 | return 1; |
---|
1260 | } |
---|
1261 | |
---|
1262 | sprintf(tmpstr, "%x", value); |
---|
1263 | debug(101, "set %s to %s", dev, tmpstr); |
---|
1264 | |
---|
1265 | if(dev != NULL) |
---|
1266 | { |
---|
1267 | ret = writesys(dev, tmpstr, 1); |
---|
1268 | return ret; |
---|
1269 | } |
---|
1270 | |
---|
1271 | return 0; |
---|
1272 | } |
---|
1273 | |
---|
1274 | char* getfbosddev(char* dev) |
---|
1275 | { |
---|
1276 | char *value = NULL; |
---|
1277 | |
---|
1278 | if(dev == NULL) |
---|
1279 | { |
---|
1280 | err("NULL detect"); |
---|
1281 | return NULL; |
---|
1282 | } |
---|
1283 | |
---|
1284 | value = readsys(dev, 1); |
---|
1285 | if(value == NULL) |
---|
1286 | { |
---|
1287 | err("NULL detect"); |
---|
1288 | return NULL; |
---|
1289 | } |
---|
1290 | |
---|
1291 | debug(101, "get %s to %s", dev, value); |
---|
1292 | |
---|
1293 | return value; |
---|
1294 | } |
---|
1295 | |
---|
1296 | |
---|
1297 | void setfbosd() |
---|
1298 | { |
---|
1299 | debug(101, "################## set osd offset ####################"); |
---|
1300 | debug(101, "status.leftoffset: %d", status.leftoffset); |
---|
1301 | debug(101, "status.rightoffset: %d", status.rightoffset); |
---|
1302 | debug(101, "status.topoffset: %d", status.topoffset); |
---|
1303 | debug(101, "status.bottomoffset: %d", status.bottomoffset); |
---|
1304 | |
---|
1305 | char* fbleftdev = "/proc/stb/fb/dst_left"; |
---|
1306 | char* fbwidthdev = "/proc/stb/fb/dst_width"; |
---|
1307 | char* fbtopdev = "/proc/stb/fb/dst_top"; |
---|
1308 | char* fbheightdev = "/proc/stb/fb/dst_height"; |
---|
1309 | |
---|
1310 | int fbleft = strtol(getfbosddev(fbleftdev) , NULL, 16); |
---|
1311 | int fbwidth = strtol(getfbosddev(fbwidthdev) , NULL, 16); |
---|
1312 | int fbtop = strtol(getfbosddev(fbtopdev) , NULL, 16); |
---|
1313 | int fbheight = strtol(getfbosddev(fbheightdev) , NULL, 16); |
---|
1314 | debug(101, "Setting OSD position: %d %d %d %d", fbleft ,fbwidth ,fbtop ,fbheight); |
---|
1315 | |
---|
1316 | fbleft = status.leftoffset; |
---|
1317 | fbwidth = 720 - status.leftoffset - status.rightoffset; |
---|
1318 | fbtop = status.topoffset; |
---|
1319 | fbheight = 576 - status.topoffset - status.bottomoffset; |
---|
1320 | debug(101, "Setting OSD position changed: %d %d %d %d", fbleft ,fbwidth ,fbtop ,fbheight); |
---|
1321 | debug(10, "Setting OSD position changed: %d %d %d %d", fbleft ,fbwidth ,fbtop ,fbheight); |
---|
1322 | |
---|
1323 | setfbosddev(fbleftdev, fbleft); |
---|
1324 | setfbosddev(fbwidthdev, fbwidth); |
---|
1325 | setfbosddev(fbtopdev, fbtop); |
---|
1326 | setfbosddev(fbheightdev, fbheight); |
---|
1327 | debug(101, "######################################################"); |
---|
1328 | } |
---|
1329 | |
---|
1330 | #endif |
---|