disable preferred_modes stuff for now, implement hotplug (but disable it)
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 24 Jan 2008 21:40:11 +0000 (21:40 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 24 Jan 2008 21:40:11 +0000 (21:40 +0000)
lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py
lib/python/Plugins/SystemPlugins/Videomode/plugin.py

index 258f78b..9a58403 100644 (file)
@@ -9,7 +9,7 @@ from Components.Pixmap import Pixmap
 from Screens.MessageBox import MessageBox
 from Screens.Setup import SetupSummary
 from Components.ConfigList import ConfigListScreen
 from Screens.MessageBox import MessageBox
 from Screens.Setup import SetupSummary
 from Components.ConfigList import ConfigListScreen
-from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict
+from Components.config import getConfigListEntry, config, ConfigSelection, ConfigSubDict, ConfigYesNo
 
 from Tools.CList import CList
 
 
 from Tools.CList import CList
 
@@ -43,6 +43,9 @@ class VideoHardware:
                "1920x1080": { 60: "1920x1080"},
                "1920x1080 multi": { 50: "1920x1080", 60: "1920x1080_50"},
                "1280x1024" : { 60: "1280x1024"},
                "1920x1080": { 60: "1920x1080"},
                "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"} 
        }
 
                "640x480" : { 60: "640x480"} 
        }
 
@@ -55,15 +58,14 @@ class VideoHardware:
                self.on_hotplug = CList()
 
                self.on_hotplug.append(self.createConfig)
                self.on_hotplug = CList()
 
                self.on_hotplug.append(self.createConfig)
-               self.ignore_preferred = False   # "edid override"
 
                self.readAvailableModes()
                self.readPreferredModes()
 
                # until we have the hotplug poll socket
 
                self.readAvailableModes()
                self.readPreferredModes()
 
                # until we have the hotplug poll socket
-               self.timer = eTimer()
-               self.timer.timeout.get().append(self.readAvailableModes)
-               self.timer.start(1000)
+#              self.timer = eTimer()
+#              self.timer.timeout.get().append(self.readPreferredModes)
+#              self.timer.start(1000)
 
        def readAvailableModes(self):
                try:
 
        def readAvailableModes(self):
                try:
@@ -84,30 +86,35 @@ class VideoHardware:
 
                if self.modes_preferred != self.last_modes_preferred:
                        self.last_modes_preferred = self.modes_preferred
 
                if self.modes_preferred != self.last_modes_preferred:
                        self.last_modes_preferred = self.modes_preferred
+                       print "hotplug on dvi"
                        self.on_hotplug("DVI") # must be DVI
 
        # check if a high-level mode with a given rate is available.
        def isModeAvailable(self, port, mode, rate):
                        self.on_hotplug("DVI") # must be DVI
 
        # 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"
                rate = self.rates[mode][rate]
                for mode in rate.values():
                        # DVI modes must be in "modes_preferred"
-                       if port == "DVI":
-                               if mode not in self.modes_preferred and not self.ignore_preferred:
-                                       return False
+#                      if port == "DVI":
+#                              if mode not in self.modes_preferred and not config.av.edid_override.value:
+#                                      print "no, not preferred"
+#                                      return False
                        if mode not in self.modes_available:
                        if mode not in self.modes_available:
+                               print "no, not available"
                                return False
                                return False
+               print "yes"
                return True
 
                return True
 
-       def setMode(self, port, mode, rate):
+       def setMode(self, port, mode, rate, force = None):
                # we can ignore "port"
                self.current_mode = mode
                modes = self.rates[mode][rate]
 
                mode_50 = modes.get(50)
                mode_60 = modes.get(60)
                # we can ignore "port"
                self.current_mode = mode
                modes = self.rates[mode][rate]
 
                mode_50 = modes.get(50)
                mode_60 = modes.get(60)
-               if mode_50 is None:
+               if mode_50 is None or force == 60:
                        mode_50 = mode_60
                        mode_50 = mode_60
-               if mode_60 is None:
+               if mode_60 is None or force == 50: 
                        mode_60 = mode_50
 
                try:
                        mode_60 = mode_50
 
                try:
@@ -155,4 +162,5 @@ class VideoHardware:
                        for (mode, rates) in modes:
                                config.av.videorate[mode] = ConfigSelection(choices = rates)
 
                        for (mode, rates) in modes:
                                config.av.videorate[mode] = ConfigSelection(choices = rates)
 
-video_hw = VideoHardware()
\ No newline at end of file
+config.av.edid_override = ConfigYesNo(default = False)
+video_hw = VideoHardware()
index f0fe140..45ff6f0 100644 (file)
@@ -86,4 +86,4 @@ class VideoWizard(Wizard):
                print "rateSelectionMade:", index
                
        def rateSelectionMoved(self):
                print "rateSelectionMade:", index
                
        def rateSelectionMoved(self):
-               print "selection moved:", self.selection
\ No newline at end of file
+               print "selection moved:", self.selection
index 1d196de..b9c85ec 100644 (file)
@@ -9,12 +9,10 @@ from Components.Pixmap import Pixmap
 from Screens.MessageBox import MessageBox
 from Screens.Setup import SetupSummary
 from Components.ConfigList import ConfigListScreen
 from Screens.MessageBox import MessageBox
 from Screens.Setup import SetupSummary
 from Components.ConfigList import ConfigListScreen
