drivers/media/usb/stk1160/stk1160-v4l.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/stk1160/stk1160-v4l.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/stk1160/stk1160-v4l.c
Extension
.c
Size
20779 bytes
Lines
842
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 stk1160_decimate_ctrl {
	bool col_en, row_en;
	enum stk1160_decimate_mode col_mode, row_mode;
	unsigned int col_n, row_n;
};

/* supported video standards */
static struct stk1160_fmt format[] = {
	{
		.fourcc   = V4L2_PIX_FMT_UYVY,
		.depth    = 16,
	}
};

/*
 * Helper to find the next divisor that results in modulo being zero.
 * This is required to guarantee valid decimation unit counts.
 */
static unsigned int
div_round_integer(unsigned int x, unsigned int y)
{
	for (;; y++) {
		if (x % y == 0)
			return x / y;
	}
}

static void stk1160_set_std(struct stk1160 *dev)
{
	int i;

	static struct regval std525[] = {

		/* 720x480 */

		/* Frame start */
		{STK116_CFSPO_STX_L, 0x0000},
		{STK116_CFSPO_STX_H, 0x0000},
		{STK116_CFSPO_STY_L, 0x0003},
		{STK116_CFSPO_STY_H, 0x0000},

		/* Frame end */
		{STK116_CFEPO_ENX_L, 0x05a0},
		{STK116_CFEPO_ENX_H, 0x0005},
		{STK116_CFEPO_ENY_L, 0x00f3},
		{STK116_CFEPO_ENY_H, 0x0000},

		{0xffff, 0xffff}
	};

	static struct regval std625[] = {

		/* 720x576 */

		/* TODO: Each line of frame has some junk at the end */
		/* Frame start */
		{STK116_CFSPO,   0x0000},
		{STK116_CFSPO+1, 0x0000},
		{STK116_CFSPO+2, 0x0001},
		{STK116_CFSPO+3, 0x0000},

		/* Frame end */
		{STK116_CFEPO,   0x05a0},
		{STK116_CFEPO+1, 0x0005},
		{STK116_CFEPO+2, 0x0121},
		{STK116_CFEPO+3, 0x0001},

		{0xffff, 0xffff}
	};

	if (dev->norm & V4L2_STD_525_60) {
		stk1160_dbg("registers to NTSC like standard\n");
		for (i = 0; std525[i].reg != 0xffff; i++)
			stk1160_write_reg(dev, std525[i].reg, std525[i].val);
	} else {
		stk1160_dbg("registers to PAL like standard\n");
		for (i = 0; std625[i].reg != 0xffff; i++)
			stk1160_write_reg(dev, std625[i].reg, std625[i].val);
	}

}

static void stk1160_set_fmt(struct stk1160 *dev,
			    struct stk1160_decimate_ctrl *ctrl)
{
	u32 val = 0;

	if (ctrl) {
		/*
		 * Since the format is UYVY, the device must skip or send

Annotation

Implementation Notes