1 /* SPDX-License-Identifier: GPL-2.0
2  *  Copyright (c) 2020 Intel Corporation
3  */
4 
5 /*
6  *  sof_sdw_common.h - prototypes for common helpers
7  */
8 
9 #ifndef SND_SOC_SOF_SDW_COMMON_H
10 #define SND_SOC_SOF_SDW_COMMON_H
11 
12 #include <linux/bits.h>
13 #include <linux/types.h>
14 
15 #define MAX_NO_PROPS 2
16 #define MAX_HDMI_NUM 4
17 #define SDW_DMIC_DAI_ID 4
18 #define SDW_MAX_CPU_DAIS 16
19 #define SDW_INTEL_BIDIR_PDI_BASE 2
20 
21 /* 8 combinations with 4 links + unused group 0 */
22 #define SDW_MAX_GROUPS 9
23 
24 enum {
25 	SOF_RT711_JD_SRC_JD1 = 1,
26 	SOF_RT711_JD_SRC_JD2 = 2,
27 };
28 
29 enum {
30 	SOF_PRE_TGL_HDMI_COUNT = 3,
31 	SOF_TGL_HDMI_COUNT = 4,
32 };
33 
34 enum {
35 	SOF_I2S_SSP0 = BIT(0),
36 	SOF_I2S_SSP1 = BIT(1),
37 	SOF_I2S_SSP2 = BIT(2),
38 	SOF_I2S_SSP3 = BIT(3),
39 	SOF_I2S_SSP4 = BIT(4),
40 	SOF_I2S_SSP5 = BIT(5),
41 };
42 
43 #define SOF_RT711_JDSRC(quirk)		((quirk) & GENMASK(1, 0))
44 #define SOF_SDW_FOUR_SPK		BIT(2)
45 #define SOF_SDW_TGL_HDMI		BIT(3)
46 #define SOF_SDW_PCH_DMIC		BIT(4)
47 #define SOF_SSP_PORT(x)		(((x) & GENMASK(5, 0)) << 5)
48 #define SOF_SSP_GET_PORT(quirk)	(((quirk) >> 5) & GENMASK(5, 0))
49 #define SOF_RT715_DAI_ID_FIX		BIT(11)
50 #define SOF_SDW_NO_AGGREGATION		BIT(12)
51 
52 struct sof_sdw_codec_info {
53 	const int id;
54 	int amp_num;
55 	const u8 acpi_id[ACPI_ID_LEN];
56 	const bool direction[2]; // playback & capture support
57 	const char *dai_name;
58 	const struct snd_soc_ops *ops;
59 
60 	int  (*init)(const struct snd_soc_acpi_link_adr *link,
61 		     struct snd_soc_dai_link *dai_links,
62 		     struct sof_sdw_codec_info *info,
63 		     bool playback);
64 };
65 
66 struct mc_private {
67 	struct list_head hdmi_pcm_list;
68 	bool common_hdmi_codec_drv;
69 	struct snd_soc_jack sdw_headset;
70 };
71 
72 extern unsigned long sof_sdw_quirk;
73 
74 /* generic HDMI support */
75 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
76 
77 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
78 
79 /* DMIC support */
80 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
81 
82 /* RT711 support */
83 int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
84 		       struct snd_soc_dai_link *dai_links,
85 		       struct sof_sdw_codec_info *info,
86 		       bool playback);
87 
88 /* RT700 support */
89 int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
90 		       struct snd_soc_dai_link *dai_links,
91 		       struct sof_sdw_codec_info *info,
92 		       bool playback);
93 
94 /* RT1308 support */
95 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
96 
97 int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link,
98 			struct snd_soc_dai_link *dai_links,
99 			struct sof_sdw_codec_info *info,
100 			bool playback);
101 
102 /* RT715 support */
103 int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link,
104 		       struct snd_soc_dai_link *dai_links,
105 		       struct sof_sdw_codec_info *info,
106 		       bool playback);
107 
108 /* RT5682 support */
109 int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
110 			struct snd_soc_dai_link *dai_links,
111 			struct sof_sdw_codec_info *info,
112 			bool playback);
113 
114 #endif
115