162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * linux/sound/soc.h -- ALSA SoC Layer
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Author:	Liam Girdwood
662306a36Sopenharmony_ci * Created:	Aug 11th 2005
762306a36Sopenharmony_ci * Copyright:	Wolfson Microelectronics. PLC.
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __LINUX_SND_SOC_H
1162306a36Sopenharmony_ci#define __LINUX_SND_SOC_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <linux/of.h>
1462306a36Sopenharmony_ci#include <linux/platform_device.h>
1562306a36Sopenharmony_ci#include <linux/types.h>
1662306a36Sopenharmony_ci#include <linux/notifier.h>
1762306a36Sopenharmony_ci#include <linux/workqueue.h>
1862306a36Sopenharmony_ci#include <linux/interrupt.h>
1962306a36Sopenharmony_ci#include <linux/kernel.h>
2062306a36Sopenharmony_ci#include <linux/regmap.h>
2162306a36Sopenharmony_ci#include <linux/log2.h>
2262306a36Sopenharmony_ci#include <sound/core.h>
2362306a36Sopenharmony_ci#include <sound/pcm.h>
2462306a36Sopenharmony_ci#include <sound/compress_driver.h>
2562306a36Sopenharmony_ci#include <sound/control.h>
2662306a36Sopenharmony_ci#include <sound/ac97_codec.h>
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/*
2962306a36Sopenharmony_ci * Convenience kcontrol builders
3062306a36Sopenharmony_ci */
3162306a36Sopenharmony_ci#define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
3262306a36Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
3362306a36Sopenharmony_ci	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
3462306a36Sopenharmony_ci	.rshift = shift_right, .max = xmax, \
3562306a36Sopenharmony_ci	.invert = xinvert, .autodisable = xautodisable})
3662306a36Sopenharmony_ci#define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
3762306a36Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
3862306a36Sopenharmony_ci	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
3962306a36Sopenharmony_ci	.rshift = shift_right, .min = xmin, .max = xmax, \
4062306a36Sopenharmony_ci	.sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
4162306a36Sopenharmony_ci#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
4262306a36Sopenharmony_ci	SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
4362306a36Sopenharmony_ci#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
4462306a36Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
4562306a36Sopenharmony_ci	{.reg = xreg, .max = xmax, .invert = xinvert})
4662306a36Sopenharmony_ci#define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
4762306a36Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
4862306a36Sopenharmony_ci	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
4962306a36Sopenharmony_ci	.max = xmax, .invert = xinvert})
5062306a36Sopenharmony_ci#define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
5162306a36Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
5262306a36Sopenharmony_ci	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
5362306a36Sopenharmony_ci	.max = xmax, .min = xmin, .sign_bit = xsign_bit, \
5462306a36Sopenharmony_ci	.invert = xinvert})
5562306a36Sopenharmony_ci#define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
5662306a36Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
5762306a36Sopenharmony_ci	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
5862306a36Sopenharmony_ci	.min = xmin, .max = xmax, .invert = xinvert})
5962306a36Sopenharmony_ci#define SOC_SINGLE(xname, reg, shift, max, invert) \
6062306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
6162306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
6262306a36Sopenharmony_ci	.put = snd_soc_put_volsw, \
6362306a36Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
6462306a36Sopenharmony_ci#define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
6562306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
6662306a36Sopenharmony_ci	.info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
6762306a36Sopenharmony_ci	.put = snd_soc_put_volsw_range, \
6862306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
6962306a36Sopenharmony_ci		{.reg = xreg, .rreg = xreg, .shift = xshift, \
7062306a36Sopenharmony_ci		 .rshift = xshift,  .min = xmin, .max = xmax, \
7162306a36Sopenharmony_ci		 .invert = xinvert} }
7262306a36Sopenharmony_ci#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
7362306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
7462306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
7562306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
7662306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
7762306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
7862306a36Sopenharmony_ci	.put = snd_soc_put_volsw, \
7962306a36Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
8062306a36Sopenharmony_ci#define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
8162306a36Sopenharmony_ci{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
8262306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
8362306a36Sopenharmony_ci	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
8462306a36Sopenharmony_ci	.tlv.p  = (tlv_array),\
8562306a36Sopenharmony_ci	.info = snd_soc_info_volsw_sx, \
8662306a36Sopenharmony_ci	.get = snd_soc_get_volsw_sx,\
8762306a36Sopenharmony_ci	.put = snd_soc_put_volsw_sx, \
8862306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
8962306a36Sopenharmony_ci		{.reg = xreg, .rreg = xreg, \
9062306a36Sopenharmony_ci		.shift = xshift, .rshift = xshift, \
9162306a36Sopenharmony_ci		.max = xmax, .min = xmin} }
9262306a36Sopenharmony_ci#define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
9362306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
9462306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
9562306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
9662306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
9762306a36Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
9862306a36Sopenharmony_ci	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
9962306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
10062306a36Sopenharmony_ci		{.reg = xreg, .rreg = xreg, .shift = xshift, \
10162306a36Sopenharmony_ci		 .rshift = xshift, .min = xmin, .max = xmax, \
10262306a36Sopenharmony_ci		 .invert = xinvert} }
10362306a36Sopenharmony_ci#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
10462306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
10562306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
10662306a36Sopenharmony_ci	.put = snd_soc_put_volsw, \
10762306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
10862306a36Sopenharmony_ci					  max, invert, 0) }
10962306a36Sopenharmony_ci#define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
11062306a36Sopenharmony_ci{									\
11162306a36Sopenharmony_ci	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),		\
11262306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,		\
11362306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_READ |				\
11462306a36Sopenharmony_ci		SNDRV_CTL_ELEM_ACCESS_VOLATILE,				\
11562306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right,	\
11662306a36Sopenharmony_ci					  max, invert, 0) }
11762306a36Sopenharmony_ci#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
11862306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
11962306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
12062306a36Sopenharmony_ci	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
12162306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
12262306a36Sopenharmony_ci					    xmax, xinvert) }
12362306a36Sopenharmony_ci#define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
12462306a36Sopenharmony_ci			   xmax, xinvert)		\
12562306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
12662306a36Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
12762306a36Sopenharmony_ci	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
12862306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
12962306a36Sopenharmony_ci					    xshift, xmin, xmax, xinvert) }
13062306a36Sopenharmony_ci#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
13162306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
13262306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
13362306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
13462306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
13562306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
13662306a36Sopenharmony_ci	.put = snd_soc_put_volsw, \
13762306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
13862306a36Sopenharmony_ci					  max, invert, 0) }
13962306a36Sopenharmony_ci#define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \
14062306a36Sopenharmony_ci{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
14162306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
14262306a36Sopenharmony_ci	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
14362306a36Sopenharmony_ci	.tlv.p  = (tlv_array), \
14462306a36Sopenharmony_ci	.info = snd_soc_info_volsw_sx, \
14562306a36Sopenharmony_ci	.get = snd_soc_get_volsw_sx, \
14662306a36Sopenharmony_ci	.put = snd_soc_put_volsw_sx, \
14762306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
14862306a36Sopenharmony_ci		{.reg = xreg, .rreg = xreg, \
14962306a36Sopenharmony_ci		.shift = shift_left, .rshift = shift_right, \
15062306a36Sopenharmony_ci		.max = xmax, .min = xmin} }
15162306a36Sopenharmony_ci#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
15262306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
15362306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
15462306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
15562306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
15662306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
15762306a36Sopenharmony_ci	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
15862306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
15962306a36Sopenharmony_ci					    xmax, xinvert) }
16062306a36Sopenharmony_ci#define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
16162306a36Sopenharmony_ci			       xmax, xinvert, tlv_array)		\
16262306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
16362306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
16462306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
16562306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
16662306a36Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
16762306a36Sopenharmony_ci	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
16862306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
16962306a36Sopenharmony_ci					    xshift, xmin, xmax, xinvert) }
17062306a36Sopenharmony_ci#define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
17162306a36Sopenharmony_ci{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
17262306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
17362306a36Sopenharmony_ci	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
17462306a36Sopenharmony_ci	.tlv.p  = (tlv_array), \
17562306a36Sopenharmony_ci	.info = snd_soc_info_volsw_sx, \
17662306a36Sopenharmony_ci	.get = snd_soc_get_volsw_sx, \
17762306a36Sopenharmony_ci	.put = snd_soc_put_volsw_sx, \
17862306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
17962306a36Sopenharmony_ci		{.reg = xreg, .rreg = xrreg, \
18062306a36Sopenharmony_ci		.shift = xshift, .rshift = xshift, \
18162306a36Sopenharmony_ci		.max = xmax, .min = xmin} }
18262306a36Sopenharmony_ci#define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
18362306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
18462306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
18562306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
18662306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
18762306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
18862306a36Sopenharmony_ci	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
18962306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
19062306a36Sopenharmony_ci					    xmin, xmax, xsign_bit, xinvert) }
19162306a36Sopenharmony_ci#define SOC_SINGLE_S_TLV(xname, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
19262306a36Sopenharmony_ci	SOC_DOUBLE_R_S_TLV(xname, xreg, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array)
19362306a36Sopenharmony_ci#define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
19462306a36Sopenharmony_ci{	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
19562306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
19662306a36Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
19762306a36Sopenharmony_ci	.tlv.p  = (tlv_array), \
19862306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
19962306a36Sopenharmony_ci	.put = snd_soc_put_volsw, \
20062306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
20162306a36Sopenharmony_ci	{.reg = xreg, .rreg = xreg,  \
20262306a36Sopenharmony_ci	 .min = xmin, .max = xmax, \
20362306a36Sopenharmony_ci	.sign_bit = 7,} }
20462306a36Sopenharmony_ci#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
20562306a36Sopenharmony_ci{	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
20662306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
20762306a36Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
20862306a36Sopenharmony_ci	.tlv.p  = (tlv_array), \
20962306a36Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
21062306a36Sopenharmony_ci	.put = snd_soc_put_volsw, \
21162306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
21262306a36Sopenharmony_ci#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
21362306a36Sopenharmony_ci{	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
21462306a36Sopenharmony_ci	.items = xitems, .texts = xtexts, \
21562306a36Sopenharmony_ci	.mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
21662306a36Sopenharmony_ci#define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
21762306a36Sopenharmony_ci	SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
21862306a36Sopenharmony_ci#define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
21962306a36Sopenharmony_ci{	.items = xitems, .texts = xtexts }
22062306a36Sopenharmony_ci#define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
22162306a36Sopenharmony_ci{	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
22262306a36Sopenharmony_ci	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
22362306a36Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
22462306a36Sopenharmony_ci	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
22562306a36Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
22662306a36Sopenharmony_ci{	.reg = xreg, .shift_l = xshift, .shift_r = xshift, \
22762306a36Sopenharmony_ci	.mask = xmask, .items = xitems, .texts = xtexts, \
22862306a36Sopenharmony_ci	.values = xvalues, .autodisable = 1}
22962306a36Sopenharmony_ci#define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
23062306a36Sopenharmony_ci	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
23162306a36Sopenharmony_ci#define SOC_ENUM(xname, xenum) \
23262306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
23362306a36Sopenharmony_ci	.info = snd_soc_info_enum_double, \
23462306a36Sopenharmony_ci	.get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
23562306a36Sopenharmony_ci	.private_value = (unsigned long)&xenum }
23662306a36Sopenharmony_ci#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
23762306a36Sopenharmony_ci	 xhandler_get, xhandler_put) \
23862306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
23962306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
24062306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
24162306a36Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
24262306a36Sopenharmony_ci#define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
24362306a36Sopenharmony_ci	 xhandler_get, xhandler_put) \
24462306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
24562306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
24662306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
24762306a36Sopenharmony_ci	.private_value = \
24862306a36Sopenharmony_ci		SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
24962306a36Sopenharmony_ci#define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
25062306a36Sopenharmony_ci	 xhandler_get, xhandler_put) \
25162306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
25262306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
25362306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
25462306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
25562306a36Sopenharmony_ci					    xmax, xinvert) }
25662306a36Sopenharmony_ci#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
25762306a36Sopenharmony_ci	 xhandler_get, xhandler_put, tlv_array) \
25862306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
25962306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
26062306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
26162306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
26262306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
26362306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
26462306a36Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
26562306a36Sopenharmony_ci#define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
26662306a36Sopenharmony_ci				 xhandler_get, xhandler_put, tlv_array) \
26762306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
26862306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
26962306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
27062306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
27162306a36Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
27262306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
27362306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
27462306a36Sopenharmony_ci		{.reg = xreg, .rreg = xreg, .shift = xshift, \
27562306a36Sopenharmony_ci		 .rshift = xshift, .min = xmin, .max = xmax, \
27662306a36Sopenharmony_ci		 .invert = xinvert} }
27762306a36Sopenharmony_ci#define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
27862306a36Sopenharmony_ci	 xhandler_get, xhandler_put, tlv_array) \
27962306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
28062306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
28162306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
28262306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
28362306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
28462306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
28562306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
28662306a36Sopenharmony_ci					  xmax, xinvert, 0) }
28762306a36Sopenharmony_ci#define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
28862306a36Sopenharmony_ci	 xhandler_get, xhandler_put, tlv_array) \
28962306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
29062306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
29162306a36Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
29262306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
29362306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
29462306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
29562306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
29662306a36Sopenharmony_ci					    xmax, xinvert) }
29762306a36Sopenharmony_ci#define SOC_DOUBLE_R_S_EXT_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, \
29862306a36Sopenharmony_ci			       xsign_bit, xinvert, xhandler_get, xhandler_put, \
29962306a36Sopenharmony_ci			       tlv_array) \
30062306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
30162306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
30262306a36Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
30362306a36Sopenharmony_ci	.tlv.p = (tlv_array), \
30462306a36Sopenharmony_ci	.info = snd_soc_info_volsw, \
30562306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
30662306a36Sopenharmony_ci	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
30762306a36Sopenharmony_ci					      xmin, xmax, xsign_bit, xinvert) }
30862306a36Sopenharmony_ci#define SOC_SINGLE_S_EXT_TLV(xname, xreg, xshift, xmin, xmax, \
30962306a36Sopenharmony_ci			     xsign_bit, xinvert, xhandler_get, xhandler_put, \
31062306a36Sopenharmony_ci			     tlv_array) \
31162306a36Sopenharmony_ci	SOC_DOUBLE_R_S_EXT_TLV(xname, xreg, xreg, xshift, xmin, xmax, \
31262306a36Sopenharmony_ci			       xsign_bit, xinvert, xhandler_get, xhandler_put, \
31362306a36Sopenharmony_ci			       tlv_array)
31462306a36Sopenharmony_ci#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
31562306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
31662306a36Sopenharmony_ci	.info = snd_soc_info_bool_ext, \
31762306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
31862306a36Sopenharmony_ci	.private_value = xdata }
31962306a36Sopenharmony_ci#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
32062306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
32162306a36Sopenharmony_ci	.info = snd_soc_info_enum_double, \
32262306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
32362306a36Sopenharmony_ci	.private_value = (unsigned long)&xenum }
32462306a36Sopenharmony_ci#define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
32562306a36Sopenharmony_ci	SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci#define SND_SOC_BYTES(xname, xbase, xregs)		      \
32862306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
32962306a36Sopenharmony_ci	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
33062306a36Sopenharmony_ci	.put = snd_soc_bytes_put, .private_value =	      \
33162306a36Sopenharmony_ci		((unsigned long)&(struct soc_bytes)           \
33262306a36Sopenharmony_ci		{.base = xbase, .num_regs = xregs }) }
33362306a36Sopenharmony_ci#define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
33462306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
33562306a36Sopenharmony_ci	.info = snd_soc_bytes_info, .get = xhandler_get, \
33662306a36Sopenharmony_ci	.put = xhandler_put, .private_value = \
33762306a36Sopenharmony_ci		((unsigned long)&(struct soc_bytes) \
33862306a36Sopenharmony_ci		{.base = xbase, .num_regs = xregs }) }
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_ci#define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)	      \
34162306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
34262306a36Sopenharmony_ci	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
34362306a36Sopenharmony_ci	.put = snd_soc_bytes_put, .private_value =	      \
34462306a36Sopenharmony_ci		((unsigned long)&(struct soc_bytes)           \
34562306a36Sopenharmony_ci		{.base = xbase, .num_regs = xregs,	      \
34662306a36Sopenharmony_ci		 .mask = xmask }) }
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci/*
34962306a36Sopenharmony_ci * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
35062306a36Sopenharmony_ci */
35162306a36Sopenharmony_ci#define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
35262306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
35362306a36Sopenharmony_ci	.info = snd_soc_bytes_info_ext, \
35462306a36Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
35562306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_bytes_ext) \
35662306a36Sopenharmony_ci		{.max = xcount} }
35762306a36Sopenharmony_ci#define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
35862306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
35962306a36Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
36062306a36Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
36162306a36Sopenharmony_ci	.tlv.c = (snd_soc_bytes_tlv_callback), \
36262306a36Sopenharmony_ci	.info = snd_soc_bytes_info_ext, \
36362306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_bytes_ext) \
36462306a36Sopenharmony_ci		{.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
36562306a36Sopenharmony_ci#define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
36662306a36Sopenharmony_ci		xmin, xmax, xinvert) \
36762306a36Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
36862306a36Sopenharmony_ci	.info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
36962306a36Sopenharmony_ci	.put = snd_soc_put_xr_sx, \
37062306a36Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mreg_control) \
37162306a36Sopenharmony_ci		{.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
37262306a36Sopenharmony_ci		.invert = xinvert, .min = xmin, .max = xmax} }
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_ci#define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
37562306a36Sopenharmony_ci	SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
37662306a36Sopenharmony_ci		snd_soc_get_strobe, snd_soc_put_strobe)
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci/*
37962306a36Sopenharmony_ci * Simplified versions of above macros, declaring a struct and calculating
38062306a36Sopenharmony_ci * ARRAY_SIZE internally
38162306a36Sopenharmony_ci */
38262306a36Sopenharmony_ci#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
38362306a36Sopenharmony_ci	const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
38462306a36Sopenharmony_ci						ARRAY_SIZE(xtexts), xtexts)
38562306a36Sopenharmony_ci#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
38662306a36Sopenharmony_ci	SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
38762306a36Sopenharmony_ci#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
38862306a36Sopenharmony_ci	const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
38962306a36Sopenharmony_ci#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
39062306a36Sopenharmony_ci	const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
39162306a36Sopenharmony_ci							ARRAY_SIZE(xtexts), xtexts, xvalues)
39262306a36Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
39362306a36Sopenharmony_ci	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
39662306a36Sopenharmony_ci	const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
39762306a36Sopenharmony_ci		xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ci#define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
40062306a36Sopenharmony_ci	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_cistruct device_node;
40362306a36Sopenharmony_cistruct snd_jack;
40462306a36Sopenharmony_cistruct snd_soc_card;
40562306a36Sopenharmony_cistruct snd_soc_pcm_stream;
40662306a36Sopenharmony_cistruct snd_soc_ops;
40762306a36Sopenharmony_cistruct snd_soc_pcm_runtime;
40862306a36Sopenharmony_cistruct snd_soc_dai;
40962306a36Sopenharmony_cistruct snd_soc_dai_driver;
41062306a36Sopenharmony_cistruct snd_soc_dai_link;
41162306a36Sopenharmony_cistruct snd_soc_component;
41262306a36Sopenharmony_cistruct snd_soc_component_driver;
41362306a36Sopenharmony_cistruct soc_enum;
41462306a36Sopenharmony_cistruct snd_soc_jack;
41562306a36Sopenharmony_cistruct snd_soc_jack_zone;
41662306a36Sopenharmony_cistruct snd_soc_jack_pin;
41762306a36Sopenharmony_ci#include <sound/soc-dapm.h>
41862306a36Sopenharmony_ci#include <sound/soc-dpcm.h>
41962306a36Sopenharmony_ci#include <sound/soc-topology.h>
42062306a36Sopenharmony_ci
42162306a36Sopenharmony_cistruct snd_soc_jack_gpio;
42262306a36Sopenharmony_ci
42362306a36Sopenharmony_cienum snd_soc_pcm_subclass {
42462306a36Sopenharmony_ci	SND_SOC_PCM_CLASS_PCM	= 0,
42562306a36Sopenharmony_ci	SND_SOC_PCM_CLASS_BE	= 1,
42662306a36Sopenharmony_ci};
42762306a36Sopenharmony_ci
42862306a36Sopenharmony_ciint snd_soc_register_card(struct snd_soc_card *card);
42962306a36Sopenharmony_civoid snd_soc_unregister_card(struct snd_soc_card *card);
43062306a36Sopenharmony_ciint devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
43162306a36Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
43262306a36Sopenharmony_ciint snd_soc_suspend(struct device *dev);
43362306a36Sopenharmony_ciint snd_soc_resume(struct device *dev);
43462306a36Sopenharmony_ci#else
43562306a36Sopenharmony_cistatic inline int snd_soc_suspend(struct device *dev)
43662306a36Sopenharmony_ci{
43762306a36Sopenharmony_ci	return 0;
43862306a36Sopenharmony_ci}
43962306a36Sopenharmony_ci
44062306a36Sopenharmony_cistatic inline int snd_soc_resume(struct device *dev)
44162306a36Sopenharmony_ci{
44262306a36Sopenharmony_ci	return 0;
44362306a36Sopenharmony_ci}
44462306a36Sopenharmony_ci#endif
44562306a36Sopenharmony_ciint snd_soc_poweroff(struct device *dev);
44662306a36Sopenharmony_ciint snd_soc_component_initialize(struct snd_soc_component *component,
44762306a36Sopenharmony_ci				 const struct snd_soc_component_driver *driver,
44862306a36Sopenharmony_ci				 struct device *dev);
44962306a36Sopenharmony_ciint snd_soc_add_component(struct snd_soc_component *component,
45062306a36Sopenharmony_ci			  struct snd_soc_dai_driver *dai_drv,
45162306a36Sopenharmony_ci			  int num_dai);
45262306a36Sopenharmony_ciint snd_soc_register_component(struct device *dev,
45362306a36Sopenharmony_ci			 const struct snd_soc_component_driver *component_driver,
45462306a36Sopenharmony_ci			 struct snd_soc_dai_driver *dai_drv, int num_dai);
45562306a36Sopenharmony_ciint devm_snd_soc_register_component(struct device *dev,
45662306a36Sopenharmony_ci			 const struct snd_soc_component_driver *component_driver,
45762306a36Sopenharmony_ci			 struct snd_soc_dai_driver *dai_drv, int num_dai);
45862306a36Sopenharmony_civoid snd_soc_unregister_component(struct device *dev);
45962306a36Sopenharmony_civoid snd_soc_unregister_component_by_driver(struct device *dev,
46062306a36Sopenharmony_ci			 const struct snd_soc_component_driver *component_driver);
46162306a36Sopenharmony_cistruct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
46262306a36Sopenharmony_ci							    const char *driver_name);
46362306a36Sopenharmony_cistruct snd_soc_component *snd_soc_lookup_component(struct device *dev,
46462306a36Sopenharmony_ci						   const char *driver_name);
46562306a36Sopenharmony_ci
46662306a36Sopenharmony_ciint soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
46762306a36Sopenharmony_ci#ifdef CONFIG_SND_SOC_COMPRESS
46862306a36Sopenharmony_ciint snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
46962306a36Sopenharmony_ci#else
47062306a36Sopenharmony_cistatic inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
47162306a36Sopenharmony_ci{
47262306a36Sopenharmony_ci	return 0;
47362306a36Sopenharmony_ci}
47462306a36Sopenharmony_ci#endif
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_civoid snd_soc_disconnect_sync(struct device *dev);
47762306a36Sopenharmony_ci
47862306a36Sopenharmony_cistruct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
47962306a36Sopenharmony_ci				struct snd_soc_dai_link *dai_link);
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_cibool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
48262306a36Sopenharmony_ci
48362306a36Sopenharmony_civoid snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
48462306a36Sopenharmony_ci			    int stream, int action);
48562306a36Sopenharmony_cistatic inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
48662306a36Sopenharmony_ci				     int stream)
48762306a36Sopenharmony_ci{
48862306a36Sopenharmony_ci	snd_soc_runtime_action(rtd, stream, 1);
48962306a36Sopenharmony_ci}
49062306a36Sopenharmony_cistatic inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
49162306a36Sopenharmony_ci				       int stream)
49262306a36Sopenharmony_ci{
49362306a36Sopenharmony_ci	snd_soc_runtime_action(rtd, stream, -1);
49462306a36Sopenharmony_ci}
49562306a36Sopenharmony_ci
49662306a36Sopenharmony_ciint snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
49762306a36Sopenharmony_ci			    struct snd_pcm_hardware *hw, int stream);
49862306a36Sopenharmony_ci
49962306a36Sopenharmony_ciint snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
50062306a36Sopenharmony_ci	unsigned int dai_fmt);
50162306a36Sopenharmony_ci
50262306a36Sopenharmony_ci#ifdef CONFIG_DMI
50362306a36Sopenharmony_ciint snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
50462306a36Sopenharmony_ci#else
50562306a36Sopenharmony_cistatic inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
50662306a36Sopenharmony_ci				       const char *flavour)
50762306a36Sopenharmony_ci{
50862306a36Sopenharmony_ci	return 0;
50962306a36Sopenharmony_ci}
51062306a36Sopenharmony_ci#endif
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ci/* Utility functions to get clock rates from various things */
51362306a36Sopenharmony_ciint snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
51462306a36Sopenharmony_ciint snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
51562306a36Sopenharmony_ciint snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
51662306a36Sopenharmony_ciint snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
51762306a36Sopenharmony_ciint snd_soc_tdm_params_to_bclk(struct snd_pcm_hw_params *params,
51862306a36Sopenharmony_ci			       int tdm_width, int tdm_slots, int slot_multiple);
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_ci/* set runtime hw params */
52162306a36Sopenharmony_ciint snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
52262306a36Sopenharmony_ci	const struct snd_pcm_hardware *hw);
52362306a36Sopenharmony_ci
52462306a36Sopenharmony_cistruct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
52562306a36Sopenharmony_cistruct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
52662306a36Sopenharmony_ci	unsigned int id, unsigned int id_mask);
52762306a36Sopenharmony_civoid snd_soc_free_ac97_component(struct snd_ac97 *ac97);
52862306a36Sopenharmony_ci
52962306a36Sopenharmony_ci#ifdef CONFIG_SND_SOC_AC97_BUS
53062306a36Sopenharmony_ciint snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
53162306a36Sopenharmony_ciint snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
53262306a36Sopenharmony_ci		struct platform_device *pdev);
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_ciextern struct snd_ac97_bus_ops *soc_ac97_ops;
53562306a36Sopenharmony_ci#else
53662306a36Sopenharmony_cistatic inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
53762306a36Sopenharmony_ci	struct platform_device *pdev)
53862306a36Sopenharmony_ci{
53962306a36Sopenharmony_ci	return 0;
54062306a36Sopenharmony_ci}
54162306a36Sopenharmony_ci
54262306a36Sopenharmony_cistatic inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
54362306a36Sopenharmony_ci{
54462306a36Sopenharmony_ci	return 0;
54562306a36Sopenharmony_ci}
54662306a36Sopenharmony_ci#endif
54762306a36Sopenharmony_ci
54862306a36Sopenharmony_ci/*
54962306a36Sopenharmony_ci *Controls
55062306a36Sopenharmony_ci */
55162306a36Sopenharmony_cistruct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
55262306a36Sopenharmony_ci				  void *data, const char *long_name,
55362306a36Sopenharmony_ci				  const char *prefix);
55462306a36Sopenharmony_ciint snd_soc_add_component_controls(struct snd_soc_component *component,
55562306a36Sopenharmony_ci	const struct snd_kcontrol_new *controls, unsigned int num_controls);
55662306a36Sopenharmony_ciint snd_soc_add_card_controls(struct snd_soc_card *soc_card,
55762306a36Sopenharmony_ci	const struct snd_kcontrol_new *controls, int num_controls);
55862306a36Sopenharmony_ciint snd_soc_add_dai_controls(struct snd_soc_dai *dai,
55962306a36Sopenharmony_ci	const struct snd_kcontrol_new *controls, int num_controls);
56062306a36Sopenharmony_ciint snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
56162306a36Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
56262306a36Sopenharmony_ciint snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
56362306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
56462306a36Sopenharmony_ciint snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
56562306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
56662306a36Sopenharmony_ciint snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
56762306a36Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
56862306a36Sopenharmony_ciint snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
56962306a36Sopenharmony_ci			  struct snd_ctl_elem_info *uinfo);
57062306a36Sopenharmony_ci#define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info
57162306a36Sopenharmony_ciint snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
57262306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
57362306a36Sopenharmony_ciint snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
57462306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
57562306a36Sopenharmony_ci#define snd_soc_get_volsw_2r snd_soc_get_volsw
57662306a36Sopenharmony_ci#define snd_soc_put_volsw_2r snd_soc_put_volsw
57762306a36Sopenharmony_ciint snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
57862306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
57962306a36Sopenharmony_ciint snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
58062306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
58162306a36Sopenharmony_ciint snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
58262306a36Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
58362306a36Sopenharmony_ciint snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
58462306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
58562306a36Sopenharmony_ciint snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
58662306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
58762306a36Sopenharmony_ciint snd_soc_limit_volume(struct snd_soc_card *card,
58862306a36Sopenharmony_ci	const char *name, int max);
58962306a36Sopenharmony_ciint snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
59062306a36Sopenharmony_ci		       struct snd_ctl_elem_info *uinfo);
59162306a36Sopenharmony_ciint snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
59262306a36Sopenharmony_ci		      struct snd_ctl_elem_value *ucontrol);
59362306a36Sopenharmony_ciint snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
59462306a36Sopenharmony_ci		      struct snd_ctl_elem_value *ucontrol);
59562306a36Sopenharmony_ciint snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
59662306a36Sopenharmony_ci	struct snd_ctl_elem_info *ucontrol);
59762306a36Sopenharmony_ciint snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
59862306a36Sopenharmony_ci	unsigned int size, unsigned int __user *tlv);
59962306a36Sopenharmony_ciint snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
60062306a36Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
60162306a36Sopenharmony_ciint snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
60262306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
60362306a36Sopenharmony_ciint snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
60462306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
60562306a36Sopenharmony_ciint snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
60662306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
60762306a36Sopenharmony_ciint snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
60862306a36Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
60962306a36Sopenharmony_ci
61062306a36Sopenharmony_cienum snd_soc_trigger_order {
61162306a36Sopenharmony_ci						/* start			stop		     */
61262306a36Sopenharmony_ci	SND_SOC_TRIGGER_ORDER_DEFAULT	= 0,	/* Link->Component->DAI		DAI->Component->Link */
61362306a36Sopenharmony_ci	SND_SOC_TRIGGER_ORDER_LDC,		/* Link->DAI->Component		Component->DAI->Link */
61462306a36Sopenharmony_ci
61562306a36Sopenharmony_ci	SND_SOC_TRIGGER_ORDER_MAX,
61662306a36Sopenharmony_ci};
61762306a36Sopenharmony_ci
61862306a36Sopenharmony_ci/* SoC PCM stream information */
61962306a36Sopenharmony_cistruct snd_soc_pcm_stream {
62062306a36Sopenharmony_ci	const char *stream_name;
62162306a36Sopenharmony_ci	u64 formats;			/* SNDRV_PCM_FMTBIT_* */
62262306a36Sopenharmony_ci	unsigned int rates;		/* SNDRV_PCM_RATE_* */
62362306a36Sopenharmony_ci	unsigned int rate_min;		/* min rate */
62462306a36Sopenharmony_ci	unsigned int rate_max;		/* max rate */
62562306a36Sopenharmony_ci	unsigned int channels_min;	/* min channels */
62662306a36Sopenharmony_ci	unsigned int channels_max;	/* max channels */
62762306a36Sopenharmony_ci	unsigned int sig_bits;		/* number of bits of content */
62862306a36Sopenharmony_ci};
62962306a36Sopenharmony_ci
63062306a36Sopenharmony_ci/* SoC audio ops */
63162306a36Sopenharmony_cistruct snd_soc_ops {
63262306a36Sopenharmony_ci	int (*startup)(struct snd_pcm_substream *);
63362306a36Sopenharmony_ci	void (*shutdown)(struct snd_pcm_substream *);
63462306a36Sopenharmony_ci	int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
63562306a36Sopenharmony_ci	int (*hw_free)(struct snd_pcm_substream *);
63662306a36Sopenharmony_ci	int (*prepare)(struct snd_pcm_substream *);
63762306a36Sopenharmony_ci	int (*trigger)(struct snd_pcm_substream *, int);
63862306a36Sopenharmony_ci};
63962306a36Sopenharmony_ci
64062306a36Sopenharmony_cistruct snd_soc_compr_ops {
64162306a36Sopenharmony_ci	int (*startup)(struct snd_compr_stream *);
64262306a36Sopenharmony_ci	void (*shutdown)(struct snd_compr_stream *);
64362306a36Sopenharmony_ci	int (*set_params)(struct snd_compr_stream *);
64462306a36Sopenharmony_ci};
64562306a36Sopenharmony_ci
64662306a36Sopenharmony_cistruct snd_soc_component*
64762306a36Sopenharmony_cisnd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
64862306a36Sopenharmony_ci		       const char *driver_name);
64962306a36Sopenharmony_ci
65062306a36Sopenharmony_cistruct snd_soc_dai_link_component {
65162306a36Sopenharmony_ci	const char *name;
65262306a36Sopenharmony_ci	struct device_node *of_node;
65362306a36Sopenharmony_ci	const char *dai_name;
65462306a36Sopenharmony_ci	struct of_phandle_args *dai_args;
65562306a36Sopenharmony_ci};
65662306a36Sopenharmony_ci
65762306a36Sopenharmony_cistruct snd_soc_dai_link_codec_ch_map {
65862306a36Sopenharmony_ci	unsigned int connected_cpu_id;
65962306a36Sopenharmony_ci	unsigned int ch_mask;
66062306a36Sopenharmony_ci};
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_cistruct snd_soc_dai_link {
66362306a36Sopenharmony_ci	/* config - must be set by machine driver */
66462306a36Sopenharmony_ci	const char *name;			/* Codec name */
66562306a36Sopenharmony_ci	const char *stream_name;		/* Stream name */
66662306a36Sopenharmony_ci
66762306a36Sopenharmony_ci	/*
66862306a36Sopenharmony_ci	 * You MAY specify the link's CPU-side device, either by device name,
66962306a36Sopenharmony_ci	 * or by DT/OF node, but not both. If this information is omitted,
67062306a36Sopenharmony_ci	 * the CPU-side DAI is matched using .cpu_dai_name only, which hence
67162306a36Sopenharmony_ci	 * must be globally unique. These fields are currently typically used
67262306a36Sopenharmony_ci	 * only for codec to codec links, or systems using device tree.
67362306a36Sopenharmony_ci	 */
67462306a36Sopenharmony_ci	/*
67562306a36Sopenharmony_ci	 * You MAY specify the DAI name of the CPU DAI. If this information is
67662306a36Sopenharmony_ci	 * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
67762306a36Sopenharmony_ci	 * only, which only works well when that device exposes a single DAI.
67862306a36Sopenharmony_ci	 */
67962306a36Sopenharmony_ci	struct snd_soc_dai_link_component *cpus;
68062306a36Sopenharmony_ci	unsigned int num_cpus;
68162306a36Sopenharmony_ci
68262306a36Sopenharmony_ci	/*
68362306a36Sopenharmony_ci	 * You MUST specify the link's codec, either by device name, or by
68462306a36Sopenharmony_ci	 * DT/OF node, but not both.
68562306a36Sopenharmony_ci	 */
68662306a36Sopenharmony_ci	/* You MUST specify the DAI name within the codec */
68762306a36Sopenharmony_ci	struct snd_soc_dai_link_component *codecs;
68862306a36Sopenharmony_ci	unsigned int num_codecs;
68962306a36Sopenharmony_ci
69062306a36Sopenharmony_ci	struct snd_soc_dai_link_codec_ch_map *codec_ch_maps;
69162306a36Sopenharmony_ci	/*
69262306a36Sopenharmony_ci	 * You MAY specify the link's platform/PCM/DMA driver, either by
69362306a36Sopenharmony_ci	 * device name, or by DT/OF node, but not both. Some forms of link
69462306a36Sopenharmony_ci	 * do not need a platform. In such case, platforms are not mandatory.
69562306a36Sopenharmony_ci	 */
69662306a36Sopenharmony_ci	struct snd_soc_dai_link_component *platforms;
69762306a36Sopenharmony_ci	unsigned int num_platforms;
69862306a36Sopenharmony_ci
69962306a36Sopenharmony_ci	int id;	/* optional ID for machine driver link identification */
70062306a36Sopenharmony_ci
70162306a36Sopenharmony_ci	/*
70262306a36Sopenharmony_ci	 * for Codec2Codec
70362306a36Sopenharmony_ci	 */
70462306a36Sopenharmony_ci	const struct snd_soc_pcm_stream *c2c_params;
70562306a36Sopenharmony_ci	unsigned int num_c2c_params;
70662306a36Sopenharmony_ci
70762306a36Sopenharmony_ci	unsigned int dai_fmt;           /* format to set on init */
70862306a36Sopenharmony_ci
70962306a36Sopenharmony_ci	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
71062306a36Sopenharmony_ci
71162306a36Sopenharmony_ci	/* codec/machine specific init - e.g. add machine controls */
71262306a36Sopenharmony_ci	int (*init)(struct snd_soc_pcm_runtime *rtd);
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_ci	/* codec/machine specific exit - dual of init() */
71562306a36Sopenharmony_ci	void (*exit)(struct snd_soc_pcm_runtime *rtd);
71662306a36Sopenharmony_ci
71762306a36Sopenharmony_ci	/* optional hw_params re-writing for BE and FE sync */
71862306a36Sopenharmony_ci	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
71962306a36Sopenharmony_ci			struct snd_pcm_hw_params *params);
72062306a36Sopenharmony_ci
72162306a36Sopenharmony_ci	/* machine stream operations */
72262306a36Sopenharmony_ci	const struct snd_soc_ops *ops;
72362306a36Sopenharmony_ci	const struct snd_soc_compr_ops *compr_ops;
72462306a36Sopenharmony_ci
72562306a36Sopenharmony_ci	/*
72662306a36Sopenharmony_ci	 * soc_pcm_trigger() start/stop sequence.
72762306a36Sopenharmony_ci	 * see also
72862306a36Sopenharmony_ci	 *	snd_soc_component_driver
72962306a36Sopenharmony_ci	 *	soc_pcm_trigger()
73062306a36Sopenharmony_ci	 */
73162306a36Sopenharmony_ci	enum snd_soc_trigger_order trigger_start;
73262306a36Sopenharmony_ci	enum snd_soc_trigger_order trigger_stop;
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci	/* Mark this pcm with non atomic ops */
73562306a36Sopenharmony_ci	unsigned int nonatomic:1;
73662306a36Sopenharmony_ci
73762306a36Sopenharmony_ci	/* For unidirectional dai links */
73862306a36Sopenharmony_ci	unsigned int playback_only:1;
73962306a36Sopenharmony_ci	unsigned int capture_only:1;
74062306a36Sopenharmony_ci
74162306a36Sopenharmony_ci	/* Keep DAI active over suspend */
74262306a36Sopenharmony_ci	unsigned int ignore_suspend:1;
74362306a36Sopenharmony_ci
74462306a36Sopenharmony_ci	/* Symmetry requirements */
74562306a36Sopenharmony_ci	unsigned int symmetric_rate:1;
74662306a36Sopenharmony_ci	unsigned int symmetric_channels:1;
74762306a36Sopenharmony_ci	unsigned int symmetric_sample_bits:1;
74862306a36Sopenharmony_ci
74962306a36Sopenharmony_ci	/* Do not create a PCM for this DAI link (Backend link) */
75062306a36Sopenharmony_ci	unsigned int no_pcm:1;
75162306a36Sopenharmony_ci
75262306a36Sopenharmony_ci	/* This DAI link can route to other DAI links at runtime (Frontend)*/
75362306a36Sopenharmony_ci	unsigned int dynamic:1;
75462306a36Sopenharmony_ci
75562306a36Sopenharmony_ci	/* DPCM capture and Playback support */
75662306a36Sopenharmony_ci	unsigned int dpcm_capture:1;
75762306a36Sopenharmony_ci	unsigned int dpcm_playback:1;
75862306a36Sopenharmony_ci
75962306a36Sopenharmony_ci	/* DPCM used FE & BE merged format */
76062306a36Sopenharmony_ci	unsigned int dpcm_merged_format:1;
76162306a36Sopenharmony_ci	/* DPCM used FE & BE merged channel */
76262306a36Sopenharmony_ci	unsigned int dpcm_merged_chan:1;
76362306a36Sopenharmony_ci	/* DPCM used FE & BE merged rate */
76462306a36Sopenharmony_ci	unsigned int dpcm_merged_rate:1;
76562306a36Sopenharmony_ci
76662306a36Sopenharmony_ci	/* pmdown_time is ignored at stop */
76762306a36Sopenharmony_ci	unsigned int ignore_pmdown_time:1;
76862306a36Sopenharmony_ci
76962306a36Sopenharmony_ci	/* Do not create a PCM for this DAI link (Backend link) */
77062306a36Sopenharmony_ci	unsigned int ignore:1;
77162306a36Sopenharmony_ci
77262306a36Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
77362306a36Sopenharmony_ci	struct snd_soc_dobj dobj; /* For topology */
77462306a36Sopenharmony_ci#endif
77562306a36Sopenharmony_ci};
77662306a36Sopenharmony_ci
77762306a36Sopenharmony_ci/* REMOVE ME */
77862306a36Sopenharmony_ci#define asoc_link_to_cpu	snd_soc_link_to_cpu
77962306a36Sopenharmony_ci#define asoc_link_to_codec	snd_soc_link_to_codec
78062306a36Sopenharmony_ci#define asoc_link_to_platform	snd_soc_link_to_platform
78162306a36Sopenharmony_ci
78262306a36Sopenharmony_cistatic inline struct snd_soc_dai_link_component*
78362306a36Sopenharmony_cisnd_soc_link_to_cpu(struct snd_soc_dai_link *link, int n) {
78462306a36Sopenharmony_ci	return &(link)->cpus[n];
78562306a36Sopenharmony_ci}
78662306a36Sopenharmony_ci
78762306a36Sopenharmony_cistatic inline struct snd_soc_dai_link_component*
78862306a36Sopenharmony_cisnd_soc_link_to_codec(struct snd_soc_dai_link *link, int n) {
78962306a36Sopenharmony_ci	return &(link)->codecs[n];
79062306a36Sopenharmony_ci}
79162306a36Sopenharmony_ci
79262306a36Sopenharmony_cistatic inline struct snd_soc_dai_link_component*
79362306a36Sopenharmony_cisnd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
79462306a36Sopenharmony_ci	return &(link)->platforms[n];
79562306a36Sopenharmony_ci}
79662306a36Sopenharmony_ci
79762306a36Sopenharmony_ci#define for_each_link_codecs(link, i, codec)				\
79862306a36Sopenharmony_ci	for ((i) = 0;							\
79962306a36Sopenharmony_ci	     ((i) < link->num_codecs) &&				\
80062306a36Sopenharmony_ci		     ((codec) = snd_soc_link_to_codec(link, i));		\
80162306a36Sopenharmony_ci	     (i)++)
80262306a36Sopenharmony_ci
80362306a36Sopenharmony_ci#define for_each_link_platforms(link, i, platform)			\
80462306a36Sopenharmony_ci	for ((i) = 0;							\
80562306a36Sopenharmony_ci	     ((i) < link->num_platforms) &&				\
80662306a36Sopenharmony_ci		     ((platform) = snd_soc_link_to_platform(link, i));	\
80762306a36Sopenharmony_ci	     (i)++)
80862306a36Sopenharmony_ci
80962306a36Sopenharmony_ci#define for_each_link_cpus(link, i, cpu)				\
81062306a36Sopenharmony_ci	for ((i) = 0;							\
81162306a36Sopenharmony_ci	     ((i) < link->num_cpus) &&					\
81262306a36Sopenharmony_ci		     ((cpu) = snd_soc_link_to_cpu(link, i));		\
81362306a36Sopenharmony_ci	     (i)++)
81462306a36Sopenharmony_ci
81562306a36Sopenharmony_ci/*
81662306a36Sopenharmony_ci * Sample 1 : Single CPU/Codec/Platform
81762306a36Sopenharmony_ci *
81862306a36Sopenharmony_ci * SND_SOC_DAILINK_DEFS(test,
81962306a36Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
82062306a36Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
82162306a36Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
82262306a36Sopenharmony_ci *
82362306a36Sopenharmony_ci * struct snd_soc_dai_link link = {
82462306a36Sopenharmony_ci *	...
82562306a36Sopenharmony_ci *	SND_SOC_DAILINK_REG(test),
82662306a36Sopenharmony_ci * };
82762306a36Sopenharmony_ci *
82862306a36Sopenharmony_ci * Sample 2 : Multi CPU/Codec, no Platform
82962306a36Sopenharmony_ci *
83062306a36Sopenharmony_ci * SND_SOC_DAILINK_DEFS(test,
83162306a36Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
83262306a36Sopenharmony_ci *			   COMP_CPU("cpu_dai2")),
83362306a36Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
83462306a36Sopenharmony_ci *			   COMP_CODEC("codec2", "codec_dai2")));
83562306a36Sopenharmony_ci *
83662306a36Sopenharmony_ci * struct snd_soc_dai_link link = {
83762306a36Sopenharmony_ci *	...
83862306a36Sopenharmony_ci *	SND_SOC_DAILINK_REG(test),
83962306a36Sopenharmony_ci * };
84062306a36Sopenharmony_ci *
84162306a36Sopenharmony_ci * Sample 3 : Define each CPU/Codec/Platform manually
84262306a36Sopenharmony_ci *
84362306a36Sopenharmony_ci * SND_SOC_DAILINK_DEF(test_cpu,
84462306a36Sopenharmony_ci *		DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
84562306a36Sopenharmony_ci *				   COMP_CPU("cpu_dai2")));
84662306a36Sopenharmony_ci * SND_SOC_DAILINK_DEF(test_codec,
84762306a36Sopenharmony_ci *		DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
84862306a36Sopenharmony_ci *				   COMP_CODEC("codec2", "codec_dai2")));
84962306a36Sopenharmony_ci * SND_SOC_DAILINK_DEF(test_platform,
85062306a36Sopenharmony_ci *		DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
85162306a36Sopenharmony_ci *
85262306a36Sopenharmony_ci * struct snd_soc_dai_link link = {
85362306a36Sopenharmony_ci *	...
85462306a36Sopenharmony_ci *	SND_SOC_DAILINK_REG(test_cpu,
85562306a36Sopenharmony_ci *			    test_codec,
85662306a36Sopenharmony_ci *			    test_platform),
85762306a36Sopenharmony_ci * };
85862306a36Sopenharmony_ci *
85962306a36Sopenharmony_ci * Sample 4 : Sample3 without platform
86062306a36Sopenharmony_ci *
86162306a36Sopenharmony_ci * struct snd_soc_dai_link link = {
86262306a36Sopenharmony_ci *	...
86362306a36Sopenharmony_ci *	SND_SOC_DAILINK_REG(test_cpu,
86462306a36Sopenharmony_ci *			    test_codec);
86562306a36Sopenharmony_ci * };
86662306a36Sopenharmony_ci */
86762306a36Sopenharmony_ci
86862306a36Sopenharmony_ci#define SND_SOC_DAILINK_REG1(name)	 SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
86962306a36Sopenharmony_ci#define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
87062306a36Sopenharmony_ci#define SND_SOC_DAILINK_REG3(cpu, codec, platform)	\
87162306a36Sopenharmony_ci	.cpus		= cpu,				\
87262306a36Sopenharmony_ci	.num_cpus	= ARRAY_SIZE(cpu),		\
87362306a36Sopenharmony_ci	.codecs		= codec,			\
87462306a36Sopenharmony_ci	.num_codecs	= ARRAY_SIZE(codec),		\
87562306a36Sopenharmony_ci	.platforms	= platform,			\
87662306a36Sopenharmony_ci	.num_platforms	= ARRAY_SIZE(platform)
87762306a36Sopenharmony_ci
87862306a36Sopenharmony_ci#define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
87962306a36Sopenharmony_ci#define SND_SOC_DAILINK_REG(...) \
88062306a36Sopenharmony_ci	SND_SOC_DAILINK_REGx(__VA_ARGS__,		\
88162306a36Sopenharmony_ci			SND_SOC_DAILINK_REG3,	\
88262306a36Sopenharmony_ci			SND_SOC_DAILINK_REG2,	\
88362306a36Sopenharmony_ci			SND_SOC_DAILINK_REG1)(__VA_ARGS__)
88462306a36Sopenharmony_ci
88562306a36Sopenharmony_ci#define SND_SOC_DAILINK_DEF(name, def...)		\
88662306a36Sopenharmony_ci	static struct snd_soc_dai_link_component name[]	= { def }
88762306a36Sopenharmony_ci
88862306a36Sopenharmony_ci#define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...)	\
88962306a36Sopenharmony_ci	SND_SOC_DAILINK_DEF(name##_cpus, cpu);			\
89062306a36Sopenharmony_ci	SND_SOC_DAILINK_DEF(name##_codecs, codec);		\
89162306a36Sopenharmony_ci	SND_SOC_DAILINK_DEF(name##_platforms, platform)
89262306a36Sopenharmony_ci
89362306a36Sopenharmony_ci#define DAILINK_COMP_ARRAY(param...)	param
89462306a36Sopenharmony_ci#define COMP_EMPTY()			{ }
89562306a36Sopenharmony_ci#define COMP_CPU(_dai)			{ .dai_name = _dai, }
89662306a36Sopenharmony_ci#define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
89762306a36Sopenharmony_ci#define COMP_PLATFORM(_name)		{ .name = _name }
89862306a36Sopenharmony_ci#define COMP_AUX(_name)			{ .name = _name }
89962306a36Sopenharmony_ci#define COMP_CODEC_CONF(_name)		{ .name = _name }
90062306a36Sopenharmony_ci#define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
90162306a36Sopenharmony_ci
90262306a36Sopenharmony_ci/* REMOVE ME */
90362306a36Sopenharmony_ci#define asoc_dummy_dlc		snd_soc_dummy_dlc
90462306a36Sopenharmony_ci
90562306a36Sopenharmony_ciextern struct snd_soc_dai_link_component null_dailink_component[0];
90662306a36Sopenharmony_ciextern struct snd_soc_dai_link_component snd_soc_dummy_dlc;
90762306a36Sopenharmony_ci
90862306a36Sopenharmony_ci
90962306a36Sopenharmony_cistruct snd_soc_codec_conf {
91062306a36Sopenharmony_ci	/*
91162306a36Sopenharmony_ci	 * specify device either by device name, or by
91262306a36Sopenharmony_ci	 * DT/OF node, but not both.
91362306a36Sopenharmony_ci	 */
91462306a36Sopenharmony_ci	struct snd_soc_dai_link_component dlc;
91562306a36Sopenharmony_ci
91662306a36Sopenharmony_ci	/*
91762306a36Sopenharmony_ci	 * optional map of kcontrol, widget and path name prefixes that are
91862306a36Sopenharmony_ci	 * associated per device
91962306a36Sopenharmony_ci	 */
92062306a36Sopenharmony_ci	const char *name_prefix;
92162306a36Sopenharmony_ci};
92262306a36Sopenharmony_ci
92362306a36Sopenharmony_cistruct snd_soc_aux_dev {
92462306a36Sopenharmony_ci	/*
92562306a36Sopenharmony_ci	 * specify multi-codec either by device name, or by
92662306a36Sopenharmony_ci	 * DT/OF node, but not both.
92762306a36Sopenharmony_ci	 */
92862306a36Sopenharmony_ci	struct snd_soc_dai_link_component dlc;
92962306a36Sopenharmony_ci
93062306a36Sopenharmony_ci	/* codec/machine specific init - e.g. add machine controls */
93162306a36Sopenharmony_ci	int (*init)(struct snd_soc_component *component);
93262306a36Sopenharmony_ci};
93362306a36Sopenharmony_ci
93462306a36Sopenharmony_ci/* SoC card */
93562306a36Sopenharmony_cistruct snd_soc_card {
93662306a36Sopenharmony_ci	const char *name;
93762306a36Sopenharmony_ci	const char *long_name;
93862306a36Sopenharmony_ci	const char *driver_name;
93962306a36Sopenharmony_ci	const char *components;
94062306a36Sopenharmony_ci#ifdef CONFIG_DMI
94162306a36Sopenharmony_ci	char dmi_longname[80];
94262306a36Sopenharmony_ci#endif /* CONFIG_DMI */
94362306a36Sopenharmony_ci
94462306a36Sopenharmony_ci#ifdef CONFIG_PCI
94562306a36Sopenharmony_ci	/*
94662306a36Sopenharmony_ci	 * PCI does not define 0 as invalid, so pci_subsystem_set indicates
94762306a36Sopenharmony_ci	 * whether a value has been written to these fields.
94862306a36Sopenharmony_ci	 */
94962306a36Sopenharmony_ci	unsigned short pci_subsystem_vendor;
95062306a36Sopenharmony_ci	unsigned short pci_subsystem_device;
95162306a36Sopenharmony_ci	bool pci_subsystem_set;
95262306a36Sopenharmony_ci#endif /* CONFIG_PCI */
95362306a36Sopenharmony_ci
95462306a36Sopenharmony_ci	char topology_shortname[32];
95562306a36Sopenharmony_ci
95662306a36Sopenharmony_ci	struct device *dev;
95762306a36Sopenharmony_ci	struct snd_card *snd_card;
95862306a36Sopenharmony_ci	struct module *owner;
95962306a36Sopenharmony_ci
96062306a36Sopenharmony_ci	struct mutex mutex;
96162306a36Sopenharmony_ci	struct mutex dapm_mutex;
96262306a36Sopenharmony_ci
96362306a36Sopenharmony_ci	/* Mutex for PCM operations */
96462306a36Sopenharmony_ci	struct mutex pcm_mutex;
96562306a36Sopenharmony_ci	enum snd_soc_pcm_subclass pcm_subclass;
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_ci	int (*probe)(struct snd_soc_card *card);
96862306a36Sopenharmony_ci	int (*late_probe)(struct snd_soc_card *card);
96962306a36Sopenharmony_ci	void (*fixup_controls)(struct snd_soc_card *card);
97062306a36Sopenharmony_ci	int (*remove)(struct snd_soc_card *card);
97162306a36Sopenharmony_ci
97262306a36Sopenharmony_ci	/* the pre and post PM functions are used to do any PM work before and
97362306a36Sopenharmony_ci	 * after the codec and DAI's do any PM work. */
97462306a36Sopenharmony_ci	int (*suspend_pre)(struct snd_soc_card *card);
97562306a36Sopenharmony_ci	int (*suspend_post)(struct snd_soc_card *card);
97662306a36Sopenharmony_ci	int (*resume_pre)(struct snd_soc_card *card);
97762306a36Sopenharmony_ci	int (*resume_post)(struct snd_soc_card *card);
97862306a36Sopenharmony_ci
97962306a36Sopenharmony_ci	/* callbacks */
98062306a36Sopenharmony_ci	int (*set_bias_level)(struct snd_soc_card *,
98162306a36Sopenharmony_ci			      struct snd_soc_dapm_context *dapm,
98262306a36Sopenharmony_ci			      enum snd_soc_bias_level level);
98362306a36Sopenharmony_ci	int (*set_bias_level_post)(struct snd_soc_card *,
98462306a36Sopenharmony_ci				   struct snd_soc_dapm_context *dapm,
98562306a36Sopenharmony_ci				   enum snd_soc_bias_level level);
98662306a36Sopenharmony_ci
98762306a36Sopenharmony_ci	int (*add_dai_link)(struct snd_soc_card *,
98862306a36Sopenharmony_ci			    struct snd_soc_dai_link *link);
98962306a36Sopenharmony_ci	void (*remove_dai_link)(struct snd_soc_card *,
99062306a36Sopenharmony_ci			    struct snd_soc_dai_link *link);
99162306a36Sopenharmony_ci
99262306a36Sopenharmony_ci	long pmdown_time;
99362306a36Sopenharmony_ci
99462306a36Sopenharmony_ci	/* CPU <--> Codec DAI links  */
99562306a36Sopenharmony_ci	struct snd_soc_dai_link *dai_link;  /* predefined links only */
99662306a36Sopenharmony_ci	int num_links;  /* predefined links only */
99762306a36Sopenharmony_ci
99862306a36Sopenharmony_ci	struct list_head rtd_list;
99962306a36Sopenharmony_ci	int num_rtd;
100062306a36Sopenharmony_ci
100162306a36Sopenharmony_ci	/* optional codec specific configuration */
100262306a36Sopenharmony_ci	struct snd_soc_codec_conf *codec_conf;
100362306a36Sopenharmony_ci	int num_configs;
100462306a36Sopenharmony_ci
100562306a36Sopenharmony_ci	/*
100662306a36Sopenharmony_ci	 * optional auxiliary devices such as amplifiers or codecs with DAI
100762306a36Sopenharmony_ci	 * link unused
100862306a36Sopenharmony_ci	 */
100962306a36Sopenharmony_ci	struct snd_soc_aux_dev *aux_dev;
101062306a36Sopenharmony_ci	int num_aux_devs;
101162306a36Sopenharmony_ci	struct list_head aux_comp_list;
101262306a36Sopenharmony_ci
101362306a36Sopenharmony_ci	const struct snd_kcontrol_new *controls;
101462306a36Sopenharmony_ci	int num_controls;
101562306a36Sopenharmony_ci
101662306a36Sopenharmony_ci	/*
101762306a36Sopenharmony_ci	 * Card-specific routes and widgets.
101862306a36Sopenharmony_ci	 * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
101962306a36Sopenharmony_ci	 */
102062306a36Sopenharmony_ci	const struct snd_soc_dapm_widget *dapm_widgets;
102162306a36Sopenharmony_ci	int num_dapm_widgets;
102262306a36Sopenharmony_ci	const struct snd_soc_dapm_route *dapm_routes;
102362306a36Sopenharmony_ci	int num_dapm_routes;
102462306a36Sopenharmony_ci	const struct snd_soc_dapm_widget *of_dapm_widgets;
102562306a36Sopenharmony_ci	int num_of_dapm_widgets;
102662306a36Sopenharmony_ci	const struct snd_soc_dapm_route *of_dapm_routes;
102762306a36Sopenharmony_ci	int num_of_dapm_routes;
102862306a36Sopenharmony_ci
102962306a36Sopenharmony_ci	/* lists of probed devices belonging to this card */
103062306a36Sopenharmony_ci	struct list_head component_dev_list;
103162306a36Sopenharmony_ci	struct list_head list;
103262306a36Sopenharmony_ci
103362306a36Sopenharmony_ci	struct list_head widgets;
103462306a36Sopenharmony_ci	struct list_head paths;
103562306a36Sopenharmony_ci	struct list_head dapm_list;
103662306a36Sopenharmony_ci	struct list_head dapm_dirty;
103762306a36Sopenharmony_ci
103862306a36Sopenharmony_ci	/* attached dynamic objects */
103962306a36Sopenharmony_ci	struct list_head dobj_list;
104062306a36Sopenharmony_ci
104162306a36Sopenharmony_ci	/* Generic DAPM context for the card */
104262306a36Sopenharmony_ci	struct snd_soc_dapm_context dapm;
104362306a36Sopenharmony_ci	struct snd_soc_dapm_stats dapm_stats;
104462306a36Sopenharmony_ci	struct snd_soc_dapm_update *update;
104562306a36Sopenharmony_ci
104662306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
104762306a36Sopenharmony_ci	struct dentry *debugfs_card_root;
104862306a36Sopenharmony_ci#endif
104962306a36Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
105062306a36Sopenharmony_ci	struct work_struct deferred_resume_work;
105162306a36Sopenharmony_ci#endif
105262306a36Sopenharmony_ci	u32 pop_time;
105362306a36Sopenharmony_ci
105462306a36Sopenharmony_ci	/* bit field */
105562306a36Sopenharmony_ci	unsigned int instantiated:1;
105662306a36Sopenharmony_ci	unsigned int topology_shortname_created:1;
105762306a36Sopenharmony_ci	unsigned int fully_routed:1;
105862306a36Sopenharmony_ci	unsigned int disable_route_checks:1;
105962306a36Sopenharmony_ci	unsigned int probed:1;
106062306a36Sopenharmony_ci	unsigned int component_chaining:1;
106162306a36Sopenharmony_ci
106262306a36Sopenharmony_ci	void *drvdata;
106362306a36Sopenharmony_ci};
106462306a36Sopenharmony_ci#define for_each_card_prelinks(card, i, link)				\
106562306a36Sopenharmony_ci	for ((i) = 0;							\
106662306a36Sopenharmony_ci	     ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
106762306a36Sopenharmony_ci	     (i)++)
106862306a36Sopenharmony_ci#define for_each_card_pre_auxs(card, i, aux)				\
106962306a36Sopenharmony_ci	for ((i) = 0;							\
107062306a36Sopenharmony_ci	     ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
107162306a36Sopenharmony_ci	     (i)++)
107262306a36Sopenharmony_ci
107362306a36Sopenharmony_ci#define for_each_card_rtds(card, rtd)			\
107462306a36Sopenharmony_ci	list_for_each_entry(rtd, &(card)->rtd_list, list)
107562306a36Sopenharmony_ci#define for_each_card_rtds_safe(card, rtd, _rtd)	\
107662306a36Sopenharmony_ci	list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
107762306a36Sopenharmony_ci
107862306a36Sopenharmony_ci#define for_each_card_auxs(card, component)			\
107962306a36Sopenharmony_ci	list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
108062306a36Sopenharmony_ci#define for_each_card_auxs_safe(card, component, _comp)	\
108162306a36Sopenharmony_ci	list_for_each_entry_safe(component, _comp,	\
108262306a36Sopenharmony_ci				 &card->aux_comp_list, card_aux_list)
108362306a36Sopenharmony_ci
108462306a36Sopenharmony_ci#define for_each_card_components(card, component)			\
108562306a36Sopenharmony_ci	list_for_each_entry(component, &(card)->component_dev_list, card_list)
108662306a36Sopenharmony_ci
108762306a36Sopenharmony_ci#define for_each_card_dapms(card, dapm)					\
108862306a36Sopenharmony_ci	list_for_each_entry(dapm, &card->dapm_list, list)
108962306a36Sopenharmony_ci
109062306a36Sopenharmony_ci#define for_each_card_widgets(card, w)\
109162306a36Sopenharmony_ci	list_for_each_entry(w, &card->widgets, list)
109262306a36Sopenharmony_ci#define for_each_card_widgets_safe(card, w, _w)	\
109362306a36Sopenharmony_ci	list_for_each_entry_safe(w, _w, &card->widgets, list)
109462306a36Sopenharmony_ci
109562306a36Sopenharmony_ci
109662306a36Sopenharmony_cistatic inline int snd_soc_card_is_instantiated(struct snd_soc_card *card)
109762306a36Sopenharmony_ci{
109862306a36Sopenharmony_ci	return card && card->instantiated;
109962306a36Sopenharmony_ci}
110062306a36Sopenharmony_ci
110162306a36Sopenharmony_ci/* SoC machine DAI configuration, glues a codec and cpu DAI together */
110262306a36Sopenharmony_cistruct snd_soc_pcm_runtime {
110362306a36Sopenharmony_ci	struct device *dev;
110462306a36Sopenharmony_ci	struct snd_soc_card *card;
110562306a36Sopenharmony_ci	struct snd_soc_dai_link *dai_link;
110662306a36Sopenharmony_ci	struct snd_pcm_ops ops;
110762306a36Sopenharmony_ci
110862306a36Sopenharmony_ci	unsigned int c2c_params_select; /* currently selected c2c_param for dai link */
110962306a36Sopenharmony_ci
111062306a36Sopenharmony_ci	/* Dynamic PCM BE runtime data */
111162306a36Sopenharmony_ci	struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
111262306a36Sopenharmony_ci	struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1];
111362306a36Sopenharmony_ci
111462306a36Sopenharmony_ci	long pmdown_time;
111562306a36Sopenharmony_ci
111662306a36Sopenharmony_ci	/* runtime devices */
111762306a36Sopenharmony_ci	struct snd_pcm *pcm;
111862306a36Sopenharmony_ci	struct snd_compr *compr;
111962306a36Sopenharmony_ci
112062306a36Sopenharmony_ci	/*
112162306a36Sopenharmony_ci	 * dais = cpu_dai + codec_dai
112262306a36Sopenharmony_ci	 * see
112362306a36Sopenharmony_ci	 *	soc_new_pcm_runtime()
112462306a36Sopenharmony_ci	 *	snd_soc_rtd_to_cpu()
112562306a36Sopenharmony_ci	 *	snd_soc_rtd_to_codec()
112662306a36Sopenharmony_ci	 */
112762306a36Sopenharmony_ci	struct snd_soc_dai **dais;
112862306a36Sopenharmony_ci
112962306a36Sopenharmony_ci	struct delayed_work delayed_work;
113062306a36Sopenharmony_ci	void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
113162306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
113262306a36Sopenharmony_ci	struct dentry *debugfs_dpcm_root;
113362306a36Sopenharmony_ci#endif
113462306a36Sopenharmony_ci
113562306a36Sopenharmony_ci	unsigned int num; /* 0-based and monotonic increasing */
113662306a36Sopenharmony_ci	struct list_head list; /* rtd list of the soc card */
113762306a36Sopenharmony_ci
113862306a36Sopenharmony_ci	/* function mark */
113962306a36Sopenharmony_ci	struct snd_pcm_substream *mark_startup;
114062306a36Sopenharmony_ci	struct snd_pcm_substream *mark_hw_params;
114162306a36Sopenharmony_ci	struct snd_pcm_substream *mark_trigger;
114262306a36Sopenharmony_ci	struct snd_compr_stream  *mark_compr_startup;
114362306a36Sopenharmony_ci
114462306a36Sopenharmony_ci	/* bit field */
114562306a36Sopenharmony_ci	unsigned int pop_wait:1;
114662306a36Sopenharmony_ci	unsigned int fe_compr:1; /* for Dynamic PCM */
114762306a36Sopenharmony_ci
114862306a36Sopenharmony_ci	bool initialized;
114962306a36Sopenharmony_ci
115062306a36Sopenharmony_ci	int num_components;
115162306a36Sopenharmony_ci	struct snd_soc_component *components[]; /* CPU/Codec/Platform */
115262306a36Sopenharmony_ci};
115362306a36Sopenharmony_ci
115462306a36Sopenharmony_ci/* REMOVE ME */
115562306a36Sopenharmony_ci#define asoc_rtd_to_cpu		snd_soc_rtd_to_cpu
115662306a36Sopenharmony_ci#define asoc_rtd_to_codec	snd_soc_rtd_to_codec
115762306a36Sopenharmony_ci#define asoc_substream_to_rtd	snd_soc_substream_to_rtd
115862306a36Sopenharmony_ci
115962306a36Sopenharmony_ci/* see soc_new_pcm_runtime()  */
116062306a36Sopenharmony_ci#define snd_soc_rtd_to_cpu(rtd, n)   (rtd)->dais[n]
116162306a36Sopenharmony_ci#define snd_soc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus]
116262306a36Sopenharmony_ci#define snd_soc_substream_to_rtd(substream) \
116362306a36Sopenharmony_ci	(struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
116462306a36Sopenharmony_ci
116562306a36Sopenharmony_ci#define for_each_rtd_components(rtd, i, component)			\
116662306a36Sopenharmony_ci	for ((i) = 0, component = NULL;					\
116762306a36Sopenharmony_ci	     ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
116862306a36Sopenharmony_ci	     (i)++)
116962306a36Sopenharmony_ci#define for_each_rtd_cpu_dais(rtd, i, dai)				\
117062306a36Sopenharmony_ci	for ((i) = 0;							\
117162306a36Sopenharmony_ci	     ((i) < rtd->dai_link->num_cpus) && ((dai) = snd_soc_rtd_to_cpu(rtd, i)); \
117262306a36Sopenharmony_ci	     (i)++)
117362306a36Sopenharmony_ci#define for_each_rtd_codec_dais(rtd, i, dai)				\
117462306a36Sopenharmony_ci	for ((i) = 0;							\
117562306a36Sopenharmony_ci	     ((i) < rtd->dai_link->num_codecs) && ((dai) = snd_soc_rtd_to_codec(rtd, i)); \
117662306a36Sopenharmony_ci	     (i)++)
117762306a36Sopenharmony_ci#define for_each_rtd_dais(rtd, i, dai)					\
117862306a36Sopenharmony_ci	for ((i) = 0;							\
117962306a36Sopenharmony_ci	     ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) &&	\
118062306a36Sopenharmony_ci		     ((dai) = (rtd)->dais[i]);				\
118162306a36Sopenharmony_ci	     (i)++)
118262306a36Sopenharmony_ci
118362306a36Sopenharmony_civoid snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
118462306a36Sopenharmony_ci
118562306a36Sopenharmony_ci/* mixer control */
118662306a36Sopenharmony_cistruct soc_mixer_control {
118762306a36Sopenharmony_ci	int min, max, platform_max;
118862306a36Sopenharmony_ci	int reg, rreg;
118962306a36Sopenharmony_ci	unsigned int shift, rshift;
119062306a36Sopenharmony_ci	unsigned int sign_bit;
119162306a36Sopenharmony_ci	unsigned int invert:1;
119262306a36Sopenharmony_ci	unsigned int autodisable:1;
119362306a36Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
119462306a36Sopenharmony_ci	struct snd_soc_dobj dobj;
119562306a36Sopenharmony_ci#endif
119662306a36Sopenharmony_ci};
119762306a36Sopenharmony_ci
119862306a36Sopenharmony_cistruct soc_bytes {
119962306a36Sopenharmony_ci	int base;
120062306a36Sopenharmony_ci	int num_regs;
120162306a36Sopenharmony_ci	u32 mask;
120262306a36Sopenharmony_ci};
120362306a36Sopenharmony_ci
120462306a36Sopenharmony_cistruct soc_bytes_ext {
120562306a36Sopenharmony_ci	int max;
120662306a36Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
120762306a36Sopenharmony_ci	struct snd_soc_dobj dobj;
120862306a36Sopenharmony_ci#endif
120962306a36Sopenharmony_ci	/* used for TLV byte control */
121062306a36Sopenharmony_ci	int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
121162306a36Sopenharmony_ci			unsigned int size);
121262306a36Sopenharmony_ci	int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
121362306a36Sopenharmony_ci			unsigned int size);
121462306a36Sopenharmony_ci};
121562306a36Sopenharmony_ci
121662306a36Sopenharmony_ci/* multi register control */
121762306a36Sopenharmony_cistruct soc_mreg_control {
121862306a36Sopenharmony_ci	long min, max;
121962306a36Sopenharmony_ci	unsigned int regbase, regcount, nbits, invert;
122062306a36Sopenharmony_ci};
122162306a36Sopenharmony_ci
122262306a36Sopenharmony_ci/* enumerated kcontrol */
122362306a36Sopenharmony_cistruct soc_enum {
122462306a36Sopenharmony_ci	int reg;
122562306a36Sopenharmony_ci	unsigned char shift_l;
122662306a36Sopenharmony_ci	unsigned char shift_r;
122762306a36Sopenharmony_ci	unsigned int items;
122862306a36Sopenharmony_ci	unsigned int mask;
122962306a36Sopenharmony_ci	const char * const *texts;
123062306a36Sopenharmony_ci	const unsigned int *values;
123162306a36Sopenharmony_ci	unsigned int autodisable:1;
123262306a36Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
123362306a36Sopenharmony_ci	struct snd_soc_dobj dobj;
123462306a36Sopenharmony_ci#endif
123562306a36Sopenharmony_ci};
123662306a36Sopenharmony_ci
123762306a36Sopenharmony_cistatic inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
123862306a36Sopenharmony_ci{
123962306a36Sopenharmony_ci	if (mc->reg == mc->rreg && mc->shift == mc->rshift)
124062306a36Sopenharmony_ci		return false;
124162306a36Sopenharmony_ci	/*
124262306a36Sopenharmony_ci	 * mc->reg == mc->rreg && mc->shift != mc->rshift, or
124362306a36Sopenharmony_ci	 * mc->reg != mc->rreg means that the control is
124462306a36Sopenharmony_ci	 * stereo (bits in one register or in two registers)
124562306a36Sopenharmony_ci	 */
124662306a36Sopenharmony_ci	return true;
124762306a36Sopenharmony_ci}
124862306a36Sopenharmony_ci
124962306a36Sopenharmony_cistatic inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
125062306a36Sopenharmony_ci	unsigned int val)
125162306a36Sopenharmony_ci{
125262306a36Sopenharmony_ci	unsigned int i;
125362306a36Sopenharmony_ci
125462306a36Sopenharmony_ci	if (!e->values)
125562306a36Sopenharmony_ci		return val;
125662306a36Sopenharmony_ci
125762306a36Sopenharmony_ci	for (i = 0; i < e->items; i++)
125862306a36Sopenharmony_ci		if (val == e->values[i])
125962306a36Sopenharmony_ci			return i;
126062306a36Sopenharmony_ci
126162306a36Sopenharmony_ci	return 0;
126262306a36Sopenharmony_ci}
126362306a36Sopenharmony_ci
126462306a36Sopenharmony_cistatic inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
126562306a36Sopenharmony_ci	unsigned int item)
126662306a36Sopenharmony_ci{
126762306a36Sopenharmony_ci	if (!e->values)
126862306a36Sopenharmony_ci		return item;
126962306a36Sopenharmony_ci
127062306a36Sopenharmony_ci	return e->values[item];
127162306a36Sopenharmony_ci}
127262306a36Sopenharmony_ci
127362306a36Sopenharmony_ci/**
127462306a36Sopenharmony_ci * snd_soc_kcontrol_component() - Returns the component that registered the
127562306a36Sopenharmony_ci *  control
127662306a36Sopenharmony_ci * @kcontrol: The control for which to get the component
127762306a36Sopenharmony_ci *
127862306a36Sopenharmony_ci * Note: This function will work correctly if the control has been registered
127962306a36Sopenharmony_ci * for a component. With snd_soc_add_codec_controls() or via table based
128062306a36Sopenharmony_ci * setup for either a CODEC or component driver. Otherwise the behavior is
128162306a36Sopenharmony_ci * undefined.
128262306a36Sopenharmony_ci */
128362306a36Sopenharmony_cistatic inline struct snd_soc_component *snd_soc_kcontrol_component(
128462306a36Sopenharmony_ci	struct snd_kcontrol *kcontrol)
128562306a36Sopenharmony_ci{
128662306a36Sopenharmony_ci	return snd_kcontrol_chip(kcontrol);
128762306a36Sopenharmony_ci}
128862306a36Sopenharmony_ci
128962306a36Sopenharmony_ciint snd_soc_util_init(void);
129062306a36Sopenharmony_civoid snd_soc_util_exit(void);
129162306a36Sopenharmony_ci
129262306a36Sopenharmony_ciint snd_soc_of_parse_card_name(struct snd_soc_card *card,
129362306a36Sopenharmony_ci			       const char *propname);
129462306a36Sopenharmony_ciint snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
129562306a36Sopenharmony_ci					  const char *propname);
129662306a36Sopenharmony_ciint snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop);
129762306a36Sopenharmony_ciint snd_soc_of_get_slot_mask(struct device_node *np,
129862306a36Sopenharmony_ci			     const char *prop_name,
129962306a36Sopenharmony_ci			     unsigned int *mask);
130062306a36Sopenharmony_ciint snd_soc_of_parse_tdm_slot(struct device_node *np,
130162306a36Sopenharmony_ci			      unsigned int *tx_mask,
130262306a36Sopenharmony_ci			      unsigned int *rx_mask,
130362306a36Sopenharmony_ci			      unsigned int *slots,
130462306a36Sopenharmony_ci			      unsigned int *slot_width);
130562306a36Sopenharmony_civoid snd_soc_of_parse_node_prefix(struct device_node *np,
130662306a36Sopenharmony_ci				   struct snd_soc_codec_conf *codec_conf,
130762306a36Sopenharmony_ci				   struct device_node *of_node,
130862306a36Sopenharmony_ci				   const char *propname);
130962306a36Sopenharmony_cistatic inline
131062306a36Sopenharmony_civoid snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
131162306a36Sopenharmony_ci				   struct snd_soc_codec_conf *codec_conf,
131262306a36Sopenharmony_ci				   struct device_node *of_node,
131362306a36Sopenharmony_ci				   const char *propname)
131462306a36Sopenharmony_ci{
131562306a36Sopenharmony_ci	snd_soc_of_parse_node_prefix(card->dev->of_node,
131662306a36Sopenharmony_ci				     codec_conf, of_node, propname);
131762306a36Sopenharmony_ci}
131862306a36Sopenharmony_ci
131962306a36Sopenharmony_ciint snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
132062306a36Sopenharmony_ci				   const char *propname);
132162306a36Sopenharmony_ciint snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
132262306a36Sopenharmony_ci
132362306a36Sopenharmony_ciunsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt);
132462306a36Sopenharmony_ciunsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
132562306a36Sopenharmony_ci
132662306a36Sopenharmony_ciunsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
132762306a36Sopenharmony_ciunsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
132862306a36Sopenharmony_ci						     const char *prefix,
132962306a36Sopenharmony_ci						     struct device_node **bitclkmaster,
133062306a36Sopenharmony_ci						     struct device_node **framemaster);
133162306a36Sopenharmony_ci#define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)	\
133262306a36Sopenharmony_ci	snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
133362306a36Sopenharmony_ci#define snd_soc_daifmt_parse_clock_provider_as_phandle			\
133462306a36Sopenharmony_ci	snd_soc_daifmt_parse_clock_provider_raw
133562306a36Sopenharmony_ci#define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix)		\
133662306a36Sopenharmony_ci	snd_soc_daifmt_clock_provider_from_bitmap(			\
133762306a36Sopenharmony_ci		snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
133862306a36Sopenharmony_ci
133962306a36Sopenharmony_ciint snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream);
134062306a36Sopenharmony_ciint snd_soc_get_dlc(const struct of_phandle_args *args,
134162306a36Sopenharmony_ci		    struct snd_soc_dai_link_component *dlc);
134262306a36Sopenharmony_ciint snd_soc_of_get_dlc(struct device_node *of_node,
134362306a36Sopenharmony_ci		       struct of_phandle_args *args,
134462306a36Sopenharmony_ci		       struct snd_soc_dai_link_component *dlc,
134562306a36Sopenharmony_ci		       int index);
134662306a36Sopenharmony_ciint snd_soc_get_dai_id(struct device_node *ep);
134762306a36Sopenharmony_ciint snd_soc_get_dai_name(const struct of_phandle_args *args,
134862306a36Sopenharmony_ci			 const char **dai_name);
134962306a36Sopenharmony_ciint snd_soc_of_get_dai_name(struct device_node *of_node,
135062306a36Sopenharmony_ci			    const char **dai_name, int index);
135162306a36Sopenharmony_ciint snd_soc_of_get_dai_link_codecs(struct device *dev,
135262306a36Sopenharmony_ci				   struct device_node *of_node,
135362306a36Sopenharmony_ci				   struct snd_soc_dai_link *dai_link);
135462306a36Sopenharmony_civoid snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
135562306a36Sopenharmony_ciint snd_soc_of_get_dai_link_cpus(struct device *dev,
135662306a36Sopenharmony_ci				 struct device_node *of_node,
135762306a36Sopenharmony_ci				 struct snd_soc_dai_link *dai_link);
135862306a36Sopenharmony_civoid snd_soc_of_put_dai_link_cpus(struct snd_soc_dai_link *dai_link);
135962306a36Sopenharmony_ci
136062306a36Sopenharmony_ciint snd_soc_add_pcm_runtimes(struct snd_soc_card *card,
136162306a36Sopenharmony_ci			     struct snd_soc_dai_link *dai_link,
136262306a36Sopenharmony_ci			     int num_dai_link);
136362306a36Sopenharmony_civoid snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
136462306a36Sopenharmony_ci				struct snd_soc_pcm_runtime *rtd);
136562306a36Sopenharmony_ci
136662306a36Sopenharmony_civoid snd_soc_dlc_use_cpu_as_platform(struct snd_soc_dai_link_component *platforms,
136762306a36Sopenharmony_ci				     struct snd_soc_dai_link_component *cpus);
136862306a36Sopenharmony_cistruct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
136962306a36Sopenharmony_ci					      struct of_phandle_args *args);
137062306a36Sopenharmony_cistruct snd_soc_dai *snd_soc_get_dai_via_args(struct of_phandle_args *dai_args);
137162306a36Sopenharmony_cistruct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
137262306a36Sopenharmony_ci					 struct snd_soc_dai_driver *dai_drv,
137362306a36Sopenharmony_ci					 bool legacy_dai_naming);
137462306a36Sopenharmony_cistruct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
137562306a36Sopenharmony_ci					      struct snd_soc_component *component,
137662306a36Sopenharmony_ci					      struct snd_soc_dai_driver *dai_drv,
137762306a36Sopenharmony_ci					      bool legacy_dai_naming);
137862306a36Sopenharmony_civoid snd_soc_unregister_dai(struct snd_soc_dai *dai);
137962306a36Sopenharmony_ci
138062306a36Sopenharmony_cistruct snd_soc_dai *snd_soc_find_dai(
138162306a36Sopenharmony_ci	const struct snd_soc_dai_link_component *dlc);
138262306a36Sopenharmony_cistruct snd_soc_dai *snd_soc_find_dai_with_mutex(
138362306a36Sopenharmony_ci	const struct snd_soc_dai_link_component *dlc);
138462306a36Sopenharmony_ci
138562306a36Sopenharmony_ci#include <sound/soc-dai.h>
138662306a36Sopenharmony_ci
138762306a36Sopenharmony_cistatic inline
138862306a36Sopenharmony_ciint snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
138962306a36Sopenharmony_ci					  const char *platform_name)
139062306a36Sopenharmony_ci{
139162306a36Sopenharmony_ci	struct snd_soc_dai_link *dai_link;
139262306a36Sopenharmony_ci	const char *name;
139362306a36Sopenharmony_ci	int i;
139462306a36Sopenharmony_ci
139562306a36Sopenharmony_ci	if (!platform_name) /* nothing to do */
139662306a36Sopenharmony_ci		return 0;
139762306a36Sopenharmony_ci
139862306a36Sopenharmony_ci	/* set platform name for each dailink */
139962306a36Sopenharmony_ci	for_each_card_prelinks(card, i, dai_link) {
140062306a36Sopenharmony_ci		/* only single platform is supported for now */
140162306a36Sopenharmony_ci		if (dai_link->num_platforms != 1)
140262306a36Sopenharmony_ci			return -EINVAL;
140362306a36Sopenharmony_ci
140462306a36Sopenharmony_ci		if (!dai_link->platforms)
140562306a36Sopenharmony_ci			return -EINVAL;
140662306a36Sopenharmony_ci
140762306a36Sopenharmony_ci		name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
140862306a36Sopenharmony_ci		if (!name)
140962306a36Sopenharmony_ci			return -ENOMEM;
141062306a36Sopenharmony_ci
141162306a36Sopenharmony_ci		/* only single platform is supported for now */
141262306a36Sopenharmony_ci		dai_link->platforms->name = name;
141362306a36Sopenharmony_ci	}
141462306a36Sopenharmony_ci
141562306a36Sopenharmony_ci	return 0;
141662306a36Sopenharmony_ci}
141762306a36Sopenharmony_ci
141862306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
141962306a36Sopenharmony_ciextern struct dentry *snd_soc_debugfs_root;
142062306a36Sopenharmony_ci#endif
142162306a36Sopenharmony_ci
142262306a36Sopenharmony_ciextern const struct dev_pm_ops snd_soc_pm_ops;
142362306a36Sopenharmony_ci
142462306a36Sopenharmony_ci/*
142562306a36Sopenharmony_ci *	DAPM helper functions
142662306a36Sopenharmony_ci */
142762306a36Sopenharmony_cienum snd_soc_dapm_subclass {
142862306a36Sopenharmony_ci	SND_SOC_DAPM_CLASS_ROOT		= 0,
142962306a36Sopenharmony_ci	SND_SOC_DAPM_CLASS_RUNTIME	= 1,
143062306a36Sopenharmony_ci};
143162306a36Sopenharmony_ci
143262306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card)
143362306a36Sopenharmony_ci{
143462306a36Sopenharmony_ci	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT);
143562306a36Sopenharmony_ci}
143662306a36Sopenharmony_ci
143762306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card)
143862306a36Sopenharmony_ci{
143962306a36Sopenharmony_ci	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
144062306a36Sopenharmony_ci}
144162306a36Sopenharmony_ci
144262306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card)
144362306a36Sopenharmony_ci{
144462306a36Sopenharmony_ci	mutex_unlock(&card->dapm_mutex);
144562306a36Sopenharmony_ci}
144662306a36Sopenharmony_ci
144762306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card)
144862306a36Sopenharmony_ci{
144962306a36Sopenharmony_ci	lockdep_assert_held(&card->dapm_mutex);
145062306a36Sopenharmony_ci}
145162306a36Sopenharmony_ci
145262306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm)
145362306a36Sopenharmony_ci{
145462306a36Sopenharmony_ci	_snd_soc_dapm_mutex_lock_root_c(dapm->card);
145562306a36Sopenharmony_ci}
145662306a36Sopenharmony_ci
145762306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm)
145862306a36Sopenharmony_ci{
145962306a36Sopenharmony_ci	_snd_soc_dapm_mutex_lock_c(dapm->card);
146062306a36Sopenharmony_ci}
146162306a36Sopenharmony_ci
146262306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm)
146362306a36Sopenharmony_ci{
146462306a36Sopenharmony_ci	_snd_soc_dapm_mutex_unlock_c(dapm->card);
146562306a36Sopenharmony_ci}
146662306a36Sopenharmony_ci
146762306a36Sopenharmony_cistatic inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm)
146862306a36Sopenharmony_ci{
146962306a36Sopenharmony_ci	_snd_soc_dapm_mutex_assert_held_c(dapm->card);
147062306a36Sopenharmony_ci}
147162306a36Sopenharmony_ci
147262306a36Sopenharmony_ci#define snd_soc_dapm_mutex_lock_root(x) _Generic((x),			\
147362306a36Sopenharmony_ci	struct snd_soc_card * :		_snd_soc_dapm_mutex_lock_root_c, \
147462306a36Sopenharmony_ci	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_lock_root_d)(x)
147562306a36Sopenharmony_ci#define snd_soc_dapm_mutex_lock(x) _Generic((x),			\
147662306a36Sopenharmony_ci	struct snd_soc_card * :		_snd_soc_dapm_mutex_lock_c,	\
147762306a36Sopenharmony_ci	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_lock_d)(x)
147862306a36Sopenharmony_ci#define snd_soc_dapm_mutex_unlock(x) _Generic((x),			\
147962306a36Sopenharmony_ci	struct snd_soc_card * :		_snd_soc_dapm_mutex_unlock_c,	\
148062306a36Sopenharmony_ci	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_unlock_d)(x)
148162306a36Sopenharmony_ci#define snd_soc_dapm_mutex_assert_held(x) _Generic((x),			\
148262306a36Sopenharmony_ci	struct snd_soc_card * :		_snd_soc_dapm_mutex_assert_held_c, \
148362306a36Sopenharmony_ci	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_assert_held_d)(x)
148462306a36Sopenharmony_ci
148562306a36Sopenharmony_ci/*
148662306a36Sopenharmony_ci *	PCM helper functions
148762306a36Sopenharmony_ci */
148862306a36Sopenharmony_cistatic inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card)
148962306a36Sopenharmony_ci{
149062306a36Sopenharmony_ci	mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
149162306a36Sopenharmony_ci}
149262306a36Sopenharmony_ci
149362306a36Sopenharmony_cistatic inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card)
149462306a36Sopenharmony_ci{
149562306a36Sopenharmony_ci	mutex_unlock(&card->pcm_mutex);
149662306a36Sopenharmony_ci}
149762306a36Sopenharmony_ci
149862306a36Sopenharmony_cistatic inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card)
149962306a36Sopenharmony_ci{
150062306a36Sopenharmony_ci	lockdep_assert_held(&card->pcm_mutex);
150162306a36Sopenharmony_ci}
150262306a36Sopenharmony_ci
150362306a36Sopenharmony_cistatic inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd)
150462306a36Sopenharmony_ci{
150562306a36Sopenharmony_ci	_snd_soc_dpcm_mutex_lock_c(rtd->card);
150662306a36Sopenharmony_ci}
150762306a36Sopenharmony_ci
150862306a36Sopenharmony_cistatic inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd)
150962306a36Sopenharmony_ci{
151062306a36Sopenharmony_ci	_snd_soc_dpcm_mutex_unlock_c(rtd->card);
151162306a36Sopenharmony_ci}
151262306a36Sopenharmony_ci
151362306a36Sopenharmony_cistatic inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd)
151462306a36Sopenharmony_ci{
151562306a36Sopenharmony_ci	_snd_soc_dpcm_mutex_assert_held_c(rtd->card);
151662306a36Sopenharmony_ci}
151762306a36Sopenharmony_ci
151862306a36Sopenharmony_ci#define snd_soc_dpcm_mutex_lock(x) _Generic((x),			\
151962306a36Sopenharmony_ci	 struct snd_soc_card * :	_snd_soc_dpcm_mutex_lock_c,	\
152062306a36Sopenharmony_ci	 struct snd_soc_pcm_runtime * :	_snd_soc_dpcm_mutex_lock_r)(x)
152162306a36Sopenharmony_ci
152262306a36Sopenharmony_ci#define snd_soc_dpcm_mutex_unlock(x) _Generic((x),			\
152362306a36Sopenharmony_ci	 struct snd_soc_card * :	_snd_soc_dpcm_mutex_unlock_c,	\
152462306a36Sopenharmony_ci	 struct snd_soc_pcm_runtime * :	_snd_soc_dpcm_mutex_unlock_r)(x)
152562306a36Sopenharmony_ci
152662306a36Sopenharmony_ci#define snd_soc_dpcm_mutex_assert_held(x) _Generic((x),		\
152762306a36Sopenharmony_ci	struct snd_soc_card * :		_snd_soc_dpcm_mutex_assert_held_c, \
152862306a36Sopenharmony_ci	struct snd_soc_pcm_runtime * :	_snd_soc_dpcm_mutex_assert_held_r)(x)
152962306a36Sopenharmony_ci
153062306a36Sopenharmony_ci#include <sound/soc-component.h>
153162306a36Sopenharmony_ci#include <sound/soc-card.h>
153262306a36Sopenharmony_ci#include <sound/soc-jack.h>
153362306a36Sopenharmony_ci
153462306a36Sopenharmony_ci#endif
1535