update Videomode plugin.
authorhschang <chang@dev3>
Wed, 13 Feb 2013 04:30:54 +0000 (13:30 +0900)
committerhschang <chang@dev3>
Wed, 13 Feb 2013 04:31:01 +0000 (13:31 +0900)
18 files changed:
lib/python/Plugins/SystemPlugins/Videomode/DVI.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/HDMI.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/LICENSE [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/Makefile.am
lib/python/Plugins/SystemPlugins/Videomode/Scart.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py [changed mode: 0755->0644]
lib/python/Plugins/SystemPlugins/Videomode/YPbPr.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/lcd_DVI.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/lcd_Scart.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/lcd_YPbPr.png [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/meta/Makefile.am [changed mode: 0755->0644]
lib/python/Plugins/SystemPlugins/Videomode/meta/plugin_videomode.xml [changed mode: 0755->0644]
lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_de.jpg [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_en.jpg [deleted file]
lib/python/Plugins/SystemPlugins/Videomode/plugin.py
lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml

diff --git a/lib/python/Plugins/SystemPlugins/Videomode/DVI.png b/lib/python/Plugins/SystemPlugins/Videomode/DVI.png
deleted file mode 100644 (file)
index 168d7ab..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/DVI.png and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/HDMI.png b/lib/python/Plugins/SystemPlugins/Videomode/HDMI.png
deleted file mode 100644 (file)
index 5aa8304..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/HDMI.png and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/LICENSE b/lib/python/Plugins/SystemPlugins/Videomode/LICENSE
deleted file mode 100644 (file)
index 9970059..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-This plugin is licensed under the Creative Commons 
-Attribution-NonCommercial-ShareAlike 3.0 Unported 
-License. To view a copy of this license, visit
-http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
-Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
-
-Alternatively, this plugin may be distributed and executed on hardware which
-is licensed by Dream Multimedia GmbH.
-
-This plugin is NOT free software. It is open source, you are allowed to
-modify it (if you keep the license), but it may not be commercially 
-distributed other than under the conditions noted above.
index 1ac1d5d..de7e13d 100644 (file)
@@ -6,16 +6,7 @@ install_PYTHON =       \
        __init__.py \
        plugin.py \
        VideoHardware.py \
        __init__.py \
        plugin.py \
        VideoHardware.py \
-       VideoWizard.py
+       VideoWizard.py 
 
 dist_install_DATA = \
 
 dist_install_DATA = \
-       DVI.png \
-       lcd_DVI.png \
-       lcd_Scart.png \
-       lcd_YPbPr.png \
-       LICENSE \
-       Scart.png \
-       videowizard.xml \
-       YPbPr.png \
-       HDMI.png \
-       lcd_HDMI.png
+       videowizard.xml
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/Scart.png b/lib/python/Plugins/SystemPlugins/Videomode/Scart.png
deleted file mode 100644 (file)
index ce36d59..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/Scart.png and /dev/null differ
index 6ecbfd4..c192395 100644 (file)
-from enigma import eTimer
-from Components.config import config, ConfigSelection, ConfigSubDict, ConfigYesNo
-
+from Components.config import config, ConfigSubDict, ConfigSelection
 from Tools.CList import CList
 from Tools.HardwareInfo import HardwareInfo
 
 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 
-# available and preferred modes, as well as handling the currently
-# selected mode. No other strict checking is done.
+# VideoHardware is the interface to /proc/stb/video.
 class VideoHardware:
 class VideoHardware:
-       rates = { } # high-level, use selectable modes.
-
-       modes = { }  # a list of (high-level) modes for a certain port.
-
-       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" } }
+       is_init = True
 
 
-       rates["480p"] =                 { "60Hz":       { 60: "480p" } }
-
-       rates["576p"] =                 { "50Hz":       { 50: "576p" } }
-
-       rates["720p"] =                 { "50Hz":       { 50: "720p50" },
-                                                               "60Hz":         { 60: "720p" },
-                                                               "multi":        { 50: "720p50", 60: "720p" } }
+       modes = { # a list of modes for available port
+               "Scart" : ["PAL", "NTSC", "Multi"],
+               "YPbPr" : ["720p", "1080i", "576p", "480p", "576i", "480i"],
+               "DVI"   : ["720p", "1080i", "576p", "480p", "576i", "480i"],
+               "DVI-PC": ["PC"]
+       }
+       rates = { # list of rates for available mode
+               "PAL":   { "50Hz" : {50: "pal"},
+                                  "60Hz" : {60: "pal60"},
+                                  "multi": {50: "pal", 60: "pal60"}
+               },
+               "NTSC":  { "60Hz" : {60: "ntsc"} },
+               "Multi": { "multi": {50: "pal", 60: "ntsc"} },
+               "480i":  { "60Hz" : {60: "480i"} },
+               "576i":  { "50Hz" : {50: "576i"} },
+               "480p":  { "60Hz" : {60: "480p"} },
+               "576p":  { "50Hz" : {50: "576p"} },
+               "720p":  {
+                       "50Hz" : {50: "720p50"},
+                       "60Hz" : {60: "720p"},
+                       "multi": {50: "720p50", 60: "720p"}
+               },
+               "1080i": {
+                       "50Hz" : {50: "1080i50"},
+                       "60Hz" : {60: "1080i"},
+                       "multi": {50: "1080i50", 60: "1080i"}
+               },
+               "1080p": {
+                       "50Hz" : {50: "1080p50"},
+                       "60Hz" : {60: "1080p"},
+                       "multi": {50: "1080p50", 60: "1080p"}
+               },
+               "PC": {
+                       "1024x768": {60: "1024x768"},
+                       "800x600" : {60: "800x600"},
+                       "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"},
+                       "1280x1024": {60: "1280x1024"},
+                       "1366x768": {60: "1366x768"},
+                       "1366x768 multi": {50: "1366x768", 60: "1366x768_50"},
+                       "1280x768": {60: "1280x768"},
+                       "640x480" : {60: "640x480"}
+               }
+       }
 
 
-       rates["1080i"] =                { "50Hz":               { 50: "1080i50" },
-                                                               "60Hz":         { 60: "1080i" },
-                                                               "multi":        { 50: "1080i50", 60: "1080i" } }
+       widescreen_modes = set(["720p", "1080i", "1080p"])
+       hdmi_hw_types = set(["dm500", "dm800se", "dm7020hd", "duo", "solo", "uno", "ultimo", "solo2", "duo2"])
+       hdmi_pc_hw_types = set(["dm500", "dm800se", "dm7020hd", "duo", "solo", "uno", "ultimo", "solo2", "duo2"])
 
 
-       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" },
-               "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" }
-       }
+       def getDeviceName(self):
+               device_name = "unknown"
+               try:
+                       file = open("/proc/stb/info/vumodel", "r")
+                       device_name = file.readline().strip()
+                       file.close()
+               except IOError:
+                       from Tools.HardwareInfo import HardwareInfo
+                       device_name = HardwareInfo.get_device_name()
 
 
-       modes["Scart"] = ["PAL", "NTSC", "Multi"]
-       modes["YPbPr"] = ["720p", "1080i", "576p", "480p", "576i", "480i"]
-       modes["DVI"] = ["720p", "1080i", "576p", "480p", "576i", "480i"]
-       modes["DVI-PC"] = ["PC"]
+               return device_name
 
 
-       widescreen_modes = set(["720p", "1080i"])
+       def isVumodel(self, hw_type):
+               return hw_type in set(["duo", "solo", "uno", "ultimo", "solo2", "duo2"])
 
 
+       # re-define AVSwitch.getOutputAspect
        def getOutputAspect(self):
                ret = (16,9)
                port = config.av.videoport.value
                if port not in config.av.videomode:
        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"
