Linux Audio

Check our new training course

Loading...
v6.13.7
 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#include <sound/soc_sdw_utils.h>
16#include "sof_hdmi_common.h"
17
 
18#define MAX_HDMI_NUM 4
19#define SOC_SDW_MAX_CPU_DAIS 16
20#define SOC_SDW_INTEL_BIDIR_PDI_BASE 2
 
21
22/* 8 combinations with 4 links + unused group 0 */
23#define SDW_MAX_GROUPS 9
24
25enum {
 
 
 
 
 
26	SOF_PRE_TGL_HDMI_COUNT = 3,
27	SOF_TGL_HDMI_COUNT = 4,
28};
29
30enum {
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/* Deprecated and no longer supported by the code */
40#define SOC_SDW_FOUR_SPK		BIT(4)
41#define SOF_SDW_TGL_HDMI		BIT(5)
42#define SOC_SDW_PCH_DMIC		BIT(6)
43#define SOF_SSP_PORT(x)		(((x) & GENMASK(5, 0)) << 7)
44#define SOF_SSP_GET_PORT(quirk)	(((quirk) >> 7) & GENMASK(5, 0))
45/* Deprecated and no longer supported by the code */
46#define SOC_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
55struct intel_mc_ctx {
56	struct sof_hdmi_private hdmi;
57	/* To store SDW Pin index for each SoundWire link */
58	unsigned int sdw_pin_index[SDW_INTEL_MAX_LINKS];
59};
60
 
 
 
 
 
 
 
 
61/* generic HDMI support */
62int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
63
64int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66#endif
v5.14.15
  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
 25enum {
 26	SOF_RT711_JD_SRC_JD1 = 1,
 27	SOF_RT711_JD_SRC_JD2 = 2,
 28};
 29
 30enum {
 31	SOF_PRE_TGL_HDMI_COUNT = 3,
 32	SOF_TGL_HDMI_COUNT = 4,
 33};
 34
 35enum {
 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_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)
 52
 53/* BT audio offload: reserve 3 bits for future */
 54#define SOF_BT_OFFLOAD_SSP_SHIFT	13
 55#define SOF_BT_OFFLOAD_SSP_MASK	(GENMASK(15, 13))
 56#define SOF_BT_OFFLOAD_SSP(quirk)	\
 57	(((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
 58#define SOF_SSP_BT_OFFLOAD_PRESENT	BIT(16)
 59
 60struct sof_sdw_codec_info {
 61	const int part_id;
 62	const int version_id;
 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)(const struct snd_soc_acpi_link_adr *link,
 71		     struct snd_soc_dai_link *dai_links,
 72		     struct sof_sdw_codec_info *info,
 73		     bool playback);
 74
 75	int (*exit)(struct device *dev, struct snd_soc_dai_link *dai_link);
 76	bool late_probe;
 77	int (*codec_card_late_probe)(struct snd_soc_card *card);
 78};
 79
 80struct mc_private {
 81	struct list_head hdmi_pcm_list;
 82	bool idisp_codec;
 83	struct snd_soc_jack sdw_headset;
 84};
 85
 86extern unsigned long sof_sdw_quirk;
 87
 88int sdw_startup(struct snd_pcm_substream *substream);
 89int sdw_prepare(struct snd_pcm_substream *substream);
 90int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
 91int sdw_hw_free(struct snd_pcm_substream *substream);
 92void sdw_shutdown(struct snd_pcm_substream *substream);
 93
 94/* generic HDMI support */
 95int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
 96
 97int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
 98
 99/* DMIC support */
100int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
101
102/* RT711 support */
103int sof_sdw_rt711_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);
107int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
108
109/* RT711-SDCA support */
110int sof_sdw_rt711_sdca_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);
114int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
115
116/* RT700 support */
117int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
118		       struct snd_soc_dai_link *dai_links,
119		       struct sof_sdw_codec_info *info,
120		       bool playback);
121
122/* RT1308 support */
123extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
124
125int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link,
126			struct snd_soc_dai_link *dai_links,
127			struct sof_sdw_codec_info *info,
128			bool playback);
129
130/* RT1316 support */
131int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link,
132			struct snd_soc_dai_link *dai_links,
133			struct sof_sdw_codec_info *info,
134			bool playback);
135
136/* RT715 support */
137int sof_sdw_rt715_init(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
142/* RT715-SDCA support */
143int sof_sdw_rt715_sdca_init(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
148/* MAX98373 support */
149int sof_sdw_mx8373_init(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
154int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
155
156/* RT5682 support */
157int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
158			struct snd_soc_dai_link *dai_links,
159			struct sof_sdw_codec_info *info,
160			bool playback);
161
162#endif