source: titan/titan/titan.c @ 26535

Last change on this file since 26535 was 26535, checked in by gost, 10 years ago

fix vusolo FB... I hope

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