1 /* SPDX-License-Identifier: GPL-2.0-only 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 #include <sound/soc.h> 15 16 #define MAX_NO_PROPS 2 17 #define MAX_HDMI_NUM 4 18 #define SDW_UNUSED_DAI_ID -1 19 #define SDW_JACK_OUT_DAI_ID 0 20 #define SDW_JACK_IN_DAI_ID 1 21 #define SDW_AMP_OUT_DAI_ID 2 22 #define SDW_AMP_IN_DAI_ID 3 23 #define SDW_DMIC_DAI_ID 4 24 #define SDW_MAX_CPU_DAIS 16 25 #define SDW_INTEL_BIDIR_PDI_BASE 2 26 27 /* 8 combinations with 4 links + unused group 0 */ 28 #define SDW_MAX_GROUPS 9 29 30 enum { 31 SOF_PRE_TGL_HDMI_COUNT = 3, 32 SOF_TGL_HDMI_COUNT = 4, 33 }; 34 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), 42 }; 43 44 #define SOF_JACK_JDSRC(quirk) ((quirk) & GENMASK(3, 0)) 45 #define SOF_SDW_FOUR_SPK BIT(4) 46 #define SOF_SDW_TGL_HDMI BIT(5) 47 #define SOF_SDW_PCH_DMIC BIT(6) 48 #define SOF_SSP_PORT(x) (((x) & GENMASK(5, 0)) << 7) 49 #define SOF_SSP_GET_PORT(quirk) (((quirk) >> 7) & GENMASK(5, 0)) 50 #define SOF_SDW_NO_AGGREGATION BIT(14) 51 52 /* BT audio offload: reserve 3 bits for future */ 53 #define SOF_BT_OFFLOAD_SSP_SHIFT 15 54 #define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(17, 15)) 55 #define SOF_BT_OFFLOAD_SSP(quirk) \ 56 (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) 57 #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(18) 58 59 #define SOF_SDW_DAI_TYPE_JACK 0 60 #define SOF_SDW_DAI_TYPE_AMP 1 61 #define SOF_SDW_DAI_TYPE_MIC 2 62 63 #define SOF_SDW_MAX_DAI_NUM 3 64 65 struct sof_sdw_codec_info; 66 67 struct sof_sdw_dai_info { 68 const bool direction[2]; /* playback & capture support */ 69 const char *dai_name; 70 const int dai_type; 71 const int dailink[2]; /* dailink id for each direction */ 72 int (*init)(struct snd_soc_card *card, 73 const struct snd_soc_acpi_link_adr *link, 74 struct snd_soc_dai_link *dai_links, 75 struct sof_sdw_codec_info *info, 76 bool playback); 77 int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 78 }; 79 80 struct sof_sdw_codec_info { 81 const int part_id; 82 const int version_id; 83 int amp_num; 84 const u8 acpi_id[ACPI_ID_LEN]; 85 const bool ignore_pch_dmic; 86 const struct snd_soc_ops *ops; 87 struct sof_sdw_dai_info dais[SOF_SDW_MAX_DAI_NUM]; 88 const int dai_num; 89 90 int (*codec_card_late_probe)(struct snd_soc_card *card); 91 }; 92 93 struct mc_private { 94 struct list_head hdmi_pcm_list; 95 bool idisp_codec; 96 struct snd_soc_jack sdw_headset; 97 struct device *headset_codec_dev; /* only one headset per card */ 98 struct device *amp_dev1, *amp_dev2; 99 }; 100 101 extern unsigned long sof_sdw_quirk; 102 103 int sdw_startup(struct snd_pcm_substream *substream); 104 int sdw_prepare(struct snd_pcm_substream *substream); 105 int sdw_trigger(struct snd_pcm_substream *substream, int cmd); 106 int sdw_hw_params(struct snd_pcm_substream *substream, 107 struct snd_pcm_hw_params *params); 108 int sdw_hw_free(struct snd_pcm_substream *substream); 109 void sdw_shutdown(struct snd_pcm_substream *substream); 110 111 /* generic HDMI support */ 112 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd); 113 114 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card); 115 116 /* DMIC support */ 117 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd); 118 119 /* RT711 support */ 120 int sof_sdw_rt711_init(struct snd_soc_card *card, 121 const struct snd_soc_acpi_link_adr *link, 122 struct snd_soc_dai_link *dai_links, 123 struct sof_sdw_codec_info *info, 124 bool playback); 125 int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 126 127 /* RT711-SDCA support */ 128 int sof_sdw_rt_sdca_jack_init(struct snd_soc_card *card, 129 const struct snd_soc_acpi_link_adr *link, 130 struct snd_soc_dai_link *dai_links, 131 struct sof_sdw_codec_info *info, 132 bool playback); 133 int sof_sdw_rt_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 134 135 /* RT712-SDCA support */ 136 int sof_sdw_rt712_sdca_init(struct snd_soc_card *card, 137 const struct snd_soc_acpi_link_adr *link, 138 struct snd_soc_dai_link *dai_links, 139 struct sof_sdw_codec_info *info, 140 bool playback); 141 int sof_sdw_rt712_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 142 int sof_sdw_rt712_spk_init(struct snd_soc_card *card, 143 const struct snd_soc_acpi_link_adr *link, 144 struct snd_soc_dai_link *dai_links, 145 struct sof_sdw_codec_info *info, 146 bool playback); 147 int sof_sdw_rt712_sdca_dmic_init(struct snd_soc_card *card, 148 const struct snd_soc_acpi_link_adr *link, 149 struct snd_soc_dai_link *dai_links, 150 struct sof_sdw_codec_info *info, 151 bool playback); 152 153 /* RT700 support */ 154 int sof_sdw_rt700_init(struct snd_soc_card *card, 155 const struct snd_soc_acpi_link_adr *link, 156 struct snd_soc_dai_link *dai_links, 157 struct sof_sdw_codec_info *info, 158 bool playback); 159 160 /* RT1308 I2S support */ 161 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops; 162 163 /* generic amp support */ 164 int sof_sdw_rt_amp_init(struct snd_soc_card *card, 165 const struct snd_soc_acpi_link_adr *link, 166 struct snd_soc_dai_link *dai_links, 167 struct sof_sdw_codec_info *info, 168 bool playback); 169 int sof_sdw_rt_amp_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 170 171 /* RT1316 support */ 172 173 /* RT715 support */ 174 int sof_sdw_rt715_init(struct snd_soc_card *card, 175 const struct snd_soc_acpi_link_adr *link, 176 struct snd_soc_dai_link *dai_links, 177 struct sof_sdw_codec_info *info, 178 bool playback); 179 180 /* RT715-SDCA support */ 181 int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, 182 const struct snd_soc_acpi_link_adr *link, 183 struct snd_soc_dai_link *dai_links, 184 struct sof_sdw_codec_info *info, 185 bool playback); 186 187 /* MAXIM codec support */ 188 int sof_sdw_maxim_init(struct snd_soc_card *card, 189 const struct snd_soc_acpi_link_adr *link, 190 struct snd_soc_dai_link *dai_links, 191 struct sof_sdw_codec_info *info, 192 bool playback); 193 194 /* RT5682 support */ 195 int sof_sdw_rt5682_init(struct snd_soc_card *card, 196 const struct snd_soc_acpi_link_adr *link, 197 struct snd_soc_dai_link *dai_links, 198 struct sof_sdw_codec_info *info, 199 bool playback); 200 201 /* CS42L42 support */ 202 int sof_sdw_cs42l42_init(struct snd_soc_card *card, 203 const struct snd_soc_acpi_link_adr *link, 204 struct snd_soc_dai_link *dai_links, 205 struct sof_sdw_codec_info *info, 206 bool playback); 207 208 #endif 209