sound/hda/codecs/side-codecs/hda_component.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/side-codecs/hda_component.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/side-codecs/hda_component.c- Extension
.c- Size
- 5841 bytes
- Lines
- 210
- 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.
- 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/acpi.hlinux/component.hlinux/module.hlinux/slab.hsound/hda_codec.hhda_component.hhda_local.h
Detected Declarations
struct hda_scodec_matchfunction Copyrightfunction hda_component_manager_bind_acpi_notificationsfunction hda_component_manager_unbind_acpi_notificationsfunction hda_component_manager_playback_hookfunction hda_comp_match_dev_namefunction hda_component_manager_bindfunction hda_component_manager_initfunction hda_component_manager_free
Annotated Snippet
struct hda_scodec_match {
const char *bus;
const char *hid;
const char *match_str;
int index;
};
/* match the device name in a slightly relaxed manner */
static int hda_comp_match_dev_name(struct device *dev, void *data)
{
struct hda_scodec_match *p = data;
const char *d = dev_name(dev);
int n = strlen(p->bus);
char tmp[32];
/* check the bus name */
if (strncmp(d, p->bus, n))
return 0;
/* skip the bus number */
if (isdigit(d[n]))
n++;
/* the rest must be exact matching */
snprintf(tmp, sizeof(tmp), p->match_str, p->hid, p->index);
return !strcmp(d + n, tmp);
}
int hda_component_manager_bind(struct hda_codec *cdc,
struct hda_component_parent *parent)
{
/* Init shared and component specific data */
memset(parent->comps, 0, sizeof(parent->comps));
guard(mutex)(&parent->mutex);
return component_bind_all(hda_codec_dev(cdc), parent);
}
EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, "SND_HDA_SCODEC_COMPONENT");
int hda_component_manager_init(struct hda_codec *cdc,
struct hda_component_parent *parent, int count,
const char *bus, const char *hid,
const char *match_str,
const struct component_master_ops *ops)
{
struct device *dev = hda_codec_dev(cdc);
struct component_match *match = NULL;
struct hda_scodec_match *sm;
int ret, i;
if (parent->codec) {
codec_err(cdc, "Component binding already created (SSID: %x)\n",
cdc->core.subsystem_id);
return -EINVAL;
}
parent->codec = cdc;
mutex_init(&parent->mutex);
for (i = 0; i < count; i++) {
sm = devm_kmalloc(dev, sizeof(*sm), GFP_KERNEL);
if (!sm)
return -ENOMEM;
sm->bus = bus;
sm->hid = hid;
sm->match_str = match_str;
sm->index = i;
component_match_add(dev, &match, hda_comp_match_dev_name, sm);
if (IS_ERR(match)) {
codec_err(cdc, "Fail to add component %ld\n", PTR_ERR(match));
return PTR_ERR(match);
}
}
ret = component_master_add_with_match(dev, ops, match);
if (ret)
codec_err(cdc, "Fail to register component aggregator %d\n", ret);
return ret;
}
EXPORT_SYMBOL_NS_GPL(hda_component_manager_init, "SND_HDA_SCODEC_COMPONENT");
void hda_component_manager_free(struct hda_component_parent *parent,
const struct component_master_ops *ops)
{
struct device *dev;
if (!parent->codec)
return;
dev = hda_codec_dev(parent->codec);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/component.h`, `linux/module.h`, `linux/slab.h`, `sound/hda_codec.h`, `hda_component.h`, `hda_local.h`.
- Detected declarations: `struct hda_scodec_match`, `function Copyright`, `function hda_component_manager_bind_acpi_notifications`, `function hda_component_manager_unbind_acpi_notifications`, `function hda_component_manager_playback_hook`, `function hda_comp_match_dev_name`, `function hda_component_manager_bind`, `function hda_component_manager_init`, `function hda_component_manager_free`.
- Atlas domain: Driver Families / sound/hda.
- 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.