drivers/media/platform/microchip/microchip-isc-base.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/microchip/microchip-isc-base.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/microchip/microchip-isc-base.c
Extension
.c
Size
55208 bytes
Lines
1971
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

vb2_start_streaming_called(vb->vb2_queue)) {
		isc->cur_frm = buf;
		isc_start_dma(isc);
	} else {
		list_add_tail(&buf->list, &isc->dma_queue);
	}
	spin_unlock_irqrestore(&isc->dma_queue_lock, flags);
}

static const struct vb2_ops isc_vb2_ops = {
	.queue_setup		= isc_queue_setup,
	.buf_prepare		= isc_buffer_prepare,
	.start_streaming	= isc_start_streaming,
	.stop_streaming		= isc_stop_streaming,
	.buf_queue		= isc_buffer_queue,
	.prepare_streaming	= isc_prepare_streaming,
	.unprepare_streaming	= isc_unprepare_streaming,
};

static int isc_querycap(struct file *file, void *priv,
			struct v4l2_capability *cap)
{
	strscpy(cap->driver, "microchip-isc", sizeof(cap->driver));
	strscpy(cap->card, "Microchip Image Sensor Controller", sizeof(cap->card));

	return 0;
}

static int isc_enum_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_fmtdesc *f)
{
	struct isc_device *isc = video_drvdata(file);
	u32 index = f->index;
	u32 i, supported_index = 0;
	struct isc_format *fmt;

	/*
	 * If we are not asked a specific mbus_code, we have to report all
	 * the formats that we can output.
	 */
	if (!f->mbus_code) {
		if (index >= isc->controller_formats_size)
			return -EINVAL;

		f->pixelformat = isc->controller_formats[index].fourcc;

		return 0;
	}

	/*
	 * If a specific mbus_code is requested, check if we support
	 * this mbus_code as input for the ISC.
	 * If it's supported, then we report the corresponding pixelformat
	 * as first possible option for the ISC.
	 * E.g. mbus MEDIA_BUS_FMT_YUYV8_2X8 and report
	 * 'YUYV' (YUYV 4:2:2)
	 */
	fmt = isc_find_format_by_code(isc, f->mbus_code, &i);
	if (!fmt)
		return -EINVAL;

	if (!index) {
		f->pixelformat = fmt->fourcc;

		return 0;
	}

	supported_index++;

	/* If the index is not raw, we don't have anymore formats to report */
	if (!ISC_IS_FORMAT_RAW(f->mbus_code))
		return -EINVAL;

	/*
	 * We are asked for a specific mbus code, which is raw.
	 * We have to search through the formats we can convert to.
	 * We have to skip the raw formats, we cannot convert to raw.
	 * E.g. 'AR12' (16-bit ARGB 4-4-4-4), 'AR15' (16-bit ARGB 1-5-5-5), etc.
	 */
	for (i = 0; i < isc->controller_formats_size; i++) {
		if (isc->controller_formats[i].raw)
			continue;
		if (index == supported_index) {
			f->pixelformat = isc->controller_formats[i].fourcc;
			return 0;
		}
		supported_index++;
	}

	return -EINVAL;

Annotation

Implementation Notes