drivers/media/usb/cx231xx/cx231xx-core.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/cx231xx/cx231xx-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/cx231xx/cx231xx-core.c- Extension
.c- Size
- 45790 bytes
- Lines
- 1784
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
cx231xx.hlinux/init.hlinux/list.hlinux/module.hlinux/slab.hlinux/vmalloc.hmedia/v4l2-common.hmedia/tuner.hcx231xx-reg.h
Detected Declarations
function cx231xx_realease_resourcesfunction cx231xx_add_into_devlistfunction cx231xx_register_extensionfunction cx231xx_unregister_extensionfunction cx231xx_init_extensionfunction cx231xx_close_extensionfunction cx231xx_send_usb_commandfunction operationsfunction cx231xx_read_ctrl_regfunction cx231xx_send_vendor_cmdfunction cx231xx_write_ctrl_regfunction cx231xx_set_video_alternatefunction cx231xx_set_alt_settingfunction cx231xx_gpio_setfunction cx231xx_demod_resetfunction is_fw_loadfunction cx231xx_set_modefunction cx231xx_ep5_bulkoutfunction cx231xx_isoc_irq_callbackfunction cx231xx_bulk_irq_callbackfunction cx231xx_uninit_isocfunction cx231xx_uninit_bulkfunction cx231xx_init_isocfunction cx231xx_init_bulkfunction cx231xx_stop_TS1function cx231xx_start_TS1function cx231xx_dev_initfunction cx231xx_dev_uninitfunction cx231xx_send_gpio_cmdfunction cx231xx_mode_registerfunction cx231xx_read_i2c_masterfunction cx231xx_write_i2c_masterfunction cx231xx_read_i2c_datafunction cx231xx_write_i2c_datafunction cx231xx_reg_mask_writefunction cx231xx_read_modify_write_i2c_dwordfunction cx231xx_set_fieldexport cx231xx_register_extensionexport cx231xx_unregister_extensionexport cx231xx_send_usb_commandexport cx231xx_set_alt_settingexport cx231xx_demod_resetexport is_fw_loadexport cx231xx_set_modeexport cx231xx_uninit_isocexport cx231xx_uninit_bulkexport cx231xx_init_isocexport cx231xx_init_bulk
Annotated Snippet
if (!(requesttype & USB_DIR_IN)) {
printk(KERN_CONT ">>>");
for (i = 0; i < size; i++)
printk(KERN_CONT " %02x",
((unsigned char *)data)[i]);
}
}
/* Do the real call to usb_control_msg */
mutex_lock(&dev->ctrl_urb_lock);
if (!(requesttype & USB_DIR_IN) && size)
memcpy(dev->urb_buf, data, size);
rc = usb_control_msg(dev->udev, pipe, request, requesttype, value,
index, dev->urb_buf, size, timeout);
if ((requesttype & USB_DIR_IN) && size)
memcpy(data, dev->urb_buf, size);
mutex_unlock(&dev->ctrl_urb_lock);
if (reg_debug) {
if (unlikely(rc < 0)) {
printk(KERN_CONT "FAILED!\n");
return rc;
}
if ((requesttype & USB_DIR_IN)) {
printk(KERN_CONT "<<<");
for (i = 0; i < size; i++)
printk(KERN_CONT " %02x",
((unsigned char *)data)[i]);
}
printk(KERN_CONT "\n");
}
return rc;
}
/*
* cx231xx_read_ctrl_reg()
* reads data from the usb device specifying bRequest and wValue
*/
int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
char *buf, int len)
{
u8 val = 0;
int ret;
int pipe = usb_rcvctrlpipe(dev->udev, 0);
if (dev->state & DEV_DISCONNECTED)
return -ENODEV;
if (len > URB_MAX_CTRL_SIZE)
return -EINVAL;
switch (len) {
case 1:
val = ENABLE_ONE_BYTE;
break;
case 2:
val = ENABLE_TWE_BYTE;
break;
case 3:
val = ENABLE_THREE_BYTE;
break;
case 4:
val = ENABLE_FOUR_BYTE;
break;
default:
val = 0xFF; /* invalid option */
}
if (val == 0xFF)
return -EINVAL;
ret = __usb_control_msg(dev, pipe, req,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
val, reg, buf, len, HZ);
return ret;
}
int cx231xx_send_vendor_cmd(struct cx231xx *dev,
struct VENDOR_REQUEST_IN *ven_req)
{
int ret;
int pipe = 0;
int unsend_size = 0;
u8 *pdata;
if (dev->state & DEV_DISCONNECTED)
return -ENODEV;
Annotation
- Immediate include surface: `cx231xx.h`, `linux/init.h`, `linux/list.h`, `linux/module.h`, `linux/slab.h`, `linux/vmalloc.h`, `media/v4l2-common.h`, `media/tuner.h`.
- Detected declarations: `function cx231xx_realease_resources`, `function cx231xx_add_into_devlist`, `function cx231xx_register_extension`, `function cx231xx_unregister_extension`, `function cx231xx_init_extension`, `function cx231xx_close_extension`, `function cx231xx_send_usb_command`, `function operations`, `function cx231xx_read_ctrl_reg`, `function cx231xx_send_vendor_cmd`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.