drivers/media/tuners/tuner-simple.c
Source file repositories/reference/linux-study-clean/drivers/media/tuners/tuner-simple.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/tuners/tuner-simple.c- Extension
.c- Size
- 29450 bytes
- Lines
- 1145
- 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/i2c.hlinux/videodev2.hmedia/tuner.hmedia/v4l2-common.hmedia/tuner-types.htuner-i2c.htuner-simple.h
Detected Declarations
struct tuner_simple_privfunction tuner_read_statusfunction tuner_signalfunction tuner_stereofunction tuner_islockedfunction tuner_afcstatusfunction simple_get_statusfunction simple_get_rf_strengthfunction simple_config_lookupfunction simple_set_rf_inputfunction simple_std_setupfunction simple_set_aux_bytefunction simple_post_tunefunction simple_radio_bandswitchfunction simple_set_tv_freqfunction simple_set_radio_freqfunction simple_set_paramsfunction simple_set_dvbfunction simple_dvb_configurefunction simple_dvb_calc_regsfunction simple_dvb_set_paramsfunction simple_initfunction simple_sleepfunction simple_releasefunction simple_get_frequencyfunction simple_get_bandwidthexport simple_tuner_attach
Annotated Snippet
struct tuner_simple_priv {
unsigned int nr;
u16 last_div;
struct tuner_i2c_props i2c_props;
struct list_head hybrid_tuner_instance_list;
unsigned int type;
const struct tunertype *tun;
u32 frequency;
u32 bandwidth;
bool radio_mode;
};
/* ---------------------------------------------------------------------- */
static int tuner_read_status(struct dvb_frontend *fe)
{
struct tuner_simple_priv *priv = fe->tuner_priv;
unsigned char byte;
if (1 != tuner_i2c_xfer_recv(&priv->i2c_props, &byte, 1))
return 0;
return byte;
}
static inline int tuner_signal(const int status)
{
return (status & TUNER_SIGNAL) << 13;
}
static inline int tuner_stereo(const int type, const int status)
{
switch (type) {
case TUNER_PHILIPS_FM1216ME_MK3:
case TUNER_PHILIPS_FM1236_MK3:
case TUNER_PHILIPS_FM1256_IH3:
case TUNER_LG_NTSC_TAPE:
case TUNER_TCL_MF02GIP_5N:
return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
case TUNER_PHILIPS_FM1216MK5:
return status | TUNER_STEREO;
default:
return status & TUNER_STEREO;
}
}
static inline int tuner_islocked(const int status)
{
return (status & TUNER_FL);
}
static inline int tuner_afcstatus(const int status)
{
return (status & TUNER_AFC) - 2;
}
static int simple_get_status(struct dvb_frontend *fe, u32 *status)
{
struct tuner_simple_priv *priv = fe->tuner_priv;
int tuner_status;
if (priv->i2c_props.adap == NULL)
return -EINVAL;
tuner_status = tuner_read_status(fe);
*status = 0;
if (tuner_islocked(tuner_status))
*status = TUNER_STATUS_LOCKED;
if (tuner_stereo(priv->type, tuner_status))
*status |= TUNER_STATUS_STEREO;
tuner_dbg("AFC Status: %d\n", tuner_afcstatus(tuner_status));
return 0;
}
static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
{
struct tuner_simple_priv *priv = fe->tuner_priv;
int signal;
if (priv->i2c_props.adap == NULL || !priv->radio_mode)
return -EINVAL;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/videodev2.h`, `media/tuner.h`, `media/v4l2-common.h`, `media/tuner-types.h`, `tuner-i2c.h`, `tuner-simple.h`.
- Detected declarations: `struct tuner_simple_priv`, `function tuner_read_status`, `function tuner_signal`, `function tuner_stereo`, `function tuner_islocked`, `function tuner_afcstatus`, `function simple_get_status`, `function simple_get_rf_strength`, `function simple_config_lookup`, `function simple_set_rf_input`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.