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

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

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/arm/mali-c55/mali-c55-resizer.c
Extension
.c
Size
37952 bytes
Lines
1158
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 (++active_routes > 1) {
			dev_dbg(rsz->mali_c55->dev,
				"Only one route can be active");
			return -EINVAL;
		}

		active_sink = route->sink_pad;
	}
	if (active_sink == UINT_MAX) {
		dev_dbg(rsz->mali_c55->dev, "One route has to be active");
		return -EINVAL;
	}

	ret = v4l2_subdev_set_routing(sd, state, routing);
	if (ret) {
		dev_dbg(rsz->mali_c55->dev, "Failed to set routing\n");
		return ret;
	}

	fmt = v4l2_subdev_state_get_format(state, active_sink, 0);
	fmt->width = MALI_C55_DEFAULT_WIDTH;
	fmt->height = MALI_C55_DEFAULT_HEIGHT;
	fmt->colorspace = V4L2_COLORSPACE_SRGB;
	fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace);
	fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace);
	fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(false,
							  fmt->colorspace,
							  fmt->ycbcr_enc);
	fmt->field = V4L2_FIELD_NONE;

	if (active_sink == MALI_C55_RSZ_SINK_PAD) {
		struct v4l2_rect *crop, *compose;

		fmt->code = MEDIA_BUS_FMT_RGB121212_1X36;

		crop = v4l2_subdev_state_get_crop(state, active_sink, 0);
		compose = v4l2_subdev_state_get_compose(state, active_sink, 0);

		crop->left = 0;
		crop->top = 0;
		crop->width = MALI_C55_DEFAULT_WIDTH;
		crop->height = MALI_C55_DEFAULT_HEIGHT;

		*compose = *crop;
	} else {
		fmt->code = MEDIA_BUS_FMT_SRGGB20_1X20;
	}

	/* Propagate the format to the source pad */
	src_fmt = v4l2_subdev_state_get_format(state, MALI_C55_RSZ_SOURCE_PAD,
					       0);
	*src_fmt = *fmt;

	/* In the event this is the bypass pad the mbus code needs correcting */
	if (active_sink == MALI_C55_RSZ_SINK_BYPASS_PAD)
		src_fmt->code = mali_c55_rsz_shift_mbus_code(src_fmt->code);

	return 0;
}

static int mali_c55_rsz_enum_mbus_code(struct v4l2_subdev *sd,
				       struct v4l2_subdev_state *state,
				       struct v4l2_subdev_mbus_code_enum *code)
{
	const struct mali_c55_isp_format_info *fmt;
	struct v4l2_mbus_framefmt *sink_fmt;
	u32 sink_pad;

	switch (code->pad) {
	case MALI_C55_RSZ_SINK_PAD:
		if (code->index)
			return -EINVAL;

		code->code = MEDIA_BUS_FMT_RGB121212_1X36;

		return 0;
	case MALI_C55_RSZ_SOURCE_PAD:
		sink_pad = mali_c55_rsz_get_active_sink(state);
		sink_fmt = v4l2_subdev_state_get_format(state, sink_pad, 0);

		/*
		 * If the active route is from the Bypass sink pad, then the
		 * source pad is a simple passthrough of the sink format,
		 * downshifted to 16-bits.
		 */

		if (sink_pad == MALI_C55_RSZ_SINK_BYPASS_PAD) {
			if (code->index)
				return -EINVAL;

Annotation

Implementation Notes