1 from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, \
2 ConfigEnableDisable, ConfigSubsection, ConfigBoolean, ConfigSelectionNumber, ConfigNothing, NoSave
3 from enigma import eAVSwitch, getDesktop
4 from SystemInfo import SystemInfo
5 from os import path as os_path
6 from os import access, W_OK
9 def setInput(self, input):
10 INPUT = { "ENCODER": 0, "SCART": 1, "AUX": 2 }
11 eAVSwitch.getInstance().setInput(INPUT[input])
13 def setColorFormat(self, value):
14 eAVSwitch.getInstance().setColorFormat(value)
16 def setAspectRatio(self, value):
17 eAVSwitch.getInstance().setAspectRatio(value)
19 def setSystem(self, value):
20 eAVSwitch.getInstance().setVideomode(value)
22 def getOutputAspect(self):
23 valstr = config.av.aspectratio.value
24 if valstr in ("4_3_letterbox", "4_3_panscan"): # 4:3
26 elif valstr == "16_9": # auto ... 4:3 or 16:9
28 aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read()
29 if aspect_str == "1": # 4:3
33 elif valstr in ("16_9_always", "16_9_letterbox"): # 16:9
35 elif valstr in ("16_10_letterbox", "16_10_panscan"): # 16:10
39 def getFramebufferScale(self):
40 aspect = self.getOutputAspect()
41 fb_size = getDesktop(0).size()
42 return (aspect[0] * fb_size.height(), aspect[1] * fb_size.width())
44 def getAspectRatioSetting(self):
45 valstr = config.av.aspectratio.value
46 if valstr == "4_3_letterbox":
48 elif valstr == "4_3_panscan":
50 elif valstr == "16_9":
52 elif valstr == "16_9_always":
54 elif valstr == "16_10_letterbox":
56 elif valstr == "16_10_panscan":
58 elif valstr == "16_9_letterbox":
62 def setAspectWSS(self, aspect=None):
63 if not config.av.wss.value:
64 value = 2 # auto(4:3_off)
67 eAVSwitch.getInstance().setWSS(value)
70 config.av = ConfigSubsection()
71 config.av.yuvenabled = ConfigBoolean(default=False)
72 colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
74 # when YUV is not enabled, don't let the user select it
75 if config.av.yuvenabled.value:
76 colorformat_choices["yuv"] = _("YPbPr")
78 config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="cvbs")
79 config.av.aspectratio = ConfigSelection(choices={
80 "4_3_letterbox": _("4:3 Letterbox"),
81 "4_3_panscan": _("4:3 PanScan"),
83 "16_9_always": _("16:9 always"),
84 "16_10_letterbox": _("16:10 Letterbox"),
85 "16_10_panscan": _("16:10 PanScan"),
86 "16_9_letterbox": _("16:9 Letterbox")},
87 default = "4_3_letterbox")
89 config.av.aspect = ConfigSelection(choices={
93 "auto": _("Automatic")},
95 config.av.policy_169 = ConfigSelection(choices={
96 # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
97 "letterbox": _("Letterbox"),
98 # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
99 "panscan": _("Pan&Scan"),
100 # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
101 "scale": _("Just Scale")},
102 default = "letterbox")
103 config.av.policy_43 = ConfigSelection(choices={
104 # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
105 "pillarbox": _("Pillarbox"),
106 # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
107 "panscan": _("Pan&Scan"),
108 # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
109 "nonlinear": _("Nonlinear"),
110 # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
111 "scale": _("Just Scale")},
112 default = "pillarbox")
113 config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
114 config.av.wss = ConfigEnableDisable(default = True)
115 config.av.defaultac3 = ConfigYesNo(default = False)
116 config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 25, default = 0)
117 config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 25, default = 0)
118 config.av.vcrswitch = ConfigEnableDisable(default = False)
120 iAVSwitch = AVSwitch()
122 def setColorFormat(configElement):
123 map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
124 iAVSwitch.setColorFormat(map[configElement.value])
126 def setAspectRatio(configElement):
127 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}
128 iAVSwitch.setAspectRatio(map[configElement.value])
130 def setSystem(configElement):
131 map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
132 iAVSwitch.setSystem(map[configElement.value])
134 def setWSS(configElement):
135 iAVSwitch.setAspectWSS()
137 # this will call the "setup-val" initial
138 config.av.colorformat.addNotifier(setColorFormat)
139 config.av.aspectratio.addNotifier(setAspectRatio)
140 config.av.tvsystem.addNotifier(setSystem)
141 config.av.wss.addNotifier(setWSS)
143 iAVSwitch.setInput("ENCODER") # init on startup
144 SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()
147 can_pcm_multichannel = access("/proc/stb/audio/multichannel_pcm", W_OK)
149 can_pcm_multichannel = False
151 SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
153 if can_pcm_multichannel:
154 def setPCMMultichannel(configElement):
155 open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
156 config.av.pcm_multichannel = ConfigYesNo(default = False)
157 config.av.pcm_multichannel.addNotifier(setPCMMultichannel)
160 can_downmix = open("/proc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1
164 SystemInfo["CanDownmixAC3"] = can_downmix
166 def setAC3Downmix(configElement):
167 open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
168 if SystemInfo.get("supportPcmMultichannel", False) and (not configElement.value) :
169 SystemInfo["CanPcmMultichannel"] = True
171 SystemInfo["CanPcmMultichannel"] = False
173 config.av.downmix_ac3 = ConfigYesNo(default = True)
174 config.av.downmix_ac3.addNotifier(setAC3Downmix)
177 can_downmix_aac = open("/proc/stb/audio/aac_choices", "r").read()[:-1].find("downmix") != -1
179 can_downmix_aac = False
181 SystemInfo["CanDownmixAAC"] = can_downmix_aac
183 def setAACDownmix(configElement):
184 open("/proc/stb/audio/aac", "w").write(configElement.value and "downmix" or "passthrough")
185 config.av.downmix_aac = ConfigYesNo(default = True)
186 config.av.downmix_aac.addNotifier(setAACDownmix)
189 can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
191 can_osd_alpha = False
193 SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha
195 def setAlpha(config):
196 open("/proc/stb/video/alpha", "w").write(str(config.value))
199 config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255))
200 config.av.osd_alpha.addNotifier(setAlpha)
202 if os_path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
203 def setScaler_sharpness(config):
204 myval = int(config.value)
206 print "--> setting scaler_sharpness to: %0.8X" % myval
207 open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
208 open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
210 print "couldn't write pep_scaler_sharpness"
212 config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
213 config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
215 config.av.scaler_sharpness = NoSave(ConfigNothing())