Commit 784cf449 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'acpi-scan' and 'acpi-tables'

Merge ACPI device enumeration changes and ACPI data-only tables support
updates for 6.10:

 - Rearrange fields in several structures to effectively eliminate
   computations from container_of() in some cases (Andy Shevchenko).

 - Do some assorted cleanups of the ACPI device enumeration code (Andy
   Shevchenko).

 - Make the ACPI device enumeration code skip devices with _STA values
   clearly identified by the specification as invalid (Rafael Wysocki).

 - Rework the handling of the NHLT table to simplify and clarify it and
   drop some obsolete pieces (Cezary Rojewski).

* acpi-scan:
  ACPI: scan: Avoid enumerating devices with clearly invalid _STA values
  ACPI: scan: Introduce typedef:s for struct acpi_hotplug_context members
  ACPI: scan: Use standard error checking pattern
  ACPI: scan: Move misleading comment to acpi_dma_configure_id()
  ACPI: scan: Use list_first_entry_or_null() in acpi_device_hid()
  ACPI: bus: Don't use "proxy" headers
  ACPI: bus: Make container_of() no-op where it makes sense

* acpi-tables:
  ACPI: NHLT: Streamline struct naming
  ACPI: NHLT: Drop redundant types
  ACPI: NHLT: Introduce API for the table
  ACPI: NHLT: Reintroduce types the table consists of
