sound/soc/soc-usb.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-usb.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-usb.c- Extension
.c- Size
- 7834 bytes
- Lines
- 323
- Domain
- Driver Families
- Bucket
- sound/soc
- 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
linux/of.hlinux/usb.hsound/jack.hsound/soc-usb.h../usb/card.h
Detected Declarations
function list_for_each_entryfunction snd_soc_usb_setup_offload_jackfunction snd_soc_usb_update_offload_routefunction snd_soc_usb_find_priv_datafunction snd_soc_usb_find_supported_formatfunction snd_soc_usb_allocate_portfunction snd_soc_usb_free_portfunction snd_soc_usb_add_portfunction snd_soc_usb_remove_portfunction snd_soc_usb_connectfunction snd_soc_usb_disconnectexport snd_soc_usb_setup_offload_jackexport snd_soc_usb_update_offload_routeexport snd_soc_usb_find_priv_dataexport snd_soc_usb_find_supported_formatexport snd_soc_usb_allocate_portexport snd_soc_usb_free_portexport snd_soc_usb_add_portexport snd_soc_usb_remove_portexport snd_soc_usb_connectexport snd_soc_usb_disconnect
Annotated Snippet
if (ctx == usb) {
list_del(&ctx->list);
break;
}
}
mutex_unlock(&ctx_mutex);
}
EXPORT_SYMBOL_GPL(snd_soc_usb_remove_port);
/**
* snd_soc_usb_connect() - Notification of USB device connection
* @usbdev: USB bus device
* @sdev: USB SND device to add
*
* Notify of a new USB SND device connection. The sdev->card_idx can be used to
* handle how the DPCM backend selects, which device to enable USB offloading
* on.
*
*/
int snd_soc_usb_connect(struct device *usbdev, struct snd_soc_usb_device *sdev)
{
struct snd_soc_usb *ctx;
if (!usbdev)
return -ENODEV;
mutex_lock(&ctx_mutex);
ctx = snd_soc_find_usb_ctx(usbdev);
if (!ctx)
goto exit;
if (ctx->connection_status_cb)
ctx->connection_status_cb(ctx, sdev, true);
exit:
mutex_unlock(&ctx_mutex);
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_usb_connect);
/**
* snd_soc_usb_disconnect() - Notification of USB device disconnection
* @usbdev: USB bus device
* @sdev: USB SND device to remove
*
* Notify of a new USB SND device disconnection to the USB backend.
*
*/
int snd_soc_usb_disconnect(struct device *usbdev, struct snd_soc_usb_device *sdev)
{
struct snd_soc_usb *ctx;
if (!usbdev)
return -ENODEV;
mutex_lock(&ctx_mutex);
ctx = snd_soc_find_usb_ctx(usbdev);
if (!ctx)
goto exit;
if (ctx->connection_status_cb)
ctx->connection_status_cb(ctx, sdev, false);
exit:
mutex_unlock(&ctx_mutex);
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_usb_disconnect);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SoC USB driver for offloading");
Annotation
- Immediate include surface: `linux/of.h`, `linux/usb.h`, `sound/jack.h`, `sound/soc-usb.h`, `../usb/card.h`.
- Detected declarations: `function list_for_each_entry`, `function snd_soc_usb_setup_offload_jack`, `function snd_soc_usb_update_offload_route`, `function snd_soc_usb_find_priv_data`, `function snd_soc_usb_find_supported_format`, `function snd_soc_usb_allocate_port`, `function snd_soc_usb_free_port`, `function snd_soc_usb_add_port`, `function snd_soc_usb_remove_port`, `function snd_soc_usb_connect`.
- Atlas domain: Driver Families / sound/soc.
- 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.