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_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 22 23 /* 8 combinations with 4 links + unused group 0 */ 24 #define SDW_MAX_GROUPS 9 25 26 enum { 27 SOF_PRE_TGL_HDMI_COUNT = 3, 28 SOF_TGL_HDMI_COUNT = 4, 29 }; 30 31 enum { 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), 38 }; 39 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) 47 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) 54 55 #define SOF_SDW_CODEC_TYPE_JACK 0 56 #define SOF_SDW_CODEC_TYPE_AMP 1 57 #define SOF_SDW_CODEC_TYPE_MIC 2 58 59 struct sof_sdw_codec_info { 60 const int part_id; 61 const int version_id; 62 const int codec_type; 63 int amp_num; 64 const u8 acpi_id[ACPI_ID_LEN]; 65 const bool direction[2]; // playback & capture support 66 const bool ignore_pch_dmic; 67 const char *dai_name; 68 const struct snd_soc_ops *ops; 69 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, 74 bool playback); 75 76 int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 77 int (*codec_card_late_probe)(struct snd_soc_card *card); 78 }; 79 80 struct mc_private { 81 struct list_head hdmi_pcm_list; 82 bool idisp_codec; 83 struct snd_soc_jack sdw_headset; 84 struct device *headset_codec_dev; /* only one headset per card */ 85 struct device *amp_dev1, *amp_dev2; 86 }; 87 88 extern unsigned long sof_sdw_quirk; 89 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); 95 96 /* generic HDMI support */ 97 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd); 98 99 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card); 100 101 /* DMIC support */ 102 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd); 103 104 /* RT711 support */ 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, 109 bool playback); 110 int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 111 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, 117 bool playback); 118 int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 119 120 /* RT700 support */ 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, 125 bool playback); 126 127 /* RT1308 I2S support */ 128 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops; 129 130 /* generic amp support */ 131 int sof_sdw_rt_amp_init(struct snd_soc_card *card, 132 const struct snd_soc_acpi_link_adr *link, 133 struct snd_soc_dai_link *dai_links, 134 struct sof_sdw_codec_info *info, 135 bool playback); 136 int sof_sdw_rt_amp_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 137 138 /* RT1316 support */ 139 140 /* RT715 support */ 141 int sof_sdw_rt715_init(struct snd_soc_card *card, 142 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); 146 147 /* RT715-SDCA support */ 148 int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, 149 const struct snd_soc_acpi_link_adr *link, 150 struct snd_soc_dai_link *dai_links, 151 struct sof_sdw_codec_info *info, 152 bool playback); 153 154 /* MAX98373 support */ 155 int sof_sdw_mx8373_init(struct snd_soc_card *card, 156 const struct snd_soc_acpi_link_adr *link, 157 struct snd_soc_dai_link *dai_links, 158 struct sof_sdw_codec_info *info, 159 bool playback); 160 161 /* RT5682 support */ 162 int sof_sdw_rt5682_init(struct snd_soc_card *card, 163 const struct snd_soc_acpi_link_adr *link, 164 struct snd_soc_dai_link *dai_links, 165 struct sof_sdw_codec_info *info, 166 bool playback); 167 168 #endif 169