drivers/media/radio/radio-tea5764.c
Source file repositories/reference/linux-study-clean/drivers/media/radio/radio-tea5764.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/radio/radio-tea5764.c- Extension
.c- Size
- 14283 bytes
- Lines
- 530
- 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/kernel.hlinux/slab.hlinux/module.hlinux/init.hlinux/videodev2.hlinux/i2c.hmedia/v4l2-common.hmedia/v4l2-ioctl.hmedia/v4l2-device.hmedia/v4l2-ctrls.hmedia/v4l2-event.h
Detected Declarations
struct tea5764_regsstruct tea5764_write_regsstruct tea5764_devicefunction tea5764_i2c_readfunction tea5764_i2c_writefunction tea5764_power_upfunction tea5764_power_downfunction tea5764_set_freqfunction tea5764_get_freqfunction tea5764_tunefunction tea5764_set_audout_modefunction tea5764_get_audout_modefunction tea5764_mutefunction vidioc_querycapfunction vidioc_g_tunerfunction vidioc_s_tunerfunction vidioc_s_frequencyfunction vidioc_g_frequencyfunction tea5764_s_ctrlfunction tea5764_i2c_probefunction tea5764_i2c_remove
Annotated Snippet
struct tea5764_regs {
u16 intreg; /* INTFLAG & INTMSK */
u16 frqset; /* FRQSETMSB & FRQSETLSB */
u16 tnctrl; /* TNCTRL1 & TNCTRL2 */
u16 frqchk; /* FRQCHKMSB & FRQCHKLSB */
u16 tunchk; /* IFCHK & LEVCHK */
u16 testreg; /* TESTBITS & TESTMODE */
u16 rdsstat; /* RDSSTAT1 & RDSSTAT2 */
u16 rdslb; /* RDSLBMSB & RDSLBLSB */
u16 rdspb; /* RDSPBMSB & RDSPBLSB */
u16 rdsbc; /* RDSBBC & RDSGBC */
u16 rdsctrl; /* RDSCTRL1 & RDSCTRL2 */
u16 rdsbbl; /* PAUSEDET & RDSBBL */
u16 manid; /* MANID1 & MANID2 */
u16 chipid; /* CHIPID1 & CHIPID2 */
} __attribute__ ((packed));
struct tea5764_write_regs {
u8 intreg; /* INTMSK */
__be16 frqset; /* FRQSETMSB & FRQSETLSB */
__be16 tnctrl; /* TNCTRL1 & TNCTRL2 */
__be16 testreg; /* TESTBITS & TESTMODE */
__be16 rdsctrl; /* RDSCTRL1 & RDSCTRL2 */
__be16 rdsbbl; /* PAUSEDET & RDSBBL */
} __attribute__ ((packed));
#ifdef CONFIG_RADIO_TEA5764_XTAL
#define RADIO_TEA5764_XTAL 1
#else
#define RADIO_TEA5764_XTAL 0
#endif
static int radio_nr = -1;
static int use_xtal = RADIO_TEA5764_XTAL;
struct tea5764_device {
struct v4l2_device v4l2_dev;
struct v4l2_ctrl_handler ctrl_handler;
struct i2c_client *i2c_client;
struct video_device vdev;
struct tea5764_regs regs;
struct mutex mutex;
};
/* I2C code related */
static int tea5764_i2c_read(struct tea5764_device *radio)
{
int i;
u16 *p = (u16 *) &radio->regs;
struct i2c_msg msgs[1] = {
{ .addr = radio->i2c_client->addr,
.flags = I2C_M_RD,
.len = sizeof(radio->regs),
.buf = (void *)&radio->regs
},
};
if (i2c_transfer(radio->i2c_client->adapter, msgs, 1) != 1)
return -EIO;
for (i = 0; i < sizeof(struct tea5764_regs) / sizeof(u16); i++)
p[i] = __be16_to_cpu((__force __be16)p[i]);
return 0;
}
static int tea5764_i2c_write(struct tea5764_device *radio)
{
struct tea5764_write_regs wr;
struct tea5764_regs *r = &radio->regs;
struct i2c_msg msgs[1] = {
{
.addr = radio->i2c_client->addr,
.len = sizeof(wr),
.buf = (void *)&wr
},
};
wr.intreg = r->intreg & 0xff;
wr.frqset = __cpu_to_be16(r->frqset);
wr.tnctrl = __cpu_to_be16(r->tnctrl);
wr.testreg = __cpu_to_be16(r->testreg);
wr.rdsctrl = __cpu_to_be16(r->rdsctrl);
wr.rdsbbl = __cpu_to_be16(r->rdsbbl);
if (i2c_transfer(radio->i2c_client->adapter, msgs, 1) != 1)
return -EIO;
return 0;
}
static void tea5764_power_up(struct tea5764_device *radio)
{
struct tea5764_regs *r = &radio->regs;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/module.h`, `linux/init.h`, `linux/videodev2.h`, `linux/i2c.h`, `media/v4l2-common.h`, `media/v4l2-ioctl.h`.
- Detected declarations: `struct tea5764_regs`, `struct tea5764_write_regs`, `struct tea5764_device`, `function tea5764_i2c_read`, `function tea5764_i2c_write`, `function tea5764_power_up`, `function tea5764_power_down`, `function tea5764_set_freq`, `function tea5764_get_freq`, `function tea5764_tune`.
- 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.