Skip to content

Commit

Permalink
Merge branch 'Developer' into Python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev0-BH committed Dec 15, 2023
2 parents 9a9b9f0 + c5560ba commit 2cd1eb1
Show file tree
Hide file tree
Showing 26 changed files with 587 additions and 365 deletions.
10 changes: 5 additions & 5 deletions data/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@
<item level="1" text="Enable panic button" description="When enabled, pressing '0' will zap you to the first channel in your first bouquet and delete your zap-history.">config.usage.panicbutton</item>
<item level="1" text="Hide number markers" description="When enabled, number markers will be hidden.">config.usage.hide_number_markers</item>
<item level="1" text="Jump first press in channel selection" description="This option allows you to choose what the first button press jumps to in channel list screen, (so pressing '2' jumps to 'A' or '2' first), when 'Quick Actions' preset actions are perfomed. ">config.usage.show_channel_jump_in_servicelist</item>
<item level="0" text="Show event-progress in channel selection" description="Set the type of the progress indication in the channel selection screen.">config.usage.show_event_progress_in_servicelist</item>
<item level="0" text="Show channel numbers in channel selection" description="When enabled, show channel numbers in the channel selection screen.">config.usage.show_channel_numbers_in_servicelist</item>
<item level="2" text="Show two lines per entry" description="Show the service information on two lines in the channel selection screen.">config.usage.servicelist_twolines</item>
<item level="1" text="Show crypto icons" description="Configure if and how crypto icons will be shown in the channel selection list.">config.usage.crypto_icon_mode</item>
<item level="1" text="Show service type icons" description="Configure if and how service type icons will be shown.">config.usage.servicetype_icon_mode</item>
<item level="1" text="Show record indicator" description="Configure if and how the record indicator will be shown in the channel selection list.">config.usage.record_indicator_mode</item>
<item level="0" text="Show event-progress in channel selection" description="Set the type of the progress indication in the channel selection screen (right alignment only available in single line mode).">config.usage.show_event_progress_in_servicelist</item>
<item level="0" text="Show channel numbers in channel selection" description="When enabled, show channel numbers in the channel selection screen.">config.usage.show_channel_numbers_in_servicelist</item>
<item level="1" text="Show crypto icons" description="Configure if and how crypto icons will be shown in the channel selection list (left alignment only available in single line mode).">config.usage.crypto_icon_mode</item>
<item level="1" text="Show service type icons" description="Configure if and how service type icons will be shown (left alignment only available in single line mode).">config.usage.servicetype_icon_mode</item>
<item level="1" text="Show record indicator" description="Configure if and how the record indicator will be shown in the channel selection list (left alignment only available in single line mode).">config.usage.record_indicator_mode</item>
<item level="1" text="Show picons in service list" description="Configure if picons will be shown in the service list.">config.usage.service_icon_enable</item>
<item level="1" text="Show columns" conditional="config.usage.servicelist_twolines.value == '0'" description="Configure if and how wide the service name column will be shown in the channel selection list.">config.usage.servicelist_column</item>
<item level="1" text="Number of rows" description="This allows you to change the number of rows shown.">config.usage.serviceitems_per_page</item>
Expand Down
116 changes: 88 additions & 28 deletions lib/dvb_ci/descrambler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <sys/ioctl.h>
#include <linux/dvb/ca.h>

#include <lib/dvb_ci/descrambler.h>

#include <lib/base/eerror.h>

#ifndef CA_SET_PID
Expand Down Expand Up @@ -38,36 +40,94 @@ struct ca_descr_data {
unsigned char *data;
};

struct vu_ca_descr_data {
int slot_id;
int fix1; // = 0x6f7c
int demux_id;
int tunernum;
int use_count;
int program_number;
int reserved1;
int fix2; // = 0x1 -> add pids
int video_pid;
int audio_pid;
int reserved2;
int fix3; // = 0x12345678
int reserved3;
int key_register;
int use_aes; // 0x2 for AES
unsigned char key[16];
unsigned char iv[16];
int audio_number;
int audio_pids[16];
};


#define CA_SET_DESCR_DATA _IOW('o', 137, struct ca_descr_data)

