Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7feb2f78 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown
Browse files

ASoC: move ACPI common code out of Intel/sst tree



ACPI support is not specific to the Intel/SST driver. Move the enumeration
and matching code which is not hardware-dependent to sound/soc and rename
relevant sst_acpi_ structures and functions with snd_soc_acpi_ prefix

soc-acpi.h is protected by a #ifndef __LINUX_SND_SOC_ACPI_H for
consistency with all other SoC .h files:

grep -L __LINUX include/sound/soc* | wc -l
0
grep __LINUX include/sound/soc* | wc -l
14

Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: default avatarLiam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 39712db8
Loading
Loading
Loading
Loading
+100 −0
Original line number Diff line number Diff line
@@ -12,10 +12,13 @@
 *
 */

#ifndef __LINUX_SND_SOC_ACPI_H
#define __LINUX_SND_SOC_ACPI_H

#include <linux/stddef.h>
#include <linux/acpi.h>

struct sst_acpi_package_context {
struct snd_soc_acpi_package_context {
	char *name;           /* package name */
	int length;           /* number of elements */
	struct acpi_buffer *format;
@@ -25,58 +28,73 @@ struct sst_acpi_package_context {

#if IS_ENABLED(CONFIG_ACPI)
/* translation fron HID to I2C name, needed for DAI codec_name */
const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
bool sst_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
				    struct sst_acpi_package_context *ctx);
const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
				    struct snd_soc_acpi_package_context *ctx);
#else
static inline const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
static inline const char *
snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
{
	return NULL;
}
static inline bool sst_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
					   struct sst_acpi_package_context *ctx)
static inline bool
snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
				   struct snd_soc_acpi_package_context *ctx)
{
	return false;
}
#endif

/* acpi match */
struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines);
struct snd_soc_acpi_mach *
snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);

/* acpi check hid */
bool sst_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);
bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);

/**
 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
 * related to the hardware, except for the firmware and topology file names.
 *
 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
 * @drv_name: machine driver name
 * @fw_filename: firmware file name.
 * @board: board name
 * @machine_quirk: pointer to quirk, usually based on DMI information when
 * ACPI ID alone is not sufficient, wrong or misleading
 * @quirk_data: data used to uniquely identify a machine, usually a list of
 * audio codecs whose presence if checked with ACPI
 * @pdata: intended for platform data or machine specific-ops. This structure
 *  is not constant since this field may be updated at run-time
 */
/* Descriptor for SST ASoC machine driver */
struct sst_acpi_mach {
	/* ACPI ID for the matching machine driver. Audio codec for instance */
struct snd_soc_acpi_mach {
	const u8 id[ACPI_ID_LEN];
	/* machine driver name */
	const char *drv_name;
	/* firmware file name */
	const char *fw_filename;

	/* board name */
	const char *board;
	struct sst_acpi_mach * (*machine_quirk)(void *arg);
	struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
	const void *quirk_data;
	void *pdata;
};

#define SST_ACPI_MAX_CODECS 3
#define SND_SOC_ACPI_MAX_CODECS 3

/**
 * struct sst_codecs: Structure to hold secondary codec information apart from
 * the matched one, this data will be passed to the quirk function to match
 * with the ACPI detected devices
 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
 * apart from the matched one, this data will be passed to the quirk function
 * to match with the ACPI detected devices
 *
 * @num_codecs: number of secondary codecs used in the platform
 * @codecs: holds the codec IDs
 *
 */
struct sst_codecs {
struct snd_soc_acpi_codecs {
	int num_codecs;
	u8 codecs[SST_ACPI_MAX_CODECS][ACPI_ID_LEN];
	u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
};

/* check all codecs */
struct sst_acpi_mach *sst_acpi_codec_list(void *arg);
struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);

#endif
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ config SND_SOC_COMPRESS
config SND_SOC_TOPOLOGY
	bool

config SND_SOC_ACPI
	tristate

# All the supported SoCs
source "sound/soc/adi/Kconfig"
source "sound/soc/amd/Kconfig"
+6 −0
Original line number Diff line number Diff line
@@ -14,6 +14,12 @@ ifneq ($(CONFIG_SND_SOC_AC97_BUS),)
snd-soc-core-objs += soc-ac97.o
endif

ifneq ($(CONFIG_SND_SOC_ACPI),)
snd-soc-acpi-objs := soc-acpi.o
endif

obj-$(CONFIG_SND_SOC_ACPI) += snd-soc-acpi.o

obj-$(CONFIG_SND_SOC)	+= snd-soc-core.o
obj-$(CONFIG_SND_SOC)	+= codecs/
obj-$(CONFIG_SND_SOC)	+= generic/
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ config SND_SOC_INTEL_SST_ACPI

config SND_SOC_INTEL_SST_MATCH
	tristate
	select SND_SOC_ACPI if ACPI

config SND_SOC_INTEL_HASWELL
	tristate
+12 −12
Original line number Diff line number Diff line
@@ -40,9 +40,9 @@
#include <acpi/acpi_bus.h>
#include <asm/cpu_device_id.h>
#include <asm/iosf_mbi.h>
#include <sound/soc-acpi.h>
#include "../sst-mfld-platform.h"
#include "../../common/sst-dsp.h"
#include "../../common/sst-acpi.h"
#include "sst.h"

/* LPE viewpoint addresses */
@@ -284,7 +284,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
	int ret = 0;
	struct intel_sst_drv *ctx;
	const struct acpi_device_id *id;
	struct sst_acpi_mach *mach;
	struct snd_soc_acpi_mach *mach;
	struct platform_device *mdev;
	struct platform_device *plat_dev;
	struct sst_platform_info *pdata;
@@ -296,8 +296,8 @@ static int sst_acpi_probe(struct platform_device *pdev)
		return -ENODEV;
	dev_dbg(dev, "for %s\n", id->id);

