Skip to content

Commit fe385b6

Browse files
brentlubardliao
authored andcommitted
ASoC: Intel: sof_ssp_amp: use common module for sof_card_private initialization
Use intel_board module to initialize sof_card_private structure. Signed-off-by: Brent Lu <[email protected]>
1 parent c743bf9 commit fe385b6

1 file changed

Lines changed: 26 additions & 67 deletions

File tree

‎sound/soc/intel/boards/sof_ssp_amp.c‎

Lines changed: 26 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,12 @@
2020
#include "sof_board_helpers.h"
2121
#include "sof_realtek_common.h"
2222
#include "sof_cirrus_common.h"
23-
#include "sof_ssp_common.h"
24-
25-
/* SSP port ID for speaker amplifier */
26-
#define SOF_AMPLIFIER_SSP(quirk) ((quirk) & GENMASK(3, 0))
27-
#define SOF_AMPLIFIER_SSP_MASK (GENMASK(3, 0))
28-
29-
/* HDMI capture*/
30-
#define SOF_HDMI_CAPTURE_SSP_MASK_SHIFT 4
31-
#define SOF_HDMI_CAPTURE_SSP_MASK_MASK (GENMASK(9, 4))
32-
#define SOF_HDMI_CAPTURE_SSP_MASK(quirk) \
33-
(((quirk) << SOF_HDMI_CAPTURE_SSP_MASK_SHIFT) & SOF_HDMI_CAPTURE_SSP_MASK_MASK)
34-
35-
/* HDMI playback */
36-
#define SOF_HDMI_PLAYBACK_PRESENT BIT(13)
37-
#define SOF_NO_OF_HDMI_PLAYBACK_SHIFT 14
38-
#define SOF_NO_OF_HDMI_PLAYBACK_MASK (GENMASK(16, 14))
39-
#define SOF_NO_OF_HDMI_PLAYBACK(quirk) \
40-
(((quirk) << SOF_NO_OF_HDMI_PLAYBACK_SHIFT) & SOF_NO_OF_HDMI_PLAYBACK_MASK)
41-
42-
/* BT audio offload */
43-
#define SOF_SSP_BT_OFFLOAD_PRESENT BIT(17)
44-
#define SOF_BT_OFFLOAD_SSP_SHIFT 18
45-
#define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(20, 18))
46-
#define SOF_BT_OFFLOAD_SSP(quirk) \
47-
(((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
23+
24+
/* Driver-specific board quirks: from bit 0 to 7 */
25+
#define SOF_HDMI_PLAYBACK_PRESENT BIT(0)
4826

4927
/* Default: SSP2 */
50-
static unsigned long sof_ssp_amp_quirk = SOF_AMPLIFIER_SSP(2);
28+
static unsigned long sof_ssp_amp_quirk = SOF_SSP_PORT_AMP(2);
5129

5230
static const struct dmi_system_id chromebook_platforms[] = {
5331
{
@@ -136,45 +114,27 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
136114
struct sof_card_private *ctx;
137115
int ret;
138116

139-
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
140-
if (!ctx)
141-
return -ENOMEM;
142-
143117
if (pdev->id_entry && pdev->id_entry->driver_data)
144118
sof_ssp_amp_quirk = (unsigned long)pdev->id_entry->driver_data;
145119

146-
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);
147-
148-
if (dmi_check_system(chromebook_platforms) || mach->mach_params.dmic_num > 0)
149-
ctx->dmic_be_num = 2;
150-
else
151-
ctx->dmic_be_num = 0;
152-
153-
/* port number/mask of peripherals attached to ssp interface */
154-
ctx->ssp_mask_hdmi_in = (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_SSP_MASK_MASK) >>
155-
SOF_HDMI_CAPTURE_SSP_MASK_SHIFT;
120+
dev_dbg(&pdev->dev, "sof_ssp_amp_quirk = %lx\n", sof_ssp_amp_quirk);
156121

157-
ctx->ssp_bt = (sof_ssp_amp_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
158-
SOF_BT_OFFLOAD_SSP_SHIFT;
122+
/* initialize ctx with board quirk */
123+
ctx = sof_intel_board_get_ctx(&pdev->dev, sof_ssp_amp_quirk);
124+
if (!ctx)
125+
return -ENOMEM;
159126

160-
ctx->ssp_amp = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK;
127+
if (!dmi_check_system(chromebook_platforms) &&
128+
(mach->mach_params.dmic_num == 0))
129+
ctx->dmic_be_num = 0;
161130

162131
if (sof_ssp_amp_quirk & SOF_HDMI_PLAYBACK_PRESENT) {
163-
ctx->hdmi_num = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_PLAYBACK_MASK) >>
164-
SOF_NO_OF_HDMI_PLAYBACK_SHIFT;
165-
/* default number of HDMI DAI's */
166-
if (!ctx->hdmi_num)
167-
ctx->hdmi_num = 3;
168-
169132
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
170133
ctx->hdmi.idisp_codec = true;
171134
} else {
172135
ctx->hdmi_num = 0;
173136
}
174137

175-
if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
176-
ctx->bt_offload_present = true;
177-
178138
ctx->link_order_overwrite = SSP_AMP_LINK_ORDER;
179139

180140
if (ctx->ssp_mask_hdmi_in) {
@@ -220,38 +180,38 @@ static const struct platform_device_id board_ids[] = {
220180
},
221181
{
222182
.name = "tgl_rt1308_hdmi_ssp",
223-
.driver_data = (kernel_ulong_t)(SOF_AMPLIFIER_SSP(2) |
224-
SOF_HDMI_CAPTURE_SSP_MASK(0x22)),
183+
.driver_data = (kernel_ulong_t)(SOF_SSP_PORT_AMP(2) |
184+
SOF_SSP_MASK_HDMI_CAPTURE(0x22)),
225185
/* SSP 1 and SSP 5 are used for HDMI IN */
226186
},
227187
{
228188
.name = "adl_cs35l41",
229-
.driver_data = (kernel_ulong_t)(SOF_AMPLIFIER_SSP(1) |
230-
SOF_NO_OF_HDMI_PLAYBACK(4) |
189+
.driver_data = (kernel_ulong_t)(SOF_SSP_PORT_AMP(1) |
190+
SOF_NUM_IDISP_HDMI(4) |
231191
SOF_HDMI_PLAYBACK_PRESENT |
232-
SOF_BT_OFFLOAD_SSP(2) |
233-
SOF_SSP_BT_OFFLOAD_PRESENT),
192+
SOF_SSP_PORT_BT_OFFLOAD(2) |
193+
SOF_BT_OFFLOAD_PRESENT),
234194
},
235195
{
236196
.name = "adl_lt6911_hdmi_ssp",
237-
.driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) |
197+
.driver_data = (kernel_ulong_t)(SOF_SSP_MASK_HDMI_CAPTURE(0x5) |
238198
/* SSP 0 and SSP 2 are used for HDMI IN */
239-
SOF_NO_OF_HDMI_PLAYBACK(3) |
199+
SOF_NUM_IDISP_HDMI(3) |
240200
SOF_HDMI_PLAYBACK_PRESENT),
241201
},
242202
{
243203
.name = "rpl_lt6911_hdmi_ssp",
244-
.driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) |
204+
.driver_data = (kernel_ulong_t)(SOF_SSP_MASK_HDMI_CAPTURE(0x5) |
245205
/* SSP 0 and SSP 2 are used for HDMI IN */
246-
SOF_NO_OF_HDMI_PLAYBACK(3) |
206+
SOF_NUM_IDISP_HDMI(3) |
247207
SOF_HDMI_PLAYBACK_PRESENT),
248208
},
249209
{
250210
.name = "mtl_lt6911_hdmi_ssp",
251-
.driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) |
252-
/* SSP 0 and SSP 2 are used for HDMI IN */
253-
SOF_NO_OF_HDMI_PLAYBACK(3) |
254-
SOF_HDMI_PLAYBACK_PRESENT),
211+
.driver_data = (kernel_ulong_t)(SOF_SSP_MASK_HDMI_CAPTURE(0x5) |
212+
/* SSP 0 and SSP 2 are used for HDMI IN */
213+
SOF_NUM_IDISP_HDMI(3) |
214+
SOF_HDMI_PLAYBACK_PRESENT),
255215
},
256216
{ }
257217
};
@@ -274,4 +234,3 @@ MODULE_LICENSE("GPL");
274234
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
275235
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
276236
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON);
277-
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);

0 commit comments

Comments
 (0)