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.

Dependency Surface

Detected Declarations

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 = &reg
		}, {
			.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

Implementation Notes