drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
Extension
.c
Size
14399 bytes
Lines
599
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 mxl111sf_demod_state {
	struct mxl111sf_state *mxl_state;

	const struct mxl111sf_demod_config *cfg;

	struct dvb_frontend fe;
};

/* ------------------------------------------------------------------------ */

static int mxl111sf_demod_read_reg(struct mxl111sf_demod_state *state,
				   u8 addr, u8 *data)
{
	return (state->cfg->read_reg) ?
		state->cfg->read_reg(state->mxl_state, addr, data) :
		-EINVAL;
}

static int mxl111sf_demod_write_reg(struct mxl111sf_demod_state *state,
				    u8 addr, u8 data)
{
	return (state->cfg->write_reg) ?
		state->cfg->write_reg(state->mxl_state, addr, data) :
		-EINVAL;
}

static
int mxl111sf_demod_program_regs(struct mxl111sf_demod_state *state,
				struct mxl111sf_reg_ctrl_info *ctrl_reg_info)
{
	return (state->cfg->program_regs) ?
		state->cfg->program_regs(state->mxl_state, ctrl_reg_info) :
		-EINVAL;
}

/* ------------------------------------------------------------------------ */
/* TPS */

static
int mxl1x1sf_demod_get_tps_code_rate(struct mxl111sf_demod_state *state,
				     enum fe_code_rate *code_rate)
{
	u8 val;
	int ret = mxl111sf_demod_read_reg(state, V6_CODE_RATE_TPS_REG, &val);
	/* bit<2:0> - 000:1/2, 001:2/3, 010:3/4, 011:5/6, 100:7/8 */
	if (mxl_fail(ret))
		goto fail;

	switch (val & V6_CODE_RATE_TPS_MASK) {
	case 0:
		*code_rate = FEC_1_2;
		break;
	case 1:
		*code_rate = FEC_2_3;
		break;
	case 2:
		*code_rate = FEC_3_4;
		break;
	case 3:
		*code_rate = FEC_5_6;
		break;
	case 4:
		*code_rate = FEC_7_8;
		break;
	}
fail:
	return ret;
}

static
int mxl1x1sf_demod_get_tps_modulation(struct mxl111sf_demod_state *state,
				      enum fe_modulation *modulation)
{
	u8 val;
	int ret = mxl111sf_demod_read_reg(state, V6_MODORDER_TPS_REG, &val);
	/* Constellation, 00 : QPSK, 01 : 16QAM, 10:64QAM */
	if (mxl_fail(ret))
		goto fail;

	switch ((val & V6_PARAM_CONSTELLATION_MASK) >> 4) {
	case 0:
		*modulation = QPSK;
		break;
	case 1:
		*modulation = QAM_16;
		break;
	case 2:
		*modulation = QAM_64;
		break;
	}

Annotation

Implementation Notes