set wss according to av settings
[vuplus_dvbapp] / lib / python / Components / AVSwitch.py
1 from config import *
2 import os
3 from enigma import *
4
5 class AVSwitch:
6         INPUT = { "ENCODER": 0, "SCART": 1, "AUX": 2 }
7         def __init__(self):
8                 pass
9
10         def setColorFormat(self, value):
11                 eAVSwitch.getInstance().setColorFormat(value)
12                 
13         def setAspectRatio(self, value):
14                 eAVSwitch.getInstance().setAspectRatio(value)
15
16         def setSystem(self, value):
17                 eAVSwitch.getInstance().setVideomode(value)
18
19         def setWSS(self, value):
20                 if value == 0:
21                         writevalue = "off"
22                 elif value == 1:
23                         writevalue = "auto"
24                 elif value == 2:
25                         writevalue = "auto(4:3_off)"
26                 try:
27                         file = open("/proc/stb/denc/0/wss", "w")
28                         file.write(writevalue)
29                         file.close()
30                 except:
31                         print "[AVSwitch.py] Error writing to /proc/stb/denc/0/wss"
32         
33         def setInput(self, input):
34                 eAVSwitch.getInstance().setInput(self.INPUT[input])
35                 # FIXME why do we have to reset the colorformat? bug in avs-driver?
36                 eAVSwitch.getInstance().setColorFormat(config.av.colorformat.value)
37
38 def InitAVSwitch():
39         config.av = ConfigSubsection();
40         config.av.colorformat = configElement("config.av.colorformat", configSelection, 1, (("cvbs", _("CVBS")), ("rgb", _("RGB")), ("svideo", _("S-Video")) ))
41         config.av.aspectratio = configElement("config.av.aspectratio", configSelection, 0, (("4_3_letterbox", _("4:3 Letterbox")), ("4_3_panscan", _("4:3 PanScan")), ("16_9", _("16:9")), ("16_9_always", _("16:9 always"))) )
42         #config.av.tvsystem = configElement("config.av.tvsystem", configSelection, 0, ("PAL", "PAL + PAL60", "Multi", "NTSC") )
43         config.av.tvsystem = configElement("config.av.tvsystem", configSelection, 0, (("pal", _("PAL")), ("ntsc", _("NTSC"))) )
44         config.av.wss = configElement("config.av.wss", configSelection, 0, (("off", _("Off")), ("auto", _("Auto")), ("auto_no4_3", _("Auto (disable on 4:3)"))) )
45         config.av.defaultac3 = configElement("config.av.defaultac3", configSelection, 1, (("enable", _("Enable")), ("disable", _("Disable"))))
46         config.av.vcrswitch = configElement("config.av.vcrswitch", configSelection, 1, (("enable", _("Enable")), ("disable", _("Disable"))))
47
48         iAVSwitch = AVSwitch()
49
50         def setColorFormat(configElement):
51                 iAVSwitch.setColorFormat(configElement.value);
52         def setAspectRatio(configElement):
53                 iAVSwitch.setAspectRatio(configElement.value);
54         def setSystem(configElement):
55                 iAVSwitch.setSystem(configElement.value);
56         def setWSS(configElement):
57                 iAVSwitch.setWSS(configElement.value);
58
59         # this will call the "setup-val" initial
60         config.av.colorformat.addNotifier(setColorFormat);
61         config.av.aspectratio.addNotifier(setAspectRatio);
62         config.av.tvsystem.addNotifier(setSystem);
63         config.av.wss.addNotifier(setWSS);
64         
65         iAVSwitch.setInput("ENCODER") # init on startup