X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/2e3af63fd26317787d16f2fd7401bba1e36db574..2c5e4d6c412c1988b32cb7dbede988bc9dfb815d:/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index 43543bb1..6ecbfd49 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -1,17 +1,8 @@ -from Screens.Screen import Screen -from Plugins.Plugin import PluginDescriptor - from enigma import eTimer - -from Components.ActionMap import ActionMap -from Components.Label import Label -from Components.Pixmap import Pixmap -from Screens.MessageBox import MessageBox -from Screens.Setup import SetupSummary -from Components.ConfigList import ConfigListScreen -from Components.config import getConfigListEntry, config, ConfigSelection, ConfigSubDict, ConfigYesNo +from Components.config import config, ConfigSelection, ConfigSubDict, ConfigYesNo from Tools.CList import CList +from Tools.HardwareInfo import HardwareInfo # The "VideoHardware" is the interface to /proc/stb/video. # It generates hotplug events, and gives you the list of @@ -22,49 +13,93 @@ class VideoHardware: modes = { } # a list of (high-level) modes for a certain port. - rates["PAL"] = { "50Hz": { 50: "pal", 60: "pal"}, - "60Hz": { 50: "pal60", 60: "pal60"}, - "multi": { 50: "pal", 60: "pal60"} } - rates["NTSC"] = { "60Hz": { 50: "ntsc", 60: "ntsc"} } - rates["Multi"] = { "multi": { 50: "pal", 60: "ntsc"} } - rates["720p"] = { "50Hz": { 50: "720p50", 60: "720p50"}, - "60Hz": { 50: "720p", 60: "720p"}, - "multi": { 50: "720p50", 60: "720p"} } - rates["1080i"] = { "50Hz": { 50: "1080i50", 60: "1080i50"}, - "60Hz": { 50: "1080i", 60: "1080i"}, - "multi": { 50: "1080i50", 60: "1080i"} } + rates["PAL"] = { "50Hz": { 50: "pal" }, + "60Hz": { 60: "pal60" }, + "multi": { 50: "pal", 60: "pal60" } } + + rates["NTSC"] = { "60Hz": { 60: "ntsc" } } + + rates["Multi"] = { "multi": { 50: "pal", 60: "ntsc" } } + + rates["480i"] = { "60Hz": { 60: "480i" } } + + rates["576i"] = { "50Hz": { 50: "576i" } } + + rates["480p"] = { "60Hz": { 60: "480p" } } + + rates["576p"] = { "50Hz": { 50: "576p" } } + + rates["720p"] = { "50Hz": { 50: "720p50" }, + "60Hz": { 60: "720p" }, + "multi": { 50: "720p50", 60: "720p" } } + + rates["1080i"] = { "50Hz": { 50: "1080i50" }, + "60Hz": { 60: "1080i" }, + "multi": { 50: "1080i50", 60: "1080i" } } + rates["PC"] = { - "1024x768": { 60: "1024x768"}, # not possible on DM7025 - "800x600" : { 60: "800x600"}, # also not possible - "720x480" : { 60: "720x480"}, - "720x576" : { 60: "720x576"}, - "1280x720": { 60: "1280x720"}, - "1280x720 multi": { 50: "1280x720_50", 60: "1280x720"}, + "1024x768": { 60: "1024x768" }, # not possible on DM7025 + "800x600" : { 60: "800x600" }, # also not possible + "720x480" : { 60: "720x480" }, + "720x576" : { 60: "720x576" }, + "1280x720": { 60: "1280x720" }, + "1280x720 multi": { 50: "1280x720_50", 60: "1280x720" }, "1920x1080": { 60: "1920x1080"}, - "1920x1080 multi": { 50: "1920x1080", 60: "1920x1080_50"}, + "1920x1080 multi": { 50: "1920x1080", 60: "1920x1080_50" }, "1280x1024" : { 60: "1280x1024"}, "1366x768" : { 60: "1366x768"}, - "1366x768 multi" : { 50: "1366x768", 60: "1366x768_50"}, - "1280x768": { 60: "1280x768"}, - "640x480" : { 60: "640x480"} + "1366x768 multi" : { 50: "1366x768", 60: "1366x768_50" }, + "1280x768": { 60: "1280x768" }, + "640x480" : { 60: "640x480" } } modes["Scart"] = ["PAL", "NTSC", "Multi"] - modes["YPbPr"] = ["720p", "1080i"] - modes["DVI"] = ["720p", "1080i", "PC"] + modes["YPbPr"] = ["720p", "1080i", "576p", "480p", "576i", "480i"] + modes["DVI"] = ["720p", "1080i", "576p", "480p", "576i", "480i"] modes["DVI-PC"] = ["PC"] widescreen_modes = set(["720p", "1080i"]) + def getOutputAspect(self): + ret = (16,9) + port = config.av.videoport.value + if port not in config.av.videomode: + print "current port not available in getOutputAspect!!! force 16:9" + else: + 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: + pass + else: + aspect = {"16_9": "16:9", "16_10": "16:10"}[config.av.aspect.value] + if aspect == "16:10": + ret = (16,10) + elif is_auto: + try: + aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read() + if aspect_str == "1": # 4:3 + ret = (4,3) + except IOError: + pass + else: # 4:3 + ret = (4,3) + return ret + def __init__(self): self.last_modes_preferred = [ ] self.on_hotplug = CList() - self.standby = False self.current_mode = None self.current_port = None self.readAvailableModes() + if self.modes.has_key("DVI-PC") and not self.getModeList("DVI-PC"): + print "remove DVI-PC because of not existing modes" + del self.modes["DVI-PC"] + self.createConfig() # self.on_hotplug.append(self.createConfig) @@ -76,7 +111,7 @@ class VideoHardware: config.av.aspectratio.notifiers = [ ] config.av.tvsystem.notifiers = [ ] config.av.wss.notifiers = [ ] - AVSwitch.setInput = self.AVSwitchSetInput + AVSwitch.getOutputAspect = self.getOutputAspect config.av.aspect.addNotifier(self.updateAspect) config.av.wss.addNotifier(self.updateAspect) @@ -88,12 +123,6 @@ class VideoHardware: # self.timer.callback.append(self.readPreferredModes) # self.timer.start(1000) - config.av.colorformat.addNotifier(self.updateFastblank) - - def AVSwitchSetInput(self, mode): - self.standby = mode == "SCART" - self.updateStandby() - def readAvailableModes(self): try: modes = open("/proc/stb/video/videomode_choices").read()[:-1] @@ -164,12 +193,15 @@ class VideoHardware: self.updateAspect(None) def saveMode(self, port, mode, rate): + print "saveMode", port, mode, rate config.av.videoport.value = port config.av.videoport.save() - config.av.videomode[port].value = mode - config.av.videomode[port].save() - config.av.videorate[mode].value = rate - config.av.videorate[mode].save() + if port in config.av.videomode: + config.av.videomode[port].value = mode + config.av.videomode[port].save() + if mode in config.av.videorate: + config.av.videorate[mode].value = rate + config.av.videorate[mode].save() def isPortAvailable(self, port): # fixme @@ -199,20 +231,29 @@ class VideoHardware: return res def createConfig(self, *args): - # create list of output ports - portlist = self.getPortList() + hw_type = HardwareInfo().get_device_name() + lst = [] - # create list of available modes - config.av.videoport = ConfigSelection(choices = [(port, _(port)) for port in portlist]) config.av.videomode = ConfigSubDict() config.av.videorate = ConfigSubDict() + # create list of output ports + portlist = self.getPortList() for port in portlist: + descr = port + if descr == 'DVI' and hw_type in ('dm500hd', 'dm800se', 'dm7020hd'): + descr = 'HDMI' + elif descr == 'DVI-PC' and hw_type in ('dm500hd', 'dm800se', 'dm7020hd'): + descr = 'HDMI-PC' + lst.append((port, descr)) + + # create list of available modes modes = self.getModeList(port) if len(modes): config.av.videomode[port] = ConfigSelection(choices = [mode for (mode, rates) in modes]) for (mode, rates) in modes: config.av.videorate[mode] = ConfigSelection(choices = rates) + config.av.videoport = ConfigSelection(choices = lst) def setConfiguredMode(self): port = config.av.videoport.value @@ -258,8 +299,9 @@ class VideoHardware: force_widescreen = self.isWidescreenMode(port, mode) - is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"] + is_widescreen = force_widescreen or config.av.aspect.value in ("16_9", "16_10") is_auto = config.av.aspect.value == "auto" + policy2 = "policy" # use main policy if is_widescreen: if force_widescreen: @@ -267,6 +309,7 @@ class VideoHardware: 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] + policy2 = {"letterbox": "letterbox", "panscan": "panscan", "scale": "bestfit"}[config.av.policy_169.value] elif is_auto: aspect = "any" policy = "bestfit" @@ -279,46 +322,14 @@ class VideoHardware: else: wss = "auto" - print "-> setting aspect, policy, wss", aspect, policy, wss + print "-> setting aspect, policy, policy2, wss", aspect, policy, policy2, wss open("/proc/stb/video/aspect", "w").write(aspect) open("/proc/stb/video/policy", "w").write(policy) open("/proc/stb/denc/0/wss", "w").write(wss) - self.updateSlowblank() - self.updateFastblank() - - def updateSlowblank(self): - if self.standby: - from Components.SystemInfo import SystemInfo - if SystemInfo["ScartSwitch"]: - input = "scart" - sb = "vcr" - else: - input = "off" - sb = "0" - else: - input = "encoder" - sb = "auto" - - open("/proc/stb/avs/0/sb", "w").write(sb) - open("/proc/stb/avs/0/input", "w").write(input) - - def updateStandby(self): - self.updateSlowblank() - self.updateFastblank() - - def updateFastblank(self, *args): - if self.standby: - from Components.SystemInfo import SystemInfo - if SystemInfo["ScartSwitch"]: - fb = "vcr" - else: - fb = "low" - else: - if self.current_port == "Scart" and config.av.colorformat.value == "rgb": - fb = "high" - else: - fb = "low" - open("/proc/stb/avs/0/fb", "w").write(fb) + try: + open("/proc/stb/video/policy2", "w").write(policy2) + except IOError: + pass config.av.edid_override = ConfigYesNo(default = False) video_hw = VideoHardware()