source: titan/titan/titan.c @ 39756

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

[titan] fix videosettings

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