1 /* SPDX-License-Identifier: GPL-2.0-only
2 * Copyright (c) 2020 Intel Corporation
6 * sof_sdw_common.h - prototypes for common helpers
9 #ifndef SND_SOC_SOF_SDW_COMMON_H
10 #define SND_SOC_SOF_SDW_COMMON_H
12 #include <linux/bits.h>
13 #include <linux/types.h>
14 #include <sound/soc.h>
16 #define MAX_NO_PROPS 2
17 #define MAX_HDMI_NUM 4
18 #define SDW_AMP_DAI_ID 2
19 #define SDW_DMIC_DAI_ID 4
20 #define SDW_MAX_CPU_DAIS 16
21 #define SDW_INTEL_BIDIR_PDI_BASE 2
23 /* 8 combinations with 4 links + unused group 0 */
24 #define SDW_MAX_GROUPS 9
27 SOF_PRE_TGL_HDMI_COUNT = 3,
28 SOF_TGL_HDMI_COUNT = 4,
32 SOF_I2S_SSP0 = BIT(0),
33 SOF_I2S_SSP1 = BIT(1),
34 SOF_I2S_SSP2 = BIT(2),
35 SOF_I2S_SSP3 = BIT(3),
36 SOF_I2S_SSP4 = BIT(4),
37 SOF_I2S_SSP5 = BIT(5),
40 #define SOF_RT711_JDSRC(quirk) ((quirk) & GENMASK(3, 0))
41 #define SOF_SDW_FOUR_SPK BIT(4)
42 #define SOF_SDW_TGL_HDMI BIT(5)
43 #define SOF_SDW_PCH_DMIC BIT(6)
44 #define SOF_SSP_PORT(x) (((x) & GENMASK(5, 0)) << 7)
45 #define SOF_SSP_GET_PORT(quirk) (((quirk) >> 7) & GENMASK(5, 0))
46 #define SOF_SDW_NO_AGGREGATION BIT(14)
48 /* BT audio offload: reserve 3 bits for future */
49 #define SOF_BT_OFFLOAD_SSP_SHIFT 15
50 #define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(17, 15))
51 #define SOF_BT_OFFLOAD_SSP(quirk) \
52 (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
53 #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(18)
55 #define SOF_SDW_CODEC_TYPE_JACK 0
56 #define SOF_SDW_CODEC_TYPE_AMP 1
57 #define SOF_SDW_CODEC_TYPE_MIC 2
59 struct sof_sdw_codec_info {
64 const u8 acpi_id[ACPI_ID_LEN];
65 const bool direction[2]; // playback & capture support
66 const bool ignore_pch_dmic;
68 const struct snd_soc_ops *ops;
70 int (*init)(struct snd_soc_card *card,
71 const struct snd_soc_acpi_link_adr *link,
72 struct snd_soc_dai_link *dai_links,
73 struct sof_sdw_codec_info *info,
76 int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
78 int (*codec_card_late_probe)(struct snd_soc_card *card);
82 struct list_head hdmi_pcm_list;
84 struct snd_soc_jack sdw_headset;
85 struct device *headset_codec_dev; /* only one headset per card */
88 extern unsigned long sof_sdw_quirk;
90 int sdw_startup(struct snd_pcm_substream *substream);
91 int sdw_prepare(struct snd_pcm_substream *substream);
92 int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
93 int sdw_hw_free(struct snd_pcm_substream *substream);
94 void sdw_shutdown(struct snd_pcm_substream *substream);
96 /* generic HDMI support */
97 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
99 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
102 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
105 int sof_sdw_rt711_init(struct snd_soc_card *card,
106 const struct snd_soc_acpi_link_adr *link,
107 struct snd_soc_dai_link *dai_links,
108 struct sof_sdw_codec_info *info,
110 int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
112 /* RT711-SDCA support */
113 int sof_sdw_rt711_sdca_init(struct snd_soc_card *card,
114 const struct snd_soc_acpi_link_adr *link,
115 struct snd_soc_dai_link *dai_links,
116 struct sof_sdw_codec_info *info,
118 int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
121 int sof_sdw_rt700_init(struct snd_soc_card *card,
122 const struct snd_soc_acpi_link_adr *link,
123 struct snd_soc_dai_link *dai_links,
124 struct sof_sdw_codec_info *info,
128 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
130 int sof_sdw_rt1308_init(struct snd_soc_card *card,
131 const struct snd_soc_acpi_link_adr *link,
132 struct snd_soc_dai_link *dai_links,
133 struct sof_sdw_codec_info *info,
137 int sof_sdw_rt1316_init(struct snd_soc_card *card,
138 const struct snd_soc_acpi_link_adr *link,
139 struct snd_soc_dai_link *dai_links,
140 struct sof_sdw_codec_info *info,
144 int sof_sdw_rt715_init(struct snd_soc_card *card,
145 const struct snd_soc_acpi_link_adr *link,
146 struct snd_soc_dai_link *dai_links,
147 struct sof_sdw_codec_info *info,
150 /* RT715-SDCA support */
151 int sof_sdw_rt715_sdca_init(struct snd_soc_card *card,
152 const struct snd_soc_acpi_link_adr *link,
153 struct snd_soc_dai_link *dai_links,
154 struct sof_sdw_codec_info *info,
157 /* MAX98373 support */
158 int sof_sdw_mx8373_init(struct snd_soc_card *card,
159 const struct snd_soc_acpi_link_adr *link,
160 struct snd_soc_dai_link *dai_links,
161 struct sof_sdw_codec_info *info,
164 int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
167 int sof_sdw_rt5682_init(struct snd_soc_card *card,
168 const struct snd_soc_acpi_link_adr *link,
169 struct snd_soc_dai_link *dai_links,
170 struct sof_sdw_codec_info *info,