+                       print "current port is not available. force 16:9"
                else:
                        mode = config.av.videomode[port].value
                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:
+                       force_wide = self.isWidescreenMode(mode)
+                       valstr = config.av.aspect.value
+
+                       if force_wide:
+                               pass
+                       elif valstr == "16_10":
+                               ret = (16,10)
+                       elif valstr == "auto":
                                try:
                                        aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read()
                                        if aspect_str == "1": # 4:3
                                                ret = (4,3)
                                except IOError:
                                        pass
                                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
+                       elif valstr == "4_3":
                                ret = (4,3)
                return ret
 
        def __init__(self):
                                ret = (4,3)
                return ret
 
        def __init__(self):
-               self.last_modes_preferred =  [ ]
+               self.last_modes_preferred = [ ]
                self.on_hotplug = CList()
                self.on_hotplug = CList()
-               self.current_mode = None
-               self.current_port = None
 
                self.readAvailableModes()
 
                if self.modes.has_key("DVI-PC") and not self.getModeList("DVI-PC"):
 
                self.readAvailableModes()
 
                if self.modes.has_key("DVI-PC") and not self.getModeList("DVI-PC"):
-                       print "remove DVI-PC because of not existing modes"
+                       print "remove DVI-PC because it does not exist."
                        del self.modes["DVI-PC"]
 
                self.createConfig()
                        del self.modes["DVI-PC"]
 
                self.createConfig()
-#              self.on_hotplug.append(self.createConfig)
 
                self.readPreferredModes()
 
 
                self.readPreferredModes()
 
-               # take over old AVSwitch component :)
+               # re-define AVSwitch components
                from Components.AVSwitch import AVSwitch
                from Components.AVSwitch import AVSwitch
-#              config.av.colorformat.notifiers = [ ] 
                config.av.aspectratio.notifiers = [ ]
                config.av.tvsystem.notifiers = [ ]
                config.av.wss.notifiers = [ ]
                AVSwitch.getOutputAspect = self.getOutputAspect
 
                config.av.aspectratio.notifiers = [ ]
                config.av.tvsystem.notifiers = [ ]
                config.av.wss.notifiers = [ ]
                AVSwitch.getOutputAspect = self.getOutputAspect
 
-               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.aspect.addNotifier(self.changedAspect)
+               config.av.wss.addNotifier(self.changedAspect)
+               config.av.policy_169.addNotifier(self.changedAspect)
+               config.av.policy_43.addNotifier(self.changedAspect)
 
 
-               # until we have the hotplug poll socket
-#              self.timer = eTimer()
-#              self.timer.callback.append(self.readPreferredModes)
-#              self.timer.start(1000)
+               # addNotifiers for port, mode, rate
+               config.av.videoport.addNotifier(self.changedVideomode)
+               for port in self.getPortList():
+                       config.av.videomode[port].addNotifier(self.changedVideomode)
+                       for mode in self.getModeList(port):
+                               config.av.videorate[mode].addNotifier(self.changedVideomode)
 
 
+               self.is_init = False
+       
        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]
+                       self.modes_available = modes.split(' ')
                except IOError:
                except IOError:
-                       print "couldn't read available videomodes."
+                       print "failed to read video_choices."
                        self.modes_available = [ ]
                        self.modes_available = [ ]
-                       return
-               self.modes_available = modes.split(' ')
 
        def readPreferredModes(self):
                try:
                        modes = open("/proc/stb/video/videomode_preferred").read()[:-1]
                        self.modes_preferred = modes.split(' ')
                except IOError:
 
        def readPreferredModes(self):
                try:
                        modes = open("/proc/stb/video/videomode_preferred").read()[:-1]
                        self.modes_preferred = modes.split(' ')
                except IOError:
-                       print "reading preferred modes failed, using all modes"
+                       print "failed to read video_preferred."
                        self.modes_preferred = self.modes_available
 
                if self.modes_preferred != self.last_modes_preferred:
                        self.last_modes_preferred = self.modes_preferred
                        self.modes_preferred = self.modes_available
 
                if self.modes_preferred != self.last_modes_preferred:
                        self.last_modes_preferred = self.modes_preferred
-                       print "hotplug on dvi"
+                       print "hotplug on DVI"
                        self.on_hotplug("DVI") # must be DVI
                        self.on_hotplug("DVI") # must be DVI
+       
+       # check if HDMI is available
+       def isHDMIAvailable(self, hw_type):
+               return hw_type in self.hdmi_hw_types
 
 
-       # check if a high-level mode with a given rate is available.
+       # check if HDMI-PC is available
+       def isHDMI_PCAvailable(self, hw_type):
+               return hw_type in self.hdmi_pc_hw_types
+
+       # check if mode is always widescreen
+       def isWidescreenMode(self, mode):
+               return mode in self.widescreen_modes
+
+       # check if rate is available for mode
        def isModeAvailable(self, port, mode, rate):
                rate = self.rates[mode][rate]
                for mode in rate.values():
        def isModeAvailable(self, 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 config.av.edid_override.value:
-#                                      print "no, not preferred"
-#                                      return False
                        if mode not in self.modes_available:
                                return False
                        if mode not in self.modes_available:
                                return False
-               return True
-
-       def isWidescreenMode(self, port, mode):
-               return mode in self.widescreen_modes
-
-       def setMode(self, port, mode, rate, force = None):
-               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)
-               mode_60 = modes.get(60)
-               if mode_50 is None or force == 60:
-                       mode_50 = mode_60
-               if mode_60 is None or force == 50: 
-                       mode_60 = mode_50
-
-               try:
-                       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
-                               open("/proc/stb/video/videomode", "w").write(mode_50)
-                       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."
-
-               self.updateAspect(None)
-
-       def saveMode(self, port, mode, rate):
-               print "saveMode", port, mode, rate
-               config.av.videoport.value = port
-               config.av.videoport.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()
+               return True
 
 
+       # check isModeAvailable in this port
        def isPortAvailable(self, port):
        def isPortAvailable(self, port):
-               # fixme
-               return True
+               for mode in self.getModeList(port):
+                       if len(self.getRateList(port, mode)):
+                               return True
 
 
-       def isPortUsed(self, port):
-               if port == "DVI":
-                       self.readPreferredModes()
-                       return len(self.modes_preferred) != 0
-               else:
-                       return True
+               return False
 
 
+       # get a list of all available port
        def getPortList(self):
                return [port for port in self.modes if self.isPortAvailable(port)]
 
        def getPortList(self):
                return [port for port in self.modes if self.isPortAvailable(port)]
 
-       # get a list with all modes, with all rates, for a given port.
+       # get a list of all available mode for a given port
        def getModeList(self, port):
        def getModeList(self, port):
-               print "getModeList for port", port
-               res = [ ]
+               modelist = [ ]
                for mode in self.modes[port]:
                for mode in self.modes[port]:
-                       # list all rates which are completely valid
-                       rates = [rate for rate in self.rates[mode] if self.isModeAvailable(port, mode, rate)]
+                       rates = self.getRateList(port, mode)
 
 
-                       # if at least one rate is ok, add this mode
                        if len(rates):
                        if len(rates):
