fixes bug #436
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 4 Feb 2010 23:18:33 +0000 (00:18 +0100)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sat, 20 Feb 2010 16:14:32 +0000 (17:14 +0100)
add support for mixed nims

lib/python/Components/NimManager.py
lib/python/Screens/Satconfig.py

index 613305d..6650c71 100644 (file)
@@ -444,7 +444,7 @@ class SecConfigure:
                self.update()
 
 class NIM(object):
                self.update()
 
 class NIM(object):
-       def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
+       def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}):
                self.slot = slot
 
                if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
                self.slot = slot
 
                if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
@@ -455,6 +455,7 @@ class NIM(object):
                self.description = description
                self.has_outputs = has_outputs
                self.internally_connectable = internally_connectable
                self.description = description
                self.has_outputs = has_outputs
                self.internally_connectable = internally_connectable
+               self.multi_type = multi_type
 
        def isCompatible(self, what):
                compatible = {
 
        def isCompatible(self, what):
                compatible = {
@@ -466,6 +467,9 @@ class NIM(object):
                        }
                return what in compatible[self.type]
        
                        }
                return what in compatible[self.type]
        
+       def getType(self):
+               return self.type
+       
        def connectableTo(self):
                connectable = {
                                "DVB-S": ("DVB-S", "DVB-S2"),
        def connectableTo(self):
                connectable = {
                                "DVB-S": ("DVB-S", "DVB-S2"),
@@ -491,6 +495,13 @@ class NIM(object):
        
        def internallyConnectableTo(self):
                return self.internally_connectable
        
        def internallyConnectableTo(self):
                return self.internally_connectable
+       
+       def isMultiType(self):
+               return (len(self.multi_type) > 0)
+       
+       # returns dict {<slotid>: <type>}
+       def getMultiTypeList(self):
+               return self.multi_type
 
        slot_id = property(getSlotID)
 
 
        slot_id = property(getSlotID)
 
@@ -636,7 +647,15 @@ class NimManager:
                                entries[current_slot]["has_outputs"] = (input == "yes")
                        elif line.strip().startswith("Internally_Connectable:"):
                                input = int(line.strip()[len("Internally_Connectable:") + 1:])
                                entries[current_slot]["has_outputs"] = (input == "yes")
                        elif line.strip().startswith("Internally_Connectable:"):
                                input = int(line.strip()[len("Internally_Connectable:") + 1:])
-                               entries[current_slot]["internally_connectable"] = input 
+                               entries[current_slot]["internally_connectable"] = input
+                       elif  line.strip().startswith("Mode"):
+                               # "Mode 0: DVB-T" -> ["Mode 0", " DVB-T"]
+                               split = line.strip().split(":")
+                               # "Mode 0" -> ["Mode, "0"]
+                               split2 = split[0].split(" ")
+                               modes = entries[current_slot].get("multi_type", {})
+                               modes[split2[1]] = split[1].strip()
+                               entries[current_slot]["multi_type"] = modes
                        elif line.strip().startswith("empty"):
                                entries[current_slot]["type"] = None
                                entries[current_slot]["name"] = _("N/A")
                        elif line.strip().startswith("empty"):
                                entries[current_slot]["type"] = None
                                entries[current_slot]["name"] = _("N/A")
@@ -650,12 +669,17 @@ class NimManager:
                                entry["has_outputs"] = True
                        if not (entry.has_key("internally_connectable")):
                                entry["internally_connectable"] = None
                                entry["has_outputs"] = True
                        if not (entry.has_key("internally_connectable")):
                                entry["internally_connectable"] = None
-                       self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"]))
+                       if not (entry.has_key("multi_type")):
+                               entry["multi_type"] = {}
+                       self.nim_slots.append(NIM(slot = id, description = entry["name"], type = entry["type"], has_outputs = entry["has_outputs"], internally_connectable = entry["internally_connectable"], multi_type = entry["multi_type"]))
 
        def hasNimType(self, chktype):
                for slot in self.nim_slots:
                        if slot.isCompatible(chktype):
                                return True
 
        def hasNimType(self, chktype):
                for slot in self.nim_slots:
                        if slot.isCompatible(chktype):
                                return True
+                       for type in slot.getMultiTypeList().values():
+                               if chktype == type:
+                                       return True
                return False
        
        def getNimType(self, slotid):
                return False
        
        def getNimType(self, slotid):
@@ -1218,11 +1242,28 @@ def InitNimManager(nimmgr):
                slot_id = configElement.slot_id
                if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
                        open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
                slot_id = configElement.slot_id
                if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2':
                        open("/proc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value)
+                       
+       def tunerTypeChanged(configElement):
+               fe_id = configElement.fe_id
+               open("/proc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value)
 
        empty_slots = 0
        for slot in nimmgr.nim_slots:
                x = slot.slot
                nim = config.Nims[x]
 
        empty_slots = 0
        for slot in nimmgr.nim_slots:
                x = slot.slot
                nim = config.Nims[x]
+               if slot.isMultiType():
+                       typeList = []
+                       value = None
+                       for id in slot.getMultiTypeList().keys():
+                               type = slot.getMultiTypeList()[id]
+                               typeList.append((id, type))
+                               if type == slot.getType():
+                                       value = id
+                       nim.multiType = ConfigSelection(typeList, "0")
+                       nim.multiType.value = value
+                       nim.multiType.fe_id = x - empty_slots
+                       nim.multiType.addNotifier(tunerTypeChanged)
+               
                if slot.isCompatible("DVB-S"):
                        nim.toneAmplitude = ConfigSelection([("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
                        nim.toneAmplitude.fe_id = x - empty_slots
                if slot.isCompatible("DVB-S"):
                        nim.toneAmplitude = ConfigSelection([("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
                        nim.toneAmplitude.fe_id = x - empty_slots
index 156f778..0d10a2c 100644 (file)
@@ -94,6 +94,11 @@ class NimSetup(Screen, ConfigListScreen, ServiceStopScreen):
                self.advancedType = None
                self.advancedManufacturer = None
                self.advancedSCR = None
                self.advancedType = None
                self.advancedManufacturer = None
                self.advancedSCR = None
+               
+               if self.nim.isMultiType():
+                       multiType = self.nimConfig.multiType
+                       self.multiType = getConfigListEntry(_("Tuner type"), multiType)
+                       self.list.append(self.multiType)
 
                if self.nim.isCompatible("DVB-S"):
                        self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
 
                if self.nim.isCompatible("DVB-S"):
                        self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
@@ -200,10 +205,19 @@ class NimSetup(Screen, ConfigListScreen, ServiceStopScreen):
                        self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, \
                        self.advancedLof, self.advancedPowerMeasurement, self.turningSpeed, \
                        self.advancedType, self.advancedSCR, self.advancedManufacturer, self.advancedUnicable, \
                        self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, \
                        self.advancedLof, self.advancedPowerMeasurement, self.turningSpeed, \
                        self.advancedType, self.advancedSCR, self.advancedManufacturer, self.advancedUnicable, \
-                       self.uncommittedDiseqcCommand, self.cableScanType)
+                       self.uncommittedDiseqcCommand, self.cableScanType, self.multiType)
+               if self["config"].getCurrent() == self.multiType:
+                       print "enumerating:"
+                       nimmanager.enumerateNIMs()
+                       print "mode value:", self.multiType[1].value
+                       from Components.NimManager import InitNimManager
+                       InitNimManager(nimmanager)
+                       self.nim = nimmanager.nim_slots[self.slotid]
+                       self.nimConfig = self.nim.config
                for x in checkList:
                        if self["config"].getCurrent() == x:
                                self.createSetup()
                for x in checkList:
                        if self["config"].getCurrent() == x:
                                self.createSetup()
+                               break
 
        def run(self):
                if self.have_advanced and self.nim.config_mode == "advanced":
 
        def run(self):
                if self.have_advanced and self.nim.config_mode == "advanced":
@@ -511,6 +525,8 @@ class NimSelection(Screen):
                                                text = _("nothing connected")
                                        elif nimConfig.configMode.value == "enabled":
                                                text = _("enabled")
                                                text = _("nothing connected")
                                        elif nimConfig.configMode.value == "enabled":
                                                text = _("enabled")
+                               if x.isMultiType():
+                                       text = _("Switchable tuner types:") + "(" + ','.join(x.getMultiTypeList().values()) + ")" + "\n" + text
                                        
                                self.list.append((slotid, x.friendly_full_description, text, x))
                self["nimlist"].setList(self.list)
                                        
                                self.list.append((slotid, x.friendly_full_description, text, x))
                self["nimlist"].setList(self.list)