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

Finally compiling

This commit is contained in:
Daniil Gentili 2022-03-19 22:07:29 +01:00
parent 5b70f19bd0
commit d7cfa1618b
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 185 additions and 186 deletions

View File

@ -22,22 +22,21 @@ TODO:
Example DVB-S2 tune: Example DVB-S2 tune:
```rust ```rust
let cmdseq = vec![
dtv_property!(DTV_DELIVERY_SYSTEM, SYS_DVBS2),
dtv_property!(DTV_FREQUENCY, (11044 - 9750) * 1000),
dtv_property!(DTV_MODULATION, PSK_8),
dtv_property!(DTV_VOLTAGE, SEC_VOLTAGE_13),
dtv_property!(DTV_TONE, SEC_TONE_OFF),
dtv_property!(DTV_INVERSION, INVERSION_AUTO),
dtv_property!(DTV_SYMBOL_RATE, 27500 * 1000),
dtv_property!(DTV_INNER_FEC, FEC_AUTO),
dtv_property!(DTV_PILOT, PILOT_AUTO),
dtv_property!(DTV_ROLLOFF, ROLLOFF_35),
dtv_property!(DTV_TUNE, 0),
];
let fe = FeDevice::open_rw(0, 0)?; let fe = FeDevice::open_rw(0, 0)?;
fe.set_properties(&cmdseq)?; set_dtv_properties!(
fe,
DTV_DELIVERY_SYSTEM(SYS_DVBS2),
DTV_FREQUENCY((11044 - 9750) * 1000),
DTV_MODULATION(PSK_8),
DTV_VOLTAGE(SEC_VOLTAGE_13),
DTV_TONE(SEC_TONE_OFF),
DTV_INVERSION(INVERSION_AUTO),
DTV_SYMBOL_RATE(27500 * 1000),
DTV_INNER_FEC(FEC_AUTO),
DTV_PILOT(PILOT_AUTO),
DTV_ROLLOFF(ROLLOFF_35),
DTV_TUNE(()),
)?;
``` ```
Frontend information: Frontend information:

View File

