drivers/media/test-drivers/vidtv/vidtv_demod.c

Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vidtv/vidtv_demod.c

File Facts

System
Linux kernel
Corpus path
drivers/media/test-drivers/vidtv/vidtv_demod.c
Extension
.c
Size
12281 bytes
Lines
462
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

if (snr < cnr2qual->cnr_ok) {
			/* eventually lose the TS lock */
			if (get_random_u32_below(100) < config->drop_tslock_prob_on_low_snr)
				state->status = 0;
		} else {
			/* recover if the signal improves */
			if (get_random_u32_below(100) <
			    config->recover_tslock_prob_on_good_snr)
				state->status = FE_HAS_SIGNAL  |
						FE_HAS_CARRIER |
						FE_HAS_VITERBI |
						FE_HAS_SYNC    |
						FE_HAS_LOCK;
		}
	}

	vidtv_demod_update_stats(&state->frontend);

	*status = state->status;

	return 0;
}

static int vidtv_demod_read_signal_strength(struct dvb_frontend *fe,
					    u16 *strength)
{
	struct dtv_frontend_properties *c = &fe->dtv_property_cache;

	*strength = c->strength.stat[0].uvalue;

	return 0;
}

/*
 * NOTE:
 * This is implemented here just to be used as an example for real
 * demod drivers.
 *
 * Should only be implemented if it actually reads something from the hardware.
 * Also, it should check for the locks, in order to avoid report wrong data
 * to userspace.
 */
static int vidtv_demod_get_frontend(struct dvb_frontend *fe,
				    struct dtv_frontend_properties *p)
{
	return 0;
}

static int vidtv_demod_set_frontend(struct dvb_frontend *fe)
{
	struct vidtv_demod_state *state = fe->demodulator_priv;
	u32 tuner_status = 0;
	int ret;

	if (!fe->ops.tuner_ops.set_params)
		return 0;

	fe->ops.tuner_ops.set_params(fe);

	/* store the CNR returned by the tuner */
	ret = fe->ops.tuner_ops.get_rf_strength(fe, &state->tuner_cnr);
	if (ret < 0)
		return ret;

	fe->ops.tuner_ops.get_status(fe, &tuner_status);
	state->status = (state->tuner_cnr > 0) ?  FE_HAS_SIGNAL  |
						    FE_HAS_CARRIER |
						    FE_HAS_VITERBI |
						    FE_HAS_SYNC    |
						    FE_HAS_LOCK	 :
						    0;

	vidtv_demod_update_stats(fe);

	if (fe->ops.i2c_gate_ctrl)
		fe->ops.i2c_gate_ctrl(fe, 0);

	return 0;
}

/*
 * NOTE:
 * This is implemented here just to be used as an example for real
 * demod drivers.
 *
 * Should only be implemented if the demod has support for DVB-S or DVB-S2
 */
static int vidtv_demod_set_tone(struct dvb_frontend *fe,
				enum fe_sec_tone_mode tone)
{

Annotation

Implementation Notes