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

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

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/renesas/vsp1/vsp1_entity.c
Extension
.c
Size
19081 bytes
Lines
678
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

scoped_guard(mutex, &entity->lock) {
			format = v4l2_subdev_state_get_format(state, 0);
			code->code = format->code;
		}
	}

	return 0;
}

/*
 * vsp1_subdev_enum_frame_size - Subdev pad enum_frame_size handler
 * @subdev: V4L2 subdevice
 * @sd_state: V4L2 subdev state
 * @fse: Frame size enumeration
 *
 * This function implements the subdev enum_frame_size pad operation for
 * entities that do not support scaling or cropping. It reports the given
 * minimum and maximum frame width and height on the sink pad, and a fixed
 * source pad size identical to the sink pad.
 */
int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
				struct v4l2_subdev_state *sd_state,
				struct v4l2_subdev_frame_size_enum *fse)
{
	struct vsp1_entity *entity = to_vsp1_entity(subdev);

	if (fse->index)
		return -EINVAL;

	if (fse->pad == 0) {
		unsigned int i;

		for (i = 0; i < entity->num_codes; ++i) {
			if (fse->code == entity->codes[i])
				break;
		}

		if (i == entity->num_codes)
			return -EINVAL;

		fse->min_width = entity->min_width;
		fse->max_width = entity->max_width;
		fse->min_height = entity->min_height;
		fse->max_height = entity->max_height;
	} else {
		struct v4l2_subdev_state *state;
		struct v4l2_mbus_framefmt *format;

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

		/*
		 * The media bus code and size on the source pad are fixed and
		 * always identical to the sink pad.
		 */
		format = v4l2_subdev_state_get_format(state, 0);

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

		if (fse->code != format->code)
			return -EINVAL;

		fse->min_width = format->width;
		fse->max_width = format->width;
		fse->min_height = format->height;
		fse->max_height = format->height;
	}

	return 0;
}

/*
 * vsp1_subdev_set_pad_format - Subdev pad set_fmt handler
 * @subdev: V4L2 subdevice
 * @sd_state: V4L2 subdev state
 * @fmt: V4L2 subdev format
 *
 * This function implements the subdev set_fmt pad operation for entities that
 * do not support scaling or cropping. It defaults to the first supported media
 * bus code if the requested code isn't supported, clamps the size to the
 * entity's limits, and propagates the sink pad format to the source pad.
 */
int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
			       struct v4l2_subdev_state *sd_state,
			       struct v4l2_subdev_format *fmt)
{
	struct vsp1_entity *entity = to_vsp1_entity(subdev);
	struct v4l2_subdev_state *state;
	struct v4l2_mbus_framefmt *format;

Annotation

Implementation Notes