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.

Dependency Surface

Detected Declarations

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

Implementation Notes