drivers/staging/greybus/audio_module.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/audio_module.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/audio_module.c- Extension
.c- Size
- 12660 bytes
- Lines
- 480
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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
linux/kernel.hlinux/module.hsound/soc.hsound/pcm_params.haudio_codec.haudio_apbridgea.haudio_manager.h
Detected Declarations
function gbaudio_request_jackfunction gbaudio_request_buttonfunction gbaudio_request_streamfunction gbaudio_codec_request_handlerfunction gb_audio_add_mgmt_connectionfunction gb_audio_add_data_connectionfunction gb_audio_probefunction gb_audio_disconnectfunction gb_audio_suspendfunction gb_audio_resumefunction list_for_each_entry
Annotated Snippet
if (btn_jack && module->button_status) {
snd_soc_jack_report(&module->button.jack, 0,
module->button_mask);
module->button_status = 0;
}
snd_soc_jack_report(&module->headset.jack, 0,
module->jack_mask);
return 0;
}
report = req->jack_attribute & module->jack_mask;
if (!report) {
dev_err_ratelimited(module->dev,
"Invalid jack event received:type: %u, event: %u\n",
req->jack_attribute, req->event);
return -EINVAL;
}
if (module->jack_type)
dev_warn_ratelimited(module->dev,
"Modifying jack from %d to %d\n",
module->jack_type, report);
module->jack_type = report;
snd_soc_jack_report(&module->headset.jack, report, module->jack_mask);
return 0;
}
static int gbaudio_request_button(struct gbaudio_module_info *module,
struct gb_audio_button_event_request *req)
{
int soc_button_id, report;
struct snd_jack *btn_jack = module->button.jack.jack;
if (!btn_jack) {
dev_err_ratelimited(module->dev,
"Invalid button event received:type: %u, event: %u\n",
req->button_id, req->event);
return -EINVAL;
}
dev_warn_ratelimited(module->dev,
"Button Event received: id: %u, event: %u\n",
req->button_id, req->event);
/* currently supports 4 buttons only */
if (!module->jack_type) {
dev_err_ratelimited(module->dev,
"Jack not present. Bogus event!!\n");
return -EINVAL;
}
report = module->button_status & module->button_mask;
soc_button_id = 0;
switch (req->button_id) {
case 1:
soc_button_id = SND_JACK_BTN_0 & module->button_mask;
break;
case 2:
soc_button_id = SND_JACK_BTN_1 & module->button_mask;
break;
case 3:
soc_button_id = SND_JACK_BTN_2 & module->button_mask;
break;
case 4:
soc_button_id = SND_JACK_BTN_3 & module->button_mask;
break;
}
if (!soc_button_id) {
dev_err_ratelimited(module->dev,
"Invalid button request received\n");
return -EINVAL;
}
if (req->event == GB_AUDIO_BUTTON_EVENT_PRESS)
report = report | soc_button_id;
else
report = report & ~soc_button_id;
module->button_status = report;
snd_soc_jack_report(&module->button.jack, report, module->button_mask);
return 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `sound/soc.h`, `sound/pcm_params.h`, `audio_codec.h`, `audio_apbridgea.h`, `audio_manager.h`.
- Detected declarations: `function gbaudio_request_jack`, `function gbaudio_request_button`, `function gbaudio_request_stream`, `function gbaudio_codec_request_handler`, `function gb_audio_add_mgmt_connection`, `function gb_audio_add_data_connection`, `function gb_audio_probe`, `function gb_audio_disconnect`, `function gb_audio_suspend`, `function gb_audio_resume`.
- Atlas domain: Driver Families / drivers/staging.
- 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.