From 26f2c70eb3ae673f11d7c0735571b4d7e803ae6c Mon Sep 17 00:00:00 2001 From: Dimitrij Date: Fri, 20 Sep 2024 16:51:02 +0300 Subject: [PATCH] [CI] use "Exclude first CA device" only pulse4k(mini) (#4065) --- lib/dvb_ci/descrambler.cpp | 18 ++++++++++++------ lib/dvb_ci/descrambler.h | 2 +- lib/dvb_ci/dvbci_ccmgr.cpp | 4 ++-- lib/python/Components/SystemInfo.py | 1 + lib/python/Screens/Ci.py | 3 ++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/dvb_ci/descrambler.cpp b/lib/dvb_ci/descrambler.cpp index f7fea6ccfc7..84a0803625f 100644 --- a/lib/dvb_ci/descrambler.cpp +++ b/lib/dvb_ci/descrambler.cpp @@ -133,7 +133,7 @@ int descrambler_set_key(int& desc_fd, eDVBCISlot *slot, int parity, unsigned cha return 0; } -int descrambler_set_pid(int desc_fd, int index, int enable, int pid) +int descrambler_set_pid(int desc_fd, eDVBCISlot *slot, int enable, int pid) { struct ca_pid p; unsigned int flags = 0x80; @@ -141,7 +141,7 @@ int descrambler_set_pid(int desc_fd, int index, int enable, int pid) if (desc_fd < 0) return -1; - if (index) + if (slot->getSlotID()) flags |= 0x40; if (enable) @@ -150,9 +150,15 @@ int descrambler_set_pid(int desc_fd, int index, int enable, int pid) p.pid = pid; p.index = flags; - if (ioctl(desc_fd, CA_SET_PID, &p) == -1) { - eWarning("[CI%d descrambler] set pid failed", index); - return -1; + if (ioctl(desc_fd, CA_SET_PID, &p) == -1) + { + if (slot->getIsCA0Excluded()) + return 0; + else + { + eWarning("[CI%d descrambler] set pid failed", slot->getSlotID()); + return -1; + } } return 0; @@ -164,7 +170,7 @@ int descrambler_init(int slot, uint8_t ca_demux_id) std::string filename = "/dev/dvb/adapter0/ca" + std::to_string(ca_demux_id); - desc_fd = open(filename.c_str(), O_RDWR); + desc_fd = open(filename.c_str(), O_RDWR | O_NONBLOCK | O_CLOEXEC); if (desc_fd == -1) { eWarning("[CI%d descrambler] can not open %s", slot, filename.c_str()); } diff --git a/lib/dvb_ci/descrambler.h b/lib/dvb_ci/descrambler.h index dfd3213d553..4cbc09d9a3f 100644 --- a/lib/dvb_ci/descrambler.h +++ b/lib/dvb_ci/descrambler.h @@ -6,6 +6,6 @@ int descrambler_init(int slot, uint8_t ca_demux_id); void descrambler_deinit(int desc_fd); int descrambler_set_key(int& desc_fd, eDVBCISlot *slot, int parity, unsigned char *data); -int descrambler_set_pid(int desc_fd, int index, int enable, int pid); +int descrambler_set_pid(int desc_fd, eDVBCISlot *slot, int enable, int pid); #endif diff --git a/lib/dvb_ci/dvbci_ccmgr.cpp b/lib/dvb_ci/dvbci_ccmgr.cpp index 846ed032925..b0e7663bb0a 100644 --- a/lib/dvb_ci/dvbci_ccmgr.cpp +++ b/lib/dvb_ci/dvbci_ccmgr.cpp @@ -133,7 +133,7 @@ void eDVBCICcSession::addProgram(uint16_t program_number, std::vector& eDebugNoNewLine("\n"); for (std::vector::iterator it = pids.begin(); it != pids.end(); ++it) - descrambler_set_pid(m_descrambler_fd, m_slot->getSlotID(), 1, *it); + descrambler_set_pid(m_descrambler_fd, m_slot, 1, *it); } @@ -145,7 +145,7 @@ void eDVBCICcSession::removeProgram(uint16_t program_number, std::vector::iterator it = pids.begin(); it != pids.end(); ++it) - descrambler_set_pid(m_descrambler_fd, m_slot->getSlotID(), 0, *it); + descrambler_set_pid(m_descrambler_fd, m_slot, 0, *it); // removing program means probably decoding on this slot is ending. So mark this slot as not descrambling eDVBCI_UI::getInstance()->setDecodingState(m_slot->getSlotID(), 0); diff --git a/lib/python/Components/SystemInfo.py b/lib/python/Components/SystemInfo.py index dc5521d530f..ee8649c7790 100644 --- a/lib/python/Components/SystemInfo.py +++ b/lib/python/Components/SystemInfo.py @@ -142,6 +142,7 @@ def setBoxInfoItems(): model = BoxInfo.getItem("machine") BoxInfo.setItem("InDebugMode", eGetEnigmaDebugLvl() >= 4) BoxInfo.setItem("CommonInterface", model in ("h9combo", "h9combose", "h10", "pulse4kmini") and 1 or eDVBCIInterfaces.getInstance().getNumOfSlots()) + BoxInfo.setItem("CiAlternativeCaHandling", model in ("pulse4k", "pulse4kmini")) BoxInfo.setItem("CommonInterfaceCIDelay", fileCheck("/proc/stb/tsmux/rmx_delay")) for cislot in range(0, BoxInfo.getItem("CommonInterface")): BoxInfo.setItem("CI%dSupportsHighBitrates" % cislot, fileCheck("/proc/stb/tsmux/ci%d_tsclk" % cislot)) diff --git a/lib/python/Screens/Ci.py b/lib/python/Screens/Ci.py index 53401b227da..f88c3f924d0 100644 --- a/lib/python/Screens/Ci.py +++ b/lib/python/Screens/Ci.py @@ -475,7 +475,8 @@ def appendEntries(self, slot, state): self.list.append((_("Show CI messages"), config.ci[slot].show_ci_messages, 3, slot)) self.list.append((_("Disable operator profiles"), config.ci[slot].disable_operator_profile, 3, slot)) self.list.append((_("Multiple service support"), config.ci[slot].canDescrambleMultipleServices, 3, slot)) - self.list.append((_("Exclude first CA device"), config.ci[slot].exclude_ca0_device, 3, slot)) + if BoxInfo.getItem("CiAlternativeCaHandling"): + self.list.append((_("Exclude first CA device"), config.ci[slot].exclude_ca0_device, 3, slot)) if BoxInfo.getItem("CI%dSupportsHighBitrates" % slot): self.list.append((_("High bitrate support"), config.ci[slot].highBitrate, 3, slot)) if BoxInfo.getItem("CI%dRelevantPidsRoutingSupport" % slot):