1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//! Tuner driver trait and implementations.
//!
//! Each tuner IC (R820T, E4000, FC0012, etc.) implements the `Tuner` trait,
//! providing frequency, gain, and bandwidth control via I2C.
// Per-tuner backends carry the IC's I2C register tables transcribed
// from upstream `librtlsdr`. Some entries aren't called from Rust
// today but are kept for completeness so adding a hardware feature
// later is a register-table read rather than a re-port. Scoped
// `dead_code` allow per-module rather than crate-level so dead paths
// in non-port code still get caught. Per #630 CR round 2.
pub
pub
pub
pub
pub
use crateRtlSdrError;
/// Trait for a tuner IC driver.
///
/// Tuners communicate with the RTL2832 via I2C. The I2C repeater must be
/// enabled before calling these methods and disabled after.
///
/// # Errors (typed since 0.2)
///
/// Each method returns [`RtlSdrError`]. The most common
/// tuner-side variants (carried inside `RtlSdrError::Tuner` as
/// [`crate::TunerError`]) match by method shape:
///
/// - `set_freq` — `PllNotLocked { freq_hz }` (R82xx, E4K when
/// the requested LO doesn't reach lock),
/// `PllProgrammingFailed { backend, freq_hz, reason }`
/// (R82xx VCO-divider / nint-bound failures, FC0012 / FC0013
/// PLL underflow, FC2580 n_val overflow), `XtalIsZero`
/// (any backend when the crystal is misconfigured).
/// - `set_bw` — `UnsupportedFilterBandwidth { mode }` (FC2580
/// only). Other backends should not return tuner errors here
/// today; the success return is the IF-frequency hint
/// (see method-level doc).
/// - `set_gain` — `InvalidGain { what, detail }` (E4K only;
/// other backends accept any value or snap to nearest).
/// - All methods can additionally return `RtlSdrError::Usb(...)`
/// from the underlying USB control transfer, and the R82xx
/// I2C path can return `I2cTransferFailed { operation, got,
/// expected }` (raw byte-count mismatch on the I2C-write
/// wrapper) or `ShadowCacheMiss { reg }` (caller used
/// `write_reg_mask` before `init` populated the shadow).
///
/// Per audit pass-2 #73 — pre-fix the trait was silent on
/// which TunerError variants each method could produce, forcing
/// consumers to either match all of them or rely on `is_*`
/// helpers that don't exist.