drivers/media/usb/pwc/pwc-v4l.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/pwc/pwc-v4l.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/pwc/pwc-v4l.c- Extension
.c- Size
- 28846 bytes
- Lines
- 1034
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/errno.hlinux/init.hlinux/mm.hlinux/module.hlinux/poll.hlinux/vmalloc.hlinux/jiffies.hasm/io.hpwc.h
Detected Declarations
function pwc_init_controlsfunction pwc_vidioc_fill_fmtfunction pwc_vidioc_try_fmtfunction pwc_s_fmt_vid_capfunction pwc_querycapfunction pwc_enum_inputfunction pwc_g_inputfunction pwc_s_inputfunction pwc_g_volatile_ctrlfunction pwc_set_awbfunction pwc_set_autogainfunction pwc_set_exposure_autofunction pwc_set_autogain_expofunction pwc_set_motorfunction pwc_s_ctrlfunction PWC_CID_CUSTOMfunction pwc_enum_fmt_vid_capfunction pwc_g_fmt_vid_capfunction pwc_try_fmt_vid_capfunction pwc_enum_framesizesfunction pwc_enum_frameintervalsfunction pwc_g_parmfunction pwc_s_parm
Annotated Snippet
if (DEVICE_USE_CODEC23(pdev->type)) {
PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n");
f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
}
break;
case V4L2_PIX_FMT_PWC2:
if (DEVICE_USE_CODEC1(pdev->type)) {
PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n");
f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
}
break;
default:
PWC_DEBUG_IOCTL("Unsupported pixel format\n");
f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
}
size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height);
pwc_vidioc_fill_fmt(f,
pwc_image_sizes[size][0],
pwc_image_sizes[size][1],
f->fmt.pix.pixelformat);
return 0;
}
/* ioctl(VIDIOC_SET_FMT) */
static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
{
struct pwc_device *pdev = video_drvdata(file);
int ret, pixelformat, compression = 0;
ret = pwc_vidioc_try_fmt(pdev, f);
if (ret < 0)
return ret;
if (vb2_is_busy(&pdev->vb_queue))
return -EBUSY;
pixelformat = f->fmt.pix.pixelformat;
PWC_DEBUG_IOCTL("Trying to set format to: width=%d height=%d fps=%d format=%c%c%c%c\n",
f->fmt.pix.width, f->fmt.pix.height, pdev->vframes,
(pixelformat)&255,
(pixelformat>>8)&255,
(pixelformat>>16)&255,
(pixelformat>>24)&255);
ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height,
pixelformat, 30, &compression, 0);
PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret);
pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt);
return ret;
}
static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
{
struct pwc_device *pdev = video_drvdata(file);
strscpy(cap->driver, PWC_NAME, sizeof(cap->driver));
strscpy(cap->card, pdev->vdev.name, sizeof(cap->card));
usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info));
return 0;
}
static int pwc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{
if (i->index) /* Only one INPUT is supported */
return -EINVAL;
strscpy(i->name, "Camera", sizeof(i->name));
i->type = V4L2_INPUT_TYPE_CAMERA;
return 0;
}
static int pwc_g_input(struct file *file, void *fh, unsigned int *i)
{
*i = 0;
return 0;
}
static int pwc_s_input(struct file *file, void *fh, unsigned int i)
{
return i ? -EINVAL : 0;
}
static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{
Annotation
- Immediate include surface: `linux/errno.h`, `linux/init.h`, `linux/mm.h`, `linux/module.h`, `linux/poll.h`, `linux/vmalloc.h`, `linux/jiffies.h`, `asm/io.h`.
- Detected declarations: `function pwc_init_controls`, `function pwc_vidioc_fill_fmt`, `function pwc_vidioc_try_fmt`, `function pwc_s_fmt_vid_cap`, `function pwc_querycap`, `function pwc_enum_input`, `function pwc_g_input`, `function pwc_s_input`, `function pwc_g_volatile_ctrl`, `function pwc_set_awb`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.