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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
media/v4l2-ioctl.hmedia/videobuf2-v4l2.husbtv.h
Detected Declarations
function usbtv_configure_for_normfunction usbtv_select_inputfunction usbtv_norm_to_16f_regfunction usbtv_select_normfunction usbtv_setup_capturefunction usbtv_chunk_to_vbuffunction usbtv_image_chunkfunction usbtv_iso_cbfunction usbtv_stopfunction usbtv_startfunction usbtv_querycapfunction usbtv_enum_inputfunction usbtv_enum_fmt_vid_capfunction usbtv_fmt_vid_capfunction usbtv_g_stdfunction usbtv_s_stdfunction usbtv_g_inputfunction usbtv_s_inputfunction usbtv_queue_setupfunction usbtv_buf_queuefunction usbtv_start_streamingfunction usbtv_stop_streamingfunction usbtv_s_ctrlfunction usbtv_releasefunction usbtv_video_initfunction usbtv_video_free
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
- Immediate include surface: `media/v4l2-ioctl.h`, `media/videobuf2-v4l2.h`, `usbtv.h`.
- Detected declarations: `function usbtv_configure_for_norm`, `function usbtv_select_input`, `function usbtv_norm_to_16f_reg`, `function usbtv_select_norm`, `function usbtv_setup_capture`, `function usbtv_chunk_to_vbuf`, `function usbtv_image_chunk`, `function usbtv_iso_cb`, `function usbtv_stop`, `function usbtv_start`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.