drivers/media/usb/usbtv/usbtv-video.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/usbtv/usbtv-video.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/usbtv/usbtv-video.c
Extension
.c
Size
26512 bytes
Lines
973
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

if (norm_params[i].norm & norm) {
			params = &norm_params[i];
			break;
		}
	}

	if (params) {
		if (vb2_is_busy(&usbtv->vb2q) &&
		    (usbtv->width != params->cap_width ||
		     usbtv->height != params->cap_height))
			return -EBUSY;
		usbtv->width = params->cap_width;
		usbtv->height = params->cap_height;
		usbtv->n_chunks = usbtv->width * usbtv->height
						/ 4 / USBTV_CHUNK;
		usbtv->norm = norm;
	} else
		ret = -EINVAL;

	return ret;
}

static int usbtv_select_input(struct usbtv *usbtv, int input)
{
	int ret;

	static const u16 composite[][2] = {
		{ USBTV_BASE + 0x0105, 0x0060 },
		{ USBTV_BASE + 0x011f, 0x00f2 },
		{ USBTV_BASE + 0x0127, 0x0060 },
		{ USBTV_BASE + 0x00ae, 0x0010 },
		{ USBTV_BASE + 0x0239, 0x0060 },
	};

	static const u16 svideo[][2] = {
		{ USBTV_BASE + 0x0105, 0x0010 },
		{ USBTV_BASE + 0x011f, 0x00ff },
		{ USBTV_BASE + 0x0127, 0x0060 },
		{ USBTV_BASE + 0x00ae, 0x0030 },
		{ USBTV_BASE + 0x0239, 0x0060 },
	};

	switch (input) {
	case USBTV_COMPOSITE_INPUT:
		ret = usbtv_set_regs(usbtv, composite, ARRAY_SIZE(composite));
		break;
	case USBTV_SVIDEO_INPUT:
		ret = usbtv_set_regs(usbtv, svideo, ARRAY_SIZE(svideo));
		break;
	default:
		ret = -EINVAL;
	}

	if (!ret)
		usbtv->input = input;

	return ret;
}

static uint16_t usbtv_norm_to_16f_reg(v4l2_std_id norm)
{
	/* NTSC M/M-JP/M-KR */
	if (norm & V4L2_STD_NTSC)
		return 0x00b8;
	/* PAL BG/DK/H/I */
	if (norm & V4L2_STD_PAL)
		return 0x00ee;
	/* SECAM B/D/G/H/K/K1/L/Lc */
	if (norm & V4L2_STD_SECAM)
		return 0x00ff;
	if (norm & V4L2_STD_NTSC_443)
		return 0x00a8;
	if (norm & (V4L2_STD_PAL_M | V4L2_STD_PAL_60))
		return 0x00bc;
	if (norm & V4L2_STD_PAL_Nc)
		return 0x00fe;
	/* Fallback to automatic detection for other standards */
	return 0x0000;
}

static int usbtv_select_norm(struct usbtv *usbtv, v4l2_std_id norm)
{
	int ret;
	/* These are the series of register values used to configure the
	 * decoder for a specific standard.
	 * The first 21 register writes are copied from the
	 * Settings\DecoderDefaults registry keys present in the Windows driver
	 * .INF file, and control various image tuning parameters (color
	 * correction, sharpness, ...).
	 */

Annotation

Implementation Notes