drivers/media/i2c/tvp5150.c

Source file repositories/reference/linux-study-clean/drivers/media/i2c/tvp5150.c

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/tvp5150.c
Extension
.c
Size
62194 bytes
Lines
2293
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 tvp5150_connector {
	struct v4l2_fwnode_connector base;
	struct media_entity ent;
	struct media_pad pad;
};

struct tvp5150 {
	struct v4l2_subdev sd;

	struct media_pad pads[TVP5150_NUM_PADS];
	struct tvp5150_connector connectors[TVP5150_MAX_CONNECTORS];
	struct tvp5150_connector *cur_connector;
	unsigned int connectors_num;

	struct v4l2_ctrl_handler hdl;
	struct v4l2_rect rect;
	struct regmap *regmap;
	int irq;

	v4l2_std_id norm;	/* Current set standard */
	v4l2_std_id detected_norm;
	u32 input;
	u32 output;
	u32 oe;
	int enable;
	bool lock;

	u16 dev_id;
	u16 rom_ver;

	enum v4l2_mbus_type mbus_type;
};

static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
{
	return container_of(sd, struct tvp5150, sd);
}

static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
{
	return &container_of(ctrl->handler, struct tvp5150, hdl)->sd;
}

static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
{
	struct tvp5150 *decoder = to_tvp5150(sd);
	int ret, val;

	ret = regmap_read(decoder->regmap, addr, &val);
	if (ret < 0)
		return ret;

	return val;
}

static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init,
				const u8 end, int max_line)
{
	u8 buf[16];
	int i = 0, j, len;

	if (max_line > 16) {
		dprintk0(sd->dev, "too much data to dump\n");
		return;
	}

	for (i = init; i < end; i += max_line) {
		len = (end - i > max_line) ? max_line : end - i;

		for (j = 0; j < len; j++)
			buf[j] = tvp5150_read(sd, i + j);

		dprintk0(sd->dev, "%s reg %02x = %*ph\n", s, i, len, buf);
	}
}

static int tvp5150_log_status(struct v4l2_subdev *sd)
{
	dprintk0(sd->dev, "tvp5150: Video input source selection #1 = 0x%02x\n",
		tvp5150_read(sd, TVP5150_VD_IN_SRC_SEL_1));
	dprintk0(sd->dev, "tvp5150: Analog channel controls = 0x%02x\n",
		tvp5150_read(sd, TVP5150_ANAL_CHL_CTL));
	dprintk0(sd->dev, "tvp5150: Operation mode controls = 0x%02x\n",
		tvp5150_read(sd, TVP5150_OP_MODE_CTL));
	dprintk0(sd->dev, "tvp5150: Miscellaneous controls = 0x%02x\n",
		tvp5150_read(sd, TVP5150_MISC_CTL));
	dprintk0(sd->dev, "tvp5150: Autoswitch mask= 0x%02x\n",
		tvp5150_read(sd, TVP5150_AUTOSW_MSK));
	dprintk0(sd->dev, "tvp5150: Color killer threshold control = 0x%02x\n",
		tvp5150_read(sd, TVP5150_COLOR_KIL_THSH_CTL));

Annotation

Implementation Notes