Merge branch 'bug_587_new_internally_connectable_and_unsupported_tuner_management...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 6 Oct 2010 07:00:42 +0000 (09:00 +0200)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 6 Oct 2010 07:00:42 +0000 (09:00 +0200)
Conflicts:
lib/python/Components/NimManager.py

data/skin_default.xml
lib/dvb/sec.cpp
lib/python/Components/NimManager.py
lib/python/Screens/Satconfig.py

index 8b26ce7ef54e2479dd072373dba966a35f5a4124..f9fb09c1f73f039cf8f3c5768b97a38865cbfa38 100755 (executable)
@@ -670,12 +670,12 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
                <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
index a8292c0c784dd046ae6c29ad3066ef98322242cc..d48d44e1f612b4c88a26e6348a26e8873cc75e94 100644 (file)
@@ -1004,19 +1004,6 @@ RESULT eDVBSatelliteEquipmentControl::clear()
        //reset some tuner configuration
        for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
        {
-               long tmp;
-               char c;
-               if (sscanf(it->m_frontend->getDescription(), "BCM450%c (internal)", &c) == 1 && !it->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, tmp) && tmp != -1)
-               {
-                       FILE *f=fopen("/proc/stb/tsmux/lnb_b_input", "w");
-                       if (!f || fwrite("B", 1, 1, f) != 1)
-                               eDebug("set /proc/stb/tsmux/lnb_b_input to B failed!! (%m)");
-                       else
-                       {
-                               eDebug("set /proc/stb/tsmux/lnb_b_input to B OK");
-                               fclose(f);
-                       }
-               }
                it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
                it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
                it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
@@ -1448,17 +1435,6 @@ RESULT eDVBSatelliteEquipmentControl::setTunerLinked(int tu1, int tu2)
                        char c;
                        p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
                        p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
-                       if (!strcmp(p1->m_frontend->getDescription(), p2->m_frontend->getDescription()) && sscanf(p1->m_frontend->getDescription(), "BCM450%c (internal)", &c) == 1)
-                       {
-                               FILE *f=fopen("/proc/stb/tsmux/lnb_b_input", "w");
-                               if (!f || fwrite("A", 1, 1, f) != 1)
-                                       eDebug("set /proc/stb/tsmux/lnb_b_input to A failed!! (%m)");
-                               else
-                               {
-                                       eDebug("set /proc/stb/tsmux/lnb_b_input to A OK");
-                                       fclose(f);
-                               }
-                       }
                }
 
                p1=p2=NULL;
index 2a1cbad3717b99b19d5d545d1dcd374148cdf1a8..f934ed50dc2f0f2392c737e91b84c06ca09a1d40 100644 (file)
@@ -110,9 +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):
@@ -127,6 +134,9 @@ class SecConfigure:
        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"
 
@@ -471,7 +481,8 @@ class SecConfigure:
                self.update()
 
 class NIM(object):
-       def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, i2c = None):
+       def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None, multi_type = {}, frontend_id = None, i2c = None):
+
                self.slot = slot
 
                if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
@@ -484,8 +495,11 @@ class NIM(object):
                self.internally_connectable = internally_connectable
                self.multi_type = multi_type
                self.i2c = i2c
+               self.frontend_id = frontend_id
 
        def isCompatible(self, what):
+               if not self.isSupported():
+                       return False
                compatible = {
                                None: (None,),
                                "DVB-S": ("DVB-S", None),
@@ -527,9 +541,22 @@ class NIM(object):
        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 isSupported(self):
+               return (self.frontend_id is not None)
+       
        # returns dict {<slotid>: <type>}
        def getMultiTypeList(self):
                return self.multi_type
@@ -552,8 +579,10 @@ class NIM(object):
                        
                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
 
@@ -679,6 +708,9 @@ class NimManager:
                        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(":")
@@ -695,6 +727,8 @@ class NimManager:
                                entries[current_slot]["name"] = _("N/A")
                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")
@@ -703,11 +737,17 @@ class NimManager:
                                entry["i2c"] = 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"], 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"]))
+
 
        def hasNimType(self, chktype):
                for slot in self.nim_slots:
@@ -726,6 +766,9 @@ class NimManager:
        
        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'
@@ -756,6 +799,12 @@ class NimManager:
        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:
index 44f4251a61cb8bae413b5f04a2a5912a1f701b84..a5712dcd9af2237e895c117cef034ff3a2d5ffa5 100644 (file)
@@ -489,7 +489,7 @@ class NimSelection(Screen):
        def okbuttonClick(self):
                nim = self["nimlist"].getCurrent()
                nim = nim and nim[3]
-               if nim is not None and not nim.empty:
+               if nim is not None and not nim.empty and nim.isSupported():
                        self.session.openWithCallback(self.updateList, self.resultclass, nim.slot)
                        
        def showNim(self, nim):
@@ -548,6 +548,8 @@ class NimSelection(Screen):
                                                text = _("enabled")
                                if x.isMultiType():
                                        text = _("Switchable tuner types:") + "(" + ','.join(x.getMultiTypeList().values()) + ")" + "\n" + text
+                               if not x.isSupported():
+                                       text = _("tuner is not supported")
                                        
                                self.list.append((slotid, x.friendly_full_description, text, x))
                self["nimlist"].setList(self.list)