drivers/media/usb/dvb-usb/vp702x-fe.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb/vp702x-fe.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/dvb-usb/vp702x-fe.c
Extension
.c
Size
8838 bytes
Lines
378
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 vp702x_fe_state {
	struct dvb_frontend fe;
	struct dvb_usb_device *d;

	struct dvb_frontend_ops ops;

	enum fe_sec_voltage voltage;
	enum fe_sec_tone_mode tone_mode;

	u8 lnb_buf[8];

	u8 lock;
	u8 sig;
	u8 snr;

	unsigned long next_status_check;
	unsigned long status_check_interval;
};

static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
{
	struct vp702x_device_state *dst = st->d->priv;
	u8 *buf;

	if (time_after(jiffies, st->next_status_check)) {
		mutex_lock(&dst->buf_mutex);
		buf = dst->buf;

		vp702x_usb_in_op(st->d, READ_STATUS, 0, 0, buf, 10);
		st->lock = buf[4];

		vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x11, 0, buf, 1);
		st->snr = buf[0];

		vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x15, 0, buf, 1);
		st->sig = buf[0];

		mutex_unlock(&dst->buf_mutex);
		st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
	}
	return 0;
}

static u8 vp702x_chksum(u8 *buf,int f, int count)
{
	u8 s = 0;
	int i;
	for (i = f; i < f+count; i++)
		s += buf[i];
	return ~s+1;
}

static int vp702x_fe_read_status(struct dvb_frontend *fe,
				 enum fe_status *status)
{
	struct vp702x_fe_state *st = fe->demodulator_priv;
	vp702x_fe_refresh_state(st);
	deb_fe("%s\n",__func__);

	if (st->lock == 0)
		*status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER;
	else
		*status = 0;

	if (*status & FE_HAS_LOCK)
		st->status_check_interval = 1000;
	else
		st->status_check_interval = 250;
	return 0;
}

/* not supported by this Frontend */
static int vp702x_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
{
	struct vp702x_fe_state *st = fe->demodulator_priv;
	vp702x_fe_refresh_state(st);
	*ber = 0;
	return 0;
}

/* not supported by this Frontend */
static int vp702x_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
{
	struct vp702x_fe_state *st = fe->demodulator_priv;
	vp702x_fe_refresh_state(st);
	*unc = 0;
	return 0;
}

static int vp702x_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)

Annotation

Implementation Notes