Loading...
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
13enum {
14 SOF_LINK_NONE = 0,
15 SOF_LINK_CODEC,
16 SOF_LINK_DMIC01,
17 SOF_LINK_DMIC16K,
18 SOF_LINK_IDISP_HDMI,
19 SOF_LINK_AMP,
20 SOF_LINK_BT_OFFLOAD,
21 SOF_LINK_HDMI_IN,
22};
23
24#define SOF_LINK_ORDER_MASK (0xF)
25#define SOF_LINK_ORDER_SHIFT (4)
26
27#define SOF_LINK_ORDER(k1, k2, k3, k4, k5, k6, k7) \
28 ((((k1) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 0)) | \
29 (((k2) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 1)) | \
30 (((k3) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 2)) | \
31 (((k4) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 3)) | \
32 (((k5) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 4)) | \
33 (((k6) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 5)) | \
34 (((k7) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 6)))
35
36/*
37 * sof_rt5682_private: private data for rt5682 machine driver
38 *
39 * @mclk: mclk clock data
40 * @is_legacy_cpu: true for BYT/CHT boards
41 */
42struct sof_rt5682_private {
43 struct clk *mclk;
44 bool is_legacy_cpu;
45};
46
47/*
48 * sof_card_private: common data for machine drivers
49 *
50 * @headset_jack: headset jack data
51 * @hdmi: init data for hdmi dai link
52 * @codec_type: type of headset codec
53 * @amp_type: type of speaker amplifier
54 * @dmic_be_num: number of Intel PCH DMIC BE link
55 * @hdmi_num: number of Intel HDMI BE link
56 * @ssp_codec: ssp port number of headphone BE link
57 * @ssp_amp: ssp port number of speaker BE link
58 * @ssp_bt: ssp port number of BT offload BE link
59 * @ssp_mask_hdmi_in: ssp port mask of HDMI-IN BE link
60 * @bt_offload_present: true to create BT offload BE link
61 * @codec_link: pointer to headset codec dai link
62 * @amp_link: pointer to speaker amplifier dai link
63 * @link_order_overwrite: custom DAI link order
64 * @rt5682: private data for rt5682 machine driver
65 */
66struct sof_card_private {
67 struct snd_soc_jack headset_jack;
68 struct sof_hdmi_private hdmi;
69
70 enum sof_ssp_codec codec_type;
71 enum sof_ssp_codec amp_type;
72
73 int dmic_be_num;
74 int hdmi_num;
75
76 int ssp_codec;
77 int ssp_amp;
78 int ssp_bt;
79 unsigned long ssp_mask_hdmi_in;
80
81 bool bt_offload_present;
82
83 struct snd_soc_dai_link *codec_link;
84 struct snd_soc_dai_link *amp_link;
85
86 unsigned long link_order_overwrite;
87
88 union {
89 struct sof_rt5682_private rt5682;
90 };
91};
92
93enum sof_dmic_be_type {
94 SOF_DMIC_01,
95 SOF_DMIC_16K,
96};
97
98int sof_intel_board_card_late_probe(struct snd_soc_card *card);
99int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
100 struct sof_card_private *ctx);
101
102int sof_intel_board_set_codec_link(struct device *dev,
103 struct snd_soc_dai_link *link, int be_id,
104 enum sof_ssp_codec codec_type, int ssp_codec);
105int sof_intel_board_set_dmic_link(struct device *dev,
106 struct snd_soc_dai_link *link, int be_id,
107 enum sof_dmic_be_type be_type);
108int sof_intel_board_set_intel_hdmi_link(struct device *dev,
109 struct snd_soc_dai_link *link, int be_id,
110 int hdmi_id, bool idisp_codec);
111int sof_intel_board_set_ssp_amp_link(struct device *dev,
112 struct snd_soc_dai_link *link, int be_id,
113 enum sof_ssp_codec amp_type, int ssp_amp);
114int sof_intel_board_set_bt_link(struct device *dev,
115 struct snd_soc_dai_link *link, int be_id,
116 int ssp_bt);
117int sof_intel_board_set_hdmi_in_link(struct device *dev,
118 struct snd_soc_dai_link *link, int be_id,
119 int ssp_hdmi);
120
121struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
122 const char * const dai_name[], int num_dais);
123
124#endif /* __SOF_INTEL_BOARD_HELPERS_H */