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.
- 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
linux/module.hlinux/usb.hlinux/mm.hlinux/slab.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-common.hmedia/v4l2-ioctl.hmedia/v4l2-fh.hmedia/v4l2-event.hmedia/videobuf2-vmalloc.hmedia/i2c/saa7115.hstk1160.hstk1160-reg.h
Detected Declarations
struct stk1160_decimate_ctrlenum stk1160_decimate_modefunction div_round_integerfunction stk1160_set_stdfunction stk1160_set_fmtfunction stk1160_set_alternatefunction stk1160_start_streamingfunction Wefunction stk1160_stop_hwfunction stk1160_stop_streamingfunction vidioc_querycapfunction vidioc_enum_fmt_vid_capfunction vidioc_g_fmt_vid_capfunction stk1160_try_fmtfunction vidioc_try_fmt_vid_capfunction vidioc_s_fmt_vid_capfunction vidioc_querystdfunction vidioc_g_stdfunction vidioc_s_stdfunction vidioc_enum_inputfunction vidioc_g_inputfunction vidioc_s_inputfunction vidioc_g_registerfunction vidioc_s_registerfunction queue_setupfunction buffer_queuefunction start_streamingfunction stop_streamingfunction stk1160_clear_queuefunction stk1160_vb2_setupfunction stk1160_video_register
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
- Immediate include surface: `linux/module.h`, `linux/usb.h`, `linux/mm.h`, `linux/slab.h`, `linux/videodev2.h`, `media/v4l2-device.h`, `media/v4l2-common.h`, `media/v4l2-ioctl.h`.
- Detected declarations: `struct stk1160_decimate_ctrl`, `enum stk1160_decimate_mode`, `function div_round_integer`, `function stk1160_set_std`, `function stk1160_set_fmt`, `function stk1160_set_alternate`, `function stk1160_start_streaming`, `function We`, `function stk1160_stop_hw`, `function stk1160_stop_streaming`.
- 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.