drivers/media/usb/dvb-usb/vp7045.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb/vp7045.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/dvb-usb/vp7045.c- Extension
.c- Size
- 6196 bytes
- Lines
- 257
- 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
vp7045.h
Detected Declarations
function vp7045_usb_opfunction vp7045_read_regfunction vp7045_power_ctrlfunction vp7045_rc_queryfunction vp7045_read_eepromfunction vp7045_read_mac_addrfunction vp7045_frontend_attachfunction vp7045_usb_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* DVB USB compliant Linux driver for the
* - TwinhanDTV Alpha/MagicBoxII USB2.0 DVB-T receiver
* - DigitalNow TinyUSB2 DVB-t receiver
*
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
*
* Thanks to Twinhan who kindly provided hardware and information.
*
* see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
*/
#include "vp7045.h"
/* debug */
static int dvb_usb_vp7045_debug;
module_param_named(debug,dvb_usb_vp7045_debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
#define deb_info(args...) dprintk(dvb_usb_vp7045_debug,0x01,args)
#define deb_xfer(args...) dprintk(dvb_usb_vp7045_debug,0x02,args)
#define deb_rc(args...) dprintk(dvb_usb_vp7045_debug,0x04,args)
int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec)
{
int ret = 0;
u8 *buf = d->priv;
buf[0] = cmd;
if (outlen > 19)
outlen = 19;
if (inlen > 11)
inlen = 11;
ret = mutex_lock_interruptible(&d->usb_mutex);
if (ret)
return ret;
if (out != NULL && outlen > 0)
memcpy(&buf[1], out, outlen);
deb_xfer("out buffer: ");
debug_dump(buf, outlen+1, deb_xfer);
if (usb_control_msg(d->udev,
usb_sndctrlpipe(d->udev,0),
TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0,
buf, 20, 2000) != 20) {
err("USB control message 'out' went wrong.");
ret = -EIO;
goto unlock;
}
msleep(msec);
if (usb_control_msg(d->udev,
usb_rcvctrlpipe(d->udev,0),
TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
buf, 12, 2000) != 12) {
err("USB control message 'in' went wrong.");
ret = -EIO;
goto unlock;
}
deb_xfer("in buffer: ");
debug_dump(buf, 12, deb_xfer);
if (in != NULL && inlen > 0)
memcpy(in, &buf[1], inlen);
unlock:
mutex_unlock(&d->usb_mutex);
return ret;
}
u8 vp7045_read_reg(struct dvb_usb_device *d, u8 reg)
{
u8 obuf[2] = { 0 },v;
obuf[1] = reg;
vp7045_usb_op(d,TUNER_REG_READ,obuf,2,&v,1,30);
return v;
}
Annotation
- Immediate include surface: `vp7045.h`.
- Detected declarations: `function vp7045_usb_op`, `function vp7045_read_reg`, `function vp7045_power_ctrl`, `function vp7045_rc_query`, `function vp7045_read_eeprom`, `function vp7045_read_mac_addr`, `function vp7045_frontend_attach`, `function vp7045_usb_probe`.
- 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.