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 printf("cannot open /proc/stb/avs/0/input\n");
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 printf("cannot open /proc/stb/avs/0/fb\n");
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 printf("cannot open /proc/stb/video/aspect\n");
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 printf("cannot open /proc/stb/video/policy\n");
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 if((fd = open("/proc/stb/video/videomode", O_WRONLY)) < 0) {
200 printf("cannot open /proc/stb/video/videomode\n");
205 write(fd, pal, strlen(pal));
208 write(fd, ntsc, strlen(ntsc));
216 void eAVSwitch::setWSS(int val) // 0 = auto, 1 = auto(4:3_off)
219 if((fd = open("/proc/stb/denc/0/wss", O_WRONLY)) < 0) {
220 printf("cannot open /proc/stb/denc/0/wss\n");
224 "off", "auto", "auto(4:3_off)", "4:3_full_format", "16:9_full_format",
225 "14:9_letterbox_center", "14:9_letterbox_top", "16:9_letterbox_center",
226 "16:9_letterbox_top", ">16:9_letterbox_center", "14:9_full_format"
228 write(fd, wss[val], strlen(wss[val]));
229 // eDebug("set wss to %s", wss[val]);
233 void eAVSwitch::setSlowblank(int val)
236 if((fd = open("/proc/stb/avs/0/sb", O_WRONLY)) < 0) {
237 printf("cannot open /proc/stb/avs/0/sb\n");
240 char *sb[] = {"0", "6", "12", "vcr", "auto"};
241 write(fd, sb[val], strlen(sb[val]));
242 // eDebug("set slow blanking to %s", sb[val]);
246 //FIXME: correct "run/startlevel"
247 eAutoInitP0<eAVSwitch> init_avswitch(eAutoInitNumbers::rc, "AVSwitch Driver");