1 #include <lib/driver/avswitch.h>
7 #include <lib/base/init.h>
8 #include <lib/base/init_num.h>
9 #include <lib/base/eerror.h>
11 eAVSwitch *eAVSwitch::instance = 0;
13 eAVSwitch::eAVSwitch()
20 eAVSwitch::~eAVSwitch()
24 eAVSwitch *eAVSwitch::getInstance()
29 void eAVSwitch::setInput(int val)
37 char *input[] = {"encoder", "scart", "aux"};
41 if((fd = open("/proc/stb/avs/0/input", O_WRONLY)) < 0) {
42 printf("cannot open /proc/stb/avs/0/input\n");
46 write(fd, input[val], strlen(input[val]));
53 void eAVSwitch::setFastBlank(int val)
56 char *fb[] = {"low", "high", "vcr"};
58 if((fd = open("/proc/stb/avs/0/fb", O_WRONLY)) < 0) {
59 printf("cannot open /proc/stb/avs/0/fb\n");
63 write(fd, fb[val], strlen(fb[0]));
67 void eAVSwitch::setColorFormat(int format)
76 char *svideo="svideo";
80 if((fd = open("/proc/stb/avs/0/colorformat", O_WRONLY)) < 0) {
81 printf("cannot open /proc/stb/avs/0/colorformat\n");
86 write(fd, cvbs, strlen(cvbs));
89 write(fd, rgb, strlen(rgb));
92 write(fd, svideo, strlen(svideo));
95 write(fd, yuv, strlen(yuv));
101 void eAVSwitch::setAspectRatio(int ratio)
110 char *aspect[] = {"4:3", "4:3", "any", "16:9"};
111 char *policy[] = {"letterbox", "panscan", "bestfit", "panscan"};
114 if((fd = open("/proc/stb/video/aspect", O_WRONLY)) < 0) {
115 printf("cannot open /proc/stb/video/aspect\n");
118 // eDebug("set aspect to %s", aspect[ratio]);
119 write(fd, aspect[ratio], strlen(aspect[ratio]));
122 if((fd = open("/proc/stb/video/policy", O_WRONLY)) < 0) {
123 printf("cannot open /proc/stb/video/policy\n");
126 // eDebug("set ratio to %s", policy[ratio]);
127 write(fd, policy[ratio], strlen(policy[ratio]));
132 void eAVSwitch::setVideomode(int mode)
137 if (mode == m_video_mode)
142 if((fd = open("/proc/stb/video/videomode", O_WRONLY)) < 0) {
143 printf("cannot open /proc/stb/video/videomode\n");
148 write(fd, pal, strlen(pal));
151 write(fd, ntsc, strlen(ntsc));
159 void eAVSwitch::setWSS(int val) // 0 = auto, 1 = auto(4:3_off)
162 if((fd = open("/proc/stb/denc/0/wss", O_WRONLY)) < 0) {
163 printf("cannot open /proc/stb/denc/0/wss\n");
167 "off", "auto", "auto(4:3_off)", "4:3_full_format", "16:9_full_format",
168 "14:9_letterbox_center", "14:9_letterbox_top", "16:9_letterbox_center",
169 "16:9_letterbox_top", ">16:9_letterbox_center", "14:9_full_format"
171 write(fd, wss[val], strlen(wss[val]));
172 // eDebug("set wss to %s", wss[val]);
176 void eAVSwitch::setSlowblank(int val)
179 if((fd = open("/proc/stb/avs/0/sb", O_WRONLY)) < 0) {
180 printf("cannot open /proc/stb/avs/0/sb\n");
183 char *sb[] = {"0", "6", "12", "vcr", "auto"};
184 write(fd, sb[val], strlen(sb[val]));
185 // eDebug("set slow blanking to %s", sb[val]);
189 //FIXME: correct "run/startlevel"
190 eAutoInitP0<eAVSwitch> init_avswitch(eAutoInitNumbers::rc, "AVSwitch Driver");