-                               res.append( (mode, rates) )
-               return res
+                               modelist.append(mode)
+
+               return modelist
 
 
-       def createConfig(self, *args):
-               hw_type = HardwareInfo().get_device_name()
-               lst = []
+       # get a list of all available rate for a given port, mode
+       def getRateList(self, port, mode):
+               return [rate for rate in self.rates[mode] if self.isModeAvailable(port, mode, rate)]
 
 
+       def createConfig(self):
                config.av.videomode = ConfigSubDict()
                config.av.videorate = ConfigSubDict()
 
                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))
+               hw_type = self.getDeviceName()
+               # vu+ support 1080p
+               if self.isVumodel(hw_type):
+                       self.modes["DVI"].insert(self.modes["DVI"].index("1080i")+1, "1080p")
+
+               portlist = [ ]
+               port_choices = self.getPortList()
+
+               for port in port_choices:
+                       desc = port
+                       if desc == 'DVI' and self.isHDMIAvailable(hw_type):
+                               desc = 'HDMI'
+                       if desc == 'DVI-PC' and self.isHDMI_PCAvailable(hw_type):
+                               desc = 'HDMI-PC'
+                       portlist.append( (port, desc))
 
                        # create list of available modes
 
                        # 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)
+                       modelist = [ ]
+                       mode_choices = self.getModeList(port)
 
 
-       def setConfiguredMode(self):
-               port = config.av.videoport.value
-               if port not in config.av.videomode:
-                       print "current port not available, not setting videomode"
+                       for mode in mode_choices:
+                               modelist.append( (mode, mode))
+
+                               # create list of available rates
+                               ratelist = [ ]
+                               rate_choices = self.getRateList(port, mode)
+
+                               for rate in rate_choices:
+                                       ratelist.append( (rate, rate))
+
+                               config.av.videorate[mode] = ConfigSelection(choices = ratelist)
+                       config.av.videomode[port] = ConfigSelection(choices = modelist)
+               config.av.videoport = ConfigSelection(choices = portlist)
+       
+       def changedVideomode(self, configElement):
+               if self.is_init:
                        return
 
                        return
 
+               self.setConfiguredMode()
+
+       def setConfiguredMode(self):
+               port = config.av.videoport.value
                mode = config.av.videomode[port].value
                mode = config.av.videomode[port].value
+               rate = config.av.videorate[mode].value
+
+               self.setVideomode(port, mode, rate)
+
+       def setVideomode(self, port, mode, rate):
+               if port is None or port not in config.av.videomode:
+                       print "current port not available. couldn't set videomode"
+                       return
 
                if mode not in config.av.videorate:
 
                if mode not in config.av.videorate:
-                       print "current mode not available, not setting videomode"
+                       print "current mode not available. couldn't set videomode"
                        return
 
                        return
 
-               rate = config.av.videorate[mode].value
-               self.setMode(port, mode, rate)
-
-       def updateAspect(self, cfgelement):
-               # determine aspect = {any,4:3,16:9,16:10}
-               # determine policy = {bestfit,letterbox,panscan,nonlinear}
-
-               # based on;
-               #   config.av.videoport.value: current video output device
-               #     Scart: 
-               #   config.av.aspect:
-               #     4_3:            use policy_169
-               #     16_9,16_10:     use policy_43
-               #     auto            always "bestfit"
-               #   config.av.policy_169
-               #     letterbox       use letterbox
-               #     panscan         use panscan
-               #     scale           use bestfit
-               #   config.av.policy_43
-               #     pillarbox       use panscan
-               #     panscan         use letterbox  ("panscan" is just a bad term, it's inverse-panscan)
-               #     nonlinear       use nonlinear
-               #     scale           use bestfit
+               if mode is None:
+                       modelist = self.getModeList(port)
+                       mode = modelist[0]
+
+                       ratelist = self.getRateList(port, mode)
+                       rate = ratelist[0]
+
+               if rate is None:
+                       ratelist = self.getRateList(port, mode)
+                       rate = ratelist[0]
+
+               print "set Videomode", port, mode, rate
+
+               modes = self.rates[mode][rate]
+               mode_50 = modes.get(50)
+               mode_60 = modes.get(60)
+               if mode_50 is None:
+                       mode_50 = mode_60
+               if mode_60 is None:
+                       mode_60 = mode_50
+
+               if (mode_50 != mode_60):
+                       try:
+                               open("/proc/stb/video/videomode_50hz", "w").write(mode_50)
+                               open("/proc/stb/video/videomode_60hz", "w").write(mode_60)
+                       except IOError:
+                               print "cannot open /proc/stb/vide/videomode_50hz or videomode_60hz"
+
+                       # Too slow moving to Scart/multi in modeSelectionMoved
+                       #try:
+                       #       open("/proc/stb/video/videomode_50hz", "w").write(mode_60)
+                       #except IOError:
+                       #       print "cannot open /proc/stb/vide/videomode_60Hz"
+
+               else:
+                       try:
+                               open("/proc/stb/video/videomode", "w").write(mode_50)
+                       except IOError:
+                               print "cannot open /proc/stb/vide/videomode"
+               
+               self.changedAspect(None)
+       
+       # autoresolution depend on this.
+       def setMode(self, port, mode, rate):
+               self.setVideomode(port, mode, rate)
+       
+       def changedAspect(self, configElement):
+               if self.is_init:
+                       return
+               # config.av.aspect:
+               #       4:3                     use policy_169
+               #       16:9, 16:10     use policy_43
+               #       auto            always "bestfit"
+               # config.av.policy_169:
+               #       letterbox       use letterbox
+               #       panscan         use panscan
+               #       scale           use bestfit
+               # config.av.policy_43:
+               #       pillarbox       use panscan
+               #       pansca          use letterbox ("panscan" is just a bad term, it is inverse-panscan)
+               #       nonlinear       use nonlinear
+               #       scale           use bestfit
 
                port = config.av.videoport.value
                if port not in config.av.videomode:
 
                port = config.av.videoport.value
                if port not in config.av.videomode:
-                       print "current port not available, not setting videomode"
+                       print "current port not available. couldn't set aspect"
                        return
                        return
-               mode = config.av.videomode[port].value
 
 
-               force_widescreen = self.isWidescreenMode(port, mode)
+               mode = config.av.videomode[port].value
+               force_wide = self.isWidescreenMode(mode)
+               valstr = config.av.aspect.value
 
 
-               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
 
                policy2 = "policy" # use main policy
 
-               if is_widescreen:
-                       if force_widescreen:
+               if force_wide or valstr == "16_9" or valstr == "16_10":
+                       if force_wide or valstr == "16_9":
                                aspect = "16:9"
                                aspect = "16:9"
-                       else:
-                               aspect = {"16_9": "16:9", "16_10": "16:10"}[config.av.aspect.value]
+                       elif valstr == "16_10":
+                               aspect = "16:10"
+
                        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]
                        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:
+               elif valstr == "auto":
                        aspect = "any"
                        aspect = "any"
-                       policy = "bestfit"
+                       policy = "bestfit" 
                else:
                        aspect = "4:3"
                        policy = {"letterbox": "letterbox", "panscan": "panscan", "scale": "bestfit"}[config.av.policy_169.value]
                else:
                        aspect = "4:3"
                        policy = {"letterbox": "letterbox", "panscan": "panscan", "scale": "bestfit"}[config.av.policy_169.value]
