drivers/media/dvb-frontends/stv0367.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/stv0367.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/stv0367.c- Extension
.c- Size
- 89993 bytes
- Lines
- 3333
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/string.hlinux/slab.hlinux/i2c.hlinux/int_log.hstv0367.hstv0367_defs.hstv0367_regs.hstv0367_priv.h
Detected Declarations
struct stv0367cab_statestruct stv0367ter_statestruct stv0367_stateenum active_demod_statefunction stv0367_writeregfunction stv0367_readregfunction extract_mask_posfunction stv0367_writebitsfunction stv0367_setbitsfunction stv0367_readbitsfunction stv0367_getbitsfunction stv0367_write_tablefunction stv0367_pll_setupfunction stv0367_get_if_khzfunction stv0367ter_gate_ctrlfunction stv0367_get_tuner_freqfunction stv0367ter_get_mclkfunction stv0367ter_filt_coeff_initfunction stv0367ter_agc_iir_lock_detect_setfunction stv0367_iir_filt_initfunction stv0367ter_agc_iir_rstfunction stv0367ter_durationfunction stv0367ter_check_syrfunction stv0367ter_check_cpampfunction stv0367ter_lock_algofunction stv0367ter_set_ts_modefunction stv0367ter_set_clk_polfunction stv0367ter_core_swfunction stv0367ter_standbyfunction stv0367ter_sleepfunction stv0367ter_initfunction stv0367ter_algofunction stv0367ter_set_frontendfunction stv0367ter_read_ucblocksfunction stv0367ter_get_frontendfunction stv0367ter_snr_readregfunction stv0367ter_read_snrfunction stv0367ter_statusfunction stv0367ter_read_statusfunction stv0367ter_read_berfunction stv0367ter_get_perfunction stv0367_get_tune_settingsfunction stv0367_releasefunction stv0367cab_gate_ctrlfunction stv0367cab_get_mclkfunction stv0367cab_get_adc_freqfunction stv0367cab_SetQamSizefunction stv0367cab_set_derot_freq
Annotated Snippet
struct stv0367cab_state {
enum stv0367_cab_signal_type state;
u32 mclk;
u32 adc_clk;
s32 search_range;
s32 derot_offset;
/* results */
int locked; /* channel found */
u32 freq_khz; /* found frequency (in kHz) */
u32 symbol_rate; /* found symbol rate (in Bds) */
enum fe_spectral_inversion spect_inv; /* Spectrum Inversion */
u32 qamfec_status_reg; /* status reg to poll for FEC Lock */
};
struct stv0367ter_state {
/* DVB-T */
enum stv0367_ter_signal_type state;
enum stv0367_ter_if_iq_mode if_iq_mode;
enum stv0367_ter_mode mode;/* mode 2K or 8K */
enum fe_guard_interval guard;
enum stv0367_ter_hierarchy hierarchy;
u32 frequency;
enum fe_spectral_inversion sense; /* current search spectrum */
u8 force; /* force mode/guard */
u8 bw; /* channel width 6, 7 or 8 in MHz */
u8 pBW; /* channel width used during previous lock */
u32 pBER;
u32 pPER;
u32 ucblocks;
s8 echo_pos; /* echo position */
u8 first_lock;
u8 unlock_counter;
u32 agc_val;
};
struct stv0367_state {
struct dvb_frontend fe;
struct i2c_adapter *i2c;
/* config settings */
const struct stv0367_config *config;
u8 chip_id;
/* DVB-C */
struct stv0367cab_state *cab_state;
/* DVB-T */
struct stv0367ter_state *ter_state;
/* flags for operation control */
u8 use_i2c_gatectrl;
u8 deftabs;
u8 reinit_on_setfrontend;
u8 auto_if_khz;
enum active_demod_state activedemod;
};
#define RF_LOOKUP_TABLE_SIZE 31
#define RF_LOOKUP_TABLE2_SIZE 16
/* RF Level (for RF AGC->AGC1) Lookup Table, depends on the board and tuner.*/
static const s32 stv0367cab_RF_LookUp1[RF_LOOKUP_TABLE_SIZE][RF_LOOKUP_TABLE_SIZE] = {
{/*AGC1*/
48, 50, 51, 53, 54, 56, 57, 58, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 80, 83, 85, 88,
}, {/*RF(dbm)*/
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47,
49, 50, 52, 53, 54, 55, 56,
}
};
/* RF Level (for IF AGC->AGC2) Lookup Table, depends on the board and tuner.*/
static const s32 stv0367cab_RF_LookUp2[RF_LOOKUP_TABLE2_SIZE][RF_LOOKUP_TABLE2_SIZE] = {
{/*AGC2*/
28, 29, 31, 32, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45,
}, {/*RF(dbm)*/
57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72,
}
};
static noinline_for_stack
int stv0367_writereg(struct stv0367_state *state, u16 reg, u8 data)
{
u8 buf[3] = { MSB(reg), LSB(reg), data };
struct i2c_msg msg = {
.addr = state->config->demod_address,
.flags = 0,
.buf = buf,
.len = 3,
};
int ret;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/string.h`, `linux/slab.h`, `linux/i2c.h`, `linux/int_log.h`, `stv0367.h`, `stv0367_defs.h`.
- Detected declarations: `struct stv0367cab_state`, `struct stv0367ter_state`, `struct stv0367_state`, `enum active_demod_state`, `function stv0367_writereg`, `function stv0367_readreg`, `function extract_mask_pos`, `function stv0367_writebits`, `function stv0367_setbits`, `function stv0367_readbits`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.