From: Felix Domke Date: Sun, 9 Mar 2008 16:30:17 +0000 (+0000) Subject: better aspect setting X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=2f2b96fef51a5b4bfeb599f9785ecb6315c1fd4d better aspect setting --- diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py index c712a60..044ea43 100644 --- a/lib/python/Components/AVSwitch.py +++ b/lib/python/Components/AVSwitch.py @@ -95,6 +95,31 @@ def InitAVSwitch(): "16_10_panscan": _("16:10 PanScan"), "16_9_letterbox": _("16:9 Letterbox")}, default = "4_3_letterbox") + + config.av.aspect = ConfigSelection(choices={ + "4_3": _("4:3"), + "16_9": _("16:9"), + "16_10": _("16:10"), + "auto": _("Automatic")}, + default = "auto") + config.av.policy_169 = ConfigSelection(choices={ + # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term. + "letterbox": _("Letterbox"), + # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term + "panscan": _("Pan&Scan"), + # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect) + "scale": _("Just Scale")}, + default = "letterbox") + config.av.policy_43 = ConfigSelection(choices={ + # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term. + "pillarbox": _("Pillarbox"), + # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term + "panscan": _("Pan&Scan"), + # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right) + "nonlinear": _("Nonlinear"), + # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect) + "scale": _("Just Scale")}, + default = "panscan") config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal") config.av.wss = ConfigEnableDisable(default = True) config.av.defaultac3 = ConfigYesNo(default = False) diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index f3e3c07..d73610a 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -53,6 +53,8 @@ class VideoHardware: modes["YPbPr"] = ["720p", "1080i"] modes["DVI"] = ["720p", "1080i", "PC"] + widescreen_modes = set(["720p", "1080i"]) + def __init__(self): self.last_modes_preferred = [ ] self.on_hotplug = CList() @@ -64,6 +66,10 @@ class VideoHardware: self.readPreferredModes() + config.av.aspect.addNotifier(self.updateAspect) + config.av.policy_169.addNotifier(self.updateAspect) + config.av.policy_43.addNotifier(self.updateAspect) + # until we have the hotplug poll socket # self.timer = eTimer() # self.timer.callback.append(self.readPreferredModes) @@ -104,6 +110,9 @@ class VideoHardware: return False return True + def isWidescreenMode(self, port, mode): + return mode in self.widescreen_modes + def setMode(self, port, mode, rate, force = None): print "setMode - port:", port, "mode:", mode, "rate:", rate # we can ignore "port" @@ -132,10 +141,7 @@ class VideoHardware: except IOError: print "writing initial videomode to /etc/videomode failed." - # workaround: this should not be set here. - if port != "Scart": - open("/proc/stb/video/aspect", "w").write("any") - open("/proc/stb/video/policy", "w").write("panscan") + self.updateAspect(None) def saveMode(self, port, mode, rate): config.av.videoport.value = port @@ -201,6 +207,55 @@ class VideoHardware: self.setMode(port, mode, rate) + def updateAspect(self, cfgelement): + # determine aspect = {any,4:3,16:9,16:10} + # determine policy = {bestfit,letterbox,panscan,nonlinear} + + # based on; + # config.av.videoport.value: current video output device + # Scart: + # config.av.aspect: + # 4_3: use policy_169 + # 16_9,16_10: use policy_43 + # auto always "bestfit" + # config.av.policy_169 + # letterbox use letterbox + # panscan use panscan + # scale use bestfit + # config.av.policy_43 + # pillarbox use panscan + # panscan use letterbox ("panscan" is just a bad term, it's inverse-panscan) + # nonlinear use nonlinear + # scale use bestfit + + port = config.av.videoport.value + if port not in config.av.videomode: + print "current port not available, not setting videomode" + return + mode = config.av.videomode[port].value + + force_widescreen = self.isWidescreenMode(port, mode) + + is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"] + is_auto = config.av.aspect.value == "auto" + + if is_widescreen: + if force_widescreen: + aspect = "16:9" + else: + aspect = {"16_9": "16:9", "16_10": "16:10"}[config.av.aspect.value] + policy = {"pillarbox": "panscan", "panscan": "letterbox", "nonlinear": "nonlinear", "scale": "bestfit"}[config.av.policy_43.value] + elif is_auto: + aspect = "any" + policy = "bestfit" + else: + aspect = "4:3" + policy = {"letterbox": "letterbox", "panscan": "panscan", "scale": "bestfit"}[config.av.policy_169.value] + + print "-> setting aspect, policy", aspect, policy + open("/proc/stb/video/aspect", "w").write(aspect) + open("/proc/stb/video/policy", "w").write(policy) + config.av.edid_override = ConfigYesNo(default = False) video_hw = VideoHardware() video_hw.setConfiguredMode() diff --git a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py index 3536ca6..aac25d6 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py @@ -60,11 +60,27 @@ class VideoSetup(Screen, ConfigListScreen): self.list.append(getConfigListEntry(_("Mode"), config.av.videomode[config.av.videoport.value])) self.list.append(getConfigListEntry(_("Refresh Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value])) + port = config.av.videoport.value + if port not in config.av.videomode: + mode = None + else: + mode = config.av.videomode[port].value + + # some modes (720p, 1080i) are always widescreen. Don't let the user select something here, "auto" is not what he wants. + force_wide = self.hw.isWidescreenMode(port, mode) + + if not force_wide: + self.list.append(getConfigListEntry(_("Aspect Ratio"), config.av.aspect)) + + if force_wide or config.av.aspect.value in ["16_9", "16_10"]: + self.list.append(getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43)) + elif config.av.aspect.value == "4_3": + self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_169)) + # if config.av.videoport.value == "DVI": # self.list.append(getConfigListEntry(_("Allow Unsupported Modes"), config.av.edid_override)) if config.av.videoport.value == "Scart": self.list.append(getConfigListEntry(_("Color Format"), config.av.colorformat)) - self.list.append(getConfigListEntry(_("Aspect Ratio"), config.av.aspectratio)) if level >= 1: self.list.append(getConfigListEntry(_("WSS on 4:3"), config.av.wss))