remove manual fastblank
[enigma2.git] / lib / driver / avswitch.cpp
1 #include <lib/driver/avswitch.h>
2
3 #include <unistd.h>
4 #include <fcntl.h>
5 #include <sys/ioctl.h>
6
7 #include <lib/base/init.h>
8 #include <lib/base/init_num.h>
9 #include <lib/base/econfig.h>
10 #include <lib/base/eerror.h>
11
12 eAVSwitch *eAVSwitch::instance = 0;
13
14 eAVSwitch::eAVSwitch()
15 {
16         ASSERT(!instance);
17         instance = this;
18 }
19
20 eAVSwitch::~eAVSwitch()
21 {
22 }
23
24 eAVSwitch *eAVSwitch::getInstance()
25 {
26         return instance;
27 }
28
29 void eAVSwitch::setInput(int val)
30 {
31         /*
32         0-encoder
33         1-scart
34         2-aux
35         */
36
37         char *input[] = {"encoder", "scart", "aux"};
38
39         int fd;
40         
41         if((fd = open("/proc/stb/avs/0/input", O_WRONLY)) < 0) {
42                 printf("cannot open /proc/stb/avs/0/input\n");
43                 return;
44         }
45
46         write(fd, input[val], strlen(input[val]));
47         close(fd);
48 }
49
50 void eAVSwitch::setFastBlank(int val)
51 {
52         int fd;
53         char *fb[] = {"low", "high", "vcr"};
54
55         
56         if((fd = open("/proc/stb/avs/0/fb", O_WRONLY)) < 0) {
57                 printf("cannot open /proc/stb/avs/0/fb\n");
58                 return;
59         }
60
61         write(fd, fb[val], strlen(fb[0]));
62         close(fd);
63 }
64
65 void eAVSwitch::setColorFormat(int format)
66 {
67         /*
68         0-CVBS
69         1-RGB
70         2-S-Video
71         */
72         char *cvbs="cvbs";
73         char *rgb="rgb";
74         char *svideo="svideo";
75         int fd;
76         
77         if((fd = open("/proc/stb/avs/0/colorformat", O_WRONLY)) < 0) {
78                 printf("cannot open /proc/stb/avs/0/colorformat\n");
79                 return;
80         }
81         switch(format) {
82                 case 0:
83                         write(fd, cvbs, strlen(cvbs));
84                         break;
85                 case 1:
86                         write(fd, rgb, strlen(rgb));
87                         break;
88                 case 2:
89                         write(fd, svideo, strlen(svideo));
90                         break;
91         }       
92         close(fd);
93 }
94
95 void eAVSwitch::setAspectRatio(int ratio)
96 {
97         /*
98         0-4:3 Letterbox
99         1-4:3 PanScan
100         2-16:9
101         3-16:9 forced
102         */
103         
104         char *aspect[] = {"4:3", "4:3", "any", "16:9"};
105         char *policy[] = {"letterbox", "panscan", "bestfit", "panscan"};
106
107         int fd;
108         if((fd = open("/proc/stb/video/aspect", O_WRONLY)) < 0) {
109                 printf("cannot open /proc/stb/video/aspect\n");
110                 return;
111         }
112         write(fd, aspect[ratio], strlen(aspect[ratio]));
113         close(fd);
114
115         if((fd = open("/proc/stb/video/policy", O_WRONLY)) < 0) {
116                 printf("cannot open /proc/stb/video/policy\n");
117                 return;
118         }
119         write(fd, policy[ratio], strlen(policy[ratio]));
120         close(fd);
121
122 }
123
124 void eAVSwitch::setVideomode(int mode)
125 {
126         char *pal="pal";
127         char *ntsc="ntsc";
128         int fd;
129         
130         return;
131         //FIXME: bug in driver (cannot set PAL)
132         if((fd = open("/proc/stb/video/videomode", O_WRONLY)) < 0) {
133                 printf("cannot open /proc/stb/video/videomode\n");
134                 return;
135         }
136         switch(mode) {
137                 case 0:
138                         write(fd, pal, strlen(pal));
139                         break;
140                 case 1:
141                         write(fd, ntsc, strlen(ntsc));
142                         break;
143         }       
144         close(fd);
145 }
146
147 //FIXME: correct "run/startlevel"
148 eAutoInitP0<eAVSwitch> init_avswitch(eAutoInitNumbers::rc, "AVSwitch Driver");