@@ -322,7 +358,11 @@ class VideoHardware:
                else:
                        wss = "auto"
 
                else:
                        wss = "auto"
 
-               print "-> setting aspect, policy, policy2, wss", aspect, policy, policy2, wss
+               self.setAspect(aspect, policy, policy2, wss)
+
+       def setAspect(self, aspect, policy, policy2, wss):
+               print "set 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)
                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)
@@ -330,7 +370,25 @@ class VideoHardware:
                        open("/proc/stb/video/policy2", "w").write(policy2)
                except IOError:
                        pass
                        open("/proc/stb/video/policy2", "w").write(policy2)
                except IOError:
                        pass
+       
+       def isPortUsed(self, port):
+               if port == "DVI":
+                       self.readPreferredModes()
+                       return len(self.modes_preferred) != 0
+               else:
+                       return True
+       
+       def saveVideomode(self, port, mode, rate):
+               print "save Videomode", port, mode, rate
+               config.av.videoport.value = port
+               config.av.videoport.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()
 
 
-config.av.edid_override = ConfigYesNo(default = False)
 video_hw = VideoHardware()
 video_hw.setConfiguredMode()
 video_hw = VideoHardware()
 video_hw.setConfiguredMode()
+
old mode 100755 (executable)
new mode 100644 (file)
index 18e8176..97038e9
 from Screens.Wizard import WizardSummary
 from Screens.WizardLanguage import WizardLanguage
 from Screens.Rc import Rc
 from Screens.Wizard import WizardSummary
 from Screens.WizardLanguage import WizardLanguage
 from Screens.Rc import Rc
-from VideoHardware import video_hw
-
-from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
-from Components.config import config, ConfigBoolean, configfile
-
+from Components.Pixmap import Pixmap
+from Components.config import config, configfile, ConfigBoolean
 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
-from Tools.HardwareInfo import HardwareInfo
 
 
-config.misc.showtestcard = ConfigBoolean(default = False)
+from VideoHardware import video_hw
 
 
-class VideoWizardSummary(WizardSummary):
-       skin = (
-       """<screen name="VideoWizardSummary" position="0,0" size="132,64" id="1">
-               <widget name="text" position="6,4" size="120,40" font="Regular;12" transparent="1" />
-               <widget source="parent.list" render="Label" position="6,40" size="120,21" font="Regular;14">
-                       <convert type="StringListSelection" />
-               </widget>
-               <!--widget name="pic" pixmap="%s" position="6,22" zPosition="10" size="64,64" transparent="1" alphatest="on"/-->
-       </screen>""",
-       """<screen name="VideoWizardSummary" position="0,0" size="96,64" id="2">
-               <widget name="text" position="0,4" size="96,40" font="Regular;12" transparent="1" />
-               <widget source="parent.list" render="Label" position="0,40" size="96,21" font="Regular;14">
-                       <convert type="StringListSelection" />
-               </widget>
-               <!--widget name="pic" pixmap="%s" position="0,22" zPosition="10" size="64,64" transparent="1" alphatest="on"/-->
-       </screen>""")
-       #% (resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/lcd_Scart.png"))
-       
-       def __init__(self, session, parent):
-               WizardSummary.__init__(self, session, parent)
-               #self["pic"] = Pixmap()
-               
-       def setLCDPicCallback(self):
-               self.parent.setLCDTextCallback(self.setText)
-               
-       def setLCDPic(self, file):
-               self["pic"].instance.setPixmapFromFile(file)
+config.misc.showtestcard = ConfigBoolean(default = False)
 
 class VideoWizard(WizardLanguage, Rc):
        skin = """
 
 class VideoWizard(WizardLanguage, Rc):
        skin = """
-               <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
+               <screen name="VideoWizard" position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
                        <widget name="text" position="153,50" size="340,270" font="Regular;23" />
                        <widget name="text" position="153,50" size="340,270" font="Regular;23" />
-                       <widget source="list" render="Listbox" position="200,300" size="290,200" scrollbarMode="showOnDemand" >
+                       <widget source="list" render="Listbox" position="50,300" size="440,200" scrollbarMode="showOnDemand" >
                                <convert type="StringList" />
                        </widget>
                                <convert type="StringList" />
                        </widget>
-                       <widget name="config" position="50,300" zPosition="1" size="440,200" transparent="1" scrollbarMode="showOnDemand" />
-                       <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
-                       <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
+                       <widget name="config" position="50,300" size="440,200" scrollbarMode="showOnDemand" zPosition="1" transparent="1" />
+                       <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" size="15,16" alphatest="on" />
                        <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
                        <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
-                       <widget name="portpic" pixmap="%s" position="50,300" zPosition="10" size="150,150" transparent="1" alphatest="on"/>
-                       <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="500,50" zPosition="10" size="154,500" transparent="1" alphatest="on"/>
-                       <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
-                       <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
-                       <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
-                       <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
-               </screen>""" % (resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/Scart.png"))
-       
+                       <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on"/>
+                       <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="500,50" zPosition="10" size="154,500" alphatest="on"/>
+                       <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on"/>
+                       <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on"/>
+                       <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on"/>
+                       <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on"/>
+               </screen>
+       """
+
        def __init__(self, session):
        def __init__(self, session):
-               # FIXME anyone knows how to use relative paths from the plugin's directory?
                self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/videowizard.xml")
                self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/videowizard.xml")
-               self.hw = video_hw
-               
-               WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
+               self.video_cfg = video_hw
+
+               WizardLanguage.__init__(self, session)
                Rc.__init__(self)
                Rc.__init__(self)
+
                self["wizard"] = Pixmap()
                self["portpic"] = Pixmap()
                self["wizard"] = Pixmap()
                self["portpic"] = Pixmap()
-               
+
                self.port = None
                self.mode = None
                self.rate = None
                self.port = None
                self.mode = None
                self.rate = None
-               
-               
+       
        def createSummary(self):
        def createSummary(self):
-               print "++++++++++++***++**** VideoWizard-createSummary"
                from Screens.Wizard import WizardSummary
                from Screens.Wizard import WizardSummary
-               return VideoWizardSummary
-               
+               return WizardSummary 
+       
        def markDone(self):
        def markDone(self):
-               config.misc.videowizardenabled.value = 0
+               config.misc.videowizardenabled.setValue(False)
                config.misc.videowizardenabled.save()
                configfile.save()
        
                config.misc.videowizardenabled.save()
                configfile.save()
        
-       def listInputChannels(self):
-               hw_type = HardwareInfo().get_device_name()
-               list = []
-
-               for port in self.hw.getPortList():
-                       if self.hw.isPortUsed(port):
-                               descr = port
-                               if descr == 'DVI' and hw_type in ('dm500hd', 'dm800se', 'dm7020hd'):
-                                       descr = 'HDMI'
+       def portList(self):
+               hw_type = self.video_cfg.getDeviceName()
+               list = [ ]
+
+               for port in self.video_cfg.getPortList():
+                       if self.video_cfg.isPortUsed(port):
+                               desc = port
+                               if desc == "DVI" and self.video_cfg.isHDMIAvailable(hw_type):
+                                       desc = "HDMI"
+                               
                                if port != "DVI-PC":
                                if port != "DVI-PC":
