source: titan/titan/mipselport.h @ 37015

Last change on this file since 37015 was 37015, checked in by gost, 8 years ago

[titan] dm7020... activate skinadjust

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