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);
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 int val = FP_EVENT_VCR_SB_CHANGED; // ask only for this event
57 if (ioctl(m_fp_fd, FP_IOCTL_GET_EVENT, &val) < 0)
58 eDebug("FP_IOCTL_GET_EVENT failed (%m)");
59 else if (val & FP_EVENT_VCR_SB_CHANGED)
60 /* emit */ vcr_sb_notifier(getVCRSlowBlanking());
63 eAVSwitch::~eAVSwitch()
67 eAVSwitch *eAVSwitch::getInstance()
72 void eAVSwitch::setInput(int val)
80 char *input[] = {"encoder", "scart", "aux"};
84 if((fd = open("/proc/stb/avs/0/input", O_WRONLY)) < 0) {
85 printf("cannot open /proc/stb/avs/0/input\n");
89 write(fd, input[val], strlen(input[val]));
96 void eAVSwitch::setFastBlank(int val)
99 char *fb[] = {"low", "high", "vcr"};
101 if((fd = open("/proc/stb/avs/0/fb", O_WRONLY)) < 0) {
102 printf("cannot open /proc/stb/avs/0/fb\n");
106 write(fd, fb[val], strlen(fb[0]));
110 void eAVSwitch::setColorFormat(int format)
119 char *svideo="svideo";
123 if((fd = open("/proc/stb/avs/0/colorformat", O_WRONLY)) < 0) {
124 printf("cannot open /proc/stb/avs/0/colorformat\n");
129 write(fd, cvbs, strlen(cvbs));
132 write(fd, rgb, strlen(rgb));
135 write(fd, svideo, strlen(svideo));
138 write(fd, yuv, strlen(yuv));
144 void eAVSwitch::setAspectRatio(int ratio)
150 3-16:9 forced ("panscan")
153 6-16:9 forced ("letterbox")
155 char *aspect[] = {"4:3", "4:3", "any", "16:9", "16:10", "16:10", "16:9", "16:9"};
156 char *policy[] = {"letterbox", "panscan", "bestfit", "panscan", "letterbox", "panscan", "letterbox"};
159 if((fd = open("/proc/stb/video/aspect", O_WRONLY)) < 0) {
160 printf("cannot open /proc/stb/video/aspect\n");
163 // eDebug("set aspect to %s", aspect[ratio]);
164 write(fd, aspect[ratio], strlen(aspect[ratio]));
167 if((fd = open("/proc/stb/video/policy", O_WRONLY)) < 0) {
168 printf("cannot open /proc/stb/video/policy\n");
171 // eDebug("set ratio to %s", policy[ratio]);
172 write(fd, policy[ratio], strlen(policy[ratio]));
177 void eAVSwitch::setVideomode(int mode)
182 if (mode == m_video_mode)
187 if((fd = open("/proc/stb/video/videomode", O_WRONLY)) < 0) {
188 printf("cannot open /proc/stb/video/videomode\n");
193 write(fd, pal, strlen(pal));
196 write(fd, ntsc, strlen(ntsc));
204 void eAVSwitch::setWSS(int val) // 0 = auto, 1 = auto(4:3_off)
207 if((fd = open("/proc/stb/denc/0/wss", O_WRONLY)) < 0) {
208 printf("cannot open /proc/stb/denc/0/wss\n");
212 "off", "auto", "auto(4:3_off)", "4:3_full_format", "16:9_full_format",
213 "14:9_letterbox_center", "14:9_letterbox_top", "16:9_letterbox_center",
214 "16:9_letterbox_top", ">16:9_letterbox_center", "14:9_full_format"
216 write(fd, wss[val], strlen(wss[val]));
217 // eDebug("set wss to %s", wss[val]);
221 void eAVSwitch::setSlowblank(int val)
224 if((fd = open("/proc/stb/avs/0/sb", O_WRONLY)) < 0) {
225 printf("cannot open /proc/stb/avs/0/sb\n");
228 char *sb[] = {"0", "6", "12", "vcr", "auto"};
229 write(fd, sb[val], strlen(sb[val]));
230 // eDebug("set slow blanking to %s", sb[val]);
234 //FIXME: correct "run/startlevel"
235 eAutoInitP0<eAVSwitch> init_avswitch(eAutoInitNumbers::rc, "AVSwitch Driver");