drivers/media/dvb-frontends/stv0299.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/stv0299.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/stv0299.c- Extension
.c- Size
- 18152 bytes
- Lines
- 756
- 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/init.hlinux/kernel.hlinux/ktime.hlinux/module.hlinux/string.hlinux/slab.hlinux/jiffies.hasm/div64.hmedia/dvb_frontend.hstv0299.h
Detected Declarations
struct stv0299_statefunction stv0299_writeregIfunction stv0299_writefunction stv0299_readregfunction stv0299_readregsfunction stv0299_set_FECfunction stv0299_get_fecfunction stv0299_wait_diseqc_fifofunction stv0299_wait_diseqc_idlefunction stv0299_set_symbolratefunction stv0299_get_symbolratefunction stv0299_send_diseqc_msgfunction stv0299_send_diseqc_burstfunction stv0299_set_tonefunction stv0299_set_voltagefunction stv0299_send_legacy_dish_cmdfunction stv0299_initfunction stv0299_read_statusfunction stv0299_read_berfunction stv0299_read_signal_strengthfunction stv0299_read_snrfunction stv0299_read_ucblocksfunction stv0299_set_frontendfunction stv0299_get_frontendfunction stv0299_sleepfunction stv0299_i2c_gate_ctrlfunction stv0299_get_tune_settingsfunction stv0299_releasefunction stv0299_attachexport stv0299_attach
Annotated Snippet
struct stv0299_state {
struct i2c_adapter* i2c;
const struct stv0299_config* config;
struct dvb_frontend frontend;
u8 initialised:1;
u32 tuner_frequency;
u32 symbol_rate;
enum fe_code_rate fec_inner;
int errmode;
u32 ucblocks;
u8 mcr_reg;
};
#define STATUS_BER 0
#define STATUS_UCBLOCKS 1
static int debug;
static int debug_legacy_dish_switch;
#define dprintk(args...) \
do { \
if (debug) printk(KERN_DEBUG "stv0299: " args); \
} while (0)
static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
{
int ret;
u8 buf [] = { reg, data };
struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
ret = i2c_transfer (state->i2c, &msg, 1);
if (ret != 1)
dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
__func__, reg, data, ret);
return (ret != 1) ? -EREMOTEIO : 0;
}
static int stv0299_write(struct dvb_frontend* fe, const u8 buf[], int len)
{
struct stv0299_state* state = fe->demodulator_priv;
if (len != 2)
return -EINVAL;
return stv0299_writeregI(state, buf[0], buf[1]);
}
static u8 stv0299_readreg (struct stv0299_state* state, u8 reg)
{
int ret;
u8 b0 [] = { reg };
u8 b1 [] = { 0 };
struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
ret = i2c_transfer (state->i2c, msg, 2);
if (ret != 2)
dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n",
__func__, reg, ret);
return b1[0];
}
static int stv0299_readregs (struct stv0299_state* state, u8 reg1, u8 *b, u8 len)
{
int ret;
struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = ®1, .len = 1 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
ret = i2c_transfer (state->i2c, msg, 2);
if (ret != 2)
dprintk("%s: readreg error (ret == %i)\n", __func__, ret);
return ret == 2 ? 0 : ret;
}
static int stv0299_set_FEC(struct stv0299_state *state, enum fe_code_rate fec)
{
dprintk ("%s\n", __func__);
switch (fec) {
case FEC_AUTO:
{
return stv0299_writeregI (state, 0x31, 0x1f);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/ktime.h`, `linux/module.h`, `linux/string.h`, `linux/slab.h`, `linux/jiffies.h`, `asm/div64.h`.
- Detected declarations: `struct stv0299_state`, `function stv0299_writeregI`, `function stv0299_write`, `function stv0299_readreg`, `function stv0299_readregs`, `function stv0299_set_FEC`, `function stv0299_get_fec`, `function stv0299_wait_diseqc_fifo`, `function stv0299_wait_diseqc_idle`, `function stv0299_set_symbolrate`.
- 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.