drivers/media/dvb-frontends/lg2160.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/lg2160.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/lg2160.c- Extension
.c- Size
- 28861 bytes
- Lines
- 1435
- 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/jiffies.hlinux/dvb/frontend.hlg2160.h
Detected Declarations
struct lg216x_statestruct lg216x_regfunction lg216x_write_regfunction lg216x_read_regfunction lg216x_write_regsfunction lg216x_set_reg_bitfunction lg216x_i2c_gate_ctrlfunction lg216x_soft_resetfunction lg216x_initializefunction lg216x_set_iffunction lg2160_agc_fixfunction lg2160_agc_freezefunction lg2160_agc_polarityfunction lg2160_tuner_pwr_save_polarityfunction lg2160_spectrum_polarityfunction lg2160_tuner_pwr_savefunction lg216x_set_paradefunction lg216x_set_ensemblefunction lg2160_set_spi_clockfunction lg2161_set_output_interfacefunction lg216x_enable_ficfunction lg216x_get_fic_versionfunction lg2160_get_parade_idfunction lg216x_get_nogfunction lg216x_get_tnogfunction lg216x_get_sgnfunction lg216x_get_prcfunction lg216x_get_rs_frame_modefunction lg216x_get_rs_frame_ensemblefunction lg216x_get_rs_code_modefunction lg216x_get_sccc_block_modefunction lg216x_get_sccc_code_modefunction lg216x_read_fic_err_countfunction lg2160_read_crc_err_countfunction lg2161_read_crc_err_countfunction lg216x_read_crc_err_countfunction lg2160_read_rs_err_countfunction lg2161_read_rs_err_countfunction lg216x_read_rs_err_countfunction lg216x_get_frontendfunction lg2160_set_frontendfunction lg2160_read_lock_statusfunction lg2161_read_lock_statusfunction lg216x_read_lock_statusfunction lg216x_read_statusfunction lg2160_read_snrfunction lg2161_read_snrfunction lg216x_read_signal_strength
Annotated Snippet
struct lg216x_state {
struct i2c_adapter *i2c_adap;
const struct lg2160_config *cfg;
struct dvb_frontend frontend;
u32 current_frequency;
u8 parade_id;
u8 fic_ver;
unsigned int last_reset;
};
/* ------------------------------------------------------------------------ */
static int lg216x_write_reg(struct lg216x_state *state, u16 reg, u8 val)
{
int ret;
u8 buf[] = { reg >> 8, reg & 0xff, val };
struct i2c_msg msg = {
.addr = state->cfg->i2c_addr, .flags = 0,
.buf = buf, .len = 3,
};
lg_reg("reg: 0x%04x, val: 0x%02x\n", reg, val);
ret = i2c_transfer(state->i2c_adap, &msg, 1);
if (ret != 1) {
lg_err("error (addr %02x %02x <- %02x, err = %i)\n",
msg.buf[0], msg.buf[1], msg.buf[2], ret);
if (ret < 0)
return ret;
else
return -EREMOTEIO;
}
return 0;
}
static int lg216x_read_reg(struct lg216x_state *state, u16 reg, u8 *val)
{
int ret;
u8 reg_buf[] = { reg >> 8, reg & 0xff };
struct i2c_msg msg[] = {
{ .addr = state->cfg->i2c_addr,
.flags = 0, .buf = reg_buf, .len = 2 },
{ .addr = state->cfg->i2c_addr,
.flags = I2C_M_RD, .buf = val, .len = 1 },
};
lg_reg("reg: 0x%04x\n", reg);
ret = i2c_transfer(state->i2c_adap, msg, 2);
if (ret != 2) {
lg_err("error (addr %02x reg %04x error (ret == %i)\n",
state->cfg->i2c_addr, reg, ret);
if (ret < 0)
return ret;
else
return -EREMOTEIO;
}
return 0;
}
struct lg216x_reg {
u16 reg;
u8 val;
};
static int lg216x_write_regs(struct lg216x_state *state,
struct lg216x_reg *regs, int len)
{
int i, ret;
lg_reg("writing %d registers...\n", len);
for (i = 0; i < len; i++) {
ret = lg216x_write_reg(state, regs[i].reg, regs[i].val);
if (lg_fail(ret))
return ret;
}
return 0;
}
static int lg216x_set_reg_bit(struct lg216x_state *state,
u16 reg, int bit, int onoff)
{
u8 val;
int ret;
Annotation
- Immediate include surface: `linux/jiffies.h`, `linux/dvb/frontend.h`, `lg2160.h`.
- Detected declarations: `struct lg216x_state`, `struct lg216x_reg`, `function lg216x_write_reg`, `function lg216x_read_reg`, `function lg216x_write_regs`, `function lg216x_set_reg_bit`, `function lg216x_i2c_gate_ctrl`, `function lg216x_soft_reset`, `function lg216x_initialize`, `function lg216x_set_if`.
- 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.