......@@ -469,6 +469,9 @@ config ACPI_REDUCED_HARDWARE_ONLY
If you are unsure what to do, do not enable this option.
config ACPI_NHLT
bool
source "drivers/acpi/nfit/Kconfig"
source "drivers/acpi/numa/Kconfig"
source "drivers/acpi/apei/Kconfig"
......
......@@ -93,6 +93,7 @@ obj-$(CONFIG_ACPI_THERMAL_LIB) += thermal_lib.o
obj-$(CONFIG_ACPI_THERMAL) += thermal.o
obj-$(CONFIG_ACPI_PLATFORM_PROFILE) += platform_profile.o
obj-$(CONFIG_ACPI_NFIT) += nfit/
obj-$(CONFIG_ACPI_NHLT) += nhlt.o
obj-$(CONFIG_ACPI_NUMA) += numa/
obj-$(CONFIG_ACPI) += acpi_memhotplug.o
obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o
......
......@@ -112,6 +112,17 @@ int acpi_bus_get_status(struct acpi_device *device)
if (ACPI_FAILURE(status))
return -ENODEV;
if (!device->status.present && device->status.enabled) {
pr_info(FW_BUG "Device [%s] status [%08x]: not present and enabled\n",
device->pnp.bus_id, (u32)sta);
device->status.enabled = 0;
/*
* The status is clearly invalid, so clear the functional bit as
* well to avoid attempting to use the device.
*/
device->status.functional = 0;
}
acpi_set_device_status(device, sta);
if (device->status.functional && !device->status.present) {
......
......@@ -88,43 +88,29 @@ static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
enum dock_callback_type cb_type)
{
struct acpi_device *adev = dd->adev;
acpi_hp_fixup fixup = NULL;
acpi_hp_uevent uevent = NULL;
acpi_hp_notify notify = NULL;
acpi_lock_hp_context();
if (!adev->hp)
goto out;
if (cb_type == DOCK_CALL_FIXUP) {
void (*fixup)(struct acpi_device *);
fixup = adev->hp->fixup;
if (fixup) {
acpi_unlock_hp_context();
fixup(adev);
return;
}
} else if (cb_type == DOCK_CALL_UEVENT) {
void (*uevent)(struct acpi_device *, u32);
uevent = adev->hp->uevent;
if (uevent) {
acpi_unlock_hp_context();
uevent(adev, event);
return;
}
} else {
int (*notify)(struct acpi_device *, u32);
notify = adev->hp->notify;
if (notify) {
acpi_unlock_hp_context();
notify(adev, event);
return;
}
if (adev->hp) {
if (cb_type == DOCK_CALL_FIXUP)
fixup = adev->hp->fixup;
else if (cb_type == DOCK_CALL_UEVENT)
uevent = adev->hp->uevent;
else
notify = adev->hp->notify;
}
out:
acpi_unlock_hp_context();
if (fixup)
fixup(adev);
else if (uevent)
uevent(adev, event);
else if (notify)
notify(adev, event);
}
static struct dock_station *find_dock_station(acpi_handle handle)
......
// 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
* 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)
{
struct acpi_nhlt_endpoint *ep;
for_each_nhlt_endpoint(tb, ep)
if (acpi_nhlt_endpoint_match(ep, link_type, dev_type, dir, bus_id))
return ep;
return NULL;
}
EXPORT_SYMBOL_GPL(acpi_nhlt_tb_find_endpoint);
/**
* 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)
{
/* TODO: Currently limited to table of index 0. */
return acpi_nhlt_tb_find_endpoint(acpi_gbl_nhlt, link_type, dev_type, dir, bus_id);
}
EXPORT_SYMBOL_GPL(acpi_nhlt_find_endpoint);
/**
* 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)
{
struct acpi_nhlt_wave_formatext *wav;
struct acpi_nhlt_format_config *fmt;
for_each_nhlt_endpoint_fmtcfg(ep, fmt) {
wav = &fmt->format;
if (wav->valid_bits_per_sample == vbps &&
wav->samples_per_sec == rate &&
wav->bits_per_sample == bps &&
wav->channel_count == ch)
return fmt;
}
return NULL;
}
EXPORT_SYMBOL_GPL(acpi_nhlt_endpoint_find_fmtcfg);
/**
* 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)
{
struct acpi_nhlt_format_config *fmt;
struct acpi_nhlt_endpoint *ep;
for_each_nhlt_endpoint(tb, ep) {
if (!acpi_nhlt_endpoint_match(ep, link_type, dev_type, dir, bus_id))
continue;
fmt = acpi_nhlt_endpoint_find_fmtcfg(ep, ch, rate, vbps, bps);
if (fmt)
return fmt;
}
return NULL;
}
EXPORT_SYMBOL_GPL(acpi_nhlt_tb_find_fmtcfg);
/**
* 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)
{
/* TODO: Currently limited to table of index 0. */
return acpi_nhlt_tb_find_fmtcfg(acpi_gbl_nhlt, link_type, dev_type, dir, bus_id,
ch, rate, vbps, bps);
}
EXPORT_SYMBOL_GPL(acpi_nhlt_find_fmtcfg);
static bool acpi_nhlt_config_is_micdevice(struct acpi_nhlt_config *cfg)
{
return cfg->capabilities_size >= sizeof(struct acpi_nhlt_micdevice_config);
}
static bool acpi_nhlt_config_is_vendor_micdevice(struct acpi_nhlt_config *cfg)
{
struct acpi_nhlt_vendor_micdevice_config *devcfg = __acpi_nhlt_config_caps(cfg);
return cfg->capabilities_size >= sizeof(*devcfg) &&
cfg->capabilities_size == struct_size(devcfg, mics, devcfg->mics_count);
}
/**
* 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)
{
union acpi_nhlt_device_config *devcfg;
struct acpi_nhlt_format_config *fmt;
struct acpi_nhlt_config *cfg;
u16 max_ch = 0;
if (!ep || ep->link_type != ACPI_NHLT_LINKTYPE_PDM)
return -EINVAL;
/* Find max number of channels based on formats configuration. */
for_each_nhlt_endpoint_fmtcfg(ep, fmt)
max_ch = max(fmt->format.channel_count, max_ch);
cfg = __acpi_nhlt_endpoint_config(ep);
devcfg = __acpi_nhlt_config_caps(cfg);
/* If @ep is not a mic array, fallback to channels count. */
if (!acpi_nhlt_config_is_micdevice(cfg) ||
devcfg->gen.config_type != ACPI_NHLT_CONFIGTYPE_MICARRAY)
return max_ch;
switch (devcfg->mic.array_type) {
case ACPI_NHLT_ARRAYTYPE_LINEAR2_SMALL:
case ACPI_NHLT_ARRAYTYPE_LINEAR2_BIG:
return 2;
case ACPI_NHLT_ARRAYTYPE_LINEAR4_GEO1:
case ACPI_NHLT_ARRAYTYPE_PLANAR4_LSHAPED:
case ACPI_NHLT_ARRAYTYPE_LINEAR4_GEO2:
return 4;
case ACPI_NHLT_ARRAYTYPE_VENDOR:
if (!acpi_nhlt_config_is_vendor_micdevice(cfg))
return -EINVAL;
return devcfg->vendor_mic.mics_count;
default:
pr_warn("undefined mic array type: %#x\n", devcfg->mic.array_type);
return max_ch;
}
}
EXPORT_SYMBOL_GPL(acpi_nhlt_endpoint_mic_count);
......@@ -73,8 +73,7 @@ void acpi_unlock_hp_context(void)
void acpi_initialize_hp_context(struct acpi_device *adev,
struct acpi_hotplug_context *hp,
int (*notify)(struct acpi_device *, u32),
void (*uevent)(struct acpi_device *, u32))
acpi_hp_notify notify, acpi_hp_uevent uevent)
{
acpi_lock_hp_context();
hp->notify = notify;
......@@ -428,7 +427,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
} else if (adev->flags.hotplug_notify) {
error = acpi_generic_hotplug_event(adev, src);
} else {
int (*notify)(struct acpi_device *, u32);
acpi_hp_notify notify;
acpi_lock_hp_context();
notify = adev->hp ? adev->hp->notify : NULL;
......@@ -1298,10 +1297,10 @@ const char *acpi_device_hid(struct acpi_device *device)
{
struct acpi_hardware_id *hid;
if (list_empty(&device->pnp.ids))
hid = list_first_entry_or_null(&device->pnp.ids, struct acpi_hardware_id, list);
if (!hid)
return dummy_hid;
hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
return hid->id;
}
EXPORT_SYMBOL(acpi_device_hid);
......@@ -1581,12 +1580,13 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 id,
struct fwnode_handle *fwnode,
const struct iommu_ops *ops)
{
int ret = iommu_fwspec_init(dev, fwnode, ops);
int ret;
if (!ret)
ret = iommu_fwspec_add_ids(dev, &id, 1);
ret = iommu_fwspec_init(dev, fwnode, ops);
if (ret)
return ret;
return ret;
return iommu_fwspec_add_ids(dev, &id, 1);
}
static inline const struct iommu_ops *acpi_iommu_fwspec_ops(struct device *dev)
......@@ -1625,12 +1625,11 @@ static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
if (!err && dev->bus)
err = iommu_probe_device(dev);
/* Ignore all other errors apart from EPROBE_DEFER */
if (err == -EPROBE_DEFER) {
if (err == -EPROBE_DEFER)
return err;
} else if (err) {
if (err) {
dev_dbg(dev, "Adding to IOMMU failed: %d\n", err);
return -ENODEV;
return err;
}
if (!acpi_iommu_fwspec_ops(dev))
return -ENODEV;
......@@ -1671,13 +1670,14 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
acpi_arch_dma_setup(dev);
/* Ignore all other errors apart from EPROBE_DEFER */
ret = acpi_iommu_configure_id(dev, input_id);
if (ret == -EPROBE_DEFER)
return -EPROBE_DEFER;
/*
* Historically this routine doesn't fail driver probing due to errors
* in acpi_iommu_configure_id()
* in acpi_iommu_configure_id().
*/
arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT);
......@@ -1962,7 +1962,7 @@ bool acpi_device_is_present(const struct acpi_device *adev)
bool acpi_device_is_enabled(const struct acpi_device *adev)
{
return adev->status.present && adev->status.enabled;
return adev->status.enabled;
}
static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
......
......@@ -9,8 +9,13 @@
#ifndef __ACPI_BUS_H__
#define __ACPI_BUS_H__
#include <linux/completion.h>
#include <linux/container_of.h>
#include <linux/device.h>
#include <linux/kobject.h>
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/types.h>
struct acpi_handle_list {
u32 count;
......@@ -124,8 +129,8 @@ static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
}
struct acpi_scan_handler {
const struct acpi_device_id *ids;
struct list_head list_node;
const struct acpi_device_id *ids;
bool (*match)(const char *idstr, const struct acpi_device_id **matchid);
int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
void (*detach)(struct acpi_device *dev);
......@@ -139,11 +144,15 @@ struct acpi_scan_handler {
* --------------------
*/
typedef int (*acpi_hp_notify) (struct acpi_device *, u32);
typedef void (*acpi_hp_uevent) (struct acpi_device *, u32);
typedef void (*acpi_hp_fixup) (struct acpi_device *);
struct acpi_hotplug_context {
struct acpi_device *self;
int (*notify)(struct acpi_device *, u32);
void (*uevent)(struct acpi_device *, u32);
void (*fixup)(struct acpi_device *);
acpi_hp_notify notify;
acpi_hp_uevent uevent;
acpi_hp_fixup fixup;
};
/*
......@@ -268,6 +277,7 @@ struct acpi_device_power_flags {
};
struct acpi_device_power_state {
struct list_head resources; /* Power resources referenced */
struct {
u8 valid:1;
u8 explicit_set:1; /* _PSx present? */
......@@ -275,7 +285,6 @@ struct acpi_device_power_state {
} flags;
int power; /* % Power (compared to D0) */
int latency; /* Dx->D0 time (microseconds) */
struct list_head resources; /* Power resources referenced */
};
struct acpi_device_power {
......@@ -341,16 +350,16 @@ struct acpi_device_wakeup {
};
struct acpi_device_physical_node {
unsigned int node_id;
struct list_head node;
struct device *dev;
unsigned int node_id;
bool put_online:1;
};
struct acpi_device_properties {
struct list_head list;
const guid_t *guid;
union acpi_object *properties;
struct list_head list;
void **bufs;
};
......@@ -487,12 +496,12 @@ struct acpi_device {
/* Non-device subnode */
struct acpi_data_node {
struct list_head sibling;
const char *name;
acpi_handle handle;
struct fwnode_handle fwnode;
struct fwnode_handle *parent;
struct acpi_device_data data;
struct list_head sibling;
struct kobject kobj;
struct completion kobj_done;
};
......@@ -577,8 +586,7 @@ static inline void acpi_set_hp_context(struct acpi_device *adev,
void acpi_initialize_hp_context(struct acpi_device *adev,
struct acpi_hotplug_context *hp,
int (*notify)(struct acpi_device *, u32),
void (*uevent)(struct acpi_device *, u32));
acpi_hp_notify notify, acpi_hp_uevent uevent);
/* acpi_device.dev.bus == &acpi_bus_type */
extern const struct bus_type acpi_bus_type;
......
This diff is collapsed.
/* 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>
*/
#ifndef __ACPI_NHLT_H__
#define __ACPI_NHLT_H__
#include <linux/acpi.h>
#include <linux/kconfig.h>
#include <linux/overflow.h>
#include <linux/types.h>
#define __acpi_nhlt_endpoint_config(ep) ((void *)((ep) + 1))
#define __acpi_nhlt_config_caps(cfg) ((void *)((cfg) + 1))
/**
* acpi_nhlt_endpoint_fmtscfg - Get the formats configuration space.
* @ep: the endpoint to retrieve the space for.
*
* Return: A pointer to the formats configuration space.
*/
static inline struct acpi_nhlt_formats_config *
acpi_nhlt_endpoint_fmtscfg(const struct acpi_nhlt_endpoint *ep)
{
struct acpi_nhlt_config *cfg = __acpi_nhlt_endpoint_config(ep);
return (struct acpi_nhlt_formats_config *)((u8 *)(cfg + 1) + cfg->capabilities_size);
}
#define __acpi_nhlt_first_endpoint(tb) \
((void *)(tb + 1))
#define __acpi_nhlt_next_endpoint(ep) \
((void *)((u8 *)(ep) + (ep)->length))
#define __acpi_nhlt_get_endpoint(tb, ep, i) \
((i) ? __acpi_nhlt_next_endpoint(ep) : __acpi_nhlt_first_endpoint(tb))
#define __acpi_nhlt_first_fmtcfg(fmts) \
((void *)(fmts + 1))
#define __acpi_nhlt_next_fmtcfg(fmt) \
((void *)((u8 *)((fmt) + 1) + (fmt)->config.capabilities_size))
#define __acpi_nhlt_get_fmtcfg(fmts, fmt, i) \
((i) ? __acpi_nhlt_next_fmtcfg(fmt) : __acpi_nhlt_first_fmtcfg(fmts))
/*
* The for_each_nhlt_*() macros rely on an iterator to deal with the
* variable length of each endpoint structure and the possible presence
* of an OED-Config used by Windows only.
*/
/**
* for_each_nhlt_endpoint - Iterate over endpoints in a NHLT table.
* @tb: the pointer to a NHLT table.
* @ep: the pointer to endpoint to use as loop cursor.
*/
#define for_each_nhlt_endpoint(tb, ep) \
for (unsigned int __i = 0; \
__i < (tb)->endpoints_count && \
(ep = __acpi_nhlt_get_endpoint(tb, ep, __i)); \
__i++)
/**
* for_each_nhlt_fmtcfg - Iterate over format configurations.
* @fmts: the pointer to formats configuration space.
* @fmt: the pointer to format to use as loop cursor.
*/
#define for_each_nhlt_fmtcfg(fmts, fmt) \
for (unsigned int __i = 0; \
__i < (fmts)->formats_count && \
(fmt = __acpi_nhlt_get_fmtcfg(fmts, fmt, __i)); \
__i++)
/**
* for_each_nhlt_endpoint_fmtcfg - Iterate over format configurations in an endpoint.
* @ep: the pointer to an endpoint.
* @fmt: the pointer to format to use as loop cursor.
*/
#define for_each_nhlt_endpoint_fmtcfg(ep, fmt) \
for_each_nhlt_fmtcfg(acpi_nhlt_endpoint_fmtscfg(ep), fmt)
#if IS_ENABLED(CONFIG_ACPI_NHLT)
/*
* System-wide pointer to the first NHLT table.
*
* A sound driver may utilize acpi_nhlt_get/put_gbl_table() on its
* initialization and removal respectively to avoid excessive mapping
* and unmapping of the memory occupied by the table between streaming
* operations.
*/
acpi_status acpi_nhlt_get_gbl_table(void);
void acpi_nhlt_put_gbl_table(void);
bool acpi_nhlt_endpoint_match(const struct acpi_nhlt_endpoint *ep,
int link_type, int dev_type, int dir, int bus_id);
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);
struct acpi_nhlt_endpoint *
acpi_nhlt_find_endpoint(int link_type, int dev_type, int dir, int bus_id);
struct acpi_nhlt_format_config *
acpi_nhlt_endpoint_find_fmtcfg(const struct acpi_nhlt_endpoint *ep,
u16 ch, u32 rate, u16 vbps, u16 bps);
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 vpbs, u16 bps);
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 vpbs, u16 bps);
int acpi_nhlt_endpoint_mic_count(const struct acpi_nhlt_endpoint *ep);
#else /* !CONFIG_ACPI_NHLT */
static inline acpi_status acpi_nhlt_get_gbl_table(void)
{
return AE_NOT_FOUND;
}
static inline void acpi_nhlt_put_gbl_table(void)
{
}
static inline bool
acpi_nhlt_endpoint_match(const struct acpi_nhlt_endpoint *ep,
int link_type, int dev_type, int dir, int bus_id)
{
return false;
}
static inline 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)
{
return NULL;
}
static inline struct acpi_nhlt_format_config *
acpi_nhlt_endpoint_find_fmtcfg(const struct acpi_nhlt_endpoint *ep,
u16 ch, u32 rate, u16 vbps, u16 bps)
{
return NULL;
}
static inline 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 vpbs, u16 bps)
{
return NULL;
}
static inline int acpi_nhlt_endpoint_mic_count(const struct acpi_nhlt_endpoint *ep)
{
return 0;
}
static inline struct acpi_nhlt_endpoint *
acpi_nhlt_find_endpoint(int link_type, int dev_type, int dir, int bus_id)
{
return NULL;
}
static inline 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 vpbs, u16 bps)
{
return NULL;
}
#endif /* CONFIG_ACPI_NHLT */
#endif /* __ACPI_NHLT_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment