blob: 266e64e3c24c4fad654af09c6c70383d844166e7 [file] [log] [blame]
Kuninori Morimoto7730bb12018-07-02 06:24:04 +00001/* SPDX-License-Identifier: GPL-2.0
2 *
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -05003 * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -05004 */
5
6#ifndef __LINUX_SND_SOC_ACPI_H
7#define __LINUX_SND_SOC_ACPI_H
8
9#include <linux/stddef.h>
10#include <linux/acpi.h>
Pierre-Louis Bossart845ab402018-01-04 16:35:52 -060011#include <linux/mod_devicetable.h>
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050012
13struct snd_soc_acpi_package_context {
14 char *name; /* package name */
15 int length; /* number of elements */
16 struct acpi_buffer *format;
17 struct acpi_buffer *state;
18 bool data_valid;
19};
20
Pierre-Louis Bossart2be2d572018-01-11 13:52:09 -060021/* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */
22#define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1)
23
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050024#if IS_ENABLED(CONFIG_ACPI)
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050025bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
26 struct snd_soc_acpi_package_context *ctx);
27#else
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050028static inline bool
29snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
30 struct snd_soc_acpi_package_context *ctx)
31{
32 return false;
33}
34#endif
35
36/* acpi match */
37struct snd_soc_acpi_mach *
38snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
39
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050040/**
Pierre-Louis Bossart86792842018-11-01 16:34:48 -050041 * snd_soc_acpi_mach_params: interface for machine driver configuration
42 *
43 * @acpi_ipc_irq_index: used for BYT-CR detection
44 * @platform: string used for HDaudio codec support
45 * @codec_mask: used for HDAudio support
46 */
47struct snd_soc_acpi_mach_params {
48 u32 acpi_ipc_irq_index;
49 const char *platform;
50 u32 codec_mask;
Pierre-Louis Bossartb92826f2018-11-16 18:47:05 -060051 u32 dmic_num;
Pierre-Louis Bossart86792842018-11-01 16:34:48 -050052};
53
54/**
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050055 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
56 * related to the hardware, except for the firmware and topology file names.
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -050057 * A platform supported by legacy and Sound Open Firmware (SOF) would expose
58 * all firmware/topology related fields.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050059 *
60 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
61 * @drv_name: machine driver name
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -050062 * @fw_filename: firmware file name. Used when SOF is not enabled.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050063 * @board: board name
64 * @machine_quirk: pointer to quirk, usually based on DMI information when
65 * ACPI ID alone is not sufficient, wrong or misleading
66 * @quirk_data: data used to uniquely identify a machine, usually a list of
67 * audio codecs whose presence if checked with ACPI
68 * @pdata: intended for platform data or machine specific-ops. This structure
69 * is not constant since this field may be updated at run-time
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -050070 * @sof_fw_filename: Sound Open Firmware file name, if enabled
71 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
72 * @asoc_plat_name: ASoC platform name, used for binding machine drivers
73 * if non NULL
74 * @new_mach_data: machine driver private data fixup
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050075 */
76/* Descriptor for SST ASoC machine driver */
77struct snd_soc_acpi_mach {
78 const u8 id[ACPI_ID_LEN];
79 const char *drv_name;
80 const char *fw_filename;
81 const char *board;
82 struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
83 const void *quirk_data;
84 void *pdata;
Pierre-Louis Bossart86792842018-11-01 16:34:48 -050085 struct snd_soc_acpi_mach_params mach_params;
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -050086 const char *sof_fw_filename;
87 const char *sof_tplg_filename;
88 const char *asoc_plat_name;
89 struct platform_device * (*new_mach_data)(void *pdata);
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050090};
91
92#define SND_SOC_ACPI_MAX_CODECS 3
93
94/**
95 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
96 * apart from the matched one, this data will be passed to the quirk function
97 * to match with the ACPI detected devices
98 *
99 * @num_codecs: number of secondary codecs used in the platform
100 * @codecs: holds the codec IDs
101 *
102 */
103struct snd_soc_acpi_codecs {
104 int num_codecs;
105 u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
106};
107
108/* check all codecs */
109struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
110
111#endif