drivers/media/usb/uvc/uvc_metadata.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/uvc/uvc_metadata.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/uvc/uvc_metadata.c- Extension
.c- Size
- 7290 bytes
- Lines
- 267
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/list.hlinux/module.hlinux/usb.hlinux/usb/uvc.hlinux/videodev2.hmedia/v4l2-ioctl.hmedia/videobuf2-v4l2.hmedia/videobuf2-vmalloc.huvcvideo.h
Detected Declarations
function Copyrightfunction uvc_meta_v4l2_get_formatfunction uvc_meta_v4l2_try_formatfunction uvc_meta_v4l2_set_formatfunction uvc_meta_v4l2_enum_formatsfunction list_for_each_entryfunction uvc_meta_detect_msxufunction uvc_meta_registerfunction uvc_meta_init
Annotated Snippet
if (dev->meta_formats[i] == fmt->dataformat) {
fmeta = fmt->dataformat;
break;
}
}
buffersize = max(UVC_METADATA_BUF_MIN_SIZE, fmt->buffersize);
memset(fmt, 0, sizeof(*fmt));
fmt->dataformat = fmeta;
fmt->buffersize = buffersize;
return 0;
}
static int uvc_meta_v4l2_set_format(struct file *file, void *priv,
struct v4l2_format *format)
{
struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct v4l2_meta_format *fmt = &format->fmt.meta;
int ret;
ret = uvc_meta_v4l2_try_format(file, priv, format);
if (ret < 0)
return ret;
/*
* We could in principle switch at any time, also during streaming.
* Metadata buffers would still be perfectly parseable, but it's more
* consistent and cleaner to disallow that.
*/
if (vb2_is_busy(&stream->meta.queue.queue))
return -EBUSY;
stream->meta.format = fmt->dataformat;
stream->meta.buffersize = fmt->buffersize;
return 0;
}
static int uvc_meta_v4l2_enum_formats(struct file *file, void *priv,
struct v4l2_fmtdesc *fdesc)
{
struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct uvc_device *dev = stream->dev;
if (fdesc->type != vfh->vdev->queue->type)
return -EINVAL;
if (fdesc->index >= dev->nmeta_formats)
return -EINVAL;
fdesc->pixelformat = dev->meta_formats[fdesc->index];
return 0;
}
static const struct v4l2_ioctl_ops uvc_meta_ioctl_ops = {
.vidioc_querycap = uvc_meta_v4l2_querycap,
.vidioc_g_fmt_meta_cap = uvc_meta_v4l2_get_format,
.vidioc_s_fmt_meta_cap = uvc_meta_v4l2_set_format,
.vidioc_try_fmt_meta_cap = uvc_meta_v4l2_try_format,
.vidioc_enum_fmt_meta_cap = uvc_meta_v4l2_enum_formats,
.vidioc_reqbufs = vb2_ioctl_reqbufs,
.vidioc_querybuf = vb2_ioctl_querybuf,
.vidioc_qbuf = vb2_ioctl_qbuf,
.vidioc_dqbuf = vb2_ioctl_dqbuf,
.vidioc_create_bufs = vb2_ioctl_create_bufs,
.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
.vidioc_streamon = vb2_ioctl_streamon,
.vidioc_streamoff = vb2_ioctl_streamoff,
};
/* -----------------------------------------------------------------------------
* V4L2 File Operations
*/
static const struct v4l2_file_operations uvc_meta_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = video_ioctl2,
.open = v4l2_fh_open,
.release = vb2_fop_release,
.poll = vb2_fop_poll,
.mmap = vb2_fop_mmap,
};
static struct uvc_entity *uvc_meta_find_msxu(struct uvc_device *dev)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/list.h`, `linux/module.h`, `linux/usb.h`, `linux/usb/uvc.h`, `linux/videodev2.h`, `media/v4l2-ioctl.h`, `media/videobuf2-v4l2.h`.
- Detected declarations: `function Copyright`, `function uvc_meta_v4l2_get_format`, `function uvc_meta_v4l2_try_format`, `function uvc_meta_v4l2_set_format`, `function uvc_meta_v4l2_enum_formats`, `function list_for_each_entry`, `function uvc_meta_detect_msxu`, `function uvc_meta_register`, `function uvc_meta_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.