sound/hda/core/bus.c
Source file repositories/reference/linux-study-clean/sound/hda/core/bus.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/core/bus.c- Extension
.c- Size
- 7554 bytes
- Lines
- 287
- Domain
- Driver Families
- Bucket
- sound/hda
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/io.hlinux/device.hlinux/module.hlinux/export.hsound/hdaudio.hlocal.htrace.h
Detected Declarations
function snd_hdac_bus_initfunction snd_hdac_bus_exitfunction snd_hdac_bus_exec_verbfunction snd_hdac_bus_exec_verb_unlockedfunction snd_hdac_bus_queue_eventfunction snd_hdac_bus_process_unsol_eventsfunction snd_hdac_bus_add_devicefunction snd_hdac_bus_remove_devicefunction snd_hdac_aligned_readfunction snd_hdac_aligned_writefunction snd_hdac_codec_link_upfunction snd_hdac_codec_link_downexport snd_hdac_bus_initexport snd_hdac_bus_exitexport snd_hdac_bus_exec_verb_unlockedexport snd_hdac_aligned_readexport snd_hdac_aligned_writeexport snd_hdac_codec_link_upexport snd_hdac_codec_link_down
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* HD-audio core bus driver
*/
#include <linux/init.h>
#include <linux/io.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/export.h>
#include <sound/hdaudio.h>
#include "local.h"
#include "trace.h"
static void snd_hdac_bus_process_unsol_events(struct work_struct *work);
static const struct hdac_bus_ops default_ops = {
.command = snd_hdac_bus_send_cmd,
.get_response = snd_hdac_bus_get_response,
.link_power = snd_hdac_bus_link_power,
};
/**
* snd_hdac_bus_init - initialize a HD-audio bas bus
* @bus: the pointer to bus object
* @dev: device pointer
* @ops: bus verb operators
*
* Returns 0 if successful, or a negative error code.
*/
int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
const struct hdac_bus_ops *ops)
{
memset(bus, 0, sizeof(*bus));
bus->dev = dev;
if (ops)
bus->ops = ops;
else
bus->ops = &default_ops;
bus->dma_type = SNDRV_DMA_TYPE_DEV;
INIT_LIST_HEAD(&bus->stream_list);
INIT_LIST_HEAD(&bus->codec_list);
INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events);
spin_lock_init(&bus->reg_lock);
mutex_init(&bus->cmd_mutex);
mutex_init(&bus->lock);
INIT_LIST_HEAD(&bus->hlink_list);
init_waitqueue_head(&bus->rirb_wq);
bus->irq = -1;
bus->addr_offset = 0;
/*
* Default value of '8' is as per the HD audio specification (Rev 1.0a).
* Following relation is used to derive STRIPE control value.
* For sample rate <= 48K:
* { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }
* For sample rate > 48K:
* { ((num_channels * bits_per_sample * rate/48000) /
* number of SDOs) >= 8 }
*/
bus->sdo_limit = 8;
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_bus_init);
/**
* snd_hdac_bus_exit - clean up a HD-audio bas bus
* @bus: the pointer to bus object
*/
void snd_hdac_bus_exit(struct hdac_bus *bus)
{
WARN_ON(!list_empty(&bus->stream_list));
WARN_ON(!list_empty(&bus->codec_list));
cancel_work_sync(&bus->unsol_work);
}
EXPORT_SYMBOL_GPL(snd_hdac_bus_exit);
/**
* snd_hdac_bus_exec_verb - execute a HD-audio verb on the given bus
* @bus: bus object
* @addr: the HDAC device address
* @cmd: HD-audio encoded verb
* @res: pointer to store the response, NULL if performing asynchronously
*
* Returns 0 if successful, or a negative error code.
*/
int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr,
unsigned int cmd, unsigned int *res)
{
Annotation
- Immediate include surface: `linux/init.h`, `linux/io.h`, `linux/device.h`, `linux/module.h`, `linux/export.h`, `sound/hdaudio.h`, `local.h`, `trace.h`.
- Detected declarations: `function snd_hdac_bus_init`, `function snd_hdac_bus_exit`, `function snd_hdac_bus_exec_verb`, `function snd_hdac_bus_exec_verb_unlocked`, `function snd_hdac_bus_queue_event`, `function snd_hdac_bus_process_unsol_events`, `function snd_hdac_bus_add_device`, `function snd_hdac_bus_remove_device`, `function snd_hdac_aligned_read`, `function snd_hdac_aligned_write`.
- Atlas domain: Driver Families / sound/hda.
- 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.