From dcc4a84bbe28965292b92a0242d9c68e6e0dbba8 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Thu, 24 Jan 2008 21:40:11 +0000 Subject: [PATCH 1/1] disable preferred_modes stuff for now, implement hotplug (but disable it) --- .../SystemPlugins/Videomode/VideoHardware.py | 32 ++++--- .../SystemPlugins/Videomode/VideoWizard.py | 2 +- .../Plugins/SystemPlugins/Videomode/plugin.py | 95 +++++++++++-------- 3 files changed, 79 insertions(+), 50 deletions(-) diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index 258f78b1..9a58403a 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -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 Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict +from Components.config import getConfigListEntry, config, ConfigSelection, ConfigSubDict, ConfigYesNo from Tools.CList import CList @@ -43,6 +43,9 @@ class VideoHardware: "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"} } @@ -55,15 +58,14 @@ class VideoHardware: 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.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: @@ -84,30 +86,35 @@ class VideoHardware: 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): + print "isModeAvailable:", port, mode, rate, 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: + print "no, not available" return False + print "yes" 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) - if mode_50 is None: + if mode_50 is None or force == 60: mode_50 = mode_60 - if mode_60 is None: + if mode_60 is None or force == 50: mode_60 = mode_50 try: @@ -155,4 +162,5 @@ class VideoHardware: 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() diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index f0fe1403..45ff6f0c 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -86,4 +86,4 @@ class VideoWizard(Wizard): print "rateSelectionMade:", index def rateSelectionMoved(self): - print "selection moved:", self.selection \ No newline at end of file + print "selection moved:", self.selection diff --git a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py index 1d196de4..b9c85ec9 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py @@ -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 Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict +from Components.config import getConfigListEntry, config from VideoWizard import VideoWizard from Components.config import config -from Tools.CList import CList - 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])) +# 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) @@ -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) - 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() @@ -111,37 +112,55 @@ class VideoSetup(Screen, ConfigListScreen): 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) @@ -153,8 +172,10 @@ def startSetup(menuid): 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 -- 2.30.2