1
0
mirror of https://github.com/danog/libdvb.git synced 2024-11-30 04:19:00 +01:00

Begin refactoring

This commit is contained in:
Daniil Gentili 2022-02-15 16:18:01 +01:00
parent 67c12ea17b
commit 3047ef2e18
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 322 additions and 286 deletions

View File

@ -14,3 +14,4 @@ edition = "2018"
[dependencies] [dependencies]
nix = "0.19" nix = "0.19"
anyhow = "1.0" anyhow = "1.0"
strum = { version = "0.23", features = ["derive"] }

View File

@ -55,7 +55,7 @@ pub struct FeDevice {
api_version: u16, api_version: u16,
name: String, name: String,
delivery_system_list: Vec<u32>, delivery_system_list: Vec<fe_delivery_system>,
frequency_range: Range<u32>, frequency_range: Range<u32>,
symbolrate_range: Range<u32>, symbolrate_range: Range<u32>,
caps: u32, caps: u32,
@ -69,7 +69,7 @@ impl fmt::Display for FeDevice {
write!(f, "Delivery system:")?; write!(f, "Delivery system:")?;
for v in &self.delivery_system_list { for v in &self.delivery_system_list {
write!(f, " {}", &DeliverySystemDisplay(*v))?; write!(f, " {}", &v)?;
} }
writeln!(f, "")?; writeln!(f, "")?;
@ -343,8 +343,8 @@ impl FeDevice {
/// - [`FE_HAS_LOCK`] /// - [`FE_HAS_LOCK`]
/// - [`FE_TIMEDOUT`] /// - [`FE_TIMEDOUT`]
/// - [`FE_REINIT`] /// - [`FE_REINIT`]
pub fn read_status(&self) -> Result<u32> { pub fn read_status(&self) -> Result<fe_status> {
let mut result: u32 = FE_NONE; let mut result: u32 = FE_NONE as u32;
// FE_READ_STATUS // FE_READ_STATUS
ioctl_read!(#[inline] ioctl_call, b'o', 69, u32); ioctl_read!(#[inline] ioctl_call, b'o', 69, u32);
@ -352,7 +352,7 @@ impl FeDevice {
ioctl_call(self.as_raw_fd(), &mut result as *mut _) ioctl_call(self.as_raw_fd(), &mut result as *mut _)
}.context("FE: read status")?; }.context("FE: read status")?;
Ok(result) Ok(fe_status::from_repr(result).context("Invalid status")?)
} }
/// Reads and returns a signal strength relative value (DVBv3 API) /// Reads and returns a signal strength relative value (DVBv3 API)

View File

@ -15,8 +15,8 @@ use {
/// Frontend status /// Frontend status
#[derive(Debug)] #[derive(Debug)]
pub struct FeStatus { pub struct FeStatus {
/// `sys::frontend::fe_status` /// `sys::frontend::FeStatus`
status: u32, status: fe_status,
/// properties /// properties
props: [DtvProperty; 6], props: [DtvProperty; 6],
@ -91,7 +91,7 @@ impl fmt::Display for FeStatus {
} }
if self.status & FE_HAS_LOCK != 0 { if self.status & FE_HAS_LOCK != 0 {
write!(f, "LOCK {}", DeliverySystemDisplay(self.get_delivery_system()))?; write!(f, "LOCK {}", self.get_delivery_system())?;
} else { } else {
write!(f, "NO-LOCK 0x{:02X}", self.status)?; write!(f, "NO-LOCK 0x{:02X}", self.status)?;
} }

View File

@ -27,80 +27,89 @@ pub use {
dtv_property_cmd::*, dtv_property_cmd::*,
}; };
use strum::{Display, FromRepr};
/// Frontend capabilities /// Frontend capabilities
mod fe_caps { #[repr(u32)]
#[allow(non_camel_case_types)]
#[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)]
pub enum fe_caps {
/// There's something wrong at the frontend, and it can't report its capabilities /// There's something wrong at the frontend, and it can't report its capabilities
pub const FE_IS_STUPID: u32 = 0; FE_IS_STUPID = 0,
/// Can auto-detect frequency spectral band inversion /// Can auto-detect frequency spectral band inversion
pub const FE_CAN_INVERSION_AUTO: u32 = 0x1; FE_CAN_INVERSION_AUTO = 0x1,
/// Supports FEC 1/2 /// Supports FEC 1/2
pub const FE_CAN_FEC_1_2: u32 = 0x2; FE_CAN_FEC_1_2 = 0x2,
/// Supports FEC 2/3 /// Supports FEC 2/3
pub const FE_CAN_FEC_2_3: u32 = 0x4; FE_CAN_FEC_2_3 = 0x4,
/// Supports FEC 3/4 /// Supports FEC 3/4
pub const FE_CAN_FEC_3_4: u32 = 0x8; FE_CAN_FEC_3_4 = 0x8,
/// Supports FEC 4/5 /// Supports FEC 4/5
pub const FE_CAN_FEC_4_5: u32 = 0x10; FE_CAN_FEC_4_5 = 0x10,
/// Supports FEC 5/6 /// Supports FEC 5/6
pub const FE_CAN_FEC_5_6: u32 = 0x20; FE_CAN_FEC_5_6 = 0x20,
/// Supports FEC 6/7 /// Supports FEC 6/7
pub const FE_CAN_FEC_6_7: u32 = 0x40; FE_CAN_FEC_6_7 = 0x40,
/// Supports FEC 7/8 /// Supports FEC 7/8
pub const FE_CAN_FEC_7_8: u32 = 0x80; FE_CAN_FEC_7_8 = 0x80,
/// Supports FEC 8/9 /// Supports FEC 8/9
pub const FE_CAN_FEC_8_9: u32 = 0x100; FE_CAN_FEC_8_9 = 0x100,
/// Can auto-detect FEC /// Can auto-detect FEC
pub const FE_CAN_FEC_AUTO: u32 = 0x200; FE_CAN_FEC_AUTO = 0x200,
/// Supports QPSK modulation /// Supports QPSK modulation
pub const FE_CAN_QPSK: u32 = 0x400; FE_CAN_QPSK = 0x400,
/// Supports 16-QAM modulation /// Supports 16-QAM modulation
pub const FE_CAN_QAM_16: u32 = 0x800; FE_CAN_QAM_16 = 0x800,
/// Supports 32-QAM modulation /// Supports 32-QAM modulation
pub const FE_CAN_QAM_32: u32 = 0x1000; FE_CAN_QAM_32 = 0x1000,
/// Supports 64-QAM modulation /// Supports 64-QAM modulation
pub const FE_CAN_QAM_64: u32 = 0x2000; FE_CAN_QAM_64 = 0x2000,
/// Supports 128-QAM modulation /// Supports 128-QAM modulation
pub const FE_CAN_QAM_128: u32 = 0x4000; FE_CAN_QAM_128 = 0x4000,
/// Supports 256-QAM modulation /// Supports 256-QAM modulation
pub const FE_CAN_QAM_256: u32 = 0x8000; FE_CAN_QAM_256 = 0x8000,
/// Can auto-detect QAM modulation /// Can auto-detect QAM modulation
pub const FE_CAN_QAM_AUTO: u32 = 0x10000; FE_CAN_QAM_AUTO = 0x10000,
/// Can auto-detect transmission mode /// Can auto-detect transmission mode
pub const FE_CAN_TRANSMISSION_MODE_AUTO: u32 = 0x20000; FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000,
/// Can auto-detect bandwidth /// Can auto-detect bandwidth
pub const FE_CAN_BANDWIDTH_AUTO: u32 = 0x40000; FE_CAN_BANDWIDTH_AUTO = 0x40000,
/// Can auto-detect guard interval /// Can auto-detect guard interval
pub const FE_CAN_GUARD_INTERVAL_AUTO: u32 = 0x80000; FE_CAN_GUARD_INTERVAL_AUTO = 0x80000,
/// Can auto-detect hierarchy /// Can auto-detect hierarchy
pub const FE_CAN_HIERARCHY_AUTO: u32 = 0x100000; FE_CAN_HIERARCHY_AUTO = 0x100000,
/// Supports 8-VSB modulation /// Supports 8-VSB modulation
pub const FE_CAN_8VSB: u32 = 0x200000; FE_CAN_8VSB = 0x200000,
/// Supports 16-VSB modulation /// Supports 16-VSB modulation
pub const FE_CAN_16VSB: u32 = 0x400000; FE_CAN_16VSB = 0x400000,
/// Unused /// Unused
pub const FE_HAS_EXTENDED_CAPS: u32 = 0x800000; FE_HAS_EXTENDED_CAPS = 0x800000,
/// Supports multistream filtering /// Supports multistream filtering
pub const FE_CAN_MULTISTREAM: u32 = 0x4000000; FE_CAN_MULTISTREAM = 0x4000000,
/// Supports "turbo FEC" modulation /// Supports "turbo FEC" modulation
pub const FE_CAN_TURBO_FEC: u32 = 0x8000000; FE_CAN_TURBO_FEC = 0x8000000,
/// Supports "2nd generation" modulation, e. g. DVB-S2, DVB-T2, DVB-C2 /// Supports "2nd generation" modulation, e. g. DVB-S2, DVB-T2, DVB-C2
pub const FE_CAN_2G_MODULATION: u32 = 0x10000000; FE_CAN_2G_MODULATION = 0x10000000,
/// Unused /// Unused
pub const FE_NEEDS_BENDING: u32 = 0x20000000; FE_NEEDS_BENDING = 0x20000000,
/// Can recover from a cable unplug automatically /// Can recover from a cable unplug automatically
pub const FE_CAN_RECOVER: u32 = 0x40000000; FE_CAN_RECOVER = 0x40000000,
/// Can stop spurious TS data output /// Can stop spurious TS data output
pub const FE_CAN_MUTE_TS: u32 = 0x80000000; FE_CAN_MUTE_TS = 0x80000000,
} }
/// DEPRECATED: Should be kept just due to backward compatibility /// DEPRECATED: Should be kept just due to backward compatibility
mod fe_type { #[repr(u32)]
pub const FE_QPSK: u32 = 0; #[allow(non_camel_case_types)]
pub const FE_QAM: u32 = 1; #[allow(non_camel_case_types)]
pub const FE_OFDM: u32 = 2; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const FE_ATSC: u32 = 3; pub enum fe_type {
FE_QPSK = 0,
FE_QAM = 1,
FE_OFDM = 2,
FE_ATSC = 3,
} }
@ -192,225 +201,253 @@ impl Default for DiseqcSlaveReply {
/// DC Voltage used to feed the LNBf /// DC Voltage used to feed the LNBf
mod fe_sec_voltage { #[repr(u32)]
#[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)]
pub enum fe_sec_voltage {
/// Output 13V to the LNB. Vertical linear. Right circular. /// Output 13V to the LNB. Vertical linear. Right circular.
pub const SEC_VOLTAGE_13: u32 = 0; SEC_VOLTAGE_13 = 0,
/// Output 18V to the LNB. Horizontal linear. Left circular. /// Output 18V to the LNB. Horizontal linear. Left circular.
pub const SEC_VOLTAGE_18: u32 = 1; SEC_VOLTAGE_18 = 1,
/// Don't feed the LNB with a DC voltage /// Don't feed the LNB with a DC voltage
pub const SEC_VOLTAGE_OFF: u32 = 2; SEC_VOLTAGE_OFF = 2,
} }
mod fe_sec_tone_mode { #[repr(u32)]
#[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)]
pub enum fe_sec_tone_mode {
/// Sends a 22kHz tone burst to the antenna /// Sends a 22kHz tone burst to the antenna
pub const SEC_TONE_ON: u32 = 0; SEC_TONE_ON = 0,
/// Don't send a 22kHz tone to the antenna (except if the FE_DISEQC_* ioctl are called) /// Don't send a 22kHz tone to the antenna (except if the FE_DISEQC_* ioctl are called)
pub const SEC_TONE_OFF: u32 = 1; SEC_TONE_OFF = 1,
} }
/// Type of mini burst to be sent /// Type of mini burst to be sent
mod fe_sec_mini_cmd { #[repr(u32)]
#[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)]
pub enum fe_sec_mini_cmd {
/// Sends a mini-DiSEqC 22kHz '0' Tone Burst to select satellite-A /// Sends a mini-DiSEqC 22kHz '0' Tone Burst to select satellite-A
pub const SEC_MINI_A: u32 = 0; SEC_MINI_A = 0,
/// Sends a mini-DiSEqC 22kHz '1' Data Burst to select satellite-B /// Sends a mini-DiSEqC 22kHz '1' Data Burst to select satellite-B
pub const SEC_MINI_B: u32 = 1; SEC_MINI_B = 1,
} }
/// Enumerates the possible frontend status /// Enumerates the possible frontend status
mod fe_status { #[repr(u32)]
#[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)]
pub enum fe_status {
/// The frontend doesn't have any kind of lock. That's the initial frontend status /// The frontend doesn't have any kind of lock. That's the initial frontend status
pub const FE_NONE: u32 = 0x00; FE_NONE = 0x00,
/// Has found something above the noise level /// Has found something above the noise level
pub const FE_HAS_SIGNAL: u32 = 0x01; FE_HAS_SIGNAL = 0x01,
/// Has found a signal /// Has found a signal
pub const FE_HAS_CARRIER: u32 = 0x02; FE_HAS_CARRIER = 0x02,
/// FEC inner coding (Viterbi, LDPC or other inner code) is stable. /// FEC inner coding (Viterbi, LDPC or other inner code) is stable.
pub const FE_HAS_VITERBI: u32 = 0x04; FE_HAS_VITERBI = 0x04,
/// Synchronization bytes was found /// Synchronization bytes was found
pub const FE_HAS_SYNC: u32 = 0x08; FE_HAS_SYNC = 0x08,
/// Digital TV were locked and everything is working /// Digital TV were locked and everything is working
pub const FE_HAS_LOCK: u32 = 0x10; FE_HAS_LOCK = 0x10,
/// Fo lock within the last about 2 seconds /// Fo lock within the last about 2 seconds
pub const FE_TIMEDOUT: u32 = 0x20; FE_TIMEDOUT = 0x20,
/// Frontend was reinitialized, application is recommended /// Frontend was reinitialized, application is recommended
/// to reset DiSEqC, tone and parameters /// to reset DiSEqC, tone and parameters
pub const FE_REINIT: u32 = 0x40; FE_REINIT = 0x40,
} }
/// Spectral band inversion /// Spectral band inversion
mod fe_spectral_inversion { #[repr(u32)]
pub const INVERSION_OFF: u32 = 0; #[allow(non_camel_case_types)]
pub const INVERSION_ON: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const INVERSION_AUTO: u32 = 2; pub enum fe_spectral_inversion {
INVERSION_OFF = 0,
INVERSION_ON = 1,
INVERSION_AUTO = 2,
} }
mod fe_code_rate { #[repr(u32)]
pub const FEC_NONE: u32 = 0; #[allow(non_camel_case_types)]
pub const FEC_1_2: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const FEC_2_3: u32 = 2; pub enum fe_code_rate {
pub const FEC_3_4: u32 = 3; FEC_NONE = 0,
pub const FEC_4_5: u32 = 4; FEC_1_2 = 1,
pub const FEC_5_6: u32 = 5; FEC_2_3 = 2,
pub const FEC_6_7: u32 = 6; FEC_3_4 = 3,
pub const FEC_7_8: u32 = 7; FEC_4_5 = 4,
pub const FEC_8_9: u32 = 8; FEC_5_6 = 5,
pub const FEC_AUTO: u32 = 9; FEC_6_7 = 6,
pub const FEC_3_5: u32 = 10; FEC_7_8 = 7,
pub const FEC_9_10: u32 = 11; FEC_8_9 = 8,
pub const FEC_2_5: u32 = 12; FEC_AUTO = 9,
pub const FEC_1_4: u32 = 13; FEC_3_5 = 10,
pub const FEC_1_3: u32 = 14; FEC_9_10 = 11,
FEC_2_5 = 12,
FEC_1_4 = 13,
FEC_1_3 = 14,
} }
/// Type of modulation/constellation /// Type of modulation/constellation
mod fe_modulation { #[repr(u32)]
pub const QPSK: u32 = 0; #[allow(non_camel_case_types)]
pub const QAM_16: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const QAM_32: u32 = 2; pub enum fe_modulation {
pub const QAM_64: u32 = 3; QPSK = 0,
pub const QAM_128: u32 = 4; QAM_16 = 1,
pub const QAM_256: u32 = 5; QAM_32 = 2,
pub const QAM_AUTO: u32 = 6; QAM_64 = 3,
pub const VSB_8: u32 = 7; QAM_128 = 4,
pub const VSB_16: u32 = 8; QAM_256 = 5,
pub const PSK_8: u32 = 9; QAM_AUTO = 6,
pub const APSK_16: u32 = 10; VSB_8 = 7,
pub const APSK_32: u32 = 11; VSB_16 = 8,
pub const DQPSK: u32 = 12; PSK_8 = 9,
pub const QAM_4_NR: u32 = 13; APSK_16 = 10,
pub const APSK_64: u32 = 14; APSK_32 = 11,
pub const APSK_128: u32 = 15; DQPSK = 12,
pub const APSK_256: u32 = 16; QAM_4_NR = 13,
APSK_64 = 14,
APSK_128 = 15,
APSK_256 = 16,
} }
mod fe_transmit_mode { #[repr(u32)]
pub const TRANSMISSION_MODE_2K: u32 = 0; #[allow(non_camel_case_types)]
pub const TRANSMISSION_MODE_8K: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const TRANSMISSION_MODE_AUTO: u32 = 2; pub enum fe_transmit_mode {
pub const TRANSMISSION_MODE_4K: u32 = 3; TRANSMISSION_MODE_2K = 0,
pub const TRANSMISSION_MODE_1K: u32 = 4; TRANSMISSION_MODE_8K = 1,
pub const TRANSMISSION_MODE_16K: u32 = 5; TRANSMISSION_MODE_AUTO = 2,
pub const TRANSMISSION_MODE_32K: u32 = 6; TRANSMISSION_MODE_4K = 3,
pub const TRANSMISSION_MODE_C1: u32 = 7; TRANSMISSION_MODE_1K = 4,
pub const TRANSMISSION_MODE_C3780: u32 = 8; TRANSMISSION_MODE_16K = 5,
TRANSMISSION_MODE_32K = 6,
TRANSMISSION_MODE_C1 = 7,
TRANSMISSION_MODE_C3780 = 8,
} }
mod fe_guard_interval { #[repr(u32)]
pub const GUARD_INTERVAL_1_32: u32 = 0; #[allow(non_camel_case_types)]
pub const GUARD_INTERVAL_1_16: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const GUARD_INTERVAL_1_8: u32 = 2; pub enum fe_guard_interval {
pub const GUARD_INTERVAL_1_4: u32 = 3; GUARD_INTERVAL_1_32 = 0,
pub const GUARD_INTERVAL_AUTO: u32 = 4; GUARD_INTERVAL_1_16 = 1,
pub const GUARD_INTERVAL_1_128: u32 = 5; GUARD_INTERVAL_1_8 = 2,
pub const GUARD_INTERVAL_19_128: u32 = 6; GUARD_INTERVAL_1_4 = 3,
pub const GUARD_INTERVAL_19_256: u32 = 7; GUARD_INTERVAL_AUTO = 4,
pub const GUARD_INTERVAL_PN420: u32 = 8; GUARD_INTERVAL_1_128 = 5,
pub const GUARD_INTERVAL_PN595: u32 = 9; GUARD_INTERVAL_19_128 = 6,
pub const GUARD_INTERVAL_PN945: u32 = 10; GUARD_INTERVAL_19_256 = 7,
GUARD_INTERVAL_PN420 = 8,
GUARD_INTERVAL_PN595 = 9,
GUARD_INTERVAL_PN945 = 10,
} }
mod fe_hierarchy { #[repr(u32)]
pub const HIERARCHY_NONE: u32 = 0; #[allow(non_camel_case_types)]
pub const HIERARCHY_1: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const HIERARCHY_2: u32 = 2; pub enum fe_hierarchy {
pub const HIERARCHY_4: u32 = 3; HIERARCHY_NONE = 0,
pub const HIERARCHY_AUTO: u32 = 4; HIERARCHY_1 = 1,
HIERARCHY_2 = 2,
HIERARCHY_4 = 3,
HIERARCHY_AUTO = 4,
} }
mod fe_interleaving { #[repr(u32)]
pub const INTERLEAVING_NONE: u32 = 0; #[allow(non_camel_case_types)]
pub const INTERLEAVING_AUTO: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const INTERLEAVING_240: u32 = 2; pub enum fe_interleaving {
pub const INTERLEAVING_720: u32 = 3; INTERLEAVING_NONE = 0,
INTERLEAVING_AUTO = 1,
INTERLEAVING_240 = 2,
INTERLEAVING_720 = 3,
} }
mod fe_pilot { #[repr(u32)]
pub const PILOT_ON: u32 = 0; #[allow(non_camel_case_types)]
pub const PILOT_OFF: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const PILOT_AUTO: u32 = 2; pub enum fe_pilot {
PILOT_ON = 0,
PILOT_OFF = 1,
PILOT_AUTO = 2,
} }
mod fe_rolloff { #[repr(u32)]
pub const ROLLOFF_35: u32 = 0; #[allow(non_camel_case_types)]
pub const ROLLOFF_20: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const ROLLOFF_25: u32 = 2; pub enum fe_rolloff {
pub const ROLLOFF_AUTO: u32 = 3; ROLLOFF_35 = 0,
pub const ROLLOFF_15: u32 = 4; ROLLOFF_20 = 1,
pub const ROLLOFF_10: u32 = 5; ROLLOFF_25 = 2,
pub const ROLLOFF_5: u32 = 6; ROLLOFF_AUTO = 3,
ROLLOFF_15 = 4,
ROLLOFF_10 = 5,
ROLLOFF_5 = 6,
} }
mod fe_delivery_system { #[derive(Display, Debug)]
use std::fmt; #[repr(u32)]
#[allow(non_camel_case_types)]
pub enum fe_delivery_system {
pub const SYS_UNDEFINED: u32 = 0; #[strum(to_string = "none")]
pub const SYS_DVBC_ANNEX_A: u32 = 1; SYS_UNDEFINED = 0,
pub const SYS_DVBC_ANNEX_B: u32 = 2; #[strum(to_string = "dvb-c")]
pub const SYS_DVBT: u32 = 3; SYS_DVBC_ANNEX_A = 1,
pub const SYS_DSS: u32 = 4; #[strum(to_string = "dvb-c/b")]
pub const SYS_DVBS: u32 = 5; SYS_DVBC_ANNEX_B = 2,
pub const SYS_DVBS2: u32 = 6; #[strum(to_string = "dvb-t")]
pub const SYS_DVBH: u32 = 7; SYS_DVBT = 3,
pub const SYS_ISDBT: u32 = 8; #[strum(to_string = "dss")]
pub const SYS_ISDBS: u32 = 9; SYS_DSS = 4,
pub const SYS_ISDBC: u32 = 10; #[strum(to_string = "dvb-s")]
pub const SYS_ATSC: u32 = 11; SYS_DVBS = 5,
pub const SYS_ATSCMH: u32 = 12; #[strum(to_string = "dvb-s2")]
pub const SYS_DTMB: u32 = 13; SYS_DVBS2 = 6,
pub const SYS_CMMB: u32 = 14; #[strum(to_string = "dvb-h")]
pub const SYS_DAB: u32 = 15; SYS_DVBH = 7,
pub const SYS_DVBT2: u32 = 16; #[strum(to_string = "isdb-t")]
pub const SYS_TURBO: u32 = 17; SYS_ISDBT = 8,
pub const SYS_DVBC_ANNEX_C: u32 = 18; #[strum(to_string = "isdb-s")]
pub const SYS_DVBC2: u32 = 19; SYS_ISDBS = 9,
#[strum(to_string = "isdb-c")]
pub struct DeliverySystemDisplay(pub u32); SYS_ISDBC = 10,
#[strum(to_string = "atsc")]
impl fmt::Display for DeliverySystemDisplay { SYS_ATSC = 11,
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[strum(to_string = "atsc-m/h")]
let v = match self.0 { SYS_ATSCMH = 12,
SYS_UNDEFINED => "none", #[strum(to_string = "dtmb")]
SYS_DVBC_ANNEX_A => "dvb-c", SYS_DTMB = 13,
SYS_DVBC_ANNEX_B => "dvb-c/b", #[strum(to_string = "cmmb")]
SYS_DVBT => "dvb-t", SYS_CMMB = 14,
SYS_DSS => "dss", #[strum(to_string = "dab")]
SYS_DVBS => "dvb-s", SYS_DAB = 15,
SYS_DVBS2 => "dvb-s2", #[strum(to_string = "dvb-t2")]
SYS_DVBH => "dvb-h", SYS_DVBT2 = 16,
SYS_ISDBT => "isdb-t", #[strum(to_string = "dvb-s/turbo")]
SYS_ISDBS => "isdb-s", SYS_TURBO = 17,
SYS_ISDBC => "isdb-c", #[strum(to_string = "dvb-c/c")]
SYS_ATSC => "atsc", SYS_DVBC_ANNEX_C = 18,
SYS_ATSCMH => "atsc-m/h", #[strum(to_string = "dvb-c2")]
SYS_DTMB => "dtmb", SYS_DVBC2 = 19,
SYS_CMMB => "cmmb",
SYS_DAB => "dab",
SYS_DVBT2 => "dvb-t2",
SYS_TURBO => "dvb-s/turbo",
SYS_DVBC_ANNEX_C => "dvb-c/c",
SYS_DVBC2 => "dvb-c2",
_ => "unknown",
};
write!(f, "{}", v)
}
}
} }
/// scale types for the quality parameters /// scale types for the quality parameters
mod fecap_scale_params { mod fecap_scale_params {
/// That QoS measure is not available. That could indicate /// That QoS measure is not available. That could indicate
@ -501,122 +538,124 @@ pub struct DtvPropertyBuffer {
#[repr(C)] #[repr(C)]
pub union DtvPropertyData { pub enum DtvPropertyData {
pub data: u32, data(u32),
pub st: DtvFrontendStats, st(DtvFrontendStats),
pub buffer: DtvPropertyBuffer, buffer(DtvPropertyBuffer),
__align: [u8; 56],
} }
/// DVBv5 property Commands /// DVBv5 property Commands
mod dtv_property_cmd { #[repr(u32)]
pub const DTV_UNDEFINED: u32 = 0; #[allow(non_camel_case_types)]
pub const DTV_TUNE: u32 = 1; #[derive(Debug, PartialEq, Eq, FromRepr)]
pub const DTV_CLEAR: u32 = 2; pub enum dtv_property_cmd {
pub const DTV_FREQUENCY: u32 = 3; DTV_UNDEFINED = 0,
pub const DTV_MODULATION: u32 = 4; DTV_TUNE = 1,
pub const DTV_BANDWIDTH_HZ: u32 = 5; DTV_CLEAR = 2,
pub const DTV_INVERSION: u32 = 6; DTV_FREQUENCY = 3,
pub const DTV_DISEQC_MASTER: u32 = 7; DTV_MODULATION = 4,
pub const DTV_SYMBOL_RATE: u32 = 8; DTV_BANDWIDTH_HZ = 5,
pub const DTV_INNER_FEC: u32 = 9; DTV_INVERSION = 6,
pub const DTV_VOLTAGE: u32 = 10; DTV_DISEQC_MASTER = 7,
pub const DTV_TONE: u32 = 11; DTV_SYMBOL_RATE = 8,
pub const DTV_PILOT: u32 = 12; DTV_INNER_FEC = 9,
pub const DTV_ROLLOFF: u32 = 13; DTV_VOLTAGE = 10,
pub const DTV_DISEQC_SLAVE_REPLY: u32 = 14; DTV_TONE = 11,
DTV_PILOT = 12,
DTV_ROLLOFF = 13,
DTV_DISEQC_SLAVE_REPLY = 14,
/* Basic enumeration set for querying unlimited capabilities */ /* Basic enumeration set for querying unlimited capabilities */
pub const DTV_FE_CAPABILITY_COUNT: u32 = 15; DTV_FE_CAPABILITY_COUNT = 15,
pub const DTV_FE_CAPABILITY: u32 = 16; DTV_FE_CAPABILITY = 16,
pub const DTV_DELIVERY_SYSTEM: u32 = 17; DTV_DELIVERY_SYSTEM = 17,
/* ISDB-T and ISDB-Tsb */ /* ISDB-T and ISDB-Tsb */
pub const DTV_ISDBT_PARTIAL_RECEPTION: u32 = 18; DTV_ISDBT_PARTIAL_RECEPTION = 18,
pub const DTV_ISDBT_SOUND_BROADCASTING: u32 = 19; DTV_ISDBT_SOUND_BROADCASTING = 19,
pub const DTV_ISDBT_SB_SUBCHANNEL_ID: u32 = 20; DTV_ISDBT_SB_SUBCHANNEL_ID = 20,
pub const DTV_ISDBT_SB_SEGMENT_IDX: u32 = 21; DTV_ISDBT_SB_SEGMENT_IDX = 21,
pub const DTV_ISDBT_SB_SEGMENT_COUNT: u32 = 22; DTV_ISDBT_SB_SEGMENT_COUNT = 22,
pub const DTV_ISDBT_LAYERA_FEC: u32 = 23; DTV_ISDBT_LAYERA_FEC = 23,
pub const DTV_ISDBT_LAYERA_MODULATION: u32 = 24; DTV_ISDBT_LAYERA_MODULATION = 24,
pub const DTV_ISDBT_LAYERA_SEGMENT_COUNT: u32 = 25; DTV_ISDBT_LAYERA_SEGMENT_COUNT = 25,
pub const DTV_ISDBT_LAYERA_TIME_INTERLEAVING: u32 = 26; DTV_ISDBT_LAYERA_TIME_INTERLEAVING = 26,
pub const DTV_ISDBT_LAYERB_FEC: u32 = 27; DTV_ISDBT_LAYERB_FEC = 27,
pub const DTV_ISDBT_LAYERB_MODULATION: u32 = 28; DTV_ISDBT_LAYERB_MODULATION = 28,
pub const DTV_ISDBT_LAYERB_SEGMENT_COUNT: u32 = 29; DTV_ISDBT_LAYERB_SEGMENT_COUNT = 29,
pub const DTV_ISDBT_LAYERB_TIME_INTERLEAVING: u32 = 30; DTV_ISDBT_LAYERB_TIME_INTERLEAVING = 30,
pub const DTV_ISDBT_LAYERC_FEC: u32 = 31; DTV_ISDBT_LAYERC_FEC = 31,
pub const DTV_ISDBT_LAYERC_MODULATION: u32 = 32; DTV_ISDBT_LAYERC_MODULATION = 32,
pub const DTV_ISDBT_LAYERC_SEGMENT_COUNT: u32 = 33; DTV_ISDBT_LAYERC_SEGMENT_COUNT = 33,
pub const DTV_ISDBT_LAYERC_TIME_INTERLEAVING: u32 = 34; DTV_ISDBT_LAYERC_TIME_INTERLEAVING = 34,
pub const DTV_API_VERSION: u32 = 35; DTV_API_VERSION = 35,
/* DVB-T/T2 */ /* DVB-T/T2 */
pub const DTV_CODE_RATE_HP: u32 = 36; DTV_CODE_RATE_HP = 36,
pub const DTV_CODE_RATE_LP: u32 = 37; DTV_CODE_RATE_LP = 37,
pub const DTV_GUARD_INTERVAL: u32 = 38; DTV_GUARD_INTERVAL = 38,
pub const DTV_TRANSMISSION_MODE: u32 = 39; DTV_TRANSMISSION_MODE = 39,
pub const DTV_HIERARCHY: u32 = 40; DTV_HIERARCHY = 40,
pub const DTV_ISDBT_LAYER_ENABLED: u32 = 41; DTV_ISDBT_LAYER_ENABLED = 41,
pub const DTV_STREAM_ID: u32 = 42; DTV_STREAM_ID = 42,
pub const DTV_DVBT2_PLP_ID_LEGACY: u32 = 43; DTV_DVBT2_PLP_ID_LEGACY = 43,
pub const DTV_ENUM_DELSYS: u32 = 44; DTV_ENUM_DELSYS = 44,
/* ATSC-MH */ /* ATSC-MH */
pub const DTV_ATSCMH_FIC_VER: u32 = 45; DTV_ATSCMH_FIC_VER = 45,
pub const DTV_ATSCMH_PARADE_ID: u32 = 46; DTV_ATSCMH_PARADE_ID = 46,
pub const DTV_ATSCMH_NOG: u32 = 47; DTV_ATSCMH_NOG = 47,
pub const DTV_ATSCMH_TNOG: u32 = 48; DTV_ATSCMH_TNOG = 48,
pub const DTV_ATSCMH_SGN: u32 = 49; DTV_ATSCMH_SGN = 49,
pub const DTV_ATSCMH_PRC: u32 = 50; DTV_ATSCMH_PRC = 50,
pub const DTV_ATSCMH_RS_FRAME_MODE: u32 = 51; DTV_ATSCMH_RS_FRAME_MODE = 51,
pub const DTV_ATSCMH_RS_FRAME_ENSEMBLE: u32 = 52; DTV_ATSCMH_RS_FRAME_ENSEMBLE = 52,
pub const DTV_ATSCMH_RS_CODE_MODE_PRI: u32 = 53; DTV_ATSCMH_RS_CODE_MODE_PRI = 53,
pub const DTV_ATSCMH_RS_CODE_MODE_SEC: u32 = 54; DTV_ATSCMH_RS_CODE_MODE_SEC = 54,
pub const DTV_ATSCMH_SCCC_BLOCK_MODE: u32 = 55; DTV_ATSCMH_SCCC_BLOCK_MODE = 55,
pub const DTV_ATSCMH_SCCC_CODE_MODE_A: u32 = 56; DTV_ATSCMH_SCCC_CODE_MODE_A = 56,
pub const DTV_ATSCMH_SCCC_CODE_MODE_B: u32 = 57; DTV_ATSCMH_SCCC_CODE_MODE_B = 57,
pub const DTV_ATSCMH_SCCC_CODE_MODE_C: u32 = 58; DTV_ATSCMH_SCCC_CODE_MODE_C = 58,
pub const DTV_ATSCMH_SCCC_CODE_MODE_D: u32 = 59; DTV_ATSCMH_SCCC_CODE_MODE_D = 59,
pub const DTV_INTERLEAVING: u32 = 60; DTV_INTERLEAVING = 60,
pub const DTV_LNA: u32 = 61; DTV_LNA = 61,
/* Quality parameters */ /* Quality parameters */
pub const DTV_STAT_SIGNAL_STRENGTH: u32 = 62; DTV_STAT_SIGNAL_STRENGTH = 62,
pub const DTV_STAT_CNR: u32 = 63; DTV_STAT_CNR = 63,
pub const DTV_STAT_PRE_ERROR_BIT_COUNT: u32 = 64; DTV_STAT_PRE_ERROR_BIT_COUNT = 64,
pub const DTV_STAT_PRE_TOTAL_BIT_COUNT: u32 = 65; DTV_STAT_PRE_TOTAL_BIT_COUNT = 65,
pub const DTV_STAT_POST_ERROR_BIT_COUNT: u32 = 66; DTV_STAT_POST_ERROR_BIT_COUNT = 66,
pub const DTV_STAT_POST_TOTAL_BIT_COUNT: u32 = 67; DTV_STAT_POST_TOTAL_BIT_COUNT = 67,
pub const DTV_STAT_ERROR_BLOCK_COUNT: u32 = 68; DTV_STAT_ERROR_BLOCK_COUNT = 68,
pub const DTV_STAT_TOTAL_BLOCK_COUNT: u32 = 69; DTV_STAT_TOTAL_BLOCK_COUNT = 69,
/* Physical layer scrambling */ /* Physical layer scrambling */
pub const DTV_SCRAMBLING_SEQUENCE_INDEX: u32 = 70; DTV_SCRAMBLING_SEQUENCE_INDEX = 70,
pub const DTV_INPUT: u32 = 71; DTV_INPUT = 71,
} }
/// Store one of frontend command and its value /// Store one of frontend command and its value
#[repr(C, packed)] #[repr(C, packed)]
pub struct DtvProperty { pub struct DtvProperty {
pub cmd: u32, pub cmd: dtv_property_cmd,
__reserved_1: [u32; 3], __reserved_1: [u32; 3],
pub u: DtvPropertyData, pub u: DtvPropertyData,
pub result: i32, pub result: i32,
@ -721,7 +760,7 @@ impl fmt::Debug for DtvProperty {
impl DtvProperty { impl DtvProperty {
#[inline] #[inline]
pub fn new(cmd: u32, data: u32) -> Self { pub fn new(cmd: dtv_property_cmd, data: u32) -> Self {
Self { Self {
cmd, cmd,
__reserved_1: [0, 0, 0], __reserved_1: [0, 0, 0],
@ -731,10 +770,6 @@ impl DtvProperty {
} }
} }
pub const DTV_MAX_COMMAND: u32 = DTV_INPUT;
/// num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl /// num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl
pub const DTV_IOCTL_MAX_MSGS: usize = 64; pub const DTV_IOCTL_MAX_MSGS: usize = 64;