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.

Dependency Surface

Detected Declarations

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

Implementation Notes