18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * linux/sound/soc.h -- ALSA SoC Layer
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author:	Liam Girdwood
68c2ecf20Sopenharmony_ci * Created:	Aug 11th 2005
78c2ecf20Sopenharmony_ci * Copyright:	Wolfson Microelectronics. PLC.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __LINUX_SND_SOC_H
118c2ecf20Sopenharmony_ci#define __LINUX_SND_SOC_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/of.h>
148c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
158c2ecf20Sopenharmony_ci#include <linux/types.h>
168c2ecf20Sopenharmony_ci#include <linux/notifier.h>
178c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
188c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
198c2ecf20Sopenharmony_ci#include <linux/kernel.h>
208c2ecf20Sopenharmony_ci#include <linux/regmap.h>
218c2ecf20Sopenharmony_ci#include <linux/log2.h>
228c2ecf20Sopenharmony_ci#include <sound/core.h>
238c2ecf20Sopenharmony_ci#include <sound/pcm.h>
248c2ecf20Sopenharmony_ci#include <sound/compress_driver.h>
258c2ecf20Sopenharmony_ci#include <sound/control.h>
268c2ecf20Sopenharmony_ci#include <sound/ac97_codec.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/*
298c2ecf20Sopenharmony_ci * Convenience kcontrol builders
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci#define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
328c2ecf20Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
338c2ecf20Sopenharmony_ci	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
348c2ecf20Sopenharmony_ci	.rshift = shift_right, .max = xmax, .platform_max = xmax, \
358c2ecf20Sopenharmony_ci	.invert = xinvert, .autodisable = xautodisable})
368c2ecf20Sopenharmony_ci#define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
378c2ecf20Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
388c2ecf20Sopenharmony_ci	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
398c2ecf20Sopenharmony_ci	.rshift = shift_right, .min = xmin, .max = xmax, .platform_max = xmax, \
408c2ecf20Sopenharmony_ci	.sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
418c2ecf20Sopenharmony_ci#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
428c2ecf20Sopenharmony_ci	SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
438c2ecf20Sopenharmony_ci#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
448c2ecf20Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
458c2ecf20Sopenharmony_ci	{.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
468c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
478c2ecf20Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
488c2ecf20Sopenharmony_ci	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
498c2ecf20Sopenharmony_ci	.max = xmax, .platform_max = xmax, .invert = xinvert})
508c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
518c2ecf20Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
528c2ecf20Sopenharmony_ci	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
538c2ecf20Sopenharmony_ci	.max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
548c2ecf20Sopenharmony_ci	.invert = xinvert})
558c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
568c2ecf20Sopenharmony_ci	((unsigned long)&(struct soc_mixer_control) \
578c2ecf20Sopenharmony_ci	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
588c2ecf20Sopenharmony_ci	.min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
598c2ecf20Sopenharmony_ci#define SOC_SINGLE(xname, reg, shift, max, invert) \
608c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
618c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
628c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw, \
638c2ecf20Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
648c2ecf20Sopenharmony_ci#define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
658c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
668c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
678c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw_range, \
688c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
698c2ecf20Sopenharmony_ci		{.reg = xreg, .rreg = xreg, .shift = xshift, \
708c2ecf20Sopenharmony_ci		 .rshift = xshift,  .min = xmin, .max = xmax, \
718c2ecf20Sopenharmony_ci		 .platform_max = xmax, .invert = xinvert} }
728c2ecf20Sopenharmony_ci#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
738c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
748c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
758c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
768c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
778c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
788c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw, \
798c2ecf20Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
808c2ecf20Sopenharmony_ci#define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
818c2ecf20Sopenharmony_ci{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
828c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
838c2ecf20Sopenharmony_ci	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
848c2ecf20Sopenharmony_ci	.tlv.p  = (tlv_array),\
858c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_sx, \
868c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw_sx,\
878c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw_sx, \
888c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
898c2ecf20Sopenharmony_ci		{.reg = xreg, .rreg = xreg, \
908c2ecf20Sopenharmony_ci		.shift = xshift, .rshift = xshift, \
918c2ecf20Sopenharmony_ci		.max = xmax, .min = xmin} }
928c2ecf20Sopenharmony_ci#define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
938c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
948c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
958c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
968c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
978c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
988c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
998c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
1008c2ecf20Sopenharmony_ci		{.reg = xreg, .rreg = xreg, .shift = xshift, \
1018c2ecf20Sopenharmony_ci		 .rshift = xshift, .min = xmin, .max = xmax, \
1028c2ecf20Sopenharmony_ci		 .platform_max = xmax, .invert = xinvert} }
1038c2ecf20Sopenharmony_ci#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
1048c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1058c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
1068c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw, \
1078c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
1088c2ecf20Sopenharmony_ci					  max, invert, 0) }
1098c2ecf20Sopenharmony_ci#define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
1108c2ecf20Sopenharmony_ci{									\
1118c2ecf20Sopenharmony_ci	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),		\
1128c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,		\
1138c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_READ |				\
1148c2ecf20Sopenharmony_ci		SNDRV_CTL_ELEM_ACCESS_VOLATILE,				\
1158c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right,	\
1168c2ecf20Sopenharmony_ci					  max, invert, 0) }
1178c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
1188c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1198c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
1208c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
1218c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
1228c2ecf20Sopenharmony_ci					    xmax, xinvert) }
1238c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
1248c2ecf20Sopenharmony_ci			   xmax, xinvert)		\
1258c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1268c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
1278c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
1288c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
1298c2ecf20Sopenharmony_ci					    xshift, xmin, xmax, xinvert) }
1308c2ecf20Sopenharmony_ci#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
1318c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1328c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
1338c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
1348c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
1358c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
1368c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw, \
1378c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
1388c2ecf20Sopenharmony_ci					  max, invert, 0) }
1398c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
1408c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1418c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
1428c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
1438c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
1448c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
1458c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
1468c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
1478c2ecf20Sopenharmony_ci					    xmax, xinvert) }
1488c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
1498c2ecf20Sopenharmony_ci			       xmax, xinvert, tlv_array)		\
1508c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1518c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
1528c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
1538c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
1548c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
1558c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
1568c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
1578c2ecf20Sopenharmony_ci					    xshift, xmin, xmax, xinvert) }
1588c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
1598c2ecf20Sopenharmony_ci{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1608c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1618c2ecf20Sopenharmony_ci	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1628c2ecf20Sopenharmony_ci	.tlv.p  = (tlv_array), \
1638c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_sx, \
1648c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw_sx, \
1658c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw_sx, \
1668c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
1678c2ecf20Sopenharmony_ci		{.reg = xreg, .rreg = xrreg, \
1688c2ecf20Sopenharmony_ci		.shift = xshift, .rshift = xshift, \
1698c2ecf20Sopenharmony_ci		.max = xmax, .min = xmin} }
1708c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
1718c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1728c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
1738c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
1748c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
1758c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
1768c2ecf20Sopenharmony_ci	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
1778c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
1788c2ecf20Sopenharmony_ci					    xmin, xmax, xsign_bit, xinvert) }
1798c2ecf20Sopenharmony_ci#define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
1808c2ecf20Sopenharmony_ci{	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1818c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1828c2ecf20Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1838c2ecf20Sopenharmony_ci	.tlv.p  = (tlv_array), \
1848c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
1858c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw, \
1868c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
1878c2ecf20Sopenharmony_ci	{.reg = xreg, .rreg = xreg,  \
1888c2ecf20Sopenharmony_ci	 .min = xmin, .max = xmax, .platform_max = xmax, \
1898c2ecf20Sopenharmony_ci	.sign_bit = 7,} }
1908c2ecf20Sopenharmony_ci#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
1918c2ecf20Sopenharmony_ci{	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1928c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1938c2ecf20Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1948c2ecf20Sopenharmony_ci	.tlv.p  = (tlv_array), \
1958c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
1968c2ecf20Sopenharmony_ci	.put = snd_soc_put_volsw, \
1978c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
1988c2ecf20Sopenharmony_ci#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
1998c2ecf20Sopenharmony_ci{	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
2008c2ecf20Sopenharmony_ci	.items = xitems, .texts = xtexts, \
2018c2ecf20Sopenharmony_ci	.mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
2028c2ecf20Sopenharmony_ci#define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
2038c2ecf20Sopenharmony_ci	SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
2048c2ecf20Sopenharmony_ci#define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
2058c2ecf20Sopenharmony_ci{	.items = xitems, .texts = xtexts }
2068c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
2078c2ecf20Sopenharmony_ci{	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
2088c2ecf20Sopenharmony_ci	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
2098c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
2108c2ecf20Sopenharmony_ci	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
2118c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
2128c2ecf20Sopenharmony_ci{	.reg = xreg, .shift_l = xshift, .shift_r = xshift, \
2138c2ecf20Sopenharmony_ci	.mask = xmask, .items = xitems, .texts = xtexts, \
2148c2ecf20Sopenharmony_ci	.values = xvalues, .autodisable = 1}
2158c2ecf20Sopenharmony_ci#define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
2168c2ecf20Sopenharmony_ci	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
2178c2ecf20Sopenharmony_ci#define SOC_ENUM(xname, xenum) \
2188c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
2198c2ecf20Sopenharmony_ci	.info = snd_soc_info_enum_double, \
2208c2ecf20Sopenharmony_ci	.get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
2218c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&xenum }
2228c2ecf20Sopenharmony_ci#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
2238c2ecf20Sopenharmony_ci	 xhandler_get, xhandler_put) \
2248c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2258c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
2268c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2278c2ecf20Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
2288c2ecf20Sopenharmony_ci#define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
2298c2ecf20Sopenharmony_ci	 xhandler_get, xhandler_put) \
2308c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
2318c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
2328c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2338c2ecf20Sopenharmony_ci	.private_value = \
2348c2ecf20Sopenharmony_ci		SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
2358c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
2368c2ecf20Sopenharmony_ci	 xhandler_get, xhandler_put) \
2378c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2388c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
2398c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2408c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
2418c2ecf20Sopenharmony_ci					    xmax, xinvert) }
2428c2ecf20Sopenharmony_ci#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
2438c2ecf20Sopenharmony_ci	 xhandler_get, xhandler_put, tlv_array) \
2448c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2458c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
2468c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
2478c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
2488c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
2498c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2508c2ecf20Sopenharmony_ci	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
2518c2ecf20Sopenharmony_ci#define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
2528c2ecf20Sopenharmony_ci				 xhandler_get, xhandler_put, tlv_array) \
2538c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
2548c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
2558c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
2568c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
2578c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw_range, \
2588c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2598c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mixer_control) \
2608c2ecf20Sopenharmony_ci		{.reg = xreg, .rreg = xreg, .shift = xshift, \
2618c2ecf20Sopenharmony_ci		 .rshift = xshift, .min = xmin, .max = xmax, \
2628c2ecf20Sopenharmony_ci		 .platform_max = xmax, .invert = xinvert} }
2638c2ecf20Sopenharmony_ci#define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
2648c2ecf20Sopenharmony_ci	 xhandler_get, xhandler_put, tlv_array) \
2658c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2668c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2678c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2688c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
2698c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
2708c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2718c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
2728c2ecf20Sopenharmony_ci					  xmax, xinvert, 0) }
2738c2ecf20Sopenharmony_ci#define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
2748c2ecf20Sopenharmony_ci	 xhandler_get, xhandler_put, tlv_array) \
2758c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2768c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2778c2ecf20Sopenharmony_ci		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2788c2ecf20Sopenharmony_ci	.tlv.p = (tlv_array), \
2798c2ecf20Sopenharmony_ci	.info = snd_soc_info_volsw, \
2808c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2818c2ecf20Sopenharmony_ci	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
2828c2ecf20Sopenharmony_ci					    xmax, xinvert) }
2838c2ecf20Sopenharmony_ci#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
2848c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2858c2ecf20Sopenharmony_ci	.info = snd_soc_info_bool_ext, \
2868c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2878c2ecf20Sopenharmony_ci	.private_value = xdata }
2888c2ecf20Sopenharmony_ci#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
2898c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2908c2ecf20Sopenharmony_ci	.info = snd_soc_info_enum_double, \
2918c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
2928c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&xenum }
2938c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
2948c2ecf20Sopenharmony_ci	SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci#define SND_SOC_BYTES(xname, xbase, xregs)		      \
2978c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
2988c2ecf20Sopenharmony_ci	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
2998c2ecf20Sopenharmony_ci	.put = snd_soc_bytes_put, .private_value =	      \
3008c2ecf20Sopenharmony_ci		((unsigned long)&(struct soc_bytes)           \
3018c2ecf20Sopenharmony_ci		{.base = xbase, .num_regs = xregs }) }
3028c2ecf20Sopenharmony_ci#define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
3038c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3048c2ecf20Sopenharmony_ci	.info = snd_soc_bytes_info, .get = xhandler_get, \
3058c2ecf20Sopenharmony_ci	.put = xhandler_put, .private_value = \
3068c2ecf20Sopenharmony_ci		((unsigned long)&(struct soc_bytes) \
3078c2ecf20Sopenharmony_ci		{.base = xbase, .num_regs = xregs }) }
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci#define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)	      \
3108c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
3118c2ecf20Sopenharmony_ci	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
3128c2ecf20Sopenharmony_ci	.put = snd_soc_bytes_put, .private_value =	      \
3138c2ecf20Sopenharmony_ci		((unsigned long)&(struct soc_bytes)           \
3148c2ecf20Sopenharmony_ci		{.base = xbase, .num_regs = xregs,	      \
3158c2ecf20Sopenharmony_ci		 .mask = xmask }) }
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci/*
3188c2ecf20Sopenharmony_ci * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
3198c2ecf20Sopenharmony_ci */
3208c2ecf20Sopenharmony_ci#define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
3218c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3228c2ecf20Sopenharmony_ci	.info = snd_soc_bytes_info_ext, \
3238c2ecf20Sopenharmony_ci	.get = xhandler_get, .put = xhandler_put, \
3248c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_bytes_ext) \
3258c2ecf20Sopenharmony_ci		{.max = xcount} }
3268c2ecf20Sopenharmony_ci#define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
3278c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3288c2ecf20Sopenharmony_ci	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
3298c2ecf20Sopenharmony_ci		  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
3308c2ecf20Sopenharmony_ci	.tlv.c = (snd_soc_bytes_tlv_callback), \
3318c2ecf20Sopenharmony_ci	.info = snd_soc_bytes_info_ext, \
3328c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_bytes_ext) \
3338c2ecf20Sopenharmony_ci		{.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
3348c2ecf20Sopenharmony_ci#define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
3358c2ecf20Sopenharmony_ci		xmin, xmax, xinvert) \
3368c2ecf20Sopenharmony_ci{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
3378c2ecf20Sopenharmony_ci	.info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
3388c2ecf20Sopenharmony_ci	.put = snd_soc_put_xr_sx, \
3398c2ecf20Sopenharmony_ci	.private_value = (unsigned long)&(struct soc_mreg_control) \
3408c2ecf20Sopenharmony_ci		{.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
3418c2ecf20Sopenharmony_ci		.invert = xinvert, .min = xmin, .max = xmax} }
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci#define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
3448c2ecf20Sopenharmony_ci	SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
3458c2ecf20Sopenharmony_ci		snd_soc_get_strobe, snd_soc_put_strobe)
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci/*
3488c2ecf20Sopenharmony_ci * Simplified versions of above macros, declaring a struct and calculating
3498c2ecf20Sopenharmony_ci * ARRAY_SIZE internally
3508c2ecf20Sopenharmony_ci */
3518c2ecf20Sopenharmony_ci#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
3528c2ecf20Sopenharmony_ci	const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
3538c2ecf20Sopenharmony_ci						ARRAY_SIZE(xtexts), xtexts)
3548c2ecf20Sopenharmony_ci#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
3558c2ecf20Sopenharmony_ci	SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
3568c2ecf20Sopenharmony_ci#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
3578c2ecf20Sopenharmony_ci	const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
3588c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
3598c2ecf20Sopenharmony_ci	const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
3608c2ecf20Sopenharmony_ci							ARRAY_SIZE(xtexts), xtexts, xvalues)
3618c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
3628c2ecf20Sopenharmony_ci	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
3658c2ecf20Sopenharmony_ci	const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
3668c2ecf20Sopenharmony_ci		xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci#define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
3698c2ecf20Sopenharmony_ci	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistruct device_node;
3728c2ecf20Sopenharmony_cistruct snd_jack;
3738c2ecf20Sopenharmony_cistruct snd_soc_card;
3748c2ecf20Sopenharmony_cistruct snd_soc_pcm_stream;
3758c2ecf20Sopenharmony_cistruct snd_soc_ops;
3768c2ecf20Sopenharmony_cistruct snd_soc_pcm_runtime;
3778c2ecf20Sopenharmony_cistruct snd_soc_dai;
3788c2ecf20Sopenharmony_cistruct snd_soc_dai_driver;
3798c2ecf20Sopenharmony_cistruct snd_soc_dai_link;
3808c2ecf20Sopenharmony_cistruct snd_soc_component;
3818c2ecf20Sopenharmony_cistruct snd_soc_component_driver;
3828c2ecf20Sopenharmony_cistruct soc_enum;
3838c2ecf20Sopenharmony_cistruct snd_soc_jack;
3848c2ecf20Sopenharmony_cistruct snd_soc_jack_zone;
3858c2ecf20Sopenharmony_cistruct snd_soc_jack_pin;
3868c2ecf20Sopenharmony_ci#include <sound/soc-dapm.h>
3878c2ecf20Sopenharmony_ci#include <sound/soc-dpcm.h>
3888c2ecf20Sopenharmony_ci#include <sound/soc-topology.h>
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_cistruct snd_soc_jack_gpio;
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_citypedef int (*hw_write_t)(void *,const char* ,int);
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_cienum snd_soc_pcm_subclass {
3958c2ecf20Sopenharmony_ci	SND_SOC_PCM_CLASS_PCM	= 0,
3968c2ecf20Sopenharmony_ci	SND_SOC_PCM_CLASS_BE	= 1,
3978c2ecf20Sopenharmony_ci};
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ciint snd_soc_register_card(struct snd_soc_card *card);
4008c2ecf20Sopenharmony_ciint snd_soc_unregister_card(struct snd_soc_card *card);
4018c2ecf20Sopenharmony_ciint devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
4028c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
4038c2ecf20Sopenharmony_ciint snd_soc_suspend(struct device *dev);
4048c2ecf20Sopenharmony_ciint snd_soc_resume(struct device *dev);
4058c2ecf20Sopenharmony_ci#else
4068c2ecf20Sopenharmony_cistatic inline int snd_soc_suspend(struct device *dev)
4078c2ecf20Sopenharmony_ci{
4088c2ecf20Sopenharmony_ci	return 0;
4098c2ecf20Sopenharmony_ci}
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_cistatic inline int snd_soc_resume(struct device *dev)
4128c2ecf20Sopenharmony_ci{
4138c2ecf20Sopenharmony_ci	return 0;
4148c2ecf20Sopenharmony_ci}
4158c2ecf20Sopenharmony_ci#endif
4168c2ecf20Sopenharmony_ciint snd_soc_poweroff(struct device *dev);
4178c2ecf20Sopenharmony_ciint snd_soc_component_initialize(struct snd_soc_component *component,
4188c2ecf20Sopenharmony_ci				 const struct snd_soc_component_driver *driver,
4198c2ecf20Sopenharmony_ci				 struct device *dev);
4208c2ecf20Sopenharmony_ciint snd_soc_add_component(struct snd_soc_component *component,
4218c2ecf20Sopenharmony_ci			  struct snd_soc_dai_driver *dai_drv,
4228c2ecf20Sopenharmony_ci			  int num_dai);
4238c2ecf20Sopenharmony_ciint snd_soc_register_component(struct device *dev,
4248c2ecf20Sopenharmony_ci			 const struct snd_soc_component_driver *component_driver,
4258c2ecf20Sopenharmony_ci			 struct snd_soc_dai_driver *dai_drv, int num_dai);
4268c2ecf20Sopenharmony_ciint devm_snd_soc_register_component(struct device *dev,
4278c2ecf20Sopenharmony_ci			 const struct snd_soc_component_driver *component_driver,
4288c2ecf20Sopenharmony_ci			 struct snd_soc_dai_driver *dai_drv, int num_dai);
4298c2ecf20Sopenharmony_civoid snd_soc_unregister_component(struct device *dev);
4308c2ecf20Sopenharmony_civoid snd_soc_unregister_component_by_driver(struct device *dev,
4318c2ecf20Sopenharmony_ci			 const struct snd_soc_component_driver *component_driver);
4328c2ecf20Sopenharmony_cistruct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
4338c2ecf20Sopenharmony_ci							    const char *driver_name);
4348c2ecf20Sopenharmony_cistruct snd_soc_component *snd_soc_lookup_component(struct device *dev,
4358c2ecf20Sopenharmony_ci						   const char *driver_name);
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ciint soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
4388c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_SOC_COMPRESS
4398c2ecf20Sopenharmony_ciint snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
4408c2ecf20Sopenharmony_ci#else
4418c2ecf20Sopenharmony_cistatic inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
4428c2ecf20Sopenharmony_ci{
4438c2ecf20Sopenharmony_ci	return 0;
4448c2ecf20Sopenharmony_ci}
4458c2ecf20Sopenharmony_ci#endif
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_civoid snd_soc_disconnect_sync(struct device *dev);
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_cistruct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
4508c2ecf20Sopenharmony_ci				struct snd_soc_dai_link *dai_link);
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cibool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_civoid snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
4558c2ecf20Sopenharmony_ci			    int stream, int action);
4568c2ecf20Sopenharmony_cistatic inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
4578c2ecf20Sopenharmony_ci				     int stream)
4588c2ecf20Sopenharmony_ci{
4598c2ecf20Sopenharmony_ci	snd_soc_runtime_action(rtd, stream, 1);
4608c2ecf20Sopenharmony_ci}
4618c2ecf20Sopenharmony_cistatic inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
4628c2ecf20Sopenharmony_ci				       int stream)
4638c2ecf20Sopenharmony_ci{
4648c2ecf20Sopenharmony_ci	snd_soc_runtime_action(rtd, stream, -1);
4658c2ecf20Sopenharmony_ci}
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ciint snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
4688c2ecf20Sopenharmony_ci			    struct snd_pcm_hardware *hw, int stream);
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ciint snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
4718c2ecf20Sopenharmony_ci	unsigned int dai_fmt);
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci#ifdef CONFIG_DMI
4748c2ecf20Sopenharmony_ciint snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
4758c2ecf20Sopenharmony_ci#else
4768c2ecf20Sopenharmony_cistatic inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
4778c2ecf20Sopenharmony_ci				       const char *flavour)
4788c2ecf20Sopenharmony_ci{
4798c2ecf20Sopenharmony_ci	return 0;
4808c2ecf20Sopenharmony_ci}
4818c2ecf20Sopenharmony_ci#endif
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci/* Utility functions to get clock rates from various things */
4848c2ecf20Sopenharmony_ciint snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
4858c2ecf20Sopenharmony_ciint snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
4868c2ecf20Sopenharmony_ciint snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
4878c2ecf20Sopenharmony_ciint snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci/* set runtime hw params */
4908c2ecf20Sopenharmony_ciint snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
4918c2ecf20Sopenharmony_ci	const struct snd_pcm_hardware *hw);
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci/* Jack reporting */
4948c2ecf20Sopenharmony_civoid snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
4958c2ecf20Sopenharmony_ciint snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
4968c2ecf20Sopenharmony_ci			  struct snd_soc_jack_pin *pins);
4978c2ecf20Sopenharmony_civoid snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
4988c2ecf20Sopenharmony_ci				    struct notifier_block *nb);
4998c2ecf20Sopenharmony_civoid snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
5008c2ecf20Sopenharmony_ci				      struct notifier_block *nb);
5018c2ecf20Sopenharmony_ciint snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
5028c2ecf20Sopenharmony_ci			  struct snd_soc_jack_zone *zones);
5038c2ecf20Sopenharmony_ciint snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
5048c2ecf20Sopenharmony_ci#ifdef CONFIG_GPIOLIB
5058c2ecf20Sopenharmony_ciint snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
5068c2ecf20Sopenharmony_ci			struct snd_soc_jack_gpio *gpios);
5078c2ecf20Sopenharmony_ciint snd_soc_jack_add_gpiods(struct device *gpiod_dev,
5088c2ecf20Sopenharmony_ci			    struct snd_soc_jack *jack,
5098c2ecf20Sopenharmony_ci			    int count, struct snd_soc_jack_gpio *gpios);
5108c2ecf20Sopenharmony_civoid snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
5118c2ecf20Sopenharmony_ci			struct snd_soc_jack_gpio *gpios);
5128c2ecf20Sopenharmony_ci#else
5138c2ecf20Sopenharmony_cistatic inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
5148c2ecf20Sopenharmony_ci					 struct snd_soc_jack_gpio *gpios)
5158c2ecf20Sopenharmony_ci{
5168c2ecf20Sopenharmony_ci	return 0;
5178c2ecf20Sopenharmony_ci}
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_cistatic inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
5208c2ecf20Sopenharmony_ci					  struct snd_soc_jack *jack,
5218c2ecf20Sopenharmony_ci					  int count,
5228c2ecf20Sopenharmony_ci					  struct snd_soc_jack_gpio *gpios)
5238c2ecf20Sopenharmony_ci{
5248c2ecf20Sopenharmony_ci	return 0;
5258c2ecf20Sopenharmony_ci}
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_cistatic inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
5288c2ecf20Sopenharmony_ci					   struct snd_soc_jack_gpio *gpios)
5298c2ecf20Sopenharmony_ci{
5308c2ecf20Sopenharmony_ci}
5318c2ecf20Sopenharmony_ci#endif
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_cistruct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
5348c2ecf20Sopenharmony_cistruct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
5358c2ecf20Sopenharmony_ci	unsigned int id, unsigned int id_mask);
5368c2ecf20Sopenharmony_civoid snd_soc_free_ac97_component(struct snd_ac97 *ac97);
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_SOC_AC97_BUS
5398c2ecf20Sopenharmony_ciint snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
5408c2ecf20Sopenharmony_ciint snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
5418c2ecf20Sopenharmony_ci		struct platform_device *pdev);
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ciextern struct snd_ac97_bus_ops *soc_ac97_ops;
5448c2ecf20Sopenharmony_ci#else
5458c2ecf20Sopenharmony_cistatic inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
5468c2ecf20Sopenharmony_ci	struct platform_device *pdev)
5478c2ecf20Sopenharmony_ci{
5488c2ecf20Sopenharmony_ci	return 0;
5498c2ecf20Sopenharmony_ci}
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_cistatic inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
5528c2ecf20Sopenharmony_ci{
5538c2ecf20Sopenharmony_ci	return 0;
5548c2ecf20Sopenharmony_ci}
5558c2ecf20Sopenharmony_ci#endif
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci/*
5588c2ecf20Sopenharmony_ci *Controls
5598c2ecf20Sopenharmony_ci */
5608c2ecf20Sopenharmony_cistruct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
5618c2ecf20Sopenharmony_ci				  void *data, const char *long_name,
5628c2ecf20Sopenharmony_ci				  const char *prefix);
5638c2ecf20Sopenharmony_ciint snd_soc_add_component_controls(struct snd_soc_component *component,
5648c2ecf20Sopenharmony_ci	const struct snd_kcontrol_new *controls, unsigned int num_controls);
5658c2ecf20Sopenharmony_ciint snd_soc_add_card_controls(struct snd_soc_card *soc_card,
5668c2ecf20Sopenharmony_ci	const struct snd_kcontrol_new *controls, int num_controls);
5678c2ecf20Sopenharmony_ciint snd_soc_add_dai_controls(struct snd_soc_dai *dai,
5688c2ecf20Sopenharmony_ci	const struct snd_kcontrol_new *controls, int num_controls);
5698c2ecf20Sopenharmony_ciint snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
5708c2ecf20Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
5718c2ecf20Sopenharmony_ciint snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
5728c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5738c2ecf20Sopenharmony_ciint snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
5748c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5758c2ecf20Sopenharmony_ciint snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
5768c2ecf20Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
5778c2ecf20Sopenharmony_ciint snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
5788c2ecf20Sopenharmony_ci			  struct snd_ctl_elem_info *uinfo);
5798c2ecf20Sopenharmony_ci#define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info
5808c2ecf20Sopenharmony_ciint snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
5818c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5828c2ecf20Sopenharmony_ciint snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
5838c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5848c2ecf20Sopenharmony_ci#define snd_soc_get_volsw_2r snd_soc_get_volsw
5858c2ecf20Sopenharmony_ci#define snd_soc_put_volsw_2r snd_soc_put_volsw
5868c2ecf20Sopenharmony_ciint snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
5878c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5888c2ecf20Sopenharmony_ciint snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
5898c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5908c2ecf20Sopenharmony_ciint snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
5918c2ecf20Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
5928c2ecf20Sopenharmony_ciint snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
5938c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5948c2ecf20Sopenharmony_ciint snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
5958c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
5968c2ecf20Sopenharmony_ciint snd_soc_limit_volume(struct snd_soc_card *card,
5978c2ecf20Sopenharmony_ci	const char *name, int max);
5988c2ecf20Sopenharmony_ciint snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
5998c2ecf20Sopenharmony_ci		       struct snd_ctl_elem_info *uinfo);
6008c2ecf20Sopenharmony_ciint snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
6018c2ecf20Sopenharmony_ci		      struct snd_ctl_elem_value *ucontrol);
6028c2ecf20Sopenharmony_ciint snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
6038c2ecf20Sopenharmony_ci		      struct snd_ctl_elem_value *ucontrol);
6048c2ecf20Sopenharmony_ciint snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
6058c2ecf20Sopenharmony_ci	struct snd_ctl_elem_info *ucontrol);
6068c2ecf20Sopenharmony_ciint snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
6078c2ecf20Sopenharmony_ci	unsigned int size, unsigned int __user *tlv);
6088c2ecf20Sopenharmony_ciint snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
6098c2ecf20Sopenharmony_ci	struct snd_ctl_elem_info *uinfo);
6108c2ecf20Sopenharmony_ciint snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
6118c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
6128c2ecf20Sopenharmony_ciint snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
6138c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
6148c2ecf20Sopenharmony_ciint snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
6158c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
6168c2ecf20Sopenharmony_ciint snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
6178c2ecf20Sopenharmony_ci	struct snd_ctl_elem_value *ucontrol);
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci/**
6208c2ecf20Sopenharmony_ci * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
6218c2ecf20Sopenharmony_ci *
6228c2ecf20Sopenharmony_ci * @pin:    name of the pin to update
6238c2ecf20Sopenharmony_ci * @mask:   bits to check for in reported jack status
6248c2ecf20Sopenharmony_ci * @invert: if non-zero then pin is enabled when status is not reported
6258c2ecf20Sopenharmony_ci * @list:   internal list entry
6268c2ecf20Sopenharmony_ci */
6278c2ecf20Sopenharmony_cistruct snd_soc_jack_pin {
6288c2ecf20Sopenharmony_ci	struct list_head list;
6298c2ecf20Sopenharmony_ci	const char *pin;
6308c2ecf20Sopenharmony_ci	int mask;
6318c2ecf20Sopenharmony_ci	bool invert;
6328c2ecf20Sopenharmony_ci};
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ci/**
6358c2ecf20Sopenharmony_ci * struct snd_soc_jack_zone - Describes voltage zones of jack detection
6368c2ecf20Sopenharmony_ci *
6378c2ecf20Sopenharmony_ci * @min_mv: start voltage in mv
6388c2ecf20Sopenharmony_ci * @max_mv: end voltage in mv
6398c2ecf20Sopenharmony_ci * @jack_type: type of jack that is expected for this voltage
6408c2ecf20Sopenharmony_ci * @debounce_time: debounce_time for jack, codec driver should wait for this
6418c2ecf20Sopenharmony_ci *		duration before reading the adc for voltages
6428c2ecf20Sopenharmony_ci * @list:   internal list entry
6438c2ecf20Sopenharmony_ci */
6448c2ecf20Sopenharmony_cistruct snd_soc_jack_zone {
6458c2ecf20Sopenharmony_ci	unsigned int min_mv;
6468c2ecf20Sopenharmony_ci	unsigned int max_mv;
6478c2ecf20Sopenharmony_ci	unsigned int jack_type;
6488c2ecf20Sopenharmony_ci	unsigned int debounce_time;
6498c2ecf20Sopenharmony_ci	struct list_head list;
6508c2ecf20Sopenharmony_ci};
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci/**
6538c2ecf20Sopenharmony_ci * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
6548c2ecf20Sopenharmony_ci *
6558c2ecf20Sopenharmony_ci * @gpio:         legacy gpio number
6568c2ecf20Sopenharmony_ci * @idx:          gpio descriptor index within the function of the GPIO
6578c2ecf20Sopenharmony_ci *                consumer device
6588c2ecf20Sopenharmony_ci * @gpiod_dev:    GPIO consumer device
6598c2ecf20Sopenharmony_ci * @name:         gpio name. Also as connection ID for the GPIO consumer
6608c2ecf20Sopenharmony_ci *                device function name lookup
6618c2ecf20Sopenharmony_ci * @report:       value to report when jack detected
6628c2ecf20Sopenharmony_ci * @invert:       report presence in low state
6638c2ecf20Sopenharmony_ci * @debounce_time: debounce time in ms
6648c2ecf20Sopenharmony_ci * @wake:	  enable as wake source
6658c2ecf20Sopenharmony_ci * @jack_status_check: callback function which overrides the detection
6668c2ecf20Sopenharmony_ci *		       to provide more complex checks (eg, reading an
6678c2ecf20Sopenharmony_ci *		       ADC).
6688c2ecf20Sopenharmony_ci */
6698c2ecf20Sopenharmony_cistruct snd_soc_jack_gpio {
6708c2ecf20Sopenharmony_ci	unsigned int gpio;
6718c2ecf20Sopenharmony_ci	unsigned int idx;
6728c2ecf20Sopenharmony_ci	struct device *gpiod_dev;
6738c2ecf20Sopenharmony_ci	const char *name;
6748c2ecf20Sopenharmony_ci	int report;
6758c2ecf20Sopenharmony_ci	int invert;
6768c2ecf20Sopenharmony_ci	int debounce_time;
6778c2ecf20Sopenharmony_ci	bool wake;
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci	/* private: */
6808c2ecf20Sopenharmony_ci	struct snd_soc_jack *jack;
6818c2ecf20Sopenharmony_ci	struct delayed_work work;
6828c2ecf20Sopenharmony_ci	struct notifier_block pm_notifier;
6838c2ecf20Sopenharmony_ci	struct gpio_desc *desc;
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci	void *data;
6868c2ecf20Sopenharmony_ci	/* public: */
6878c2ecf20Sopenharmony_ci	int (*jack_status_check)(void *data);
6888c2ecf20Sopenharmony_ci};
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_cistruct snd_soc_jack {
6918c2ecf20Sopenharmony_ci	struct mutex mutex;
6928c2ecf20Sopenharmony_ci	struct snd_jack *jack;
6938c2ecf20Sopenharmony_ci	struct snd_soc_card *card;
6948c2ecf20Sopenharmony_ci	struct list_head pins;
6958c2ecf20Sopenharmony_ci	int status;
6968c2ecf20Sopenharmony_ci	struct blocking_notifier_head notifier;
6978c2ecf20Sopenharmony_ci	struct list_head jack_zones;
6988c2ecf20Sopenharmony_ci};
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci/* SoC PCM stream information */
7018c2ecf20Sopenharmony_cistruct snd_soc_pcm_stream {
7028c2ecf20Sopenharmony_ci	const char *stream_name;
7038c2ecf20Sopenharmony_ci	u64 formats;			/* SNDRV_PCM_FMTBIT_* */
7048c2ecf20Sopenharmony_ci	unsigned int rates;		/* SNDRV_PCM_RATE_* */
7058c2ecf20Sopenharmony_ci	unsigned int rate_min;		/* min rate */
7068c2ecf20Sopenharmony_ci	unsigned int rate_max;		/* max rate */
7078c2ecf20Sopenharmony_ci	unsigned int channels_min;	/* min channels */
7088c2ecf20Sopenharmony_ci	unsigned int channels_max;	/* max channels */
7098c2ecf20Sopenharmony_ci	unsigned int sig_bits;		/* number of bits of content */
7108c2ecf20Sopenharmony_ci};
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_ci/* SoC audio ops */
7138c2ecf20Sopenharmony_cistruct snd_soc_ops {
7148c2ecf20Sopenharmony_ci	int (*startup)(struct snd_pcm_substream *);
7158c2ecf20Sopenharmony_ci	void (*shutdown)(struct snd_pcm_substream *);
7168c2ecf20Sopenharmony_ci	int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
7178c2ecf20Sopenharmony_ci	int (*hw_free)(struct snd_pcm_substream *);
7188c2ecf20Sopenharmony_ci	int (*prepare)(struct snd_pcm_substream *);
7198c2ecf20Sopenharmony_ci	int (*trigger)(struct snd_pcm_substream *, int);
7208c2ecf20Sopenharmony_ci};
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_cistruct snd_soc_compr_ops {
7238c2ecf20Sopenharmony_ci	int (*startup)(struct snd_compr_stream *);
7248c2ecf20Sopenharmony_ci	void (*shutdown)(struct snd_compr_stream *);
7258c2ecf20Sopenharmony_ci	int (*set_params)(struct snd_compr_stream *);
7268c2ecf20Sopenharmony_ci	int (*trigger)(struct snd_compr_stream *);
7278c2ecf20Sopenharmony_ci};
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_cistruct snd_soc_component*
7308c2ecf20Sopenharmony_cisnd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
7318c2ecf20Sopenharmony_ci		       const char *driver_name);
7328c2ecf20Sopenharmony_ci
7338c2ecf20Sopenharmony_cistruct snd_soc_dai_link_component {
7348c2ecf20Sopenharmony_ci	const char *name;
7358c2ecf20Sopenharmony_ci	struct device_node *of_node;
7368c2ecf20Sopenharmony_ci	const char *dai_name;
7378c2ecf20Sopenharmony_ci};
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_cistruct snd_soc_dai_link {
7408c2ecf20Sopenharmony_ci	/* config - must be set by machine driver */
7418c2ecf20Sopenharmony_ci	const char *name;			/* Codec name */
7428c2ecf20Sopenharmony_ci	const char *stream_name;		/* Stream name */
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci	/*
7458c2ecf20Sopenharmony_ci	 * You MAY specify the link's CPU-side device, either by device name,
7468c2ecf20Sopenharmony_ci	 * or by DT/OF node, but not both. If this information is omitted,
7478c2ecf20Sopenharmony_ci	 * the CPU-side DAI is matched using .cpu_dai_name only, which hence
7488c2ecf20Sopenharmony_ci	 * must be globally unique. These fields are currently typically used
7498c2ecf20Sopenharmony_ci	 * only for codec to codec links, or systems using device tree.
7508c2ecf20Sopenharmony_ci	 */
7518c2ecf20Sopenharmony_ci	/*
7528c2ecf20Sopenharmony_ci	 * You MAY specify the DAI name of the CPU DAI. If this information is
7538c2ecf20Sopenharmony_ci	 * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
7548c2ecf20Sopenharmony_ci	 * only, which only works well when that device exposes a single DAI.
7558c2ecf20Sopenharmony_ci	 */
7568c2ecf20Sopenharmony_ci	struct snd_soc_dai_link_component *cpus;
7578c2ecf20Sopenharmony_ci	unsigned int num_cpus;
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	/*
7608c2ecf20Sopenharmony_ci	 * You MUST specify the link's codec, either by device name, or by
7618c2ecf20Sopenharmony_ci	 * DT/OF node, but not both.
7628c2ecf20Sopenharmony_ci	 */
7638c2ecf20Sopenharmony_ci	/* You MUST specify the DAI name within the codec */
7648c2ecf20Sopenharmony_ci	struct snd_soc_dai_link_component *codecs;
7658c2ecf20Sopenharmony_ci	unsigned int num_codecs;
7668c2ecf20Sopenharmony_ci
7678c2ecf20Sopenharmony_ci	/*
7688c2ecf20Sopenharmony_ci	 * You MAY specify the link's platform/PCM/DMA driver, either by
7698c2ecf20Sopenharmony_ci	 * device name, or by DT/OF node, but not both. Some forms of link
7708c2ecf20Sopenharmony_ci	 * do not need a platform. In such case, platforms are not mandatory.
7718c2ecf20Sopenharmony_ci	 */
7728c2ecf20Sopenharmony_ci	struct snd_soc_dai_link_component *platforms;
7738c2ecf20Sopenharmony_ci	unsigned int num_platforms;
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ci	int id;	/* optional ID for machine driver link identification */
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci	const struct snd_soc_pcm_stream *params;
7788c2ecf20Sopenharmony_ci	unsigned int num_params;
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_ci	unsigned int dai_fmt;           /* format to set on init */
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci	/* codec/machine specific init - e.g. add machine controls */
7858c2ecf20Sopenharmony_ci	int (*init)(struct snd_soc_pcm_runtime *rtd);
7868c2ecf20Sopenharmony_ci
7878c2ecf20Sopenharmony_ci	/* codec/machine specific exit - dual of init() */
7888c2ecf20Sopenharmony_ci	void (*exit)(struct snd_soc_pcm_runtime *rtd);
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci	/* optional hw_params re-writing for BE and FE sync */
7918c2ecf20Sopenharmony_ci	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
7928c2ecf20Sopenharmony_ci			struct snd_pcm_hw_params *params);
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci	/* machine stream operations */
7958c2ecf20Sopenharmony_ci	const struct snd_soc_ops *ops;
7968c2ecf20Sopenharmony_ci	const struct snd_soc_compr_ops *compr_ops;
7978c2ecf20Sopenharmony_ci
7988c2ecf20Sopenharmony_ci	/* Mark this pcm with non atomic ops */
7998c2ecf20Sopenharmony_ci	unsigned int nonatomic:1;
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_ci	/* For unidirectional dai links */
8028c2ecf20Sopenharmony_ci	unsigned int playback_only:1;
8038c2ecf20Sopenharmony_ci	unsigned int capture_only:1;
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_ci	/* Keep DAI active over suspend */
8068c2ecf20Sopenharmony_ci	unsigned int ignore_suspend:1;
8078c2ecf20Sopenharmony_ci
8088c2ecf20Sopenharmony_ci	/* Symmetry requirements */
8098c2ecf20Sopenharmony_ci	unsigned int symmetric_rates:1;
8108c2ecf20Sopenharmony_ci	unsigned int symmetric_channels:1;
8118c2ecf20Sopenharmony_ci	unsigned int symmetric_samplebits:1;
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_ci	/* Do not create a PCM for this DAI link (Backend link) */
8148c2ecf20Sopenharmony_ci	unsigned int no_pcm:1;
8158c2ecf20Sopenharmony_ci
8168c2ecf20Sopenharmony_ci	/* This DAI link can route to other DAI links at runtime (Frontend)*/
8178c2ecf20Sopenharmony_ci	unsigned int dynamic:1;
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci	/* DPCM capture and Playback support */
8208c2ecf20Sopenharmony_ci	unsigned int dpcm_capture:1;
8218c2ecf20Sopenharmony_ci	unsigned int dpcm_playback:1;
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci	/* DPCM used FE & BE merged format */
8248c2ecf20Sopenharmony_ci	unsigned int dpcm_merged_format:1;
8258c2ecf20Sopenharmony_ci	/* DPCM used FE & BE merged channel */
8268c2ecf20Sopenharmony_ci	unsigned int dpcm_merged_chan:1;
8278c2ecf20Sopenharmony_ci	/* DPCM used FE & BE merged rate */
8288c2ecf20Sopenharmony_ci	unsigned int dpcm_merged_rate:1;
8298c2ecf20Sopenharmony_ci
8308c2ecf20Sopenharmony_ci	/* pmdown_time is ignored at stop */
8318c2ecf20Sopenharmony_ci	unsigned int ignore_pmdown_time:1;
8328c2ecf20Sopenharmony_ci
8338c2ecf20Sopenharmony_ci	/* Do not create a PCM for this DAI link (Backend link) */
8348c2ecf20Sopenharmony_ci	unsigned int ignore:1;
8358c2ecf20Sopenharmony_ci
8368c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
8378c2ecf20Sopenharmony_ci	struct snd_soc_dobj dobj; /* For topology */
8388c2ecf20Sopenharmony_ci#endif
8398c2ecf20Sopenharmony_ci};
8408c2ecf20Sopenharmony_ci#define for_each_link_codecs(link, i, codec)				\
8418c2ecf20Sopenharmony_ci	for ((i) = 0;							\
8428c2ecf20Sopenharmony_ci	     ((i) < link->num_codecs) && ((codec) = &link->codecs[i]);	\
8438c2ecf20Sopenharmony_ci	     (i)++)
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_ci#define for_each_link_platforms(link, i, platform)			\
8468c2ecf20Sopenharmony_ci	for ((i) = 0;							\
8478c2ecf20Sopenharmony_ci	     ((i) < link->num_platforms) &&				\
8488c2ecf20Sopenharmony_ci	     ((platform) = &link->platforms[i]);			\
8498c2ecf20Sopenharmony_ci	     (i)++)
8508c2ecf20Sopenharmony_ci
8518c2ecf20Sopenharmony_ci#define for_each_link_cpus(link, i, cpu)				\
8528c2ecf20Sopenharmony_ci	for ((i) = 0;							\
8538c2ecf20Sopenharmony_ci	     ((i) < link->num_cpus) && ((cpu) = &link->cpus[i]);	\
8548c2ecf20Sopenharmony_ci	     (i)++)
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_ci/*
8578c2ecf20Sopenharmony_ci * Sample 1 : Single CPU/Codec/Platform
8588c2ecf20Sopenharmony_ci *
8598c2ecf20Sopenharmony_ci * SND_SOC_DAILINK_DEFS(test,
8608c2ecf20Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
8618c2ecf20Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
8628c2ecf20Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
8638c2ecf20Sopenharmony_ci *
8648c2ecf20Sopenharmony_ci * struct snd_soc_dai_link link = {
8658c2ecf20Sopenharmony_ci *	...
8668c2ecf20Sopenharmony_ci *	SND_SOC_DAILINK_REG(test),
8678c2ecf20Sopenharmony_ci * };
8688c2ecf20Sopenharmony_ci *
8698c2ecf20Sopenharmony_ci * Sample 2 : Multi CPU/Codec, no Platform
8708c2ecf20Sopenharmony_ci *
8718c2ecf20Sopenharmony_ci * SND_SOC_DAILINK_DEFS(test,
8728c2ecf20Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
8738c2ecf20Sopenharmony_ci *			   COMP_CPU("cpu_dai2")),
8748c2ecf20Sopenharmony_ci *	DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
8758c2ecf20Sopenharmony_ci *			   COMP_CODEC("codec2", "codec_dai2")));
8768c2ecf20Sopenharmony_ci *
8778c2ecf20Sopenharmony_ci * struct snd_soc_dai_link link = {
8788c2ecf20Sopenharmony_ci *	...
8798c2ecf20Sopenharmony_ci *	SND_SOC_DAILINK_REG(test),
8808c2ecf20Sopenharmony_ci * };
8818c2ecf20Sopenharmony_ci *
8828c2ecf20Sopenharmony_ci * Sample 3 : Define each CPU/Codec/Platform manually
8838c2ecf20Sopenharmony_ci *
8848c2ecf20Sopenharmony_ci * SND_SOC_DAILINK_DEF(test_cpu,
8858c2ecf20Sopenharmony_ci *		DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
8868c2ecf20Sopenharmony_ci *				   COMP_CPU("cpu_dai2")));
8878c2ecf20Sopenharmony_ci * SND_SOC_DAILINK_DEF(test_codec,
8888c2ecf20Sopenharmony_ci *		DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
8898c2ecf20Sopenharmony_ci *				   COMP_CODEC("codec2", "codec_dai2")));
8908c2ecf20Sopenharmony_ci * SND_SOC_DAILINK_DEF(test_platform,
8918c2ecf20Sopenharmony_ci *		DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
8928c2ecf20Sopenharmony_ci *
8938c2ecf20Sopenharmony_ci * struct snd_soc_dai_link link = {
8948c2ecf20Sopenharmony_ci *	...
8958c2ecf20Sopenharmony_ci *	SND_SOC_DAILINK_REG(test_cpu,
8968c2ecf20Sopenharmony_ci *			    test_codec,
8978c2ecf20Sopenharmony_ci *			    test_platform),
8988c2ecf20Sopenharmony_ci * };
8998c2ecf20Sopenharmony_ci *
9008c2ecf20Sopenharmony_ci * Sample 4 : Sample3 without platform
9018c2ecf20Sopenharmony_ci *
9028c2ecf20Sopenharmony_ci * struct snd_soc_dai_link link = {
9038c2ecf20Sopenharmony_ci *	...
9048c2ecf20Sopenharmony_ci *	SND_SOC_DAILINK_REG(test_cpu,
9058c2ecf20Sopenharmony_ci *			    test_codec);
9068c2ecf20Sopenharmony_ci * };
9078c2ecf20Sopenharmony_ci */
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_REG1(name)	 SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
9108c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
9118c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_REG3(cpu, codec, platform)	\
9128c2ecf20Sopenharmony_ci	.cpus		= cpu,				\
9138c2ecf20Sopenharmony_ci	.num_cpus	= ARRAY_SIZE(cpu),		\
9148c2ecf20Sopenharmony_ci	.codecs		= codec,			\
9158c2ecf20Sopenharmony_ci	.num_codecs	= ARRAY_SIZE(codec),		\
9168c2ecf20Sopenharmony_ci	.platforms	= platform,			\
9178c2ecf20Sopenharmony_ci	.num_platforms	= ARRAY_SIZE(platform)
9188c2ecf20Sopenharmony_ci
9198c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
9208c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_REG(...) \
9218c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_REGx(__VA_ARGS__,		\
9228c2ecf20Sopenharmony_ci			SND_SOC_DAILINK_REG3,	\
9238c2ecf20Sopenharmony_ci			SND_SOC_DAILINK_REG2,	\
9248c2ecf20Sopenharmony_ci			SND_SOC_DAILINK_REG1)(__VA_ARGS__)
9258c2ecf20Sopenharmony_ci
9268c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_DEF(name, def...)		\
9278c2ecf20Sopenharmony_ci	static struct snd_soc_dai_link_component name[]	= { def }
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_ci#define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...)	\
9308c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_DEF(name##_cpus, cpu);			\
9318c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_DEF(name##_codecs, codec);		\
9328c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_DEF(name##_platforms, platform)
9338c2ecf20Sopenharmony_ci
9348c2ecf20Sopenharmony_ci#define DAILINK_COMP_ARRAY(param...)	param
9358c2ecf20Sopenharmony_ci#define COMP_EMPTY()			{ }
9368c2ecf20Sopenharmony_ci#define COMP_CPU(_dai)			{ .dai_name = _dai, }
9378c2ecf20Sopenharmony_ci#define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
9388c2ecf20Sopenharmony_ci#define COMP_PLATFORM(_name)		{ .name = _name }
9398c2ecf20Sopenharmony_ci#define COMP_AUX(_name)			{ .name = _name }
9408c2ecf20Sopenharmony_ci#define COMP_CODEC_CONF(_name)		{ .name = _name }
9418c2ecf20Sopenharmony_ci#define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
9428c2ecf20Sopenharmony_ci
9438c2ecf20Sopenharmony_ciextern struct snd_soc_dai_link_component null_dailink_component[0];
9448c2ecf20Sopenharmony_ci
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_cistruct snd_soc_codec_conf {
9478c2ecf20Sopenharmony_ci	/*
9488c2ecf20Sopenharmony_ci	 * specify device either by device name, or by
9498c2ecf20Sopenharmony_ci	 * DT/OF node, but not both.
9508c2ecf20Sopenharmony_ci	 */
9518c2ecf20Sopenharmony_ci	struct snd_soc_dai_link_component dlc;
9528c2ecf20Sopenharmony_ci
9538c2ecf20Sopenharmony_ci	/*
9548c2ecf20Sopenharmony_ci	 * optional map of kcontrol, widget and path name prefixes that are
9558c2ecf20Sopenharmony_ci	 * associated per device
9568c2ecf20Sopenharmony_ci	 */
9578c2ecf20Sopenharmony_ci	const char *name_prefix;
9588c2ecf20Sopenharmony_ci};
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_cistruct snd_soc_aux_dev {
9618c2ecf20Sopenharmony_ci	/*
9628c2ecf20Sopenharmony_ci	 * specify multi-codec either by device name, or by
9638c2ecf20Sopenharmony_ci	 * DT/OF node, but not both.
9648c2ecf20Sopenharmony_ci	 */
9658c2ecf20Sopenharmony_ci	struct snd_soc_dai_link_component dlc;
9668c2ecf20Sopenharmony_ci
9678c2ecf20Sopenharmony_ci	/* codec/machine specific init - e.g. add machine controls */
9688c2ecf20Sopenharmony_ci	int (*init)(struct snd_soc_component *component);
9698c2ecf20Sopenharmony_ci};
9708c2ecf20Sopenharmony_ci
9718c2ecf20Sopenharmony_ci/* SoC card */
9728c2ecf20Sopenharmony_cistruct snd_soc_card {
9738c2ecf20Sopenharmony_ci	const char *name;
9748c2ecf20Sopenharmony_ci	const char *long_name;
9758c2ecf20Sopenharmony_ci	const char *driver_name;
9768c2ecf20Sopenharmony_ci	const char *components;
9778c2ecf20Sopenharmony_ci#ifdef CONFIG_DMI
9788c2ecf20Sopenharmony_ci	char dmi_longname[80];
9798c2ecf20Sopenharmony_ci#endif /* CONFIG_DMI */
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI
9828c2ecf20Sopenharmony_ci	/*
9838c2ecf20Sopenharmony_ci	 * PCI does not define 0 as invalid, so pci_subsystem_set indicates
9848c2ecf20Sopenharmony_ci	 * whether a value has been written to these fields.
9858c2ecf20Sopenharmony_ci	 */
9868c2ecf20Sopenharmony_ci	unsigned short pci_subsystem_vendor;
9878c2ecf20Sopenharmony_ci	unsigned short pci_subsystem_device;
9888c2ecf20Sopenharmony_ci	bool pci_subsystem_set;
9898c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI */
9908c2ecf20Sopenharmony_ci
9918c2ecf20Sopenharmony_ci	char topology_shortname[32];
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_ci	struct device *dev;
9948c2ecf20Sopenharmony_ci	struct snd_card *snd_card;
9958c2ecf20Sopenharmony_ci	struct module *owner;
9968c2ecf20Sopenharmony_ci
9978c2ecf20Sopenharmony_ci	struct mutex mutex;
9988c2ecf20Sopenharmony_ci	struct mutex dapm_mutex;
9998c2ecf20Sopenharmony_ci
10008c2ecf20Sopenharmony_ci	/* Mutex for PCM operations */
10018c2ecf20Sopenharmony_ci	struct mutex pcm_mutex;
10028c2ecf20Sopenharmony_ci	enum snd_soc_pcm_subclass pcm_subclass;
10038c2ecf20Sopenharmony_ci
10048c2ecf20Sopenharmony_ci	spinlock_t dpcm_lock;
10058c2ecf20Sopenharmony_ci
10068c2ecf20Sopenharmony_ci	int (*probe)(struct snd_soc_card *card);
10078c2ecf20Sopenharmony_ci	int (*late_probe)(struct snd_soc_card *card);
10088c2ecf20Sopenharmony_ci	int (*remove)(struct snd_soc_card *card);
10098c2ecf20Sopenharmony_ci
10108c2ecf20Sopenharmony_ci	/* the pre and post PM functions are used to do any PM work before and
10118c2ecf20Sopenharmony_ci	 * after the codec and DAI's do any PM work. */
10128c2ecf20Sopenharmony_ci	int (*suspend_pre)(struct snd_soc_card *card);
10138c2ecf20Sopenharmony_ci	int (*suspend_post)(struct snd_soc_card *card);
10148c2ecf20Sopenharmony_ci	int (*resume_pre)(struct snd_soc_card *card);
10158c2ecf20Sopenharmony_ci	int (*resume_post)(struct snd_soc_card *card);
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci	/* callbacks */
10188c2ecf20Sopenharmony_ci	int (*set_bias_level)(struct snd_soc_card *,
10198c2ecf20Sopenharmony_ci			      struct snd_soc_dapm_context *dapm,
10208c2ecf20Sopenharmony_ci			      enum snd_soc_bias_level level);
10218c2ecf20Sopenharmony_ci	int (*set_bias_level_post)(struct snd_soc_card *,
10228c2ecf20Sopenharmony_ci				   struct snd_soc_dapm_context *dapm,
10238c2ecf20Sopenharmony_ci				   enum snd_soc_bias_level level);
10248c2ecf20Sopenharmony_ci
10258c2ecf20Sopenharmony_ci	int (*add_dai_link)(struct snd_soc_card *,
10268c2ecf20Sopenharmony_ci			    struct snd_soc_dai_link *link);
10278c2ecf20Sopenharmony_ci	void (*remove_dai_link)(struct snd_soc_card *,
10288c2ecf20Sopenharmony_ci			    struct snd_soc_dai_link *link);
10298c2ecf20Sopenharmony_ci
10308c2ecf20Sopenharmony_ci	long pmdown_time;
10318c2ecf20Sopenharmony_ci
10328c2ecf20Sopenharmony_ci	/* CPU <--> Codec DAI links  */
10338c2ecf20Sopenharmony_ci	struct snd_soc_dai_link *dai_link;  /* predefined links only */
10348c2ecf20Sopenharmony_ci	int num_links;  /* predefined links only */
10358c2ecf20Sopenharmony_ci
10368c2ecf20Sopenharmony_ci	struct list_head rtd_list;
10378c2ecf20Sopenharmony_ci	int num_rtd;
10388c2ecf20Sopenharmony_ci
10398c2ecf20Sopenharmony_ci	/* optional codec specific configuration */
10408c2ecf20Sopenharmony_ci	struct snd_soc_codec_conf *codec_conf;
10418c2ecf20Sopenharmony_ci	int num_configs;
10428c2ecf20Sopenharmony_ci
10438c2ecf20Sopenharmony_ci	/*
10448c2ecf20Sopenharmony_ci	 * optional auxiliary devices such as amplifiers or codecs with DAI
10458c2ecf20Sopenharmony_ci	 * link unused
10468c2ecf20Sopenharmony_ci	 */
10478c2ecf20Sopenharmony_ci	struct snd_soc_aux_dev *aux_dev;
10488c2ecf20Sopenharmony_ci	int num_aux_devs;
10498c2ecf20Sopenharmony_ci	struct list_head aux_comp_list;
10508c2ecf20Sopenharmony_ci
10518c2ecf20Sopenharmony_ci	const struct snd_kcontrol_new *controls;
10528c2ecf20Sopenharmony_ci	int num_controls;
10538c2ecf20Sopenharmony_ci
10548c2ecf20Sopenharmony_ci	/*
10558c2ecf20Sopenharmony_ci	 * Card-specific routes and widgets.
10568c2ecf20Sopenharmony_ci	 * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
10578c2ecf20Sopenharmony_ci	 */
10588c2ecf20Sopenharmony_ci	const struct snd_soc_dapm_widget *dapm_widgets;
10598c2ecf20Sopenharmony_ci	int num_dapm_widgets;
10608c2ecf20Sopenharmony_ci	const struct snd_soc_dapm_route *dapm_routes;
10618c2ecf20Sopenharmony_ci	int num_dapm_routes;
10628c2ecf20Sopenharmony_ci	const struct snd_soc_dapm_widget *of_dapm_widgets;
10638c2ecf20Sopenharmony_ci	int num_of_dapm_widgets;
10648c2ecf20Sopenharmony_ci	const struct snd_soc_dapm_route *of_dapm_routes;
10658c2ecf20Sopenharmony_ci	int num_of_dapm_routes;
10668c2ecf20Sopenharmony_ci
10678c2ecf20Sopenharmony_ci	/* lists of probed devices belonging to this card */
10688c2ecf20Sopenharmony_ci	struct list_head component_dev_list;
10698c2ecf20Sopenharmony_ci	struct list_head list;
10708c2ecf20Sopenharmony_ci
10718c2ecf20Sopenharmony_ci	struct list_head widgets;
10728c2ecf20Sopenharmony_ci	struct list_head paths;
10738c2ecf20Sopenharmony_ci	struct list_head dapm_list;
10748c2ecf20Sopenharmony_ci	struct list_head dapm_dirty;
10758c2ecf20Sopenharmony_ci
10768c2ecf20Sopenharmony_ci	/* attached dynamic objects */
10778c2ecf20Sopenharmony_ci	struct list_head dobj_list;
10788c2ecf20Sopenharmony_ci
10798c2ecf20Sopenharmony_ci	/* Generic DAPM context for the card */
10808c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context dapm;
10818c2ecf20Sopenharmony_ci	struct snd_soc_dapm_stats dapm_stats;
10828c2ecf20Sopenharmony_ci	struct snd_soc_dapm_update *update;
10838c2ecf20Sopenharmony_ci
10848c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
10858c2ecf20Sopenharmony_ci	struct dentry *debugfs_card_root;
10868c2ecf20Sopenharmony_ci#endif
10878c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
10888c2ecf20Sopenharmony_ci	struct work_struct deferred_resume_work;
10898c2ecf20Sopenharmony_ci#endif
10908c2ecf20Sopenharmony_ci	u32 pop_time;
10918c2ecf20Sopenharmony_ci
10928c2ecf20Sopenharmony_ci	/* bit field */
10938c2ecf20Sopenharmony_ci	unsigned int instantiated:1;
10948c2ecf20Sopenharmony_ci	unsigned int topology_shortname_created:1;
10958c2ecf20Sopenharmony_ci	unsigned int fully_routed:1;
10968c2ecf20Sopenharmony_ci	unsigned int disable_route_checks:1;
10978c2ecf20Sopenharmony_ci	unsigned int probed:1;
10988c2ecf20Sopenharmony_ci
10998c2ecf20Sopenharmony_ci	void *drvdata;
11008c2ecf20Sopenharmony_ci};
11018c2ecf20Sopenharmony_ci#define for_each_card_prelinks(card, i, link)				\
11028c2ecf20Sopenharmony_ci	for ((i) = 0;							\
11038c2ecf20Sopenharmony_ci	     ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
11048c2ecf20Sopenharmony_ci	     (i)++)
11058c2ecf20Sopenharmony_ci#define for_each_card_pre_auxs(card, i, aux)				\
11068c2ecf20Sopenharmony_ci	for ((i) = 0;							\
11078c2ecf20Sopenharmony_ci	     ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
11088c2ecf20Sopenharmony_ci	     (i)++)
11098c2ecf20Sopenharmony_ci
11108c2ecf20Sopenharmony_ci#define for_each_card_rtds(card, rtd)			\
11118c2ecf20Sopenharmony_ci	list_for_each_entry(rtd, &(card)->rtd_list, list)
11128c2ecf20Sopenharmony_ci#define for_each_card_rtds_safe(card, rtd, _rtd)	\
11138c2ecf20Sopenharmony_ci	list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
11148c2ecf20Sopenharmony_ci
11158c2ecf20Sopenharmony_ci#define for_each_card_auxs(card, component)			\
11168c2ecf20Sopenharmony_ci	list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
11178c2ecf20Sopenharmony_ci#define for_each_card_auxs_safe(card, component, _comp)	\
11188c2ecf20Sopenharmony_ci	list_for_each_entry_safe(component, _comp,	\
11198c2ecf20Sopenharmony_ci				 &card->aux_comp_list, card_aux_list)
11208c2ecf20Sopenharmony_ci
11218c2ecf20Sopenharmony_ci#define for_each_card_components(card, component)			\
11228c2ecf20Sopenharmony_ci	list_for_each_entry(component, &(card)->component_dev_list, card_list)
11238c2ecf20Sopenharmony_ci
11248c2ecf20Sopenharmony_ci#define for_each_card_dapms(card, dapm)					\
11258c2ecf20Sopenharmony_ci	list_for_each_entry(dapm, &card->dapm_list, list)
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_ci#define for_each_card_widgets(card, w)\
11288c2ecf20Sopenharmony_ci	list_for_each_entry(w, &card->widgets, list)
11298c2ecf20Sopenharmony_ci#define for_each_card_widgets_safe(card, w, _w)	\
11308c2ecf20Sopenharmony_ci	list_for_each_entry_safe(w, _w, &card->widgets, list)
11318c2ecf20Sopenharmony_ci
11328c2ecf20Sopenharmony_ci/* SoC machine DAI configuration, glues a codec and cpu DAI together */
11338c2ecf20Sopenharmony_cistruct snd_soc_pcm_runtime {
11348c2ecf20Sopenharmony_ci	struct device *dev;
11358c2ecf20Sopenharmony_ci	struct snd_soc_card *card;
11368c2ecf20Sopenharmony_ci	struct snd_soc_dai_link *dai_link;
11378c2ecf20Sopenharmony_ci	struct snd_pcm_ops ops;
11388c2ecf20Sopenharmony_ci
11398c2ecf20Sopenharmony_ci	unsigned int params_select; /* currently selected param for dai link */
11408c2ecf20Sopenharmony_ci
11418c2ecf20Sopenharmony_ci	/* Dynamic PCM BE runtime data */
11428c2ecf20Sopenharmony_ci	struct snd_soc_dpcm_runtime dpcm[2];
11438c2ecf20Sopenharmony_ci
11448c2ecf20Sopenharmony_ci	long pmdown_time;
11458c2ecf20Sopenharmony_ci
11468c2ecf20Sopenharmony_ci	/* runtime devices */
11478c2ecf20Sopenharmony_ci	struct snd_pcm *pcm;
11488c2ecf20Sopenharmony_ci	struct snd_compr *compr;
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_ci	/*
11518c2ecf20Sopenharmony_ci	 * dais = cpu_dai + codec_dai
11528c2ecf20Sopenharmony_ci	 * see
11538c2ecf20Sopenharmony_ci	 *	soc_new_pcm_runtime()
11548c2ecf20Sopenharmony_ci	 *	asoc_rtd_to_cpu()
11558c2ecf20Sopenharmony_ci	 *	asoc_rtd_to_codec()
11568c2ecf20Sopenharmony_ci	 */
11578c2ecf20Sopenharmony_ci	struct snd_soc_dai **dais;
11588c2ecf20Sopenharmony_ci	unsigned int num_codecs;
11598c2ecf20Sopenharmony_ci	unsigned int num_cpus;
11608c2ecf20Sopenharmony_ci
11618c2ecf20Sopenharmony_ci	struct snd_soc_dapm_widget *playback_widget;
11628c2ecf20Sopenharmony_ci	struct snd_soc_dapm_widget *capture_widget;
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_ci	struct delayed_work delayed_work;
11658c2ecf20Sopenharmony_ci	void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
11668c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
11678c2ecf20Sopenharmony_ci	struct dentry *debugfs_dpcm_root;
11688c2ecf20Sopenharmony_ci#endif
11698c2ecf20Sopenharmony_ci
11708c2ecf20Sopenharmony_ci	unsigned int num; /* 0-based and monotonic increasing */
11718c2ecf20Sopenharmony_ci	struct list_head list; /* rtd list of the soc card */
11728c2ecf20Sopenharmony_ci
11738c2ecf20Sopenharmony_ci	/* function mark */
11748c2ecf20Sopenharmony_ci	struct snd_pcm_substream *mark_startup;
11758c2ecf20Sopenharmony_ci
11768c2ecf20Sopenharmony_ci	/* bit field */
11778c2ecf20Sopenharmony_ci	unsigned int pop_wait:1;
11788c2ecf20Sopenharmony_ci	unsigned int fe_compr:1; /* for Dynamic PCM */
11798c2ecf20Sopenharmony_ci
11808c2ecf20Sopenharmony_ci	int num_components;
11818c2ecf20Sopenharmony_ci	struct snd_soc_component *components[]; /* CPU/Codec/Platform */
11828c2ecf20Sopenharmony_ci};
11838c2ecf20Sopenharmony_ci/* see soc_new_pcm_runtime()  */
11848c2ecf20Sopenharmony_ci#define asoc_rtd_to_cpu(rtd, n)   (rtd)->dais[n]
11858c2ecf20Sopenharmony_ci#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
11868c2ecf20Sopenharmony_ci#define asoc_substream_to_rtd(substream) \
11878c2ecf20Sopenharmony_ci	(struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
11888c2ecf20Sopenharmony_ci
11898c2ecf20Sopenharmony_ci#define for_each_rtd_components(rtd, i, component)			\
11908c2ecf20Sopenharmony_ci	for ((i) = 0, component = NULL;					\
11918c2ecf20Sopenharmony_ci	     ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
11928c2ecf20Sopenharmony_ci	     (i)++)
11938c2ecf20Sopenharmony_ci#define for_each_rtd_cpu_dais(rtd, i, dai)				\
11948c2ecf20Sopenharmony_ci	for ((i) = 0;							\
11958c2ecf20Sopenharmony_ci	     ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
11968c2ecf20Sopenharmony_ci	     (i)++)
11978c2ecf20Sopenharmony_ci#define for_each_rtd_cpu_dais_rollback(rtd, i, dai)		\
11988c2ecf20Sopenharmony_ci	for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_cpu(rtd, i));)
11998c2ecf20Sopenharmony_ci#define for_each_rtd_codec_dais(rtd, i, dai)				\
12008c2ecf20Sopenharmony_ci	for ((i) = 0;							\
12018c2ecf20Sopenharmony_ci	     ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
12028c2ecf20Sopenharmony_ci	     (i)++)
12038c2ecf20Sopenharmony_ci#define for_each_rtd_codec_dais_rollback(rtd, i, dai)		\
12048c2ecf20Sopenharmony_ci	for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_codec(rtd, i));)
12058c2ecf20Sopenharmony_ci#define for_each_rtd_dais(rtd, i, dai)					\
12068c2ecf20Sopenharmony_ci	for ((i) = 0;							\
12078c2ecf20Sopenharmony_ci	     ((i) < (rtd)->num_cpus + (rtd)->num_codecs) &&		\
12088c2ecf20Sopenharmony_ci		     ((dai) = (rtd)->dais[i]);				\
12098c2ecf20Sopenharmony_ci	     (i)++)
12108c2ecf20Sopenharmony_ci#define for_each_rtd_dais_rollback(rtd, i, dai)		\
12118c2ecf20Sopenharmony_ci	for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);)
12128c2ecf20Sopenharmony_ci
12138c2ecf20Sopenharmony_civoid snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
12148c2ecf20Sopenharmony_ci
12158c2ecf20Sopenharmony_ci/* mixer control */
12168c2ecf20Sopenharmony_cistruct soc_mixer_control {
12178c2ecf20Sopenharmony_ci	int min, max, platform_max;
12188c2ecf20Sopenharmony_ci	int reg, rreg;
12198c2ecf20Sopenharmony_ci	unsigned int shift, rshift;
12208c2ecf20Sopenharmony_ci	unsigned int sign_bit;
12218c2ecf20Sopenharmony_ci	unsigned int invert:1;
12228c2ecf20Sopenharmony_ci	unsigned int autodisable:1;
12238c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
12248c2ecf20Sopenharmony_ci	struct snd_soc_dobj dobj;
12258c2ecf20Sopenharmony_ci#endif
12268c2ecf20Sopenharmony_ci};
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_cistruct soc_bytes {
12298c2ecf20Sopenharmony_ci	int base;
12308c2ecf20Sopenharmony_ci	int num_regs;
12318c2ecf20Sopenharmony_ci	u32 mask;
12328c2ecf20Sopenharmony_ci};
12338c2ecf20Sopenharmony_ci
12348c2ecf20Sopenharmony_cistruct soc_bytes_ext {
12358c2ecf20Sopenharmony_ci	int max;
12368c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
12378c2ecf20Sopenharmony_ci	struct snd_soc_dobj dobj;
12388c2ecf20Sopenharmony_ci#endif
12398c2ecf20Sopenharmony_ci	/* used for TLV byte control */
12408c2ecf20Sopenharmony_ci	int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
12418c2ecf20Sopenharmony_ci			unsigned int size);
12428c2ecf20Sopenharmony_ci	int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
12438c2ecf20Sopenharmony_ci			unsigned int size);
12448c2ecf20Sopenharmony_ci};
12458c2ecf20Sopenharmony_ci
12468c2ecf20Sopenharmony_ci/* multi register control */
12478c2ecf20Sopenharmony_cistruct soc_mreg_control {
12488c2ecf20Sopenharmony_ci	long min, max;
12498c2ecf20Sopenharmony_ci	unsigned int regbase, regcount, nbits, invert;
12508c2ecf20Sopenharmony_ci};
12518c2ecf20Sopenharmony_ci
12528c2ecf20Sopenharmony_ci/* enumerated kcontrol */
12538c2ecf20Sopenharmony_cistruct soc_enum {
12548c2ecf20Sopenharmony_ci	int reg;
12558c2ecf20Sopenharmony_ci	unsigned char shift_l;
12568c2ecf20Sopenharmony_ci	unsigned char shift_r;
12578c2ecf20Sopenharmony_ci	unsigned int items;
12588c2ecf20Sopenharmony_ci	unsigned int mask;
12598c2ecf20Sopenharmony_ci	const char * const *texts;
12608c2ecf20Sopenharmony_ci	const unsigned int *values;
12618c2ecf20Sopenharmony_ci	unsigned int autodisable:1;
12628c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_SOC_TOPOLOGY
12638c2ecf20Sopenharmony_ci	struct snd_soc_dobj dobj;
12648c2ecf20Sopenharmony_ci#endif
12658c2ecf20Sopenharmony_ci};
12668c2ecf20Sopenharmony_ci
12678c2ecf20Sopenharmony_cistatic inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
12688c2ecf20Sopenharmony_ci{
12698c2ecf20Sopenharmony_ci	if (mc->reg == mc->rreg && mc->shift == mc->rshift)
12708c2ecf20Sopenharmony_ci		return false;
12718c2ecf20Sopenharmony_ci	/*
12728c2ecf20Sopenharmony_ci	 * mc->reg == mc->rreg && mc->shift != mc->rshift, or
12738c2ecf20Sopenharmony_ci	 * mc->reg != mc->rreg means that the control is
12748c2ecf20Sopenharmony_ci	 * stereo (bits in one register or in two registers)
12758c2ecf20Sopenharmony_ci	 */
12768c2ecf20Sopenharmony_ci	return true;
12778c2ecf20Sopenharmony_ci}
12788c2ecf20Sopenharmony_ci
12798c2ecf20Sopenharmony_cistatic inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
12808c2ecf20Sopenharmony_ci	unsigned int val)
12818c2ecf20Sopenharmony_ci{
12828c2ecf20Sopenharmony_ci	unsigned int i;
12838c2ecf20Sopenharmony_ci
12848c2ecf20Sopenharmony_ci	if (!e->values)
12858c2ecf20Sopenharmony_ci		return val;
12868c2ecf20Sopenharmony_ci
12878c2ecf20Sopenharmony_ci	for (i = 0; i < e->items; i++)
12888c2ecf20Sopenharmony_ci		if (val == e->values[i])
12898c2ecf20Sopenharmony_ci			return i;
12908c2ecf20Sopenharmony_ci
12918c2ecf20Sopenharmony_ci	return 0;
12928c2ecf20Sopenharmony_ci}
12938c2ecf20Sopenharmony_ci
12948c2ecf20Sopenharmony_cistatic inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
12958c2ecf20Sopenharmony_ci	unsigned int item)
12968c2ecf20Sopenharmony_ci{
12978c2ecf20Sopenharmony_ci	if (!e->values)
12988c2ecf20Sopenharmony_ci		return item;
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	return e->values[item];
13018c2ecf20Sopenharmony_ci}
13028c2ecf20Sopenharmony_ci
13038c2ecf20Sopenharmony_ci/**
13048c2ecf20Sopenharmony_ci * snd_soc_kcontrol_component() - Returns the component that registered the
13058c2ecf20Sopenharmony_ci *  control
13068c2ecf20Sopenharmony_ci * @kcontrol: The control for which to get the component
13078c2ecf20Sopenharmony_ci *
13088c2ecf20Sopenharmony_ci * Note: This function will work correctly if the control has been registered
13098c2ecf20Sopenharmony_ci * for a component. With snd_soc_add_codec_controls() or via table based
13108c2ecf20Sopenharmony_ci * setup for either a CODEC or component driver. Otherwise the behavior is
13118c2ecf20Sopenharmony_ci * undefined.
13128c2ecf20Sopenharmony_ci */
13138c2ecf20Sopenharmony_cistatic inline struct snd_soc_component *snd_soc_kcontrol_component(
13148c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol)
13158c2ecf20Sopenharmony_ci{
13168c2ecf20Sopenharmony_ci	return snd_kcontrol_chip(kcontrol);
13178c2ecf20Sopenharmony_ci}
13188c2ecf20Sopenharmony_ci
13198c2ecf20Sopenharmony_ciint snd_soc_util_init(void);
13208c2ecf20Sopenharmony_civoid snd_soc_util_exit(void);
13218c2ecf20Sopenharmony_ci
13228c2ecf20Sopenharmony_ciint snd_soc_of_parse_card_name(struct snd_soc_card *card,
13238c2ecf20Sopenharmony_ci			       const char *propname);
13248c2ecf20Sopenharmony_ciint snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
13258c2ecf20Sopenharmony_ci					  const char *propname);
13268c2ecf20Sopenharmony_ciint snd_soc_of_get_slot_mask(struct device_node *np,
13278c2ecf20Sopenharmony_ci			     const char *prop_name,
13288c2ecf20Sopenharmony_ci			     unsigned int *mask);
13298c2ecf20Sopenharmony_ciint snd_soc_of_parse_tdm_slot(struct device_node *np,
13308c2ecf20Sopenharmony_ci			      unsigned int *tx_mask,
13318c2ecf20Sopenharmony_ci			      unsigned int *rx_mask,
13328c2ecf20Sopenharmony_ci			      unsigned int *slots,
13338c2ecf20Sopenharmony_ci			      unsigned int *slot_width);
13348c2ecf20Sopenharmony_civoid snd_soc_of_parse_node_prefix(struct device_node *np,
13358c2ecf20Sopenharmony_ci				   struct snd_soc_codec_conf *codec_conf,
13368c2ecf20Sopenharmony_ci				   struct device_node *of_node,
13378c2ecf20Sopenharmony_ci				   const char *propname);
13388c2ecf20Sopenharmony_cistatic inline
13398c2ecf20Sopenharmony_civoid snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
13408c2ecf20Sopenharmony_ci				   struct snd_soc_codec_conf *codec_conf,
13418c2ecf20Sopenharmony_ci				   struct device_node *of_node,
13428c2ecf20Sopenharmony_ci				   const char *propname)
13438c2ecf20Sopenharmony_ci{
13448c2ecf20Sopenharmony_ci	snd_soc_of_parse_node_prefix(card->dev->of_node,
13458c2ecf20Sopenharmony_ci				     codec_conf, of_node, propname);
13468c2ecf20Sopenharmony_ci}
13478c2ecf20Sopenharmony_ci
13488c2ecf20Sopenharmony_ciint snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
13498c2ecf20Sopenharmony_ci				   const char *propname);
13508c2ecf20Sopenharmony_ciint snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
13518c2ecf20Sopenharmony_ciunsigned int snd_soc_of_parse_daifmt(struct device_node *np,
13528c2ecf20Sopenharmony_ci				     const char *prefix,
13538c2ecf20Sopenharmony_ci				     struct device_node **bitclkmaster,
13548c2ecf20Sopenharmony_ci				     struct device_node **framemaster);
13558c2ecf20Sopenharmony_ciint snd_soc_get_dai_id(struct device_node *ep);
13568c2ecf20Sopenharmony_ciint snd_soc_get_dai_name(struct of_phandle_args *args,
13578c2ecf20Sopenharmony_ci			 const char **dai_name);
13588c2ecf20Sopenharmony_ciint snd_soc_of_get_dai_name(struct device_node *of_node,
13598c2ecf20Sopenharmony_ci			    const char **dai_name);
13608c2ecf20Sopenharmony_ciint snd_soc_of_get_dai_link_codecs(struct device *dev,
13618c2ecf20Sopenharmony_ci				   struct device_node *of_node,
13628c2ecf20Sopenharmony_ci				   struct snd_soc_dai_link *dai_link);
13638c2ecf20Sopenharmony_civoid snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
13648c2ecf20Sopenharmony_ci
13658c2ecf20Sopenharmony_ciint snd_soc_add_pcm_runtime(struct snd_soc_card *card,
13668c2ecf20Sopenharmony_ci			    struct snd_soc_dai_link *dai_link);
13678c2ecf20Sopenharmony_civoid snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
13688c2ecf20Sopenharmony_ci				struct snd_soc_pcm_runtime *rtd);
13698c2ecf20Sopenharmony_ci
13708c2ecf20Sopenharmony_cistruct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
13718c2ecf20Sopenharmony_ci					 struct snd_soc_dai_driver *dai_drv,
13728c2ecf20Sopenharmony_ci					 bool legacy_dai_naming);
13738c2ecf20Sopenharmony_cistruct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
13748c2ecf20Sopenharmony_ci					      struct snd_soc_component *component,
13758c2ecf20Sopenharmony_ci					      struct snd_soc_dai_driver *dai_drv,
13768c2ecf20Sopenharmony_ci					      bool legacy_dai_naming);
13778c2ecf20Sopenharmony_civoid snd_soc_unregister_dai(struct snd_soc_dai *dai);
13788c2ecf20Sopenharmony_ci
13798c2ecf20Sopenharmony_cistruct snd_soc_dai *snd_soc_find_dai(
13808c2ecf20Sopenharmony_ci	const struct snd_soc_dai_link_component *dlc);
13818c2ecf20Sopenharmony_cistruct snd_soc_dai *snd_soc_find_dai_with_mutex(
13828c2ecf20Sopenharmony_ci	const struct snd_soc_dai_link_component *dlc);
13838c2ecf20Sopenharmony_ci
13848c2ecf20Sopenharmony_ci#include <sound/soc-dai.h>
13858c2ecf20Sopenharmony_ci
13868c2ecf20Sopenharmony_cistatic inline
13878c2ecf20Sopenharmony_ciint snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
13888c2ecf20Sopenharmony_ci					  const char *platform_name)
13898c2ecf20Sopenharmony_ci{
13908c2ecf20Sopenharmony_ci	struct snd_soc_dai_link *dai_link;
13918c2ecf20Sopenharmony_ci	const char *name;
13928c2ecf20Sopenharmony_ci	int i;
13938c2ecf20Sopenharmony_ci
13948c2ecf20Sopenharmony_ci	if (!platform_name) /* nothing to do */
13958c2ecf20Sopenharmony_ci		return 0;
13968c2ecf20Sopenharmony_ci
13978c2ecf20Sopenharmony_ci	/* set platform name for each dailink */
13988c2ecf20Sopenharmony_ci	for_each_card_prelinks(card, i, dai_link) {
13998c2ecf20Sopenharmony_ci		name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
14008c2ecf20Sopenharmony_ci		if (!name)
14018c2ecf20Sopenharmony_ci			return -ENOMEM;
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_ci		if (!dai_link->platforms)
14048c2ecf20Sopenharmony_ci			return -EINVAL;
14058c2ecf20Sopenharmony_ci
14068c2ecf20Sopenharmony_ci		/* only single platform is supported for now */
14078c2ecf20Sopenharmony_ci		dai_link->platforms->name = name;
14088c2ecf20Sopenharmony_ci	}
14098c2ecf20Sopenharmony_ci
14108c2ecf20Sopenharmony_ci	return 0;
14118c2ecf20Sopenharmony_ci}
14128c2ecf20Sopenharmony_ci
14138c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
14148c2ecf20Sopenharmony_ciextern struct dentry *snd_soc_debugfs_root;
14158c2ecf20Sopenharmony_ci#endif
14168c2ecf20Sopenharmony_ci
14178c2ecf20Sopenharmony_ciextern const struct dev_pm_ops snd_soc_pm_ops;
14188c2ecf20Sopenharmony_ci
14198c2ecf20Sopenharmony_ci/* Helper functions */
14208c2ecf20Sopenharmony_cistatic inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
14218c2ecf20Sopenharmony_ci{
14228c2ecf20Sopenharmony_ci	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
14238c2ecf20Sopenharmony_ci}
14248c2ecf20Sopenharmony_ci
14258c2ecf20Sopenharmony_cistatic inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
14268c2ecf20Sopenharmony_ci{
14278c2ecf20Sopenharmony_ci	mutex_unlock(&dapm->card->dapm_mutex);
14288c2ecf20Sopenharmony_ci}
14298c2ecf20Sopenharmony_ci
14308c2ecf20Sopenharmony_ci#include <sound/soc-component.h>
14318c2ecf20Sopenharmony_ci#include <sound/soc-card.h>
14328c2ecf20Sopenharmony_ci
14338c2ecf20Sopenharmony_ci#endif
1434