From 8fb4794c1ccf9707874ff2db69ea4153f18c7896 Mon Sep 17 00:00:00 2001 From: Andrey Dyldin Date: Tue, 26 Jan 2021 16:30:53 +0200 Subject: [PATCH] FeDevice::set_tone(); FeDevice::set_voltage() --- src/fe/mod.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/fe/sys.rs | 16 ---------------- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/fe/mod.rs b/src/fe/mod.rs index 2972261..9aae98d 100644 --- a/src/fe/mod.rs +++ b/src/fe/mod.rs @@ -33,6 +33,8 @@ use { nix::{ ioctl_read, ioctl_write_ptr, + ioctl_write_int_bad, + request_code_none, }, sys::*, @@ -341,6 +343,50 @@ impl FeDevice { Ok(()) } + /// Turns on/off generation of the continuous 22kHz tone + /// + /// allowed `value`'s: + /// + /// - SEC_TONE_ON - turn 22kHz on + /// - SEC_TONE_OFF - turn 22kHz off + pub fn set_tone(&self, value: u32) -> Result<()> { + ioctl_write_int_bad!(#[inline] ioctl_call, request_code_none!(b'o', 66)); + + unsafe { + ioctl_call(self.as_raw_fd(), value as _) + }.context("frontend set tone")?; + + Ok(()) + } + + /// Sets the DC voltage level for LNB + /// + /// allowed `value`'s: + /// + /// - SEC_VOLTAGE_13 for 13V + /// - SEC_VOLTAGE_18 for 18V + /// - SEC_VOLTAGE_OFF turns LNB power supply off + /// + /// Different power levels used to select internal antennas for different polarizations: + /// + /// - 13V: + /// - Vertical in linear LNB + /// - Right in circular LNB + /// - 18V: + /// - Horizontal in linear LNB + /// - Left in circular LNB + /// - OFF is needed with external power supply, for example + /// to use same LNB with several receivers. + pub fn set_voltage(&self, value: u32) -> Result<()> { + ioctl_write_int_bad!(#[inline] ioctl_call, request_code_none!(b'o', 67)); + + unsafe { + ioctl_call(self.as_raw_fd(), value as _) + }.context("frontend set voltage")?; + + Ok(()) + } + /// Sets DiSEqC master command /// /// `msg` is a message no more 6 bytes length diff --git a/src/fe/sys.rs b/src/fe/sys.rs index 3741bf8..36d98b8 100644 --- a/src/fe/sys.rs +++ b/src/fe/sys.rs @@ -734,19 +734,3 @@ impl FeEvent { #[inline] pub fn as_mut_ptr(&mut self) -> *mut FeEvent { self as *mut _ } } - - -pub const FE_DISEQC_RESET_OVERLOAD: IoctlInt = io_none(b'o', 62); -pub const FE_DISEQC_RECV_SLAVE_REPLY: IoctlInt = io_read::(b'o', 64); -pub const FE_DISEQC_SEND_BURST: IoctlInt = io_none(b'o', 65); - -pub const FE_SET_TONE: IoctlInt = io_none(b'o', 66); -pub const FE_SET_VOLTAGE: IoctlInt = io_none(b'o', 67); -pub const FE_ENABLE_HIGH_LNB_VOLTAGE: IoctlInt = io_none(b'o', 68); - -pub const FE_READ_BER: IoctlInt = io_read::(b'o', 70); -pub const FE_READ_SIGNAL_STRENGTH: IoctlInt = io_read::(b'o', 71); -pub const FE_READ_SNR: IoctlInt = io_read::(b'o', 72); -pub const FE_READ_UNCORRECTED_BLOCKS: IoctlInt = io_read::(b'o', 73); - -pub const FE_SET_FRONTEND_TUNE_MODE: IoctlInt = io_none(b'o', 81);