5 #include <lib/base/init.h>
6 #include <lib/base/init_num.h>
7 #include <lib/base/eerror.h>
8 #include <lib/base/ebase.h>
9 #include <lib/driver/avswitch.h>
11 eAVSwitch *eAVSwitch::instance = 0;
13 eAVSwitch::eAVSwitch()
18 m_fp_fd = open("/dev/dbox/fp0", O_RDONLY|O_NONBLOCK);
21 eDebug("couldnt open /dev/dbox/fp0 to monitor vcr scart slow blanking changed!");
26 m_fp_notifier = new eSocketNotifier(eApp, m_fp_fd, eSocketNotifier::Read|POLLERR);
27 CONNECT(m_fp_notifier->activated, eAVSwitch::fp_event);
31 #ifndef FP_IOCTL_GET_EVENT
32 #define FP_IOCTL_GET_EVENT 20
35 #ifndef FP_IOCTL_GET_VCR
36 #define FP_IOCTL_GET_VCR 7
39 #ifndef FP_EVENT_VCR_SB_CHANGED
40 #define FP_EVENT_VCR_SB_CHANGED 1
43 int eAVSwitch::getVCRSlowBlanking()
48 if (ioctl(m_fp_fd, FP_IOCTL_GET_VCR, &val) < 0)
49 eDebug("FP_GET_VCR failed (%m)");
54 void eAVSwitch::fp_event(int what)
56 if (what & POLLERR) // driver not ready for fp polling
58 eDebug("fp driver not read for polling.. so disable polling");
59 m_fp_notifier->stop();
63 int val = FP_EVENT_VCR_SB_CHANGED; // ask only for this event
64 if (ioctl(m_fp_fd, FP_IOCTL_GET_EVENT, &val) < 0)
65 eDebug("FP_IOCTL_GET_EVENT failed (%m)");
66 else if (val & FP_EVENT_VCR_SB_CHANGED)
67 /* emit */ vcr_sb_notifier(getVCRSlowBlanking());
71 eAVSwitch::~eAVSwitch()
79 eAVSwitch *eAVSwitch::getInstance()
84 void eAVSwitch::setInput(int val)
92 char *input[] = {"encoder", "scart", "aux"};
96 if((fd = open("/proc/stb/avs/0/input", O_WRONLY)) < 0) {
97 eDebug("cannot open /proc/stb/avs/0/input");
101 write(fd, input[val], strlen(input[val]));
108 void eAVSwitch::setFastBlank(int val)
111 char *fb[] = {"low", "high", "vcr"};
113 if((fd = open("/proc/stb/avs/0/fb", O_WRONLY)) < 0) {
114 eDebug("cannot open /proc/stb/avs/0/fb");
118 write(fd, fb[val], strlen(fb[0]));
122 void eAVSwitch::setColorFormat(int format)
131 char *svideo="svideo";
135 if((fd = open("/proc/stb/avs/0/colorformat", O_WRONLY)) < 0) {
136 printf("cannot open /proc/stb/avs/0/colorformat\n");
141 write(fd, cvbs, strlen(cvbs));
144 write(fd, rgb, strlen(rgb));
147 write(fd, svideo, strlen(svideo));
150 write(fd, yuv, strlen(yuv));
156 void eAVSwitch::setAspectRatio(int ratio)
162 3-16:9 forced ("panscan")
165 6-16:9 forced ("letterbox")
167 char *aspect[] = {"4:3", "4:3", "any", "16:9", "16:10", "16:10", "16:9", "16:9"};
168 char *policy[] = {"letterbox", "panscan", "bestfit", "panscan", "letterbox", "panscan", "letterbox"};
171 if((fd = open("/proc/stb/video/aspect", O_WRONLY)) < 0) {
172 eDebug("cannot open /proc/stb/video/aspect");
175 // eDebug("set aspect to %s", aspect[ratio]);
176 write(fd, aspect[ratio], strlen(aspect[ratio]));
179 if((fd = open("/proc/stb/video/policy", O_WRONLY)) < 0) {
180 eDebug("cannot open /proc/stb/video/policy");
183 // eDebug("set ratio to %s", policy[ratio]);
184 write(fd, policy[ratio], strlen(policy[ratio]));
189 void eAVSwitch::setVideomode(int mode)
194 if (mode == m_video_mode)
199 int fd1 = open("/proc/stb/video/videomode_50hz", O_WRONLY);
201 eDebug("cannot open /proc/stb/video/videomode_50hz");
204 int fd2 = open("/proc/stb/video/videomode_60hz", O_WRONLY);
206 eDebug("cannot open /proc/stb/video/videomode_60hz");
210 write(fd1, pal, strlen(pal));
211 write(fd2, ntsc, strlen(ntsc));
217 int fd = open("/proc/stb/video/videomode", O_WRONLY);
219 eDebug("cannot open /proc/stb/video/videomode");
224 write(fd, pal, strlen(pal));
227 write(fd, ntsc, strlen(ntsc));
230 eDebug("unknown videomode %d", mode);
238 void eAVSwitch::setWSS(int val) // 0 = auto, 1 = auto(4:3_off)
241 if((fd = open("/proc/stb/denc/0/wss", O_WRONLY)) < 0) {
242 eDebug("cannot open /proc/stb/denc/0/wss");
246 "off", "auto", "auto(4:3_off)", "4:3_full_format", "16:9_full_format",
247 "14:9_letterbox_center", "14:9_letterbox_top", "16:9_letterbox_center",
248 "16:9_letterbox_top", ">16:9_letterbox_center", "14:9_full_format"
250 write(fd, wss[val], strlen(wss[val]));
251 // eDebug("set wss to %s", wss[val]);
255 void eAVSwitch::setSlowblank(int val)
258 if((fd = open("/proc/stb/avs/0/sb", O_WRONLY)) < 0) {
259 eDebug("cannot open /proc/stb/avs/0/sb");
262 char *sb[] = {"0", "6", "12", "vcr", "auto"};
263 write(fd, sb[val], strlen(sb[val]));
264 // eDebug("set slow blanking to %s", sb[val]);
268 //FIXME: correct "run/startlevel"
269 eAutoInitP0<eAVSwitch> init_avswitch(eAutoInitNumbers::rc, "AVSwitch Driver");