source: titan/titan/sh4port.h @ 39988

Last change on this file since 39988 was 38477, checked in by obi, 8 years ago

fix minitv disable mipselport.h

File size: 20.3 KB
Line 
1#ifndef SH4PORT_H
2#define SH4PORT_H
3
4#include <bpamem.h>
5#include <libmmeimage.h>
6#include <linux/stmfb.h>
7
8struct stmfbio_output_configuration outcfg;
9struct stmfbio_outputinfo outinfo;
10struct stmfbio_planeinfo planemode;
11struct stmfbio_var_screeninfo_ex infoex;
12
13#define VIDEO_DISCONTINUITY                   _IO('o',  84)
14#define DVB_DISCONTINUITY_SKIP                0x01
15#define DVB_DISCONTINUITY_CONTINUOUS_REVERSE  0x02
16
17int setmixer(struct dvbdev* node, int left, int right)
18{
19        return 0;
20}
21
22int setencoding(struct channel* chnode, struct dvbdev* videonode)
23{
24        int ret = 1;
25        if(chnode == NULL) return ret;
26       
27        switch(chnode->videocodec)
28        {
29                case MPEGV:
30                        ret = videosetencoding(videonode, 2);
31                        break;
32                case MPEG4V:
33                        ret = videosetencoding(videonode, 7);
34                        break;
35                case H264:
36                        ret = videosetencoding(videonode, 8);
37                        break;
38                case VC1:
39                        ret = videosetencoding(videonode, 10);
40                        break;
41                default:
42                        ret = videosetencoding(videonode, 0);
43        }
44        return ret;
45}
46
47// inform the player about the jump in the stream data
48// flag 0: skip
49// flag 1: cont. reverse
50int videodiscontinuityskip(struct dvbdev* node, int flag)
51{
52        int param = 0;
53
54        if(node == NULL)
55        {
56                err("NULL detect");
57                return 1;
58        }
59
60        if(flag >= 0)
61                param = DVB_DISCONTINUITY_SKIP;
62        else
63                param = DVB_DISCONTINUITY_CONTINUOUS_REVERSE;
64
65        debug(200, "VIDEO_DISCONTINUITY");
66        if(ioctl(node->fd, VIDEO_DISCONTINUITY, (void*)param) < 0)
67        {
68                perr("VIDEO_DISCONTINUITY");
69                return 1;
70        }
71
72        return 0;
73}
74
75void fbsave()
76{
77  outcfg.outputid = STMFBIO_OUTPUTID_MAIN;
78  if(ioctl(fb->fd, STMFBIO_GET_OUTPUT_CONFIG, &outcfg) < 0)
79  {
80    perr("ioctl STMFBIO_GET_OUTPUT_CONFIG");
81  }
82
83        outinfo.outputid = STMFBIO_OUTPUTID_MAIN;
84        if(ioctl(fb->fd, STMFBIO_GET_OUTPUTINFO, &outinfo) < 0)
85  {
86                perr("ioctl STMFBIO_GET_OUTPUTINFO");
87  }
88
89        planemode.layerid = 0;
90        if(ioctl(fb->fd, STMFBIO_GET_PLANEMODE, &planemode) < 0)
91  {
92    perr("ioctl STMFBIO_GET_PLANEMODE");
93  }
94
95  if(ioctl(fb->fd, STMFBIO_GET_VAR_SCREENINFO_EX, &infoex) < 0)
96  {
97    perr("ioctl STMFBIO_GET_VAR_SCREENINFO_EX");
98  }
99}
100
101void fbrestore()
102{
103  if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &infoex) < 0)
104  {
105    perr("ioctl STMFBIO_SET_VAR_SCREENINFO_EX");
106  }
107
108        if(ioctl(fb->fd, STMFBIO_SET_PLANEMODE, &planemode) < 0)
109  {
110                perr("ioctl STMFBIO_SET_PLANEMODE");
111  }
112
113        if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &infoex) < 0)
114  {
115                perr("ioctl STMFBIO_SET_VAR_SCREENINFO_EX");
116  }
117
118        if(ioctl(fb->fd, STMFBIO_SET_OUTPUTINFO, &outinfo) < 0)
119  {
120                perr("ioctl STMFBIO_SET_OUTPUTINFO");
121  }
122
123        if(ioctl(fb->fd, STMFBIO_SET_OUTPUT_CONFIG, &outcfg) < 0)
124  {
125                perr("ioctl STMFBIO_SET_OUTPUT_CONFIG");
126  }
127}
128
129void setfbvarsize(struct fb* newnode)
130{
131        if(newnode != NULL)
132                newnode->varfbsize = 1920 * 1080 * newnode->colbytes;
133}
134
135void enablemanualblit()
136{
137}
138
139//flag 0 = no animation
140//flag 1 = animation
141void blitfb2(struct fb* fbnode, int flag)
142{
143        int i = 0, max = 1, wstep = 0, hstep = 0, ret = 0;
144        unsigned char buf[10];
145
146        if(fbnode == NULL) return;
147        if(fbnode == fb) return;
148
149        if(status.rguidfd > -1)
150        {
151                m_lock(&status.accelfbmutex, 16);
152               
153                int zlen = 0;
154                char* zbuf = NULL;
155                blitscale(0, 0, fbnode->width, fbnode->height, 440, 330, 1);
156                ret = ozip((char*)accelfb->fb, 440 * 330 * 4, &zbuf, &zlen, 1);
157
158                if(ret == 0)
159                {
160                        memset(buf, 0, 10);
161                        char* tmpnr = oitoa(zlen);
162                        memcpy(buf, tmpnr, strlen(tmpnr));
163                        free(tmpnr); tmpnr = NULL;
164                        socksend(&status.rguidfd, buf, 10, 5000 * 1000);
165                        socksend(&status.rguidfd, (unsigned char*)zbuf, zlen, 5000 * 1000);
166                }
167                free(zbuf); zbuf = NULL;
168                zlen = 0;
169
170                m_unlock(&status.accelfbmutex, 16);
171        }
172
173        if(status.write_png == 1 && status.infobaraktiv == 0)
174        {
175                m_lock(&status.accelfbmutex, 16);
176                blitscale(0, 0, fbnode->width, fbnode->height, 320, 240, 1);
177                if(writeFBfile.ActBuf == NULL)
178                {
179                        writeFBfile.buf1 = malloc(4 * 320 * 240);
180                        writeFBfile.ActBuf = writeFBfile.buf1;
181                        memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240);
182                        addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL);
183                }
184                else if(writeFBfile.buf1 == writeFBfile.ActBuf)
185                {
186                        if(writeFBfile.buf2 == NULL)
187                                writeFBfile.buf2 = malloc(4 * 320 * 240);
188                        memcpy(writeFBfile.buf2, accelfb->fb, 4 * 320 * 240);
189                }
190                else if(writeFBfile.buf2 == writeFBfile.ActBuf)
191                {
192                        if(writeFBfile.buf1 == NULL)
193                                writeFBfile.buf1 = malloc(4 * 320 * 240);
194                        memcpy(writeFBfile.buf1, accelfb->fb, 4 * 320 * 240);
195                }
196                m_unlock(&status.accelfbmutex, 16);
197        }
198
199        int mode3d = 0;
200        char* mode3dstr = NULL;
201
202        if(status.leftoffset != 0) blitrect(0, 0, status.leftoffset, fb->height, 0, 255, 2);
203        if(status.rightoffset != 0) blitrect(fb->width - status.rightoffset, 0, status.rightoffset, fb->height, 0, 255, 2);
204        if(status.topoffset != 0) blitrect(0, 0, fb->width, status.topoffset, 0, 255, 2);
205        if(status.bottomoffset != 0) blitrect(0, fb->height - status.bottomoffset, fb->width, status.bottomoffset, 0, 255, 2);
206
207        mode3dstr = getconfig("av_mode3d", NULL);
208        if(ostrcmp(mode3dstr, "sbs") == 0)
209                mode3d = 1;
210        else if(ostrcmp(mode3dstr, "tab") == 0)
211                mode3d = 2;
212
213        STMFBIO_BLT_DATA  bltData;
214        memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA));
215
216        bltData.operation  = BLT_OP_COPY;
217        bltData.srcOffset  = fbnode->fb - fb->fb;
218        bltData.srcPitch   = fbnode->pitch;
219        bltData.src_top    = 0;
220        bltData.src_left   = 0;
221        bltData.src_right  = fbnode->width;
222        bltData.src_bottom = fbnode->height;
223        bltData.srcFormat  = SURF_BGRA8888;
224        bltData.srcMemBase = STMFBGP_FRAMEBUFFER;
225
226        bltData.dstOffset  = 0;
227        bltData.dstPitch   = fb->pitch;
228        bltData.dst_left   = status.leftoffset;
229        bltData.dst_top    = status.topoffset;
230        if(mode3d == 1)
231                bltData.dst_right = (fb->width - status.rightoffset) / 2;
232        else
233                bltData.dst_right = fb->width - status.rightoffset;
234        if(mode3d == 2)
235                bltData.dst_bottom = (fb->height - status.bottomoffset) / 2;
236        else
237                bltData.dst_bottom = fb->height - status.bottomoffset;
238        bltData.dstFormat  = SURF_BGRA8888;
239        bltData.dstMemBase = STMFBGP_FRAMEBUFFER;
240
241        if(flag == 1 && status.screenanim > 0 && mode3d == 0)
242        {
243                int width = (fb->width - status.rightoffset) - status.leftoffset;
244                int height = (fb->height - status.topoffset) - status.bottomoffset;
245                max = 25;
246                if(status.screenanim == 1 || status.screenanim == 3)
247                {
248                        bltData.dst_left = (width / 2) - 1;
249                        bltData.dst_right = (width / 2) + 1;
250                }
251                if(status.screenanim == 2 || status.screenanim == 3)
252                {
253                        bltData.dst_top = (height / 2) - 1;
254                        bltData.dst_bottom = (height / 2) + 1;
255                }
256                wstep = width / max;
257                hstep = height / max;
258        }
259
260        for(i = 0; i < max; i++)
261        {
262
263                if(status.screenanim == 1 || status.screenanim == 3)
264                {
265                        int tmpleft = bltData.dst_left - wstep;
266                        int tmpright = bltData.dst_right + wstep;
267                        if(tmpleft < status.leftoffset)
268                                tmpleft = status.leftoffset;
269                        if(tmpright > fb->width - status.rightoffset)
270                                tmpright = fb->width - status.rightoffset;
271                        bltData.dst_left = tmpleft;
272                        bltData.dst_right = tmpright;
273                }
274
275                if(status.screenanim == 2 || status.screenanim == 3)
276                {
277                        int tmptop = bltData.dst_top - hstep;
278                        int tmpbottom = bltData.dst_bottom + hstep;
279                        if(tmptop < status.topoffset)
280                                tmptop = status.topoffset;
281                        if(tmpbottom > fb->height - status.bottomoffset)
282                                tmpbottom = fb->height - status.bottomoffset;
283                        bltData.dst_top = tmptop;
284                        bltData.dst_bottom = tmpbottom;
285                }
286
287                if(status.screenanim > 0) usleep(status.screenanimspeed * 1000);
288
289                if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0)
290                {
291                        perr("ioctl STMFBIO_BLT");
292                }
293                if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0)
294                {
295                        perr("ioctl STMFBIO_SYNC_BLITTER");
296                }
297
298                if(mode3d != 0)
299                {
300                        if(mode3d == 1)
301                                bltData.dst_left = status.leftoffset + ((fb->width - status.rightoffset) / 2);
302                        if(mode3d == 2)
303                                bltData.dst_top = status.topoffset + ((fb->height - status.bottomoffset) / 2);
304                        bltData.dst_right  = fb->width - status.rightoffset;
305                        bltData.dst_bottom = fb->height - status.bottomoffset;
306
307                        if (ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0)
308                        {
309                                perr("ioctl STMFBIO_BLT");
310                        }
311                        if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0)
312                        {
313                                perr("ioctl STMFBIO_SYNC_BLITTER");
314                        }
315                }
316        }
317}
318
319void setfbtransparent(int value)
320{
321        struct stmfbio_var_screeninfo_ex varEx = {0};
322
323        varEx.layerid  = 0;
324        varEx.activate = STMFBIO_ACTIVATE_IMMEDIATE;
325        varEx.caps = STMFBIO_VAR_CAPS_OPACITY;
326        varEx.opacity = value;
327
328
329        if(ioctl(fb->fd, STMFBIO_SET_VAR_SCREENINFO_EX, &varEx) < 0)
330                perr("STMFBIO_SET_VAR_SCREENINFO_EX");
331}
332
333int allocbpamem(size_t size, int *memfd, unsigned char **mem)
334{
335        *memfd = open("/dev/bpamem0", O_RDWR);
336       
337        if(*memfd < 0)
338        {
339                err("cannot access /dev/bpamem0! err = %d", (int)*memfd);
340                return -1;
341        }
342
343        BPAMemAllocMemData bpa_data;
344        bpa_data.bpa_part = "LMI_VID";
345        bpa_data.mem_size = size;
346        int res;
347        res = ioctl(*memfd, BPAMEMIO_ALLOCMEM, &bpa_data); // request memory from bpamem
348        if(res)
349        {
350                err("cannot alloc required bpa mem");
351                close(*memfd);
352                return -1;
353        }
354
355        char* bpa_mem_device = NULL;
356        bpa_mem_device = malloc(30);
357        if(bpa_mem_device == NULL)
358        {
359                err("no mem");
360                return -1;
361        }
362
363        sprintf(bpa_mem_device, "/dev/bpamem%d", bpa_data.device_num);
364        close(*memfd);
365
366        *memfd = open(bpa_mem_device, O_RDWR);
367
368        if(*memfd < 0)
369        {
370                free(bpa_mem_device);
371                err("cannot access %s! err = %d", bpa_mem_device, (int)*memfd);
372                return -1;
373        }
374
375        *mem = (unsigned char *)mmap(0, bpa_data.mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, *memfd, 0);
376
377        if(*mem == MAP_FAILED)
378        {
379                err("could not map bpa mem");
380                free(bpa_mem_device);
381                ioctl(*memfd, BPAMEMIO_FREEMEM);
382                close(*memfd);
383                return -1;
384        }
385       
386        free(bpa_mem_device);
387        return 0;
388}
389
390void freebpamem(int memfd, unsigned char* mem, size_t len)
391{
392        munmap(mem, len);
393        ioctl(memfd, BPAMEMIO_FREEMEM);
394        close(memfd);
395}
396
397//mode 0: with fill (draw to skinfb)
398//mode 1: without fill (draw to skinfb)
399//mode 2: with fill (draw to fb)
400//mode 3: without fill (draw to fb)
401void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode)
402{
403        unsigned long tmpcol;
404
405        transparent = (transparent - 255) * -1;
406        tmpcol = color | ((transparent & 0xff) << 24);
407
408        STMFBIO_BLT_DATA  bltData;
409        memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA));
410
411        if(posx < 0) posx = 0;
412        if(posy < 0) posy = 0;
413        if(mode < 2)
414        {
415                if(posx > skinfb->width) posx = skinfb->width;
416                if(posy > skinfb->height) posy = skinfb->height;
417                if(posx + width > skinfb->width) width = skinfb->width - posx;
418                if(posy + height > skinfb->height) height = skinfb->height - posy;
419        }
420        else
421        {
422                if(posx > fb->width) posx = fb->width;
423                if(posy > fb->height) posy = fb->height;
424                if(posx + width > fb->width) width = fb->width - posx;
425                if(posy + height > fb->height) height = fb->height - posy;
426        }
427
428        if(width <= 0 || height <= 0) return;
429
430        if(mode == 0 || mode == 2)
431                bltData.operation  = BLT_OP_FILL;
432        else if(mode == 1 || mode == 3)
433                bltData.operation  = BLT_OP_DRAW_RECTANGLE;
434        bltData.colour     = tmpcol;
435        bltData.srcFormat  = SURF_ARGB8888;
436        bltData.srcMemBase = STMFBGP_FRAMEBUFFER;
437
438        if(status.usedirectfb == 1)
439                bltData.dstOffset  = 0;
440        else
441        {
442                if(mode < 2)
443                        bltData.dstOffset  = fb->varfbsize;
444                else
445                        bltData.dstOffset  = 0;
446        }
447        if(mode < 2)
448                bltData.dstPitch   = skinfb->pitch;
449        else
450                bltData.dstPitch   = fb->pitch;
451        bltData.dst_top    = posy;
452        bltData.dst_left   = posx;
453        bltData.dst_bottom = posy + height;
454        bltData.dst_right  = posx + width;
455        bltData.dstFormat  = SURF_ARGB8888;
456        bltData.dstMemBase = STMFBGP_FRAMEBUFFER;
457
458        if(ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0)
459        {
460                perr("ioctl STMFBIO_BLT");
461        }
462        if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0)
463        {
464                perr("ioctl STMFBIO_SYNC_BLITTER");
465        }
466}
467
468int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd)
469{
470        FILE *fp;
471        unsigned int temp1, temp2, temp3, temp4;
472
473        if(filename == NULL) return -1;
474
475        debug(200, "hardware decode picture (%s)...", filename);
476
477        if (!(fp = fopen(filename, "rb")))
478                return -1;
479         
480        if(get_jpeg_img_size(fp, &temp1, &temp2) != LIBMMEIMG_SUCCESS)
481                return -1;
482       
483        *width = temp1;
484        *height = temp2;
485        *channels = 3;
486        *rowbytes = *channels * temp1;
487       
488        if(allocbpamem(temp1 * temp2 * (*channels), memfd, mem) != 0)
489        {
490                fclose(fp);
491                return -1;
492        }
493       
494        temp3 = temp1;
495        temp4 = temp2;
496       
497        if(temp3 > skinfb->width) temp3 = skinfb->width;
498        if(temp4 > skinfb->height) temp4 = skinfb->height;
499               
500        if(decode_jpeg_noalloc(fp, temp1, temp2, 200, 200, (char *)*mem, 1) == LIBMMEIMG_SUCCESS)
501        {
502                fclose(fp);
503                return 0;
504        }
505       
506        fclose(fp);
507        freebpamem(*memfd, *mem, temp1 * temp2 * (*channels));
508        err("hardware decode error");
509
510        return -1;
511}
512
513//flag 0: blit from accelfb to skinfb
514//flag 1: blit from skinfb to accelfb
515void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag)
516{
517        STMFBIO_BLT_DATA  blt_data;
518        memset(&blt_data, 0, sizeof(STMFBIO_BLT_DATA));
519
520        if(scalewidth == 0) scalewidth = width;
521        if(scaleheight == 0) scaleheight = height;
522
523        if(posx < 0) posx = 0;
524        if(posx > skinfb->width) posx = skinfb->width;
525        if(posy < 0) posy = 0;
526        if(posy > skinfb->height) posy = skinfb->height;
527        if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx;
528        if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy;
529       
530        if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return;
531       
532        if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize)
533        {
534                err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize);
535                return;
536        }
537
538        blt_data.operation  = BLT_OP_COPY;
539       
540        if(flag == 0)
541        {
542                if(status.usedirectfb == 1)
543                        blt_data.srcOffset  = fb->varfbsize;
544                else
545                        blt_data.srcOffset  = fb->varfbsize + skinfb->varfbsize;
546        }
547        else
548        {
549                if(status.usedirectfb == 1)
550                        blt_data.srcOffset  = 0;
551                else
552                        blt_data.srcOffset  = fb->varfbsize;
553        }
554       
555        blt_data.srcPitch   = width * 4;
556        blt_data.src_top    = 0;
557        blt_data.src_left   = 0;
558        blt_data.src_right  = width;
559        blt_data.src_bottom = height;
560        blt_data.srcFormat  = SURF_ARGB8888;
561        blt_data.srcMemBase = STMFBGP_FRAMEBUFFER;
562       
563        if(flag == 0)
564        {
565                if(status.usedirectfb == 1)
566                {
567                        blt_data.dstOffset  = 0;
568                        blt_data.dstPitch   = fb->pitch;
569                }
570                else
571                {
572                        blt_data.dstOffset  = fb->varfbsize;
573                        blt_data.dstPitch   = skinfb->pitch;
574                }
575        }
576        else
577        {
578                if(status.usedirectfb == 1)
579                {
580                        blt_data.dstOffset  = fb->varfbsize;
581                        blt_data.dstPitch   = skinfb->pitch;
582                }
583                else
584                {
585                        blt_data.dstOffset  = fb->varfbsize + skinfb->varfbsize;
586                        blt_data.dstPitch   = scalewidth * 4;
587                }
588        }
589       
590        blt_data.dst_left   = posx;
591        blt_data.dst_top    = posy;
592        blt_data.dst_right  = posx + scalewidth;
593        blt_data.dst_bottom = posy + scaleheight;
594        blt_data.dstFormat  = SURF_ARGB8888;
595        blt_data.dstMemBase = STMFBGP_FRAMEBUFFER;
596       
597        if (ioctl(fb->fd, STMFBIO_BLT, &blt_data) < 0)
598        {
599                perr("ioctl STMFBIO_BLT");
600        }
601        if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0)
602        {
603                perr("ioctl STMFBIO_SYNC_BLITTER");
604        }
605}
606
607void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight, int mwidth, int mheight, int halign, int valign)
608{
609        STMFBIO_BLT_EXTERN_DATA blt_data;
610        memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA));
611       
612        //auto scale to mwidth / mheight
613        if(scalewidth == 1 && scaleheight == 1)
614                calcautoscale(width, height, mwidth, mheight, &scalewidth, &scaleheight);
615               
616        if(scalewidth == 0) scalewidth = width;
617        if(scaleheight == 0) scaleheight = height;
618
619        if(scalewidth > mwidth) scalewidth = mwidth;
620        if(scaleheight > mheight) scaleheight = mheight;
621
622        if(halign == CENTER)
623                posx += mwidth / 2 - width / 2;
624        else if(halign == RIGHT)
625                posx += mwidth - width;
626        if(valign == MIDDLE)
627                posy += mheight / 2 - height / 2;
628        else if(valign == BOTTOM)
629                posy += mheight - height;
630
631        blt_data.operation  = BLT_OP_COPY;
632        blt_data.ulFlags    = 0;
633        blt_data.srcOffset  = 0;
634        blt_data.srcPitch   = width * 3;
635        blt_data.dstOffset  = 0;
636        blt_data.dstPitch   = skinfb->pitch;
637        blt_data.src_top    = 0;
638        blt_data.src_left   = 0;
639        blt_data.src_right  = width;
640        blt_data.src_bottom = height;
641        blt_data.dst_left   = posx;
642        blt_data.dst_top    = posy;
643       
644        blt_data.dst_right  = posx + scalewidth;
645        blt_data.dst_bottom = posy + scaleheight;
646        blt_data.srcFormat  = SURF_BGR888;
647        blt_data.dstFormat  = SURF_ARGB8888;
648        blt_data.srcMemBase = (char *)buf;
649        blt_data.dstMemBase = (char *)skinfb->fb;
650        blt_data.srcMemSize = width * height * 3;
651        blt_data.dstMemSize = skinfb->pitch * skinfb->height;
652       
653        if(ioctl(skinfb->fd, STMFBIO_BLT_EXTERN, &blt_data) < 0)
654        {
655                err("ioctl STMFBIO_BLT_EXTERN");
656        }
657        if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0)
658        {
659                perr("ioctl STMFBIO_SYNC_BLITTER");
660        }
661}
662
663void initsignal(struct sigaction* sa)
664{
665        sigaction(SIGILL, sa, NULL);
666        sigaction(SIGBUS, sa, NULL);
667        sigaction(SIGFPE, sa, NULL);
668        sigaction(SIGUSR1, sa, NULL);
669        sigaction(SIGSEGV, sa, NULL);
670        sigaction(SIGUSR2, sa, NULL);
671        sigaction(SIGPIPE, sa, NULL);
672        sigaction(SIGALRM, sa, NULL);
673        sigaction(SIGSTKFLT, sa, NULL);
674        sigaction(SIGABRT, sa, NULL);
675
676        signal(SIGHUP, SIG_IGN);
677        signal(SIGINT, SIG_IGN);
678        signal(SIGTRAP, SIG_IGN);
679        signal(SIGTERM, SIG_IGN);
680        signal(SIGXCPU, SIG_IGN);
681        signal(SIGXFSZ, SIG_IGN);
682        signal(SIGVTALRM, SIG_IGN);
683        signal(SIGPROF, SIG_IGN);
684        signal(SIGPOLL, SIG_IGN);
685        signal(SIGRTMAX, SIG_IGN);
686        signal(SIGPWR, SIG_IGN);
687        signal(SIGSYS, SIG_IGN);
688}
689
690void sighandler(int sig, struct sigcontext ctx)
691{
692        switch(sig)
693        {
694                case SIGALRM:
695                {
696                        err("got signal sigalrm but ignore it");
697                        break;
698                }
699                case SIGPIPE:
700                {
701                        err("got signal sigpipe but ignore it");
702                        break;
703                }
704                case SIGUSR1:
705                {
706                        //todo all configs
707                        reloadconfig(status.configfile);
708                        reloadconfig(getconfig("ownconfig", NULL));
709                        break;
710                }
711                case SIGUSR2: //called if hanging mainthread detect
712                {
713                        debugstack(sig, NULL, NULL);
714                        break;
715                }
716                case SIGILL:
717                case SIGBUS:
718                case SIGFPE:
719                case SIGSEGV:
720                case SIGSTKFLT:
721                {
722                        /* sh4
723                        unsigned long sc_regs[16];
724                        unsigned long sc_pc; //programm counter register
725                        unsigned long sc_pr; //procedure register
726                        unsigned long sc_sr; //status register
727                        unsigned long sc_gbr;
728                        unsigned long sc_mach;
729                        unsigned long sc_macl; */
730
731                        debugstack(sig, (void *)ctx.sc_pr, (void *)ctx.sc_pc);
732                        err("got signal %d (%s), programm counter reg: 0x%lx,  procedure reg: 0x%lx", sig, strsignal(sig), ctx.sc_pc, ctx.sc_pr);
733
734                        if(getconfigint("saverun", NULL) == 1 && status.longjumpbuf != NULL)
735                                siglongjmp(status.longjumpbuf, 999);
736                        else
737                                exit(100);
738                        break;
739                }
740        }
741}
742
743int setvmpeg(struct dvbdev* node, int posx, int posy, int width, int height)
744{
745        if(status.tvpic == 1 && (posx != 0 || posy != 0 || width != 0 || height != 0))
746                return 0;
747
748        if(getskinconfigint("minitv", NULL) == 1)
749                return 0;
750       
751        char* vmpegdev = NULL, *tmpstr = NULL, *buf = NULL;
752        int ret = 0;
753
754        if(node == NULL) return 1;
755        vmpegdev = getconfig("vmpegalldev", NULL);
756
757        if(vmpegdev != NULL)
758        {
759                buf = malloc(MINMALLOC);
760                if(buf == NULL)
761                {
762                        err("no mem");
763                        return 1;
764                }
765               
766                tmpstr = malloc(MINMALLOC);
767                if(tmpstr == NULL)
768                {
769                        err("no mem");
770                        free(buf);
771                        return 1;
772                }
773               
774                snprintf(buf, MINMALLOC, vmpegdev, node->devnr);
775                snprintf(tmpstr, MINMALLOC, "%x %x %x %x", posx, posy, width, height);
776                debug(444, "set %s to %s", buf, tmpstr);
777
778                status.tvpic = 1;
779                ret = writesys(buf, tmpstr, 1);
780
781                //reset
782                if(posx == 0 && posy == 0 && width == 0 && height == 0)
783                        status.tvpic = 0;
784               
785                free(tmpstr);
786                free(buf);
787                return ret;
788        }
789
790        return 0;
791}
792
793//flag 0: wh = width
794//flag 1: wh = height
795int setvmpegrect(struct dvbdev* node, int posx, int posy, int wh, int flag)
796{
797        int ret = 0;
798        int leftoffset = status.leftoffset;
799        int rightoffset = status.rightoffset;
800        int topoffset = status.topoffset;
801        int bottomoffset = status.bottomoffset;
802
803        float rx = (float)fb->width / 720;
804        float ry = (float)fb->height / 576;
805
806        leftoffset = (float)leftoffset / rx;
807        rightoffset = (float)rightoffset / rx;
808        topoffset = (float)topoffset / ry;
809        bottomoffset = (float)bottomoffset / ry;
810
811        rx = (float)720 / (float)(720 - leftoffset - rightoffset);
812        ry = (float)576 / (float)(576 - topoffset - bottomoffset);
813
814        posx = (float)posx / rx;
815        posx += leftoffset;
816
817        posy = (float)posy / ry;
818        posy += topoffset;
819
820        if(flag == 0)
821        {
822                wh = ((float)wh / rx);
823                ret = setvmpeg(node, posx, posy, wh, (int)((float)wh / 1.2));
824        }
825
826        if(flag == 1)
827        {
828                wh = ((float)wh / ry);
829                ret = setvmpeg(node, posx, posy, (int)((float)wh * 1.2), wh);
830        }
831
832        return ret;
833}
834
835int resettvpic()
836{
837        int ret = 0;
838
839        if(status.tvpic > 0 && status.aktservice != NULL)
840                ret = setvmpeg(status.aktservice->videodev, 0, 0, 0, 0);
841
842        return ret;
843}
844
845int cagetslotinfo(struct dvbdev* node, ca_slot_info_t* info)
846{
847        if(node == NULL)
848        {
849                err("NULL detect");
850                return 1;
851        }
852
853        //info.num
854        //info.type
855        //info.flags (1:no, 2:present, 3:ready)
856
857        debug(201, "CA_GET_SLOT_INFO");
858        if(ioctl(node->fd, CA_GET_SLOT_INFO, info) < 0)
859        {
860                perr("CA_GET_SLOT_INFO");
861                return 1;
862        }
863
864        return 0;
865}
866
867#endif
Note: See TracBrowser for help on using the repository browser.