drivers/media/usb/usbtv/usbtv-core.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/usbtv/usbtv-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/usbtv/usbtv-core.c- Extension
.c- Size
- 4749 bytes
- Lines
- 166
- 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
usbtv.h
Detected Declarations
function usbtv_set_regsfunction usbtv_probefunction usbtv_disconnect
Annotated Snippet
#include "usbtv.h"
int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
{
int ret;
int pipe = usb_sndctrlpipe(usbtv->udev, 0);
int i;
for (i = 0; i < size; i++) {
u16 index = regs[i][0];
u16 value = regs[i][1];
ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, NULL, 0, USB_CTRL_GET_TIMEOUT);
if (ret < 0)
return ret;
}
return 0;
}
static int usbtv_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
int ret;
int size;
struct device *dev = &intf->dev;
struct usbtv *usbtv;
struct usb_host_endpoint *ep;
/* Checks that the device is what we think it is. */
if (intf->num_altsetting != 2)
return -ENODEV;
if (intf->altsetting[1].desc.bNumEndpoints != 4)
return -ENODEV;
ep = &intf->altsetting[1].endpoint[0];
/* Packet size is split into 11 bits of base size and count of
* extra multiplies of it.*/
size = usb_endpoint_maxp(&ep->desc);
size = size * usb_endpoint_maxp_mult(&ep->desc);
/* Device structure */
usbtv = kzalloc_obj(struct usbtv);
if (usbtv == NULL)
return -ENOMEM;
usbtv->dev = dev;
usbtv->udev = interface_to_usbdev(intf);
usbtv->iso_size = size;
usb_set_intfdata(intf, usbtv);
ret = usbtv_video_init(usbtv);
if (ret < 0)
goto usbtv_video_fail;
ret = usbtv_audio_init(usbtv);
if (ret < 0)
goto usbtv_audio_fail;
/* for simplicity we exploit the v4l2_device reference counting */
v4l2_device_get(&usbtv->v4l2_dev);
dev_info(dev, "Fushicai USBTV007 Audio-Video Grabber\n");
return 0;
usbtv_audio_fail:
/* we must not free at this point */
v4l2_device_get(&usbtv->v4l2_dev);
/* this will undo the v4l2_device_get() */
usbtv_video_free(usbtv);
usbtv_video_fail:
usb_set_intfdata(intf, NULL);
kfree(usbtv);
return ret;
}
static void usbtv_disconnect(struct usb_interface *intf)
{
struct usbtv *usbtv = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
if (!usbtv)
return;
Annotation
- Immediate include surface: `usbtv.h`.
- Detected declarations: `function usbtv_set_regs`, `function usbtv_probe`, `function usbtv_disconnect`.
- 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.