source: titan/titan/titan.c @ 30133

Last change on this file since 30133 was 30133, checked in by obi, 10 years ago

[atemio6200] update titan stuff

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