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

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

File Facts

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

	const struct mxl111sf_tuner_config *cfg;

	enum mxl_if_freq if_freq;

	u32 frequency;
	u32 bandwidth;
};

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

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

static int mxl111sf_tuner_program_regs(struct mxl111sf_tuner_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;
}

static int mxl1x1sf_tuner_top_master_ctrl(struct mxl111sf_tuner_state *state,
					  int onoff)
{
	return (state->cfg->top_master_ctrl) ?
		state->cfg->top_master_ctrl(state->mxl_state, onoff) :
		-EINVAL;
}

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

static struct mxl111sf_reg_ctrl_info mxl_phy_tune_rf[] = {
	{0x1d, 0x7f, 0x00}, /* channel bandwidth section 1/2/3,
			       DIG_MODEINDEX, _A, _CSF, */
	{0x1e, 0xff, 0x00}, /* channel frequency (lo and fractional) */
	{0x1f, 0xff, 0x00}, /* channel frequency (hi for integer portion) */
	{0,    0,    0}
};

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

static struct mxl111sf_reg_ctrl_info *mxl111sf_calc_phy_tune_regs(u32 freq,
								  u8 bw)
{
	u8 filt_bw;

	/* set channel bandwidth */
	switch (bw) {
	case 0: /* ATSC */
		filt_bw = 25;
		break;
	case 1: /* QAM */
		filt_bw = 69;
		break;
	case 6:
		filt_bw = 21;
		break;
	case 7:
		filt_bw = 42;
		break;
	case 8:
		filt_bw = 63;
		break;
	default:
		pr_err("%s: invalid bandwidth setting!", __func__);
		return NULL;
	}

	/* calculate RF channel */
	freq /= 1000000;

	freq *= 64;
#if 0
	/* do round */
	freq += 0.5;
#endif

Annotation

Implementation Notes