	mach = (struct sst_acpi_mach *)id->driver_data;
	mach = sst_acpi_find_machine(mach);
	mach = (struct snd_soc_acpi_mach *)id->driver_data;
	mach = snd_soc_acpi_find_machine(mach);
	if (mach == NULL) {
		dev_err(dev, "No matching machine driver found\n");
		return -ENODEV;
@@ -435,7 +435,7 @@ static const struct dmi_system_id cht_table[] = {
};


static struct sst_acpi_mach cht_surface_mach = {
static struct snd_soc_acpi_mach cht_surface_mach = {
	.id = "10EC5640",
	.drv_name = "cht-bsw-rt5645",
	.fw_filename = "intel/fw_sst_22a8.bin",
@@ -443,7 +443,7 @@ static struct sst_acpi_mach cht_surface_mach = {
	.pdata = &chv_platform_data,
};

static struct sst_acpi_mach byt_thinkpad_10 = {
static struct snd_soc_acpi_mach byt_thinkpad_10 = {
	.id = "10EC5640",
	.drv_name = "cht-bsw-rt5672",
	.fw_filename = "intel/fw_sst_0f28.bin",
@@ -451,9 +451,9 @@ static struct sst_acpi_mach byt_thinkpad_10 = {
	.pdata = &byt_rvp_platform_data,
};

static struct sst_acpi_mach *cht_quirk(void *arg)
static struct snd_soc_acpi_mach *cht_quirk(void *arg)
{
	struct sst_acpi_mach *mach = arg;
	struct snd_soc_acpi_mach *mach = arg;

	dmi_check_system(cht_table);

@@ -463,9 +463,9 @@ static struct sst_acpi_mach *cht_quirk(void *arg)
		return mach;
}

static struct sst_acpi_mach *byt_quirk(void *arg)
static struct snd_soc_acpi_mach *byt_quirk(void *arg)
{
	struct sst_acpi_mach *mach = arg;
	struct snd_soc_acpi_mach *mach = arg;

	dmi_check_system(byt_table);

@@ -476,7 +476,7 @@ static struct sst_acpi_mach *byt_quirk(void *arg)
}


static struct sst_acpi_mach sst_acpi_bytcr[] = {
static struct snd_soc_acpi_mach sst_acpi_bytcr[] = {
	{
		.id = "10EC5640",
		.drv_name = "bytcr_rt5640",
@@ -560,7 +560,7 @@ static struct sst_acpi_mach sst_acpi_bytcr[] = {
};

/* Cherryview-based platforms: CherryTrail and Braswell */
static struct sst_acpi_mach sst_acpi_chv[] = {
static struct snd_soc_acpi_mach sst_acpi_chv[] = {
	{
		.id = "10EC5670",
		.drv_name = "cht-bsw-rt5672",
Loading