Merge remote branch 'remotes/origin/bug_593_i2c_device_from_file'
authorghost <andreas.monzner@multimedia-labs.de>
Thu, 14 Oct 2010 11:31:36 +0000 (13:31 +0200)
committerghost <andreas.monzner@multimedia-labs.de>
Thu, 14 Oct 2010 11:31:36 +0000 (13:31 +0200)
1  2 
lib/python/Components/NimManager.py

index 33f1c13c125341a67cc1a9f2d133803e5107e1ea,67a1abc8c416f656adba5f1804175cf8061d0f68..73031861795941491ce1839440da3ddeb4169ea4
@@@ -150,7 -150,7 +150,7 @@@ class SecConfigure
  
                for slot in nim_slots:
                        if slot.type is not None:
 -                              used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2")))
 +                              used_nim_slots.append((slot.slot, slot.description, slot.config.configMode.value != "nothing" and True or False, slot.isCompatible("DVB-S2"), slot.frontend_id is None and -1 or slot.frontend_id))
                eDVBResourceManager.getInstance().setFrontendSlotInformations(used_nim_slots)
  
                for slot in nim_slots:
                self.update()
  
  class NIM(object):
-       def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = None, is_empty = False):
 -      def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = None, i2c = None):
 -
++      def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = None, i2c = None, is_empty = False):
                self.slot = slot
  
                if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
                self.has_outputs = has_outputs
                self.internally_connectable = internally_connectable
                self.multi_type = multi_type
+               self.i2c = i2c
                self.frontend_id = frontend_id
 +              self.__is_empty = is_empty
  
        def isCompatible(self, what):
                if not self.isSupported():
        def getSlotID(self):
                return chr(ord('A') + self.slot)
        
+       def getI2C(self):
+               return self.i2c
+       
        def hasOutputs(self):
                return self.has_outputs
        
        def isMultiType(self):
                return (len(self.multi_type) > 0)
        
 +      def isEmpty(self):
 +              return self.__is_empty
 +      
 +      # empty tuners are supported!
        def isSupported(self):
 -              return (self.frontend_id is not None)
 +              return (self.frontend_id is not None) or self.__is_empty
        
        # returns dict {<slotid>: <type>}
        def getMultiTypeList(self):
@@@ -700,10 -700,8 +704,10 @@@ class NimManager
                                entries[current_slot] = {}
                        elif line.strip().startswith("Type:"):
                                entries[current_slot]["type"] = str(line.strip()[6:])
 +                              entries[current_slot]["isempty"] = False
                        elif line.strip().startswith("Name:"):
                                entries[current_slot]["name"] = str(line.strip()[6:])
 +                              entries[current_slot]["isempty"] = False
                        elif line.strip().startswith("Has_Outputs:"):
                                input = str(line.strip()[len("Has_Outputs:") + 1:])
                                entries[current_slot]["has_outputs"] = (input == "yes")
                                modes = entries[current_slot].get("multi_type", {})
                                modes[split2[1]] = split[1].strip()
                                entries[current_slot]["multi_type"] = modes
+                       elif line.strip().startswith("I2C_Device:"):
+                               input = int(line.strip()[len("I2C_Device:") + 1:])
+                               entries[current_slot]["i2c"] = input
                        elif line.strip().startswith("empty"):
                                entries[current_slot]["type"] = None
                                entries[current_slot]["name"] = _("N/A")
 +                              entries[current_slot]["isempty"] = True
                nimfile.close()
                
                from os import path
                        if not (entry.has_key("name") and entry.has_key("type")):
                                entry["name"] =  _("N/A")
                                entry["type"] = None
+                       if not (entry.has_key("i2c")):
+                               entry["i2c"] = None
                        if not (entry.has_key("has_outputs")):
                                entry["has_outputs"] = True
                        if entry.has_key("frontend_device"): # check if internally connectable
                                entry["frontend_device"] = entry["internally_connectable"] = None
                        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"], frontend_id = entry["frontend_device"], is_empty = entry["isempty"]))
 -                      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"], frontend_id = entry["frontend_device"], i2c = entry["i2c"]))
 -
++                      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"], frontend_id = entry["frontend_device"], i2c = entry["i2c"], is_empty = entry["isempty"]))
  
        def hasNimType(self, chktype):
                for slot in self.nim_slots:
        
        def getNim(self, slotid):
                return self.nim_slots[slotid]
+       
+       def getI2CDevice(self, slotid):
+               return self.nim_slots[slotid].getI2C()
  
        def getNimListOfType(self, type, exception = -1):
                # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
@@@ -1392,7 -1398,7 +1404,7 @@@ def InitNimManager(nimmgr)
                nim = config.Nims[x]
  
                if slot.isCompatible("DVB-S"):
 -                      nim.toneAmplitude = ConfigSelection([("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
 +                      nim.toneAmplitude = ConfigSelection([("11", "340mV"), ("10", "360mV"), ("9", "600mV"), ("8", "700mV"), ("7", "800mV"), ("6", "900mV"), ("5", "1100mV")], "7")
                        nim.toneAmplitude.fe_id = x - empty_slots
                        nim.toneAmplitude.slot_id = x
                        nim.toneAmplitude.addNotifier(toneAmplitudeChanged)