Merge remote branch 'remotes/origin/bug_587_new_internally_connectable_and_unsupporte...
authorghost <andreas.monzner@multimedia-labs.de>
Thu, 14 Oct 2010 11:21:33 +0000 (13:21 +0200)
committerghost <andreas.monzner@multimedia-labs.de>
Thu, 14 Oct 2010 11:21:33 +0000 (13:21 +0200)
1  2 
data/skin_default.xml
lib/dvb/frontend.cpp
lib/python/Components/NimManager.py

diff --combined data/skin_default.xml
@@@ -670,12 -670,12 +670,12 @@@ self.instance.move(ePoint(orgpos.x() + 
                <widget name="menu" position="10,10" size="440,310" />
        </screen>
        <!-- Nim selection -->
-       <screen name="NimSelection" position="center,center" size="400,330" title="Choose Tuner">
-               <widget source="nimlist" render="Listbox" position="0,0" size="380,360" scrollbarMode="showOnDemand">
+       <screen name="NimSelection" position="center,center" size="490,330" title="Choose Tuner">
+               <widget source="nimlist" render="Listbox" position="0,0" size="460,360" scrollbarMode="showOnDemand">
                        <convert type="TemplatedMultiContent">
                                {"template": [
-                                               MultiContentEntryText(pos = (10, 5), size = (360, 30), flags = RT_HALIGN_LEFT, text = 1), # index 1 is the nim name,
-                                               MultiContentEntryText(pos = (50, 30), size = (320, 50), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is a description of the nim settings,
+                                               MultiContentEntryText(pos = (10, 5), size = (440, 30), flags = RT_HALIGN_LEFT, text = 1), # index 1 is the nim name,
+                                               MultiContentEntryText(pos = (50, 30), size = (400, 50), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is a description of the nim settings,
                                        ],
                                 "fonts": [gFont("Regular", 20), gFont("Regular", 15)],
                                 "itemHeight": 80
        </screen>
        <!-- Color OLED screen (standby) -->
        <screen name="StandbySummary" position="0,0" size="96,64" id="2">
 -              <widget source="global.CurrentTime" render="Label" position="0,0" size="96,64" font="Regular;40" halign="center" valign="center">
 +              <widget source="global.CurrentTime" render="Label" position="0,0" size="96,64" font="Regular;38" halign="center" valign="center">
                        <convert type="ClockToText">Format:%H:%M</convert>
                </widget>
                <widget source="session.RecordState" render="FixedLabel" position="0,0" zPosition="1" size="96,64" text=" ">
diff --combined lib/dvb/frontend.cpp
@@@ -813,7 -813,7 +813,7 @@@ int eDVBFrontend::readFrontendData(int 
                                        float fval1 = SDS_SNRE / 268435456.0,
                                                  fval2, fval3, fval4;
  
 -                                      if (parm_u_qpsk_fec_inner <= FEC_S2_QPSK_9_10) // DVB-S2 QPSK
 +                                      if (oparm.sat.modulation == eDVBFrontendParametersSatellite::Modulation_QPSK)
                                        {
                                                fval2 = 6.76;
                                                fval3 = 4.35;
@@@ -2700,17 -2700,23 +2700,23 @@@ int eDVBFrontend::isCompatibleWith(ePtr
  
  bool eDVBFrontend::setSlotInfo(ePyObject obj)
  {
-       ePyObject Id, Descr, Enabled, IsDVBS2;
-       if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 4)
+       ePyObject Id, Descr, Enabled, IsDVBS2, frontendId;
+       if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 5)
                goto arg_error;
        Id = PyTuple_GET_ITEM(obj, 0);
        Descr = PyTuple_GET_ITEM(obj, 1);
        Enabled = PyTuple_GET_ITEM(obj, 2);
        IsDVBS2 = PyTuple_GET_ITEM(obj, 3);
-       if (!PyInt_Check(Id) || !PyString_Check(Descr) || !PyBool_Check(Enabled) || !PyBool_Check(IsDVBS2))
+       frontendId = PyTuple_GET_ITEM(obj, 4);
+       m_slotid = PyInt_AsLong(Id);
+       if (!PyInt_Check(Id) || !PyString_Check(Descr) || !PyBool_Check(Enabled) || !PyBool_Check(IsDVBS2) || !PyInt_Check(frontendId))
                goto arg_error;
        strcpy(m_description, PyString_AS_STRING(Descr));
-       m_slotid = PyInt_AsLong(Id);
+       if (PyInt_AsLong(frontendId) == -1 || PyInt_AsLong(frontendId) != m_dvbid) {
+ //            eDebugNoSimulate("skip slotinfo for slotid %d, descr %s",
+ //                    m_slotid, m_description);
+               return false;
+       }
        m_enabled = Enabled == Py_True;
        // HACK.. the rotor workaround is neede for all NIMs with LNBP21 voltage regulator...
        m_need_rotor_workaround = !!strstr(m_description, "Alps BSBE1") ||
@@@ -110,9 -110,16 +110,16 @@@ class SecConfigure
        def setSatposDepends(self, sec, nim1, nim2):
                print "tuner", nim1, "depends on satpos of", nim2
                sec.setTunerDepends(nim1, nim2)
+               
+       def linkInternally(self, slotid):
+               nim = self.NimManager.getNim(slotid)
+               if nim.internallyConnectableTo is not None:
+                       nim.setInternalLink()
  
        def linkNIMs(self, sec, nim1, nim2):
                print "link tuner", nim1, "to tuner", nim2
+               if nim2 == (nim1 - 1):
+                       self.linkInternally(nim1)
                sec.setTunerLinked(nim1, nim2)
                
        def getRoot(self, slotid, connto):
        def update(self):
                sec = secClass.getInstance()
                self.configuredSatellites = set()
+               for slotid in self.NimManager.getNimListOfType("DVB-S"):
+                       if self.NimManager.nimInternallyConnectableTo(slotid) is not None:
+                               self.NimManager.nimRemoveInternalLink(slotid)
                sec.clear() ## this do unlinking NIMs too !!
                print "sec config cleared"
  
  
                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 = {}):
+       def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = 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.frontend_id = frontend_id
+               self.__is_empty = is_empty
  
        def isCompatible(self, what):
+               if not self.isSupported():
+                       return False
                compatible = {
                                None: (None,),
                                "DVB-S": ("DVB-S", None),
        def internallyConnectableTo(self):
                return self.internally_connectable
        
+       def setInternalLink(self):
+               if self.internally_connectable is not None:
+                       print "setting internal link on frontend id", self.frontend_id
+                       open("/proc/stb/frontend/%d/rf_switch" % self.frontend_id, "w").write("internal")
+               
+       def removeInternalLink(self):
+               if self.internally_connectable is not None:
+                       print "removing internal link on frontend id", self.frontend_id
+                       open("/proc/stb/frontend/%d/rf_switch" % self.frontend_id, "w").write("external")
+       
        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) or self.__is_empty
+       
        # returns dict {<slotid>: <type>}
        def getMultiTypeList(self):
                return self.multi_type
                        
                if self.empty:
                        nim_text += _("(empty)")
+               elif not self.isSupported():
+                       nim_text += self.description + " (" + _("not supported") + ")"
                else:
-                       nim_text += self.description + " (" + self.friendly_type + ")"
+                       nim_text += self.description + " (" + self.friendly_type + ")"
                
                return nim_text
  
@@@ -667,14 -700,19 +700,19 @@@ 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")
                        elif line.strip().startswith("Internally_Connectable:"):
                                input = int(line.strip()[len("Internally_Connectable:") + 1:])
                                entries[current_slot]["internally_connectable"] = input
+                       elif line.strip().startswith("Frontend_Device:"):
+                               input = int(line.strip()[len("Frontend_Device:") + 1:])
+                               entries[current_slot]["frontend_device"] = input
                        elif  line.strip().startswith("Mode"):
                                # "Mode 0: DVB-T" -> ["Mode 0", " DVB-T"]
                                split = line.strip().split(":")
                        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
+               
                for id, entry in entries.items():
                        if not (entry.has_key("name") and entry.has_key("type")):
                                entry["name"] =  _("N/A")
                                entry["type"] = None
                        if not (entry.has_key("has_outputs")):
                                entry["has_outputs"] = True
-                       if not (entry.has_key("internally_connectable")):
-                               entry["internally_connectable"] = None
+                       if entry.has_key("frontend_device"): # check if internally connectable
+                               if path.exists("/proc/stb/frontend/%d/rf_switch" % entry["frontend_device"]):
+                                       entry["internally_connectable"] = entry["frontend_device"] - 1
+                               else:
+                                       entry["internally_connectable"] = None
+                       else:
+                               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"]))
+                       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"]))
  
        def hasNimType(self, chktype):
                for slot in self.nim_slots:
        
        def getNimName(self, slotid):
                return self.nim_slots[slotid].description
+       
+       def getNim(self, slotid):
+               return self.nim_slots[slotid]
  
        def getNimListOfType(self, type, exception = -1):
                # returns a list of indexes for NIMs compatible to the given type, except for 'exception'
        def hasOutputs(self, slotid):
                return self.nim_slots[slotid].hasOutputs()
        
+       def nimInternallyConnectableTo(self, slotid):
+               return self.nim_slots[slotid].internallyConnectableTo()
+       
+       def nimRemoveInternalLink(self, slotid):
+               self.nim_slots[slotid].removeInternalLink()
+       
        def canConnectTo(self, slotid):
                slots = []
                if self.nim_slots[slotid].internallyConnectableTo() is not None:
@@@ -1337,7 -1392,7 +1392,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)