drivers/media/platform/rockchip/rkcif/rkcif-interface.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/rockchip/rkcif/rkcif-interface.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/rockchip/rkcif/rkcif-interface.c
Extension
.c
Size
11537 bytes
Lines
444
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

for_each_active_route(&state->routing, route) {
			stream = &interface->streams[route->sink_stream];
			rkcif_interface_apply_crop(stream, state);
		}
	}

	mask = v4l2_subdev_state_xlate_streams(state, RKCIF_IF_PAD_SINK,
					       RKCIF_IF_PAD_SRC, &streams_mask);

	return v4l2_subdev_enable_streams(remote_sd, remote_pad->index, mask);
}

static int rkcif_interface_disable_streams(struct v4l2_subdev *sd,
					   struct v4l2_subdev_state *state,
					   u32 pad, u64 streams_mask)
{
	struct v4l2_subdev *remote_sd;
	struct media_pad *remote_pad;
	u64 mask;

	remote_pad =
		media_pad_remote_pad_first(&sd->entity.pads[RKCIF_IF_PAD_SINK]);
	remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);

	mask = v4l2_subdev_state_xlate_streams(state, RKCIF_IF_PAD_SINK,
					       RKCIF_IF_PAD_SRC, &streams_mask);

	return v4l2_subdev_disable_streams(remote_sd, remote_pad->index, mask);
}

static const struct v4l2_subdev_pad_ops rkcif_interface_pad_ops = {
	.get_fmt = v4l2_subdev_get_fmt,
	.set_fmt = rkcif_interface_set_fmt,
	.get_selection = rkcif_interface_get_sel,
	.set_selection = rkcif_interface_set_sel,
	.set_routing = rkcif_interface_set_routing,
	.enable_streams = rkcif_interface_enable_streams,
	.disable_streams = rkcif_interface_disable_streams,
};

static const struct v4l2_subdev_ops rkcif_interface_ops = {
	.pad = &rkcif_interface_pad_ops,
};

static int rkcif_interface_init_state(struct v4l2_subdev *sd,
				      struct v4l2_subdev_state *state)
{
	struct rkcif_interface *interface = to_rkcif_interface(sd);
	struct v4l2_subdev_route routes[] = {
		{
			.sink_pad = RKCIF_IF_PAD_SINK,
			.sink_stream = 0,
			.source_pad = RKCIF_IF_PAD_SRC,
			.source_stream = 0,
			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
		},
	};
	struct v4l2_subdev_krouting routing = {
		.len_routes = ARRAY_SIZE(routes),
		.num_routes = ARRAY_SIZE(routes),
		.routes = routes,
	};
	const struct v4l2_mbus_framefmt dvp_default_format = {
		.width = 3840,
		.height = 2160,
		.code = MEDIA_BUS_FMT_YUYV8_1X16,
		.field = V4L2_FIELD_NONE,
		.colorspace = V4L2_COLORSPACE_REC709,
		.ycbcr_enc = V4L2_YCBCR_ENC_709,
		.quantization = V4L2_QUANTIZATION_LIM_RANGE,
		.xfer_func = V4L2_XFER_FUNC_NONE,
	};
	const struct v4l2_mbus_framefmt mipi_default_format = {
		.width = 3840,
		.height = 2160,
		.code = MEDIA_BUS_FMT_SRGGB10_1X10,
		.field = V4L2_FIELD_NONE,
		.colorspace = V4L2_COLORSPACE_RAW,
		.ycbcr_enc = V4L2_YCBCR_ENC_601,
		.quantization = V4L2_QUANTIZATION_FULL_RANGE,
		.xfer_func = V4L2_XFER_FUNC_NONE,
	};
	const struct v4l2_mbus_framefmt *default_format;
	int ret;

	default_format = (interface->type == RKCIF_IF_DVP) ?
				 &dvp_default_format :
				 &mipi_default_format;

	ret = v4l2_subdev_set_routing_with_fmt(sd, state, &routing,

Annotation

Implementation Notes