drivers/media/platform/arm/mali-c55/mali-c55-capture.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/arm/mali-c55/mali-c55-capture.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/arm/mali-c55/mali-c55-capture.c
Extension
.c
Size
26619 bytes
Lines
960
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 (j++ == f->index) {
			f->pixelformat = mali_c55_fmts[i].fourcc;
			return 0;
		}
	}

	return -EINVAL;
}

static int mali_c55_querycap(struct file *file, void *fh,
			     struct v4l2_capability *cap)
{
	strscpy(cap->driver, MALI_C55_DRIVER_NAME, sizeof(cap->driver));
	strscpy(cap->card, "ARM Mali-C55 ISP", sizeof(cap->card));

	return 0;
}

static const struct v4l2_ioctl_ops mali_c55_v4l2_ioctl_ops = {
	.vidioc_reqbufs = vb2_ioctl_reqbufs,
	.vidioc_querybuf = vb2_ioctl_querybuf,
	.vidioc_create_bufs = vb2_ioctl_create_bufs,
	.vidioc_qbuf = vb2_ioctl_qbuf,
	.vidioc_expbuf = vb2_ioctl_expbuf,
	.vidioc_dqbuf = vb2_ioctl_dqbuf,
	.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
	.vidioc_streamon = vb2_ioctl_streamon,
	.vidioc_streamoff = vb2_ioctl_streamoff,
	.vidioc_try_fmt_vid_cap_mplane = mali_c55_try_fmt_vid_cap_mplane,
	.vidioc_s_fmt_vid_cap_mplane = mali_c55_s_fmt_vid_cap_mplane,
	.vidioc_g_fmt_vid_cap_mplane = mali_c55_g_fmt_vid_cap_mplane,
	.vidioc_enum_fmt_vid_cap = mali_c55_enum_fmt_vid_cap_mplane,
	.vidioc_querycap = mali_c55_querycap,
	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
};

static int mali_c55_register_cap_dev(struct mali_c55 *mali_c55,
				     enum mali_c55_cap_devs cap_dev_id)
{
	struct mali_c55_cap_dev *cap_dev = &mali_c55->cap_devs[cap_dev_id];
	struct v4l2_pix_format_mplane pix_mp;
	struct video_device *vdev;
	struct vb2_queue *vb2q;
	int ret;

	vdev = &cap_dev->vdev;
	vb2q = &cap_dev->queue;

	cap_dev->mali_c55 = mali_c55;
	mutex_init(&cap_dev->lock);
	INIT_LIST_HEAD(&cap_dev->buffers.input);
	INIT_LIST_HEAD(&cap_dev->buffers.processing);
	spin_lock_init(&cap_dev->buffers.lock);
	spin_lock_init(&cap_dev->buffers.processing_lock);

	switch (cap_dev_id) {
	case MALI_C55_CAP_DEV_FR:
		cap_dev->rsz = &mali_c55->resizers[MALI_C55_RSZ_FR];
		cap_dev->reg_offset = MALI_C55_CAP_DEV_FR_REG_OFFSET;
		break;
	case MALI_C55_CAP_DEV_DS:
		cap_dev->rsz = &mali_c55->resizers[MALI_C55_RSZ_DS];
		cap_dev->reg_offset = MALI_C55_CAP_DEV_DS_REG_OFFSET;
		break;
	default:
		ret = -EINVAL;
		goto err_destroy_mutex;
	}

	cap_dev->pad.flags = MEDIA_PAD_FL_SINK;
	ret = media_entity_pads_init(&cap_dev->vdev.entity, 1, &cap_dev->pad);
	if (ret) {
		mutex_destroy(&cap_dev->lock);
		goto err_destroy_mutex;
	}

	vb2q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
	vb2q->io_modes = VB2_MMAP | VB2_DMABUF;
	vb2q->drv_priv = cap_dev;
	vb2q->mem_ops = &vb2_dma_contig_memops;
	vb2q->ops = &mali_c55_vb2_ops;
	vb2q->buf_struct_size = sizeof(struct mali_c55_buffer);
	vb2q->min_queued_buffers = 1;
	vb2q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
	vb2q->lock = &cap_dev->lock;
	vb2q->dev = mali_c55->dev;

	ret = vb2_queue_init(vb2q);
	if (ret) {

Annotation

Implementation Notes