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