drivers/media/dvb-frontends/tda8083.c

Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/tda8083.c

File Facts

System
Linux kernel
Corpus path
drivers/media/dvb-frontends/tda8083.c
Extension
.c
Size
11436 bytes
Lines
485
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 tda8083_state {
	struct i2c_adapter* i2c;
	/* configuration settings */
	const struct tda8083_config* config;
	struct dvb_frontend frontend;
};

static int debug;
#define dprintk(args...) \
	do { \
		if (debug) printk(KERN_DEBUG "tda8083: " args); \
	} while (0)


static u8 tda8083_init_tab [] = {
	0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
	0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
	0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
	0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
	0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00
};


static int tda8083_writereg (struct tda8083_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 %02x, ret == %i)\n",
			__func__, reg, ret);

	return (ret != 1) ? -1 : 0;
}

static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len)
{
	int ret;
	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg1, .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 (reg %02x, ret == %i)\n",
			__func__, reg1, ret);

	return ret == 2 ? 0 : -1;
}

static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg)
{
	u8 val;

	tda8083_readregs (state, reg, &val, 1);

	return val;
}

static int tda8083_set_inversion(struct tda8083_state *state,
				 enum fe_spectral_inversion inversion)
{
	/*  XXX FIXME: implement other modes than FEC_AUTO */
	if (inversion == INVERSION_AUTO)
		return 0;

	return -EINVAL;
}

static int tda8083_set_fec(struct tda8083_state *state, enum fe_code_rate fec)
{
	if (fec == FEC_AUTO)
		return tda8083_writereg (state, 0x07, 0xff);

	if (fec >= FEC_1_2 && fec <= FEC_8_9)
		return tda8083_writereg (state, 0x07, 1 << (FEC_8_9 - fec));

	return -EINVAL;
}

static enum fe_code_rate tda8083_get_fec(struct tda8083_state *state)
{
	u8 index;
	static enum fe_code_rate fec_tab[] = {
		FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
		FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8

Annotation

Implementation Notes