drivers/staging/greybus/audio_gb.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/audio_gb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/audio_gb.c- Extension
.c- Size
- 5819 bytes
- Lines
- 226
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- 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/greybus.haudio_codec.h
Detected Declarations
function gb_audio_gb_get_topologyfunction gb_audio_gb_get_controlfunction gb_audio_gb_set_controlfunction gb_audio_gb_enable_widgetfunction gb_audio_gb_disable_widgetfunction gb_audio_gb_get_pcmfunction gb_audio_gb_set_pcmfunction gb_audio_gb_set_tx_data_sizefunction gb_audio_gb_activate_txfunction gb_audio_gb_deactivate_txfunction gb_audio_gb_set_rx_data_sizefunction gb_audio_gb_activate_rxfunction gb_audio_gb_deactivate_rxexport gb_audio_gb_get_topologyexport gb_audio_gb_get_controlexport gb_audio_gb_set_controlexport gb_audio_gb_enable_widgetexport gb_audio_gb_disable_widgetexport gb_audio_gb_get_pcmexport gb_audio_gb_set_pcmexport gb_audio_gb_set_tx_data_sizeexport gb_audio_gb_activate_txexport gb_audio_gb_deactivate_txexport gb_audio_gb_set_rx_data_sizeexport gb_audio_gb_activate_rxexport gb_audio_gb_deactivate_rx
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Greybus Audio Device Class Protocol helpers
*
* Copyright 2015-2016 Google Inc.
*/
#include <linux/greybus.h>
#include "audio_codec.h"
/* TODO: Split into separate calls */
int gb_audio_gb_get_topology(struct gb_connection *connection,
struct gb_audio_topology **topology)
{
struct gb_audio_get_topology_size_response size_resp;
struct gb_audio_topology *topo;
u16 size;
int ret;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE,
NULL, 0, &size_resp, sizeof(size_resp));
if (ret)
return ret;
size = le16_to_cpu(size_resp.size);
if (size < sizeof(*topo))
return -ENODATA;
topo = kzalloc(size, GFP_KERNEL);
if (!topo)
return -ENOMEM;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, NULL, 0,
topo, size);
if (ret) {
kfree(topo);
return ret;
}
*topology = topo;
return 0;
}
EXPORT_SYMBOL_GPL(gb_audio_gb_get_topology);
int gb_audio_gb_get_control(struct gb_connection *connection,
u8 control_id, u8 index,
struct gb_audio_ctl_elem_value *value)
{
struct gb_audio_get_control_request req;
struct gb_audio_get_control_response resp;
int ret;
req.control_id = control_id;
req.index = index;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_CONTROL,
&req, sizeof(req), &resp, sizeof(resp));
if (ret)
return ret;
memcpy(value, &resp.value, sizeof(*value));
return 0;
}
EXPORT_SYMBOL_GPL(gb_audio_gb_get_control);
int gb_audio_gb_set_control(struct gb_connection *connection,
u8 control_id, u8 index,
struct gb_audio_ctl_elem_value *value)
{
struct gb_audio_set_control_request req;
req.control_id = control_id;
req.index = index;
memcpy(&req.value, value, sizeof(req.value));
return gb_operation_sync(connection, GB_AUDIO_TYPE_SET_CONTROL,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_set_control);
int gb_audio_gb_enable_widget(struct gb_connection *connection,
u8 widget_id)
{
struct gb_audio_enable_widget_request req;
req.widget_id = widget_id;
return gb_operation_sync(connection, GB_AUDIO_TYPE_ENABLE_WIDGET,
Annotation
- Immediate include surface: `linux/greybus.h`, `audio_codec.h`.
- Detected declarations: `function gb_audio_gb_get_topology`, `function gb_audio_gb_get_control`, `function gb_audio_gb_set_control`, `function gb_audio_gb_enable_widget`, `function gb_audio_gb_disable_widget`, `function gb_audio_gb_get_pcm`, `function gb_audio_gb_set_pcm`, `function gb_audio_gb_set_tx_data_size`, `function gb_audio_gb_activate_tx`, `function gb_audio_gb_deactivate_tx`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: integration 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.