1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
6 * Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
8 * Author: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
13 #include <sound/core.h>
14 #include <sound/jack.h>
15 #include <sound/pcm_params.h>
16 #include <sound/soc-dapm.h>
17 #include <linux/input.h>
18 #include <linux/module.h>
19 #include <sound/soc.h>
21 #include "acp_common.h"
23 #define TDM_CHANNELS 8
25 #define ACP_OPS(priv, cb) ((priv)->ops.cb)
27 #define acp_get_drvdata(card) ((struct acp_card_drvdata *)(card)->drvdata)
44 enum codec_endpoints
{
57 int (*probe
)(struct snd_soc_card
*card
);
58 int (*configure_link
)(struct snd_soc_card
*card
, struct snd_soc_dai_link
*dai_link
);
59 int (*configure_widgets
)(struct snd_soc_card
*card
);
60 int (*suspend_pre
)(struct snd_soc_card
*card
);
61 int (*resume_post
)(struct snd_soc_card
*card
);
64 struct acp_card_drvdata
{
65 unsigned int hs_cpu_id
;
66 unsigned int amp_cpu_id
;
67 unsigned int bt_cpu_id
;
68 unsigned int dmic_cpu_id
;
69 unsigned int hs_codec_id
;
70 unsigned int amp_codec_id
;
71 unsigned int bt_codec_id
;
72 unsigned int dmic_codec_id
;
77 struct acp_mach_ops ops
;
78 struct snd_soc_acpi_mach
*acpi_mach
;
84 int acp_sofdsp_dai_links_create(struct snd_soc_card
*card
);
85 int acp_legacy_dai_links_create(struct snd_soc_card
*card
);
86 extern const struct dmi_system_id acp_quirk_table
[];
88 static inline int acp_ops_probe(struct snd_soc_card
*card
)
91 struct acp_card_drvdata
*priv
= acp_get_drvdata(card
);
93 if (ACP_OPS(priv
, probe
))
94 ret
= ACP_OPS(priv
, probe
)(card
);
98 static inline int acp_ops_configure_link(struct snd_soc_card
*card
,
99 struct snd_soc_dai_link
*dai_link
)
102 struct acp_card_drvdata
*priv
= acp_get_drvdata(card
);
104 if (ACP_OPS(priv
, configure_link
))
105 ret
= ACP_OPS(priv
, configure_link
)(card
, dai_link
);
109 static inline int acp_ops_configure_widgets(struct snd_soc_card
*card
)
112 struct acp_card_drvdata
*priv
= acp_get_drvdata(card
);
114 if (ACP_OPS(priv
, configure_widgets
))
115 ret
= ACP_OPS(priv
, configure_widgets
)(card
);
119 static inline int acp_ops_suspend_pre(struct snd_soc_card
*card
)
122 struct acp_card_drvdata
*priv
= acp_get_drvdata(card
);
124 if (ACP_OPS(priv
, suspend_pre
))
125 ret
= ACP_OPS(priv
, suspend_pre
)(card
);
129 static inline int acp_ops_resume_post(struct snd_soc_card
*card
)
132 struct acp_card_drvdata
*priv
= acp_get_drvdata(card
);
134 if (ACP_OPS(priv
, resume_post
))
135 ret
= ACP_OPS(priv
, resume_post
)(card
);