source: titan/titan/titan.c @ 39778

Last change on this file since 39778 was 39778, checked in by obi, 6 years ago

enable sec for arm

File size: 33.6 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#ifdef MIPSEL
629        ret = setaac(getconfig("av_aacmode", NULL));
630        ret = setwss(getconfig("av_wssmode", NULL));
631#endif
632        ret = setpolicy(getconfig("av_policy", NULL));
633        ret = setmode3d(getconfig("av_mode3d", NULL));
634        ret = setvfdbrightness(getconfigint("vfdbrightness", NULL));
635        ret = setaudiodelaybitstream(getconfig("audiodelaybitstream", NULL));
636        ret = addinetworkall(NULL);
637       
638        ret = 1;
639        if(file_exist("/var/etc/.usbimage"))
640                ret = system("mount | grep titan");
641 
642#ifndef SIMULATE
643        if(checkrealbox("DM900") == 1)
644                ret = 1;
645
646        // set pvr 1 = allowed , 0 = disabled
647        status.pvr = 1;
648        if(file_exist("/etc/.stable") && (checkbox("ATEMIO6000") == 1 || checkbox("ATEMIO6100") == 1 || checkbox("ATEMIO6200") == 1))
649                status.pvr = 0;
650
651        if(getconfigint("sos", NULL) == 0)
652        {
653                if(ostrcmp(string_newline(gettimeinfo()), TIMECODE) == 1)
654                {
655                        printf("error: 1\n");
656                        destroy();
657                        exit(100);
658                }
659                if(ostrcmp(string_newline(gettimeinfovar()), TIMECODE) == 1)
660                {
661                        printf("error: 2\n");           
662                        destroy();
663                        exit(100);
664                }
665                if(checkreseller() != 0)
666                {
667                        printf("error: 3\n");           
668                        destroy();
669                        exit(100);
670                }
671                if(ret > 0)
672                {
673                        if(getsysinfo() != SYSCODE)
674                        {
675                                printf("error: 4\n");           
676                                destroy();
677                                exit(100);
678                        }
679                }
680                if(file_exist("/mnt/swapextensions/etc/.vnumber") == 1)
681                {
682                        printf("error: 5\n");           
683                        destroy();
684                        exit(100);
685                }
686                if(ret > 0)
687                {
688                        if(checkflash() != 0)
689                        {
690                                printf("error: 6\n");           
691                                destroy();
692                                exit(100);
693                        }
694                }
695                if(ret > 0)
696                {
697                        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)
698                        {
699                                printf("error: 7\n");           
700                                destroy();
701                                exit(100);
702                        }
703                }
704                if(checkbox("UFS910") == 1 && checklowflash() != 0)
705                {
706                        printf("error: 8\n");           
707                        destroy();
708                        exit(100);
709                }
710       
711                char* cpuid = getcpuid();
712                checkserial(cpuid);
713                free(cpuid); cpuid = NULL;
714        }
715        else
716        {
717                status.security = 5;
718                startnet();
719                setskinnodeslocked(0);
720        }
721#endif
722
723        if(file_exist("/mnt/config/dualboot.enigma2"))
724        {
725                printf("error: found /mnt/config/dualboot.enigma2\n");
726                return 0;
727        }
728
729        ret = initfont();
730        if(ret != 0)
731        {
732                printf("error: initfont\n");
733                return 100;
734        }
735        ret = openfont(getconfig("fontfile1", NULL));
736        if(ret != 0)
737        {
738                err("open fontfile1 font");
739                printf("error: open fontfile1 font\n");
740                return 100;
741        }
742        openfont(getconfig("fontfile2", NULL));
743        openfont(getconfig("fontfile3", NULL));
744        openfont(getconfig("fontfile4", NULL));
745        openfont(getconfig("fontfile5", NULL));
746
747        //skin defined fonts
748        openfont(getskinconfig("fontfile1", NULL));
749        openfont(getskinconfig("fontfile2", NULL));
750        openfont(getskinconfig("fontfile3", NULL));
751        openfont(getskinconfig("fontfile4", NULL));
752        openfont(getskinconfig("fontfile5", NULL));
753
754
755        status.volume = -1;
756        setvol(getconfigint("vol", NULL));
757
758       
759        setlang(getconfig("lang", NULL));
760        initlocale(getconfig("localepath", NULL));
761
762#ifdef MIPSEL
763        bcm_accel_init();
764#endif
765
766        fb = openfb(getconfig("fbdev", NULL), 0);
767        if(fb == NULL)
768        {
769                printf("error: openfb %s\n", getconfig("fbdev", NULL));
770                return 100;
771        }
772        clearfball();
773        enablemanualblit();
774       
775        tmpstr = getconfig("fb1dev", NULL);
776        if(tmpstr != NULL)
777                fb1 = openfb(tmpstr, 1);
778        tmpstr = NULL;
779
780#ifdef MIPSEL
781        waitvsync();
782        if(checkbox("DM7020HD") == 0 && checkbox("DM7020HDV2") == 0 && checkbox("VUSOLO2") == 0 && checkbox("DM900") == 0)
783                setfbosd();
784        status.usedirectfb = 1;
785#endif
786
787        if(status.usedirectfb != 1)
788        {
789                skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize, 0);
790                if(skinfb != NULL)
791                {
792                        ret = getfbsize(0);
793                        if(ret > 0)
794                                accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize, 0);
795                }
796                else
797                {
798                        debug(100, "use directfb");
799                        status.usedirectfb = 1;
800                }
801        }
802        if(status.usedirectfb == 1)
803        {
804                skinfb = fb;
805#ifndef MIPSEL
806                ret = getfbsize(0);
807                if(ret > 0)
808                        accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize, fb->data_phys + fb->varfbsize);
809#else
810                ret = getfbsize(0);
811                if(ret > 0 && status.bcm == 1)
812                {
813                        skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize, fb->data_phys + fb->varfbsize);
814                        if(skinfb != NULL)
815                        {
816                                status.usedirectfb = 0;
817                                ret = getfbsize(0);
818                                if(ret > 0)
819                                        accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize, skinfb->data_phys + skinfb->varfbsize);
820                        }
821                }
822#endif
823        }
824
825        //if(lcdskinfb == NULL) {
826                //mmapfb = malloc(4 * 320 * 240);
827                //mmapfb = malloc(4 * 1024 * 768);
828                //mmapfb = NULL;
829                /* dev=999 ist LCD Buffer */
830                //lcdskinfb = addfb("lcdskinfb", 999, 320, 240, 4, -1, mmapfb, 4 * 320 * 240);
831                //lcdskinfb = addfb("lcdskinfb", 999, 1024, 768, 4, -1, mmapfb, 4 * 1024 * 768);
832                // mmapfb = NULL;
833        //}
834
835        ret = createstartscreen();
836        if(ret != 0)
837        {
838                printf("error: createstartscreen\n");
839                return 100;
840        }
841        //from here we can use starterror screen
842        ret = openrc();
843        if(ret != 0)
844        {
845                tmpstr = ostrcat(tmpstr, _("Error: open rc device !!"), 1, 0);
846                goto starterror;
847        }
848
849        if(fegetdev() < 1)
850        {
851                tmpstr = ostrcat(tmpstr, _("Error: no frontend device found !!"), 1, 0);
852                err("no frontend device found");
853                goto starterror;
854        }
855        if(dmxgetdev() < 1)
856        {
857                tmpstr = ostrcat(tmpstr, _("Error: no demux device found !!"), 1, 0);
858                err("no demux device found");
859                goto starterror;
860        }
861        if(videogetdev() < 1)
862        {
863                tmpstr = ostrcat(tmpstr, _("Error: no video device found !!"), 1, 0);
864                err("no video device found");
865                goto starterror;
866        }
867        if(audiogetdev() < 1)
868        {
869                tmpstr = ostrcat(tmpstr, _("Error: no audio device found !!"), 1, 0);
870                err("no audio device found");
871                goto starterror;
872        }
873        ret = fecreatedummy();
874        ret = cagetdev();
875        ret = cigetdev();
876        ret = dvrgetdev();
877        ret = scgetdev();
878#ifdef MIPSEL
879        if(checkchipset("BCM7424") == 1) //inihdp
880                ret = encodergetdev();
881#endif
882
883        settunerstatus();
884
885        //start ca slot watching threads
886        castart();
887
888        //check skin
889        if(skincheck > 0)
890        {
891
892                tmpstr = ostrcat(tmpstr, _("Error: skin not found !!"), 1, 0);
893                err("skin not found");
894                goto starterror;
895        }
896
897        ret = readsat(getconfig("satfile", NULL));
898        ret = readtransponder(getconfig("transponderfile", NULL));
899        ret = readprovider(getconfig("providerfile", NULL));
900        ret = readchannel(getconfig("channelfile", NULL));
901        ret = readtransponderencoding(getconfig("transponderencodingfile", NULL));
902        ret = readmostzap(getconfig("mostzapfile", NULL));
903        ret = readlastsubtitle(getconfig("lastsubtitle", NULL));
904        ret = readchannelslot(getconfig("channelslotfile", NULL));
905
906        status.aktservice = addservice(NULL);
907        status.lastservice = addservice(NULL);
908        status.pipservice = addservice(NULL);
909
910        //check if startchannel defined
911        char* startchannellist = getconfig("startchannellist", NULL);
912        int startserviceid = getconfigint("startserviceid", NULL);
913        uint64_t starttransponderid = getconfigllu("starttransponderid", NULL);
914        int startservicetype = getconfigint("startservicetype", NULL);
915        if(startchannellist != NULL && startserviceid != 0)
916        {
917                if(startservicetype == 0)
918                {
919                        addconfig("channellist", startchannellist);
920                        addconfigint("serviceid", startserviceid);
921                        addconfigllu("transponderid", starttransponderid);
922                }
923                else
924                {
925                        addconfig("rchannellist", startchannellist);
926                        addconfigint("rserviceid", startserviceid);
927                        addconfigllu("rtransponderid", starttransponderid);
928                }
929                addconfigint("servicetype", startservicetype);
930        }
931        setvol(getconfigint("vol", NULL));
932        //tune to channel
933        if(status.servicetype == 0)
934                serviceret = servicestart(getchannel(getconfigint("serviceid", NULL), getconfigllu("transponderid", NULL)), getconfig("channellist", NULL), NULL, 0);
935        else
936                serviceret = servicestart(getchannel(getconfigint("rserviceid", NULL), getconfigllu("rtransponderid", NULL)), getconfig("rchannellist", NULL),  NULL, 0);
937
938        if(checkbox("IPBOX9000") == 1 && !file_exist("/tmp/.opticum9600.workaround"))
939        {
940                printf("opticum.workaround start\n");
941                system("touch /tmp/.opticum9600.workaround");
942                oshutdown(3, 1);
943                printf("opticum.workaround end\n");
944        }
945
946        ret = readscreen(getconfig("skinfile", NULL), 0, 0);
947        if(getconfig("keyskin_file", NULL) == NULL)
948                ret = readscreen("/var/usr/local/share/titan/skin/default/keyskin.xml", 0, 0);
949        else
950                ret = readscreen(getconfig("keyskin_file", NULL), 0, 0);
951        if(checkchipset("BCM7424") == 1 || checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1 || checkbox("DM900") == 1)  //inihdp
952        {
953                if(getconfig("oledskin_path", NULL) == NULL)
954                        ret = readscreen("/var/usr/local/share/titan/skin/default/oledskin.xml", 0, 0);
955                else
956                {
957                        tmpstr = ostrcat(getconfig("oledskin_path", NULL),"/oledskin.xml", 0, 0);
958                        ret = readscreen(tmpstr, 0, 0);
959                        free(tmpstr);tmpstr=NULL;
960                }
961        }
962        ret = readmainbouquet(getconfig("bouquetfile", NULL));
963        ret = readallbouquet();
964        ret = readmainplaylist(getconfig("playlistfile", NULL));
965        ret = readallplaylist();
966        ret = readrcmap(getconfig("rcmapfile", NULL));
967        ret = readepgscanlist(getconfig("epgchannelfile", NULL));
968        ret = settimezone(getconfig("timezone", NULL));
969        ret = readextepgconfig(getconfig("extepgfile", NULL));
970
971        //check to remove preinstalled tpk packages
972        ret = tpkupdatepre();
973
974        addtimer(&checkdate, START, 2000, -1, NULL, NULL, NULL);
975        if(checkbox("ATEMIO510") == 0)
976                addtimer(&updatevfd, START, 1000, -1, NULL, NULL, NULL);
977
978        if(getconfigint("firststart", NULL) == 1)
979        {
980                if(file_exist("/var/etc/.scart"))
981                {
982                        setvideomode("pal", 0);
983                        changefbresolution("pal", 0);
984                        autoresolution();
985                }
986                addconfig("firststart", "0");
987        }
988
989        if(getconfig("remotecontrol", NULL) == NULL)
990        {
991                if(checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
992                {
993                        //autopo work
994                        char* tmptxt = NULL;
995                        tmptxt = ostrcat(tmptxt, _("RemoteControl Old Version"), 0, 0);
996                        tmptxt = ostrcat(tmptxt, _("RemoteControl Long Version"), 0, 0);
997                        free(tmptxt), tmptxt = NULL;
998
999                        struct menulist* mlist = NULL, *mbox = NULL;
1000                        addmenulist(&mlist, "RemoteControl Old Version", "0", NULL, 0, 0);
1001                        addmenulist(&mlist, "RemoteControl Long Version", "1", NULL, 0, 0);
1002                        // remotecontrol try menulist
1003                        mbox = menulistbox(mlist, "menulist", _("Select Your Remote Control"), _("Choose your Remotecontrol Model from the following list"), NULL, NULL, 3, 0);
1004                        if(mbox != NULL)
1005                        {
1006                                debug(10, "mbox->name %s", mbox->name);
1007                                debug(10, "mbox->text %s", mbox->text);
1008                                addconfig("remotecontrol", mbox->text);
1009                                writeallconfig(1);                             
1010                        }
1011                }
1012                if(checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1 || checkbox("DM900"))
1013                {
1014                        addconfig("remotecontrol", "0");
1015                        writeallconfig(1);     
1016                }                       
1017        }
1018
1019        if(getconfigint("autoscan", NULL) == 1)
1020        {
1021                status.updatevfd = PAUSE;
1022                resettvpic();
1023                screentunerconfig();
1024                resettvpic();
1025                screenscanconfig(1);
1026                resettvpic();
1027                writevfd("");
1028                status.updatevfd = START;
1029                drawscreen(skin, 0, 0);
1030                addconfig("autoscan", "0");
1031        }
1032               
1033        //first wizzard
1034        if(getconfigint("nofirstwizzard", NULL) < 2)
1035        {
1036                if(file_exist("/var/etc/.scart"))
1037                {
1038                        setvideomode("pal", 0);
1039                        changefbresolution("pal", 0);
1040                }
1041
1042                autoresolution();
1043                       
1044                if(getconfigint("nofirstwizzard", NULL) == 0)
1045                {
1046firstwizzardstep1:
1047
1048                        status.updatevfd = PAUSE;
1049//                      screenavsettings(1);
1050//                      resettvpic();
1051                        //this screen can reload the skin (on language change)
1052                        //all skin changes before here than are deleted
1053//                      if(screenlanguage(2) == 2) return 100;
1054//                      resettvpic();
1055
1056                        screentunerconfig();
1057                        resettvpic();
1058                        screenscanconfig(1);
1059                        resettvpic();
1060//                      screennetwork_adapter();
1061//                      resettvpic();
1062                        writevfd("Setting OK ?");
1063                        if(textbox(_("First Wizzard"), _("Settings OK ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2)
1064                        {
1065                                goto firstwizzardstep1;
1066                        }
1067                }
1068                resettvpic();
1069
1070                char* msg = NULL;
1071                msg = readfiletomem("/etc/imageinfo", 0);
1072                textbox(_("Info"), _(msg), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 680, 30, 0);
1073                free(msg); msg = NULL;
1074               
1075                writevfd("");
1076                status.updatevfd = START;
1077                drawscreen(skin, 0, 0);
1078                addconfig("nofirstwizzard", "2");
1079        }
1080        else
1081        {
1082                // workaround, remove bootlogo on startup
1083                drawscreen(skin, 0, 0);
1084
1085                //check servicestart
1086                if(serviceret != 21) // no message if startchannel empty
1087                        servicecheckret(serviceret, 0);
1088        }
1089
1090// fixt manual start
1091        resettvpic();
1092
1093        //start auto shutdown thread
1094        addtimer(&checkshutdowntimer, START, 10000, -1, NULL, NULL, NULL);
1095        //start demo mode
1096        if(checkbox("WHITEBOX") == 1)
1097                addtimer(&demomodethread, START, 600000, -1, NULL, NULL, NULL);
1098
1099        status.lastrcaction = time(NULL);
1100        ret = loadplugin();
1101        setosdtransparent(getskinconfigint("osdtransparent", NULL));
1102        ret = setsaturation(getconfigint("vs_saturation", NULL));
1103        ret = setbrightness(getconfigint("vs_brightness", NULL));
1104        ret = setcontrast(getconfigint("vs_contrast", NULL));
1105        ret = settint(getconfigint("vs_tint", NULL));
1106        videoApplySettings();
1107       
1108#ifndef SIMULATE
1109        //set skinentrys locked
1110        if(status.security == 0)
1111                setskinnodeslocked(1);
1112        else
1113                setskinnodeslocked(0);
1114#endif
1115
1116        //start epg thread
1117        status.epgthread = addtimer(&epgthreadfunc, START, 1000, -1, NULL, NULL, NULL);
1118        //start record timer thread (on delay change you must change rectimer.h also)
1119        status.rectimerthread = addtimer(&checkrectimer, START, 1000, -1, NULL, NULL, NULL);
1120        //check if cam socket connected
1121        addtimer(&checkcam, START, 3000, -1, NULL, NULL, NULL);
1122        //start stream server
1123        tmpthread = addtimer(&streamthreadfunc, START, 10000, -1, NULL, NULL, NULL);
1124        if(tmpthread != NULL)
1125        {
1126                tmpthread->flag = setbit(tmpthread->flag, 0);
1127                tmpthread = NULL;
1128        }
1129        //start epg scanlist
1130        status.epgscanlistthread = addtimer(&epgscanlistthread, START, 1000, 1, NULL, NULL, NULL);
1131        //get pmt
1132        if(getconfigint("checkpmtalways", NULL) == 1)
1133                addtimer(&dvbgetpmtthread, START, 2000, -1, NULL, NULL, NULL);
1134        //check hdd
1135        status.addhddall = addtimer(&addhddall, START, 6000, -1, NULL, NULL, NULL);
1136        //check net
1137        addtimer(&addinetworkall, START, 15000, -1, NULL, NULL, NULL);
1138        //check kill net (security)
1139        addtimer(&ckeckkillnetthread, START, 1000, 1, NULL, NULL, NULL);
1140        //check old entrys and remove from mem
1141        addtimer(&oldentrythreadfunc, START, 60000 * 60, -1, NULL, NULL, NULL);
1142
1143        //start newsletter
1144        startnewsletter(1);
1145
1146        //thumb create thread
1147        startthumb(1);
1148
1149        //start webserver
1150        starthttpd(1);
1151       
1152        //start rguid
1153        startrguid(1);
1154
1155        //init the player
1156        playerinit(argc, argv);
1157       
1158        //start spinner thread
1159        addtimer(&checkspinner, START, 2000, -1, NULL, NULL, NULL);
1160
1161        system(getconfig("skriptaftertv", NULL));
1162
1163        // work
1164        resettvpic();
1165       
1166        char* cmd = NULL;
1167#ifdef SH4
1168        cmd = ostrcat("/media/hdd/movie/titankey.sh4", NULL, 0, 0);
1169#endif
1170
1171#ifdef MIPSEL
1172        cmd = ostrcat("/media/hdd/movie/titankey.mipsel", NULL, 0, 0);
1173#endif
1174
1175        //for atemio to unlock box with stick
1176        if(file_exist(cmd))
1177        {
1178                char* cpuid = getcpuid();
1179                cmd = ostrcat(cmd, " ", 1, 0);
1180                cmd = ostrcat(cmd, cpuid, 1, 0);
1181
1182                system(cmd);
1183                checkserial(cpuid);
1184                free(cmd); cmd = NULL;
1185
1186                if(status.security >= 1)
1187                {
1188                        char* mac = getmacfromcmdline();
1189                        if(mac != NULL)
1190                        {
1191                                cmd = ostrcat(cmd, cpuid, 1, 0);
1192                                cmd = ostrcat(cmd, ",", 1, 0);
1193                                cmd = ostrcat(cmd, mac, 1, 0);
1194                               
1195                                free(mac); mac = NULL;
1196                        }
1197                        else
1198                                cmd = ostrcat(cmd, cpuid, 1, 0);
1199
1200                        writesys("/media/hdd/movie/codelist.txt", cmd, 3);
1201                        textbox(_("Message"), _("Receiver successful unlocked"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1202                }
1203
1204                free(cpuid); cpuid = NULL;
1205        }
1206        free(cmd); cmd = NULL;
1207
1208        //must called direct befor screeninfobar
1209        if(getconfigint("saverun", NULL) == 1)
1210        {
1211                ret = sigsetjmp(status.longjumpbuf, 1);
1212                if(ret != 0 && ret != 999)
1213                {
1214                        err("set sigsegjump");
1215                }
1216        }
1217
1218        if(checkbox("UFS910") == 0 && checkbox("UFS922") == 0)
1219        {
1220                //check free space in /var
1221                if(getfreespace("/var") / 1024 < 50) //200kb
1222                        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);
1223                else
1224                {
1225                        //check writeable in /var
1226                        if(mkdir("/var/writetest", 0777) != 0 && errno != EEXIST)
1227                        {
1228                                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)
1229                                {
1230                                        system("repairjffs2.sh var &"); //this script kills titan an reboot
1231                                        sleep(10);
1232                                }
1233                        }
1234                        rmdir("/var/writetest");
1235                }
1236       
1237                //check free space in /mnt
1238                if(getfreespace("/mnt") / 1024 < 50) //200kb
1239                        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);
1240                else
1241                {
1242                        //check writeable in /mnt
1243                        if(mkdir("/mnt/writetest", 0777) != 0 && errno != EEXIST)
1244                        {
1245                                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)
1246                                {
1247                                        if(file_exist("/mnt/swapextensions/epg.dat"))
1248                                        {
1249                                                unlink("/mnt/swapextensions/epg.dat");
1250                                                system("sync");
1251                                                oshutdown(3, 0);
1252                                        }
1253                                        else
1254                                        {
1255                                                system("repairjffs2.sh mnt &"); //this script kills titan an reboot
1256                                                sleep(10);
1257                                        }
1258                                }
1259                        }
1260                        rmdir("/mnt/writetest");
1261                }
1262        }
1263
1264        addtimer(&guestthread, START, 1000, 1, NULL, NULL, NULL);
1265        startinternreader(1);
1266       
1267        screeninfobar();
1268
1269        //for testign screens
1270        //screenmanualscan();
1271        //screeninputhelp();
1272        //screendownload("test", "www.orf.at", NULL, 80, "test.html", 0);
1273        //screenrectimer();
1274        //screenepgsettings();
1275        //screenlnb("1");
1276        //screendiseqc("1");
1277        //screenlanguage();
1278        //screenvideosettings();
1279        //screenskinselect();
1280        //screenrectimer();
1281        //screennetwork_adapter(2);
1282        //screenpin();
1283        //screenchannellist();
1284        //recordstart(channel, RECDIRECT);
1285        //mc_main();
1286        //screenmc_videoplayer();
1287        //screenserviceinfo();
1288        //screentunerconfig();
1289        //screenvfdisplay();
1290        //screenavsettings(1);
1291        //screenadjust();
1292        //subtitlestart();
1293
1294        if(mmapfb != NULL) {
1295                free(mmapfb); mmapfb=NULL;
1296        }
1297        oshutdown(1, 1);
1298        return 0;
1299
1300starterror:
1301        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);
1302        struct skin *starterror = getscreen("starterror");
1303        if(tmpstr == NULL)
1304                tmpstr = ostrcat(tmpstr, _("Unknown Error."), 1, 0);
1305        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
1306        tmpstr = ostrcat(tmpstr, _("Automatic stop in 10 seconds."), 1, 0);
1307        changetext(starterror, _(tmpstr));
1308        drawscreen(starterror, 0, 0);
1309        sleep(10);
1310        printf("error: starterror=%s\n", tmpstr);
1311        free(tmpstr);
1312        return 100;
1313}
Note: See TracBrowser for help on using the repository browser.