mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
armbox: add dvbci (thx DboxOldie)
This commit is contained in:
@@ -9,13 +9,24 @@ AM_CXXFLAGS += \
|
||||
-I $(top_srcdir)/libdvbci
|
||||
endif
|
||||
|
||||
if BOXTYPE_ARMBOX
|
||||
AM_CXXFLAGS += \
|
||||
-I $(top_srcdir)/include \
|
||||
-I $(top_srcdir)/libdvbci
|
||||
endif
|
||||
|
||||
if BOXTYPE_DUCKBOX
|
||||
libcommon_la_SOURCES = \
|
||||
ca_ci.cpp
|
||||
else
|
||||
if BOXTYPE_ARMBOX
|
||||
libcommon_la_SOURCES = \
|
||||
ca_ci.cpp
|
||||
else
|
||||
libcommon_la_SOURCES = \
|
||||
ca.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
libcommon_la_SOURCES += \
|
||||
lt_debug.cpp \
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dummy functions to implement ca_cs.h interface
|
||||
*/
|
||||
#if HAVE_DUCKBOX_HARDWARE
|
||||
#if HAVE_DUCKBOX_HARDWARE || HAVE_ARM_HARDWARE
|
||||
#include "ca_ci.h"
|
||||
#else
|
||||
#ifndef __CA_LIBTRIPLE_H_
|
||||
|
959
common/ca_ci.cpp
959
common/ca_ci.cpp
File diff suppressed because it is too large
Load Diff
@@ -194,8 +194,10 @@ typedef struct
|
||||
|
||||
bool ccmgr_ready;
|
||||
|
||||
char ci_dev[32];
|
||||
char name[512];
|
||||
|
||||
bool newPids;
|
||||
bool newCapmt;
|
||||
bool multi;
|
||||
bool recordUse[CI_MAX_MULTI];
|
||||
@@ -212,6 +214,8 @@ typedef struct
|
||||
CaIdVector cam_caids;
|
||||
std::priority_queue<queueData> sendqueue;
|
||||
|
||||
std::vector<u16> pids;
|
||||
|
||||
bSIDVector bsids;
|
||||
unsigned char lastKey[32];
|
||||
unsigned char scrambled;
|
||||
@@ -237,6 +241,38 @@ private:
|
||||
cCA(void);
|
||||
/// Private data for the CA module
|
||||
CS_CA_PDATA *privateData;
|
||||
/// set inputs with tuner letter in tsmux
|
||||
void setInputs();
|
||||
/// write ci info file to /tmp
|
||||
void write_ci_info(int slot, CaIdVector caids);
|
||||
/// delete ci info file
|
||||
void del_ci_info(int slot);
|
||||
/// extract audio / video pids from capmt
|
||||
void extractPids(eDVBCISlot* slot);
|
||||
/// ci module is detected
|
||||
void ci_inserted(eDVBCISlot* slot);
|
||||
/// ci module is removed
|
||||
void ci_removed(eDVBCISlot* slot);
|
||||
/// decode the tpdu tag
|
||||
void process_tpdu(eDVBCISlot* slot, unsigned char tpdu_tag, __u8* data, int asn_data_length, int con_id);
|
||||
/// set flag of running ci record to false
|
||||
bool StopRecordCI( u64 TP, u16 SID, u8 source, u32 calen);
|
||||
/// set flag of running ci live-tv to false
|
||||
bool StopLiveCI( u64 TP, u16 SID, u8 source, u32 calen);
|
||||
/// find an unused ci slot for use with service
|
||||
SlotIt FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, u8 scrambled);
|
||||
/// get slot iterator by slot number
|
||||
SlotIt GetSlot(unsigned int slot);
|
||||
/// send buffered capmt to ci modul
|
||||
bool SendCaPMT(eDVBCISlot* slot);
|
||||
/// send a dummy capmt to ci for deactivating
|
||||
bool SendNullPMT(eDVBCISlot* slot);
|
||||
/// set ci source
|
||||
void setSource(eDVBCISlot* slot);
|
||||
/// set demux source
|
||||
void setInputSource(eDVBCISlot* slot, bool ci);
|
||||
/// check if data in queue
|
||||
bool checkQueueSize(eDVBCISlot* slot);
|
||||
enum CA_INIT_MASK initMask;
|
||||
int num_slots;
|
||||
bool init;
|
||||
@@ -246,7 +282,9 @@ private:
|
||||
pthread_t slot_thread;
|
||||
|
||||
public:
|
||||
/// sh4 unused
|
||||
bool Init(void);
|
||||
/// init ci and start the loop
|
||||
cCA(int Slots);
|
||||
/// Returns the number of CI slots
|
||||
uint32_t GetNumberCISlots(void);
|
||||
@@ -260,17 +298,23 @@ public:
|
||||
bool SendMessage(const CA_MESSAGE *Msg);
|
||||
/// Sets which modules to initialize. It is only
|
||||
/// possible to change this once!
|
||||
/// sh4 unused
|
||||
void SetInitMask(enum CA_INIT_MASK InitMask);
|
||||
/// Sets the frequency (in Hz) of the TS stream input (only valid for CI)
|
||||
void SetTSClock(u32 /*Speed*/) { return; };
|
||||
/// sh4 unused
|
||||
void SetTSClock(u32 Speed);
|
||||
/// Start the CA module
|
||||
/// sh4 unused
|
||||
bool Start(void);
|
||||
/// Stops the CA module
|
||||
/// sh4 unused
|
||||
void Stop(void);
|
||||
/// Notify that the GUI is ready to receive messages
|
||||
/// (CA messages coming from a module)
|
||||
/// sh4 unused
|
||||
void Ready(bool Set);
|
||||
/// Resets a module (if possible)
|
||||
/// sh4 unused
|
||||
void ModuleReset(enum CA_SLOT_TYPE, uint32_t Slot);
|
||||
/// Checks if a module is present
|
||||
bool ModulePresent(enum CA_SLOT_TYPE, uint32_t Slot);
|
||||
@@ -285,29 +329,20 @@ public:
|
||||
/// Notify the module we closed the menu
|
||||
void MenuClose(enum CA_SLOT_TYPE, uint32_t Slot);
|
||||
/// Get the supported CAIDs
|
||||
// int GetCAIDS(CaIdVector & /*Caids*/) { return 0; };
|
||||
int GetCAIDS(CaIdVector &Caids);
|
||||
/// Send a CA-PMT object and Raw unparsed PMT to the CA layer
|
||||
bool SendCAPMT(u64 /*Source*/, u8 /*DemuxSource*/, u8 /*DemuxMask*/, const unsigned char * /*CAPMT*/, u32 /*CAPMTLen*/, const unsigned char * /*RawPMT*/, u32 /*RawPMTLen*/, enum CA_SLOT_TYPE SlotType = CA_SLOT_TYPE_ALL,
|
||||
unsigned char scrambled = 0, ca_map_t camap = std::set<int>(), int mode = 0, bool enabled = false);
|
||||
|
||||
bool StopRecordCI( u64 TP, u16 SID, u8 source, u32 calen);
|
||||
bool StopLiveCI( u64 TP, u16 SID, u8 source, u32 calen);
|
||||
SlotIt FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned char scrambled);
|
||||
SlotIt GetSlot(unsigned int slot);
|
||||
/// sh4 unused
|
||||
bool SendDateTime(void);
|
||||
bool SendCaPMT(eDVBCISlot* slot);
|
||||
/// the main loop
|
||||
void slot_pollthread(void *c);
|
||||
void setSource(eDVBCISlot* slot);
|
||||
bool checkQueueSize(eDVBCISlot* slot);
|
||||
void process_tpdu(eDVBCISlot* slot, unsigned char tpdu_tag, __u8* data, int asn_data_length, int con_id);
|
||||
|
||||
/// check if current channel uses any ci module
|
||||
bool checkChannelID(u64 chanID);
|
||||
/// set checking for live-tv use ci to true
|
||||
void setCheckLiveSlot(int check);
|
||||
bool SendNullPMT(eDVBCISlot* slot);
|
||||
/// as the name says
|
||||
bool CheckCerts(void);
|
||||
void Test(int slot, CaIdVector caids);
|
||||
void DelTest(int slot);
|
||||
/// Virtual destructor
|
||||
virtual ~cCA();
|
||||
};
|
||||
|
@@ -131,6 +131,11 @@ void cPlayback::SetTitle(int /*title*/)
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t cPlayback::GetReadCount(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cPlayback::cPlayback(int /*num*/)
|
||||
{
|
||||
printf("%s:%s\n", FILENAME, __func__);
|
||||
|
@@ -40,7 +40,7 @@ inline void cs_api_exit()
|
||||
#define cs_free_uncached free
|
||||
|
||||
// Callback function helpers
|
||||
static inline void cs_register_messenger(cs_messenger) { return; };
|
||||
void cs_register_messenger(cs_messenger messenger);
|
||||
static inline void cs_deregister_messenger(void) { return; };
|
||||
//cs_messenger cs_get_messenger(void);
|
||||
|
||||
|
@@ -29,7 +29,7 @@ hw_caps_t *get_hwcaps(void)
|
||||
memset(&caps, 0, sizeof(hw_caps_t));
|
||||
|
||||
initialized = 1;
|
||||
caps.has_CI = 0;
|
||||
caps.has_CI = 1;
|
||||
caps.can_cec = 1;
|
||||
caps.can_shutdown = 1;
|
||||
caps.display_xres = 16;
|
||||
|
@@ -3,25 +3,106 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <linux/dvb/ca.h>
|
||||
|
||||
#include "misc.h"
|
||||
#include "descrambler.h"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
static const char * FILENAME = "[descrambler]";
|
||||
|
||||
static const char *descrambler_filename = "/dev/dvb/adapter0/ca3";
|
||||
static int desc_fd = -1;
|
||||
static int desc_user_count = 0;
|
||||
|
||||
#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";
|
||||
|
||||
enum ca_descr_data_type {
|
||||
CA_DATA_IV,
|
||||
CA_DATA_KEY,
|
||||
};
|
||||
|
||||
enum ca_descr_parity {
|
||||
CA_PARITY_EVEN,
|
||||
CA_PARITY_ODD,
|
||||
};
|
||||
|
||||
struct ca_descr_data {
|
||||
unsigned int index;
|
||||
enum ca_descr_parity parity;
|
||||
enum ca_descr_data_type data_type;
|
||||
unsigned int length;
|
||||
unsigned char *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)
|
||||
{
|
||||
struct ca_descr_data d;
|
||||
int ret;
|
||||
|
||||
printf("%s -> %s %s\n", FILENAME, __FUNCTION__, descrambler_filename);
|
||||
|
||||
if (descrambler_open())
|
||||
{
|
||||
printf("Complete Data-> Index: (%d) Parity: (%d) -> ", index, parity);
|
||||
hexdump(data, 32);
|
||||
|
||||
d.index = index;
|
||||
d.parity = (ca_descr_parity)parity;
|
||||
d.data_type = CA_DATA_KEY;
|
||||
d.length = 16;
|
||||
d.data = data;
|
||||
|
||||
printf("AES Index: (%d) Parity: (%d) -> ", d.index, d.parity);
|
||||
hexdump(d.data, 16);
|
||||
|
||||
ret = ioctl(desc_fd, CA_SET_DESCR_DATA, &d);
|
||||
if (ret)
|
||||
{
|
||||
printf("CA_SET_DESCR_DATA (AES) index=%d parity=%d (errno=%d %s)\n", index, parity, errno, strerror(errno));
|
||||
}
|
||||
|
||||
d.index = index;
|
||||
d.parity = (ca_descr_parity)parity;
|
||||
d.data_type = CA_DATA_IV;
|
||||
d.length = 16;
|
||||
d.data = data + 16;
|
||||
|
||||
printf("IV Index: (%d) Parity: (%d) -> ", d.index, d.parity);
|
||||
hexdump(d.data, 16);
|
||||
|
||||
ret = ioctl(desc_fd, CA_SET_DESCR_DATA, &d);
|
||||
if (ret)
|
||||
{
|
||||
printf("CA_SET_DESCR_DATA (IV) index=%d parity=%d (errno=%d %s)\n", index, parity, errno, strerror(errno));
|
||||
}
|
||||
|
||||
descrambler_close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static const char *descrambler_filename = "/dev/dvb/adapter0/ca3";
|
||||
|
||||
/* Byte 0 to 15 are AES Key, Byte 16 to 31 are IV */
|
||||
|
||||
int descrambler_set_key(int index, int parity, unsigned char *data)
|
||||
{
|
||||
struct ca_descr_data d;
|
||||
|
||||
printf("%s -> %s\n", FILENAME, __FUNCTION__);
|
||||
printf("%s -> %s %s\n", FILENAME, __FUNCTION__, descrambler_filename);
|
||||
|
||||
index |= 0x100;
|
||||
|
||||
@@ -32,37 +113,55 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
|
||||
d.data_type = CA_DATA_KEY;
|
||||
d.length = 32;
|
||||
d.data = data;
|
||||
#if 0
|
||||
printf("Index: %d Parity: (%d) -> ", d.index, d.parity);
|
||||
hexdump(d.data, 32);
|
||||
#endif
|
||||
if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d))
|
||||
{
|
||||
printf("CA_SET_DESCR_DATA index=%d parity=%d (errno=%d %s)\n", index, parity, errno, strerror(errno));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* we don't use this for sh4 ci cam ! */
|
||||
|
||||
/* we don't use this for ci cam ! */
|
||||
/*
|
||||
int descrambler_set_pid(int index, int enable, int pid)
|
||||
{
|
||||
struct ca_pid p;
|
||||
#if HAVE_ARM_HARDWARE
|
||||
unsigned int flags = 0x80;
|
||||
|
||||
if (index)
|
||||
flags |= 0x40;
|
||||
|
||||
if (enable)
|
||||
p.index = index;
|
||||
else
|
||||
p.index = -1;
|
||||
flags |= 0x20;
|
||||
|
||||
p.index = flags;
|
||||
p.pid = pid;
|
||||
#else
|
||||
p.index = index;
|
||||
if (enable)
|
||||
p.pid = pid;
|
||||
else
|
||||
p.pid = -1;
|
||||
#endif
|
||||
|
||||
if (ioctl(desc_fd, CA_SET_PID, &p))
|
||||
printf("CA_SET_PID\n");
|
||||
printf("CA_SET_PID pid=0x%04x index=0x%04x\n", p.pid, p.index);
|
||||
if (ioctl(desc_fd, CA_SET_PID, &p) == -1)
|
||||
printf("CA_SET_PID pid=0x%04x index=0x%04x (errno=%d %s)\n", p.pid, p.index, errno, strerror(errno));
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
bool descrambler_open(void)
|
||||
{
|
||||
@@ -74,12 +173,6 @@ bool descrambler_open(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void descrambler_close(void)
|
||||
{
|
||||
close(desc_fd);
|
||||
desc_fd = -1;
|
||||
}
|
||||
|
||||
int descrambler_init(void)
|
||||
{
|
||||
desc_user_count++;
|
||||
@@ -87,6 +180,12 @@ int descrambler_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void descrambler_close(void)
|
||||
{
|
||||
close(desc_fd);
|
||||
desc_fd = -1;
|
||||
}
|
||||
|
||||
void descrambler_deinit(void)
|
||||
{
|
||||
desc_user_count--;
|
||||
|
@@ -6,7 +6,7 @@ void descrambler_deinit(void);
|
||||
bool descrambler_open(void);
|
||||
void descrambler_close(void);
|
||||
int descrambler_set_key(int index, int parity, unsigned char *data);
|
||||
/* we don't use this for ci cam ! */
|
||||
//int descrambler_set_pid(int index, int enable, int pid);
|
||||
/* we don't use this for sh4 ci cam ! */
|
||||
int descrambler_set_pid(int index, int enable, int pid);
|
||||
|
||||
#endif
|
||||
|
@@ -1347,6 +1347,38 @@ void eDVBCIContentControlManagerSession::resendKey(eDVBCISlot *tslot)
|
||||
*/
|
||||
|
||||
if (!tslot->SidBlackListed && (tslot->recordUse[0] || tslot->liveUse[0]))
|
||||
{
|
||||
#if HAVE_ARM_HARDWARE
|
||||
if (slot->newPids)
|
||||
{
|
||||
if (slot->pids.size())
|
||||
{
|
||||
if (descrambler_open())
|
||||
{
|
||||
for (unsigned int i = 0; i < slot->pids.size(); i++)
|
||||
descrambler_set_pid((int)tslot->slot, 1, (int) slot->pids[i]);
|
||||
descrambler_close();
|
||||
}
|
||||
}
|
||||
slot->newPids = false;
|
||||
}
|
||||
descrambler_set_key((int)tslot->slot, tslot->lastParity, tslot->lastKey);
|
||||
#else
|
||||
if (slot->newPids)
|
||||
{
|
||||
if (slot->pids.size())
|
||||
{
|
||||
if (descrambler_open())
|
||||
{
|
||||
for (unsigned int i = 0; i < slot->pids.size(); i++)
|
||||
descrambler_set_pid((int)tslot->slot, 1, (int) slot->pids[i]);
|
||||
descrambler_close();
|
||||
}
|
||||
}
|
||||
slot->newPids = false;
|
||||
}
|
||||
descrambler_set_key((int)tslot->source, tslot->lastParity, tslot->lastKey);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,9 +5,9 @@
|
||||
|
||||
#define SLMS 256
|
||||
|
||||
#define ROOT_CERT "/etc/pem/root.pem"
|
||||
#define CUSTOMER_CERT "/etc/pem/customer.pem"
|
||||
#define DEVICE_CERT "/etc/pem/device.pem"
|
||||
#define ROOT_CERT "/etc/ssl/certs/root.pem"
|
||||
#define CUSTOMER_CERT "/etc/ssl/certs/customer.pem"
|
||||
#define DEVICE_CERT "/etc/ssl/certs/device.pem"
|
||||
|
||||
class eDVBCISession
|
||||
{
|
||||
|
Reference in New Issue
Block a user