-                                       list.append((descr,port))
+                                       list.append( (desc, port))
+
                list.sort(key = lambda x: x[0])
                list.sort(key = lambda x: x[0])
-               print "listInputChannels:", list
                return list
 
                return list
 
-       def inputSelectionMade(self, index):
-               print "inputSelectionMade:", index
+       def portSelectionMade(self, index):
                self.port = index
                self.port = index
-               self.inputSelect(index)
-               
-       def inputSelectionMoved(self):
-               print "input selection moved:", self.selection
-               self.inputSelect(self.selection)
-               if self["portpic"].instance is not None:
-                       picname = self.selection
-                       if picname == "DVI" and HardwareInfo().get_device_name() in ("dm500hd", "dm800se", "dm7020hd"):
-                               picname = "HDMI"
-                       self["portpic"].instance.setPixmapFromFile(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/" + picname + ".png"))
-               
-       def inputSelect(self, port):
-               print "inputSelect:", port
-               modeList = self.hw.getModeList(self.selection)
-               print "modeList:", modeList
-               self.port = port
-               if (len(modeList) > 0):
-                       ratesList = self.listRates(modeList[0][0])
-                       self.hw.setMode(port = port, mode = modeList[0][0], rate = ratesList[0][0])
+               self.video_cfg.setVideomode(self.port, self.mode, self.rate)
+       
+       def portSelectionMoved(self):
+               self.video_cfg.setVideomode(self.selection, self.mode, self.rate)
+
+       def modeList(self):
+               list = [ ]
+               for mode in self.video_cfg.getModeList(self.port):
+                       list.append( (mode, mode))
                
                
-       def listModes(self):
-               list = []
-               print "modes for port", self.port
-               for mode in self.hw.getModeList(self.port):
-                       #if mode[0] != "PC":
-                               list.append((mode[0], mode[0]))
-               print "modeslist:", list
                return list
                return list
-       
+
        def modeSelectionMade(self, index):
        def modeSelectionMade(self, index):
-               print "modeSelectionMade:", index
                self.mode = index
                self.mode = index
-               self.modeSelect(index)
-               
+               self.modeSelect(self.mode)
+       
        def modeSelectionMoved(self):
        def modeSelectionMoved(self):
-               print "mode selection moved:", self.selection
                self.modeSelect(self.selection)
                self.modeSelect(self.selection)
-               
+       
        def modeSelect(self, mode):
        def modeSelect(self, mode):
-               ratesList = self.listRates(mode)
-               print "ratesList:", ratesList
-               if self.port == "DVI" and mode in ("720p", "1080i"):
+               if self.port == "DVI" and self.video_cfg.isWidescreenMode(mode):
                        self.rate = "multi"
                        self.rate = "multi"
-                       self.hw.setMode(port = self.port, mode = mode, rate = "multi")
                else:
                else:
-                       self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0])
-       
-       def listRates(self, querymode = None):
-               if querymode is None:
-                       querymode = self.mode
-               list = []
-               print "modes for port", self.port, "and mode", querymode
-               for mode in self.hw.getModeList(self.port):
-                       print mode
-                       if mode[0] == querymode:
-                               for rate in mode[1]:
-                                       if self.port == "DVI-PC":
-                                               print "rate:", rate
-                                               if rate == "640x480":
-                                                       list.insert(0, (rate, rate))
-                                                       continue
-                                       list.append((rate, rate))
+                       self.rate = None
+               self.video_cfg.setVideomode(self.port, mode, self.rate)
+
+       def rateList(self):
+               list = [ ]
+               for rate in self.video_cfg.getRateList(self.port, self.mode):
+                       list.append( (rate, rate))
+               
                return list
                return list
-       
+
        def rateSelectionMade(self, index):
        def rateSelectionMade(self, index):
-               print "rateSelectionMade:", index
                self.rate = index
                self.rate = index
-               self.rateSelect(index)
-               
+               self.video_cfg.setVideomode(self.port, self.mode, self.rate)
+       
        def rateSelectionMoved(self):
        def rateSelectionMoved(self):
-               print "rate selection moved:", self.selection
-               self.rateSelect(self.selection)
+               self.video_cfg.setVideomode(self.port, self.mode, self.selection)
 
 
-       def rateSelect(self, rate):
-               self.hw.setMode(port = self.port, mode = self.mode, rate = rate)
-
-       def showTestCard(self, selection = None):
+       def showVideoTune(self, selection = None):
                if selection is None:
                        selection = self.selection
                if selection is None:
                        selection = self.selection
-               print "set config.misc.showtestcard to", {'yes': True, 'no': False}[selection]
+
                if selection == "yes":
                        config.misc.showtestcard.value = True
                else:
                        config.misc.showtestcard.value = False
 
                if selection == "yes":
                        config.misc.showtestcard.value = True
                else:
                        config.misc.showtestcard.value = False
 
-       def keyNumberGlobal(self, number):
-               if number in (1,2,3):
-                       if number == 1:
-                               self.hw.saveMode("DVI", "720p", "multi")
-                       elif number == 2:
-                               self.hw.saveMode("DVI", "1080i", "multi")
-                       elif number == 3:
-                               self.hw.saveMode("Scart", "Multi", "multi")
-                       self.hw.setConfiguredMode()
-                       self.close()
-
-               WizardLanguage.keyNumberGlobal(self, number)
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/YPbPr.png b/lib/python/Plugins/SystemPlugins/Videomode/YPbPr.png
deleted file mode 100644 (file)
index 884e650..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/YPbPr.png and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/lcd_DVI.png b/lib/python/Plugins/SystemPlugins/Videomode/lcd_DVI.png
deleted file mode 100644 (file)
index f6fb7b7..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/lcd_DVI.png and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png b/lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png
deleted file mode 100644 (file)
index 425da5c..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/lcd_Scart.png b/lib/python/Plugins/SystemPlugins/Videomode/lcd_Scart.png
deleted file mode 100644 (file)
index bab5cf0..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/lcd_Scart.png and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/lcd_YPbPr.png b/lib/python/Plugins/SystemPlugins/Videomode/lcd_YPbPr.png
deleted file mode 100644 (file)
index cfa8b10..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/lcd_YPbPr.png and /dev/null differ
old mode 100755 (executable)
new mode 100644 (file)
index ddcc18c..e124250
@@ -1,5 +1,3 @@
 installdir = $(datadir)/meta
 
 dist_install_DATA = plugin_videomode.xml
 installdir = $(datadir)/meta
 
 dist_install_DATA = plugin_videomode.xml
-
-EXTRA_DIST = videomode_en.jpg videomode_de.jpg
old mode 100755 (executable)
new mode 100644 (file)
index e16a7dc..79aa980
@@ -1,19 +1,16 @@
 <default>
 <default>
-         <prerequisites>
-                    <tag type="Display" />
-                    <tag type="System" />
-         </prerequisites>
-          <info>
-                    <author>Dream Multimedia</author>
-                    <name>Videomode</name>
-                    <packagename>enigma2-plugin-systemplugins-videomode</packagename>
-                    <shortdescription>Videomode provides advanced video mode settings</shortdescription>
-                    <description>The Videomode plugin provides advanced video mode settings.</description>
-                    <screenshot src="http://www.dreamboxupdate.com/preview/plugin_videomode_en.jpg" />
-          </info>
-
-         <files type="package"> <!-- without version, without .ipk -->
+       <prerequisites>
+               <tag type="Display" />
+               <tag type="System" />
+       </prerequisites>
+       <info>
+               <author>smlee</author>
+               <name>Videomode K</name>
+               <packagename>enigma2-plugin-systemplugins-videomode</packagename>
+               <shortdescription>advanced video mode settings.</shortdescription>
+               <description>With Videomode K plugin, you can set advanced video mode.</description>
+       </info>
+       <files type="package">
                <file type="package" name="enigma2-plugin-systemplugins-videomode" />
        </files>
                <file type="package" name="enigma2-plugin-systemplugins-videomode" />
        </files>
