drivers/media/platform/qcom/camss/camss-video.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/camss/camss-video.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/qcom/camss/camss-video.c
Extension
.c
Size
20045 bytes
Lines
770
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 (ret) {
			dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret);
			return;
		}
	}

	video_device_pipeline_stop(vdev);

	video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR);
}

static void video_unprepare_streaming(struct vb2_queue *q)
{
	struct camss_video *video = vb2_get_drv_priv(q);
	struct video_device *vdev = &video->vdev;

	v4l2_pipeline_pm_put(&vdev->entity);
}

static const struct vb2_ops msm_video_vb2_q_ops = {
	.queue_setup     = video_queue_setup,
	.buf_init        = video_buf_init,
	.buf_prepare     = video_buf_prepare,
	.buf_queue       = video_buf_queue,
	.prepare_streaming = video_prepare_streaming,
	.start_streaming = video_start_streaming,
	.stop_streaming  = video_stop_streaming,
	.unprepare_streaming = video_unprepare_streaming,
};

/* -----------------------------------------------------------------------------
 * V4L2 ioctls
 */

static int video_querycap(struct file *file, void *fh,
			  struct v4l2_capability *cap)
{
	strscpy(cap->driver, "qcom-camss", sizeof(cap->driver));
	strscpy(cap->card, "Qualcomm Camera Subsystem", sizeof(cap->card));

	return 0;
}

static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
	struct camss_video *video = video_drvdata(file);
	int i, j, k;
	u32 mcode = f->mbus_code;

	if (f->type != video->type)
		return -EINVAL;

	if (f->index >= video->nformats)
		return -EINVAL;

	/*
	 * Find index "i" of "k"th unique pixelformat in formats array.
	 *
	 * If f->mbus_code passed to video_enum_fmt() is not zero, a device
	 * with V4L2_CAP_IO_MC capability restricts enumeration to only the
	 * pixel formats that can be produced from that media bus code.
	 * This is implemented by skipping video->formats[] entries with
	 * code != f->mbus_code (if f->mbus_code is not zero).
	 * If the f->mbus_code passed to video_enum_fmt() is not supported,
	 * -EINVAL is returned.
	 * If f->mbus_code is zero, all the pixel formats are enumerated.
	 */
	k = -1;
	for (i = 0; i < video->nformats; i++) {
		if (mcode != 0 && video->formats[i].code != mcode)
			continue;

		for (j = 0; j < i; j++) {
			if (mcode != 0 && video->formats[j].code != mcode)
				continue;
			if (video->formats[i].pixelformat ==
					video->formats[j].pixelformat)
				break;
		}

		if (j == i)
			k++;

		if (k == f->index)
			break;
	}

	if (k == -1 || k < f->index)
		/*
		 * All the unique pixel formats matching the arguments

Annotation

Implementation Notes