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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pm_runtime.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/v4l2-mc.hmedia/v4l2-rect.hrcar-vin.h
Detected Declarations
function rvin_format_bytesperlinefunction rvin_format_sizeimagefunction rvin_format_alignfunction rvin_querycapfunction rvin_g_fmt_vid_capfunction rvin_enum_fmt_vid_capfunction rvin_remote_rectanglefunction rvin_g_selectionfunction rvin_s_selectionfunction rvin_subscribe_eventfunction rvin_mc_try_formatfunction rvin_mc_try_fmt_vid_capfunction rvin_mc_s_fmt_vid_capfunction rvin_openfunction rvin_releasefunction rvin_v4l2_unregisterfunction rvin_notifyfunction rvin_v4l2_register
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
- Immediate include surface: `linux/pm_runtime.h`, `media/v4l2-event.h`, `media/v4l2-ioctl.h`, `media/v4l2-mc.h`, `media/v4l2-rect.h`, `rcar-vin.h`.
- Detected declarations: `function rvin_format_bytesperline`, `function rvin_format_sizeimage`, `function rvin_format_align`, `function rvin_querycap`, `function rvin_g_fmt_vid_cap`, `function rvin_enum_fmt_vid_cap`, `function rvin_remote_rectangle`, `function rvin_g_selection`, `function rvin_s_selection`, `function rvin_subscribe_event`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.