-
 </default>
 </default>
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_de.jpg b/lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_de.jpg
deleted file mode 100755 (executable)
index 00b7ac7..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_de.jpg and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_en.jpg b/lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_en.jpg
deleted file mode 100755 (executable)
index 1f4288b..0000000
Binary files a/lib/python/Plugins/SystemPlugins/Videomode/meta/videomode_en.jpg and /dev/null differ
index e7805fc..74cec11 100644 (file)
 from Screens.Screen import Screen
 from Screens.Screen import Screen
-from Plugins.Plugin import PluginDescriptor
-from Components.SystemInfo import SystemInfo
 from Components.ConfigList import ConfigListScreen
 from Components.ConfigList import ConfigListScreen
-from Components.config import getConfigListEntry, config, ConfigBoolean, ConfigNothing, ConfigSlider
+from Components.ActionMap import NumberActionMap
+from Components.config import config, ConfigNothing, ConfigBoolean, getConfigListEntry
 from Components.Sources.StaticText import StaticText
 from Components.Sources.StaticText import StaticText
+from Components.SystemInfo import SystemInfo
+from Plugins.Plugin import PluginDescriptor
 
 from VideoHardware import video_hw
 
 config.misc.videowizardenabled = ConfigBoolean(default = True)
 
 
 from VideoHardware import video_hw
 
 config.misc.videowizardenabled = ConfigBoolean(default = True)
 
-class VideoSetup(Screen, ConfigListScreen):
+class avSetupScreen(ConfigListScreen, Screen):
+       avSetupItems = [
+               {"idx":1, "level":0, "text":"Video Output", "item":config.av.videoport},
+               {"idx":2, "level":0, "text":"Mode", "item":config.av.videomode[config.av.videoport.value]},
+               {"idx":3, "level":0, "text":"Refresh Rate", "item":config.av.videorate[config.av.videomode[config.av.videoport.value].value]},
+               {"idx":4, "level":0, "text":"Aspect Ratio", "item":config.av.aspect},
+               {"idx":5, "level":0, "text":"Display 4:3 content as", "item":config.av.policy_43},
+               {"idx":6, "level":0, "text":"Display > 16:9 content as", "item":config.av.policy_169},
+               {"idx":7, "level":0, "text":"Color Format", "item":config.av.colorformat},
+               {"idx":8, "level":1, "text":"WSS on 4:3", "item":config.av.wss},
+               {"idx":9, "level":1, "text":"Auto scart switching", "requires":"ScartSwitch", "item":config.av.vcrswitch},
+               {"idx":0, "level":1, "text":"Dolby Digital default", "item":config.av.defaultac3},
+               {"idx":0, "level":1, "text":"Dolby Digital downmix", "requires":"CanDownmixAC3", "item":config.av.downmix_ac3},
+               {"idx":0, "level":1, "text":"General Dolby Digital delay(ms)", "item":config.av.generalAC3delay},
+               {"idx":0, "level":1, "text":"General PCM delay(ms)", "item":config.av.generalPCMdelay},
+               {"idx":0, "level":0, "text":"OSD visibility", "requires":"CanChangeOsdAlpha", "item":config.av.osd_alpha},
+               {"idx":0, "level":0, "text":"Scaler sharpness", "item":config.av.scaler_sharpness},
+       ]
 
 
-       def __init__(self, session, hw):
+       def __init__(self, session):
                Screen.__init__(self, session)
                Screen.__init__(self, session)
-               # for the skin: first try VideoSetup, then Setup, this allows individual skinning
-               self.skinName = ["VideoSetup", "Setup" ]
+               # for the skin: first try a setup_avsetup, then Setup
+               self.skinName = ["setup_avsetup", "Setup"]
                self.setup_title = _("A/V Settings")
                self.setup_title = _("A/V Settings")
-               self.hw = hw
+
+               self.video_cfg = video_hw
+               self.audio_cfg = [ ]
+
                self.onChangedEntry = [ ]
 
                self.onChangedEntry = [ ]
 
-               # handle hotplug by re-creating setup
+               # handle hotplug by re-createing setup
                self.onShow.append(self.startHotplug)
                self.onHide.append(self.stopHotplug)
 
                self.list = [ ]
                self.onShow.append(self.startHotplug)
                self.onHide.append(self.stopHotplug)
 
                self.list = [ ]
-               ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
 
 
-               from Components.ActionMap import ActionMap
-               self["actions"] = ActionMap(["SetupActions"], 
+               self["key_red"] = StaticText( _("Cancel"))
+               self["key_green"] = StaticText( _("OK"))
+
+               self["action"] = NumberActionMap(["SetupActions"],
                        {
                                "cancel": self.keyCancel,
                        {
                                "cancel": self.keyCancel,
-                               "save": self.apply,
+                               "save": self.keySave,
                        }, -2)
 
                        }, -2)
 
-               self["key_red"] = StaticText(_("Cancel"))
-               self["key_green"] = StaticText(_("OK"))
+               ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
+               
+               self.createScreen()
 
 
-               self.createSetup()
-               self.grabLastGoodMode()
                self.onLayoutFinish.append(self.layoutFinished)
                self.onLayoutFinish.append(self.layoutFinished)
-
+       
        def layoutFinished(self):
                self.setTitle(self.setup_title)
        def layoutFinished(self):
                self.setTitle(self.setup_title)
