drivers/media/dvb-frontends/af9013.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/dvb-frontends/af9013.c
Extension
.c
Size
35344 bytes
Lines
1577
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source 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 af9013_state {
	struct i2c_client *client;
	struct regmap *regmap;
	struct i2c_mux_core *muxc;
	struct dvb_frontend fe;
	u32 clk;
	u8 tuner;
	u32 if_frequency;
	u8 ts_mode;
	u8 ts_output_pin;
	bool spec_inv;
	u8 api_version[4];
	u8 gpio[4];

	u32 bandwidth_hz;
	enum fe_status fe_status;
	/* RF and IF AGC limits used for signal strength calc */
	u8 strength_en, rf_agc_50, rf_agc_80, if_agc_50, if_agc_80;
	unsigned long set_frontend_jiffies;
	unsigned long read_status_jiffies;
	unsigned long strength_jiffies;
	unsigned long cnr_jiffies;
	unsigned long ber_ucb_jiffies;
	u16 dvbv3_snr;
	u16 dvbv3_strength;
	u32 dvbv3_ber;
	u32 dvbv3_ucblocks;
	bool first_tune;
};

static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval)
{
	struct i2c_client *client = state->client;
	int ret;
	u8 pos;
	u16 addr;

	dev_dbg(&client->dev, "gpio %u, gpioval %02x\n", gpio, gpioval);

	/*
	 * GPIO0 & GPIO1 0xd735
	 * GPIO2 & GPIO3 0xd736
	 */

	switch (gpio) {
	case 0:
	case 1:
		addr = 0xd735;
		break;
	case 2:
	case 3:
		addr = 0xd736;
		break;

	default:
		ret = -EINVAL;
		goto err;
	}

	switch (gpio) {
	case 0:
	case 2:
		pos = 0;
		break;
	case 1:
	case 3:
	default:
		pos = 4;
		break;
	}

	ret = regmap_update_bits(state->regmap, addr, 0x0f << pos,
				 gpioval << pos);
	if (ret)
		goto err;

	return 0;
err:
	dev_dbg(&client->dev, "failed %d\n", ret);
	return ret;
}

static int af9013_get_tune_settings(struct dvb_frontend *fe,
	struct dvb_frontend_tune_settings *fesettings)
{
	fesettings->min_delay_ms = 800;
	fesettings->step_size = 0;
	fesettings->max_drift = 0;

	return 0;

Annotation

Implementation Notes