workaround: on non-scart modes, set aspect/policy
[enigma2.git] / lib / python / Plugins / SystemPlugins / Videomode / VideoHardware.py
index 9a58403..c6d6b86 100644 (file)
@@ -50,16 +50,18 @@ class VideoHardware:
        }
 
        modes["Scart"] = ["PAL", "NTSC", "Multi"]
-       modes["YPrPb"] = ["720p", "1080i"]
+       modes["YPbPr"] = ["720p", "1080i"]
        modes["DVI"] = ["720p", "1080i", "PC"]
 
        def __init__(self):
                self.last_modes_preferred =  [ ]
                self.on_hotplug = CList()
 
-               self.on_hotplug.append(self.createConfig)
-
                self.readAvailableModes()
+
+               self.createConfig()
+#              self.on_hotplug.append(self.createConfig)
+
                self.readPreferredModes()
 
                # until we have the hotplug poll socket
@@ -91,7 +93,6 @@ class VideoHardware:
 
        # check if a high-level mode with a given rate is available.
        def isModeAvailable(self, port, mode, rate):
-               print "isModeAvailable:", port, mode, rate, 
                rate = self.rates[mode][rate]
                for mode in rate.values():
                        # DVI modes must be in "modes_preferred"
@@ -100,12 +101,11 @@ class VideoHardware:
 #                                      print "no, not preferred"
 #                                      return False
                        if mode not in self.modes_available:
-                               print "no, not available"
                                return False
-               print "yes"
                return True
 
        def setMode(self, port, mode, rate, force = None):
+               print "setMode - port:", port, "mode:", mode, "rate:", rate
                # we can ignore "port"
                self.current_mode = mode
                modes = self.rates[mode][rate]
@@ -127,10 +127,27 @@ class VideoHardware:
                        except IOError:
                                print "setting videomode failed."
 
+               try:
+                       open("/etc/videomode", "w").write(mode_50) # use 50Hz mode (if available) for booting
+               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")
+
        def isPortAvailable(self, port):
                # fixme
                return True
 
+       def isPortUsed(self, port):
+               if port == "DVI":
+                       self.readPreferredModes()
+                       return len(self.modes_preferred) != 0
+               else:
+                       return True
+
        def getPortList(self):
                return [port for port in self.modes if self.isPortAvailable(port)]
 
@@ -162,5 +179,21 @@ class VideoHardware:
                        for (mode, rates) in modes:
                                config.av.videorate[mode] = ConfigSelection(choices = rates)
 
+       def setConfiguredMode(self):
+               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
+
+               if mode not in config.av.videorate:
+                       print "current mode not available, not setting videomode"
+                       return
+
+               rate = config.av.videorate[mode].value
+               self.setMode(port, mode, rate)
+
 config.av.edid_override = ConfigYesNo(default = False)
 video_hw = VideoHardware()
+video_hw.setConfiguredMode()