Merge branch 'vuplus_experimental' of code.vuplus.com:/opt/repository/dvbapp into...
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / Blindscan / plugin.py
index faeb9d9..40a349e 100644 (file)
@@ -18,7 +18,8 @@ from Tools.Directories import resolveFilename, SCOPE_DEFAULTPARTITIONMOUNTDIR, S
 
 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager, getDesktop
 
-_supportNimType   = { 'AVL1208':'', 'AVL6222':'6222_', 'AVL6211':'6211_'}
+_modelName = file('/proc/stb/info/vumodel').read().strip()
+_supportNimType = { 'AVL1208':'', 'AVL6222':'6222_', 'AVL6211':'6211_', 'BCM7356':'bcm7346_'}
 
 class Blindscan(ConfigListScreen, Screen):
        skin =  """
@@ -85,40 +86,67 @@ class Blindscan(ConfigListScreen, Screen):
                        self["introduction"] = Label(_("Please setup your tuner configuration."))
 
                self.i2c_mapping_table = None
-               self.makeNimSocket()
                self.nimSockets = self.ScanNimsocket()
+               self.makeNimSocket()
 
-       def ScanNimsocket(self):
+       def ScanNimsocket(self, filepath = '/proc/bus/nim_sockets'):
                _nimSocket = {}
-               fp = file('/proc/bus/nim_sockets')
+               fp = file(filepath)
 
-               sNo, sName = -1, ""
+               sNo, sName, sI2C = -1, "", -1
                for line in fp:
                        line = line.strip()
                        if line.startswith('NIM Socket'):
-                               sNo = line.split()[2][:-1]
+                               sNo, sName, sI2C = -1, '', -1
+                               try:    sNo = line.split()[2][:-1]
+                               except: sNo = -1
+                       elif line.startswith('I2C_Device:'):
+                               try:    sI2C = line.split()[1]
+                               except: sI2C = -1
                        elif line.startswith('Name:'):
-                               sName = line.split()[3][4:-1]
+                               splitLines = line.split()
+                               try:
+                                       if splitLines[1].startswith('BCM'):
+                                               sName = splitLines[1]
+                                       else:
+                                               sName = splitLines[3][4:-1]
+                               except: sName = ""
                        if sNo >= 0 and sName != "":
-                               _nimSocket[sNo] = sName
-                               sNo   = -1
-                               sName = ''
+                               if sName.startswith('BCM'):
+                                       sI2C = sNo
+                               if sI2C != -1:
+                                       _nimSocket[sNo] = [sName, sI2C]
+                               else:   _nimSocket[sNo] = [sName]
                fp.close()
+               print "parsed nimsocket :", _nimSocket
                return _nimSocket
 
        def makeNimSocket(self, nimname=""):
-               self.i2c_mapping_table = {}
+               is_exist_i2c = False
+               self.i2c_mapping_table = {0:2, 1:3, 2:1, 3:0}
+               if self.nimSockets is not None:
+                       for XX in self.nimSockets.keys():
+                               nimsocket = self.nimSockets[XX]
+                               if len(nimsocket) > 1:
+                                       try:    self.i2c_mapping_table[int(XX)] = int(nimsocket[1])
+                                       except: continue
+                                       is_exist_i2c = True
+               print "i2c_mapping_table :", self.i2c_mapping_table, ", is_exist_i2c :", is_exist_i2c
+               if is_exist_i2c: return
 
                if nimname == "AVL6222":
-                       model = file('/proc/stb/info/vumodel').read().strip()
+                       model = _modelName #file('/proc/stb/info/vumodel').read().strip()
                        if model == "uno":
                                self.i2c_mapping_table = {0:3, 1:3, 2:1, 3:0}
                        elif model == "duo2":
-                               if self.nimSockets['0'] == "AVL6222":
-                                       self.i2c_mapping_table = {0:2, 1:2, 2:4, 3:4}
-                               else:   self.i2c_mapping_table = {0:2, 1:4, 2:4, 3:0}
+                               nimdata = self.nimSockets['0']
+                               try:
+                                       if nimdata[0] == "AVL6222":
+                                               self.i2c_mapping_table = {0:2, 1:2, 2:4, 3:4}
+                                       else:   self.i2c_mapping_table = {0:2, 1:4, 2:4, 3:0}
+                               except: self.i2c_mapping_table = {0:2, 1:4, 2:4, 3:0}
                        else:   self.i2c_mapping_table = {0:2, 1:4, 2:0, 3:0}
-               else:   self.i2c_mapping_table = {0:2, 1:3, 2:1, 3:0}
+               else:   self.i2c_mapping_table = {0:2, 1:3, 2:1, 3:0}
 
        def getNimSocket(self, slot_number):
                if slot_number < 0 or slot_number > 3:
@@ -366,13 +394,13 @@ class Blindscan(ConfigListScreen, Screen):
                def GetCommand(nimIdx):
                        _nimSocket = self.nimSockets
                        try:
-                               sName = _nimSocket[str(nimIdx)]
+                               sName = _nimSocket[str(nimIdx)][0]
                                sType = _supportNimType[sName]
                                return "vuplus_%(TYPE)sblindscan"%{'TYPE':sType}, sName
                        except: pass
                        return "vuplus_blindscan", ""
                self.binName,nimName =  GetCommand(self.scan_nims.value)
-               
+
                self.makeNimSocket(nimName)
                if self.binName is None:
                        self.session.open(MessageBox, "Blindscan is not supported in " + nimName + " tuner.", MessageBox.TYPE_ERROR)
@@ -500,7 +528,8 @@ class Blindscan(ConfigListScreen, Screen):
                                                "ROLLOFF_25" : parm.RollOff_alpha_0_25,
                                                "ROLLOFF_35" : parm.RollOff_alpha_0_35}
                                        pilot={ "PILOT_ON" : parm.Pilot_On,
-                                               "PILOT_OFF" : parm.Pilot_Off}
+                                               "PILOT_OFF" : parm.Pilot_Off,
+                                               "PILOT_AUTO" : parm.Pilot_Unknown}
                                        pol = { "HORIZONTAL" : parm.Polarisation_Horizontal,
                                                "VERTICAL" : parm.Polarisation_Vertical}
                                        try :
@@ -515,8 +544,7 @@ class Blindscan(ConfigListScreen, Screen):
                                                parm.modulation = qam[data[8]]
                                                parm.rolloff = roll[data[9]]
                                                self.tmp_tplist.append(parm)
-                                       except:
-                                               pass
+                                       except: pass
                self.blindscan_session.close(True)
 
        def blindscanContainerAvail(self, str):