xref: /linux/sound/soc/intel/boards/sof_board_helpers.h (revision c745b15c1f9cea5680c2906ae868302108f8daf0)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright(c) 2023 Intel Corporation.
4  */
5 
6 #ifndef __SOF_INTEL_BOARD_HELPERS_H
7 #define __SOF_INTEL_BOARD_HELPERS_H
8 
9 #include <sound/soc.h>
10 #include "sof_hdmi_common.h"
11 #include "sof_ssp_common.h"
12 
13 /*
14  * sof_rt5682_private: private data for rt5682 machine driver
15  *
16  * @mclk: mclk clock data
17  * @is_legacy_cpu: true for BYT/CHT boards
18  */
19 struct sof_rt5682_private {
20 	struct clk *mclk;
21 	bool is_legacy_cpu;
22 };
23 
24 /*
25  * sof_card_private: common data for machine drivers
26  *
27  * @headset_jack: headset jack data
28  * @hdmi: init data for hdmi dai link
29  * @codec_type: type of headset codec
30  * @amp_type: type of speaker amplifier
31  * @dmic_be_num: number of Intel PCH DMIC BE link
32  * @hdmi_num: number of Intel HDMI BE link
33  * @ssp_codec: ssp port number of headphone BE link
34  * @ssp_amp: ssp port number of speaker BE link
35  * @ssp_bt: ssp port number of BT offload BE link
36  * @ssp_mask_hdmi_in: ssp port mask of HDMI-IN BE link
37  * @bt_offload_present: true to create BT offload BE link
38  * @codec_link: pointer to headset codec dai link
39  * @amp_link: pointer to speaker amplifier dai link
40  * @rt5682: private data for rt5682 machine driver
41  */
42 struct sof_card_private {
43 	struct snd_soc_jack headset_jack;
44 	struct sof_hdmi_private hdmi;
45 
46 	enum sof_ssp_codec codec_type;
47 	enum sof_ssp_codec amp_type;
48 
49 	int dmic_be_num;
50 	int hdmi_num;
51 
52 	int ssp_codec;
53 	int ssp_amp;
54 	int ssp_bt;
55 	unsigned long ssp_mask_hdmi_in;
56 
57 	bool bt_offload_present;
58 
59 	struct snd_soc_dai_link *codec_link;
60 	struct snd_soc_dai_link *amp_link;
61 
62 	union {
63 		struct sof_rt5682_private rt5682;
64 	};
65 };
66 
67 enum sof_dmic_be_type {
68 	SOF_DMIC_01,
69 	SOF_DMIC_16K,
70 };
71 
72 int sof_intel_board_card_late_probe(struct snd_soc_card *card);
73 int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
74 				 struct sof_card_private *ctx);
75 
76 int sof_intel_board_set_codec_link(struct device *dev,
77 				   struct snd_soc_dai_link *link, int be_id,
78 				   enum sof_ssp_codec codec_type, int ssp_codec);
79 int sof_intel_board_set_dmic_link(struct device *dev,
80 				  struct snd_soc_dai_link *link, int be_id,
81 				  enum sof_dmic_be_type be_type);
82 int sof_intel_board_set_intel_hdmi_link(struct device *dev,
83 					struct snd_soc_dai_link *link, int be_id,
84 					int hdmi_id, bool idisp_codec);
85 int sof_intel_board_set_ssp_amp_link(struct device *dev,
86 				     struct snd_soc_dai_link *link, int be_id,
87 				     enum sof_ssp_codec amp_type, int ssp_amp);
88 int sof_intel_board_set_bt_link(struct device *dev,
89 				struct snd_soc_dai_link *link, int be_id,
90 				int ssp_bt);
91 int sof_intel_board_set_hdmi_in_link(struct device *dev,
92 				     struct snd_soc_dai_link *link, int be_id,
93 				     int ssp_hdmi);
94 
95 #endif /* __SOF_INTEL_BOARD_HELPERS_H */
96