cleanup PC Modes
[enigma2.git] / lib / python / Plugins / SystemPlugins / Videomode / VideoHardware.py
index d73610a50253ab7ec5aff6dd2321eb63406eec9f..d3389a75c0e386923637f2145ebb595bcdc0ba76 100644 (file)
@@ -22,17 +22,26 @@ class VideoHardware:
 
        modes = { }  # a list of (high-level) modes for a certain port.
 
 
        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["480p"] =                 { "60Hz":       { 60: "480p" } }
+
+       rates["576p"] =                 { "50Hz":       { 50: "576p" } }
+
+       rates["720p"] =                 { "50Hz":       { 50: "720p50", 60: "720p50" },
+                                                               "60Hz":         { 60: "720p" },
+                                                               "multi":        { 50: "720p50" } }
+
+       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
        rates["PC"] = { 
                "1024x768": { 60: "1024x768"}, # not possible on DM7025
                "800x600" : { 60: "800x600"},  # also not possible
@@ -46,18 +55,22 @@ class VideoHardware:
                "1366x768" : { 60: "1366x768"},
                "1366x768 multi" : { 50: "1366x768", 60: "1366x768_50"},
                "1280x768": { 60: "1280x768"},
                "1366x768" : { 60: "1366x768"},
                "1366x768 multi" : { 50: "1366x768", 60: "1366x768_50"},
                "1280x768": { 60: "1280x768"},
-               "640x480" : { 60: "640x480"} 
+               "640x480" : { 60: "640x480"}
        }
 
        modes["Scart"] = ["PAL", "NTSC", "Multi"]
        }
 
        modes["Scart"] = ["PAL", "NTSC", "Multi"]
-       modes["YPbPr"] = ["720p", "1080i"]
-       modes["DVI"] = ["720p", "1080i", "PC"]
+       modes["YPbPr"] = ["720p", "1080i", "576p", "480p"]
+       modes["DVI"] = ["720p", "1080i", "576p", "480p"]
+       modes["DVI-PC"] = ["PC"]
 
        widescreen_modes = set(["720p", "1080i"])
 
        def __init__(self):
                self.last_modes_preferred =  [ ]
                self.on_hotplug = CList()
 
        widescreen_modes = set(["720p", "1080i"])
 
        def __init__(self):
                self.last_modes_preferred =  [ ]
                self.on_hotplug = CList()
+               self.standby = False
+               self.current_mode = None
+               self.current_port = None
 
                self.readAvailableModes()
 
 
                self.readAvailableModes()
 
@@ -66,7 +79,16 @@ class VideoHardware:
 
                self.readPreferredModes()
 
 
                self.readPreferredModes()
 
+               # take over old AVSwitch component :)
+               from Components.AVSwitch import AVSwitch
+#              config.av.colorformat.notifiers = [ ] 
+               config.av.aspectratio.notifiers = [ ]
+               config.av.tvsystem.notifiers = [ ]
+               config.av.wss.notifiers = [ ]
+               AVSwitch.setInput = self.AVSwitchSetInput
+
                config.av.aspect.addNotifier(self.updateAspect)
                config.av.aspect.addNotifier(self.updateAspect)
+               config.av.wss.addNotifier(self.updateAspect)
                config.av.policy_169.addNotifier(self.updateAspect)
                config.av.policy_43.addNotifier(self.updateAspect)
 
                config.av.policy_169.addNotifier(self.updateAspect)
                config.av.policy_43.addNotifier(self.updateAspect)
 
@@ -75,6 +97,12 @@ class VideoHardware:
 #              self.timer.callback.append(self.readPreferredModes)
 #              self.timer.start(1000)
 
 #              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]
        def readAvailableModes(self):
                try:
                        modes = open("/proc/stb/video/videomode_choices").read()[:-1]
@@ -117,6 +145,7 @@ class VideoHardware:
                print "setMode - port:", port, "mode:", mode, "rate:", rate
                # we can ignore "port"
                self.current_mode = mode
                print "setMode - port:", port, "mode:", mode, "rate:", rate
                # we can ignore "port"
                self.current_mode = mode
+               self.current_port = port
                modes = self.rates[mode][rate]
 
                mode_50 = modes.get(50)
                modes = self.rates[mode][rate]
 
                mode_50 = modes.get(50)
@@ -127,8 +156,8 @@ class VideoHardware:
                        mode_60 = mode_50
 
                try:
                        mode_60 = mode_50
 
                try:
-                       open("/proc/stb/video/videomode_60hz", "w").write(mode_50)
-                       open("/proc/stb/video/videomode_50hz", "w").write(mode_60)
+                       open("/proc/stb/video/videomode_50hz", "w").write(mode_50)
+                       open("/proc/stb/video/videomode_60hz", "w").write(mode_60)
                except IOError:
                        try:
                                # fallback if no possibility to setup 50/60 hz mode
                except IOError:
                        try:
                                # fallback if no possibility to setup 50/60 hz mode
@@ -145,8 +174,11 @@ class VideoHardware:
 
        def saveMode(self, port, mode, rate):
                config.av.videoport.value = port
 
        def saveMode(self, port, mode, rate):
                config.av.videoport.value = port
+               config.av.videoport.save()
                config.av.videomode[port].value = mode
                config.av.videomode[port].value = mode
+               config.av.videomode[port].save()
                config.av.videorate[mode].value = rate
                config.av.videorate[mode].value = rate
+               config.av.videorate[mode].save()
 
        def isPortAvailable(self, port):
                # fixme
 
        def isPortAvailable(self, port):
                # fixme
@@ -205,7 +237,6 @@ class VideoHardware:
 
                rate = config.av.videorate[mode].value
                self.setMode(port, mode, rate)
 
                rate = config.av.videorate[mode].value
                self.setMode(port, mode, rate)
-               
 
        def updateAspect(self, cfgelement):
                # determine aspect = {any,4:3,16:9,16:10}
 
        def updateAspect(self, cfgelement):
                # determine aspect = {any,4:3,16:9,16:10}
@@ -252,9 +283,51 @@ class VideoHardware:
                        aspect = "4:3"
                        policy = {"letterbox": "letterbox", "panscan": "panscan", "scale": "bestfit"}[config.av.policy_169.value]
 
                        aspect = "4:3"
                        policy = {"letterbox": "letterbox", "panscan": "panscan", "scale": "bestfit"}[config.av.policy_169.value]
 
-               print "-> setting aspect, policy", aspect, policy
+               if not config.av.wss.value:
+                       wss = "auto(4:3_off)"
+               else:
+                       wss = "auto"
+
+               print "-> setting aspect, policy, wss", aspect, policy, wss
                open("/proc/stb/video/aspect", "w").write(aspect)
                open("/proc/stb/video/policy", "w").write(policy)
                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)
 
 config.av.edid_override = ConfigYesNo(default = False)
 video_hw = VideoHardware()
 
 config.av.edid_override = ConfigYesNo(default = False)
 video_hw = VideoHardware()