fix ci arm hardware (thx DboxOldie)

This commit is contained in:
Frankenstone
2018-01-06 14:15:16 +01:00
committed by Thilo Graf
parent e6c29f2545
commit 0cdc859110
3 changed files with 19 additions and 16 deletions

View File

@@ -190,7 +190,7 @@ eData waitData(int fd, unsigned char* buffer, int* len)
else if (retval == 0) else if (retval == 0)
{ {
#if wd_debug #if wd_debug
//printf("**** wd DataTimeout\n"); printf("**** wd DataTimeout\n");
#endif #endif
return eDataTimeout; return eDataTimeout;
} }
@@ -214,7 +214,7 @@ eData waitData(int fd, unsigned char* buffer, int* len)
else if (fds.revents & POLLOUT) else if (fds.revents & POLLOUT)
{ {
#if wd_debug #if wd_debug
//printf("**** wd DataWrite\n"); printf("**** wd DataWrite\n");
#endif #endif
return eDataWrite; return eDataWrite;
} }
@@ -1343,12 +1343,11 @@ void cCA::slot_pollthread(void *c)
{ {
unsigned char data[1024 * 4]; unsigned char data[1024 * 4];
eDVBCISlot* slot = (eDVBCISlot*) c; eDVBCISlot* slot = (eDVBCISlot*) c;
bool wait = false;
while (1) while (1)
{ {
#if HAVE_ARM_HARDWARE /* Armbox */ #if HAVE_ARM_HARDWARE /* Armbox */
if (slot->init && !slot->mmiOpened)
sleep(1);
int len = 1024 *4; int len = 1024 *4;
eData status; eData status;
@@ -1381,6 +1380,9 @@ void cCA::slot_pollthread(void *c)
goto FROM_FIRST; goto FROM_FIRST;
} }
} }
/* slow down the loop, if no CI cam present */
// printf("***sleep\n");
sleep(1);
} /* case statusnone */ } /* case statusnone */
break; break;
case eStatusWait: case eStatusWait:
@@ -1389,6 +1391,7 @@ void cCA::slot_pollthread(void *c)
FROM_FIRST: FROM_FIRST:
if (status == eDataReady) if (status == eDataReady)
{ {
wait = false;
slot->pollConnection = false; slot->pollConnection = false;
if (len) if (len)
{ {
@@ -1398,6 +1401,7 @@ FROM_FIRST:
} /*if data ready */ } /*if data ready */
else if (status == eDataWrite) else if (status == eDataWrite)
{ {
wait = true;
/* only writing any data here while status = eDataWrite */ /* only writing any data here while status = eDataWrite */
if (!slot->sendqueue.empty()) if (!slot->sendqueue.empty())
{ {
@@ -1619,6 +1623,9 @@ FROM_FIRST:
if (slot->ccmgr_ready && slot->hasCCManager && slot->scrambled && !slot->SidBlackListed) if (slot->ccmgr_ready && slot->hasCCManager && slot->scrambled && !slot->SidBlackListed)
slot->ccmgrSession->resendKey(slot); slot->ccmgrSession->resendKey(slot);
} }
/* slow down for hd51 to avoid high cpu load */
if (wait && slot->init)
usleep(300000);
} }
} }

View File

