drivers/media/platform/renesas/vsp1/vsp1_rwpf.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/renesas/vsp1/vsp1_rwpf.c
Extension
.c
Size
10945 bytes
Lines
383
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 (csc && (flags & V4L2_MBUS_FRAMEFMT_SET_CSC)) {
			format->ycbcr_enc = fmt->format.ycbcr_enc;
			format->quantization = fmt->format.quantization;
		} else {
			format->ycbcr_enc = sink_format->ycbcr_enc;
			format->quantization = sink_format->quantization;
		}

		vsp1_entity_adjust_color_space(format);

		fmt->format = *format;
		fmt->format.flags = flags;

		return 0;
	}

	format->code = fmt->format.code;
	format->width = clamp_t(unsigned int, fmt->format.width,
				RWPF_MIN_WIDTH, rwpf->entity.max_width);
	format->height = clamp_t(unsigned int, fmt->format.height,
				 RWPF_MIN_HEIGHT, rwpf->entity.max_height);
	format->field = V4L2_FIELD_NONE;

	format->colorspace = fmt->format.colorspace;
	format->xfer_func = fmt->format.xfer_func;
	format->ycbcr_enc = fmt->format.ycbcr_enc;
	format->quantization = fmt->format.quantization;

	vsp1_entity_adjust_color_space(format);

	fmt->format = *format;

	if (rwpf->entity.type == VSP1_ENTITY_RPF) {
		struct v4l2_rect *crop;

		/* Update the sink crop rectangle. */
		crop = v4l2_subdev_state_get_crop(state, RWPF_PAD_SINK);
		crop->left = 0;
		crop->top = 0;
		crop->width = fmt->format.width;
		crop->height = fmt->format.height;
	}

	/* Propagate the format to the source pad. */
	format = v4l2_subdev_state_get_format(state, RWPF_PAD_SOURCE);
	*format = fmt->format;

	if (rwpf->flip.rotate) {
		format->width = fmt->format.height;
		format->height = fmt->format.width;
	}

	return 0;
}

static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
				   struct v4l2_subdev_state *sd_state,
				   struct v4l2_subdev_selection *sel)
{
	struct vsp1_rwpf *rwpf = to_rwpf(subdev);
	struct v4l2_subdev_state *state;
	struct v4l2_mbus_framefmt *format;

	/*
	 * Cropping is only supported on the RPF and is implemented on the sink
	 * pad.
	 */
	if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK)
		return -EINVAL;

	guard(mutex)(&rwpf->entity.lock);

	state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which);
	if (!state)
		return -EINVAL;

	switch (sel->target) {
	case V4L2_SEL_TGT_CROP:
		sel->r = *v4l2_subdev_state_get_crop(state, RWPF_PAD_SINK);
		break;

	case V4L2_SEL_TGT_CROP_BOUNDS:
		format = v4l2_subdev_state_get_format(state, RWPF_PAD_SINK);
		sel->r.left = 0;
		sel->r.top = 0;
		sel->r.width = format->width;
		sel->r.height = format->height;
		break;

	default:

Annotation

Implementation Notes