summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-04-24 23:39:07 +0300
committerYuval Adam <_@yuv.al>2021-04-24 23:39:07 +0300
commit0a6bfe601e51f4c9475bec03d077e72ed7c46823 (patch)
tree522fc705ce3aa681fddf3406660f9036fb99e01e /src
parent638c2137cccaf7e7041a5552c26d8670b4a8bf6a (diff)
Implement get_freq_range in addition to hard coded table
Diffstat (limited to 'src')
-rw-r--r--src/tuners/r820t.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/tuners/r820t.rs b/src/tuners/r820t.rs
index 6b5c477..ae80e25 100644
--- a/src/tuners/r820t.rs
+++ b/src/tuners/r820t.rs
@@ -114,6 +114,53 @@ const FREQ_RANGES: [(u32, u8, u8, u8, u8, u8, u8); 21] = [
(650, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00),
];
+fn get_freq_range(freq: u32) -> FreqRange {
+ let open_d = match freq {
+ 0..=69 => 0x08,
+ _ => 0x00,
+ };
+ let rf_mux_ploy = match freq {
+ 0..=279 => 0x02,
+ 280..=449 => 0x41,
+ _ => 0x40,
+ };
+ let tf_c = match freq {
+ 0 => 0xdf,
+ 1..=49 => 0xbe,
+ 50..=54 => 0x8b,
+ 55..=59 => 0x7b,
+ 60..=64 => 0x69,
+ 65..=69 => 0x58,
+ 70..=79 => 0x44,
+ 80..=99 => 0x34,
+ 100..=119 => 0x24,
+ 120..=139 => 0x14,
+ 140..=219 => 0x13,
+ 220..=249 => 0x11,
+ _ => 0x00,
+ };
+ let xtal_cap20p = match freq {
+ 0..=79 => 0x02,
+ 80..=139 => 0x01,
+ _ => 0x00,
+ };
+ let xtal_cap10p = match freq {
+ 0..=139 => 0x01,
+ _ => 0x00,
+ };
+ let xtal_cap0p = 0x00;
+
+ FreqRange {
+ freq,
+ open_d,
+ rf_mux_ploy,
+ tf_c,
+ xtal_cap20p,
+ xtal_cap10p,
+ xtal_cap0p,
+ }
+}
+
const XTAL_CAPS: [(u8, XtalCapValue); 5] = [
(0x0b, XtalCapValue::XtalLowCap30P),
(0x02, XtalCapValue::XtalLowCap20P),