source: titan/titan/titan.c @ 44506

Last change on this file since 44506 was 44506, checked in by gost, 3 years ago

fix atemio function

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