drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
Extension
.c
Size
17045 bytes
Lines
746
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 (matched == f->index) {
			f->pixelformat = rvin_formats[i].fourcc;
			return 0;
		}
	}

	return -EINVAL;
}

static int rvin_remote_rectangle(struct rvin_dev *vin, struct v4l2_rect *rect)
{
	struct media_pad *pad = media_pad_remote_pad_first(&vin->pad);
	struct v4l2_subdev_format fmt = {
		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
	};
	struct v4l2_subdev *sd;
	unsigned int index;
	int ret;

	if (!pad)
		return -EINVAL;

	sd = media_entity_to_v4l2_subdev(pad->entity);
	index = pad->index;

	fmt.pad = index;
	ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
	if (ret)
		return ret;

	rect->left = rect->top = 0;
	rect->width = fmt.format.width;
	rect->height = fmt.format.height;

	if (fmt.format.field == V4L2_FIELD_ALTERNATE) {
		switch (vin->format.field) {
		case V4L2_FIELD_INTERLACED_TB:
		case V4L2_FIELD_INTERLACED_BT:
		case V4L2_FIELD_INTERLACED:
			rect->height *= 2;
			break;
		}
	}

	return 0;
}

static int rvin_g_selection(struct file *file, void *fh,
			    struct v4l2_selection *s)
{
	struct rvin_dev *vin = video_drvdata(file);
	int ret;

	if (!vin->scaler)
		return -ENOIOCTLCMD;

	if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;

	switch (s->target) {
	case V4L2_SEL_TGT_CROP_BOUNDS:
	case V4L2_SEL_TGT_CROP_DEFAULT:
		ret = rvin_remote_rectangle(vin, &s->r);
		if (ret)
			return ret;

		break;
	case V4L2_SEL_TGT_CROP:
		s->r = vin->crop;
		break;
	case V4L2_SEL_TGT_COMPOSE_BOUNDS:
	case V4L2_SEL_TGT_COMPOSE_DEFAULT:
		s->r.left = s->r.top = 0;
		s->r.width = vin->format.width;
		s->r.height = vin->format.height;
		break;
	case V4L2_SEL_TGT_COMPOSE:
		s->r = vin->compose;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

static int rvin_s_selection(struct file *file, void *fh,
			    struct v4l2_selection *s)
{
	struct rvin_dev *vin = video_drvdata(file);

Annotation

Implementation Notes