WIP FPC-III support
[linux/fpc-iii.git] / sound / soc / intel / boards / sof_sdw_common.h
blobf3cb6796363e7fcb8ce024d437be7018d936e25c
1 /* SPDX-License-Identifier: GPL-2.0-only
2 * Copyright (c) 2020 Intel Corporation
3 */
5 /*
6 * sof_sdw_common.h - prototypes for common helpers
7 */
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_DMIC_DAI_ID 4
19 #define SDW_MAX_CPU_DAIS 16
20 #define SDW_INTEL_BIDIR_PDI_BASE 2
22 /* 8 combinations with 4 links + unused group 0 */
23 #define SDW_MAX_GROUPS 9
25 enum {
26 SOF_RT711_JD_SRC_JD1 = 1,
27 SOF_RT711_JD_SRC_JD2 = 2,
30 enum {
31 SOF_PRE_TGL_HDMI_COUNT = 3,
32 SOF_TGL_HDMI_COUNT = 4,
35 enum {
36 SOF_I2S_SSP0 = BIT(0),
37 SOF_I2S_SSP1 = BIT(1),
38 SOF_I2S_SSP2 = BIT(2),
39 SOF_I2S_SSP3 = BIT(3),
40 SOF_I2S_SSP4 = BIT(4),
41 SOF_I2S_SSP5 = BIT(5),
44 #define SOF_RT711_JDSRC(quirk) ((quirk) & GENMASK(1, 0))
45 #define SOF_SDW_FOUR_SPK BIT(2)
46 #define SOF_SDW_TGL_HDMI BIT(3)
47 #define SOF_SDW_PCH_DMIC BIT(4)
48 #define SOF_SSP_PORT(x) (((x) & GENMASK(5, 0)) << 5)
49 #define SOF_SSP_GET_PORT(quirk) (((quirk) >> 5) & GENMASK(5, 0))
50 #define SOF_RT715_DAI_ID_FIX BIT(11)
51 #define SOF_SDW_NO_AGGREGATION BIT(12)
53 struct sof_sdw_codec_info {
54 const int part_id;
55 const int version_id;
56 int amp_num;
57 const u8 acpi_id[ACPI_ID_LEN];
58 const bool direction[2]; // playback & capture support
59 const char *dai_name;
60 const struct snd_soc_ops *ops;
62 int (*init)(const struct snd_soc_acpi_link_adr *link,
63 struct snd_soc_dai_link *dai_links,
64 struct sof_sdw_codec_info *info,
65 bool playback);
67 int (*exit)(struct device *dev, struct snd_soc_dai_link *dai_link);
68 bool late_probe;
69 int (*codec_card_late_probe)(struct snd_soc_card *card);
72 struct mc_private {
73 struct list_head hdmi_pcm_list;
74 bool common_hdmi_codec_drv;
75 bool idisp_codec;
76 struct snd_soc_jack sdw_headset;
79 extern unsigned long sof_sdw_quirk;
81 int sdw_startup(struct snd_pcm_substream *substream);
82 int sdw_prepare(struct snd_pcm_substream *substream);
83 int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
84 int sdw_hw_free(struct snd_pcm_substream *substream);
85 void sdw_shutdown(struct snd_pcm_substream *substream);
87 /* generic HDMI support */
88 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
90 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
92 /* DMIC support */
93 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
95 /* RT711 support */
96 int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
97 struct snd_soc_dai_link *dai_links,
98 struct sof_sdw_codec_info *info,
99 bool playback);
100 int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
102 /* RT711-SDCA support */
103 int sof_sdw_rt711_sdca_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 int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
109 /* RT700 support */
110 int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
111 struct snd_soc_dai_link *dai_links,
112 struct sof_sdw_codec_info *info,
113 bool playback);
115 /* RT1308 support */
116 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
118 int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link,
119 struct snd_soc_dai_link *dai_links,
120 struct sof_sdw_codec_info *info,
121 bool playback);
123 /* RT1316 support */
124 int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link,
125 struct snd_soc_dai_link *dai_links,
126 struct sof_sdw_codec_info *info,
127 bool playback);
129 /* RT715 support */
130 int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link,
131 struct snd_soc_dai_link *dai_links,
132 struct sof_sdw_codec_info *info,
133 bool playback);
135 /* RT715-SDCA support */
136 int sof_sdw_rt715_sdca_init(const struct snd_soc_acpi_link_adr *link,
137 struct snd_soc_dai_link *dai_links,
138 struct sof_sdw_codec_info *info,
139 bool playback);
141 /* MAX98373 support */
142 int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
143 struct snd_soc_dai_link *dai_links,
144 struct sof_sdw_codec_info *info,
145 bool playback);
147 int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
149 /* RT5682 support */
150 int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
151 struct snd_soc_dai_link *dai_links,
152 struct sof_sdw_codec_info *info,
153 bool playback);
155 #endif