// SPDX-License-Identifier: GPL-2.0-only /* * Copyright(c) 2023-2024 Intel Corporation * * Authors: Cezary Rojewski <[email protected]> * Amadeusz Slawinski <[email protected]> */ #define pr_fmt(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 = …; /** * 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) { … } EXPORT_SYMBOL_GPL(…); /** * acpi_nhlt_put_gbl_table - Release the global NHLT table. */ void acpi_nhlt_put_gbl_table(void) { … } EXPORT_SYMBOL_GPL(…); /** * 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) { … } EXPORT_SYMBOL_GPL(…); /** * 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 * an ERR_PTR() otherwise. */ struct acpi_nhlt_endpoint * acpi_nhlt_tb_find_endpoint(const struct acpi_table_nhlt *tb, int link_type, int dev_type, int dir, int bus_id) { … } EXPORT_SYMBOL_GPL(…); /** * acpi_nhlt_find_endpoint - Search all NHLT tables for an endpoint. * @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 * an ERR_PTR() otherwise. */ struct acpi_nhlt_endpoint * acpi_nhlt_find_endpoint(int link_type, int dev_type, int dir, int bus_id) { … } EXPORT_SYMBOL_GPL(…); /** * acpi_nhlt_endpoint_find_fmtcfg - Search endpoint's formats configuration space * for a specific format. * @ep: the endpoint to search. * @ch: number of channels. * @rate: samples per second. * @vbps: valid bits per sample. * @bps: bits per sample. * * Return: A pointer to format matching the criteria, %NULL if not found or * an ERR_PTR() otherwise. */ struct acpi_nhlt_format_config * acpi_nhlt_endpoint_find_fmtcfg(const struct acpi_nhlt_endpoint *ep, u16 ch, u32 rate, u16 vbps, u16 bps) { … } EXPORT_SYMBOL_GPL(…); /** * acpi_nhlt_tb_find_fmtcfg - Search a NHLT table for a specific format. * @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. * * @ch: number of channels. * @rate: samples per second. * @vbps: valid bits per sample. * @bps: bits per sample. * * 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 format matching the criteria, %NULL if not found or * an ERR_PTR() otherwise. */ struct acpi_nhlt_format_config * acpi_nhlt_tb_find_fmtcfg(const struct acpi_table_nhlt *tb, int link_type, int dev_type, int dir, int bus_id, u16 ch, u32 rate, u16 vbps, u16 bps) { … } EXPORT_SYMBOL_GPL(…); /** * acpi_nhlt_find_fmtcfg - Search all NHLT tables for a specific format. * @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. * * @ch: number of channels. * @rate: samples per second. * @vbps: valid bits per sample. * @bps: bits per sample. * * 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 format matching the criteria, %NULL if not found or * an ERR_PTR() otherwise. */ struct acpi_nhlt_format_config * acpi_nhlt_find_fmtcfg(int link_type, int dev_type, int dir, int bus_id, u16 ch, u32 rate, u16 vbps, u16 bps) { … } EXPORT_SYMBOL_GPL(…); static bool acpi_nhlt_config_is_micdevice(struct acpi_nhlt_config *cfg) { … } static bool acpi_nhlt_config_is_vendor_micdevice(struct acpi_nhlt_config *cfg) { … } /** * acpi_nhlt_endpoint_mic_count - Retrieve number of digital microphones for a PDM endpoint. * @ep: the endpoint to return microphones count for. * * Return: A number of microphones or an error code if an invalid endpoint is provided. */ int acpi_nhlt_endpoint_mic_count(const struct acpi_nhlt_endpoint *ep) { … } EXPORT_SYMBOL_GPL(…);