mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
test c**
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
|
||||
static const char * FILENAME = "[descrambler]";
|
||||
|
||||
static int desc_fd;
|
||||
static const char *descrambler_filename = "/dev/dvb/adapter0/ca3";
|
||||
static int desc_fd = -1;
|
||||
static int desc_user_count = 0;
|
||||
|
||||
/* Byte 0 to 15 are AES Key, Byte 16 to 31 are IV */
|
||||
|
||||
@@ -23,22 +25,28 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
|
||||
|
||||
index |= 0x100;
|
||||
|
||||
d.index = index;
|
||||
d.parity = (ca_descr_parity)parity;
|
||||
d.data_type = CA_DATA_KEY;
|
||||
d.length = 32;
|
||||
d.data = data;
|
||||
|
||||
printf("Index: %d Parity: (%d) -> ", d.index, d.parity);
|
||||
hexdump(d.data, 32);
|
||||
|
||||
if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d))
|
||||
if (descrambler_open())
|
||||
{
|
||||
//printf("CA_SET_DESCR_DATA\n");
|
||||
d.index = index;
|
||||
d.parity = (ca_descr_parity)parity;
|
||||
d.data_type = CA_DATA_KEY;
|
||||
d.length = 32;
|
||||
d.data = data;
|
||||
|
||||
printf("Index: %d Parity: (%d) -> ", d.index, d.parity);
|
||||
hexdump(d.data, 32);
|
||||
|
||||
if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d))
|
||||
{
|
||||
//printf("CA_SET_DESCR_DATA\n");
|
||||
}
|
||||
descrambler_close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* we don't use this for ci cam ! */
|
||||
/*
|
||||
int descrambler_set_pid(int index, int enable, int pid)
|
||||
{
|
||||
struct ca_pid p;
|
||||
@@ -54,23 +62,34 @@ int descrambler_set_pid(int index, int enable, int pid)
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
bool descrambler_open(void)
|
||||
{
|
||||
desc_fd = open(descrambler_filename, O_RDWR | O_NONBLOCK );
|
||||
if (desc_fd <= 0) {
|
||||
printf("cannot open %s\n", descrambler_filename);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void descrambler_close(void)
|
||||
{
|
||||
close(desc_fd);
|
||||
desc_fd = -1;
|
||||
}
|
||||
|
||||
int descrambler_init(void)
|
||||
{
|
||||
const char *filename = "/dev/dvb/adapter0/ca3";
|
||||
|
||||
printf("%s -> %s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
desc_fd = open(filename, O_RDWR | O_NONBLOCK );
|
||||
if (desc_fd <= 0) {
|
||||
printf("cannot open %s\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
desc_user_count++;
|
||||
printf("%s -> %s %d\n", FILENAME, __FUNCTION__, desc_user_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void descrambler_deinit(void)
|
||||
{
|
||||
close(desc_fd);
|
||||
desc_user_count--;
|
||||
if (desc_user_count <= 0 && desc_fd > 0)
|
||||
descrambler_close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user