drivers/media/usb/stk1160/stk1160-core.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/stk1160/stk1160-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/stk1160/stk1160-core.c- Extension
.c- Size
- 10204 bytes
- Lines
- 431
- 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.
- 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/module.hlinux/init.hlinux/kernel.hlinux/errno.hlinux/slab.hlinux/usb.hlinux/mm.hlinux/vmalloc.hmedia/i2c/saa7115.hstk1160.hstk1160-reg.h
Detected Declarations
function stk1160_read_regfunction stk1160_write_regfunction stk1160_select_inputfunction stk1160_reg_resetfunction stk1160_releasefunction stk1160_scan_usbfunction stk1160_probefunction stk1160_disconnect
Annotated Snippet
if (usb_endpoint_is_isoc_in(desc)) {
switch (desc->bEndpointAddress) {
case STK1160_EP_AUDIO:
has_audio = true;
break;
case STK1160_EP_VIDEO:
has_video = true;
max_pkt_size[i] = size;
break;
}
}
}
}
/* Is this even possible? */
if (!(has_audio || has_video)) {
dev_err(&udev->dev, "no audio or video endpoints found\n");
return -ENODEV;
}
switch (udev->speed) {
case USB_SPEED_LOW:
speed = "1.5";
break;
case USB_SPEED_FULL:
speed = "12";
break;
case USB_SPEED_HIGH:
speed = "480";
break;
default:
speed = "unknown";
}
dev_info(&udev->dev, "New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
udev->manufacturer ? udev->manufacturer : "",
udev->product ? udev->product : "",
speed,
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ifnum,
intf->altsetting->desc.bInterfaceNumber);
/* This should never happen, since we rejected audio interfaces */
if (has_audio)
dev_warn(&udev->dev, "audio interface %d found.\n\
This is not implemented by this driver,\
you should use snd-usb-audio instead\n", ifnum);
if (has_video)
dev_info(&udev->dev, "video interface %d found\n",
ifnum);
/*
* Make sure we have 480 Mbps of bandwidth, otherwise things like
* video stream wouldn't likely work, since 12 Mbps is generally
* not enough even for most streams.
*/
if (udev->speed != USB_SPEED_HIGH)
dev_warn(&udev->dev, "must be connected to a high-speed USB 2.0 port\n\
You may not be able to stream video smoothly\n");
return 0;
}
static int stk1160_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
int rc = 0;
unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
struct usb_device *udev;
struct stk1160 *dev;
udev = interface_to_usbdev(interface);
/*
* Since usb audio class is supported by snd-usb-audio,
* we reject audio interface.
*/
if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO)
return -ENODEV;
/* Alloc an array for all possible max_pkt_size */
alt_max_pkt_size = kmalloc_array(interface->num_altsetting,
sizeof(alt_max_pkt_size[0]),
GFP_KERNEL);
if (alt_max_pkt_size == NULL)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/kernel.h`, `linux/errno.h`, `linux/slab.h`, `linux/usb.h`, `linux/mm.h`, `linux/vmalloc.h`.
- Detected declarations: `function stk1160_read_reg`, `function stk1160_write_reg`, `function stk1160_select_input`, `function stk1160_reg_reset`, `function stk1160_release`, `function stk1160_scan_usb`, `function stk1160_probe`, `function stk1160_disconnect`.
- 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.