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* targetADDR, 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 | int doblit = 1; |
---|
132 | struct fb_var_screeninfo var_screeninfo; |
---|
133 | |
---|
134 | var_screeninfo.xres_virtual = fb->width; |
---|
135 | var_screeninfo.xres = fb->width; |
---|
136 | var_screeninfo.yres_virtual = fb->height * 2; |
---|
137 | var_screeninfo.yres = fb->height; |
---|
138 | var_screeninfo.height = 0; |
---|
139 | var_screeninfo.width = 0; |
---|
140 | var_screeninfo.xoffset = 0; |
---|
141 | var_screeninfo.yoffset = 0; |
---|
142 | var_screeninfo.bits_per_pixel = fb->colbytes * 8; |
---|
143 | |
---|
144 | switch(fb->colbytes) |
---|
145 | { |
---|
146 | case 2: |
---|
147 | var_screeninfo.transp.offset = 15; |
---|
148 | var_screeninfo.transp.length = 1; |
---|
149 | var_screeninfo.red.offset = 10; |
---|
150 | var_screeninfo.red.length = 5; |
---|
151 | var_screeninfo.green.offset = 5; |
---|
152 | var_screeninfo.green.length = 5; |
---|
153 | var_screeninfo.blue.offset = 0; |
---|
154 | var_screeninfo.blue.length = 5; |
---|
155 | break; |
---|
156 | case 4: |
---|
157 | var_screeninfo.transp.offset = 24; |
---|
158 | var_screeninfo.transp.length = 8; |
---|
159 | var_screeninfo.red.offset = 16; |
---|
160 | var_screeninfo.red.length = 8; |
---|
161 | var_screeninfo.green.offset = 8; |
---|
162 | var_screeninfo.green.length = 8; |
---|
163 | var_screeninfo.blue.offset = 0; |
---|
164 | var_screeninfo.blue.length = 8; |
---|
165 | break; |
---|
166 | } |
---|
167 | |
---|
168 | debug(444, "FB: line_length %d", fix_screeninfo.line_length); |
---|
169 | debug(444, "FB: var_screeninfo.xres %d", var_screeninfo.xres); |
---|
170 | debug(444, "FB: var_screeninfo.yres %d", var_screeninfo.yres); |
---|
171 | debug(444, "FB: var_screeninfo.xres_virt %d", var_screeninfo.xres_virtual); |
---|
172 | debug(444, "FB: var_screeninfo.yres_virt %d", var_screeninfo.yres_virtual); |
---|
173 | debug(444, "FB: var_screeninfo.xoffset %d", var_screeninfo.xoffset); |
---|
174 | debug(444, "FB: var_screeninfo.yoffset %d", var_screeninfo.yoffset); |
---|
175 | debug(444, "FB: var_screeninfo.bits_per_pixel %d", var_screeninfo.bits_per_pixel); |
---|
176 | debug(444, "FB: var_screeninfo.grayscale %d", var_screeninfo.grayscale); |
---|
177 | |
---|
178 | if(ioctl(fb->fd, FBIOPUT_VSCREENINFO, &var_screeninfo) < 0) |
---|
179 | { |
---|
180 | var_screeninfo.yres_virtual = fb->height; |
---|
181 | if(ioctl(fb->fd, FBIOPUT_VSCREENINFO, &var_screeninfo) < 0) |
---|
182 | { |
---|
183 | perr("FBIOPUT_VSCREENINFO"); |
---|
184 | } |
---|
185 | debug(444, "FB: double buffering not available"); |
---|
186 | } |
---|
187 | else |
---|
188 | { |
---|
189 | debug(444, "FB: double buffering available!"); |
---|
190 | } |
---|
191 | |
---|
192 | ioctl(fb->fd, FBIOGET_VSCREENINFO, &var_screeninfo); |
---|
193 | if ((var_screeninfo.xres!=fb->width) && (var_screeninfo.yres!=fb->height) && (var_screeninfo.bits_per_pixel!=fb->colbytes)) |
---|
194 | { |
---|
195 | debug(444, "SetMode failed: wanted: %dx%dx%d, got %dx%dx%d", |
---|
196 | fb->width, fb->height, fb->colbytes, |
---|
197 | var_screeninfo.xres, var_screeninfo.yres, var_screeninfo.bits_per_pixel); |
---|
198 | } |
---|
199 | |
---|
200 | int posx = 0; |
---|
201 | int posy = 0; |
---|
202 | int width = 0; |
---|
203 | int height = 0; |
---|
204 | |
---|
205 | if(status.bcm == 1 && status.usedirectfb == 0) |
---|
206 | { |
---|
207 | width = (fb->width - posx) - (getconfigint("fbrightoffset", NULL) * 5); |
---|
208 | height = (fb->height - posy) - (getconfigint("fbbottomoffset", NULL) * 5); |
---|
209 | posx = getconfigint("fbleftoffset", NULL) * 5; |
---|
210 | posy = getconfigint("fbtopoffset", NULL) * 5; |
---|
211 | } |
---|
212 | else |
---|
213 | { |
---|
214 | width = (720 - posx) - (getconfigint("fbrightoffset", NULL)); |
---|
215 | height = (576 - posy) - (getconfigint("fbbottomoffset", NULL)); |
---|
216 | posx = getconfigint("fbleftoffset", NULL); |
---|
217 | posy = getconfigint("fbtopoffset", NULL); |
---|
218 | } |
---|
219 | |
---|
220 | //printf("posx:%i posy:%i width:%i height:%i\n", posx, posy, width, height); |
---|
221 | |
---|
222 | int i = 0, max = 1, wstep = 0, hstep = 0; |
---|
223 | int dst_left = 0, dst_width = 0, dst_top = 0, dst_height = 0; |
---|
224 | int mode3d = 0; |
---|
225 | |
---|
226 | if(flag == 0 || checkbox("ATEMIO5200") == 1) |
---|
227 | { |
---|
228 | if(status.bcm == 1 && status.usedirectfb == 0) |
---|
229 | bcm_accel_blit(skinfb->data_phys, skinfb->width, skinfb->height, skinfb->pitch, 0, fb->data_phys, fb->width, fb->height, fb->pitch, 0, 0, skinfb->width, skinfb->height, posx, posy, width, height, 0, 0); |
---|
230 | else |
---|
231 | blit(); |
---|
232 | return; |
---|
233 | } |
---|
234 | |
---|
235 | if(flag == 1 && status.screenanim > 0 && mode3d == 0) |
---|
236 | { |
---|
237 | doblit = 0; |
---|
238 | //max = 25; |
---|
239 | max = 8; |
---|
240 | dst_left = posx; |
---|
241 | dst_width = width; |
---|
242 | dst_top = posy; |
---|
243 | dst_height = height; |
---|
244 | |
---|
245 | char* fbleftdev = "/proc/stb/fb/dst_left"; |
---|
246 | char* fbwidthdev = "/proc/stb/fb/dst_width"; |
---|
247 | char* fbtopdev = "/proc/stb/fb/dst_top"; |
---|
248 | char* fbheightdev = "/proc/stb/fb/dst_height"; |
---|
249 | |
---|
250 | int screenanimspeed = 0; |
---|
251 | |
---|
252 | if(status.bcm == 1 && status.usedirectfb == 0) |
---|
253 | { |
---|
254 | if(status.screenanimspeed == 1 || status.screenanimspeed == 0) |
---|
255 | max = 4; |
---|
256 | else if(status.screenanimspeed == 5) |
---|
257 | max = 8; |
---|
258 | else |
---|
259 | screenanimspeed = status.screenanimspeed; |
---|
260 | } |
---|
261 | else |
---|
262 | screenanimspeed = status.screenanimspeed; |
---|
263 | |
---|
264 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
265 | { |
---|
266 | dst_left = (width / 2) - 1; |
---|
267 | dst_width = 2; |
---|
268 | } |
---|
269 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
270 | { |
---|
271 | dst_top = (height / 2) - 1; |
---|
272 | dst_height = 2; |
---|
273 | } |
---|
274 | if(status.screenanim == 4) |
---|
275 | { |
---|
276 | dst_top = posy; |
---|
277 | dst_height = height; |
---|
278 | dst_left = posx; |
---|
279 | dst_width = 2; |
---|
280 | } |
---|
281 | if(status.screenanim == 5) |
---|
282 | { |
---|
283 | dst_top = posy; |
---|
284 | dst_height = 2; |
---|
285 | dst_left = posx; |
---|
286 | dst_width = width; |
---|
287 | } |
---|
288 | |
---|
289 | wstep = width / max; |
---|
290 | hstep = height / max; |
---|
291 | |
---|
292 | for(i = 0; i <= max; i++) |
---|
293 | { |
---|
294 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
295 | { |
---|
296 | int tmpleft = dst_left - (wstep/2); |
---|
297 | int tmpwidth = dst_width + wstep; |
---|
298 | if(tmpleft < posx) |
---|
299 | tmpleft = posx; |
---|
300 | if(tmpwidth > width) |
---|
301 | tmpwidth = width; |
---|
302 | dst_left = tmpleft; |
---|
303 | dst_width = tmpwidth; |
---|
304 | } |
---|
305 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
306 | { |
---|
307 | int tmptop = dst_top - (hstep/2); |
---|
308 | int tmpheight = dst_height + hstep; |
---|
309 | if(tmptop < posy) |
---|
310 | tmptop = posy; |
---|
311 | if(tmpheight > height) |
---|
312 | tmpheight = height; |
---|
313 | dst_top = tmptop; |
---|
314 | dst_height = tmpheight; |
---|
315 | } |
---|
316 | if(status.screenanim == 4) |
---|
317 | { |
---|
318 | int tmpwidth = dst_width + wstep; |
---|
319 | if(tmpwidth > width) |
---|
320 | tmpwidth = width; |
---|
321 | dst_width = tmpwidth; |
---|
322 | } |
---|
323 | if(status.screenanim == 5) |
---|
324 | { |
---|
325 | int tmpheight = dst_height + hstep; |
---|
326 | if(tmpheight > height) |
---|
327 | tmpheight = height; |
---|
328 | dst_height = tmpheight; |
---|
329 | } |
---|
330 | |
---|
331 | if((dst_width + dst_left) > width) |
---|
332 | dst_width = dst_width - dst_left; |
---|
333 | |
---|
334 | if((dst_height + dst_top) > height) |
---|
335 | dst_height = dst_height - dst_top; |
---|
336 | |
---|
337 | //printf("left:%i width:%i top:%i height:%i\n", dst_left, dst_width, dst_top, dst_height); |
---|
338 | //waitvsync(); |
---|
339 | if(status.bcm == 1 && status.usedirectfb == 0) |
---|
340 | bcm_accel_blit(skinfb->data_phys, skinfb->width, skinfb->height, skinfb->pitch, 0, fb->data_phys, fb->width, fb->height, fb->pitch, 0, 0, skinfb->width, skinfb->height, dst_left, dst_top, dst_width, dst_height, 0, 0); |
---|
341 | else |
---|
342 | { |
---|
343 | setfbosddev(fbleftdev, dst_left); |
---|
344 | setfbosddev(fbwidthdev, dst_width); |
---|
345 | setfbosddev(fbtopdev, dst_top); |
---|
346 | setfbosddev(fbheightdev, dst_height); |
---|
347 | usleep(1000); |
---|
348 | } |
---|
349 | if(status.screenanim > 0) usleep(status.screenanimspeed * 1000); |
---|
350 | blit(); |
---|
351 | } |
---|
352 | if(status.bcm == 1 && status.usedirectfb == 0) |
---|
353 | bcm_accel_blit(skinfb->data_phys, skinfb->width, skinfb->height, skinfb->pitch, 0, fb->data_phys, fb->width, fb->height, fb->pitch, 0, 0, skinfb->width, skinfb->height, posx, posy, width, height, 0, 0); |
---|
354 | else |
---|
355 | { |
---|
356 | setfbosddev(fbleftdev, posx); |
---|
357 | setfbosddev(fbwidthdev, width); |
---|
358 | setfbosddev(fbtopdev, posy); |
---|
359 | setfbosddev(fbheightdev, height); |
---|
360 | } |
---|
361 | blit(); |
---|
362 | } |
---|
363 | else |
---|
364 | bcm_accel_blit(skinfb->data_phys, skinfb->width, skinfb->height, skinfb->pitch, 0, fb->data_phys, fb->width, fb->height, fb->pitch, 0, 0, skinfb->width, skinfb->height, posx, posy, width, height, 0, 0); |
---|
365 | |
---|
366 | if(doblit == 1) |
---|
367 | blit(); |
---|
368 | |
---|
369 | /* |
---|
370 | int xRes, yRes, stride, bpp; |
---|
371 | |
---|
372 | xRes=var_screeninfo.xres; |
---|
373 | yRes=var_screeninfo.yres; |
---|
374 | bpp=var_screeninfo.bits_per_pixel; |
---|
375 | // fb_fix_screeninfo fix; |
---|
376 | // struct fb_fix_screeninfo fix_screeninfo; |
---|
377 | if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fix_screeninfo)<0) |
---|
378 | { |
---|
379 | perror("FBIOGET_FSCREENINFO"); |
---|
380 | printf("fb failed\n"); |
---|
381 | } |
---|
382 | stride=fix_screeninfo.line_length; |
---|
383 | memset(lfb, 0, stride*yRes); |
---|
384 | */ |
---|
385 | // blit(); |
---|
386 | |
---|
387 | /* |
---|
388 | int i = 0, max = 1, wstep = 0, hstep = 0, ret = 0; |
---|
389 | unsigned char buf[10]; |
---|
390 | |
---|
391 | if(fbnode == NULL) return; |
---|
392 | #ifndef NOHWBLIT |
---|
393 | if(fbnode == fb) return; |
---|
394 | |
---|
395 | if(status.rguidfd > -1) |
---|
396 | { |
---|
397 | m_lock(&status.accelfbmutex, 16); |
---|
398 | |
---|
399 | int zlen = 0; |
---|
400 | char* zbuf = NULL; |
---|
401 | blitscale(0, 0, fbnode->width, fbnode->height, 440, 330, 1); |
---|
402 | ret = ozip((char*)accelfb->fb, 440 * 330 * 4, &zbuf, &zlen, 1); |
---|
403 | |
---|
404 | if(ret == 0) |
---|
405 | { |
---|
406 | memset(buf, 0, 10); |
---|
407 | char* tmpnr = oitoa(zlen); |
---|
408 | memcpy(buf, tmpnr, strlen(tmpnr)); |
---|
409 | free(tmpnr); tmpnr = NULL; |
---|
410 | socksend(&status.rguidfd, buf, 10, 5000 * 1000); |
---|
411 | socksend(&status.rguidfd, (unsigned char*)zbuf, zlen, 5000 * 1000); |
---|
412 | } |
---|
413 | free(zbuf); zbuf = NULL; |
---|
414 | zlen = 0; |
---|
415 | |
---|
416 | m_unlock(&status.accelfbmutex, 16); |
---|
417 | } |
---|
418 | |
---|
419 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
420 | { |
---|
421 | m_lock(&status.accelfbmutex, 16); |
---|
422 | blitscale(0, 0, fbnode->width, fbnode->height, 320, 240, 1); |
---|
423 | if(writeFBfile.ActBuf == NULL) |
---|
424 | { |
---|
425 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
426 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
427 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
428 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
429 | } |
---|
430 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
431 | { |
---|
432 | if(writeFBfile.buf2 == NULL) |
---|
433 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
434 | memcpy(writeFBfile.buf2, accelfb->fb, 4 * 320 * 240); |
---|
435 | } |
---|
436 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
437 | { |
---|
438 | if(writeFBfile.buf1 == NULL) |
---|
439 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
440 | memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240); |
---|
441 | } |
---|
442 | m_unlock(&status.accelfbmutex, 16); |
---|
443 | } |
---|
444 | |
---|
445 | int mode3d = 0, leftoffset = 0, rightoffset = 0, topoffset = 0, bottomoffset = 0; |
---|
446 | char* mode3dstr = NULL; |
---|
447 | |
---|
448 | if(status.leftoffset != 0) blitrect(0, 0, status.leftoffset, fb->height, 0, 255, 2); |
---|
449 | if(status.rightoffset != 0) blitrect(fb->width - status.rightoffset, 0, status.rightoffset, fb->height, 0, 255, 2); |
---|
450 | if(status.topoffset != 0) blitrect(0, 0, fb->width, status.topoffset, 0, 255, 2); |
---|
451 | if(status.bottomoffset != 0) blitrect(0, fb->height - status.bottomoffset, fb->width, status.bottomoffset, 0, 255, 2); |
---|
452 | |
---|
453 | mode3dstr = getconfig("av_mode3d", NULL); |
---|
454 | if(ostrcmp(mode3dstr, "sbs") == 0) |
---|
455 | mode3d = 1; |
---|
456 | else if(ostrcmp(mode3dstr, "tab") == 0) |
---|
457 | mode3d = 2; |
---|
458 | |
---|
459 | STMFBIO_BLT_DATA bltData; |
---|
460 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
461 | |
---|
462 | bltData.operation = BLT_OP_COPY; |
---|
463 | bltData.srcOffset = fbnode->fb - fb->fb; |
---|
464 | bltData.srcPitch = fbnode->pitch; |
---|
465 | bltData.src_top = 0; |
---|
466 | bltData.src_left = 0; |
---|
467 | bltData.src_right = fbnode->width; |
---|
468 | bltData.src_bottom = fbnode->height; |
---|
469 | bltData.srcFormat = SURF_BGRA8888; |
---|
470 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
471 | |
---|
472 | bltData.dstOffset = 0; |
---|
473 | bltData.dstPitch = fb->pitch; |
---|
474 | bltData.dst_left = status.leftoffset; |
---|
475 | bltData.dst_top = status.topoffset; |
---|
476 | if(mode3d == 1) |
---|
477 | bltData.dst_right = (fb->width - status.rightoffset) / 2; |
---|
478 | else |
---|
479 | bltData.dst_right = fb->width - status.rightoffset; |
---|
480 | if(mode3d == 2) |
---|
481 | bltData.dst_bottom = (fb->height - status.bottomoffset) / 2; |
---|
482 | else |
---|
483 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
484 | bltData.dstFormat = SURF_BGRA8888; |
---|
485 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
486 | |
---|
487 | if(flag == 1 && status.screenanim > 0 && mode3d == 0) |
---|
488 | { |
---|
489 | int width = (fb->width - status.rightoffset) - status.leftoffset; |
---|
490 | int height = (fb->height - status.topoffset) - status.bottomoffset; |
---|
491 | max = 25; |
---|
492 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
493 | { |
---|
494 | bltData.dst_left = (width / 2) - 1; |
---|
495 | bltData.dst_right = (width / 2) + 1; |
---|
496 | } |
---|
497 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
498 | { |
---|
499 | bltData.dst_top = (height / 2) - 1; |
---|
500 | bltData.dst_bottom = (height / 2) + 1; |
---|
501 | } |
---|
502 | wstep = width / max; |
---|
503 | hstep = height / max; |
---|
504 | } |
---|
505 | |
---|
506 | for(i = 0; i < max; i++) |
---|
507 | { |
---|
508 | |
---|
509 | if(status.screenanim == 1 || status.screenanim == 3) |
---|
510 | { |
---|
511 | int tmpleft = bltData.dst_left - wstep; |
---|
512 | int tmpright = bltData.dst_right + wstep; |
---|
513 | if(tmpleft < status.leftoffset) |
---|
514 | tmpleft = status.leftoffset; |
---|
515 | if(tmpright > fb->width - status.rightoffset) |
---|
516 | tmpright = fb->width - status.rightoffset; |
---|
517 | bltData.dst_left = tmpleft; |
---|
518 | bltData.dst_right = tmpright; |
---|
519 | } |
---|
520 | |
---|
521 | if(status.screenanim == 2 || status.screenanim == 3) |
---|
522 | { |
---|
523 | int tmptop = bltData.dst_top - hstep; |
---|
524 | int tmpbottom = bltData.dst_bottom + hstep; |
---|
525 | if(tmptop < status.topoffset) |
---|
526 | tmptop = status.topoffset; |
---|
527 | if(tmpbottom > fb->height - status.bottomoffset) |
---|
528 | tmpbottom = fb->height - status.bottomoffset; |
---|
529 | bltData.dst_top = tmptop; |
---|
530 | bltData.dst_bottom = tmpbottom; |
---|
531 | } |
---|
532 | |
---|
533 | if(status.screenanim > 0) usleep(status.screenanimspeed * 1000); |
---|
534 | |
---|
535 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
536 | { |
---|
537 | perr("ioctl STMFBIO_BLT"); |
---|
538 | } |
---|
539 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
540 | { |
---|
541 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
542 | } |
---|
543 | |
---|
544 | if(mode3d != 0) |
---|
545 | { |
---|
546 | if(mode3d == 1) |
---|
547 | bltData.dst_left = 0 + status.leftoffset + ((fb->width - status.rightoffset) / 2); |
---|
548 | if(mode3d == 2) |
---|
549 | bltData.dst_top = 0 + status.topoffset + ((fb->height - status.bottomoffset) / 2); |
---|
550 | bltData.dst_right = fb->width - status.rightoffset; |
---|
551 | bltData.dst_bottom = fb->height - status.bottomoffset; |
---|
552 | |
---|
553 | if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
554 | { |
---|
555 | perr("ioctl STMFBIO_BLT"); |
---|
556 | } |
---|
557 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
558 | { |
---|
559 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
560 | } |
---|
561 | } |
---|
562 | } |
---|
563 | #else |
---|
564 | #ifdef NOFB |
---|
565 | if(status.rguidfd > -1) |
---|
566 | { |
---|
567 | char* buf = NULL; |
---|
568 | buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0); |
---|
569 | if(buf != NULL) |
---|
570 | { |
---|
571 | socksend(&status.rguidfd, (unsigned char*)buf, 320 * 240 * 4, 5000 * 1000); |
---|
572 | free(buf); buf = NULL; |
---|
573 | } |
---|
574 | } |
---|
575 | if(status.write_png == 1 && status.infobaraktiv == 0) |
---|
576 | { |
---|
577 | char* buf = NULL; |
---|
578 | buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0); |
---|
579 | if(buf != NULL) |
---|
580 | { |
---|
581 | if(writeFBfile.ActBuf == NULL) |
---|
582 | { |
---|
583 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
584 | writeFBfile.ActBuf = writeFBfile.buf1; |
---|
585 | memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240); |
---|
586 | addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
587 | } |
---|
588 | else if(writeFBfile.buf1 == writeFBfile.ActBuf) |
---|
589 | { |
---|
590 | if(writeFBfile.buf2 == NULL) |
---|
591 | writeFBfile.buf2 = malloc(4 * 320 * 240); |
---|
592 | memcpy(writeFBfile.buf2, (unsigned char*)buf, 4 * 320 * 240); |
---|
593 | } |
---|
594 | else if(writeFBfile.buf2 == writeFBfile.ActBuf) |
---|
595 | { |
---|
596 | if(writeFBfile.buf1 == NULL) |
---|
597 | writeFBfile.buf1 = malloc(4 * 320 * 240); |
---|
598 | memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240); |
---|
599 | } |
---|
600 | //fb2png((unsigned char*)buf, 320, 240, "/tmp/titanlcd.png"); |
---|
601 | free(buf); buf = NULL; |
---|
602 | } |
---|
603 | } |
---|
604 | |
---|
605 | if(fbnode != fb) |
---|
606 | { |
---|
607 | for(i = 0; i < fbnode->height; i++) |
---|
608 | { |
---|
609 | memcpy(fb->fb + (i * fb->pitch), fbnode->fb + (i * fbnode->pitch), fbnode->width * fbnode->colbytes); |
---|
610 | } |
---|
611 | } |
---|
612 | system("killall -9 xloadimage"); |
---|
613 | |
---|
614 | FILE *fd; |
---|
615 | fd=fopen("titan.png", "w"); |
---|
616 | fwrite(fb->fb, fb->varfbsize, 1, fd); |
---|
617 | fclose(fd); |
---|
618 | |
---|
619 | system("fbgrab -f titan.png -w 1280 -h 720 -b 32 titan1.png > /dev/null"); |
---|
620 | system("xloadimage titan1.png > /dev/null &"); |
---|
621 | #endif |
---|
622 | #endif |
---|
623 | */ |
---|
624 | } |
---|
625 | |
---|
626 | void setfbtransparent(int value) |
---|
627 | { |
---|
628 | char* transparentdev; |
---|
629 | |
---|
630 | transparentdev = getconfig("transparentdev", NULL); |
---|
631 | |
---|
632 | if(transparentdev != NULL /*&& checkdev(transparentdev)*/) |
---|
633 | { |
---|
634 | debug(100, "set %s to %d", transparentdev, value); |
---|
635 | writesysint(transparentdev, value, 1); |
---|
636 | return; |
---|
637 | } |
---|
638 | /* |
---|
639 | #ifndef SIMULATE |
---|
640 | struct stmfbio_var_screeninfo_ex varEx = {0}; |
---|
641 | |
---|
642 | varEx.layerid = 0; |
---|
643 | varEx.activate = STMFBIO_ACTIVATE_IMMEDIATE; |
---|
644 | varEx.caps = STMFBIO_VAR_CAPS_OPACITY; |
---|
645 | varEx.opacity = value; |
---|
646 | |
---|
647 | |
---|
648 | if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &varEx) < 0) |
---|
649 | perr("STMFBIO_SET_VAR_SCREENINFO_EX"); |
---|
650 | #endif |
---|
651 | */ |
---|
652 | } |
---|
653 | |
---|
654 | int allocbpamem(size_t size, int *memfd, unsigned char **mem) |
---|
655 | { |
---|
656 | return -1; |
---|
657 | } |
---|
658 | |
---|
659 | void freebpamem(int memfd, unsigned char* mem, size_t len) |
---|
660 | { |
---|
661 | } |
---|
662 | |
---|
663 | //mode 0: with fill (draw to skinfb) |
---|
664 | //mode 1: without fill (draw to skinfb) |
---|
665 | //mode 2: with fill (draw to fb) |
---|
666 | //mode 3: without fill (draw to fb) |
---|
667 | void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode) |
---|
668 | { |
---|
669 | int y, x; |
---|
670 | unsigned long tmpcol; |
---|
671 | struct fb* tmpfb = NULL; |
---|
672 | |
---|
673 | if(posx < 0) posx = 0; |
---|
674 | if(posy < 0) posy = 0; |
---|
675 | if(mode < 2) |
---|
676 | tmpfb = skinfb; |
---|
677 | else |
---|
678 | tmpfb = fb; |
---|
679 | |
---|
680 | if(posx > tmpfb->width) posx = tmpfb->width; |
---|
681 | if(posy > tmpfb->height) posy = tmpfb->height; |
---|
682 | if(posx + width > tmpfb->width) width = tmpfb->width - posx; |
---|
683 | if(posy + height > tmpfb->height) height = tmpfb->height - posy; |
---|
684 | |
---|
685 | if(width <= 0 || height <= 0) return; |
---|
686 | |
---|
687 | transparent = (transparent - 255) * -1; |
---|
688 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
689 | |
---|
690 | if(mode == 0 || mode == 2) |
---|
691 | { |
---|
692 | |
---|
693 | if(status.bcm == 1 && tmpfb->data_phys != 0) |
---|
694 | { |
---|
695 | bcm_accel_fill(tmpfb->data_phys, tmpfb->width, tmpfb->height, tmpfb->pitch, posx, posy, width, height, tmpcol); |
---|
696 | } |
---|
697 | else |
---|
698 | { |
---|
699 | int yend = (posy + height) * tmpfb->width; |
---|
700 | posy *= tmpfb->width; |
---|
701 | int xend = posx + width; |
---|
702 | // int xlen = (xend - posx) * tmpfb->colbytes; |
---|
703 | int r = 0; |
---|
704 | unsigned char* from = tmpfb->fb + (posy + posx) * tmpfb->colbytes; |
---|
705 | |
---|
706 | for(y = posy; y < yend; y += tmpfb->width) |
---|
707 | { |
---|
708 | if(r == 0) |
---|
709 | { |
---|
710 | r = 1; |
---|
711 | for(x = posx; x < xend; x++) |
---|
712 | drawpixelfastfb(tmpfb, x, y, tmpcol); |
---|
713 | } |
---|
714 | else |
---|
715 | { |
---|
716 | //memcpy(tmpfb->fb + (y + posx) * tmpfb->colbytes, from, xlen); |
---|
717 | memcpy_area(tmpfb->fb + (y + posx) * tmpfb->colbytes, from, posx * 4, height-1, width*4, tmpfb->width*4); |
---|
718 | y = yend; |
---|
719 | } |
---|
720 | |
---|
721 | } |
---|
722 | } |
---|
723 | } |
---|
724 | else if(mode == 1 || mode == 3) |
---|
725 | { |
---|
726 | //topline |
---|
727 | for(x = 0; x < width; x++) |
---|
728 | drawpixelfb(tmpfb, posx + x, posy, tmpcol); |
---|
729 | //bottomline |
---|
730 | for(x = 0; x < width; x++) |
---|
731 | drawpixelfb(tmpfb, posx + x, posy + height - 1, tmpcol); |
---|
732 | //leftline |
---|
733 | for(y = 0; y < height; y++) |
---|
734 | drawpixelfb(tmpfb, posx, posy + y, tmpcol); |
---|
735 | //rightline |
---|
736 | for(y = 0; y < height; y++) |
---|
737 | drawpixelfb(tmpfb, posx + width - 1, posy + y, tmpcol); |
---|
738 | } |
---|
739 | |
---|
740 | /* |
---|
741 | unsigned long tmpcol; |
---|
742 | |
---|
743 | transparent = (transparent - 255) * -1; |
---|
744 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
745 | |
---|
746 | STMFBIO_BLT_DATA bltData; |
---|
747 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
748 | |
---|
749 | if(posx < 0) posx = 0; |
---|
750 | if(posy < 0) posy = 0; |
---|
751 | if(mode < 2) |
---|
752 | { |
---|
753 | if(posx > skinfb->width) posx = skinfb->width; |
---|
754 | if(posy > skinfb->height) posy = skinfb->height; |
---|
755 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
756 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
757 | } |
---|
758 | else |
---|
759 | { |
---|
760 | if(posx > fb->width) posx = fb->width; |
---|
761 | if(posy > fb->height) posy = fb->height; |
---|
762 | if(posx + width > fb->width) width = fb->width - posx; |
---|
763 | if(posy + height > fb->height) height = fb->height - posy; |
---|
764 | } |
---|
765 | |
---|
766 | if(width <= 0 || height <= 0) return; |
---|
767 | |
---|
768 | if(mode == 0 || mode == 2) |
---|
769 | bltData.operation = BLT_OP_FILL; |
---|
770 | else if(mode == 1 || mode == 3) |
---|
771 | bltData.operation = BLT_OP_DRAW_RECTANGLE; |
---|
772 | bltData.colour = tmpcol; |
---|
773 | bltData.srcFormat = SURF_ARGB8888; |
---|
774 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
775 | |
---|
776 | if(status.usedirectfb == 1) |
---|
777 | bltData.dstOffset = 0; |
---|
778 | else |
---|
779 | { |
---|
780 | if(mode < 2) |
---|
781 | bltData.dstOffset = fb->varfbsize; |
---|
782 | else |
---|
783 | bltData.dstOffset = 0; |
---|
784 | } |
---|
785 | if(mode < 2) |
---|
786 | bltData.dstPitch = skinfb->pitch; |
---|
787 | else |
---|
788 | bltData.dstPitch = fb->pitch; |
---|
789 | bltData.dst_top = posy; |
---|
790 | bltData.dst_left = posx; |
---|
791 | bltData.dst_bottom = posy + height; |
---|
792 | bltData.dst_right = posx + width; |
---|
793 | bltData.dstFormat = SURF_ARGB8888; |
---|
794 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
795 | |
---|
796 | if(ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
797 | { |
---|
798 | perr("ioctl STMFBIO_BLT"); |
---|
799 | } |
---|
800 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
801 | { |
---|
802 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
803 | } |
---|
804 | */ |
---|
805 | } |
---|
806 | |
---|
807 | int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd) |
---|
808 | { |
---|
809 | /* |
---|
810 | #ifndef SIMULATE |
---|
811 | FILE *fp; |
---|
812 | unsigned int temp1, temp2; |
---|
813 | |
---|
814 | if(filename == NULL) return -1; |
---|
815 | |
---|
816 | debug(200, "hardware decode picture (%s)...", filename); |
---|
817 | |
---|
818 | if (!(fp = fopen(filename, "rb"))) |
---|
819 | return -1; |
---|
820 | |
---|
821 | if(get_jpeg_img_size(fp, &temp1, &temp2) != LIBMMEIMG_SUCCESS) |
---|
822 | return -1; |
---|
823 | |
---|
824 | *width = temp1; |
---|
825 | *height = temp2; |
---|
826 | *channels = 3; |
---|
827 | *rowbytes = *channels * temp1; |
---|
828 | |
---|
829 | if(allocbpamem(temp1 * temp2 * (*channels), memfd, mem) != 0) |
---|
830 | { |
---|
831 | fclose(fp); |
---|
832 | return -1; |
---|
833 | } |
---|
834 | |
---|
835 | if(decode_jpeg_noalloc(fp, temp1, temp2, temp1, temp2, (char *)*mem, 1) == LIBMMEIMG_SUCCESS) |
---|
836 | { |
---|
837 | fclose(fp); |
---|
838 | return 0; |
---|
839 | } |
---|
840 | |
---|
841 | fclose(fp); |
---|
842 | freebpamem(*memfd, *mem, temp1 * temp2 * (*channels)); |
---|
843 | err("hardware decode error"); |
---|
844 | #endif |
---|
845 | return -1; |
---|
846 | */ |
---|
847 | return -1; |
---|
848 | } |
---|
849 | |
---|
850 | //flag 0: blit from accelfb to skinfb |
---|
851 | //flag 1: blit from skinfb to accelfb |
---|
852 | void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag) |
---|
853 | { |
---|
854 | #ifndef SIMULATE |
---|
855 | //#ifdef BLITHELP |
---|
856 | unsigned char *source = NULL; |
---|
857 | unsigned char *target = NULL; |
---|
858 | int zpitch = 0; |
---|
859 | int zheight = 0; |
---|
860 | int zwidth = 0; |
---|
861 | int qpitch = 0; |
---|
862 | int qheight = 0; |
---|
863 | int qwidth = 0; |
---|
864 | unsigned long source_phys = 0; |
---|
865 | unsigned long target_phys = 0; |
---|
866 | |
---|
867 | if(scalewidth == 0) scalewidth = width; |
---|
868 | if(scaleheight == 0) scaleheight = height; |
---|
869 | |
---|
870 | if(posx < 0) posx = 0; |
---|
871 | if(posx > skinfb->width) posx = skinfb->width; |
---|
872 | if(posy < 0) posy = 0; |
---|
873 | if(posy > skinfb->height) posy = skinfb->height; |
---|
874 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
875 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
876 | |
---|
877 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
878 | |
---|
879 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
880 | { |
---|
881 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
882 | return; |
---|
883 | } |
---|
884 | if(flag == 0) |
---|
885 | { |
---|
886 | source = accelfb->fb; |
---|
887 | source_phys = accelfb->data_phys; |
---|
888 | target_phys = skinfb->data_phys; |
---|
889 | |
---|
890 | target = skinfb->fb + (posy * skinfb->pitch) + (posx*4); |
---|
891 | zpitch = skinfb->pitch; |
---|
892 | zheight = skinfb->height; |
---|
893 | zwidth = skinfb->width; |
---|
894 | qpitch = width*4; |
---|
895 | qheight = height; |
---|
896 | qwidth = width; |
---|
897 | } |
---|
898 | else |
---|
899 | { |
---|
900 | source = skinfb->fb; |
---|
901 | source_phys = skinfb->data_phys; |
---|
902 | target_phys = accelfb->data_phys; |
---|
903 | |
---|
904 | target = accelfb->fb + (posy * accelfb->pitch) + (posx*4); |
---|
905 | zpitch = accelfb->pitch; |
---|
906 | zheight = accelfb->height; |
---|
907 | zwidth = accelfb->width; |
---|
908 | qpitch = width*4; |
---|
909 | qheight = height; |
---|
910 | qwidth = width; |
---|
911 | } |
---|
912 | |
---|
913 | if(status.bcm == 1 && source_phys > 0 && target_phys >0) |
---|
914 | { |
---|
915 | bcm_accel_blit(source_phys, qwidth, qheight, qpitch, 0, target_phys, zwidth, zheight, zpitch, 0, 0, width, height, posx, posy, scalewidth, scaleheight, 0, 0); |
---|
916 | flag = 1; |
---|
917 | } |
---|
918 | else |
---|
919 | { |
---|
920 | unsigned char *helpbuf = NULL; |
---|
921 | helpbuf = scale(source, width, height, 4, scalewidth, scaleheight, 0); |
---|
922 | |
---|
923 | size_t helpb = 0; |
---|
924 | size_t helpz = 0; |
---|
925 | size_t help = 0; |
---|
926 | |
---|
927 | while(helpz < scaleheight && helpz < (zheight - posy)) { |
---|
928 | //memcpy(target[help], helpbuf[helpb], scalewidth*4); |
---|
929 | memcpy(target+help, helpbuf+helpb, scalewidth*4); |
---|
930 | help = help + zpitch; |
---|
931 | helpb = helpb + scalewidth*4; |
---|
932 | helpz = helpz + 1; |
---|
933 | } |
---|
934 | free(helpbuf); |
---|
935 | } |
---|
936 | |
---|
937 | |
---|
938 | if(flag == 0) |
---|
939 | blit(); |
---|
940 | |
---|
941 | //#endif |
---|
942 | |
---|
943 | /* |
---|
944 | STMFBIO_BLT_DATA blt_data; |
---|
945 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
946 | |
---|
947 | if(scalewidth == 0) scalewidth = width; |
---|
948 | if(scaleheight == 0) scaleheight = height; |
---|
949 | |
---|
950 | if(posx < 0) posx = 0; |
---|
951 | if(posx > skinfb->width) posx = skinfb->width; |
---|
952 | if(posy < 0) posy = 0; |
---|
953 | if(posy > skinfb->height) posy = skinfb->height; |
---|
954 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
955 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
956 | |
---|
957 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
958 | |
---|
959 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
960 | { |
---|
961 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
962 | return; |
---|
963 | } |
---|
964 | |
---|
965 | blt_data.operation = BLT_OP_COPY; |
---|
966 | |
---|
967 | if(flag == 0) |
---|
968 | { |
---|
969 | if(status.usedirectfb == 1) |
---|
970 | blt_data.srcOffset = fb->varfbsize; |
---|
971 | else |
---|
972 | blt_data.srcOffset = fb->varfbsize + skinfb->varfbsize; |
---|
973 | } |
---|
974 | else |
---|
975 | { |
---|
976 | if(status.usedirectfb == 1) |
---|
977 | blt_data.srcOffset = 0; |
---|
978 | else |
---|
979 | blt_data.srcOffset = fb->varfbsize; |
---|
980 | } |
---|
981 | |
---|
982 | blt_data.srcPitch = width * 4; |
---|
983 | blt_data.src_top = 0; |
---|
984 | blt_data.src_left = 0; |
---|
985 | blt_data.src_right = width; |
---|
986 | blt_data.src_bottom = height; |
---|
987 | blt_data.srcFormat = SURF_ARGB8888; |
---|
988 | blt_data.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
989 | |
---|
990 | if(flag == 0) |
---|
991 | { |
---|
992 | if(status.usedirectfb == 1) |
---|
993 | { |
---|
994 | blt_data.dstOffset = 0; |
---|
995 | blt_data.dstPitch = fb->pitch; |
---|
996 | } |
---|
997 | else |
---|
998 | { |
---|
999 | blt_data.dstOffset = fb->varfbsize; |
---|
1000 | blt_data.dstPitch = skinfb->pitch; |
---|
1001 | } |
---|
1002 | } |
---|
1003 | else |
---|
1004 | { |
---|
1005 | if(status.usedirectfb == 1) |
---|
1006 | { |
---|
1007 | blt_data.dstOffset = fb->varfbsize; |
---|
1008 | blt_data.dstPitch = skinfb->pitch; |
---|
1009 | } |
---|
1010 | else |
---|
1011 | { |
---|
1012 | blt_data.dstOffset = fb->varfbsize + skinfb->varfbsize; |
---|
1013 | blt_data.dstPitch = scalewidth * 4; |
---|
1014 | } |
---|
1015 | } |
---|
1016 | |
---|
1017 | blt_data.dst_left = posx; |
---|
1018 | blt_data.dst_top = posy; |
---|
1019 | blt_data.dst_right = posx + scalewidth; |
---|
1020 | blt_data.dst_bottom = posy + scaleheight; |
---|
1021 | blt_data.dstFormat = SURF_ARGB8888; |
---|
1022 | blt_data.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
1023 | |
---|
1024 | if (ioctl(fb->fd, STMFBIO_BLT, &blt_data) < 0) |
---|
1025 | { |
---|
1026 | perr("ioctl STMFBIO_BLT"); |
---|
1027 | } |
---|
1028 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
1029 | { |
---|
1030 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
1031 | } |
---|
1032 | */ |
---|
1033 | #endif |
---|
1034 | } |
---|
1035 | |
---|
1036 | 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) |
---|
1037 | //void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight) |
---|
1038 | { |
---|
1039 | #ifndef SIMULATE |
---|
1040 | #ifdef BLITHELP |
---|
1041 | unsigned char *helpbuf = NULL; |
---|
1042 | unsigned char *framebuf = NULL; |
---|
1043 | |
---|
1044 | if(scalewidth != 0 || scaleheight != 0) { |
---|
1045 | helpbuf = scale(buf, width, height, 3, scalewidth, scaleheight, 1); |
---|
1046 | if(helpbuf == NULL) |
---|
1047 | return; |
---|
1048 | } |
---|
1049 | else { |
---|
1050 | helpbuf = buf; |
---|
1051 | scalewidth = width; |
---|
1052 | scaleheight = height; |
---|
1053 | } |
---|
1054 | size_t helpb = 0; |
---|
1055 | size_t helpz = 0; |
---|
1056 | size_t help = 0; |
---|
1057 | |
---|
1058 | framebuf = skinfb->fb; |
---|
1059 | framebuf = framebuf + (posy * skinfb->pitch) + (posx*4); |
---|
1060 | |
---|
1061 | while(helpz < scaleheight && helpz < (skinfb->height - posy)) { |
---|
1062 | help = 0; |
---|
1063 | while(help < (scalewidth*4) && help < (skinfb->pitch - (posx*4))) { |
---|
1064 | framebuf[help+0] = helpbuf[helpb+2]; |
---|
1065 | framebuf[help+1] = helpbuf[helpb+1]; |
---|
1066 | framebuf[help+2] = helpbuf[helpb+0]; |
---|
1067 | framebuf[help+3] = 0xff; |
---|
1068 | help = help + 4; |
---|
1069 | helpb = helpb + 3; |
---|
1070 | } |
---|
1071 | if(help >= (skinfb->pitch - (posx*4))) |
---|
1072 | helpb = (helpz+1) * (scalewidth*3); |
---|
1073 | framebuf = framebuf + skinfb->pitch; |
---|
1074 | helpz = helpz + 1; |
---|
1075 | } |
---|
1076 | free(helpbuf); |
---|
1077 | blit(); |
---|
1078 | #endif |
---|
1079 | |
---|
1080 | /* |
---|
1081 | STMFBIO_BLT_EXTERN_DATA blt_data; |
---|
1082 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); |
---|
1083 | |
---|
1084 | blt_data.operation = BLT_OP_COPY; |
---|
1085 | blt_data.ulFlags = 0; |
---|
1086 | blt_data.srcOffset = 0; |
---|
1087 | blt_data.srcPitch = width * 3; |
---|
1088 | blt_data.dstOffset = 0; |
---|
1089 | blt_data.dstPitch = skinfb->pitch; |
---|
1090 | blt_data.src_top = 0; |
---|
1091 | blt_data.src_left = 0; |
---|
1092 | blt_data.src_right = width; |
---|
1093 | blt_data.src_bottom = height; |
---|
1094 | blt_data.dst_left = posx; |
---|
1095 | blt_data.dst_top = posy; |
---|
1096 | |
---|
1097 | if(scalewidth == 0) scalewidth = width; |
---|
1098 | if(scaleheight == 0) scaleheight = height; |
---|
1099 | |
---|
1100 | blt_data.dst_right = posx + scalewidth; |
---|
1101 | blt_data.dst_bottom = posy + scaleheight; |
---|
1102 | blt_data.srcFormat = SURF_BGR888; |
---|
1103 | blt_data.dstFormat = SURF_ARGB8888; |
---|
1104 | blt_data.srcMemBase = (char *)buf; |
---|
1105 | blt_data.dstMemBase = (char *)skinfb->fb; |
---|
1106 | blt_data.srcMemSize = width * height * 3; |
---|
1107 | blt_data.dstMemSize = skinfb->pitch * skinfb->height; |
---|
1108 | |
---|
1109 | if(ioctl(skinfb->fd, STMFBIO_BLT_EXTERN, &blt_data) < 0) |
---|
1110 | { |
---|
1111 | err("ioctl STMFBIO_BLT_EXTERN"); |
---|
1112 | } |
---|
1113 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
1114 | { |
---|
1115 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
1116 | } |
---|
1117 | */ |
---|
1118 | |
---|
1119 | #endif |
---|
1120 | } |
---|
1121 | |
---|
1122 | void initsignal(struct sigaction* sa) |
---|
1123 | { |
---|
1124 | sigaction(SIGILL, sa, NULL); |
---|
1125 | sigaction(SIGBUS, sa, NULL); |
---|
1126 | sigaction(SIGFPE, sa, NULL); |
---|
1127 | sigaction(SIGUSR1, sa, NULL); |
---|
1128 | sigaction(SIGSEGV, sa, NULL); |
---|
1129 | sigaction(SIGUSR2, sa, NULL); |
---|
1130 | sigaction(SIGPIPE, sa, NULL); |
---|
1131 | sigaction(SIGALRM, sa, NULL); |
---|
1132 | // sigaction(SIGSTKFLT, sa, NULL); |
---|
1133 | sigaction(SIGABRT, sa, NULL); |
---|
1134 | |
---|
1135 | signal(SIGHUP, SIG_IGN); |
---|
1136 | signal(SIGINT, SIG_IGN); |
---|
1137 | signal(SIGTRAP, SIG_IGN); |
---|
1138 | signal(SIGXCPU, SIG_IGN); |
---|
1139 | signal(SIGXFSZ, SIG_IGN); |
---|
1140 | signal(SIGVTALRM, SIG_IGN); |
---|
1141 | signal(SIGPROF, SIG_IGN); |
---|
1142 | signal(SIGPOLL, SIG_IGN); |
---|
1143 | signal(SIGRTMAX, SIG_IGN); |
---|
1144 | signal(SIGPWR, SIG_IGN); |
---|
1145 | signal(SIGSYS, SIG_IGN); |
---|
1146 | } |
---|
1147 | |
---|
1148 | void sighandler(int sig, struct sigcontext ctx) |
---|
1149 | { |
---|
1150 | switch(sig) |
---|
1151 | { |
---|
1152 | case SIGALRM: |
---|
1153 | { |
---|
1154 | err("got signal sigalrm but ignore it"); |
---|
1155 | break; |
---|
1156 | } |
---|
1157 | case SIGPIPE: |
---|
1158 | { |
---|
1159 | err("got signal sigpipe but ignore it"); |
---|
1160 | break; |
---|
1161 | } |
---|
1162 | case SIGUSR1: |
---|
1163 | { |
---|
1164 | //todo all configs |
---|
1165 | reloadconfig(status.configfile); |
---|
1166 | reloadconfig(getconfig("ownconfig", NULL)); |
---|
1167 | break; |
---|
1168 | } |
---|
1169 | case SIGUSR2: //called if hanging mainthread detect |
---|
1170 | { |
---|
1171 | debugstack(sig, NULL, NULL); |
---|
1172 | break; |
---|
1173 | } |
---|
1174 | case SIGILL: |
---|
1175 | case SIGBUS: |
---|
1176 | case SIGFPE: |
---|
1177 | case SIGSEGV: |
---|
1178 | // case SIGSTKFLT: |
---|
1179 | { |
---|
1180 | /* |
---|
1181 | #ifdef SIMULATE |
---|
1182 | //intel |
---|
1183 | debugstack((void *)ctx.eip, NULL); |
---|
1184 | err("got signal %d, fault address 0x%lx from 0x%lx", sig, ctx.cr2, ctx.eip); |
---|
1185 | #else |
---|
1186 | // sh4 |
---|
1187 | //unsigned long sc_regs[16]; |
---|
1188 | //unsigned long sc_pc; //programm counter register |
---|
1189 | //unsigned long sc_pr; //procedure register |
---|
1190 | //unsigned long sc_sr; //status register |
---|
1191 | //unsigned long sc_gbr; |
---|
1192 | //unsigned long sc_mach; |
---|
1193 | //unsigned long sc_macl; |
---|
1194 | |
---|
1195 | debugstack(sig, (void *)ctx.sc_pr, (void *)ctx.sc_pc); |
---|
1196 | err("got signal %d (%s), programm counter reg: 0x%lx, procedure reg: 0x%lx", sig, strsignal(sig), ctx.sc_pc, ctx.sc_pr); |
---|
1197 | #endif |
---|
1198 | */ |
---|
1199 | if(getconfigint("saverun", NULL) == 1 && status.longjumpbuf != NULL) |
---|
1200 | siglongjmp(status.longjumpbuf, 999); |
---|
1201 | else |
---|
1202 | exit(100); |
---|
1203 | break; |
---|
1204 | } |
---|
1205 | } |
---|
1206 | } |
---|
1207 | |
---|
1208 | int setvmpeg(struct dvbdev* node, int value, int flag) |
---|
1209 | { |
---|
1210 | debug(4440, "in"); |
---|
1211 | char* vmpegdev = NULL, *tmpstr = NULL, *buf = NULL; |
---|
1212 | int ret = 0; |
---|
1213 | |
---|
1214 | if(node == NULL) return 1; |
---|
1215 | if(flag == 0) vmpegdev = getconfig("vmpegleftdev", NULL); |
---|
1216 | if(flag == 1) vmpegdev = getconfig("vmpegtopdev", NULL); |
---|
1217 | if(flag == 2) vmpegdev = getconfig("vmpegwidthdev", NULL); |
---|
1218 | if(flag == 3) vmpegdev = getconfig("vmpegheightdev", NULL); |
---|
1219 | if(flag == 99) vmpegdev = getconfig("vmpegapplydev", NULL); |
---|
1220 | |
---|
1221 | if(vmpegdev != NULL) |
---|
1222 | { |
---|
1223 | buf = malloc(MINMALLOC); |
---|
1224 | if(buf == NULL) |
---|
1225 | { |
---|
1226 | err("no mem"); |
---|
1227 | return 1; |
---|
1228 | } |
---|
1229 | |
---|
1230 | tmpstr = malloc(10); |
---|
1231 | if(tmpstr == NULL) |
---|
1232 | { |
---|
1233 | err("no mem"); |
---|
1234 | free(buf); |
---|
1235 | return 1; |
---|
1236 | } |
---|
1237 | |
---|
1238 | snprintf(buf, MINMALLOC, vmpegdev, node->devnr); |
---|
1239 | snprintf(tmpstr, 10, "%x", value); |
---|
1240 | debug(444, "set %s to %s", buf, tmpstr); |
---|
1241 | status.tvpic = 1; |
---|
1242 | ret = writesys(buf, tmpstr, 1); |
---|
1243 | |
---|
1244 | free(tmpstr); |
---|
1245 | free(buf); |
---|
1246 | return ret; |
---|
1247 | } |
---|
1248 | |
---|
1249 | debug(4440, "out"); |
---|
1250 | return 0; |
---|
1251 | } |
---|
1252 | |
---|
1253 | //flag 0: wh = width |
---|
1254 | //flag 1: wh = height |
---|
1255 | int setvmpegrect(struct dvbdev* node, int left, int top, int wh, int flag) |
---|
1256 | { |
---|
1257 | int ret = 0; |
---|
1258 | |
---|
1259 | ret = setvmpeg(node, left, 0); |
---|
1260 | ret = setvmpeg(node, top, 1); |
---|
1261 | |
---|
1262 | if(flag == 0) |
---|
1263 | { |
---|
1264 | ret = setvmpeg(node, wh, 2); |
---|
1265 | ret = setvmpeg(node, wh / 1.4, 3); |
---|
1266 | } |
---|
1267 | if(flag == 1) |
---|
1268 | { |
---|
1269 | ret = setvmpeg(node, wh, 3); |
---|
1270 | ret = setvmpeg(node, wh * 1.3, 2); |
---|
1271 | } |
---|
1272 | |
---|
1273 | setvmpeg(node, 0, 99); |
---|
1274 | |
---|
1275 | return ret; |
---|
1276 | } |
---|
1277 | |
---|
1278 | int resetvmpeg(struct dvbdev* node) |
---|
1279 | { |
---|
1280 | int ret = 0; |
---|
1281 | |
---|
1282 | ret = setvmpeg(node, 0, 0); |
---|
1283 | ret = setvmpeg(node, 0, 1); |
---|
1284 | ret = setvmpeg(node, 0, 2); |
---|
1285 | ret = setvmpeg(node, 0, 3); |
---|
1286 | |
---|
1287 | ret = setvmpeg(node, 0, 99); |
---|
1288 | |
---|
1289 | status.tvpic = 0; |
---|
1290 | |
---|
1291 | return ret; |
---|
1292 | } |
---|
1293 | |
---|
1294 | int resettvpic() |
---|
1295 | { |
---|
1296 | /* |
---|
1297 | if(status.tvpic == 1 && status.aktservice != NULL) |
---|
1298 | { |
---|
1299 | status.tvpic = 0; |
---|
1300 | resetvmpeg(status.aktservice->videodev); |
---|
1301 | } |
---|
1302 | */ |
---|
1303 | int ret = 0; |
---|
1304 | |
---|
1305 | if(status.tvpic > 0 && status.aktservice != NULL) |
---|
1306 | ret = resetvmpeg(status.aktservice->videodev); |
---|
1307 | |
---|
1308 | return ret; |
---|
1309 | } |
---|
1310 | |
---|
1311 | int cagetslotinfo(struct dvbdev* node, ca_slot_info_t* info) |
---|
1312 | { |
---|
1313 | int ret = 0; |
---|
1314 | |
---|
1315 | if(node == NULL || info == NULL) |
---|
1316 | { |
---|
1317 | err("NULL detect"); |
---|
1318 | return 1; |
---|
1319 | } |
---|
1320 | |
---|
1321 | struct pollfd fds; |
---|
1322 | |
---|
1323 | fds.fd = node->fd; |
---|
1324 | fds.events = POLLOUT | POLLPRI | POLLIN; |
---|
1325 | |
---|
1326 | info->flags = 0; |
---|
1327 | |
---|
1328 | ret = TEMP_FAILURE_RETRY(poll(&fds, 1, 1000)); |
---|
1329 | |
---|
1330 | if(ret < 0) |
---|
1331 | { |
---|
1332 | err("poll data"); |
---|
1333 | return 1; //error |
---|
1334 | } |
---|
1335 | else if(ret == 0) |
---|
1336 | return 0; //timeout |
---|
1337 | else if(ret > 0) |
---|
1338 | { |
---|
1339 | if(fds.revents & POLLOUT) |
---|
1340 | info->flags = CA_CI_MODULE_READY; |
---|
1341 | if(fds.revents & POLLIN) |
---|
1342 | info->flags = CA_CI_MODULE_READY; |
---|
1343 | if(fds.revents & POLLPRI) |
---|
1344 | info->flags = 0; |
---|
1345 | } |
---|
1346 | |
---|
1347 | return 0; |
---|
1348 | } |
---|
1349 | |
---|
1350 | void memcpy_word(char* dest, char* src, long anzw) |
---|
1351 | { |
---|
1352 | // Folgende Werte m�ssen volatile definiert sein |
---|
1353 | // char* memcpy_word_src ---> pointer Quelle |
---|
1354 | // char* memcpy_word_dest ---> pointer Ziehl |
---|
1355 | // long memcpy_word_anzw ---> Anzahl der W�rter (4 byte) die kopiert werden sollen. |
---|
1356 | |
---|
1357 | memcpy_word_src = src; |
---|
1358 | memcpy_word_dest = dest; |
---|
1359 | memcpy_word_anzw = anzw; |
---|
1360 | |
---|
1361 | #ifndef ARM |
---|
1362 | asm( |
---|
1363 | " lw $8, memcpy_word_src \n" |
---|
1364 | " lw $9, memcpy_word_dest \n" |
---|
1365 | " lw $10, memcpy_word_anzw \n" |
---|
1366 | " addi $10, $10, -1 \n" |
---|
1367 | "loop1: \n" |
---|
1368 | " lw $11, ($8) \n" |
---|
1369 | " sw $11, ($9) \n" |
---|
1370 | " addi $8, $8, 4 \n" |
---|
1371 | " addi $9, $9, 4 \n" |
---|
1372 | " addi $10, $10, -1 \n" |
---|
1373 | " bgez $10, loop1 \n" |
---|
1374 | ); |
---|
1375 | #endif |
---|
1376 | |
---|
1377 | } |
---|
1378 | |
---|
1379 | void memcpy_byte(char* dest, char* src, long anzb) |
---|
1380 | { |
---|
1381 | // Folgende Werte m�ssen volatile definiert sein |
---|
1382 | // char* memcpy_byte_src ---> pointer Quelle |
---|
1383 | // char* memcpy_byte_dest ---> pointer Ziehl |
---|
1384 | // long memcpy_byte_anzb ---> Anzahl bytes die kopiert werden sollen. |
---|
1385 | |
---|
1386 | memcpy_byte_src = src; |
---|
1387 | memcpy_byte_dest = dest; |
---|
1388 | memcpy_byte_anzb = anzb; |
---|
1389 | |
---|
1390 | #ifndef ARM |
---|
1391 | asm ( |
---|
1392 | " li $12, 4 \n" |
---|
1393 | " lw $8, memcpy_byte_src \n" |
---|
1394 | " lw $9, memcpy_byte_dest \n" |
---|
1395 | " lw $10, memcpy_byte_anzb \n" |
---|
1396 | "word: \n" |
---|
1397 | " bltu $10, $12, byte \n" |
---|
1398 | " lw $11, ($8) \n" |
---|
1399 | " sw $11, ($9) \n" |
---|
1400 | " addi $8, $8, 4 \n" |
---|
1401 | " addi $9, $9, 4 \n" |
---|
1402 | " addi $10, $10, -4 \n" |
---|
1403 | " b word \n" |
---|
1404 | "byte: \n" |
---|
1405 | " beqz $10, end \n" |
---|
1406 | " lb $11, ($8) \n" |
---|
1407 | " sb $11, ($9) \n" |
---|
1408 | " addi $8, $8, 1 \n" |
---|
1409 | " addi $9, $9, 1 \n" |
---|
1410 | " addi $10, $10, -1 \n" |
---|
1411 | " b byte \n" |
---|
1412 | "end: \n" |
---|
1413 | " nop \n" |
---|
1414 | ); |
---|
1415 | #endif |
---|
1416 | } |
---|
1417 | |
---|
1418 | |
---|
1419 | void memcpy_area(unsigned char* targetADDR, unsigned char* startADDR, long pxAbs, long hight, long widthAbs, long FBwidthAbs) |
---|
1420 | { |
---|
1421 | |
---|
1422 | #ifndef ARM |
---|
1423 | asm( |
---|
1424 | |
---|
1425 | " lw $t3, %[targetADDR] \n" |
---|
1426 | " lw $t4, %[startADDR] \n" |
---|
1427 | " lw $t5, %[pxAbs] \n" |
---|
1428 | " lw $t6, %[widthAbs] \n" |
---|
1429 | " lw $t7, %[FBwidthAbs] \n" |
---|
1430 | " lw $t8, %[hight] \n" |
---|
1431 | |
---|
1432 | " move $t0, $t4 # Temp-startADDR \n" |
---|
1433 | " move $t1, $t6 # Temp-widthAbs \n" |
---|
1434 | " add $t2, $t5, $t6 \n" |
---|
1435 | " sub $t7, $t7, $t2 # Diff withAbs und FBwidthAbs \n" |
---|
1436 | |
---|
1437 | "p3NewLine2: \n" |
---|
1438 | " beqz $t8, p3End \n" |
---|
1439 | "p3NextWord: \n" |
---|
1440 | " beqz $t1, p3NewLine1 \n" |
---|
1441 | " lw $t9, ($t0) \n" |
---|
1442 | " sw $t9, ($t3) \n" |
---|
1443 | " addi $t0, 4 \n" |
---|
1444 | " addi $t3, 4 \n" |
---|
1445 | " addi $t1, -4 \n" |
---|
1446 | " b p3NextWord \n" |
---|
1447 | |
---|
1448 | |
---|
1449 | "p3NewLine1: \n" |
---|
1450 | " move $t0, $t4 \n" |
---|
1451 | " move $t1, $t6 \n" |
---|
1452 | " add $t3, $t3, $t7 \n" |
---|
1453 | " add $t3, $t3, $t5 \n" |
---|
1454 | " addi $t8, -1 \n" |
---|
1455 | " b p3NewLine2 \n" |
---|
1456 | |
---|
1457 | "p3End: \n" |
---|
1458 | " nop \n" |
---|
1459 | ::[targetADDR] "m" (targetADDR), [startADDR] "m" (startADDR), [pxAbs] "m" (pxAbs), [widthAbs] "m" (widthAbs), [FBwidthAbs] "m" (FBwidthAbs), [hight] "m" (hight) |
---|
1460 | ); |
---|
1461 | #endif |
---|
1462 | |
---|
1463 | return; |
---|
1464 | } |
---|
1465 | |
---|
1466 | int setfbosddev(char* dev, int value) |
---|
1467 | { |
---|
1468 | char* tmpstr = NULL; |
---|
1469 | int ret = 0; |
---|
1470 | |
---|
1471 | tmpstr = malloc(10); |
---|
1472 | if(tmpstr == NULL) |
---|
1473 | { |
---|
1474 | err("no mem"); |
---|
1475 | return 1; |
---|
1476 | } |
---|
1477 | |
---|
1478 | sprintf(tmpstr, "%x", value); |
---|
1479 | debug(101, "set %s to %s", dev, tmpstr); |
---|
1480 | |
---|
1481 | if(dev != NULL) |
---|
1482 | { |
---|
1483 | ret = writesys(dev, tmpstr, 1); |
---|
1484 | return ret; |
---|
1485 | } |
---|
1486 | |
---|
1487 | return 0; |
---|
1488 | } |
---|
1489 | |
---|
1490 | char* getfbosddev(char* dev) |
---|
1491 | { |
---|
1492 | char *value = NULL; |
---|
1493 | |
---|
1494 | if(dev == NULL) |
---|
1495 | { |
---|
1496 | err("NULL detect"); |
---|
1497 | return NULL; |
---|
1498 | } |
---|
1499 | |
---|
1500 | value = readsys(dev, 1); |
---|
1501 | if(value == NULL) |
---|
1502 | { |
---|
1503 | err("NULL detect"); |
---|
1504 | return NULL; |
---|
1505 | } |
---|
1506 | |
---|
1507 | debug(101, "get %s to %s", dev, value); |
---|
1508 | |
---|
1509 | return value; |
---|
1510 | } |
---|
1511 | |
---|
1512 | |
---|
1513 | void setfbosd() |
---|
1514 | { |
---|
1515 | debug(101, "################## set osd offset ####################"); |
---|
1516 | debug(101, "status.leftoffset: %d", status.leftoffset); |
---|
1517 | debug(101, "status.rightoffset: %d", status.rightoffset); |
---|
1518 | debug(101, "status.topoffset: %d", status.topoffset); |
---|
1519 | debug(101, "status.bottomoffset: %d", status.bottomoffset); |
---|
1520 | |
---|
1521 | char* fbleftdev = "/proc/stb/fb/dst_left"; |
---|
1522 | char* fbwidthdev = "/proc/stb/fb/dst_width"; |
---|
1523 | char* fbtopdev = "/proc/stb/fb/dst_top"; |
---|
1524 | char* fbheightdev = "/proc/stb/fb/dst_height"; |
---|
1525 | |
---|
1526 | int fbleft = strtol(getfbosddev(fbleftdev) , NULL, 16); |
---|
1527 | int fbwidth = strtol(getfbosddev(fbwidthdev) , NULL, 16); |
---|
1528 | int fbtop = strtol(getfbosddev(fbtopdev) , NULL, 16); |
---|
1529 | int fbheight = strtol(getfbosddev(fbheightdev) , NULL, 16); |
---|
1530 | debug(101, "Setting OSD position: %d %d %d %d", fbleft ,fbwidth ,fbtop ,fbheight); |
---|
1531 | |
---|
1532 | fbleft = status.leftoffset; |
---|
1533 | fbwidth = 720 - status.leftoffset - status.rightoffset; |
---|
1534 | fbtop = status.topoffset; |
---|
1535 | fbheight = 576 - status.topoffset - status.bottomoffset; |
---|
1536 | debug(101, "Setting OSD position changed: %d %d %d %d", fbleft ,fbwidth ,fbtop ,fbheight); |
---|
1537 | debug(10, "Setting OSD position changed: %d %d %d %d", fbleft ,fbwidth ,fbtop ,fbheight); |
---|
1538 | |
---|
1539 | setfbosddev(fbleftdev, fbleft); |
---|
1540 | setfbosddev(fbwidthdev, fbwidth); |
---|
1541 | setfbosddev(fbtopdev, fbtop); |
---|
1542 | setfbosddev(fbheightdev, fbheight); |
---|
1543 | debug(101, "######################################################"); |
---|
1544 | } |
---|
1545 | |
---|
1546 | int setrtctimemips() |
---|
1547 | { |
---|
1548 | char *rtctimedev = NULL, *tmpstr = NULL; |
---|
1549 | int ret = 0; |
---|
1550 | // int value = 0; |
---|
1551 | |
---|
1552 | time_t t = time(NULL); |
---|
1553 | struct tm *local = localtime(&t); |
---|
1554 | time_t rawlocal = mktime(local); |
---|
1555 | |
---|
1556 | t = time(NULL); |
---|
1557 | struct tm *gmt = gmtime(&t); |
---|
1558 | time_t rawgmt = mktime(gmt); |
---|
1559 | |
---|
1560 | int offset = difftime(rawlocal, rawgmt); |
---|
1561 | |
---|
1562 | tmpstr = oitoa(offset); |
---|
1563 | rtctimedev = getconfig("rtctime_offsetdev", NULL); |
---|
1564 | if(rtctimedev != NULL) |
---|
1565 | ret = writesys(rtctimedev, tmpstr, 0); |
---|
1566 | else |
---|
1567 | ret = writesys("/proc/stb/fp/rtc_offset", tmpstr, 0); |
---|
1568 | free(tmpstr); tmpstr = NULL; |
---|
1569 | rtctimedev = NULL; |
---|
1570 | |
---|
1571 | if(ret == 0) |
---|
1572 | { |
---|
1573 | tmpstr = oitoa(rawlocal); |
---|
1574 | rtctimedev = getconfig("rtctimedev", NULL); |
---|
1575 | if(rtctimedev != NULL) |
---|
1576 | ret = writesys(rtctimedev, tmpstr, 0); |
---|
1577 | else |
---|
1578 | ret = writesys("/proc/stb/fp/rtc", tmpstr, 0); |
---|
1579 | free(tmpstr); tmpstr = NULL; |
---|
1580 | rtctimedev = NULL; |
---|
1581 | } |
---|
1582 | return ret; |
---|
1583 | } |
---|
1584 | |
---|
1585 | #endif |
---|