-from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict
+from Components.config import getConfigListEntry, config
 from VideoWizard import VideoWizard
 from Components.config import config
 
 from VideoWizard import VideoWizard
 from Components.config import config
 
-from Tools.CList import CList
-
 from VideoHardware import video_hw
 
 class VideoSetup(Screen, ConfigListScreen):
 from VideoHardware import video_hw
 
 class VideoSetup(Screen, ConfigListScreen):
@@ -64,6 +62,9 @@ class VideoSetup(Screen, ConfigListScreen):
                        self.list.append(getConfigListEntry(_("Mode"), config.av.videomode[config.av.videoport.value]))
                        self.list.append(getConfigListEntry(_("Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
 
                        self.list.append(getConfigListEntry(_("Mode"), config.av.videomode[config.av.videoport.value]))
                        self.list.append(getConfigListEntry(_("Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
 
+#              if config.av.videoport.value == "DVI":
+#                      self.list.append(getConfigListEntry(_("Allow Unsupported Modes"), config.av.edid_override))
+
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
@@ -93,7 +94,7 @@ class VideoSetup(Screen, ConfigListScreen):
                rate = config.av.videorate[mode].value
                if (port, mode, rate) != self.last_good or True:
                        self.hw.setMode(port, mode, rate)
                rate = config.av.videorate[mode].value
                if (port, mode, rate) != self.last_good or True:
                        self.hw.setMode(port, mode, rate)
-                       self.session.openWithCallback(self.confirm, MessageBox, "Is this videomode ok?", MessageBox.TYPE_YESNO, timeout = 5, default = False)
+                       self.session.openWithCallback(self.confirm, MessageBox, "Is this videomode ok?", MessageBox.TYPE_YESNO, timeout = 20, default = False)
                else:
                        self.keySave()
 
                else:
                        self.keySave()
 
@@ -111,37 +112,55 @@ class VideoSetup(Screen, ConfigListScreen):
        def createSummary(self):
                return SetupSummary
 
        def createSummary(self):
                return SetupSummary
 
-#class VideomodeHotplug:
-#      def __init__(self, hw):
-#              self.hw = hw
-#              self.hw.on_hotplug.append(self.hotplug)
-#
-#      def hotplug(self, what):
-#              print "hotplug detected on port '%s'" % (what)
-# ...
-#
-#hotplug = None
-#
-#def startHotplug(self):
-#      global hotplug
-#      hotplug = VideomodeHotplug()
-#      hotplug.start()
-#
-#def stopHotplug(self):
-#      global hotplug
-#      hotplug.stop()
-#
-#
-#def autostart(reason, session = None, **kwargs):
-#      if session is not None:
-#              global my_global_session
-#              my_global_session = session
-#              return
-#
-#      if reason == 0:
-#              startHotplug()
-#      elif reason == 1:
-#              stopHotplug()
+class VideomodeHotplug:
+       def __init__(self, hw):
+               self.hw = hw
+
+       def start(self):
+               self.hw.on_hotplug.append(self.hotplug)
+
+       def stop(self):
+               self.hw.on_hotplug.remove(self.hotplug)
+
+       def hotplug(self, what):
+               print "hotplug detected on port '%s'" % (what)
+               port = config.av.videoport.value
+               mode = config.av.videomode[port].value
+               rate = config.av.videorate[mode].value
+
+               if not self.hw.isModeAvailable(port, mode, rate):
+                       print "mode %s/%s/%s went away!" % (port, mode, rate)
+                       modelist = self.hw.getModeList(port)
+                       if not len(modelist):
+                               print "sorry, no other mode is available (unplug?). Doing nothing."
+                               return
+                       mode = modelist[0][0]
+                       rate = modelist[0][1]
+                       print "setting %s/%s/%s" % (port, mode, rate)
+                       self.hw.setMode(port, mode, rate)
+
+hotplug = None
+
+def startHotplug():
+       global hotplug, video_hw
+       hotplug = VideomodeHotplug(video_hw)
+       hotplug.start()
+
+def stopHotplug():
+       global hotplug
+       hotplug.stop()
+
+
+def autostart(reason, session = None, **kwargs):
+       if session is not None:
+               global my_global_session
+               my_global_session = session
+               return
+
+       if reason == 0:
+               startHotplug()
+       elif reason == 1:
+               stopHotplug()
 
 def videoSetupMain(session, **kwargs):
        session.open(VideoSetup, video_hw)
 
 def videoSetupMain(session, **kwargs):
        session.open(VideoSetup, video_hw)
@@ -153,8 +172,10 @@ def startSetup(menuid):
        return [(_("Video Setup"), videoSetupMain, "video_setup", None)]
 
 def Plugins(**kwargs):
        return [(_("Video Setup"), videoSetupMain, "video_setup", None)]
 
 def Plugins(**kwargs):
-       list = []
-       list.append(PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))
+       list = [
+#              PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
+               PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup) 
+       ]
        if config.misc.firstrun.value:
                list.append(PluginDescriptor(name=_("Video Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=VideoWizard))
        return list
        if config.misc.firstrun.value:
                list.append(PluginDescriptor(name=_("Video Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=VideoWizard))
        return list