drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-subdev.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-subdev.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-subdev.c
Extension
.c
Size
10095 bytes
Lines
377
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

// SPDX-License-Identifier: GPL-2.0
/*
 * Renesas RZ/V2H(P) Input Video Control Block driver
 *
 * Copyright (C) 2025 Ideas on Board Oy
 */

#include "rzv2h-ivc.h"

#include <linux/media.h>
#include <linux/media-bus-format.h>
#include <linux/v4l2-mediabus.h>

#include <media/v4l2-async.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-event.h>

#define RZV2H_IVC_N_INPUTS_PER_OUTPUT		6

/*
 * We support 8/10/12/14/16/20 bit input in any bayer order, but the output
 * format is fixed at 20-bits with the same order as the input.
 */
static const struct {
	u32 inputs[RZV2H_IVC_N_INPUTS_PER_OUTPUT];
	u32 output;
} rzv2h_ivc_formats[] = {
	{
		.inputs = {
			MEDIA_BUS_FMT_SBGGR8_1X8,
			MEDIA_BUS_FMT_SBGGR10_1X10,
			MEDIA_BUS_FMT_SBGGR12_1X12,
			MEDIA_BUS_FMT_SBGGR14_1X14,
			MEDIA_BUS_FMT_SBGGR16_1X16,
			MEDIA_BUS_FMT_SBGGR20_1X20,
		},
		.output = MEDIA_BUS_FMT_SBGGR20_1X20
	},
	{
		.inputs = {
			MEDIA_BUS_FMT_SGBRG8_1X8,
			MEDIA_BUS_FMT_SGBRG10_1X10,
			MEDIA_BUS_FMT_SGBRG12_1X12,
			MEDIA_BUS_FMT_SGBRG14_1X14,
			MEDIA_BUS_FMT_SGBRG16_1X16,
			MEDIA_BUS_FMT_SGBRG20_1X20,
		},
		.output = MEDIA_BUS_FMT_SGBRG20_1X20
	},
	{
		.inputs = {
			MEDIA_BUS_FMT_SGRBG8_1X8,
			MEDIA_BUS_FMT_SGRBG10_1X10,
			MEDIA_BUS_FMT_SGRBG12_1X12,
			MEDIA_BUS_FMT_SGRBG14_1X14,
			MEDIA_BUS_FMT_SGRBG16_1X16,
			MEDIA_BUS_FMT_SGRBG20_1X20,
		},
		.output = MEDIA_BUS_FMT_SGRBG20_1X20
	},
	{
		.inputs = {
			MEDIA_BUS_FMT_SRGGB8_1X8,
			MEDIA_BUS_FMT_SRGGB10_1X10,
			MEDIA_BUS_FMT_SRGGB12_1X12,
			MEDIA_BUS_FMT_SRGGB14_1X14,
			MEDIA_BUS_FMT_SRGGB16_1X16,
			MEDIA_BUS_FMT_SRGGB20_1X20,
		},
		.output = MEDIA_BUS_FMT_SRGGB20_1X20
	},
};

static u32 rzv2h_ivc_get_mbus_output_from_input(u32 mbus_code)
{
	unsigned int i, j;

	for (i = 0; i < ARRAY_SIZE(rzv2h_ivc_formats); i++) {
		for (j = 0; j < RZV2H_IVC_N_INPUTS_PER_OUTPUT; j++) {
			if (rzv2h_ivc_formats[i].inputs[j] == mbus_code)
				return rzv2h_ivc_formats[i].output;
		}
	}

	return 0;
}

static int rzv2h_ivc_enum_mbus_code(struct v4l2_subdev *sd,
				    struct v4l2_subdev_state *state,

Annotation

Implementation Notes