source: titan/titan/titan.c @ 40424

Last change on this file since 40424 was 40080, checked in by gost, 7 years ago

[titan] dm900 fix 3d mode

File size: 34.1 KB
Line 
1#include "struct.h"
2#include "header.h"
3#include "debug.h"
4#include "crc32.h"
5#include "sock.h"
6
7#define SYSCODE 0UL
8#define HTTPAUTH "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0="
9
10struct clist *config[LISTHASHSIZE] = {NULL};
11struct clist *ownconfig[LISTHASHSIZE] = {NULL};
12struct clist *rcconfig[LISTHASHSIZE] = {NULL};
13struct clist *skinconfig[LISTHASHSIZE] = {NULL};
14struct skin *skin = NULL;
15struct fb *fb = NULL;
16struct fb* skinfb = NULL;
17struct fb* accelfb = NULL;
18struct fb* fb1 = NULL;
19struct fb* lcdskinfb = NULL;
20struct fb* oledskinfb = NULL;
21struct font *font = NULL;
22struct rc *rc = NULL;
23struct dvbdev *dvbdev = NULL;
24struct dvbdev *dvbdevsim = NULL;
25struct channel *channel = NULL;
26struct transponder *transponder = NULL;
27struct provider *provider = NULL;
28struct sat *sat = NULL;
29struct service *service = NULL;
30struct mainbouquet *mainbouquet = NULL;
31struct mainplaylist *mainplaylist = NULL;
32struct pic *pic = NULL;
33struct rcmap *rcmap = NULL;
34struct inetwork *inetwork = NULL;
35struct stimerthread *stimerthread = NULL;
36struct rectimer *rectimer = NULL;
37struct subpage* subpage = NULL, *oldsubpage = NULL;
38struct epgscanlist* epgscanlist = NULL;
39struct screensaver* screensaver = NULL;
40struct channelcache* channelcache[CHANNELCACHEMAX] = {NULL};
41struct transpondercache* transpondercache[TRANSPONDERCACHEMAX] = {NULL};
42struct hdd* hdd = NULL;
43struct queue* queue = NULL;
44struct caservice caservice[MAXCASERVICE];
45struct channelhistory channelhistory[MAXCHANNELHISTORY];
46struct mostzap* mostzap = NULL;
47struct mediadbfilter* mediadbfilter = NULL;
48struct mediadbcategory* mediadbcategory = NULL;
49struct mediadb* mediadb = NULL;
50struct mediadbcache* mediadbcache[MEDIADBCACHEMAX] = {NULL};
51struct unicable* unicable = NULL;
52struct oldentry* oldentry = NULL;
53struct newsletter* newsletter = NULL;
54struct extepgcache* extepgcache = NULL;
55struct extepgchannel* extepgchannel = NULL;
56struct extepgconfig* extepgconfig = NULL;
57struct lastsubtitle* lastsubtitle = NULL;
58struct style* style = NULL;
59struct download* bgdownload[MAXBGDOWNLOAD] = {NULL};
60struct channelslot *channelslot = NULL;
61
62#ifdef SH4
63#include "sh4port.h"
64#endif
65
66#ifdef MIPSEL
67#include "mipselport.h"
68#endif
69
70#ifdef I386
71#include "i386port.h"
72#endif
73
74#include "oldentry.h"
75#include "tpk.h"
76#include "queue.h"
77#include "channelcache.h"
78#include "transpondercache.h"
79#include "strconvert.h"
80#include "numinput.h"
81#include "textinput.h"
82#include "radiotext.h"
83#include "list.h"
84#include "config.h"
85#include "defaults.h"
86#include "ownconfig.h"
87#include "rcconfig.h"
88#include "skinconfig.h"
89#include "thumb.h"
90#include "global.h"
91#include "security.h"
92#include "stream.h"
93#include "dvbdev.h"
94#include "rotorcalc.h"
95#include "frontenddev.h"
96#include "dmxdev.h"
97#include "videodev.h"
98#include "audiodev.h"
99#include "cidev.h"
100#include "cadev.h"
101#include "scdev.h"
102#include "cacc.h"
103#include "ca.h"
104#include "dvrdev.h"
105#include "cam.h"
106#include "dvb.h"
107#include "fb.h"
108#include "font.h"
109#include "rcmap.h"
110#include "rc.h"
111#include "sat.h"
112#include "transponder.h"
113#include "provider.h"
114#include "channel.h"
115#include "bouquets.h"
116#include "mainbouquets.h"
117#include "playlist.h"
118#include "mainplaylist.h"
119#include "pic.h"
120#include "filelist.h"
121#include "skinfunc.h"
122#include "style.h"
123#include "skin.h"
124#include "inputhelp.h"
125#include "rcfunc.h"
126#include "listbox.h"
127#include "choicebox.h"
128#include "vfd.h"
129#include "timerthread.h"
130#include "service.h"
131#include "pip.h"
132#include "player.h"
133#include "dvdplayer.h"
134#include "timeshift.h"
135#include "record.h"
136#include "zap.h"
137#include "showiframe.h"
138#include "epgrecord.h"
139#include "multiepg.h"
140#include "gmultiepg.h"
141#include "epg.h"
142#include "eit.h"
143#include "extepg.h"
144#include "epgscan.h"
145#include "menulist.h"
146#include "videomode.h"
147#include "inetwork.h"
148#include "keyactions.h"
149#include "scart.h"
150#include "standby.h"
151#include "dir.h"
152#include "spinner.h"
153#include "lnbconfig.h"
154#include "diseqcconfig.h"
155#include "tunerconfig.h"
156#include "epgsettings.h"
157#include "listedit.h"
158#include "channellist.h"
159#include "vfdisplay.h"
160#include "videosettings.h"
161#include "textbox.h"
162#include "autores.h"
163#include "language.h"
164#include "about.h"
165#include "serviceinfo.h"
166#include "avsettings.h"
167#include "mute.h"
168#include "volume.h"
169#include "timezone.h"
170#include "adjust.h"
171#include "skinadjust.h"
172#include "blindscanadjust.h"
173#include "moduleconfig.h"
174#include "scconfig.h"
175#include "possetup.h"
176#include "rectimer.h"
177#include "pin.h"
178#include "plugin.h"
179#include "recordpath.h"
180#include "subtitle.h"
181#include "audiotrack.h"
182#include "linkedchannel.h"
183#include "powerofftimer.h"
184#include "skinselector.h"
185#include "play.h"
186#include "satfinder.h"
187#include "menu.h"
188#include "channelbynr.h"
189#include "infobar.h"
190#include "network.h"
191#include "harddisk.h"
192#include "httpdfunc.h"
193#include "httpd.h"
194#include "download.h"
195#include "copyfile.h"
196#include "screensaver.h"
197#include "screensaveradjust.h"
198#include "scan.h"
199#include "restoredefault.h"
200#include "help.h"
201#include "httpdsettings.h"
202#include "epgsearch.h"
203#include "inadyn.h"
204#include "rguid.h"
205#include "channelhistroy.h"
206#include "mostzap.h"
207#include "settings_redbutton.h"
208#include "settings_bluebutton.h"
209#include "extensions.h"
210#include "system_update.h"
211#include "system_backup.h"
212#include "system_backup_restore.h"
213#include "info.h"
214#include "softcam.h"
215#include "id3.h"
216#include "mediadbcache.h"
217#include "mediadb.h"
218#include "mediadbsettings.h"
219#include "colorpicker.h"
220#include "ocrypt.h"
221#include "unlock.h"
222#include "md5.h"
223#include "rc4.h"
224#include "textinputhist.h"
225#include "system_infos.h"
226#include "system_infos_sysinfo.h"
227#include "unicable.h"
228#include "newsletter.h"
229#include "dirsort.h"
230#include "shortepg.h"
231#include "mediadbedit.h"
232#include "tpchoice.h"
233#include "marker.h"
234#include "timeshiftsettings.h"
235#include "log.h"
236#include "bgdownload.h"
237#include "fancontrol.h"
238#include "channelslot.h"
239#include "hwtest.h"
240#include "settings_autostart.h"
241#include "settings_overclocking.h"
242#include "settings_pluginbutton.h"
243#include "bcm.h"
244#include "settings_mediabutton.h"
245#include "oled.h"
246#ifdef MIPSEL
247#include "cec.h"
248#include "encoder.h"
249#endif
250
251#define TIMECODE "1472042241"
252
253// mipsel start
254/* Apparently, surfaces must be 64-byte aligned */
255#define ACCEL_ALIGNMENT_SHIFT   6
256#define ACCEL_ALIGNMENT_MASK    ((1<<ACCEL_ALIGNMENT_SHIFT)-1)
257
258#define ACCEL_DEBUG
259
260//gAccel *gAccel::instance;
261#define BCM_ACCEL
262
263#ifdef BCM_ACCEL
264extern int bcm_accel_init(void);
265extern void bcm_accel_close(void);
266extern void bcm_accel_blit(
267                int src_addr, int src_width, int src_height, int src_stride, int src_format,
268                int dst_addr, int dst_width, int dst_height, int dst_stride,
269                int src_x, int src_y, int width, int height,
270                int dst_x, int dst_y, int dwidth, int dheight,
271                int pal_addr, int flags);
272extern void bcm_accel_fill(
273                int dst_addr, int dst_width, int dst_height, int dst_stride,
274                int x, int y, int width, int height,
275                unsigned long color);
276extern bool bcm_accel_has_alphablending();
277#endif
278// mipsel end
279
280void demomodethread(struct stimerthread* self)
281{
282        textbox(_("Message"), _("!!! This is a DEMO Version !!!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 600, 0, 1);
283}
284
285int createstartscreen()
286{
287        addscreen("<screen name=framebuffer/>", 0, 0);
288        if(skin == NULL)
289        {
290                err("can't set framebuffer skin");
291                return 1;
292        }
293        addscreen("<screen name=skinerror/>", 0, 0);
294        status.skinerr = getscreen("skinerror");
295        skin->width = skinfb->width;
296        skin->height = skinfb->height;
297        skin->iwidth = skinfb->width;
298        skin->iheight = skinfb->height;
299        skin->rwidth = skinfb->width;
300        skin->rheight = skinfb->height;
301        skin->bgcol = 0;
302        skin->transparent = 255;
303        skin->flag = 1;
304
305        return 0;
306}
307
308//exitcode: 1 power off
309//exitcode: 2 restart
310//exitcode: 3 Gui restart
311//flag: 0 do not check record
312//flag: 1 check record
313//flag: 2 check record / don't write config
314//flag: 3 check record with timeout
315//flag: 4 check record with increase fixpowerofftime
316//flag: 5 check record with increase powerofftime
317void oshutdown(int exitcode, int flag)
318{
319        struct dvbdev* dvbnode = dvbdev;
320        struct service* servicenode = service;
321        void* threadstatus;
322        int i = 0, faststop = 0, ret = 0;
323        char* tmpstr = NULL;
324        struct skin* logo = getscreen("logo");
325        pthread_attr_t writethreadattr = {};
326        pthread_t writethread = '\0';
327
328        //stop permanent timeshift
329        if(status.timeshift == 1)
330                timeshiftstop(3);
331
332        ret = checkshutdown(flag);
333        if(ret == 1) return;
334
335        ret = servicestop(status.aktservice, 1, 1);
336        if(ret == 1) return;
337       
338        if(exitcode == 1)
339                tmpstr = getconfig("userpowerofflogo", NULL);
340        else if(exitcode == 2)
341                tmpstr = getconfig("userrestartlogo", NULL);
342        else if(exitcode == 3)
343                tmpstr = getconfig("userguirestartlogo", NULL);
344       
345        if(tmpstr != NULL) {
346                if(file_exist(tmpstr) == 0)
347                        tmpstr = NULL;
348        }       
349        if(tmpstr == NULL) {   
350                if(exitcode == 1)
351                        tmpstr = getconfig("powerofflogo", NULL);
352                else if(exitcode == 2)
353                        tmpstr = getconfig("restartlogo", NULL);
354                else if(exitcode == 3)
355                        tmpstr = getconfig("guirestartlogo", NULL);
356        }
357                       
358        if(tmpstr != NULL)
359        {
360                changepic(logo, tmpstr);
361                tmpstr = NULL;
362                drawscreen(logo, 0, 0);
363        }
364        else
365                clearfball();
366
367        //stop all records
368        while(servicenode != NULL)
369        {
370                servicenode->recendtime = 1;
371                servicenode = servicenode->next;
372        }
373
374        faststop = getconfigint("faststop", NULL);
375
376        // Free memory, semaphores, etc. and say goodbye
377        if(faststop == 0) cleanupvfd();
378
379        if(status.servicetype != 99) //don't save tmp servicetype
380        {
381                tmpstr = oitoa(status.servicetype);
382                addconfig("servicetype", tmpstr);
383                free(tmpstr); tmpstr = NULL;
384        }
385
386        status.sec = 0;
387
388        if(flag != 2)
389        {
390                //start write thread
391                pthread_attr_init(&writethreadattr);
392                pthread_attr_setstacksize(&writethreadattr, 50000);
393                pthread_attr_setdetachstate(&writethreadattr, PTHREAD_CREATE_JOINABLE);
394
395                int epgsave = getconfigint("epgsave", NULL);
396                if((epgsave == 1 && exitcode == 3) || epgsave == 2)
397                        ret = pthread_create(&writethread, &writethreadattr, writeallconfigthread1, NULL); //do not save epg
398                else
399                        ret = pthread_create(&writethread, &writethreadattr, writeallconfigthread0, NULL); //save epg
400                if(ret)
401                {
402                        err("create write thread");
403                }
404        }
405       
406        //stop fan
407        if(checkchipset("BCM7424") == 1) //inihdp
408                writesys("/proc/stb/fp/fan", "1", 1);
409               
410        //reset ci devices
411        while(dvbnode != NULL)
412        {
413                if(dvbnode->type == CIDEV && dvbnode->fd > -1)
414                {
415                        if(dvbnode->caslot != NULL) dvbnode->caslot->status = 101;
416                        usleep(10000);
417                        careset(dvbnode, dvbnode->devnr);
418                }
419                dvbnode = dvbnode->next;
420        }
421
422        if(faststop == 0)
423        {
424                //wait for write thread
425                if(writethread != '\0')
426                        pthread_join(writethread, &threadstatus);
427                pthread_attr_destroy(&writethreadattr);
428
429                //stop timer thread
430                i = 0;
431                status.timerthreadaktion = STOP;
432                while(status.timerthreadstatus != DEACTIVE)
433                {
434                        usleep(100000);
435                        i++; if(i > 20) break;
436                }
437
438                if(i > 20)
439                {
440                        err("detect hanging timer thread");
441                }
442                else if(status.timerthread != '\0')
443                        pthread_join(status.timerthread, &threadstatus);
444                pthread_attr_destroy(&status.timerthreadattr);
445               
446                // free timerthread struct and stop all timer sub threads
447                freetimer(0);
448
449                status.skinerr = NULL;
450                free(status.gateway);
451                free(status.dnsserver1);
452                free(status.dnsserver2);
453                free(status.boxtype);
454                free(status.httpauth);
455                free(status.bgpic);
456
457                freeservice();
458                freecaservice();
459
460                freescreen();
461                freepic();
462                freefont();
463                deinitfont();
464
465                freerectimer();
466                freemostzap(0);
467                freechannelhistory();
468                freesat();
469                freeallplaylist();
470                freemainplaylist();
471                freeallbouquet();
472                freemainbouquet(0);
473                freechannel(0);
474                freetransponder();
475                freeprovider();
476                freeownconfig();
477                freeepgscanlist();
478                freercconfig();
479                freeskinconfig();
480                freequeue();
481                freehdd(0);
482
483                free(status.configfile);
484                freeconfig();
485
486                freedvbdev(0);
487
488                closefb(fb);
489                freefb();
490
491                closerc();
492                freerc();
493                freercmap();
494                free_shutdowntimervar();
495                freeinetwork();
496                freeoldentry();
497                freeextepgconfig();
498                freelastsubtitle();
499                freebgdownload();
500                freechannelslot();
501        }
502        else
503                freetimer(1);
504
505        if(exitcode == 1)
506                setcecstandby(1);
507
508        starthttpd(0);
509        startrguid(0);
510        initmutex(0);
511
512        if(faststop != 0)
513        {
514                //wait for write thread
515                if(writethread != '\0')
516                        pthread_join(writethread, &threadstatus);
517                pthread_attr_destroy(&writethreadattr);
518        }
519
520        exit(exitcode);
521}
522
523int main(int argc, char *argv[])
524{
525        int ret = 0, serviceret = 0, skincheck = 0;
526        char* tmpstr = NULL;
527        unsigned char *mmapfb = NULL;
528        struct sigaction sa;
529        struct stimerthread *tmpthread = NULL;
530        //struct sched_param schedparam;
531
532#ifdef SIMULATE
533        // for mem leak debug
534        setenv("MALLOC_TRACE", "/home/nit/titan/m.txt", 1);
535        mtrace();
536        status.security = 1;
537#endif
538
539        printf("[%s] copyright by %s - version %s (%d)\n", PROGNAME, COPYRIGHT, OVERSION, PLUGINVERSION);
540        printf("[%s] crontribut: %s\n", PROGNAME, CRONTRIBUT);
541
542        sa.sa_handler = (void *)sighandler;
543        sigemptyset(&sa.sa_mask);
544        sa.sa_flags = SA_RESTART;
545       
546        initsignal(&sa);
547
548        status.rguidfd = -1;
549        status.sec = time(NULL);
550        status.mainthread = pthread_self();
551
552        if(argc > 1)
553                status.configfile = ostrcat(argv[1], NULL, 0, 0);
554        else
555                status.configfile = ostrcat(CONFIGFILE, NULL, 0, 0);
556
557        printf("[%s] using config: %s\n", PROGNAME, status.configfile);
558        ret = readconfig(status.configfile, config);
559        if(ret != 0)
560        {
561                printf("error: status.configfile ret=%d\n", ret);
562                return 100;
563        }
564        //Workaround da ansonsten DVR4 nicht funktioniert (Treiberproblem)
565        status.setdvr0 = 0;
566       
567        //start timer thread
568        status.timerthreadaktion = START;
569        pthread_attr_init(&status.timerthreadattr);
570        pthread_attr_setstacksize(&status.timerthreadattr, 50000);
571        pthread_attr_setdetachstate(&status.timerthreadattr, PTHREAD_CREATE_JOINABLE);
572        ret = pthread_create(&status.timerthread, &status.timerthreadattr, timerthreadfunc, NULL);
573        if(ret)
574        {
575                err("create timer thread");
576                printf("error: create timer thread\n");
577                return 100;
578        }
579
580        //change working dir to /tmp
581        //chdir("/tmp");
582
583        //set main scheduler priority
584        //schedparam.sched_priority = 10;
585        //pthread_setschedparam(pthread_self(), SCHED_RR, &schedparam);
586
587        readconfig(getconfig("ownconfig", NULL), ownconfig);
588        readconfig(getconfig("rcconfig", NULL), rcconfig);
589
590        skincheck = checkskin();
591        readconfig(getconfig("skinconfig", NULL), skinconfig);
592
593        setprogress(100);
594        setdefaults();
595        setdebuglevel();
596        initmutex(1);
597        m_lock(&status.waitrcmutex, 24);
598        initvfd();
599
600        if(checkbox("UFS922") == 1)
601                setfanspeed(-1, 0);
602        if(checkchipset("BCM7424") == 1) //inihdp
603        {
604                if(getconfigint("fanmode", NULL) == 0)
605                        addconfig("fanmode", "3");
606                writesys("/proc/stb/fp/fan", getconfig("fanmode", NULL), 1);
607        }
608        if(getconfigint("wol", NULL) == 1)
609                system("echo enable > /proc/stb/fp/wol");
610        else
611                system("echo disable > /proc/stb/fp/wol");
612
613#ifdef MIPSEL
614        addtimer(&cecinit, START, 10000, 1, NULL, NULL, NULL);
615        //cecinit();
616#endif 
617        system(getconfig("skriptbeforetv", NULL));
618//      ret = setcecstandby(0); --- > jetzt in checkboxstart
619        ret = setvideomode(getconfig("av_videomode", NULL), 0);
620#ifndef MIPSEL
621        ret = setaspect(getconfig("av_aspect", NULL));
622#endif
623        ret = setpolicy(getconfig("av_policy", NULL));
624        ret = setcolorformat(getconfig("av_colorformat", NULL), 0);
625        ret = setcolorformat(getconfig("av_colorformatscart", NULL), 1);
626        ret = setaudiosource(getconfig("av_audiosource", NULL));
627        ret = setac3(getconfig("av_ac3mode", NULL));
628
629        if(checkbox("DM900") == 1)
630        {
631                if(getconfig("av_ac3plusmode", NULL) == NULL)
632                        addconfig("av_ac3plusmode", "force_ac3");
633                if(getconfig("av_dtshdmode", NULL) == NULL)
634                        addconfig("av_dtshdmode", "force_dts");
635                if(getconfig("av_wmapromode", NULL) == NULL)
636                        addconfig("av_wmapromode", "downmix");
637                ret = setac3plus(getconfig("av_ac3plusmode", NULL));
638                ret = setdtshd(getconfig("av_dtshdmode", NULL));
639                ret = setwmapro(getconfig("av_wmapromode", NULL));
640       
641                addconfig("mode3ddev", "/proc/stb/fb/primary/3d");     //24.02.17
642        }
643               
644#ifdef MIPSEL
645        ret = setaac(getconfig("av_aacmode", NULL));
646        ret = setwss(getconfig("av_wssmode", NULL));
647#endif
648        ret = setpolicy(getconfig("av_policy", NULL));
649        ret = setmode3d(getconfig("av_mode3d", NULL));
650        ret = setvfdbrightness(getconfigint("vfdbrightness", NULL));
651        ret = setaudiodelaybitstream(getconfig("audiodelaybitstream", NULL));
652        ret = addinetworkall(NULL);
653       
654        ret = 1;
655        if(file_exist("/var/etc/.usbimage"))
656                ret = system("mount | grep titan");
657 
658#ifndef SIMULATE
659        if(checkrealbox("DM900") == 1)
660                ret = 0;
661
662        // set pvr 1 = allowed , 0 = disabled
663        status.pvr = 1;
664        if(file_exist("/etc/.stable") && (checkbox("ATEMIO6000") == 1 || checkbox("ATEMIO6100") == 1 || checkbox("ATEMIO6200") == 1))
665                status.pvr = 0;
666
667        if(getconfigint("sos", NULL) == 0)
668        {
669                if(ostrcmp(string_newline(gettimeinfo()), TIMECODE) == 1)
670                {
671                        printf("error: 1\n");
672                        destroy();
673                        exit(100);
674                }
675                if(ostrcmp(string_newline(gettimeinfovar()), TIMECODE) == 1)
676                {
677                        printf("error: 2\n");           
678                        destroy();
679                        exit(100);
680                }
681                if(checkreseller() != 0)
682                {
683                        printf("error: 3\n");           
684                        destroy();
685                        exit(100);
686                }
687                if(ret > 0)
688                {
689                        if(getsysinfo() != SYSCODE)
690                        {
691                                printf("error: 4\n");           
692                                destroy();
693                                exit(100);
694                        }
695                }
696                if(file_exist("/mnt/swapextensions/etc/.vnumber") == 1)
697                {
698                        printf("error: 5\n");           
699                        destroy();
700                        exit(100);
701                }
702                if(ret > 0)
703                {
704                        if(checkflash() != 0)
705                        {
706                                printf("error: 6\n");           
707                                destroy();
708                                exit(100);
709                        }
710                }
711                if(ret > 0)
712                {
713                        if((checkchipset("BCM7424") == 1 || checkchipset("BCM7358") == 1 || checkchipset("BCM7362") == 1 || checkbox("UFS913") == 1 || checkbox("SPARK") == 1 || checkbox("SPARK7162") == 1 || checkbox("IPBOX91") == 1 || checkbox("IPBOX900") == 1 || checkbox("IPBOX910") == 1 || checkbox("IPBOX9000") == 1) && checkhighflash() != 0)
714                        {
715                                printf("error: 7\n");           
716                                destroy();
717                                exit(100);
718                        }
719                }
720                if(checkbox("UFS910") == 1 && checklowflash() != 0)
721                {
722                        printf("error: 8\n");           
723                        destroy();
724                        exit(100);
725                }
726       
727                char* cpuid = getcpuid();
728                checkserial(cpuid);
729                free(cpuid); cpuid = NULL;
730        }
731        else
732        {
733                status.security = 5;
734                startnet();
735                setskinnodeslocked(0);
736        }
737#endif
738
739        if(file_exist("/mnt/config/dualboot.enigma2"))
740        {
741                printf("error: found /mnt/config/dualboot.enigma2\n");
742                return 0;
743        }
744
745        ret = initfont();
746        if(ret != 0)
747        {
748                printf("error: initfont\n");
749                return 100;
750        }
751        ret = openfont(getconfig("fontfile1", NULL));
752        if(ret != 0)
753        {
754                err("open fontfile1 font");
755                printf("error: open fontfile1 font\n");
756                return 100;
757        }
758        openfont(getconfig("fontfile2", NULL));
759        openfont(getconfig("fontfile3", NULL));
760        openfont(getconfig("fontfile4", NULL));
761        openfont(getconfig("fontfile5", NULL));
762
763        //skin defined fonts
764        openfont(getskinconfig("fontfile1", NULL));
765        openfont(getskinconfig("fontfile2", NULL));
766        openfont(getskinconfig("fontfile3", NULL));
767        openfont(getskinconfig("fontfile4", NULL));
768        openfont(getskinconfig("fontfile5", NULL));
769
770
771        status.volume = -1;
772        setvol(getconfigint("vol", NULL));
773
774       
775        setlang(getconfig("lang", NULL));
776        initlocale(getconfig("localepath", NULL));
777
778#ifdef MIPSEL
779        bcm_accel_init();
780#endif
781
782        fb = openfb(getconfig("fbdev", NULL), 0);
783        if(fb == NULL)
784        {
785                printf("error: openfb %s\n", getconfig("fbdev", NULL));
786                return 100;
787        }
788        clearfball();
789        enablemanualblit();
790       
791        tmpstr = getconfig("fb1dev", NULL);
792        if(tmpstr != NULL)
793                fb1 = openfb(tmpstr, 1);
794        tmpstr = NULL;
795
796#ifdef MIPSEL
797        waitvsync();
798        if(checkbox("DM7020HD") == 0 && checkbox("DM7020HDV2") == 0 && checkbox("VUSOLO2") == 0 && checkbox("DM900") == 0)
799                setfbosd();
800        status.usedirectfb = 1;
801#endif
802
803        if(status.usedirectfb != 1)
804        {
805                skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize, 0);
806                if(skinfb != NULL)
807                {
808                        ret = getfbsize(0);
809                        if(ret > 0)
810                                accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize, 0);
811                }
812                else
813                {
814                        debug(100, "use directfb");
815                        status.usedirectfb = 1;
816                }
817        }
818        if(status.usedirectfb == 1)
819        {
820                skinfb = fb;
821#ifndef MIPSEL
822                ret = getfbsize(0);
823                if(ret > 0)
824                        accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize, fb->data_phys + fb->varfbsize);
825#else
826                ret = getfbsize(0);
827                if(ret > 0 && status.bcm == 1)
828                {
829                        skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize, fb->data_phys + fb->varfbsize);
830                        if(skinfb != NULL)
831                        {
832                                status.usedirectfb = 0;
833                                ret = getfbsize(0);
834                                if(ret > 0)
835                                        accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize, skinfb->data_phys + skinfb->varfbsize);
836                        }
837                }
838#endif
839        }
840
841        //if(lcdskinfb == NULL) {
842                //mmapfb = malloc(4 * 320 * 240);
843                //mmapfb = malloc(4 * 1024 * 768);
844                //mmapfb = NULL;
845                /* dev=999 ist LCD Buffer */
846                //lcdskinfb = addfb("lcdskinfb", 999, 320, 240, 4, -1, mmapfb, 4 * 320 * 240);
847                //lcdskinfb = addfb("lcdskinfb", 999, 1024, 768, 4, -1, mmapfb, 4 * 1024 * 768);
848                // mmapfb = NULL;
849        //}
850
851        ret = createstartscreen();
852        if(ret != 0)
853        {
854                printf("error: createstartscreen\n");
855                return 100;
856        }
857        //from here we can use starterror screen
858        ret = openrc();
859        if(ret != 0)
860        {
861                tmpstr = ostrcat(tmpstr, _("Error: open rc device !!"), 1, 0);
862                goto starterror;
863        }
864
865        if(fegetdev() < 1)
866        {
867                tmpstr = ostrcat(tmpstr, _("Error: no frontend device found !!"), 1, 0);
868                err("no frontend device found");
869                goto starterror;
870        }
871        if(dmxgetdev() < 1)
872        {
873                tmpstr = ostrcat(tmpstr, _("Error: no demux device found !!"), 1, 0);
874                err("no demux device found");
875                goto starterror;
876        }
877        if(videogetdev() < 1)
878        {
879                tmpstr = ostrcat(tmpstr, _("Error: no video device found !!"), 1, 0);
880                err("no video device found");
881                goto starterror;
882        }
883        if(audiogetdev() < 1)
884        {
885                tmpstr = ostrcat(tmpstr, _("Error: no audio device found !!"), 1, 0);
886                err("no audio device found");
887                goto starterror;
888        }
889        ret = fecreatedummy();
890        ret = cagetdev();
891        ret = cigetdev();
892        ret = dvrgetdev();
893        ret = scgetdev();
894#ifdef MIPSEL
895        if(checkchipset("BCM7424") == 1) //inihdp
896                ret = encodergetdev();
897#endif
898
899        settunerstatus();
900
901        //start ca slot watching threads
902        castart();
903
904        //check skin
905        if(skincheck > 0)
906        {
907
908                tmpstr = ostrcat(tmpstr, _("Error: skin not found !!"), 1, 0);
909                err("skin not found");
910                goto starterror;
911        }
912
913        ret = readsat(getconfig("satfile", NULL));
914        ret = readtransponder(getconfig("transponderfile", NULL));
915        ret = readprovider(getconfig("providerfile", NULL));
916        ret = readchannel(getconfig("channelfile", NULL));
917        ret = readtransponderencoding(getconfig("transponderencodingfile", NULL));
918        ret = readmostzap(getconfig("mostzapfile", NULL));
919        ret = readlastsubtitle(getconfig("lastsubtitle", NULL));
920        ret = readchannelslot(getconfig("channelslotfile", NULL));
921
922        status.aktservice = addservice(NULL);
923        status.lastservice = addservice(NULL);
924        status.pipservice = addservice(NULL);
925
926        //check if startchannel defined
927        char* startchannellist = getconfig("startchannellist", NULL);
928        int startserviceid = getconfigint("startserviceid", NULL);
929        uint64_t starttransponderid = getconfigllu("starttransponderid", NULL);
930        int startservicetype = getconfigint("startservicetype", NULL);
931        if(startchannellist != NULL && startserviceid != 0)
932        {
933                if(startservicetype == 0)
934                {
935                        addconfig("channellist", startchannellist);
936                        addconfigint("serviceid", startserviceid);
937                        addconfigllu("transponderid", starttransponderid);
938                }
939                else
940                {
941                        addconfig("rchannellist", startchannellist);
942                        addconfigint("rserviceid", startserviceid);
943                        addconfigllu("rtransponderid", starttransponderid);
944                }
945                addconfigint("servicetype", startservicetype);
946        }
947        setvol(getconfigint("vol", NULL));
948        //tune to channel
949        if(status.servicetype == 0)
950                serviceret = servicestart(getchannel(getconfigint("serviceid", NULL), getconfigllu("transponderid", NULL)), getconfig("channellist", NULL), NULL, 0);
951        else
952                serviceret = servicestart(getchannel(getconfigint("rserviceid", NULL), getconfigllu("rtransponderid", NULL)), getconfig("rchannellist", NULL),  NULL, 0);
953
954        if(checkbox("IPBOX9000") == 1 && !file_exist("/tmp/.opticum9600.workaround"))
955        {
956                printf("opticum.workaround start\n");
957                system("touch /tmp/.opticum9600.workaround");
958                oshutdown(3, 1);
959                printf("opticum.workaround end\n");
960        }
961
962        ret = readscreen(getconfig("skinfile", NULL), 0, 0);
963        if(getconfig("keyskin_file", NULL) == NULL)
964                ret = readscreen("/var/usr/local/share/titan/skin/default/keyskin.xml", 0, 0);
965        else
966                ret = readscreen(getconfig("keyskin_file", NULL), 0, 0);
967        if(checkchipset("BCM7424") == 1 || checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1 || checkbox("DM900") == 1)  //inihdp
968        {
969                if(getconfig("oledskin_path", NULL) == NULL)
970                        ret = readscreen("/var/usr/local/share/titan/skin/default/oledskin.xml", 0, 0);
971                else
972                {
973                        tmpstr = ostrcat(getconfig("oledskin_path", NULL),"/oledskin.xml", 0, 0);
974                        ret = readscreen(tmpstr, 0, 0);
975                        free(tmpstr);tmpstr=NULL;
976                }
977        }
978        ret = readmainbouquet(getconfig("bouquetfile", NULL));
979        ret = readallbouquet();
980        ret = readmainplaylist(getconfig("playlistfile", NULL));
981        ret = readallplaylist();
982        ret = readrcmap(getconfig("rcmapfile", NULL));
983        ret = readepgscanlist(getconfig("epgchannelfile", NULL));
984        ret = settimezone(getconfig("timezone", NULL));
985        ret = readextepgconfig(getconfig("extepgfile", NULL));
986
987        //check to remove preinstalled tpk packages
988        ret = tpkupdatepre();
989
990        addtimer(&checkdate, START, 2000, -1, NULL, NULL, NULL);
991        if(checkbox("ATEMIO510") == 0)
992                addtimer(&updatevfd, START, 1000, -1, NULL, NULL, NULL);
993
994        if(getconfigint("firststart", NULL) == 1)
995        {
996                if(file_exist("/var/etc/.scart"))
997                {
998                        setvideomode("pal", 0);
999                        changefbresolution("pal", 0);
1000                        autoresolution();
1001                }
1002                addconfig("firststart", "0");
1003        }
1004
1005        if(getconfig("remotecontrol", NULL) == NULL)
1006        {
1007                if(checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
1008                {
1009                        //autopo work
1010                        char* tmptxt = NULL;
1011                        tmptxt = ostrcat(tmptxt, _("RemoteControl Old Version"), 0, 0);
1012                        tmptxt = ostrcat(tmptxt, _("RemoteControl Long Version"), 0, 0);
1013                        free(tmptxt), tmptxt = NULL;
1014
1015                        struct menulist* mlist = NULL, *mbox = NULL;
1016                        addmenulist(&mlist, "RemoteControl Old Version", "0", NULL, 0, 0);
1017                        addmenulist(&mlist, "RemoteControl Long Version", "1", NULL, 0, 0);
1018                        // remotecontrol try menulist
1019                        mbox = menulistbox(mlist, "menulist", _("Select Your Remote Control"), _("Choose your Remotecontrol Model from the following list"), NULL, NULL, 3, 0);
1020                        if(mbox != NULL)
1021                        {
1022                                debug(10, "mbox->name %s", mbox->name);
1023                                debug(10, "mbox->text %s", mbox->text);
1024                                addconfig("remotecontrol", mbox->text);
1025                                writeallconfig(1);                             
1026                        }
1027                }
1028                if(checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1 || checkbox("DM900"))
1029                {
1030                        addconfig("remotecontrol", "0");
1031                        writeallconfig(1);     
1032                }                       
1033        }
1034
1035        if(getconfigint("autoscan", NULL) == 1)
1036        {
1037                status.updatevfd = PAUSE;
1038                resettvpic();
1039                screentunerconfig();
1040                resettvpic();
1041                screenscanconfig(1);
1042                resettvpic();
1043                writevfd("");
1044                status.updatevfd = START;
1045                drawscreen(skin, 0, 0);
1046                addconfig("autoscan", "0");
1047        }
1048               
1049        //first wizzard
1050        if(getconfigint("nofirstwizzard", NULL) < 2)
1051        {
1052                if(file_exist("/var/etc/.scart"))
1053                {
1054                        setvideomode("pal", 0);
1055                        changefbresolution("pal", 0);
1056                }
1057
1058                autoresolution();
1059                       
1060                if(getconfigint("nofirstwizzard", NULL) == 0)
1061                {
1062firstwizzardstep1:
1063
1064                        status.updatevfd = PAUSE;
1065//                      screenavsettings(1);
1066//                      resettvpic();
1067                        //this screen can reload the skin (on language change)
1068                        //all skin changes before here than are deleted
1069//                      if(screenlanguage(2) == 2) return 100;
1070//                      resettvpic();
1071
1072                        screentunerconfig();
1073                        resettvpic();
1074                        screenscanconfig(1);
1075                        resettvpic();
1076//                      screennetwork_adapter();
1077//                      resettvpic();
1078                        writevfd("Setting OK ?");
1079                        if(textbox(_("First Wizzard"), _("Settings OK ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2)
1080                        {
1081                                goto firstwizzardstep1;
1082                        }
1083                }
1084                resettvpic();
1085
1086                char* msg = NULL;
1087                msg = readfiletomem("/etc/imageinfo", 0);
1088                textbox(_("Info"), _(msg), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 680, 30, 0);
1089                free(msg); msg = NULL;
1090               
1091                writevfd("");
1092                status.updatevfd = START;
1093                drawscreen(skin, 0, 0);
1094                addconfig("nofirstwizzard", "2");
1095        }
1096        else
1097        {
1098                // workaround, remove bootlogo on startup
1099                drawscreen(skin, 0, 0);
1100
1101                //check servicestart
1102                if(serviceret != 21) // no message if startchannel empty
1103                        servicecheckret(serviceret, 0);
1104        }
1105
1106// fixt manual start
1107        resettvpic();
1108
1109        //start auto shutdown thread
1110        addtimer(&checkshutdowntimer, START, 10000, -1, NULL, NULL, NULL);
1111        //start demo mode
1112        if(checkbox("WHITEBOX") == 1)
1113                addtimer(&demomodethread, START, 600000, -1, NULL, NULL, NULL);
1114
1115        status.lastrcaction = time(NULL);
1116        ret = loadplugin();
1117        setosdtransparent(getskinconfigint("osdtransparent", NULL));
1118        ret = setsaturation(getconfigint("vs_saturation", NULL));
1119        ret = setbrightness(getconfigint("vs_brightness", NULL));
1120        ret = setcontrast(getconfigint("vs_contrast", NULL));
1121        ret = settint(getconfigint("vs_tint", NULL));
1122        videoApplySettings();
1123       
1124#ifndef SIMULATE
1125        //set skinentrys locked
1126        if(status.security == 0)
1127                setskinnodeslocked(1);
1128        else
1129                setskinnodeslocked(0);
1130#endif
1131
1132        //start epg thread
1133        status.epgthread = addtimer(&epgthreadfunc, START, 1000, -1, NULL, NULL, NULL);
1134        //start record timer thread (on delay change you must change rectimer.h also)
1135        status.rectimerthread = addtimer(&checkrectimer, START, 1000, -1, NULL, NULL, NULL);
1136        //check if cam socket connected
1137        addtimer(&checkcam, START, 3000, -1, NULL, NULL, NULL);
1138        //start stream server
1139        tmpthread = addtimer(&streamthreadfunc, START, 10000, -1, NULL, NULL, NULL);
1140        if(tmpthread != NULL)
1141        {
1142                tmpthread->flag = setbit(tmpthread->flag, 0);
1143                tmpthread = NULL;
1144        }
1145        //start epg scanlist
1146        status.epgscanlistthread = addtimer(&epgscanlistthread, START, 1000, 1, NULL, NULL, NULL);
1147        //get pmt
1148        if(getconfigint("checkpmtalways", NULL) == 1)
1149                addtimer(&dvbgetpmtthread, START, 2000, -1, NULL, NULL, NULL);
1150        //check hdd
1151        status.addhddall = addtimer(&addhddall, START, 6000, -1, NULL, NULL, NULL);
1152        //check net
1153        addtimer(&addinetworkall, START, 15000, -1, NULL, NULL, NULL);
1154        //check kill net (security)
1155        addtimer(&ckeckkillnetthread, START, 1000, 1, NULL, NULL, NULL);
1156        //check old entrys and remove from mem
1157        addtimer(&oldentrythreadfunc, START, 60000 * 60, -1, NULL, NULL, NULL);
1158
1159        //start newsletter
1160        startnewsletter(1);
1161
1162        //thumb create thread
1163        startthumb(1);
1164
1165        //start webserver
1166        starthttpd(1);
1167       
1168        //start rguid
1169        startrguid(1);
1170
1171        //init the player
1172        playerinit(argc, argv);
1173       
1174        //start spinner thread
1175        addtimer(&checkspinner, START, 2000, -1, NULL, NULL, NULL);
1176
1177        system(getconfig("skriptaftertv", NULL));
1178
1179        // work
1180        resettvpic();
1181       
1182        char* cmd = NULL;
1183#ifdef SH4
1184        cmd = ostrcat("/media/hdd/movie/titankey.sh4", NULL, 0, 0);
1185#endif
1186
1187#ifdef MIPSEL
1188        cmd = ostrcat("/media/hdd/movie/titankey.mipsel", NULL, 0, 0);
1189#endif
1190
1191        //for atemio to unlock box with stick
1192        if(file_exist(cmd))
1193        {
1194                char* cpuid = getcpuid();
1195                cmd = ostrcat(cmd, " ", 1, 0);
1196                cmd = ostrcat(cmd, cpuid, 1, 0);
1197
1198                system(cmd);
1199                checkserial(cpuid);
1200                free(cmd); cmd = NULL;
1201
1202                if(status.security >= 1)
1203                {
1204                        char* mac = getmacfromcmdline();
1205                        if(mac != NULL)
1206                        {
1207                                cmd = ostrcat(cmd, cpuid, 1, 0);
1208                                cmd = ostrcat(cmd, ",", 1, 0);
1209                                cmd = ostrcat(cmd, mac, 1, 0);
1210                               
1211                                free(mac); mac = NULL;
1212                        }
1213                        else
1214                                cmd = ostrcat(cmd, cpuid, 1, 0);
1215
1216                        writesys("/media/hdd/movie/codelist.txt", cmd, 3);
1217                        textbox(_("Message"), _("Receiver successful unlocked"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1218                }
1219
1220                free(cpuid); cpuid = NULL;
1221        }
1222        free(cmd); cmd = NULL;
1223
1224        //must called direct befor screeninfobar
1225        if(getconfigint("saverun", NULL) == 1)
1226        {
1227                ret = sigsetjmp(status.longjumpbuf, 1);
1228                if(ret != 0 && ret != 999)
1229                {
1230                        err("set sigsegjump");
1231                }
1232        }
1233
1234        if(checkbox("UFS910") == 0 && checkbox("UFS922") == 0)
1235        {
1236                //check free space in /var
1237                if(getfreespace("/var") / 1024 < 50) //200kb
1238                        textbox(_("Message"), _("Free space in /var to little!\nThis can make problems!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 7, 0);
1239                else
1240                {
1241                        //check writeable in /var
1242                        if(mkdir("/var/writetest", 0777) != 0 && errno != EEXIST)
1243                        {
1244                                if(textbox(_("Message"), _("/var not writeable!\nRepair it?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 15, 0) == 1)
1245                                {
1246                                        system("repairjffs2.sh var &"); //this script kills titan an reboot
1247                                        sleep(10);
1248                                }
1249                        }
1250                        rmdir("/var/writetest");
1251                }
1252       
1253                //check free space in /mnt
1254                if(getfreespace("/mnt") / 1024 < 50) //200kb
1255                        textbox(_("Message"), _("Free space in /mnt to little!\nThis can make problems!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 7, 0);
1256                else
1257                {
1258                        //check writeable in /mnt
1259                        if(mkdir("/mnt/writetest", 0777) != 0 && errno != EEXIST)
1260                        {
1261                                if(textbox(_("Message"), _("/mnt not writeable!\nRepair it?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 15, 0) == 1)
1262                                {
1263                                        if(file_exist("/mnt/swapextensions/epg.dat"))
1264                                        {
1265                                                unlink("/mnt/swapextensions/epg.dat");
1266                                                system("sync");
1267                                                oshutdown(3, 0);
1268                                        }
1269                                        else
1270                                        {
1271                                                system("repairjffs2.sh mnt &"); //this script kills titan an reboot
1272                                                sleep(10);
1273                                        }
1274                                }
1275                        }
1276                        rmdir("/mnt/writetest");
1277                }
1278        }
1279
1280        addtimer(&guestthread, START, 1000, 1, NULL, NULL, NULL);
1281        startinternreader(1);
1282       
1283        screeninfobar();
1284
1285        //for testign screens
1286        //screenmanualscan();
1287        //screeninputhelp();
1288        //screendownload("test", "www.orf.at", NULL, 80, "test.html", 0);
1289        //screenrectimer();
1290        //screenepgsettings();
1291        //screenlnb("1");
1292        //screendiseqc("1");
1293        //screenlanguage();
1294        //screenvideosettings();
1295        //screenskinselect();
1296        //screenrectimer();
1297        //screennetwork_adapter(2);
1298        //screenpin();
1299        //screenchannellist();
1300        //recordstart(channel, RECDIRECT);
1301        //mc_main();
1302        //screenmc_videoplayer();
1303        //screenserviceinfo();
1304        //screentunerconfig();
1305        //screenvfdisplay();
1306        //screenavsettings(1);
1307        //screenadjust();
1308        //subtitlestart();
1309
1310        if(mmapfb != NULL) {
1311                free(mmapfb); mmapfb=NULL;
1312        }
1313        oshutdown(1, 1);
1314        return 0;
1315
1316starterror:
1317        addscreen("<screen hspace=5 vspace=5 type=textbox name=starterror posx=center posy=center bordersize=2 bordercol=#ffffff fontsize=30 fontcol=#ffffff width=600 height=150/>", 0, 0);
1318        struct skin *starterror = getscreen("starterror");
1319        if(tmpstr == NULL)
1320                tmpstr = ostrcat(tmpstr, _("Unknown Error."), 1, 0);
1321        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
1322        tmpstr = ostrcat(tmpstr, _("Automatic stop in 10 seconds."), 1, 0);
1323        changetext(starterror, _(tmpstr));
1324        drawscreen(starterror, 0, 0);
1325        sleep(10);
1326        printf("error: starterror=%s\n", tmpstr);
1327        free(tmpstr);
1328        return 100;
1329}
Note: See TracBrowser for help on using the repository browser.