drivers/media/v4l2-core/tuner-core.c
Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/tuner-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/v4l2-core/tuner-core.c- Extension
.c- Size
- 37571 bytes
- Lines
- 1425
- 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/module.hlinux/kernel.hlinux/string.hlinux/timer.hlinux/delay.hlinux/errno.hlinux/slab.hlinux/poll.hlinux/i2c.hlinux/types.hlinux/init.hlinux/videodev2.hmedia/tuner.hmedia/tuner-types.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmt20xx.htda8290.htea5761.htea5767.hxc2028.htuner-simple.htda9887.hxc5000.htda18271.hxc4000.h
Detected Declarations
struct tunerenum tuner_pad_indexenum if_vid_dec_pad_indexfunction tuner_detachfunction tuner_detachfunction fe_set_paramsfunction fe_standbyfunction fe_set_configfunction set_typefunction tuner_s_type_addrfunction set_configfunction tuner_lookupfunction list_for_each_entryfunction tuner_probefunction tuner_removefunction radiofunction set_modefunction set_freqfunction set_tv_freqfunction tuner_fixup_stdfunction set_radio_freqfunction tuner_statusfunction tuner_s_radiofunction tuner_standbyfunction tuner_s_stdfunction tuner_s_frequencyfunction tuner_g_frequencyfunction tuner_g_tunerfunction tuner_s_tunerfunction tuner_log_statusfunction tuner_suspendfunction tuner_resumefunction tuner_command
Annotated Snippet
struct tuner {
/* device */
struct dvb_frontend fe;
struct i2c_client *i2c;
struct v4l2_subdev sd;
struct list_head list;
/* keep track of the current settings */
v4l2_std_id std;
unsigned int tv_freq;
unsigned int radio_freq;
unsigned int audmode;
enum v4l2_tuner_type mode;
unsigned int mode_mask; /* Combination of allowable modes */
bool standby; /* Standby mode */
unsigned int type; /* chip type id */
void *config;
const char *name;
#if defined(CONFIG_MEDIA_CONTROLLER)
struct media_pad pad[TUNER_NUM_PADS];
#endif
};
/*
* Function prototypes
*/
static void set_tv_freq(struct i2c_client *c, unsigned int freq);
static void set_radio_freq(struct i2c_client *c, unsigned int freq);
/*
* tuner attach/detach logic
*/
/* This macro allows us to probe dynamically, avoiding static links */
#ifdef CONFIG_MEDIA_ATTACH
#define tuner_symbol_probe(FUNCTION, ARGS...) ({ \
int __r = -EINVAL; \
typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
if (__a) { \
__r = (int) __a(ARGS); \
symbol_put(FUNCTION); \
} else { \
printk(KERN_ERR "TUNER: Unable to find " \
"symbol "#FUNCTION"()\n"); \
} \
__r; \
})
static void tuner_detach(struct dvb_frontend *fe)
{
if (fe->ops.tuner_ops.release) {
fe->ops.tuner_ops.release(fe);
symbol_put_addr(fe->ops.tuner_ops.release);
}
if (fe->ops.analog_ops.release) {
fe->ops.analog_ops.release(fe);
symbol_put_addr(fe->ops.analog_ops.release);
}
}
#else
#define tuner_symbol_probe(FUNCTION, ARGS...) ({ \
FUNCTION(ARGS); \
})
static void tuner_detach(struct dvb_frontend *fe)
{
if (fe->ops.tuner_ops.release)
fe->ops.tuner_ops.release(fe);
if (fe->ops.analog_ops.release)
fe->ops.analog_ops.release(fe);
}
#endif
static inline struct tuner *to_tuner(struct v4l2_subdev *sd)
{
return container_of(sd, struct tuner, sd);
}
/*
* struct analog_demod_ops callbacks
*/
static void fe_set_params(struct dvb_frontend *fe,
struct analog_parameters *params)
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/string.h`, `linux/timer.h`, `linux/delay.h`, `linux/errno.h`, `linux/slab.h`, `linux/poll.h`.
- Detected declarations: `struct tuner`, `enum tuner_pad_index`, `enum if_vid_dec_pad_index`, `function tuner_detach`, `function tuner_detach`, `function fe_set_params`, `function fe_standby`, `function fe_set_config`, `function set_type`, `function tuner_s_type_addr`.
- 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.