-
-       def startHotplug(self):
-               self.hw.on_hotplug.append(self.createSetup)
-
-       def stopHotplug(self):
-               self.hw.on_hotplug.remove(self.createSetup)
-
-       def createSetup(self):
-               level = config.usage.setup_level.index
-
-               self.list = [
-                       getConfigListEntry(_("Video Output"), config.av.videoport)
-               ]
-
-               # if we have modes for this port:
-               if config.av.videoport.value in config.av.videomode:
-                       # add mode- and rate-selection:
-                       self.list.append(getConfigListEntry(_("Mode"), config.av.videomode[config.av.videoport.value]))
-                       if config.av.videomode[config.av.videoport.value].value == 'PC':
-                               self.list.append(getConfigListEntry(_("Resolution"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
-                       else:
-                               self.list.append(getConfigListEntry(_("Refresh Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
-
-               port = config.av.videoport.value
-               if port not in config.av.videomode:
-                       mode = None
-               else:
-                       mode = config.av.videomode[port].value
-
-               # some modes (720p, 1080i) are always widescreen. Don't let the user select something here, "auto" is not what he wants.
-               force_wide = self.hw.isWidescreenMode(port, mode)
-
-               if not force_wide:
-                       self.list.append(getConfigListEntry(_("Aspect Ratio"), config.av.aspect))
-
-               if force_wide or config.av.aspect.value in ("16_9", "16_10"):
-                       self.list.extend((
-                               getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43),
-                               getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169)
-                       ))
-               elif config.av.aspect.value == "4_3":
-                       self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_169))
-
-#              if config.av.videoport.value == "DVI":
-#                      self.list.append(getConfigListEntry(_("Allow Unsupported Modes"), config.av.edid_override))
-               if config.av.videoport.value == "Scart":
-                       self.list.append(getConfigListEntry(_("Color Format"), config.av.colorformat))
-                       if level >= 1:
-                               self.list.append(getConfigListEntry(_("WSS on 4:3"), config.av.wss))
-                               if SystemInfo["ScartSwitch"]:
-                                       self.list.append(getConfigListEntry(_("Auto scart switching"), config.av.vcrswitch))
-
-               if level >= 1:
-                       self.list.append(getConfigListEntry(_("Dolby Digital default"), config.av.defaultac3))
-                       if SystemInfo["CanDownmixAC3"]:
-                               self.list.append(getConfigListEntry(_("Dolby Digital downmix"), config.av.downmix_ac3))
-                       self.list.extend((
-                               getConfigListEntry(_("General Dolby Digital Delay"), config.av.generalAC3delay),
-                               getConfigListEntry(_("General PCM Delay"), config.av.generalPCMdelay)
-                       ))
-
-               if SystemInfo["CanChangeOsdAlpha"]:
-                       self.list.append(getConfigListEntry(_("OSD visibility"), config.av.osd_alpha))
-
-               if not isinstance(config.av.scaler_sharpness, ConfigNothing):
-                       self.list.append(getConfigListEntry(_("Scaler sharpness"), config.av.scaler_sharpness))
-
-               self["config"].list = self.list
-               self["config"].l.setList(self.list)
-
-       def keyLeft(self):
-               ConfigListScreen.keyLeft(self)
-               self.createSetup()
-
-       def keyRight(self):
-               ConfigListScreen.keyRight(self)
-               self.createSetup()
-
-       def confirm(self, confirmed):
-               if not confirmed:
-                       config.av.videoport.value = self.last_good[0]
-                       config.av.videomode[self.last_good[0]].value = self.last_good[1]
-                       config.av.videorate[self.last_good[1]].value = self.last_good[2]
-                       self.hw.setMode(*self.last_good)
-               else:
-                       self.keySave()
-
-       def grabLastGoodMode(self):
-               port = config.av.videoport.value
-               mode = config.av.videomode[port].value
-               rate = config.av.videorate[mode].value
-               self.last_good = (port, mode, rate)
-
-       def apply(self):
-               port = config.av.videoport.value
-               mode = config.av.videomode[port].value
-               rate = config.av.videorate[mode].value
-               if (port, mode, rate) != self.last_good:
-                       self.hw.setMode(port, mode, rate)
-                       from Screens.MessageBox import MessageBox
-                       self.session.openWithCallback(self.confirm, MessageBox, _("Is this videomode ok?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
-               else:
-                       self.keySave()
-
+       
        # for summary:
        def changedEntry(self):
                for x in self.onChangedEntry:
                        x()
        # for summary:
        def changedEntry(self):
                for x in self.onChangedEntry:
                        x()
-
+       
        def getCurrentEntry(self):
                return self["config"].getCurrent()[0]
 
        def getCurrentEntry(self):
                return self["config"].getCurrent()[0]
 
@@ -160,75 +78,116 @@ class VideoSetup(Screen, ConfigListScreen):
        def createSummary(self):
                from Screens.Setup import SetupSummary
                return SetupSummary
        def createSummary(self):
                from Screens.Setup import SetupSummary
                return SetupSummary
+       
+       def createScreen(self):
+               self.list = [ ]
+               self.audio_cfg = [ ]
+
+               for x in self.avSetupItems:
+                       item_level = int(x.get("level", 0))
+                       if item_level > config.usage.setup_level.index:
+                               continue
+
+                       requires = x.get("requires")
+                       if requires and not SystemInfo.get(requires, False):
+                               continue
+
+                       item_text = _(x.get("text", "??").encode("UTF-8"))
+
+                       item = x.get("item", None)
+                       if item is None:
+                               continue
+
+                       idx = x.get("idx", 0)
+                       if idx > 0:
+                               if idx == 1: # Video Output
+                                       current_port = item.value
+                               elif idx == 2: # Mode
+                                       item = config.av.videomode[current_port]
+                                       current_mode = item.value
+                                       # some modes (720p, 1080i, 1080p) are always widescreen.
+                                       force_wide = self.video_cfg.isWidescreenMode(current_mode)
+                               elif idx == 3: # Refresh Rate
+                                       item = config.av.videorate[current_mode]
+                                       current_rate = item.value
+                                       if current_mode == "PC":
+                                               item_text = _("Resolution")
+                               elif idx == 4: # Aspect Ratio
+                                       current_aspect = item.value
+                                       if force_wide:
+                                               continue
+                               elif idx == 5: # Display 4:3 content as
+                                       if current_aspect == "auto" and not force_wide:
+                                               continue
+                                       elif current_aspect == "4_3":
+                                               continue
+                               elif idx == 6: # Display 16:9 > content as
+                                       if current_aspect == "auto" and not force_wide:
+                                               continue
+                               # Color Format, WSS on 4:3, Auto scart switching
+                               elif (idx == 7 or idx == 8 or idx == 9) and not current_port == "Scart":
+                                       continue
+                       if idx == 0 and item_level == 1: # audio
+                               self.audio_cfg.append(item_text)
+
+                       # add to configlist
+                       if not isinstance(item, ConfigNothing):
+                               self.list.append(getConfigListEntry(item_text, item))
+
+               self["config"].setList(self.list)
+       
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.createScreen()
+               # show current value on VFD
+               if self.getCurrentEntry() not in self.audio_cfg:
+                       self.summaries[0]["SetupTitle"].text = self.getCurrentValue()
+       
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.createScreen()
+               # show current value on VFD
+               if self.getCurrentEntry() not in self.audio_cfg:
+                       self.summaries[0]["SetupTitle"].text = self.getCurrentValue()
 
 
-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 startHotplug(self):
+               self.video_cfg.on_hotplug.append(self.createScreen)
 
 
-def autostart(reason, session = None, **kwargs):
-       if session is not None:
-               global my_global_session
-               my_global_session = session
-               return
+       def stopHotplug(self):
+               self.video_cfg.on_hotplug.remove(self.createScreen)
 
 
-       if reason == 0:
-               startHotplug()
-       elif reason == 1:
-               stopHotplug()
 
 
-def videoSetupMain(session, **kwargs):
-       session.open(VideoSetup, video_hw)
+def avSetupMain(session, **kwargs):
+       session.open(avSetupScreen)
 
 
-def startSetup(menuid):
-       if menuid != "system": 
-               return [ ]
+def startAVsetup(menuid):
+       if menuid != "system":
+               return []
 
 
-       return [(_("A/V Settings"), videoSetupMain, "av_setup", 40)]
+       return [( _("A/V Settings"), avSetupMain, "av_setup", 40)]
 
 
-def VideoWizard(*args, **kwargs):
+def startVideoWizard(*args, **kwargs):
        from VideoWizard import VideoWizard
        return VideoWizard(*args, **kwargs)
 
 def Plugins(**kwargs):
        from VideoWizard import VideoWizard
        return VideoWizard(*args, **kwargs)
 
 def Plugins(**kwargs):
-       list = [
-#              PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
-               PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=startSetup) 
+       plugin_list = [ 
+               PluginDescriptor(
+                       name = "Videomode-K",
+                       description = "Videomode-K based videomode",
+                       where = PluginDescriptor.WHERE_MENU,
+                       needsRestart = False,
+                       fnc = startAVsetup)
        ]
        ]
+
        if config.misc.videowizardenabled.value:
        if config.misc.videowizardenabled.value:
-               list.append(PluginDescriptor(name=_("Video Wizard"), where = PluginDescriptor.WHERE_WIZARD, needsRestart = False, fnc=(0, VideoWizard)))
-       return list
+               plugin_list.append(
+                       PluginDescriptor(
+                               name = "Video Wizard",
+                               where = PluginDescriptor.WHERE_WIZARD,
+                               fnc=(0, startVideoWizard)
+                       )
+               )
+       
+       return plugin_list
+
index 5dea661..84b1e62 100644 (file)
 <wizard>
 <wizard>
-       <step id="inputselection" nextstep="modeselection" timeout="20" timeoutaction="selectnext">
-               <text value="Video input selection\n\nPlease press OK if you can see this page on your TV (or select a different input port).\n\nThe next input port will be automatically probed in 10 seconds." />
-               <displaytext value="Select video input with up/down buttons" />
-               <list type="dynamic" source="listInputChannels" evaluation="inputSelectionMade" onselect="inputSelectionMoved" />
+       <step id="portselection" nextstep="modeselection" timeout="20" timeoutaction="selectnext">
+               <text value="Video input selection\n\nPlease press OK if you can see this page on your TV or select a different input port.\n\nThe next input port will be automatically probed in 20 seconds" />
+               <displaytext value="Select video port" />
+               <list type="dynamic" source="portList" evaluation="portSelectionMade" onselect="portSelectionMoved" />
                <code>
                <code>
-self["portpic"].show()
 self.clearSelectedKeys()
 self.selectKey("OK")
                </code>
        </step>
        <step id="modeselection" nextstep="rateselection" timeout="20" timeoutaction="selectnext">
 self.clearSelectedKeys()
 self.selectKey("OK")
                </code>
        </step>
        <step id="modeselection" nextstep="rateselection" timeout="20" timeoutaction="selectnext">
-               <text value="Video mode selection." />
+               <text value="Video mode selection" />
                <displaytext value="Select video mode" />
                <displaytext value="Select video mode" />
-               <list type="dynamic" source="listModes" evaluation="modeSelectionMade" onselect="modeSelectionMoved" />
+               <list type="dynamic" source="modeList" evaluation="modeSelectionMade" onselect="modeSelectionMoved" />
                <code>
 self.clearSelectedKeys()
 self.selectKey("UP")
 self.selectKey("DOWN")
                <code>
 self.clearSelectedKeys()
 self.selectKey("UP")
 self.selectKey("DOWN")
-self["portpic"].hide()
                </code>
        </step>
        <step id="rateselection" nextstep="end" timeout="20" timeoutaction="selectnext">
                <condition>
                </code>
        </step>
        <step id="rateselection" nextstep="end" timeout="20" timeoutaction="selectnext">
                <condition>
-self.condition = (self.port != "DVI" or self.mode == "PC")
-               </condition>            
-               <text value="Refresh rate selection." />
-               <displaytext value="Select refresh rate" />
-               <list type="dynamic" source="listRates" evaluation="rateSelectionMade" onselect="rateSelectionMoved" />
-               <code>
-self.clearSelectedKeys()
-self.selectKey("UP")
-self.selectKey("DOWN")
-               </code>
-       </step>
-       <!--step id="dvirateintroduction" nextstep="dvirateselection">
-               <condition>
-self.condition = (self.port == "DVI" and self.mode in ["720p", "1080i"])
-               </condition>
-               <text value="We will now test if your TV can also display this resolution at 50hz. If your screen goes black, wait 20 seconds and it will switch back to 60hz.\nPlease press OK to begin." />
-               <displaytext value="Please follow the instructions on the TV" />
-               <code>
-self.clearSelectedKeys()
-self.selectKey("UP")
-self.selectKey("DOWN")
-self.rateSelect("60Hz")
-               </code>
-       </step>
-       <step id="dvirateselection" timeout="20" timeoutaction="changestep" timeoutstep="notworking50Hz">
-               <condition>
-self.condition = (self.port == "DVI" and self.mode in ["720p", "1080i"])
+self.condition = (self.port != "DVI")
                </condition>
                </condition>
-               <text value="If you can see this page, please press OK." />
-               <displaytext value="" />
-               <list>
-                       <listentry caption="50 Hz" step="working50Hz" />
-               </list>
-               <code>
-self.clearSelectedKeys()
-self.selectKey("UP")
-self.selectKey("DOWN")
-self.rateSelect("50Hz")
-               </code>
-               <code pos="after">
-self.rateSelect("60Hz")                        
-               </code>
-       </step>
-       <step id="notworking50Hz" nextstep="end">
-               <condition>
-self.condition = (self.port == "DVI" and self.mode in ["720p", "1080i"])
-               </condition>
-               <text value="No 50 Hz, sorry. :(" />
-               <displaytext value="" />
+               <text value="Refresh rate selection" />
+               <displaytext value="Select refresh rate" />
+               <list type="dynamic" source="rateList" evaluation="rateSelectionMade" onselect="rateSelectionMoved" />
                <code>
 self.clearSelectedKeys()
 self.selectKey("UP")
 self.selectKey("DOWN")
                </code>
        </step>
                <code>
 self.clearSelectedKeys()
 self.selectKey("UP")
 self.selectKey("DOWN")
                </code>
        </step>
-       <step id="working50Hz" nextstep="end" timeout="20" timeoutaction="nextstep">
-               <condition>
-self.condition = (self.port == "DVI" and self.mode in ["720p", "1080i"])
-               </condition>
-               <text value="Your TV works with 50 Hz. Good!" />
-               <displaytext value="" />
-               <code>
-self.clearSelectedKeys()
-self.selectKey("UP")
-self.selectKey("DOWN")
-self.rateSelect("50Hz")
-               </code>
-       </step-->
        <step id="end">
                <code>
        <step id="end">
                <code>
-self.hw.saveMode(self.port, self.mode, self.rate)
+self.video_cfg.saveVideomode(self.port, self.mode, self.rate)
 from Components.config import configfile
 from Components.config import configfile
-configfile.save() 
+configfile.save()
                </code>
                </code>
-               <text value="The input port should be configured now.\nYou can now configure the screen by displaying some test pictures. Do you want to do that now?" />
-               <!--text value="You have successfully finished the video setup. If you want to change the settings later, you can do this in the settings menu."/-->
-               <displaytext value="No picture on TV? Press EXIT and retry." />
-               <list evaluation="showTestCard" onselect="showTestCard">
+               <text value="The input port should be configured now.\nYou can now configure the screen by displaying some test picture. Do you want to do that now?" />
+               <displaytext value="video tune" />
+               <list evaluation="showVideoTune" onselect="showVideoTune">
                        <listentry caption="Yes" step="yes" />
                        <listentry caption="No" step="no" />
                </list>
                        <listentry caption="Yes" step="yes" />
                        <listentry caption="No" step="no" />
                </list>
-               </step>
+       </step>
 </wizard>
 </wizard>