try to make CA-Init more reliable

This commit is contained in:
FlatTV
2021-05-30 12:26:14 +02:00
committed by Thilo Graf
parent 3fcb4ff6a6
commit c3c6aa66ca
3 changed files with 25 additions and 7 deletions

View File

@@ -71,7 +71,8 @@ void cs_register_messenger(cs_messenger messenger)
return; return;
} }
cCA *CA = cCA::GetInstance(); //let Neutrino start this function
//cCA *CA = cCA::GetInstance();
cCA::cCA(void) cCA::cCA(void)
{ {
@@ -237,14 +238,14 @@ eData waitData(int fd, unsigned char *buffer, int *len)
static bool transmitData(eDVBCISlot *slot, unsigned char *d, int len) static bool transmitData(eDVBCISlot *slot, unsigned char *d, int len)
{ {
printf("%s -> %s len(%d)\n", FILENAME, __func__, len); printf("%s -> %s len(%d) -> ", FILENAME, __func__, len);
#if BOXMODEL_VUSOLO4K || BOXMODEL_VUDUO4K || BOXMODEL_VUDUO4KSE || BOXMODEL_VUULTIMO4K || BOXMODEL_VUZERO4K #if BOXMODEL_VUSOLO4K || BOXMODEL_VUDUO4K || BOXMODEL_VUDUO4KSE || BOXMODEL_VUULTIMO4K || BOXMODEL_VUZERO4K
#if y_debug #if y_debug
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
printf("%02x ", d[i]); printf("%02x ", d[i]);
printf("\n");
#endif #endif
printf("\n");
int res = write(slot->fd, d, len); int res = write(slot->fd, d, len);
printf("send: %d len: %d\n", res, len); printf("send: %d len: %d\n", res, len);
@@ -1266,6 +1267,7 @@ cCA::cCA(int Slots)
{ {
printf("%s -> %s %d\n", FILENAME, __func__, Slots); printf("%s -> %s %d\n", FILENAME, __func__, Slots);
zapitReady = false;
num_slots = Slots; num_slots = Slots;
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE #if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
setInputs(); setInputs();
@@ -1525,6 +1527,18 @@ void cCA::slot_pollthread(void *c)
eDVBCISlot *slot = (eDVBCISlot *) c; eDVBCISlot *slot = (eDVBCISlot *) c;
bool wait = false; bool wait = false;
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
//prevert zapit fail on booting with CI
if (!zapitReady)
{
printf("[CA] Slot%d: Waiting for zapit\n", slot->slot);
while (!zapitReady)
{
usleep( 3 * 1000000); //wait for 3 seconds
}
printf("[CA] Slot%d: zapit is ready\n", slot->slot);
}
#endif
while (1) while (1)
{ {
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE /* Armbox/Mipsbox */ #if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE /* Armbox/Mipsbox */
@@ -1950,7 +1964,7 @@ void cCA::SetTSClock(u32 Speed, int slot)
char buf[64]; char buf[64];
snprintf(buf, 64, "/proc/stb/tsmux/ci%d_tsclk", slot); snprintf(buf, 64, "/proc/stb/tsmux/ci%d_tsclk", slot);
FILE *ci = fopen(buf, "wb"); FILE *ci = fopen(buf, "wb");
printf("%s -> %s to: %s\n", FILENAME, __func__, Speed > 9 * 1000000 ? "extra_high" : Speed > 6 * 1000000 ? "high" : "normal"); printf("%s -> %s for Slot%d to: %s\n", FILENAME, __func__, slot, Speed > 9 * 1000000 ? "extra_high" : Speed > 6 * 1000000 ? "high" : "normal");
if (ci) if (ci)
{ {
if (Speed > 9 * 1000000) if (Speed > 9 * 1000000)
@@ -1969,7 +1983,7 @@ void cCA::SetCIDelay(int Delay)
char buf[64]; char buf[64];
snprintf(buf, 64, "/proc/stb/tsmux/rmx_delay"); snprintf(buf, 64, "/proc/stb/tsmux/rmx_delay");
FILE *ci = fopen(buf, "wb"); FILE *ci = fopen(buf, "wb");
printf("%s -> %s to: %i\n", FILENAME, __func__, Delay); printf("%s -> %s for all Slots to: %i\n", FILENAME, __func__, Delay);
if (ci) if (ci)
{ {
fprintf(ci, "%i", Delay); fprintf(ci, "%i", Delay);
@@ -1982,7 +1996,7 @@ void cCA::SetCIRelevantPidsRouting(int RPR, int slot)
char buf[64]; char buf[64];
snprintf(buf, 64, "/proc/stb/tsmux/ci%d_relevant_pids_routing", slot); snprintf(buf, 64, "/proc/stb/tsmux/ci%d_relevant_pids_routing", slot);
FILE *ci = fopen(buf, "wb"); FILE *ci = fopen(buf, "wb");
printf("%s -> %s to: %i\n", FILENAME, __func__, RPR); printf("%s -> %s for Slot%d to: %i\n", FILENAME, __func__, slot, RPR);
if (ci) if (ci)
{ {
fprintf(ci, "%s", RPR == 1 ? "yes" : "no"); fprintf(ci, "%s", RPR == 1 ? "yes" : "no");

View File

@@ -315,6 +315,7 @@ class cCA
pthread_mutex_t ciMutex; pthread_mutex_t ciMutex;
std::list<eDVBCISlot *> slot_data; std::list<eDVBCISlot *> slot_data;
pthread_t slot_thread; pthread_t slot_thread;
bool zapitReady;
public: public:
/// sh4 unused /// sh4 unused
@@ -386,6 +387,9 @@ class cCA
void setCheckLiveSlot(int check); void setCheckLiveSlot(int check);
/// as the name says /// as the name says
bool CheckCerts(void); bool CheckCerts(void);
/// start pollthread after zapit is ready
virtual void setZapitReady(){zapitReady = true;};
virtual bool getZapitReady(){return zapitReady;};
/// Virtual destructor /// Virtual destructor
virtual ~cCA(); virtual ~cCA();
}; };

View File

@@ -292,7 +292,7 @@ void eDVBCISession::receiveData(eDVBCISlot *slot, const unsigned char *ptr, size
unsigned char tag = *pkt++; unsigned char tag = *pkt++;
int llen, hlen; int llen, hlen;
printf("[CI SESS] receiveData slot: %p > ", slot); printf("[CI SESS] receiveData slot: %p <- ", slot);
#if 0 #if 0
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)