drivers/media/dvb-frontends/cx24120.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/cx24120.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/cx24120.c- Extension
.c- Size
- 42473 bytes
- Lines
- 1592
- 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/slab.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/firmware.hmedia/dvb_frontend.hcx24120.h
Detected Declarations
struct cx24120_tuningstruct cx24120_statestruct cx24120_cmdstruct cx24120_modfecstruct cx24120_clock_ratios_tablestruct cx24120_modfec_tableenum command_message_idfunction cx24120_readregfunction cx24120_writeregfunction cx24120_writeregsfunction cx24120_test_romfunction cx24120_read_snrfunction cx24120_read_berfunction cx24120_check_cmdfunction cx24120_message_sendfunction cx24120_message_sendrcvfunction cx24120_read_signal_strengthfunction cx24120_msg_mpeg_output_global_configfunction cx24120_msg_mpeg_output_configfunction cx24120_diseqc_send_burstfunction cx24120_set_tonefunction cx24120_set_voltagefunction cx24120_send_diseqc_msgfunction cx24120_get_statsfunction cx24120_read_statusfunction cx24120_get_fecfunction cx24120_calculate_ber_windowfunction cx24120_set_clock_ratiosfunction cx24120_set_inversionfunction cx24120_set_fecfunction cx24120_set_pilotfunction cx24120_set_symbolratefunction cx24120_clone_paramsfunction cx24120_set_frontendfunction cx24120_set_vcofunction cx24120_initfunction cx24120_msg_mpeg_output_configfunction cx24120_tunefunction cx24120_get_algofunction cx24120_sleepfunction cx24120_get_frontendfunction cx24120_releasefunction cx24120_read_ucblocksexport cx24120_attach
Annotated Snippet
struct cx24120_tuning {
u32 frequency;
u32 symbol_rate;
enum fe_spectral_inversion inversion;
enum fe_code_rate fec;
enum fe_delivery_system delsys;
enum fe_modulation modulation;
enum fe_pilot pilot;
/* Demod values */
u8 fec_val;
u8 fec_mask;
u8 clkdiv;
u8 ratediv;
u8 inversion_val;
u8 pilot_val;
};
/* Private state */
struct cx24120_state {
struct i2c_adapter *i2c;
const struct cx24120_config *config;
struct dvb_frontend frontend;
u8 cold_init;
u8 mpeg_enabled;
u8 need_clock_set;
/* current and next tuning parameters */
struct cx24120_tuning dcur;
struct cx24120_tuning dnxt;
enum fe_status fe_status;
/* dvbv5 stats calculations */
u32 bitrate;
u32 berw_usecs;
u32 ber_prev;
u32 ucb_offset;
unsigned long ber_jiffies_stats;
unsigned long per_jiffies_stats;
};
/* Command message to firmware */
struct cx24120_cmd {
u8 id;
u8 len;
u8 arg[CX24120_MAX_CMD_LEN];
};
/* Read single register */
static int cx24120_readreg(struct cx24120_state *state, u8 reg)
{
int ret;
u8 buf = 0;
struct i2c_msg msg[] = {
{
.addr = state->config->i2c_addr,
.flags = 0,
.len = 1,
.buf = ®
}, {
.addr = state->config->i2c_addr,
.flags = I2C_M_RD,
.len = 1,
.buf = &buf
}
};
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2) {
err("Read error: reg=0x%02x, ret=%i)\n", reg, ret);
return ret;
}
dev_dbg(&state->i2c->dev, "reg=0x%02x; data=0x%02x\n", reg, buf);
return buf;
}
/* Write single register */
static int cx24120_writereg(struct cx24120_state *state, u8 reg, u8 data)
{
u8 buf[] = { reg, data };
struct i2c_msg msg = {
.addr = state->config->i2c_addr,
.flags = 0,
.buf = buf,
.len = 2
Annotation
- Immediate include surface: `linux/slab.h`, `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/firmware.h`, `media/dvb_frontend.h`, `cx24120.h`.
- Detected declarations: `struct cx24120_tuning`, `struct cx24120_state`, `struct cx24120_cmd`, `struct cx24120_modfec`, `struct cx24120_clock_ratios_table`, `struct cx24120_modfec_table`, `enum command_message_id`, `function cx24120_readreg`, `function cx24120_writereg`, `function cx24120_writeregs`.
- 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.