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_DMIC_DAI_ID 4 19 #define SDW_MAX_CPU_DAIS 16 20 #define SDW_INTEL_BIDIR_PDI_BASE 2 21 22 /* 8 combinations with 4 links + unused group 0 */ 23 #define SDW_MAX_GROUPS 9 24 25 enum { 26 SOF_PRE_TGL_HDMI_COUNT = 3, 27 SOF_TGL_HDMI_COUNT = 4, 28 }; 29 30 enum { 31 SOF_I2S_SSP0 = BIT(0), 32 SOF_I2S_SSP1 = BIT(1), 33 SOF_I2S_SSP2 = BIT(2), 34 SOF_I2S_SSP3 = BIT(3), 35 SOF_I2S_SSP4 = BIT(4), 36 SOF_I2S_SSP5 = BIT(5), 37 }; 38 39 #define SOF_RT711_JDSRC(quirk) ((quirk) & GENMASK(1, 0)) 40 #define SOF_SDW_FOUR_SPK BIT(2) 41 #define SOF_SDW_TGL_HDMI BIT(3) 42 #define SOF_SDW_PCH_DMIC BIT(4) 43 #define SOF_SSP_PORT(x) (((x) & GENMASK(5, 0)) << 5) 44 #define SOF_SSP_GET_PORT(quirk) (((quirk) >> 5) & GENMASK(5, 0)) 45 #define SOF_RT715_DAI_ID_FIX BIT(11) 46 #define SOF_SDW_NO_AGGREGATION BIT(12) 47 48 struct sof_sdw_codec_info { 49 const int part_id; 50 const int version_id; 51 int amp_num; 52 const u8 acpi_id[ACPI_ID_LEN]; 53 const bool direction[2]; // playback & capture support 54 const bool ignore_pch_dmic; 55 const char *dai_name; 56 const struct snd_soc_ops *ops; 57 58 int (*init)(const struct snd_soc_acpi_link_adr *link, 59 struct snd_soc_dai_link *dai_links, 60 struct sof_sdw_codec_info *info, 61 bool playback); 62 63 int (*exit)(struct device *dev, struct snd_soc_dai_link *dai_link); 64 bool late_probe; 65 int (*codec_card_late_probe)(struct snd_soc_card *card); 66 }; 67 68 struct mc_private { 69 struct list_head hdmi_pcm_list; 70 bool common_hdmi_codec_drv; 71 bool idisp_codec; 72 struct snd_soc_jack sdw_headset; 73 }; 74 75 extern unsigned long sof_sdw_quirk; 76 77 int sdw_startup(struct snd_pcm_substream *substream); 78 int sdw_prepare(struct snd_pcm_substream *substream); 79 int sdw_trigger(struct snd_pcm_substream *substream, int cmd); 80 int sdw_hw_free(struct snd_pcm_substream *substream); 81 void sdw_shutdown(struct snd_pcm_substream *substream); 82 83 /* generic HDMI support */ 84 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd); 85 86 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card); 87 88 /* DMIC support */ 89 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd); 90 91 /* RT711 support */ 92 int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link, 93 struct snd_soc_dai_link *dai_links, 94 struct sof_sdw_codec_info *info, 95 bool playback); 96 int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link); 97 98 /* RT711-SDCA support */ 99 int sof_sdw_rt711_sdca_init(const struct snd_soc_acpi_link_adr *link, 100 struct snd_soc_dai_link *dai_links, 101 struct sof_sdw_codec_info *info, 102 bool playback); 103 int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link); 104 105 /* RT700 support */ 106 int sof_sdw_rt700_init(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 111 /* RT1308 support */ 112 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops; 113 114 int sof_sdw_rt1308_init(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 119 /* RT1316 support */ 120 int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link, 121 struct snd_soc_dai_link *dai_links, 122 struct sof_sdw_codec_info *info, 123 bool playback); 124 125 /* RT715 support */ 126 int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link, 127 struct snd_soc_dai_link *dai_links, 128 struct sof_sdw_codec_info *info, 129 bool playback); 130 131 /* RT715-SDCA support */ 132 int sof_sdw_rt715_sdca_init(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 137 /* MAX98373 support */ 138 int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link, 139 struct snd_soc_dai_link *dai_links, 140 struct sof_sdw_codec_info *info, 141 bool playback); 142 143 int sof_sdw_mx8373_late_probe(struct snd_soc_card *card); 144 145 /* RT5682 support */ 146 int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link, 147 struct snd_soc_dai_link *dai_links, 148 struct sof_sdw_codec_info *info, 149 bool playback); 150 151 #endif 152