mirror of
https://github.com/danog/libdvb.git
synced 2024-11-26 20:04:39 +01:00
More refactoring
This commit is contained in:
parent
3047ef2e18
commit
5f24d414a7
@ -37,9 +37,9 @@ impl Default for FeStatus {
|
|||||||
status: 0,
|
status: 0,
|
||||||
props: [
|
props: [
|
||||||
// delivery system
|
// delivery system
|
||||||
DtvProperty::new(DTV_DELIVERY_SYSTEM, FE_NONE),
|
DTV_DELIVERY_SYSTEM(DtvPropertyData::new(SYS_UNDEFINED)),
|
||||||
// modulation
|
// modulation
|
||||||
DtvProperty::new(DTV_MODULATION, QPSK),
|
DTV_MODULATION(DtvPropertyData::new(QPSK)),
|
||||||
// signal level
|
// signal level
|
||||||
DtvProperty::new(DTV_STAT_SIGNAL_STRENGTH, 0),
|
DtvProperty::new(DTV_STAT_SIGNAL_STRENGTH, 0),
|
||||||
// signal-to-noise ratio
|
// signal-to-noise ratio
|
||||||
|
446
src/fe/sys.rs
446
src/fe/sys.rs
@ -1,30 +1,10 @@
|
|||||||
use {
|
use std::{fmt, mem};
|
||||||
std::{
|
|
||||||
fmt,
|
|
||||||
mem,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
fe_caps::*,
|
fe_caps::*, fe_code_rate::*, fe_delivery_system::*, fe_guard_interval::*, fe_hierarchy::*,
|
||||||
fe_type::*,
|
fe_interleaving::*, fe_modulation::*, fe_pilot::*, fe_rolloff::*, fe_sec_mini_cmd::*,
|
||||||
fe_sec_voltage::*,
|
fe_sec_tone_mode::*, fe_sec_voltage::*, fe_spectral_inversion::*, fe_status::*,
|
||||||
fe_sec_tone_mode::*,
|
fe_transmit_mode::*, fe_type::*, fecap_scale_params::*, DtvProperty::*,
|
||||||
fe_sec_mini_cmd::*,
|
|
||||||
fe_status::*,
|
|
||||||
fe_spectral_inversion::*,
|
|
||||||
fe_code_rate::*,
|
|
||||||
fe_modulation::*,
|
|
||||||
fe_transmit_mode::*,
|
|
||||||
fe_guard_interval::*,
|
|
||||||
fe_hierarchy::*,
|
|
||||||
fe_interleaving::*,
|
|
||||||
fe_pilot::*,
|
|
||||||
fe_rolloff::*,
|
|
||||||
fe_delivery_system::*,
|
|
||||||
fecap_scale_params::*,
|
|
||||||
dtv_property_cmd::*,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use strum::{Display, FromRepr};
|
use strum::{Display, FromRepr};
|
||||||
@ -99,7 +79,6 @@ pub enum fe_caps {
|
|||||||
FE_CAN_MUTE_TS = 0x80000000,
|
FE_CAN_MUTE_TS = 0x80000000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// DEPRECATED: Should be kept just due to backward compatibility
|
/// DEPRECATED: Should be kept just due to backward compatibility
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@ -112,7 +91,6 @@ pub enum fe_type {
|
|||||||
FE_ATSC = 3,
|
FE_ATSC = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Frontend properties and capabilities
|
/// Frontend properties and capabilities
|
||||||
/// The frequencies are specified in Hz for Terrestrial and Cable systems.
|
/// The frequencies are specified in Hz for Terrestrial and Cable systems.
|
||||||
/// The frequencies are specified in kHz for Satellite systems.
|
/// The frequencies are specified in kHz for Satellite systems.
|
||||||
@ -143,18 +121,19 @@ pub struct FeInfo {
|
|||||||
pub caps: u32,
|
pub caps: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Default for FeInfo {
|
impl Default for FeInfo {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self { unsafe { mem::zeroed::<Self>() } }
|
fn default() -> Self {
|
||||||
|
unsafe { mem::zeroed::<Self>() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl FeInfo {
|
impl FeInfo {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_mut_ptr(&mut self) -> *mut FeInfo { self as *mut _ }
|
pub fn as_mut_ptr(&mut self) -> *mut FeInfo {
|
||||||
|
self as *mut _
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// DiSEqC master command
|
/// DiSEqC master command
|
||||||
/// Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
|
/// Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
|
||||||
@ -170,12 +149,12 @@ pub struct DiseqcMasterCmd {
|
|||||||
pub len: u8,
|
pub len: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Default for DiseqcMasterCmd {
|
impl Default for DiseqcMasterCmd {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self { unsafe { mem::zeroed::<Self>() } }
|
fn default() -> Self {
|
||||||
|
unsafe { mem::zeroed::<Self>() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// DiSEqC received data
|
/// DiSEqC received data
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -193,12 +172,12 @@ pub struct DiseqcSlaveReply {
|
|||||||
pub timeout: u32,
|
pub timeout: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Default for DiseqcSlaveReply {
|
impl Default for DiseqcSlaveReply {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self { unsafe { mem::zeroed::<Self>() } }
|
fn default() -> Self {
|
||||||
|
unsafe { mem::zeroed::<Self>() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// DC Voltage used to feed the LNBf
|
/// DC Voltage used to feed the LNBf
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
@ -213,7 +192,6 @@ pub enum fe_sec_voltage {
|
|||||||
SEC_VOLTAGE_OFF = 2,
|
SEC_VOLTAGE_OFF = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -224,7 +202,6 @@ pub enum fe_sec_tone_mode {
|
|||||||
SEC_TONE_OFF = 1,
|
SEC_TONE_OFF = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Type of mini burst to be sent
|
/// Type of mini burst to be sent
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@ -236,7 +213,6 @@ pub enum fe_sec_mini_cmd {
|
|||||||
SEC_MINI_B = 1,
|
SEC_MINI_B = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Enumerates the possible frontend status
|
/// Enumerates the possible frontend status
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@ -261,7 +237,6 @@ pub enum fe_status {
|
|||||||
FE_REINIT = 0x40,
|
FE_REINIT = 0x40,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Spectral band inversion
|
/// Spectral band inversion
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@ -272,7 +247,6 @@ pub enum fe_spectral_inversion {
|
|||||||
INVERSION_AUTO = 2,
|
INVERSION_AUTO = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -294,7 +268,6 @@ pub enum fe_code_rate {
|
|||||||
FEC_1_3 = 14,
|
FEC_1_3 = 14,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Type of modulation/constellation
|
/// Type of modulation/constellation
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@ -319,7 +292,6 @@ pub enum fe_modulation {
|
|||||||
APSK_256 = 16,
|
APSK_256 = 16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -335,7 +307,6 @@ pub enum fe_transmit_mode {
|
|||||||
TRANSMISSION_MODE_C3780 = 8,
|
TRANSMISSION_MODE_C3780 = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -353,7 +324,6 @@ pub enum fe_guard_interval {
|
|||||||
GUARD_INTERVAL_PN945 = 10,
|
GUARD_INTERVAL_PN945 = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -365,7 +335,6 @@ pub enum fe_hierarchy {
|
|||||||
HIERARCHY_AUTO = 4,
|
HIERARCHY_AUTO = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -376,7 +345,6 @@ pub enum fe_interleaving {
|
|||||||
INTERLEAVING_720 = 3,
|
INTERLEAVING_720 = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -386,7 +354,6 @@ pub enum fe_pilot {
|
|||||||
PILOT_AUTO = 2,
|
PILOT_AUTO = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
@ -400,12 +367,10 @@ pub enum fe_rolloff {
|
|||||||
ROLLOFF_5 = 6,
|
ROLLOFF_5 = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Display, Debug)]
|
#[derive(Display, Debug)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub enum fe_delivery_system {
|
pub enum fe_delivery_system {
|
||||||
|
|
||||||
#[strum(to_string = "none")]
|
#[strum(to_string = "none")]
|
||||||
SYS_UNDEFINED = 0,
|
SYS_UNDEFINED = 0,
|
||||||
#[strum(to_string = "dvb-c")]
|
#[strum(to_string = "dvb-c")]
|
||||||
@ -448,6 +413,15 @@ pub enum fe_delivery_system {
|
|||||||
SYS_DVBC2 = 19,
|
SYS_DVBC2 = 19,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(u32)]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
||||||
|
pub enum fe_lna {
|
||||||
|
LNA_OFF = 0,
|
||||||
|
LNA_ON = 1,
|
||||||
|
LNA_AUTO = 0xFFFFFFFF,
|
||||||
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@ -463,7 +437,6 @@ mod fecap_scale_params {
|
|||||||
pub const FE_SCALE_COUNTER: u8 = 3;
|
pub const FE_SCALE_COUNTER: u8 = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Used for reading a DTV status property
|
/// Used for reading a DTV status property
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -472,7 +445,6 @@ pub struct DtvStats {
|
|||||||
pub value: i64,
|
pub value: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl fmt::Debug for DtvStats {
|
impl fmt::Debug for DtvStats {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut s = f.debug_struct("DtvStats");
|
let mut s = f.debug_struct("DtvStats");
|
||||||
@ -506,10 +478,8 @@ impl fmt::Debug for DtvStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub const MAX_DTV_STATS: usize = 4;
|
pub const MAX_DTV_STATS: usize = 4;
|
||||||
|
|
||||||
|
|
||||||
/// Store Digital TV frontend statistics
|
/// Store Digital TV frontend statistics
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -518,7 +488,6 @@ pub struct DtvFrontendStats {
|
|||||||
pub stat: [DtvStats; MAX_DTV_STATS],
|
pub stat: [DtvStats; MAX_DTV_STATS],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl fmt::Debug for DtvFrontendStats {
|
impl fmt::Debug for DtvFrontendStats {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let len = ::std::cmp::min(self.len as usize, self.stat.len());
|
let len = ::std::cmp::min(self.len as usize, self.stat.len());
|
||||||
@ -526,7 +495,6 @@ impl fmt::Debug for DtvFrontendStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct DtvPropertyBuffer {
|
pub struct DtvPropertyBuffer {
|
||||||
@ -536,244 +504,152 @@ pub struct DtvPropertyBuffer {
|
|||||||
__reserved_2: *mut std::ffi::c_void,
|
__reserved_2: *mut std::ffi::c_void,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for DtvPropertyBuffer {
|
||||||
#[repr(C)]
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
pub enum DtvPropertyData {
|
let len = ::std::cmp::min(self.len as usize, self.data.len());
|
||||||
data(u32),
|
f.debug_list().entries(self.data[0..len].iter()).finish()
|
||||||
st(DtvFrontendStats),
|
}
|
||||||
buffer(DtvPropertyBuffer),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// DVBv5 property Commands
|
|
||||||
#[repr(u32)]
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
#[derive(Debug, PartialEq, Eq, FromRepr)]
|
|
||||||
pub enum dtv_property_cmd {
|
|
||||||
DTV_UNDEFINED = 0,
|
|
||||||
DTV_TUNE = 1,
|
|
||||||
DTV_CLEAR = 2,
|
|
||||||
DTV_FREQUENCY = 3,
|
|
||||||
DTV_MODULATION = 4,
|
|
||||||
DTV_BANDWIDTH_HZ = 5,
|
|
||||||
DTV_INVERSION = 6,
|
|
||||||
DTV_DISEQC_MASTER = 7,
|
|
||||||
DTV_SYMBOL_RATE = 8,
|
|
||||||
DTV_INNER_FEC = 9,
|
|
||||||
DTV_VOLTAGE = 10,
|
|
||||||
DTV_TONE = 11,
|
|
||||||
DTV_PILOT = 12,
|
|
||||||
DTV_ROLLOFF = 13,
|
|
||||||
DTV_DISEQC_SLAVE_REPLY = 14,
|
|
||||||
|
|
||||||
/* Basic enumeration set for querying unlimited capabilities */
|
|
||||||
|
|
||||||
DTV_FE_CAPABILITY_COUNT = 15,
|
|
||||||
DTV_FE_CAPABILITY = 16,
|
|
||||||
DTV_DELIVERY_SYSTEM = 17,
|
|
||||||
|
|
||||||
/* ISDB-T and ISDB-Tsb */
|
|
||||||
|
|
||||||
DTV_ISDBT_PARTIAL_RECEPTION = 18,
|
|
||||||
DTV_ISDBT_SOUND_BROADCASTING = 19,
|
|
||||||
|
|
||||||
DTV_ISDBT_SB_SUBCHANNEL_ID = 20,
|
|
||||||
DTV_ISDBT_SB_SEGMENT_IDX = 21,
|
|
||||||
DTV_ISDBT_SB_SEGMENT_COUNT = 22,
|
|
||||||
|
|
||||||
DTV_ISDBT_LAYERA_FEC = 23,
|
|
||||||
DTV_ISDBT_LAYERA_MODULATION = 24,
|
|
||||||
DTV_ISDBT_LAYERA_SEGMENT_COUNT = 25,
|
|
||||||
DTV_ISDBT_LAYERA_TIME_INTERLEAVING = 26,
|
|
||||||
|
|
||||||
DTV_ISDBT_LAYERB_FEC = 27,
|
|
||||||
DTV_ISDBT_LAYERB_MODULATION = 28,
|
|
||||||
DTV_ISDBT_LAYERB_SEGMENT_COUNT = 29,
|
|
||||||
DTV_ISDBT_LAYERB_TIME_INTERLEAVING = 30,
|
|
||||||
|
|
||||||
DTV_ISDBT_LAYERC_FEC = 31,
|
|
||||||
DTV_ISDBT_LAYERC_MODULATION = 32,
|
|
||||||
DTV_ISDBT_LAYERC_SEGMENT_COUNT = 33,
|
|
||||||
DTV_ISDBT_LAYERC_TIME_INTERLEAVING = 34,
|
|
||||||
|
|
||||||
DTV_API_VERSION = 35,
|
|
||||||
|
|
||||||
/* DVB-T/T2 */
|
|
||||||
|
|
||||||
DTV_CODE_RATE_HP = 36,
|
|
||||||
DTV_CODE_RATE_LP = 37,
|
|
||||||
DTV_GUARD_INTERVAL = 38,
|
|
||||||
DTV_TRANSMISSION_MODE = 39,
|
|
||||||
DTV_HIERARCHY = 40,
|
|
||||||
|
|
||||||
DTV_ISDBT_LAYER_ENABLED = 41,
|
|
||||||
|
|
||||||
DTV_STREAM_ID = 42,
|
|
||||||
DTV_DVBT2_PLP_ID_LEGACY = 43,
|
|
||||||
|
|
||||||
DTV_ENUM_DELSYS = 44,
|
|
||||||
|
|
||||||
/* ATSC-MH */
|
|
||||||
|
|
||||||
DTV_ATSCMH_FIC_VER = 45,
|
|
||||||
DTV_ATSCMH_PARADE_ID = 46,
|
|
||||||
DTV_ATSCMH_NOG = 47,
|
|
||||||
DTV_ATSCMH_TNOG = 48,
|
|
||||||
DTV_ATSCMH_SGN = 49,
|
|
||||||
DTV_ATSCMH_PRC = 50,
|
|
||||||
DTV_ATSCMH_RS_FRAME_MODE = 51,
|
|
||||||
DTV_ATSCMH_RS_FRAME_ENSEMBLE = 52,
|
|
||||||
DTV_ATSCMH_RS_CODE_MODE_PRI = 53,
|
|
||||||
DTV_ATSCMH_RS_CODE_MODE_SEC = 54,
|
|
||||||
DTV_ATSCMH_SCCC_BLOCK_MODE = 55,
|
|
||||||
DTV_ATSCMH_SCCC_CODE_MODE_A = 56,
|
|
||||||
DTV_ATSCMH_SCCC_CODE_MODE_B = 57,
|
|
||||||
DTV_ATSCMH_SCCC_CODE_MODE_C = 58,
|
|
||||||
DTV_ATSCMH_SCCC_CODE_MODE_D = 59,
|
|
||||||
|
|
||||||
DTV_INTERLEAVING = 60,
|
|
||||||
DTV_LNA = 61,
|
|
||||||
|
|
||||||
/* Quality parameters */
|
|
||||||
|
|
||||||
DTV_STAT_SIGNAL_STRENGTH = 62,
|
|
||||||
DTV_STAT_CNR = 63,
|
|
||||||
DTV_STAT_PRE_ERROR_BIT_COUNT = 64,
|
|
||||||
DTV_STAT_PRE_TOTAL_BIT_COUNT = 65,
|
|
||||||
DTV_STAT_POST_ERROR_BIT_COUNT = 66,
|
|
||||||
DTV_STAT_POST_TOTAL_BIT_COUNT = 67,
|
|
||||||
DTV_STAT_ERROR_BLOCK_COUNT = 68,
|
|
||||||
DTV_STAT_TOTAL_BLOCK_COUNT = 69,
|
|
||||||
|
|
||||||
/* Physical layer scrambling */
|
|
||||||
|
|
||||||
DTV_SCRAMBLING_SEQUENCE_INDEX = 70,
|
|
||||||
DTV_INPUT = 71,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Store one of frontend command and its value
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
pub struct DtvProperty {
|
#[derive(Debug)]
|
||||||
pub cmd: dtv_property_cmd,
|
pub struct DtvPropertyData<T> {
|
||||||
__reserved_1: [u32; 3],
|
__reserved: [u32; 3],
|
||||||
pub u: DtvPropertyData,
|
pub data: T,
|
||||||
pub result: i32,
|
pub result: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> DtvPropertyData<T> {
|
||||||
|
pub fn new(data: T) -> Self {
|
||||||
|
Self {
|
||||||
|
__reserved: [0, 0, 0],
|
||||||
|
data,
|
||||||
|
result: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Debug for DtvProperty {
|
pub type DtvPropertyRequestStats = DtvPropertyData<DtvFrontendStats>;
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
pub type DtvPropertyRequestData = DtvPropertyData<DtvPropertyBuffer>;
|
||||||
let mut s = f.debug_struct("DtvProperty");
|
pub type DtvPropertyRequest = DtvPropertyData<u32>;
|
||||||
|
|
||||||
const FIELD_CMD: &str = "cmd";
|
#[repr(C, packed)]
|
||||||
const FIELD_DATA: &str = "data";
|
#[derive(Debug)]
|
||||||
const FIELD_STATS: &str = "stats";
|
pub struct DtvPropertyNotImplementedLinux {
|
||||||
|
__reserved: [u32; 6],
|
||||||
|
}
|
||||||
|
|
||||||
match self.cmd {
|
#[deprecated(
|
||||||
DTV_FREQUENCY => {
|
note = "Not implemented, please fork libdvb and provide a correct implementation for this property."
|
||||||
s.field(FIELD_CMD, &"DTV_FREQUENCY");
|
)]
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
type DtvPropertyNotImplemented = DtvPropertyNotImplementedLinux;
|
||||||
}
|
#[deprecated]
|
||||||
DTV_MODULATION => {
|
type DtvPropertyDeprecated = DtvPropertyNotImplementedLinux;
|
||||||
s.field(FIELD_CMD, &"DTV_MODULATION");
|
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
/// DVBv5 property Commands
|
||||||
}
|
#[repr(u32, C)]
|
||||||
DTV_BANDWIDTH_HZ => {
|
#[allow(non_camel_case_types)]
|
||||||
s.field(FIELD_CMD, &"DTV_BANDWIDTH_HZ");
|
#[derive(Debug)]
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
pub enum DtvProperty {
|
||||||
}
|
DTV_UNDEFINED(DtvPropertyNotImplementedLinux),
|
||||||
DTV_INVERSION => {
|
DTV_TUNE(DtvPropertyRequest),
|
||||||
s.field(FIELD_CMD, &"DTV_INVERSION");
|
DTV_CLEAR(DtvPropertyRequest),
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
DTV_FREQUENCY(DtvPropertyData<u32>),
|
||||||
}
|
DTV_MODULATION(DtvPropertyData<fe_modulation>),
|
||||||
DTV_SYMBOL_RATE => {
|
DTV_BANDWIDTH_HZ(DtvPropertyData<u32>),
|
||||||
s.field(FIELD_CMD, &"DTV_SYMBOL_RATE");
|
DTV_INVERSION(DtvPropertyData<fe_spectral_inversion>),
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
DTV_DISEQC_MASTER(DtvPropertyNotImplementedLinux),
|
||||||
}
|
DTV_SYMBOL_RATE(DtvPropertyData<u32>),
|
||||||
DTV_INNER_FEC => {
|
DTV_INNER_FEC(DtvPropertyData<fe_code_rate>),
|
||||||
s.field(FIELD_CMD, &"DTV_INNER_FEC");
|
DTV_VOLTAGE(DtvPropertyData<fe_sec_voltage>),
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
DTV_TONE(DtvPropertyNotImplementedLinux),
|
||||||
}
|
DTV_PILOT(DtvPropertyData<fe_pilot>),
|
||||||
DTV_PILOT => {
|
DTV_ROLLOFF(DtvPropertyData<fe_rolloff>),
|
||||||
s.field(FIELD_CMD, &"DTV_PILOT");
|
DTV_DISEQC_SLAVE_REPLY(DtvPropertyNotImplementedLinux),
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
|
||||||
}
|
/* Basic enumeration set for querying unlimited capabilities */
|
||||||
DTV_ROLLOFF => {
|
DTV_FE_CAPABILITY_COUNT(DtvPropertyNotImplementedLinux),
|
||||||
s.field(FIELD_CMD, &"DTV_ROLLOFF");
|
DTV_FE_CAPABILITY(DtvPropertyNotImplementedLinux),
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
DTV_DELIVERY_SYSTEM(DtvPropertyData<fe_delivery_system>),
|
||||||
}
|
|
||||||
DTV_DELIVERY_SYSTEM => {
|
/* ISDB-T and ISDB-Tsb */
|
||||||
s.field(FIELD_CMD, &"DTV_DELIVERY_SYSTEM");
|
// Please fork
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
DTV_ISDBT_PARTIAL_RECEPTION(DtvPropertyData<i32>),
|
||||||
}
|
DTV_ISDBT_SOUND_BROADCASTING(DtvPropertyData<i32>),
|
||||||
DTV_API_VERSION => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_API_VERSION");
|
DTV_ISDBT_SB_SUBCHANNEL_ID(DtvPropertyData<i32>),
|
||||||
s.field(FIELD_DATA, unsafe { &self.u.data });
|
DTV_ISDBT_SB_SEGMENT_IDX(DtvPropertyData<i32>),
|
||||||
}
|
DTV_ISDBT_SB_SEGMENT_COUNT(DtvPropertyData<u32>),
|
||||||
|
|
||||||
|
DTV_ISDBT_LAYERA_FEC(DtvPropertyData<fe_code_rate>),
|
||||||
|
DTV_ISDBT_LAYERA_MODULATION(DtvPropertyData<fe_modulation>),
|
||||||
|
DTV_ISDBT_LAYERA_SEGMENT_COUNT(DtvPropertyData<i32>),
|
||||||
|
DTV_ISDBT_LAYERA_TIME_INTERLEAVING(DtvPropertyData<i32>),
|
||||||
|
|
||||||
|
DTV_ISDBT_LAYERB_FEC(DtvPropertyData<fe_code_rate>),
|
||||||
|
DTV_ISDBT_LAYERB_MODULATION(DtvPropertyData<fe_modulation>),
|
||||||
|
DTV_ISDBT_LAYERB_SEGMENT_COUNT(DtvPropertyData<i32>),
|
||||||
|
DTV_ISDBT_LAYERB_TIME_INTERLEAVING(DtvPropertyData<i32>),
|
||||||
|
|
||||||
|
DTV_ISDBT_LAYERC_FEC(DtvPropertyData<fe_code_rate>),
|
||||||
|
DTV_ISDBT_LAYERC_MODULATION(DtvPropertyData<fe_modulation>),
|
||||||
|
DTV_ISDBT_LAYERC_SEGMENT_COUNT(DtvPropertyData<i32>),
|
||||||
|
DTV_ISDBT_LAYERC_TIME_INTERLEAVING(DtvPropertyData<i32>),
|
||||||
|
|
||||||
|
DTV_API_VERSION(DtvPropertyRequest),
|
||||||
|
|
||||||
|
/* DVB-T/T2 */
|
||||||
|
DTV_CODE_RATE_HP(DtvPropertyData<fe_transmit_mode>),
|
||||||
|
DTV_CODE_RATE_LP(DtvPropertyData<fe_transmit_mode>),
|
||||||
|
DTV_GUARD_INTERVAL(DtvPropertyData<fe_guard_interval>),
|
||||||
|
DTV_TRANSMISSION_MODE(DtvPropertyData<fe_transmit_mode>),
|
||||||
|
DTV_HIERARCHY(DtvPropertyData<fe_hierarchy>),
|
||||||
|
|
||||||
|
DTV_ISDBT_LAYER_ENABLED(DtvPropertyData<u32>),
|
||||||
|
|
||||||
|
DTV_STREAM_ID(DtvPropertyData<u32>),
|
||||||
|
#[deprecated(note = "Obsolete, replaced with DTV_STREAM_ID.")]
|
||||||
|
DTV_DVBT2_PLP_ID_LEGACY(DtvPropertyDeprecated),
|
||||||
|
|
||||||
|
DTV_ENUM_DELSYS(DtvPropertyRequestData),
|
||||||
|
|
||||||
|
/* ATSC-MH */
|
||||||
|
DTV_ATSCMH_FIC_VER(DtvPropertyData<u32>),
|
||||||
|
DTV_ATSCMH_PARADE_ID(DtvPropertyData<u32>),
|
||||||
|
DTV_ATSCMH_NOG(DtvPropertyData<u32>),
|
||||||
|
DTV_ATSCMH_TNOG(DtvPropertyData<u32>),
|
||||||
|
DTV_ATSCMH_SGN(DtvPropertyData<u32>),
|
||||||
|
DTV_ATSCMH_PRC(DtvPropertyData<u32>),
|
||||||
|
DTV_ATSCMH_RS_FRAME_MODE(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_RS_FRAME_ENSEMBLE(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_RS_CODE_MODE_PRI(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_RS_CODE_MODE_SEC(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_SCCC_BLOCK_MODE(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_SCCC_CODE_MODE_A(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_SCCC_CODE_MODE_B(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_SCCC_CODE_MODE_C(DtvPropertyNotImplemented),
|
||||||
|
DTV_ATSCMH_SCCC_CODE_MODE_D(DtvPropertyNotImplemented),
|
||||||
|
|
||||||
|
DTV_INTERLEAVING(DtvPropertyData<fe_interleaving>),
|
||||||
|
DTV_LNA(DtvPropertyData<fe_lna>),
|
||||||
|
|
||||||
/* Quality parameters */
|
/* Quality parameters */
|
||||||
|
DTV_STAT_SIGNAL_STRENGTH(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_CNR(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_PRE_ERROR_BIT_COUNT(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_PRE_TOTAL_BIT_COUNT(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_POST_ERROR_BIT_COUNT(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_POST_TOTAL_BIT_COUNT(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_ERROR_BLOCK_COUNT(DtvPropertyRequestStats),
|
||||||
|
DTV_STAT_TOTAL_BLOCK_COUNT(DtvPropertyRequestStats),
|
||||||
|
|
||||||
DTV_STAT_SIGNAL_STRENGTH => {
|
/* Physical layer scrambling */
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_SIGNAL_STRENGTH");
|
DTV_SCRAMBLING_SEQUENCE_INDEX(DtvPropertyRequest),
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
DTV_STAT_CNR => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_CNR");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
|
|
||||||
DTV_STAT_PRE_ERROR_BIT_COUNT => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_PRE_ERROR_BIT_COUNT");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
DTV_STAT_PRE_TOTAL_BIT_COUNT => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_PRE_TOTAL_BIT_COUNT");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
DTV_STAT_POST_ERROR_BIT_COUNT => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_POST_ERROR_BIT_COUNT");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
DTV_STAT_POST_TOTAL_BIT_COUNT => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_POST_TOTAL_BIT_COUNT");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
DTV_STAT_ERROR_BLOCK_COUNT => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_ERROR_BLOCK_COUNT");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
DTV_STAT_TOTAL_BLOCK_COUNT => {
|
|
||||||
s.field(FIELD_CMD, &"DTV_STAT_TOTAL_BLOCK_COUNT");
|
|
||||||
s.field(FIELD_STATS, unsafe { &self.u.st });
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: more values
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
s.field("result", &{ self.result });
|
|
||||||
s.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl DtvProperty {
|
|
||||||
#[inline]
|
|
||||||
pub fn new(cmd: dtv_property_cmd, data: u32) -> Self {
|
|
||||||
Self {
|
|
||||||
cmd,
|
|
||||||
__reserved_1: [0, 0, 0],
|
|
||||||
u: DtvPropertyData { data },
|
|
||||||
result: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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;
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FeParameters {
|
pub struct FeParameters {
|
||||||
@ -785,10 +661,8 @@ pub struct FeParameters {
|
|||||||
__reserved_1: [u8; 28],
|
__reserved_1: [u8; 28],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub const FE_MAX_EVENT: usize = 8;
|
pub const FE_MAX_EVENT: usize = 8;
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FeEvent {
|
pub struct FeEvent {
|
||||||
@ -796,14 +670,16 @@ pub struct FeEvent {
|
|||||||
pub parameters: FeParameters,
|
pub parameters: FeParameters,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Default for FeEvent {
|
impl Default for FeEvent {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self { unsafe { mem::zeroed::<Self>() } }
|
fn default() -> Self {
|
||||||
|
unsafe { mem::zeroed::<Self>() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl FeEvent {
|
impl FeEvent {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_mut_ptr(&mut self) -> *mut FeEvent { self as *mut _ }
|
pub fn as_mut_ptr(&mut self) -> *mut FeEvent {
|
||||||
|
self as *mut _
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user