@ -1,5 +1,3 @@
use crate::{dtv_property, req_dtv_properties};
mod status; mod status;
pub mod sys; pub mod sys;
@ -96,15 +94,91 @@ impl AsRawFd for FeDevice {
} }
#[macro_export]
macro_rules! get_dtv_properties {
( $device:expr, $( $property:ident ),+ ) => { (|| -> anyhow::Result<_> {
let mut input = [ $( $property(DtvPropertyRequest::default()), )* ];
$device.get_properties(&mut input)?;
let mut iterator = input.iter();
Ok((
$(
match iterator.next() {
Some($property(d)) => d.get(),
_ => ::anyhow::Result::Err(anyhow!("Error unpacking")),
}?,
)*
))
})()}
}
#[macro_export]
macro_rules! set_dtv_properties {
( $device:expr, $( $property:ident($data:expr) ),+ ) => {
$device.set_properties(&[
$( set_dtv_properties!(inner $device, $property, $data), )*
])
};
( inner $device:expr, DTV_FREQUENCY, $data:expr ) => {
if !$device.frequency_range.contains($data) {
bail!("FE: frequency out of range");
} else {
DTV_FREQUENCY(DtvPropertyRequest::new($data:expr))
}
};
( inner $device:expr, DTV_SYMBOL_RATE, $data:expr ) => {
if !$device.symbolrate_range.contains($data) {
bail!("FE: symbolrate out of range");
} else {
DTV_SYMBOL_RATE(DtvPropertyRequest::new($data:expr))
}
};
( inner $device:expr, DTV_INVERSION, $data:expr ) => {
if $data == INVERSION_AUTO && !$device.caps.contains(fe_caps::FE_CAN_INVERSION_AUTO) {
bail!("FE: auto inversion is not available");
} else {
DTV_INVERSION(DtvPropertyRequest::new($data:expr))
}
};
( inner $device:expr, DTV_TRANSMISSION_MODE, $data:expr ) => {
if $data == TRANSMISSION_MODE_AUTO && !$device.caps.contains(fe_caps::FE_CAN_TRANSMISSION_MODE_AUTO) {
bail!("FE: no auto transmission mode");
} else {
DTV_TRANSMISSION_MODE(DtvPropertyRequest::new($data:expr))
}
};
( inner $device:expr, DTV_GUARD_INTERVAL, $data:expr ) => {
if $data == GUARD_INTERVAL_AUTO && !$device.caps.contains(fe_caps::FE_CAN_GUARD_INTERVAL_AUTO) {
bail!("FE: no auto guard interval");
}
};
( inner $device:expr, DTV_HIERARCHY, $data:expr ) => {
if $data == HIERARCHY_AUTO && !$device.caps.contains(fe_caps::FE_CAN_HIERARCHY_AUTO) {
bail!("FE: no auto hierarchy");
} else {
DTV_HIERARCHY(DtvPropertyRequest::new($data:expr))
}
};
( inner $device:expr, DTV_STREAM_ID, $data:expr ) => {
if !$device.caps.contains(fe_caps::FE_CAN_MULTISTREAM) {
bail!("FE: no multistream");
} else {
DTV_STREAM_ID(DtvPropertyRequest::new($data:expr))
}
};
( inner $device:expr, $property:ident, $data:expr ) => {
$property(DtvPropertyRequest::new($data))
}
}
impl FeDevice { impl FeDevice {
/// Clears frontend settings and event queue /// Clears frontend settings and event queue
pub fn clear(&self) -> Result<()> { pub fn clear(&self) -> Result<()> {
let cmdseq = [ set_dtv_properties!(
dtv_property!(DTV_VOLTAGE, SEC_VOLTAGE_OFF), self,
dtv_property!(DTV_TONE, SEC_TONE_OFF), DTV_VOLTAGE(SEC_VOLTAGE_OFF),
dtv_property!(DTV_CLEAR, 0), DTV_TONE(SEC_TONE_OFF),
]; DTV_CLEAR(())
self.set_properties(&cmdseq).context("FE: clear")?; ).context("FE: clear")?;
let mut event = FeEvent::default(); let mut event = FeEvent::default();
@ -139,7 +213,7 @@ impl FeDevice {
self.caps = feinfo.caps; self.caps = feinfo.caps;
// DVB v5 properties // DVB v5 properties
let (api_version, enum_delsys) = req_dtv_properties!( let (api_version, enum_delsys) = get_dtv_properties!(
self, self,
DTV_API_VERSION, DTV_API_VERSION,
DTV_ENUM_DELSYS DTV_ENUM_DELSYS
@ -206,70 +280,8 @@ impl FeDevice {
Self::open(adapter, device, true) Self::open(adapter, device, true)
} }
fn check_properties(&self, cmdseq: &[DtvProperty]) -> Result<()> {
for p in cmdseq {
match p {
DTV_FREQUENCY(DtvPropertyRequest{data, ..}) => {
ensure!(
self.frequency_range.contains(&data),
"FE: frequency out of range"
);
}
DTV_SYMBOL_RATE(DtvPropertyRequest{data, ..}) => {
ensure!(
self.symbolrate_range.contains(&data),
"FE: symbolrate out of range"
);
}
DTV_INVERSION(DtvPropertyRequest{data, ..}) => {
if *data == INVERSION_AUTO {
ensure!(
self.caps.contains(fe_caps::FE_CAN_INVERSION_AUTO),
"FE: auto inversion is not available"
);
}
}
DTV_TRANSMISSION_MODE(DtvPropertyRequest{data, ..}) => {
if *data == TRANSMISSION_MODE_AUTO {
ensure!(
self.caps.contains(fe_caps::FE_CAN_TRANSMISSION_MODE_AUTO),
"FE: no auto transmission mode"
);
}
}
DTV_GUARD_INTERVAL(DtvPropertyRequest{data, ..}) => {
if *data == GUARD_INTERVAL_AUTO {
ensure!(
self.caps.contains(fe_caps::FE_CAN_GUARD_INTERVAL_AUTO),
"FE: no auto guard interval"
);
}
}
DTV_HIERARCHY(DtvPropertyRequest{data, ..}) => {
if *data == HIERARCHY_AUTO {
ensure!(
self.caps.contains(fe_caps::FE_CAN_HIERARCHY_AUTO),
"FE: no auto hierarchy"
);
}
}
DTV_STREAM_ID(..) => {
ensure!(
self.caps.contains(fe_caps::FE_CAN_MULTISTREAM),
"FE: no multistream"
);
}
_ => {}
}
}
Ok(())
}
/// Sets properties on frontend device /// Sets properties on frontend device
pub fn set_properties(&self, cmdseq: &[DtvProperty]) -> Result<()> { pub fn set_properties(&self, cmdseq: &[DtvProperty]) -> Result<()> {
self.check_properties(cmdseq).context("FE: property check")?;
#[repr(C)] #[repr(C)]
pub struct DtvProperties { pub struct DtvProperties {
num: u32, num: u32,

View File

@ -1,4 +1,4 @@
use crate::req_dtv_properties; use crate::get_dtv_properties;
use { use {
super::{sys::*, FeDevice}, super::{sys::*, FeDevice},
@ -235,7 +235,7 @@ impl FeStatus {
return Ok(()); return Ok(());
} }
let (delivery_system, modulation, signal_strength, snr, ber, unc) = req_dtv_properties!( let (delivery_system, modulation, signal_strength, snr, ber, unc) = get_dtv_properties!(
fe, fe,
DTV_DELIVERY_SYSTEM, DTV_DELIVERY_SYSTEM,
DTV_MODULATION, DTV_MODULATION,

View File

@ -240,7 +240,7 @@ bitflags! {
/// Spectral band inversion /// Spectral band inversion
#[repr(u32)] #[repr(u32)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)] #[derive(Debug, PartialEq, Eq, FromRepr, Clone, Copy)]
pub enum fe_spectral_inversion { pub enum fe_spectral_inversion {
INVERSION_OFF = 0, INVERSION_OFF = 0,
INVERSION_ON = 1, INVERSION_ON = 1,
@ -249,7 +249,7 @@ pub enum fe_spectral_inversion {
#[repr(u32)] #[repr(u32)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, FromRepr)] #[derive(Debug, PartialEq, Eq, FromRepr, Clone, Copy)]
pub enum fe_code_rate { pub enum fe_code_rate {
FEC_NONE = 0, FEC_NONE = 0,
FEC_1_2 = 1, FEC_1_2 = 1,
@ -562,8 +562,6 @@ impl DtvStatType for DtvFrontendStats {
pub struct DtvPropertyBuffer { pub struct DtvPropertyBuffer {
data: [u8; 32], data: [u8; 32],
len: u32, len: u32,
__reserved_1: [u32; 3],
__reserved_2: *mut std::ffi::c_void,
} }
impl WrappedSlice<u8> for DtvPropertyBuffer { impl WrappedSlice<u8> for DtvPropertyBuffer {
@ -579,42 +577,63 @@ impl fmt::Debug for DtvPropertyBuffer {
} }
} }
const DATA_SIZE: usize = 56;
#[repr(C, packed)] #[repr(C, packed)]
#[derive(Debug)] pub struct DtvPropertyRequest<T, const N: usize> {
pub struct DtvPropertyRequest<T> {
__reserved: [u32; 3], __reserved: [u32; 3],
data: T, data: T,
padding: [u8; N],
result: i32, // Unused result: i32, // Unused
} }
impl<T> DtvPropertyRequest<T> { impl<T, const N: usize> DtvPropertyRequest<T, N> {
#[inline] #[inline]
pub fn new(data: T) -> Self { pub fn new(data: T) -> Self {
Self { Self {
__reserved: [0, 0, 0], __reserved: [0; 3],
data, data,
result: 0, padding: [0; N],
result: 0
} }
} }
} }
impl<T> Default for DtvPropertyRequest<T> { impl<T, const N: usize> Default for DtvPropertyRequest<T, N> {
#[inline] #[inline]
fn default() -> Self { fn default() -> Self {
unsafe { mem::zeroed::<Self>() } unsafe { mem::zeroed::<Self>() }
} }
} }
impl<T: Copy> WrappedResult<T> for DtvPropertyRequest<T> { pub type DtvPropertyRequestVoid = DtvPropertyRequest<(), DATA_SIZE>;
impl WrappedResult<()> for DtvPropertyRequestVoid {
#[inline]
fn get(&self) ->anyhow::Result<()> {
Ok(())
}
}
pub type DtvPropertyRequestInt<T> = DtvPropertyRequest<T, {DATA_SIZE-4}>;
impl<T: Copy> WrappedResult<T> for DtvPropertyRequestInt<T> {
#[inline] #[inline]
fn get(&self) -> anyhow::Result<T> { fn get(&self) -> anyhow::Result<T> {
Ok(self.data) Ok(self.data)
} }
} }
pub type DtvPropertyRequestVoid = DtvPropertyRequest<u32>; pub type DtvPropertyRequestFrontendStats = DtvPropertyRequest<DtvFrontendStats, {DATA_SIZE-37}>;
pub type DtvPropertyRequestDeliverySystems = DtvPropertyRequest<DtvPropertyBuffer>; impl WrappedResult<DtvFrontendStats> for DtvPropertyRequestFrontendStats {
#[inline]
fn get(&self) -> anyhow::Result<DtvFrontendStats> {
Ok(self.data)
}
}
pub type DtvPropertyRequestDeliverySystems = DtvPropertyRequest<DtvPropertyBuffer, {DATA_SIZE-4-32}>;
impl<T: FromIterator<fe_delivery_system>> WrappedResult<T> for DtvPropertyRequestDeliverySystems { impl<T: FromIterator<fe_delivery_system>> WrappedResult<T> for DtvPropertyRequestDeliverySystems {
#[inline] #[inline]
@ -627,8 +646,8 @@ impl<T: FromIterator<fe_delivery_system>> WrappedResult<T> for DtvPropertyReques
} }
} }
#[repr(C, packed)] #[repr(C, packed)]
#[derive(Debug)]
pub struct DtvPropertyNotImplementedLinux { pub struct DtvPropertyNotImplementedLinux {
__reserved: [u32; 6], __reserved: [u32; 6],
} }
@ -643,78 +662,77 @@ type DtvPropertyDeprecated = DtvPropertyNotImplementedLinux;
/// DVBv5 property Commands /// DVBv5 property Commands
#[repr(u32, C)] #[repr(u32, C)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Debug)]
#[allow(deprecated)] #[allow(deprecated)]
pub enum DtvProperty { pub enum DtvProperty {
DTV_UNDEFINED(DtvPropertyNotImplementedLinux), DTV_UNDEFINED(DtvPropertyNotImplementedLinux),
DTV_TUNE(DtvPropertyRequestVoid), DTV_TUNE(DtvPropertyRequestVoid),
DTV_CLEAR(DtvPropertyRequestVoid), DTV_CLEAR(DtvPropertyRequestVoid),
DTV_FREQUENCY(DtvPropertyRequest<u32>), DTV_FREQUENCY(DtvPropertyRequestInt<u32>),
DTV_MODULATION(DtvPropertyRequest<fe_modulation>), DTV_MODULATION(DtvPropertyRequestInt<fe_modulation>),
DTV_BANDWIDTH_HZ(DtvPropertyRequest<u32>), DTV_BANDWIDTH_HZ(DtvPropertyRequestInt<u32>),
DTV_INVERSION(DtvPropertyRequest<fe_spectral_inversion>), DTV_INVERSION(DtvPropertyRequestInt<fe_spectral_inversion>),
DTV_DISEQC_MASTER(DtvPropertyNotImplementedLinux), DTV_DISEQC_MASTER(DtvPropertyNotImplementedLinux),
DTV_SYMBOL_RATE(DtvPropertyRequest<u32>), DTV_SYMBOL_RATE(DtvPropertyRequestInt<u32>),
DTV_INNER_FEC(DtvPropertyRequest<fe_code_rate>), DTV_INNER_FEC(DtvPropertyRequestInt<fe_code_rate>),
DTV_VOLTAGE(DtvPropertyRequest<fe_sec_voltage>), DTV_VOLTAGE(DtvPropertyRequestInt<fe_sec_voltage>),
DTV_TONE(DtvPropertyRequest<fe_sec_tone_mode>), DTV_TONE(DtvPropertyRequestInt<fe_sec_tone_mode>),
DTV_PILOT(DtvPropertyRequest<fe_pilot>), DTV_PILOT(DtvPropertyRequestInt<fe_pilot>),
DTV_ROLLOFF(DtvPropertyRequest<fe_rolloff>), DTV_ROLLOFF(DtvPropertyRequestInt<fe_rolloff>),
DTV_DISEQC_SLAVE_REPLY(DtvPropertyNotImplementedLinux), DTV_DISEQC_SLAVE_REPLY(DtvPropertyNotImplementedLinux),
/* Basic enumeration set for querying unlimited capabilities */ /* Basic enumeration set for querying unlimited capabilities */
DTV_FE_CAPABILITY_COUNT(DtvPropertyNotImplementedLinux), DTV_FE_CAPABILITY_COUNT(DtvPropertyNotImplementedLinux),
DTV_FE_CAPABILITY(DtvPropertyNotImplementedLinux), DTV_FE_CAPABILITY(DtvPropertyNotImplementedLinux),
DTV_DELIVERY_SYSTEM(DtvPropertyRequest<fe_delivery_system>), DTV_DELIVERY_SYSTEM(DtvPropertyRequestInt<fe_delivery_system>),
/* ISDB-T and ISDB-Tsb */ /* ISDB-T and ISDB-Tsb */
// Please fork // Please fork
DTV_ISDBT_PARTIAL_RECEPTION(DtvPropertyRequest<i32>), DTV_ISDBT_PARTIAL_RECEPTION(DtvPropertyRequestInt<i32>),
DTV_ISDBT_SOUND_BROADCASTING(DtvPropertyRequest<i32>), DTV_ISDBT_SOUND_BROADCASTING(DtvPropertyRequestInt<i32>),
DTV_ISDBT_SB_SUBCHANNEL_ID(DtvPropertyRequest<i32>), DTV_ISDBT_SB_SUBCHANNEL_ID(DtvPropertyRequestInt<i32>),
DTV_ISDBT_SB_SEGMENT_IDX(DtvPropertyRequest<i32>), DTV_ISDBT_SB_SEGMENT_IDX(DtvPropertyRequestInt<i32>),
DTV_ISDBT_SB_SEGMENT_COUNT(DtvPropertyRequest<u32>), DTV_ISDBT_SB_SEGMENT_COUNT(DtvPropertyRequestInt<u32>),
DTV_ISDBT_LAYERA_FEC(DtvPropertyRequest<fe_code_rate>), DTV_ISDBT_LAYERA_FEC(DtvPropertyRequestInt<fe_code_rate>),
DTV_ISDBT_LAYERA_MODULATION(DtvPropertyRequest<fe_modulation>), DTV_ISDBT_LAYERA_MODULATION(DtvPropertyRequestInt<fe_modulation>),
DTV_ISDBT_LAYERA_SEGMENT_COUNT(DtvPropertyRequest<i32>), DTV_ISDBT_LAYERA_SEGMENT_COUNT(DtvPropertyRequestInt<i32>),
DTV_ISDBT_LAYERA_TIME_INTERLEAVING(DtvPropertyRequest<i32>), DTV_ISDBT_LAYERA_TIME_INTERLEAVING(DtvPropertyRequestInt<i32>),
DTV_ISDBT_LAYERB_FEC(DtvPropertyRequest<fe_code_rate>), DTV_ISDBT_LAYERB_FEC(DtvPropertyRequestInt<fe_code_rate>),
DTV_ISDBT_LAYERB_MODULATION(DtvPropertyRequest<fe_modulation>), DTV_ISDBT_LAYERB_MODULATION(DtvPropertyRequestInt<fe_modulation>),
DTV_ISDBT_LAYERB_SEGMENT_COUNT(DtvPropertyRequest<i32>), DTV_ISDBT_LAYERB_SEGMENT_COUNT(DtvPropertyRequestInt<i32>),
DTV_ISDBT_LAYERB_TIME_INTERLEAVING(DtvPropertyRequest<i32>), DTV_ISDBT_LAYERB_TIME_INTERLEAVING(DtvPropertyRequestInt<i32>),
DTV_ISDBT_LAYERC_FEC(DtvPropertyRequest<fe_code_rate>), DTV_ISDBT_LAYERC_FEC(DtvPropertyRequestInt<fe_code_rate>),
DTV_ISDBT_LAYERC_MODULATION(DtvPropertyRequest<fe_modulation>), DTV_ISDBT_LAYERC_MODULATION(DtvPropertyRequestInt<fe_modulation>),
DTV_ISDBT_LAYERC_SEGMENT_COUNT(DtvPropertyRequest<i32>), DTV_ISDBT_LAYERC_SEGMENT_COUNT(DtvPropertyRequestInt<i32>),
DTV_ISDBT_LAYERC_TIME_INTERLEAVING(DtvPropertyRequest<i32>), DTV_ISDBT_LAYERC_TIME_INTERLEAVING(DtvPropertyRequestInt<i32>),
DTV_API_VERSION(DtvPropertyRequest<u32>), DTV_API_VERSION(DtvPropertyRequestInt<u32>),
/* DVB-T/T2 */ /* DVB-T/T2 */
DTV_CODE_RATE_HP(DtvPropertyRequest<fe_transmit_mode>), DTV_CODE_RATE_HP(DtvPropertyRequestInt<fe_transmit_mode>),
DTV_CODE_RATE_LP(DtvPropertyRequest<fe_transmit_mode>), DTV_CODE_RATE_LP(DtvPropertyRequestInt<fe_transmit_mode>),
DTV_GUARD_INTERVAL(DtvPropertyRequest<fe_guard_interval>), DTV_GUARD_INTERVAL(DtvPropertyRequestInt<fe_guard_interval>),
DTV_TRANSMISSION_MODE(DtvPropertyRequest<fe_transmit_mode>), DTV_TRANSMISSION_MODE(DtvPropertyRequestInt<fe_transmit_mode>),
DTV_HIERARCHY(DtvPropertyRequest<fe_hierarchy>), DTV_HIERARCHY(DtvPropertyRequestInt<fe_hierarchy>),
DTV_ISDBT_LAYER_ENABLED(DtvPropertyRequest<u32>), DTV_ISDBT_LAYER_ENABLED(DtvPropertyRequestInt<u32>),
DTV_STREAM_ID(DtvPropertyRequest<u32>), DTV_STREAM_ID(DtvPropertyRequestInt<u32>),
#[deprecated(note = "Obsolete, replaced with DTV_STREAM_ID.")] #[deprecated(note = "Obsolete, replaced with DTV_STREAM_ID.")]
DTV_DVBT2_PLP_ID_LEGACY(DtvPropertyDeprecated), DTV_DVBT2_PLP_ID_LEGACY(DtvPropertyDeprecated),
DTV_ENUM_DELSYS(DtvPropertyRequestDeliverySystems), DTV_ENUM_DELSYS(DtvPropertyRequestDeliverySystems),
/* ATSC-MH */ /* ATSC-MH */
DTV_ATSCMH_FIC_VER(DtvPropertyRequest<u32>), DTV_ATSCMH_FIC_VER(DtvPropertyRequestInt<u32>),
DTV_ATSCMH_PARADE_ID(DtvPropertyRequest<u32>), DTV_ATSCMH_PARADE_ID(DtvPropertyRequestInt<u32>),
DTV_ATSCMH_NOG(DtvPropertyRequest<u32>), DTV_ATSCMH_NOG(DtvPropertyRequestInt<u32>),
DTV_ATSCMH_TNOG(DtvPropertyRequest<u32>), DTV_ATSCMH_TNOG(DtvPropertyRequestInt<u32>),
DTV_ATSCMH_SGN(DtvPropertyRequest<u32>), DTV_ATSCMH_SGN(DtvPropertyRequestInt<u32>),
DTV_ATSCMH_PRC(DtvPropertyRequest<u32>), DTV_ATSCMH_PRC(DtvPropertyRequestInt<u32>),
DTV_ATSCMH_RS_FRAME_MODE(DtvPropertyNotImplemented), DTV_ATSCMH_RS_FRAME_MODE(DtvPropertyNotImplemented),
DTV_ATSCMH_RS_FRAME_ENSEMBLE(DtvPropertyNotImplemented), DTV_ATSCMH_RS_FRAME_ENSEMBLE(DtvPropertyNotImplemented),
DTV_ATSCMH_RS_CODE_MODE_PRI(DtvPropertyNotImplemented), DTV_ATSCMH_RS_CODE_MODE_PRI(DtvPropertyNotImplemented),
@ -725,51 +743,21 @@ pub enum DtvProperty {
DTV_ATSCMH_SCCC_CODE_MODE_C(DtvPropertyNotImplemented), DTV_ATSCMH_SCCC_CODE_MODE_C(DtvPropertyNotImplemented),
DTV_ATSCMH_SCCC_CODE_MODE_D(DtvPropertyNotImplemented), DTV_ATSCMH_SCCC_CODE_MODE_D(DtvPropertyNotImplemented),
DTV_INTERLEAVING(DtvPropertyRequest<fe_interleaving>), DTV_INTERLEAVING(DtvPropertyRequestInt<fe_interleaving>),
DTV_LNA(DtvPropertyRequest<fe_lna>), DTV_LNA(DtvPropertyRequestInt<fe_lna>),
/* Quality parameters */ /* Quality parameters */
DTV_STAT_SIGNAL_STRENGTH(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_SIGNAL_STRENGTH(DtvPropertyRequestFrontendStats),
DTV_STAT_CNR(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_CNR(DtvPropertyRequestFrontendStats),
DTV_STAT_PRE_ERROR_BIT_COUNT(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_PRE_ERROR_BIT_COUNT(DtvPropertyRequestFrontendStats),
DTV_STAT_PRE_TOTAL_BIT_COUNT(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_PRE_TOTAL_BIT_COUNT(DtvPropertyRequestFrontendStats),
DTV_STAT_POST_ERROR_BIT_COUNT(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_POST_ERROR_BIT_COUNT(DtvPropertyRequestFrontendStats),
DTV_STAT_POST_TOTAL_BIT_COUNT(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_POST_TOTAL_BIT_COUNT(DtvPropertyRequestFrontendStats),
DTV_STAT_ERROR_BLOCK_COUNT(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_ERROR_BLOCK_COUNT(DtvPropertyRequestFrontendStats),
DTV_STAT_TOTAL_BLOCK_COUNT(DtvPropertyRequest<DtvFrontendStats>), DTV_STAT_TOTAL_BLOCK_COUNT(DtvPropertyRequestFrontendStats),
/* Physical layer scrambling */ /* Physical layer scrambling */
DTV_SCRAMBLING_SEQUENCE_INDEX(DtvPropertyRequest<u32>), DTV_SCRAMBLING_SEQUENCE_INDEX(DtvPropertyRequestInt<u32>),
}
#[macro_export]
macro_rules! dtv_property {
( $property:ident, $data:expr ) => {
$property(DtvPropertyRequest::new($data))
};
( $property:ident($data:expr) ) => {
$property(DtvPropertyRequest::new($data))
};
( $property:expr ) => {
$property
};
}
#[macro_export]
macro_rules! req_dtv_properties {
( $device:expr, $( $property:ident ),+ ) => { (|| -> anyhow::Result<_> {
let mut input = [ $( $property(DtvPropertyRequest::default()), )* ];
$device.get_properties(&mut input)?;
let mut iterator = input.iter();
Ok((
$(
match iterator.next() {
Some($property(d)) => d.get(),
_ => ::anyhow::Result::Err(anyhow!("Error unpacking")),
}?,
)*
))
})()}
} }
/// num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl /// num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl