drivers/media/test-drivers/vivid/vivid-kthread-cap.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vivid/vivid-kthread-cap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vivid/vivid-kthread-cap.c- Extension
.c- Size
- 30362 bytes
- Lines
- 916
- 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/errno.hlinux/kernel.hlinux/init.hlinux/sched.hlinux/slab.hlinux/font.hlinux/mutex.hlinux/videodev2.hlinux/kthread.hlinux/freezer.hlinux/random.hlinux/v4l2-dv-timings.hlinux/jiffies.hasm/div64.hmedia/videobuf2-vmalloc.hmedia/v4l2-dv-timings.hmedia/v4l2-ioctl.hmedia/v4l2-fh.hmedia/v4l2-event.hmedia/v4l2-rect.hvivid-core.hvivid-vid-common.hvivid-vid-cap.hvivid-vid-out.hvivid-radio-common.hvivid-radio-rx.hvivid-radio-tx.hvivid-sdr-cap.hvivid-vbi-cap.hvivid-vbi-out.hvivid-osd.h
Detected Declarations
function vivid_get_std_capfunction copy_pixfunction blend_linefunction scale_linefunction crop_capfunction vivid_copy_bufferfunction vivid_fillbufffunction vivid_cap_update_frame_periodfunction vivid_thread_vid_cap_tickfunction vivid_thread_vid_capfunction vivid_grab_controlsfunction vivid_start_generating_vid_capfunction vivid_stop_generating_vid_cap
Annotated Snippet
if (error >= dstw) {
error -= dstw;
src_x++;
}
}
}
/*
* Precalculate the rectangles needed to perform video looping:
*
* The nominal pipeline is that the video output buffer is cropped by
* crop_out, scaled to compose_out, overlaid with the output overlay,
* cropped on the capture side by crop_cap and scaled again to the video
* capture buffer using compose_cap.
*
* To keep things efficient we calculate the intersection of compose_out
* and crop_cap (since that's the only part of the video that will
* actually end up in the capture buffer), determine which part of the
* video output buffer that is and which part of the video capture buffer
* so we can scale the video straight from the output buffer to the capture
* buffer without any intermediate steps.
*
* If we need to deal with an output overlay, then there is no choice and
* that intermediate step still has to be taken. For the output overlay
* support we calculate the intersection of the framebuffer and the overlay
* window (which may be partially or wholly outside of the framebuffer
* itself) and the intersection of that with loop_vid_copy (i.e. the part of
* the actual looped video that will be overlaid). The result is calculated
* both in framebuffer coordinates (loop_fb_copy) and compose_out coordinates
* (loop_vid_overlay). Finally calculate the part of the capture buffer that
* will receive that overlaid video.
*/
static void vivid_precalc_copy_rects(struct vivid_dev *dev, struct vivid_dev *out_dev)
{
/* Framebuffer rectangle */
struct v4l2_rect r_fb = {
0, 0, dev->display_width, dev->display_height
};
/* Overlay window rectangle in framebuffer coordinates */
struct v4l2_rect r_overlay = {
out_dev->overlay_out_left, out_dev->overlay_out_top,
out_dev->compose_out.width, out_dev->compose_out.height
};
v4l2_rect_intersect(&dev->loop_vid_copy, &dev->crop_cap, &out_dev->compose_out);
dev->loop_vid_out = dev->loop_vid_copy;
v4l2_rect_scale(&dev->loop_vid_out, &out_dev->compose_out, &out_dev->crop_out);
dev->loop_vid_out.left += out_dev->crop_out.left;
dev->loop_vid_out.top += out_dev->crop_out.top;
dev->loop_vid_cap = dev->loop_vid_copy;
v4l2_rect_scale(&dev->loop_vid_cap, &dev->crop_cap, &dev->compose_cap);
dprintk(dev, 1,
"loop_vid_copy: (%d,%d)/%ux%u loop_vid_out: (%d,%d)/%ux%u loop_vid_cap: (%d,%d)/%ux%u\n",
dev->loop_vid_copy.left, dev->loop_vid_copy.top,
dev->loop_vid_copy.width, dev->loop_vid_copy.height,
dev->loop_vid_out.left, dev->loop_vid_out.top,
dev->loop_vid_out.width, dev->loop_vid_out.height,
dev->loop_vid_cap.left, dev->loop_vid_cap.top,
dev->loop_vid_cap.width, dev->loop_vid_cap.height);
v4l2_rect_intersect(&r_overlay, &r_fb, &r_overlay);
/* shift r_overlay to the same origin as compose_out */
r_overlay.left += out_dev->compose_out.left - out_dev->overlay_out_left;
r_overlay.top += out_dev->compose_out.top - out_dev->overlay_out_top;
v4l2_rect_intersect(&dev->loop_vid_overlay, &r_overlay, &dev->loop_vid_copy);
dev->loop_fb_copy = dev->loop_vid_overlay;
/* shift dev->loop_fb_copy back again to the fb origin */
dev->loop_fb_copy.left -= out_dev->compose_out.left - out_dev->overlay_out_left;
dev->loop_fb_copy.top -= out_dev->compose_out.top - out_dev->overlay_out_top;
dev->loop_vid_overlay_cap = dev->loop_vid_overlay;
v4l2_rect_scale(&dev->loop_vid_overlay_cap, &dev->crop_cap, &dev->compose_cap);
dprintk(dev, 1,
"loop_fb_copy: (%d,%d)/%ux%u loop_vid_overlay: (%d,%d)/%ux%u loop_vid_overlay_cap: (%d,%d)/%ux%u\n",
dev->loop_fb_copy.left, dev->loop_fb_copy.top,
dev->loop_fb_copy.width, dev->loop_fb_copy.height,
dev->loop_vid_overlay.left, dev->loop_vid_overlay.top,
dev->loop_vid_overlay.width, dev->loop_vid_overlay.height,
dev->loop_vid_overlay_cap.left, dev->loop_vid_overlay_cap.top,
dev->loop_vid_overlay_cap.width, dev->loop_vid_overlay_cap.height);
}
static void *plane_vaddr(struct tpg_data *tpg, struct vivid_buffer *buf,
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/kernel.h`, `linux/init.h`, `linux/sched.h`, `linux/slab.h`, `linux/font.h`, `linux/mutex.h`.
- Detected declarations: `function vivid_get_std_cap`, `function copy_pix`, `function blend_line`, `function scale_line`, `function crop_cap`, `function vivid_copy_buffer`, `function vivid_fillbuff`, `function vivid_cap_update_frame_period`, `function vivid_thread_vid_cap_tick`, `function vivid_thread_vid_cap`.
- 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.