1 from config import config, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean
2 from enigma import eAVSwitch
5 INPUT = { "ENCODER": (0, 4), "SCART": (1, 3), "AUX": (2, 4) }
7 def setInput(self, input):
8 eAVSwitch.getInstance().setInput(self.INPUT[input][0])
9 if self.INPUT[input][1] == 4:
10 aspect = self.getAspectRatioSetting()
11 self.setAspectWSS(aspect)
12 self.setAspectSlowBlank(aspect)
14 eAVSwitch.getInstance().setSlowblank(self.INPUT[input][1])
15 # FIXME why do we have to reset the colorformat? bug in avs-driver?
16 map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
17 eAVSwitch.getInstance().setColorFormat(map[config.av.colorformat.value])
19 def setColorFormat(self, value):
20 eAVSwitch.getInstance().setColorFormat(value)
22 def setAspectRatio(self, value):
23 eAVSwitch.getInstance().setAspectRatio(value)
24 self.setAspectWSS(value)
25 self.setAspectSlowBlank(value)
27 def setSystem(self, value):
28 eAVSwitch.getInstance().setVideomode(value)
30 def getAspectRatioSetting(self):
31 valstr = config.av.aspectratio.value
32 if valstr == "4_3_letterbox":
34 elif valstr == "4_3_panscan":
36 elif valstr == "16_9":
38 elif valstr == "16_9_always":
40 elif valstr == "16_10_letterbox":
42 elif valstr == "16_10_panscan":
44 elif valstr == "16_9_letterbox":
48 def setAspectWSS(self, aspect=None):
50 aspect = self.getAspectRatioSetting()
51 if aspect == 0 or aspect == 1: # letterbox or panscan
52 value = 3 # 4:3_full_format
53 elif aspect == 2: # 16:9
54 if not config.av.wss.value:
55 value = 2 # auto(4:3_off)
58 elif aspect == 3 or aspect == 6: # always 16:9
59 value = 4 # 16:9_full_format
60 elif aspect == 4 or aspect == 5: # 16:10
61 value = 10 # 14:9_full_format
62 eAVSwitch.getInstance().setWSS(value)
64 def setAspectSlowBlank(self, aspect=None):
66 aspect = self.getAspectRatioSetting()
67 if aspect == 0 or aspect == 1: # letterbox or panscan
69 elif aspect == 2: # 16:9
71 elif aspect == 3 or aspect == 4 or aspect == 5 or aspect == 6: # always 16:9
73 eAVSwitch.getInstance().setSlowblank(value)
76 config.av = ConfigSubsection()
77 config.av.yuvenabled = ConfigBoolean(default=False)
78 colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
80 # when YUV is not enabled, don't let the user select it
81 if config.av.yuvenabled.value:
82 colorformat_choices["yuv"] = _("YPbPr")
84 config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
85 config.av.aspectratio = ConfigSelection(choices={
86 "4_3_letterbox": _("4:3 Letterbox"),
87 "4_3_panscan": _("4:3 PanScan"),
89 "16_9_always": _("16:9 always"),
90 "16_10_letterbox": _("16:10 Letterbox"),
91 "16_10_panscan": _("16:10 PanScan"),
92 "16_9_letterbox": _("16:9 Letterbox")},
93 default = "4_3_letterbox")
94 config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
95 config.av.wss = ConfigEnableDisable(default = True)
96 config.av.defaultac3 = ConfigYesNo(default = False)
97 config.av.vcrswitch = ConfigEnableDisable(default = False)
99 iAVSwitch = AVSwitch()
101 def setColorFormat(configElement):
102 map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
103 iAVSwitch.setColorFormat(map[configElement.value])
105 def setAspectRatio(configElement):
106 map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
107 iAVSwitch.setAspectRatio(map[configElement.value])
109 def setSystem(configElement):
110 map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
111 iAVSwitch.setSystem(map[configElement.value])
113 def setWSS(configElement):
114 iAVSwitch.setAspectWSS()
116 # this will call the "setup-val" initial
117 config.av.colorformat.addNotifier(setColorFormat)
118 config.av.aspectratio.addNotifier(setAspectRatio)
119 config.av.tvsystem.addNotifier(setSystem)
120 config.av.wss.addNotifier(setWSS)
122 iAVSwitch.setInput("ENCODER") # init on startup