11#include <linux/dvb/ca.h>
23 if (ioctl(
fd, CA_GET_CAP, &Caps) == 0) {
24 if ((Caps.slot_type & CA_CI_LINK) != 0) {
25 int NumSlots = Caps.slot_num;
27 for (
int i = 0; i < NumSlots; i++)
32 esyslog(
"ERROR: no CAM slots found on device %d",
device->DeviceNumber());
35 isyslog(
"device %d doesn't support CI link layer interface",
device->DeviceNumber());
38 esyslog(
"ERROR: can't get CA capabilities on device %d",
device->DeviceNumber());
48 if (Buffer && MaxLength > 0) {
51 pfd[0].events = POLLIN;
56 esyslog(
"ERROR: can't read from CI adapter on device %d: %m",
device->DeviceNumber());
64 if (Buffer && Length > 0) {
66 esyslog(
"ERROR: can't write to CI adapter on device %d: %m",
device->DeviceNumber());
72 if (ioctl(
fd, CA_RESET, 1 << Slot) != -1)
75 esyslog(
"ERROR: can't reset CAM slot %d on device %d: %m", Slot,
device->DeviceNumber());
83 if (ioctl(
fd, CA_GET_SLOT_INFO, &sinfo) != -1) {
84 if ((sinfo.flags & CA_CI_MODULE_READY) != 0)
86 else if ((sinfo.flags & CA_CI_MODULE_PRESENT) != 0)
90 esyslog(
"ERROR: can't get info of CAM slot %d on device %d: %m", Slot,
device->DeviceNumber());
cDvbCiAdapter(cDevice *Device, int Fd)
virtual void Write(const uint8_t *Buffer, int Length) override
Writes Length bytes of the given Buffer.
virtual int Read(uint8_t *Buffer, int MaxLength) override
Reads one chunk of data into the given Buffer, up to MaxLength bytes.
static cDvbCiAdapter * CreateCiAdapter(cDevice *Device, int Fd)
virtual ~cDvbCiAdapter() override
virtual eModuleStatus ModuleStatus(int Slot) override
Returns the status of the CAM in the given Slot.
virtual bool Reset(int Slot) override
Resets the CAM in the given Slot.
virtual bool Assign(cDevice *Device, bool Query=false) override
Assigns this adapter to the given Device, if this is possible.
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
void SetDescription(const char *Description,...) __attribute__((format(printf
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...