drivers/media/i2c/tvaudio.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/tvaudio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/tvaudio.c- Extension
.c- Size
- 63294 bytes
- Lines
- 2104
- 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/sched.hlinux/string.hlinux/timer.hlinux/delay.hlinux/errno.hlinux/slab.hlinux/videodev2.hlinux/i2c.hlinux/init.hlinux/kthread.hlinux/freezer.hmedia/i2c/tvaudio.hmedia/v4l2-device.hmedia/v4l2-ctrls.h
Detected Declarations
struct CHIPSTATEstruct CHIPDESCstruct CHIPSTATEfunction chip_writefunction chip_write_maskedfunction chip_readfunction chip_read2function chip_cmdfunction modefunction chip_threadfunction tda9840_getrxsubchansfunction tda9840_setaudmodefunction tda9840_checkitfunction tda9855_volumefunction tda9855_bassfunction tda9855_treblefunction tda985x_getrxsubchansfunction tda985x_setaudmodefunction monofunction tda9873_setaudmodefunction tda9873_checkitfunction tda9874a_setupfunction tda9874a_getrxsubchansfunction tda9874a_setaudmodefunction pinfunction tda9874a_checkitfunction tda9874a_initializefunction tda9875_initializefunction tda9875_volumefunction tda9875_bassfunction tda9875_treblefunction tda9875_checkitfunction tea6300_shift10function tea6300_shift12function tea6320_volumefunction tea6320_shift11function tea6320_initializefunction tda8425_shift10function tda8425_shift12function tda8425_setaudmodefunction ta8874z_getrxsubchansfunction ta8874z_setaudmodefunction ta8874z_checkitfunction tvaudio_s_ctrlfunction tvaudio_s_radiofunction tvaudio_s_routingfunction tvaudio_s_tunerfunction tvaudio_g_tuner
Annotated Snippet
struct CHIPDESC {
char *name; /* chip name */
int addr_lo, addr_hi; /* i2c address range */
int registers; /* # of registers */
int *insmodopt;
checkit checkit;
initialize initialize;
int flags;
#define CHIP_HAS_VOLUME 1
#define CHIP_HAS_BASSTREBLE 2
#define CHIP_HAS_INPUTSEL 4
#define CHIP_NEED_CHECKMODE 8
/* various i2c command sequences */
audiocmd init;
/* which register has which value */
int leftreg, rightreg, treblereg, bassreg;
/* initialize with (defaults to 65535/32768/32768 */
int volinit, trebleinit, bassinit;
/* functions to convert the values (v4l -> chip) */
getvalue volfunc, treblefunc, bassfunc;
/* get/set mode */
getrxsubchans getrxsubchans;
setaudmode setaudmode;
/* input switch register + values for v4l inputs */
int inputreg;
int inputmap[4];
int inputmute;
int inputmask;
};
/* current state of the chip */
struct CHIPSTATE {
struct v4l2_subdev sd;
struct v4l2_ctrl_handler hdl;
struct {
/* volume/balance cluster */
struct v4l2_ctrl *volume;
struct v4l2_ctrl *balance;
};
/* chip-specific description - should point to
an entry at CHIPDESC table */
struct CHIPDESC *desc;
/* shadow register set */
audiocmd shadow;
/* current settings */
u16 muted;
int prevmode;
int radio;
int input;
/* thread */
struct task_struct *thread;
struct timer_list wt;
int audmode;
};
static inline struct CHIPSTATE *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct CHIPSTATE, sd);
}
static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
{
return &container_of(ctrl->handler, struct CHIPSTATE, hdl)->sd;
}
/* ---------------------------------------------------------------------- */
/* i2c I/O functions */
static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
{
struct v4l2_subdev *sd = &chip->sd;
struct i2c_client *c = v4l2_get_subdevdata(sd);
unsigned char buffer[2];
int rc;
if (subaddr < 0) {
v4l2_dbg(1, debug, sd, "chip_write: 0x%x\n", val);
chip->shadow.bytes[1] = val;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/string.h`, `linux/timer.h`, `linux/delay.h`, `linux/errno.h`, `linux/slab.h`.
- Detected declarations: `struct CHIPSTATE`, `struct CHIPDESC`, `struct CHIPSTATE`, `function chip_write`, `function chip_write_masked`, `function chip_read`, `function chip_read2`, `function chip_cmd`, `function mode`, `function chip_thread`.
- 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.