drivers/staging/media/ipu3/ipu3-v4l2.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/ipu3/ipu3-v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/ipu3/ipu3-v4l2.c- Extension
.c- Size
- 39565 bytes
- Lines
- 1420
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/module.hlinux/pm_runtime.hlinux/string_choices.hmedia/v4l2-event.hmedia/v4l2-ioctl.hipu3.hipu3-dmamap.h
Detected Declarations
struct imgu_fmtstruct imgu_meta_fmtfunction imgu_subdev_openfunction imgu_subdev_s_streamfunction imgu_subdev_get_fmtfunction imgu_subdev_set_fmtfunction imgu_subdev_get_cropfunction imgu_subdev_get_composefunction imgu_subdev_get_selectionfunction imgu_subdev_set_selectionfunction imgu_link_setupfunction imgu_vb2_buf_initfunction imgu_vb2_buf_cleanupfunction imgu_vb2_buf_queuefunction imgu_vb2_queue_setupfunction imgu_all_nodes_streamingfunction for_each_set_bitfunction imgu_return_all_buffersfunction imgu_vb2_start_streamingfunction for_each_set_bitfunction imgu_vb2_stop_streamingfunction for_each_set_bitfunction imgu_vidioc_querycapfunction enum_fmtsfunction vidioc_enum_fmt_vid_capfunction vidioc_enum_fmt_vid_outfunction imgu_vidioc_g_fmtfunction selectionsfunction imgu_try_fmtfunction imgu_vidioc_try_fmtfunction imgu_vidioc_s_fmtfunction imgu_meta_enum_formatfunction imgu_vidioc_g_meta_fmtfunction imgu_sd_s_ctrlfunction imgu_node_to_v4l2function imgu_v4l2_subdev_registerfunction imgu_v4l2_node_setupfunction imgu_v4l2_nodes_cleanup_pipefunction imgu_v4l2_nodes_setup_pipefunction imgu_v4l2_subdev_cleanupfunction imgu_v4l2_cleanup_pipesfunction imgu_v4l2_register_pipesfunction imgu_v4l2_registerfunction imgu_v4l2_unregisterfunction imgu_v4l2_buffer_done
Annotated Snippet
struct imgu_fmt {
u32 fourcc;
u16 type; /* VID_CAPTURE or VID_OUTPUT not both */
};
/* format descriptions for capture and preview */
static const struct imgu_fmt formats[] = {
{ V4L2_PIX_FMT_NV12, VID_CAPTURE },
{ V4L2_PIX_FMT_IPU3_SGRBG10, VID_OUTPUT },
{ V4L2_PIX_FMT_IPU3_SBGGR10, VID_OUTPUT },
{ V4L2_PIX_FMT_IPU3_SGBRG10, VID_OUTPUT },
{ V4L2_PIX_FMT_IPU3_SRGGB10, VID_OUTPUT },
};
/* Find the first matched format, return default if not found */
static const struct imgu_fmt *find_format(struct v4l2_format *f, u32 type)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(formats); i++) {
if (formats[i].fourcc == f->fmt.pix_mp.pixelformat &&
formats[i].type == type)
return &formats[i];
}
return type == VID_CAPTURE ? &formats[DEF_VID_CAPTURE] :
&formats[DEF_VID_OUTPUT];
}
static int imgu_vidioc_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
struct imgu_device *imgu = video_drvdata(file);
strscpy(cap->driver, IMGU_NAME, sizeof(cap->driver));
strscpy(cap->card, IMGU_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
pci_name(imgu->pci_dev));
return 0;
}
static int enum_fmts(struct v4l2_fmtdesc *f, u32 type)
{
unsigned int i, j;
if (f->mbus_code != 0 && f->mbus_code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
for (i = j = 0; i < ARRAY_SIZE(formats); ++i) {
if (formats[i].type == type) {
if (j == f->index)
break;
++j;
}
}
if (i < ARRAY_SIZE(formats)) {
f->pixelformat = formats[i].fourcc;
return 0;
}
return -EINVAL;
}
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
return -EINVAL;
return enum_fmts(f, VID_CAPTURE);
}
static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return -EINVAL;
return enum_fmts(f, VID_OUTPUT);
}
/* Propagate forward always the format from the CIO2 subdev */
static int imgu_vidioc_g_fmt(struct file *file, void *fh,
struct v4l2_format *f)
{
struct imgu_video_device *node = file_to_intel_imgu_node(file);
f->fmt = node->vdev_fmt.fmt;
Annotation
- Immediate include surface: `linux/module.h`, `linux/pm_runtime.h`, `linux/string_choices.h`, `media/v4l2-event.h`, `media/v4l2-ioctl.h`, `ipu3.h`, `ipu3-dmamap.h`.
- Detected declarations: `struct imgu_fmt`, `struct imgu_meta_fmt`, `function imgu_subdev_open`, `function imgu_subdev_s_stream`, `function imgu_subdev_get_fmt`, `function imgu_subdev_set_fmt`, `function imgu_subdev_get_crop`, `function imgu_subdev_get_compose`, `function imgu_subdev_get_selection`, `function imgu_subdev_set_selection`.
- Atlas domain: Driver Families / drivers/staging.
- 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.