0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef SND_SOC_SOF_SDW_COMMON_H
0010 #define SND_SOC_SOF_SDW_COMMON_H
0011
0012 #include <linux/bits.h>
0013 #include <linux/types.h>
0014 #include <sound/soc.h>
0015
0016 #define MAX_NO_PROPS 2
0017 #define MAX_HDMI_NUM 4
0018 #define SDW_AMP_DAI_ID 2
0019 #define SDW_DMIC_DAI_ID 4
0020 #define SDW_MAX_CPU_DAIS 16
0021 #define SDW_INTEL_BIDIR_PDI_BASE 2
0022
0023
0024 #define SDW_MAX_GROUPS 9
0025
0026 enum {
0027 SOF_PRE_TGL_HDMI_COUNT = 3,
0028 SOF_TGL_HDMI_COUNT = 4,
0029 };
0030
0031 enum {
0032 SOF_I2S_SSP0 = BIT(0),
0033 SOF_I2S_SSP1 = BIT(1),
0034 SOF_I2S_SSP2 = BIT(2),
0035 SOF_I2S_SSP3 = BIT(3),
0036 SOF_I2S_SSP4 = BIT(4),
0037 SOF_I2S_SSP5 = BIT(5),
0038 };
0039
0040 #define SOF_RT711_JDSRC(quirk) ((quirk) & GENMASK(3, 0))
0041 #define SOF_SDW_FOUR_SPK BIT(4)
0042 #define SOF_SDW_TGL_HDMI BIT(5)
0043 #define SOF_SDW_PCH_DMIC BIT(6)
0044 #define SOF_SSP_PORT(x) (((x) & GENMASK(5, 0)) << 7)
0045 #define SOF_SSP_GET_PORT(quirk) (((quirk) >> 7) & GENMASK(5, 0))
0046 #define SOF_SDW_NO_AGGREGATION BIT(14)
0047
0048
0049 #define SOF_BT_OFFLOAD_SSP_SHIFT 15
0050 #define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(17, 15))
0051 #define SOF_BT_OFFLOAD_SSP(quirk) \
0052 (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
0053 #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(18)
0054
0055 #define SOF_SDW_CODEC_TYPE_JACK 0
0056 #define SOF_SDW_CODEC_TYPE_AMP 1
0057 #define SOF_SDW_CODEC_TYPE_MIC 2
0058
0059 struct sof_sdw_codec_info {
0060 const int part_id;
0061 const int version_id;
0062 const int codec_type;
0063 int amp_num;
0064 const u8 acpi_id[ACPI_ID_LEN];
0065 const bool direction[2];
0066 const bool ignore_pch_dmic;
0067 const char *dai_name;
0068 const struct snd_soc_ops *ops;
0069
0070 int (*init)(struct snd_soc_card *card,
0071 const struct snd_soc_acpi_link_adr *link,
0072 struct snd_soc_dai_link *dai_links,
0073 struct sof_sdw_codec_info *info,
0074 bool playback);
0075
0076 int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
0077 bool late_probe;
0078 int (*codec_card_late_probe)(struct snd_soc_card *card);
0079 };
0080
0081 struct mc_private {
0082 struct list_head hdmi_pcm_list;
0083 bool idisp_codec;
0084 struct snd_soc_jack sdw_headset;
0085 struct device *headset_codec_dev;
0086 };
0087
0088 extern unsigned long sof_sdw_quirk;
0089
0090 int sdw_startup(struct snd_pcm_substream *substream);
0091 int sdw_prepare(struct snd_pcm_substream *substream);
0092 int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
0093 int sdw_hw_free(struct snd_pcm_substream *substream);
0094 void sdw_shutdown(struct snd_pcm_substream *substream);
0095
0096
0097 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
0098
0099 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
0100
0101
0102 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
0103
0104
0105 int sof_sdw_rt711_init(struct snd_soc_card *card,
0106 const struct snd_soc_acpi_link_adr *link,
0107 struct snd_soc_dai_link *dai_links,
0108 struct sof_sdw_codec_info *info,
0109 bool playback);
0110 int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
0111
0112
0113 int sof_sdw_rt711_sdca_init(struct snd_soc_card *card,
0114 const struct snd_soc_acpi_link_adr *link,
0115 struct snd_soc_dai_link *dai_links,
0116 struct sof_sdw_codec_info *info,
0117 bool playback);
0118 int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
0119
0120
0121 int sof_sdw_rt700_init(struct snd_soc_card *card,
0122 const struct snd_soc_acpi_link_adr *link,
0123 struct snd_soc_dai_link *dai_links,
0124 struct sof_sdw_codec_info *info,
0125 bool playback);
0126
0127
0128 extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
0129
0130 int sof_sdw_rt1308_init(struct snd_soc_card *card,
0131 const struct snd_soc_acpi_link_adr *link,
0132 struct snd_soc_dai_link *dai_links,
0133 struct sof_sdw_codec_info *info,
0134 bool playback);
0135
0136
0137 int sof_sdw_rt1316_init(struct snd_soc_card *card,
0138 const struct snd_soc_acpi_link_adr *link,
0139 struct snd_soc_dai_link *dai_links,
0140 struct sof_sdw_codec_info *info,
0141 bool playback);
0142
0143
0144 int sof_sdw_rt715_init(struct snd_soc_card *card,
0145 const struct snd_soc_acpi_link_adr *link,
0146 struct snd_soc_dai_link *dai_links,
0147 struct sof_sdw_codec_info *info,
0148 bool playback);
0149
0150
0151 int sof_sdw_rt715_sdca_init(struct snd_soc_card *card,
0152 const struct snd_soc_acpi_link_adr *link,
0153 struct snd_soc_dai_link *dai_links,
0154 struct sof_sdw_codec_info *info,
0155 bool playback);
0156
0157
0158 int sof_sdw_mx8373_init(struct snd_soc_card *card,
0159 const struct snd_soc_acpi_link_adr *link,
0160 struct snd_soc_dai_link *dai_links,
0161 struct sof_sdw_codec_info *info,
0162 bool playback);
0163
0164 int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
0165
0166
0167 int sof_sdw_rt5682_init(struct snd_soc_card *card,
0168 const struct snd_soc_acpi_link_adr *link,
0169 struct snd_soc_dai_link *dai_links,
0170 struct sof_sdw_codec_info *info,
0171 bool playback);
0172
0173 #endif