int descrambler_set_key(int desc_fd, int index, int parity, unsigned char *data)
int descrambler_set_key(int& desc_fd, eDVBCISlot *slot, int parity, unsigned char *data)
{
struct ca_descr_data d;

if (desc_fd < 0)
return -1;

d.index = index;
d.parity = (enum ca_descr_parity)parity;
d.data_type = CA_DATA_KEY;
d.length = 16;
d.data = data;

if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d) == -1) {
eWarning("[CI descrambler] set key failed");
return -1;
bool vuIoctlSuccess = false;

if (slot->getTunerNum() > 7) // might be VU box with 2 FBC tuners -> try to use VU ioctl
{
struct vu_ca_descr_data d;

d.slot_id = slot->getSlotID();
d.fix1 = 0x6f7c;
d.demux_id = slot->getCADemuxID();
d.tunernum = slot->getTunerNum();
d.use_count = slot->getUseCount();
d.program_number = slot->getProgramNumber();
d.fix2 = 0x1;
d.video_pid = slot->getVideoPid();
d.audio_pid = slot->getAudioPid();
d.fix3 = 0x12345678;
d.key_register = parity;
d.use_aes = 0x2; // AES
memcpy(d.key, data, 16);
memcpy(d.iv, data + 16, 16);
d.audio_number = slot->getAudioNumber();
memcpy(d.audio_pids, slot->getAudioPids(), 16*4);

unsigned int ret = ioctl(slot->getFd(), 0x10, &d);
if (ret == 0)
{
vuIoctlSuccess = true;
descrambler_deinit(desc_fd); // don't set pids for VU ioctl
desc_fd = -1;
}
eDebug("[CI%d] descrambler_set_key vu ret %u", slot->getSlotID(), ret);
}

d.index = index;
d.parity = (enum ca_descr_parity)parity;
d.data_type = CA_DATA_IV;
d.length = 16;
d.data = data + 16;

if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d) == -1) {
eWarning("[CI descrambler] set iv failed");
return -1;
if (!vuIoctlSuccess)
{
struct ca_descr_data d;

if (desc_fd < 0)
return -1;

d.index = slot->getSlotID();
d.parity = (enum ca_descr_parity)parity;
d.data_type = CA_DATA_KEY;
d.length = 16;
d.data = data;

if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d) == -1) {
eWarning("[CI%d descrambler] set key failed", slot->getSlotID());
return -1;
}

d.index = slot->getSlotID();
d.parity = (enum ca_descr_parity)parity;
d.data_type = CA_DATA_IV;
d.length = 16;
d.data = data + 16;

if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d) == -1) {
eWarning("[CI%d descrambler] set iv failed", slot->getSlotID());
return -1;
}
}

return 0;
Expand All @@ -91,24 +151,24 @@ int descrambler_set_pid(int desc_fd, int index, int enable, int pid)
p.index = flags;

if (ioctl(desc_fd, CA_SET_PID, &p) == -1) {
eWarning("[CI descrambler] set pid failed");
eWarning("[CI%d descrambler] set pid failed", index);
return -1;
}

return 0;
}

int descrambler_init(uint8_t ca_demux_id)
int descrambler_init(int slot, uint8_t ca_demux_id)
{
int desc_fd;

std::string filename = "/dev/dvb/adapter0/ca" + std::to_string(ca_demux_id);

desc_fd = open(filename.c_str(), O_RDWR);
if (desc_fd == -1) {
eWarning("[CI descrambler] can not open %s", filename.c_str());
eWarning("[CI%d descrambler] can not open %s", slot, filename.c_str());
}
eDebug("[CI descrambler] using ca device %s", filename.c_str());
eDebug("[CI%d descrambler] using ca device %s", slot, filename.c_str());

return desc_fd;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/dvb_ci/descrambler.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef __DESCR_H_
#define __DESCR_H_

int descrambler_init(uint8_t ca_demux_id);
#include <lib/dvb_ci/dvbci.h>

int descrambler_init(int slot, uint8_t ca_demux_id);
void descrambler_deinit(int desc_fd);
int descrambler_set_key(int desc_fd, int index, int parity, unsigned char *data);
int descrambler_set_key(int& desc_fd, eDVBCISlot *slot, int parity, unsigned char *data);
int descrambler_set_pid(int desc_fd, int index, int enable, int pid);

#endif
Loading

0 comments on commit 2cd1eb1

Please sign in to comment.