1 from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean
2 from enigma import eAVSwitch
3 from SystemInfo import SystemInfo
6 INPUT = { "ENCODER": (0, 4), "SCART": (1, 3), "AUX": (2, 4) }
8 def setInput(self, input):
9 eAVSwitch.getInstance().setInput(self.INPUT[input][0])
10 if self.INPUT[input][1] == 4:
11 aspect = self.getAspectRatioSetting()
12 self.setAspectWSS(aspect)
13 self.setAspectSlowBlank(aspect)
15 eAVSwitch.getInstance().setSlowblank(self.INPUT[input][1])
16 # FIXME why do we have to reset the colorformat? bug in avs-driver?
17 map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
18 eAVSwitch.getInstance().setColorFormat(map[config.av.colorformat.value])
20 def setColorFormat(self, value):
21 eAVSwitch.getInstance().setColorFormat(value)
23 def setAspectRatio(self, value):
24 eAVSwitch.getInstance().setAspectRatio(value)
25 self.setAspectWSS(value)
26 self.setAspectSlowBlank(value)
28 def setSystem(self, value):
29 eAVSwitch.getInstance().setVideomode(value)
31 def getAspectRatioSetting(self):
32 valstr = config.av.aspectratio.value
33 if valstr == "4_3_letterbox":
35 elif valstr == "4_3_panscan":
37 elif valstr == "16_9":
39 elif valstr == "16_9_always":
41 elif valstr == "16_10_letterbox":
43 elif valstr == "16_10_panscan":
45 elif valstr == "16_9_letterbox":
49 def setAspectWSS(self, aspect=None):
51 aspect = self.getAspectRatioSetting()
52 if aspect == 0 or aspect == 1: # letterbox or panscan
53 if not config.av.wss.value:
56 value = 3 # 4:3_full_format
57 elif aspect == 2: # 16:9
58 if not config.av.wss.value:
59 value = 2 # auto(4:3_off)
62 elif aspect == 3 or aspect == 6: # always 16:9
63 value = 4 # 16:9_full_format
64 elif aspect == 4 or aspect == 5: # 16:10
65 value = 10 # 14:9_full_format
66 eAVSwitch.getInstance().setWSS(value)
68 def setAspectSlowBlank(self, aspect=None):
70 aspect = self.getAspectRatioSetting()
71 if aspect == 0 or aspect == 1: # letterbox or panscan
73 elif aspect == 2: # 16:9
75 elif aspect == 3 or aspect == 4 or aspect == 5 or aspect == 6: # always 16:9
77 eAVSwitch.getInstance().setSlowblank(value)
80 config.av = ConfigSubsection()
81 config.av.yuvenabled = ConfigBoolean(default=False)
82 colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
84 # when YUV is not enabled, don't let the user select it
85 if config.av.yuvenabled.value:
86 colorformat_choices["yuv"] = _("YPbPr")
88 config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
89 config.av.aspectratio = ConfigSelection(choices={
90 "4_3_letterbox": _("4:3 Letterbox"),
91 "4_3_panscan": _("4:3 PanScan"),
93 "16_9_always": _("16:9 always"),
94 "16_10_letterbox": _("16:10 Letterbox"),
95 "16_10_panscan": _("16:10 PanScan"),
96 "16_9_letterbox": _("16:9 Letterbox")},
97 default = "4_3_letterbox")
99 config.av.aspect = ConfigSelection(choices={
103 "auto": _("Automatic")},
105 config.av.policy_169 = ConfigSelection(choices={
106 # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
107 "letterbox": _("Letterbox"),
108 # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
109 "panscan": _("Pan&Scan"),
110 # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
111 "scale": _("Just Scale")},
112 default = "letterbox")
113 config.av.policy_43 = ConfigSelection(choices={
114 # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
115 "pillarbox": _("Pillarbox"),
116 # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
117 "panscan": _("Pan&Scan"),
118 # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
119 "nonlinear": _("Nonlinear"),
120 # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
121 "scale": _("Just Scale")},
122 default = "pillarbox")
123 config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
124 config.av.wss = ConfigEnableDisable(default = True)
125 config.av.defaultac3 = ConfigYesNo(default = False)
126 config.av.vcrswitch = ConfigEnableDisable(default = False)
128 iAVSwitch = AVSwitch()
130 def setColorFormat(configElement):
131 map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
132 iAVSwitch.setColorFormat(map[configElement.value])
134 def setAspectRatio(configElement):
135 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}
136 iAVSwitch.setAspectRatio(map[configElement.value])
138 def setSystem(configElement):
139 map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
140 iAVSwitch.setSystem(map[configElement.value])
142 def setWSS(configElement):
143 iAVSwitch.setAspectWSS()
145 # this will call the "setup-val" initial
146 config.av.colorformat.addNotifier(setColorFormat)
147 config.av.aspectratio.addNotifier(setAspectRatio)
148 config.av.tvsystem.addNotifier(setSystem)
149 config.av.wss.addNotifier(setWSS)
151 iAVSwitch.setInput("ENCODER") # init on startup
152 SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()
155 can_downmix = open("/proc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1
159 SystemInfo["CanDownmixAC3"] = can_downmix
161 def setAC3Downmix(configElement):
162 open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
163 config.av.downmix_ac3 = ConfigYesNo(default = True)
164 config.av.downmix_ac3.addNotifier(setAC3Downmix)
167 can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
169 can_osd_alpha = False
171 SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha
173 def setAlpha(config):
174 open("/proc/stb/video/alpha", "w").write(str(config.value))
177 config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255))
178 config.av.osd_alpha.addNotifier(setAlpha)