install_PYTHON = \
__init__.py \
- plugin.py
+ plugin.py \
+ VideoHardware.py \
+ VideoWizard.py \
+ videowizard.xml
--- /dev/null
+from Screens.Screen import Screen
+from Plugins.Plugin import PluginDescriptor
+
+from enigma import eTimer
+
+from Components.ActionMap import ActionMap
+from Components.Label import Label
+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 Tools.CList import CList
+
+# 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.
+class VideoHardware:
+ rates = { } # high-level, use selectable modes.
+
+ modes = { } # a list of (high-level) modes for a certain port.
+
+ rates["PAL"] = { "50Hz": { 50: "pal", 60: "pal"},
+ "60Hz": { 50: "pal60", 60: "pal60"},
+ "multi": { 50: "pal", 60: "pal60"} }
+ rates["NTSC"] = { "60Hz": { 50: "ntsc", 60: "ntsc"} }
+ rates["Multi"] = { "multi": { 50: "pal", 60: "ntsc"} }
+ rates["720p"] = { "50Hz": { 50: "720p50", 60: "720p50"},
+ "60Hz": { 50: "720p", 60: "720p"},
+ "multi": { 50: "720p50", 60: "720p"} }
+ rates["1080i"] = { "50Hz": { 50: "1080i50", 60: "1080i50"},
+ "60Hz": { 50: "1080i", 60: "1080i"},
+ "multi": { 50: "1080i50", 60: "1080i"} }
+ rates["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"},
+ "640x480" : { 60: "640x480"}
+ }
+
+ modes["Scart"] = ["PAL", "NTSC", "Multi"]
+ modes["YPrPb"] = ["720p", "1080i"]
+ modes["DVI"] = ["720p", "1080i", "PC"]
+
+ def __init__(self):
+ self.last_modes_preferred = [ ]
+ self.on_hotplug = CList()
+
+ self.on_hotplug.append(self.createConfig)
+ self.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)
+
+ def readAvailableModes(self):
+ try:
+ modes = open("/proc/stb/video/videomode_choices").read()[:-1]
+ except IOError:
+ print "couldn't read available videomodes."
+ 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:
+ print "reading preferred modes failed, using all modes"
+ self.modes_preferred = self.modes_available
+
+ if self.modes_preferred != self.last_modes_preferred:
+ self.last_modes_preferred = self.modes_preferred
+ 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):
+ 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 mode not in self.modes_available:
+ return False
+ return True
+
+ def setMode(self, port, mode, rate):
+ # 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:
+ mode_50 = mode_60
+ if mode_60 is None:
+ mode_60 = mode_50
+
+ try:
+ open("/proc/stb/video/videomode_60hz", "w").write(mode_50)
+ open("/proc/stb/video/videomode_50hz", "w").write(mode_60)
+ 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."
+
+ def isPortAvailable(self, port):
+ # fixme
+ return True
+
+ 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.
+ def getModeList(self, port):
+ res = [ ]
+ 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)]
+
+ # if at least one rate is ok, add this mode
+ if len(rates):
+ res.append( (mode, rates) )
+ return res
+
+ def createConfig(self, *args):
+ # create list of output ports
+ portlist = self.getPortList()
+
+ # create list of available modes
+ config.av.videoport = ConfigSelection(choices = [(port, _(port)) for port in portlist])
+ config.av.videomode = ConfigSubDict()
+ config.av.videorate = ConfigSubDict()
+
+ for port in portlist:
+ 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)
+
+video_hw = VideoHardware()
\ No newline at end of file
--- /dev/null
+from Screens.Wizard import Wizard, wizardManager
+import sys
+from VideoHardware import video_hw
+
+from Components.Pixmap import Pixmap, MovingPixmap
+from Components.config import config, ConfigBoolean, configfile
+
+class VideoWizard(Wizard):
+ skin = """
+ <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
+ <widget name="text" position="153,50" size="340,270" font="Regular;23" />
+ <widget source="list" render="Listbox" position="50,300" size="440,200" scrollbarMode="showOnDemand" >
+ <convert type="StringList" />
+ </widget>
+ <widget name="config" position="50,300" zPosition="1" size="440,200" transparent="1" scrollbarMode="showOnDemand" />
+ <widget name="stepslider" position="50,500" zPosition="1" borderWidth="2" size="440,20" backgroundColor="dark" />
+ <widget name="wizard" pixmap="wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
+ <widget name="rc" pixmap="rc.png" position="500,600" zPosition="10" size="154,475" transparent="1" alphatest="on"/>
+ <widget name="arrowdown" pixmap="arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
+ <widget name="arrowup" pixmap="arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
+ <widget name="arrowup2" pixmap="arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
+ </screen>"""
+
+ def __init__(self, session):
+ # FIXME anyone knows how to use relative paths from the plugin's directory?
+ self.xmlfile = sys.path[0] + "/Plugins/SystemPlugins/Videomode/videowizard.xml"
+ self.hw = video_hw
+
+ Wizard.__init__(self, session, showSteps = False)
+ self["wizard"] = Pixmap()
+ self["rc"] = MovingPixmap()
+ self["arrowdown"] = MovingPixmap()
+ self["arrowup"] = MovingPixmap()
+ self["arrowup2"] = MovingPixmap()
+
+ self.port = None
+ self.mode = None
+
+ def createSummary(self):
+ print "++++++++++++***++**** VideoWizard-createSummary"
+ from Screens.Wizard import WizardSummary
+ return WizardSummary
+
+ def markDone(self):
+ pass
+
+ def listInputChannels(self):
+ list = []
+
+ for port in self.hw.getPortList():
+ list.append((port, port))
+ return list
+
+ def inputSelectionMade(self, index):
+ print "inputSelectionMade:", index
+ self.port = index
+
+ def inputSelectionMoved(self):
+ print "selection moved:", self.selection
+
+ def listModes(self):
+ list = []
+ print "modes for port", self.port
+ for mode in self.hw.getModeList(self.port):
+ list.append((mode[0], mode[0]))
+ return list
+
+ def modeSelectionMade(self, index):
+ print "modeSelectionMade:", index
+ self.mode = index
+
+ def modeSelectionMoved(self):
+ print "selection moved:", self.selection
+
+ def listRates(self):
+ list = []
+ print "modes for port", self.port
+ for mode in self.hw.getModeList(self.port):
+ print mode
+ if mode[0] == self.mode:
+ for rate in mode[1]:
+ list.append((rate, rate))
+ return list
+
+ def rateSelectionMade(self, index):
+ print "rateSelectionMade:", index
+
+ def rateSelectionMoved(self):
+ print "selection moved:", self.selection
\ No newline at end of file
from Screens.Setup import SetupSummary
from Components.ConfigList import ConfigListScreen
from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict
+from VideoWizard import VideoWizard
+from Components.config import config
from Tools.CList import CList
-# 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.
-class VideoHardware:
- rates = { } # high-level, use selectable modes.
-
- modes = { } # a list of (high-level) modes for a certain port.
-
- rates["PAL"] = { "50Hz": { 50: "pal", 60: "pal"},
- "60Hz": { 50: "pal60", 60: "pal60"},
- "multi": { 50: "pal", 60: "pal60"} }
- rates["NTSC"] = { "60Hz": { 50: "ntsc", 60: "ntsc"} }
- rates["Multi"] = { "multi": { 50: "pal", 60: "ntsc"} }
- rates["720p"] = { "50Hz": { 50: "720p50", 60: "720p50"},
- "60Hz": { 50: "720p", 60: "720p"},
- "multi": { 50: "720p50", 60: "720p"} }
- rates["1080i"] = { "50Hz": { 50: "1080i50", 60: "1080i50"},
- "60Hz": { 50: "1080i", 60: "1080i"},
- "multi": { 50: "1080i50", 60: "1080i"} }
- rates["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"},
- "640x480" : { 60: "640x480"}
- }
-
- modes["Scart"] = ["PAL", "NTSC", "Multi"]
- modes["YPrPb"] = ["720p", "1080i"]
- modes["DVI"] = ["720p", "1080i", "PC"]
-
- def __init__(self):
- self.last_modes_preferred = [ ]
- self.on_hotplug = CList()
-
- self.on_hotplug.append(self.createConfig)
- self.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)
-
- def readAvailableModes(self):
- try:
- modes = open("/proc/stb/video/videomode_choices").read()[:-1]
- except IOError:
- print "couldn't read available videomodes."
- 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:
- print "reading preferred modes failed, using all modes"
- self.modes_preferred = self.modes_available
-
- if self.modes_preferred != self.last_modes_preferred:
- self.last_modes_preferred = self.modes_preferred
- 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):
- 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 mode not in self.modes_available:
- return False
- return True
-
- def setMode(self, port, mode, rate):
- # 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:
- mode_50 = mode_60
- if mode_60 is None:
- mode_60 = mode_50
-
- try:
- open("/proc/stb/video/videomode_60hz", "w").write(mode_50)
- open("/proc/stb/video/videomode_50hz", "w").write(mode_60)
- 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."
-
- def isPortAvailable(self, port):
- # fixme
- return True
-
- 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.
- def getModeList(self, port):
- res = [ ]
- 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)]
-
- # if at least one rate is ok, add this mode
- if len(rates):
- res.append( (mode, rates) )
- return res
-
- def createConfig(self, *args):
- # create list of output ports
- portlist = self.getPortList()
-
- # create list of available modes
- config.av.videoport = ConfigSelection(choices = [(port, _(port)) for port in portlist])
- config.av.videomode = ConfigSubDict()
- config.av.videorate = ConfigSubDict()
-
- for port in portlist:
- 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)
-
-video_hw = VideoHardware()
+from VideoHardware import video_hw
class VideoSetup(Screen, ConfigListScreen):
def __init__(self, session, hw):
return [(_("Video Setup"), videoSetupMain, "video_setup", None)]
def Plugins(**kwargs):
- return [
-# PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
- PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup)
- ]
+ list = []
+ list.append(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
--- /dev/null
+<wizard>
+ <step id="inputselection" nextstep="modeselection" timeout="10" timeoutaction="selectnext">
+ <text value="Video input selction\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" />
+ <list type="dynamic" source="listInputChannels" evaluation="inputSelectionMade" onselect="inputSelectionMoved" />
+ <code>
+self["arrowdown"].moveTo(557, 232, 1)
+self["arrowdown"].startMoving()
+self["arrowup"].moveTo(800, 232, 1)
+self["arrowup"].startMoving()
+self["rc"].moveTo(500, 50, 1)
+self["rc"].startMoving()
+ </code>
+ </step>
+ <step id="modeselection" nextstep="rateselection" timeout="10" timeoutaction="selectnext">
+ <text value="Video mode selection." />
+ <displaytext value="Select video mode" />
+ <list type="dynamic" source="listModes" evaluation="modeSelectionMade" onselect="modeSelectionMoved" />
+ <code>
+self["arrowup2"].moveTo(800, 320, 1)
+self["arrowup2"].startMoving()
+self["arrowdown"].moveTo(557, 200, 1)
+self["arrowup"].moveTo(557, 355, 1)
+self["arrowdown"].startMoving()
+self["arrowup"].startMoving()
+self["rc"].moveTo(500, 50, 1)
+self["rc"].startMoving()
+ </code>
+ </step>
+ <step id="rateselection" nextstep="end" timeout="10" timeoutaction="selectnext">
+ <text value="Rate selection." />
+ <displaytext value="Select video mode rate" />
+ <list type="dynamic" source="listRates" evaluation="rateSelectionMade" onselect="rateSelectionMoved" />
+ <code>
+self["arrowup2"].moveTo(800, 320, 1)
+self["arrowup2"].startMoving()
+self["arrowdown"].moveTo(557, 200, 1)
+self["arrowup"].moveTo(557, 355, 1)
+self["arrowdown"].startMoving()
+self["arrowup"].startMoving()
+self["rc"].moveTo(500, 50, 1)
+self["rc"].startMoving()
+ </code>
+ </step>
+ <step id="end">
+ <text value="The input port should be configured now." />
+ <displaytext value="No picture on TV? Press EXIT and retry." />
+ </step>
+</wizard>