Merge remote branch 'remotes/origin/bug_592_dont_allow_default_parental_control_pin'
authorghost <andreas.monzner@multimedia-labs.de>
Thu, 14 Oct 2010 11:32:46 +0000 (13:32 +0200)
committerghost <andreas.monzner@multimedia-labs.de>
Thu, 14 Oct 2010 11:32:46 +0000 (13:32 +0200)
data/skin_default.xml
lib/dvb/dvb.cpp
lib/dvb/frontend.cpp
lib/dvb/sec.cpp
lib/python/Components/NimManager.py
lib/python/Plugins/Extensions/MediaPlayer/plugin.py
lib/python/Screens/Satconfig.py
lib/python/Screens/ScanSetup.py
lib/service/servicemp3.cpp

index 7cb5b007582a1e9de5a949c5706601dca02647b7..e5b31322b0caac5eead03e4d3df7934ff0764d31 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 40d441861d97d5afcffd4f064464961c192fb617..516294523be74848efe99c80952296adf628a58a 100644 (file)
@@ -320,27 +320,34 @@ PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
                PyErr_SetString(PyExc_StandardError, "eDVBResourceManager::setFrontendSlotInformations argument should be a python list");
                return NULL;
        }
-       if ((unsigned int)PyList_Size(list) != m_frontend.size())
+       unsigned int assigned=0;
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
        {
+               int pos=0;
+               while (pos < PyList_Size(list)) {
+                       ePyObject obj = PyList_GET_ITEM(list, pos++);
+                       if (!i->m_frontend->setSlotInfo(obj))
+                               continue;
+                       ++assigned;
+                       break;
+               }
+       }
+       if (assigned != m_frontend.size()) {
                char blasel[256];
-               sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations list size incorrect %d frontends avail, but %d entries in slotlist",
-                       m_frontend.size(), PyList_Size(list));
+               sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations .. assigned %d socket informations, but %d registered frontends!",
+                       m_frontend.size(), assigned);
                PyErr_SetString(PyExc_StandardError, blasel);
                return NULL;
        }
-       int pos=0;
-       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
-       {
-               ePyObject obj = PyList_GET_ITEM(list, pos++);
-               if (!i->m_frontend->setSlotInfo(obj))
-                       return NULL;
-       }
-       pos=0;
        for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_simulate_frontend.begin()); i != m_simulate_frontend.end(); ++i)
        {
-               ePyObject obj = PyList_GET_ITEM(list, pos++);
-               if (!i->m_frontend->setSlotInfo(obj))
-                       return NULL;
+               int pos=0;
+               while (pos < PyList_Size(list)) {
+                       ePyObject obj = PyList_GET_ITEM(list, pos++);
+                       if (!i->m_frontend->setSlotInfo(obj))
+                               continue;
+                       break;
+               }
        }
        Py_RETURN_NONE;
 }
index abbb8d294ab6f2e89d25fda3e8f8e796120a206b..ebdad8a7599e734b0d6902df8deaee096ba715c0 100644 (file)
@@ -813,7 +813,7 @@ int eDVBFrontend::readFrontendData(int type)
                                        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 @@ int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)
 
 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") ||
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 b75b65eb5019ced7649bfbeec52c6ed394ed8574..73031861795941491ce1839440da3ddeb4169ea4 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"
 
@@ -140,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:
@@ -471,7 +481,7 @@ class SecConfigure:
                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, i2c = None, is_empty = False):
                self.slot = slot
 
                if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
@@ -483,8 +493,13 @@ class NIM(object):
                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():
+                       return False
                compatible = {
                                None: (None,),
                                "DVB-S": ("DVB-S", None),
@@ -517,15 +532,35 @@ class NIM(object):
        def getSlotID(self):
                return chr(ord('A') + self.slot)
        
+       def getI2C(self):
+               return self.i2c
+       
        def hasOutputs(self):
                return self.has_outputs
        
        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
@@ -548,8 +583,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
 
@@ -667,14 +704,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(":")
@@ -683,22 +725,35 @@ class NimManager:
                                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
+               
                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("i2c")):
+                               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"]))
+                       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:
@@ -717,6 +772,12 @@ class NimManager:
        
        def getNimName(self, slotid):
                return self.nim_slots[slotid].description
+       
+       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'
@@ -747,6 +808,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 9ae886fc68fc0632ead346046dc0575589dc093f..e4bdba12def67cc3b7b9da94b155bdd8497e3017 100755 (executable)
@@ -110,7 +110,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
 
                # 'None' is magic to start at the list of mountpoints
                defaultDir = config.mediaplayer.defaultDir.getValue()
-               self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls")
+               self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|m2ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls")
                self["filelist"] = self.filelist
 
                self.playlist = MyPlayList()
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)
index f482808832ad30b60f29ddcb19eb3a2fb28c88a3..2e2f8364d5f841e2902640840f9517843e452d26 100644 (file)
@@ -192,21 +192,16 @@ class CableTransponderSearchSupport:
                self.cable_search_container.dataAvail.append(self.getCableTransponderData)
                cableConfig = config.Nims[nim_idx].cable
                tunername = nimmanager.getNimName(nim_idx)
+               bus = nimmanager.getI2CDevice(nim_idx)
+               if bus is None:
+                       print "ERROR: could not get I2C device for nim", nim_idx, "for cable transponder search"
+                       bus = 2
+
                if tunername == "CXD1981":
-                       cmd = "cxd1978 --init --scan --verbose --wakeup --inv 2 --bus "
-               else:
-                       cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
-               #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
-               if nim_idx < 2:
-                       if HardwareInfo().get_device_name() == "dm500hd":
-                               cmd += "2"
-                       else:
-                               cmd += str(nim_idx)
+                       cmd = "cxd1978 --init --scan --verbose --wakeup --inv 2 --bus %d" % bus
                else:
-                       if nim_idx == 2:
-                               cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
-                       else:
-                               cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
+                       cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus %d" % bus
+               
                if cableConfig.scan_type.value == "bands":
                        cmd += " --scan-bands "
                        bands = 0
index 1fb1e443ac45f3083082ee70b3a75c7bb4721d1a..9c24d4bb2e4dff7aff7c68f2baf108fa2de0a600 100644 (file)
@@ -48,6 +48,7 @@ eServiceFactoryMP3::eServiceFactoryMP3()
                extensions.push_back("mp4");
                extensions.push_back("mov");
                extensions.push_back("m4a");
+               extensions.push_back("m2ts");
                sc->addServiceFactory(eServiceFactoryMP3::id, this, extensions);
        }