@@ -20,8 +20,6 @@ static int desc_user_count = 0;
#if HAVE_ARM_HARDWARE #if HAVE_ARM_HARDWARE
//static const char *descrambler_filename = "/dev/dvb/adapter0/ca0";
//static const char *descrambler_filename = "/dev/dvb/adapter0/ca1";
static const char *descrambler_filename = "/dev/ciplus_ca0"; static const char *descrambler_filename = "/dev/ciplus_ca0";
enum ca_descr_data_type { enum ca_descr_data_type {
@@ -43,19 +41,18 @@ struct ca_descr_data {
}; };
#define CA_SET_DESCR_DATA _IOW('o', 137, struct ca_descr_data) #define CA_SET_DESCR_DATA _IOW('o', 137, struct ca_descr_data)
//#define CA_SET_DESCR_DATA _IOW('o', 10, struct ca_descr_data)
int descrambler_set_key(int index, int parity, unsigned char *data) int descrambler_set_key(int index, int parity, unsigned char *data)
{ {
struct ca_descr_data d; struct ca_descr_data d;
int ret; int ret;
printf("%s -> %s %s\n", FILENAME, __FUNCTION__, descrambler_filename); printf("%s -> %s\n", FILENAME, __FUNCTION__);
if (descrambler_open()) if (descrambler_open())
{ {
printf("Complete Data-> Index: (%d) Parity: (%d) -> ", index, parity); //printf("Complete Data-> Index: (%d) Parity: (%d) -> ", index, parity);
hexdump(data, 32); //hexdump(data, 32);
d.index = index; d.index = index;
d.parity = (ca_descr_parity)parity; d.parity = (ca_descr_parity)parity;
@@ -78,7 +75,7 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
d.length = 16; d.length = 16;
d.data = data + 16; d.data = data + 16;
printf("IV Index: (%d) Parity: (%d) -> ", d.index, d.parity); printf("IV Index: (%d) Parity: (%d) -> ", d.index, d.parity);
hexdump(d.data, 16); hexdump(d.data, 16);
ret = ioctl(desc_fd, CA_SET_DESCR_DATA, &d); ret = ioctl(desc_fd, CA_SET_DESCR_DATA, &d);
@@ -87,7 +84,6 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
printf("CA_SET_DESCR_DATA (IV) index=%d parity=%d (errno=%d %s)\n", index, parity, errno, strerror(errno)); printf("CA_SET_DESCR_DATA (IV) index=%d parity=%d (errno=%d %s)\n", index, parity, errno, strerror(errno));
} }
descrambler_close();
} }
return 0; return 0;
} }
@@ -102,7 +98,7 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
{ {
struct ca_descr_data d; struct ca_descr_data d;
printf("%s -> %s %s\n", FILENAME, __FUNCTION__, descrambler_filename); printf("%s -> %s\n", FILENAME, __FUNCTION__);
index |= 0x100; index |= 0x100;
@@ -125,7 +121,6 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
printf("Index: %d Parity: (%d) -> ", d.index, d.parity); printf("Index: %d Parity: (%d) -> ", d.index, d.parity);
hexdump(d.data, 32); hexdump(d.data, 32);
descrambler_close();
} }
return 0; return 0;
} }
@@ -165,6 +160,8 @@ int descrambler_set_pid(int index, int enable, int pid)
bool descrambler_open(void) bool descrambler_open(void)
{ {
if (desc_fd > 0)
return true;
desc_fd = open(descrambler_filename, O_RDWR | O_NONBLOCK ); desc_fd = open(descrambler_filename, O_RDWR | O_NONBLOCK );
if (desc_fd <= 0) { if (desc_fd <= 0) {
printf("cannot open %s\n", descrambler_filename); printf("cannot open %s\n", descrambler_filename);
@@ -176,6 +173,7 @@ bool descrambler_open(void)
int descrambler_init(void) int descrambler_init(void)
{ {
desc_user_count++; desc_user_count++;
descrambler_open();
printf("%s -> %s %d\n", FILENAME, __FUNCTION__, desc_user_count); printf("%s -> %s %d\n", FILENAME, __FUNCTION__, desc_user_count);
return 0; return 0;
} }

View File

@@ -1357,7 +1357,6 @@ void eDVBCIContentControlManagerSession::resendKey(eDVBCISlot *tslot)
{ {
for (unsigned int i = 0; i < slot->pids.size(); i++) for (unsigned int i = 0; i < slot->pids.size(); i++)
descrambler_set_pid((int)tslot->slot, 1, (int) slot->pids[i]); descrambler_set_pid((int)tslot->slot, 1, (int) slot->pids[i]);
descrambler_close();
} }
} }
slot->newPids = false; slot->newPids = false;
@@ -1372,7 +1371,6 @@ void eDVBCIContentControlManagerSession::resendKey(eDVBCISlot *tslot)
{ {
for (unsigned int i = 0; i < slot->pids.size(); i++) for (unsigned int i = 0; i < slot->pids.size(); i++)
descrambler_set_pid((int)tslot->slot, 1, (int) slot->pids[i]); descrambler_set_pid((int)tslot->slot, 1, (int) slot->pids[i]);
descrambler_close();
} }
} }
slot->newPids = false; slot->newPids = false;