libdvb_rs/ca/
sys.rs

1use std::mem;
2
3pub use {ca_descr_type::*, ca_slot_flags::*, ca_slot_type::*};
4
5mod ca_slot_type {
6    /// CI high level interface
7    pub const CA_CI: u32 = 1;
8    /// CI link layer level interface
9    pub const CA_CI_LINK: u32 = 2;
10    /// CI physical layer level interface
11    pub const CA_CI_PHYS: u32 = 4;
12    /// built-in descrambler
13    pub const CA_DESCR: u32 = 8;
14    /// simple smart card interface
15    pub const CA_SC: u32 = 128;
16}
17
18mod ca_slot_flags {
19    pub const CA_CI_MODULE_NOT_FOUND: u32 = 0;
20    /// module (or card) inserted
21    pub const CA_CI_MODULE_PRESENT: u32 = 1;
22    /// module is ready for usage
23    pub const CA_CI_MODULE_READY: u32 = 2;
24}
25
26/// CA slot interface types and info
27#[repr(C)]
28#[derive(Default, Debug)]
29pub struct CaSlotInfo {
30    /// slot number
31    pub slot_num: u32,
32    /// slot type - ca_slot_type
33    pub slot_type: u32,
34    /// flags applicable to the slot - ca_slot_flags
35    pub flags: u32,
36}
37
38mod ca_descr_type {
39    /// European Common Descrambler (ECD) hardware
40    pub const CA_ECD: u32 = 1;
41    /// Videoguard (NDS) hardware
42    pub const CA_NDS: u32 = 2;
43    /// Distributed Sample Scrambling (DSS) hardware
44    pub const CA_DSS: u32 = 4;
45}
46
47/// descrambler types and info
48#[repr(C)]
49#[derive(Default, Debug)]
50pub struct CaDescrInfo {
51    /// number of available descramblers (keys)
52    pub descr_num: u32,
53    /// type of supported scrambling system - ca_descr_type
54    pub descr_type: u32,
55}
56
57/// CA slot interface capabilities
58#[repr(C)]
59#[derive(Default, Debug)]
60pub struct CaCaps {
61    /// total number of CA card and module slots
62    pub slot_num: u32,
63    /// bitmap with all supported types as defined at ca_slot_info
64    pub slot_type: u32,
65    /// total number of descrambler slots (keys)
66    pub descr_num: u32,
67    /// bitmap with all supported types as defined at ca_descr_info
68    pub descr_type: u32,
69}
70
71/// a message to/from a CI-CAM
72#[repr(C)]
73#[derive(Debug)]
74pub struct CaMsg {
75    /// unused
76    index: u32,
77    /// unused
78    typ: u32,
79    /// length of the message
80    pub length: u32,
81    /// message
82    pub msg: [u8; 256],
83}
84
85impl Default for CaMsg {
86    #[inline]
87    fn default() -> Self {
88        unsafe { mem::zeroed::<Self>() }
89    }
90}
91
92/// CA descrambler control words info
93#[repr(C)]
94#[derive(Default, Debug)]
95pub struct CaDescr {
96    /// CA Descrambler slot
97    pub index: u32,
98    /// control words parity, where 0 means even and 1 means odd
99    pub parity: u32,
100    /// CA Descrambler control words
101    pub cw: [u8; 8],
102}
103
104#[repr(C)]
105#[derive(Default, Debug)]
106pub struct CaPid {
107    pub pid: u32,
108    /// -1 == disable
109    pub index: i32,
110}
111
112// pub const CA_GET_DESCR_INFO: IoctlInt = io_read::<CaDescrInfo>(b'o', 131);
113// pub const CA_GET_MSG: IoctlInt = io_read::<CaMsg>(b'o', 132);
114// pub const CA_SEND_MSG: IoctlInt = io_write::<CaMsg>(b'o', 133);
115// pub const CA_SET_DESCR: IoctlInt = io_write::<CaDescr>(b'o', 134);
116// pub const CA_SET_PID: IoctlInt = io_write::<CaPid>(b'o', 135);