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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/printk.hlinux/random.hlinux/ratelimit.hlinux/slab.hlinux/string.hlinux/workqueue.hmedia/dvb_frontend.hvidtv_demod.h
Detected Declarations
function vidtv_clean_statsfunction vidtv_demod_update_statsfunction vidtv_demod_read_statusfunction vidtv_demod_read_signal_strengthfunction vidtv_demod_get_frontendfunction vidtv_demod_set_frontendfunction vidtv_demod_set_tonefunction vidtv_demod_set_voltagefunction vidtv_send_diseqc_msgfunction vidtv_diseqc_send_burstfunction vidtv_demod_releasefunction vidtv_demod_i2c_probefunction vidtv_demod_i2c_remove
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
- Immediate include surface: `linux/errno.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/printk.h`, `linux/random.h`, `linux/ratelimit.h`.
- Detected declarations: `function vidtv_clean_stats`, `function vidtv_demod_update_stats`, `function vidtv_demod_read_status`, `function vidtv_demod_read_signal_strength`, `function vidtv_demod_get_frontend`, `function vidtv_demod_set_frontend`, `function vidtv_demod_set_tone`, `function vidtv_demod_set_voltage`, `function vidtv_send_diseqc_msg`, `function vidtv_diseqc_send_burst`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.