drivers/media/usb/hdpvr/hdpvr-control.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/hdpvr/hdpvr-control.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/hdpvr/hdpvr-control.c- Extension
.c- Size
- 4500 bytes
- Lines
- 178
- 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/kernel.hlinux/errno.hlinux/init.hlinux/slab.hlinux/module.hlinux/usb.hlinux/mutex.hlinux/videodev2.hmedia/v4l2-common.hhdpvr.h
Detected Declarations
function Copyrightfunction get_video_infofunction get_input_lines_infofunction hdpvr_set_bitratefunction hdpvr_set_audiofunction hdpvr_set_options
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Hauppauge HD PVR USB driver - video 4 linux 2 interface
*
* Copyright (C) 2008 Janne Grunau (j@jannau.net)
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/mutex.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include "hdpvr.h"
int hdpvr_config_call(struct hdpvr_device *dev, uint value, u8 valbuf)
{
int ret;
char request_type = 0x38, snd_request = 0x01;
mutex_lock(&dev->usbc_mutex);
dev->usbc_buf[0] = valbuf;
ret = usb_control_msg(dev->udev,
usb_sndctrlpipe(dev->udev, 0),
snd_request, 0x00 | request_type,
value, CTRL_DEFAULT_INDEX,
dev->usbc_buf, 1, 10000);
mutex_unlock(&dev->usbc_mutex);
v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
"config call request for value 0x%x returned %d\n", value,
ret);
return ret < 0 ? ret : 0;
}
int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf)
{
int ret;
vidinf->valid = false;
mutex_lock(&dev->usbc_mutex);
ret = usb_control_msg(dev->udev,
usb_rcvctrlpipe(dev->udev, 0),
0x81, 0x80 | 0x38,
0x1400, 0x0003,
dev->usbc_buf, 5,
1000);
#ifdef HDPVR_DEBUG
if (hdpvr_debug & MSG_INFO)
v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
"get video info returned: %d, %5ph\n", ret,
dev->usbc_buf);
#endif
mutex_unlock(&dev->usbc_mutex);
if (ret < 0)
return ret;
vidinf->width = dev->usbc_buf[1] << 8 | dev->usbc_buf[0];
vidinf->height = dev->usbc_buf[3] << 8 | dev->usbc_buf[2];
vidinf->fps = dev->usbc_buf[4];
vidinf->valid = vidinf->width && vidinf->height && vidinf->fps;
return 0;
}
int get_input_lines_info(struct hdpvr_device *dev)
{
int ret, lines;
mutex_lock(&dev->usbc_mutex);
ret = usb_control_msg(dev->udev,
usb_rcvctrlpipe(dev->udev, 0),
0x81, 0x80 | 0x38,
0x1800, 0x0003,
dev->usbc_buf, 3,
1000);
#ifdef HDPVR_DEBUG
if (hdpvr_debug & MSG_INFO)
v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/usb.h`, `linux/mutex.h`, `linux/videodev2.h`.
- Detected declarations: `function Copyright`, `function get_video_info`, `function get_input_lines_info`, `function hdpvr_set_bitrate`, `function hdpvr_set_audio`, `function hdpvr_set_options`.
- 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.