drivers/usb/gadget/function/u_audio.h
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/function/u_audio.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/function/u_audio.h- Extension
.h- Size
- 3974 bytes
- Lines
- 136
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/usb/composite.huac_common.h
Detected Declarations
struct uac_fu_paramsstruct uac_paramsstruct g_audiofunction num_channels
Annotated Snippet
struct uac_fu_params {
int id; /* Feature Unit ID */
bool mute_present; /* mute control enable */
bool volume_present; /* volume control enable */
s16 volume_min; /* min volume in 1/256 dB */
s16 volume_max; /* max volume in 1/256 dB */
s16 volume_res; /* volume resolution in 1/256 dB */
};
struct uac_params {
/* playback */
int p_chmask; /* channel mask */
int p_srates[UAC_MAX_RATES]; /* available rates in Hz (0 terminated list) */
int p_ssize; /* sample size */
struct uac_fu_params p_fu; /* Feature Unit parameters */
/* capture */
int c_chmask; /* channel mask */
int c_srates[UAC_MAX_RATES]; /* available rates in Hz (0 terminated list) */
int c_ssize; /* sample size */
struct uac_fu_params c_fu; /* Feature Unit parameters */
/* rates are dynamic, in uac_rtd_params */
int req_number; /* number of preallocated requests */
int fb_max; /* upper frequency drift feedback limit per-mil */
};
struct g_audio {
struct usb_function func;
struct usb_gadget *gadget;
struct usb_ep *in_ep;
struct usb_ep *out_ep;
/* feedback IN endpoint corresponding to out_ep */
struct usb_ep *in_ep_fback;
/* Max packet size for all in_ep possible speeds */
unsigned int in_ep_maxpsize;
/* Max packet size for all out_ep possible speeds */
unsigned int out_ep_maxpsize;
/* Notify UAC driver about control change */
int (*notify)(struct g_audio *g_audio, int unit_id, int cs);
/* The ALSA Sound Card it represents on the USB-Client side */
struct snd_uac_chip *uac;
struct uac_params params;
};
static inline struct g_audio *func_to_g_audio(struct usb_function *f)
{
return container_of(f, struct g_audio, func);
}
static inline uint num_channels(uint chanmask)
{
uint num = 0;
while (chanmask) {
num += (chanmask & 1);
chanmask >>= 1;
}
return num;
}
/*
* g_audio_setup - initialize one virtual ALSA sound card
* @g_audio: struct with filled params, in_ep_maxpsize, out_ep_maxpsize
* @pcm_name: the id string for a PCM instance of this sound card
* @card_name: name of this soundcard
*
* This sets up the single virtual ALSA sound card that may be exported by a
* gadget driver using this framework.
*
* Context: may sleep
*
* Returns zero on success, or a negative error on failure.
*/
int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
const char *card_name);
void g_audio_cleanup(struct g_audio *g_audio);
int u_audio_start_capture(struct g_audio *g_audio);
void u_audio_stop_capture(struct g_audio *g_audio);
Annotation
- Immediate include surface: `linux/usb/composite.h`, `uac_common.h`.
- Detected declarations: `struct uac_fu_params`, `struct uac_params`, `struct g_audio`, `function num_channels`.
- Atlas domain: Driver Families / drivers/usb.
- 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.