drivers/acpi/nhlt.c
Source file repositories/reference/linux-study-clean/drivers/acpi/nhlt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/nhlt.c- Extension
.c- Size
- 8915 bytes
- Lines
- 290
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/errno.hlinux/export.hlinux/minmax.hlinux/printk.hlinux/types.hacpi/nhlt.h
Detected Declarations
function acpi_nhlt_get_gbl_tablefunction acpi_nhlt_put_gbl_tablefunction acpi_nhlt_endpoint_matchfunction ERR_PTRfunction ERR_PTRfunction ERR_PTRfunction for_each_nhlt_endpoint_fmtcfgfunction ERR_PTRfunction for_each_nhlt_endpointfunction ERR_PTRfunction acpi_nhlt_config_is_micdevicefunction acpi_nhlt_config_is_vendor_micdevicefunction acpi_nhlt_endpoint_mic_countexport acpi_nhlt_get_gbl_tableexport acpi_nhlt_put_gbl_tableexport acpi_nhlt_endpoint_matchexport acpi_nhlt_tb_find_endpointexport acpi_nhlt_find_endpointexport acpi_nhlt_endpoint_find_fmtcfgexport acpi_nhlt_tb_find_fmtcfgexport acpi_nhlt_find_fmtcfgexport acpi_nhlt_endpoint_mic_count
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright(c) 2023-2024 Intel Corporation
*
* Authors: Cezary Rojewski <cezary.rojewski@intel.com>
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
*/
#define pr_fmt(fmt) "ACPI: NHLT: " fmt
#include <linux/acpi.h>
#include <linux/errno.h>
#include <linux/export.h>
#include <linux/minmax.h>
#include <linux/printk.h>
#include <linux/types.h>
#include <acpi/nhlt.h>
static struct acpi_table_nhlt *acpi_gbl_nhlt;
static struct acpi_table_nhlt empty_nhlt = {
.header = {
.signature = ACPI_SIG_NHLT,
},
};
/**
* acpi_nhlt_get_gbl_table - Retrieve a pointer to the first NHLT table.
*
* If there is no NHLT in the system, acpi_gbl_nhlt will instead point to an
* empty table.
*
* Return: ACPI status code of the operation.
*/
acpi_status acpi_nhlt_get_gbl_table(void)
{
acpi_status status;
status = acpi_get_table(ACPI_SIG_NHLT, 0, (struct acpi_table_header **)(&acpi_gbl_nhlt));
if (!acpi_gbl_nhlt)
acpi_gbl_nhlt = &empty_nhlt;
return status;
}
EXPORT_SYMBOL_GPL(acpi_nhlt_get_gbl_table);
/**
* acpi_nhlt_put_gbl_table - Release the global NHLT table.
*/
void acpi_nhlt_put_gbl_table(void)
{
acpi_put_table((struct acpi_table_header *)acpi_gbl_nhlt);
}
EXPORT_SYMBOL_GPL(acpi_nhlt_put_gbl_table);
/**
* acpi_nhlt_endpoint_match - Verify if an endpoint matches criteria.
* @ep: the endpoint to check.
* @link_type: the hardware link type, e.g.: PDM or SSP.
* @dev_type: the device type.
* @dir: stream direction.
* @bus_id: the ID of virtual bus hosting the endpoint.
*
* Either of @link_type, @dev_type, @dir or @bus_id may be set to a negative
* value to ignore the parameter when matching.
*
* Return: %true if endpoint matches specified criteria or %false otherwise.
*/
bool acpi_nhlt_endpoint_match(const struct acpi_nhlt_endpoint *ep,
int link_type, int dev_type, int dir, int bus_id)
{
return ep &&
(link_type < 0 || ep->link_type == link_type) &&
(dev_type < 0 || ep->device_type == dev_type) &&
(bus_id < 0 || ep->virtual_bus_id == bus_id) &&
(dir < 0 || ep->direction == dir);
}
EXPORT_SYMBOL_GPL(acpi_nhlt_endpoint_match);
/**
* acpi_nhlt_tb_find_endpoint - Search a NHLT table for an endpoint.
* @tb: the table to search.
* @link_type: the hardware link type, e.g.: PDM or SSP.
* @dev_type: the device type.
* @dir: stream direction.
* @bus_id: the ID of virtual bus hosting the endpoint.
*
* Either of @link_type, @dev_type, @dir or @bus_id may be set to a negative
* value to ignore the parameter during the search.
*
* Return: A pointer to endpoint matching the criteria, %NULL if not found or
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/errno.h`, `linux/export.h`, `linux/minmax.h`, `linux/printk.h`, `linux/types.h`, `acpi/nhlt.h`.
- Detected declarations: `function acpi_nhlt_get_gbl_table`, `function acpi_nhlt_put_gbl_table`, `function acpi_nhlt_endpoint_match`, `function ERR_PTR`, `function ERR_PTR`, `function ERR_PTR`, `function for_each_nhlt_endpoint_fmtcfg`, `function ERR_PTR`, `function for_each_nhlt_endpoint`, `function ERR_PTR`.
- Atlas domain: Driver Families / drivers/acpi.
- 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.