xref: /openbmc/linux/sound/soc/sof/amd/vangogh.c (revision f7da8800)
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2023 Advanced Micro Devices, Inc.
7 //
8 // Authors: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
9 
10 /*
11  * Hardware interface for Audio DSP on Vangogh platform
12  */
13 
14 #include <linux/platform_device.h>
15 #include <linux/module.h>
16 
17 #include "../ops.h"
18 #include "../sof-audio.h"
19 #include "acp.h"
20 #include "acp-dsp-offset.h"
21 
22 #define I2S_HS_INSTANCE		0
23 #define I2S_BT_INSTANCE		1
24 #define I2S_SP_INSTANCE		2
25 #define PDM_DMIC_INSTANCE	3
26 #define I2S_HS_VIRTUAL_INSTANCE	4
27 
28 static struct snd_soc_dai_driver vangogh_sof_dai[] = {
29 	[I2S_HS_INSTANCE] = {
30 		.id = I2S_HS_INSTANCE,
31 		.name = "acp-sof-hs",
32 		.playback = {
33 			.rates = SNDRV_PCM_RATE_8000_96000,
34 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
35 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
36 			.channels_min = 2,
37 			.channels_max = 8,
38 			.rate_min = 8000,
39 			.rate_max = 96000,
40 		},
41 		.capture = {
42 			.rates = SNDRV_PCM_RATE_8000_48000,
43 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
44 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
45 			/* Supporting only stereo for I2S HS controller capture */
46 			.channels_min = 2,
47 			.channels_max = 2,
48 			.rate_min = 8000,
49 			.rate_max = 48000,
50 		},
51 	},
52 
53 	[I2S_BT_INSTANCE] = {
54 		.id = I2S_BT_INSTANCE,
55 		.name = "acp-sof-bt",
56 		.playback = {
57 			.rates = SNDRV_PCM_RATE_8000_96000,
58 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
59 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
60 			.channels_min = 2,
61 			.channels_max = 8,
62 			.rate_min = 8000,
63 			.rate_max = 96000,
64 		},
65 		.capture = {
66 			.rates = SNDRV_PCM_RATE_8000_48000,
67 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
68 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
69 			/* Supporting only stereo for I2S BT controller capture */
70 			.channels_min = 2,
71 			.channels_max = 2,
72 			.rate_min = 8000,
73 			.rate_max = 48000,
74 		},
75 	},
76 
77 	[I2S_SP_INSTANCE] = {
78 		.id = I2S_SP_INSTANCE,
79 		.name = "acp-sof-sp",
80 		.playback = {
81 			.rates = SNDRV_PCM_RATE_8000_96000,
82 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
83 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
84 			.channels_min = 2,
85 			.channels_max = 8,
86 			.rate_min = 8000,
87 			.rate_max = 96000,
88 		},
89 		.capture = {
90 			.rates = SNDRV_PCM_RATE_8000_48000,
91 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
92 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
93 			/* Supporting only stereo for I2S SP controller capture */
94 			.channels_min = 2,
95 			.channels_max = 2,
96 			.rate_min = 8000,
97 			.rate_max = 48000,
98 		},
99 	},
100 
101 	[PDM_DMIC_INSTANCE] = {
102 		.id = PDM_DMIC_INSTANCE,
103 		.name = "acp-sof-dmic",
104 		.capture = {
105 			.rates = SNDRV_PCM_RATE_8000_48000,
106 			.formats = SNDRV_PCM_FMTBIT_S32_LE,
107 			.channels_min = 2,
108 			.channels_max = 4,
109 			.rate_min = 8000,
110 			.rate_max = 48000,
111 		},
112 	},
113 
114 	[I2S_HS_VIRTUAL_INSTANCE] = {
115 		.id = I2S_HS_VIRTUAL_INSTANCE,
116 		.name = "acp-sof-hs-virtual",
117 		.playback = {
118 			.rates = SNDRV_PCM_RATE_8000_96000,
119 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
120 					   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
121 			.channels_min = 2,
122 			.channels_max = 8,
123 			.rate_min = 8000,
124 			.rate_max = 96000,
125 		},
126 		.capture = {
127 			.rates = SNDRV_PCM_RATE_8000_48000,
128 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
129 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
130 			/* Supporting only stereo for I2S HS-Virtual controller capture */
131 			.channels_min = 2,
132 			.channels_max = 2,
133 			.rate_min = 8000,
134 			.rate_max = 48000,
135 		},
136 	},
137 };
138 
139 /* Vangogh ops */
140 struct snd_sof_dsp_ops sof_vangogh_ops;
141 EXPORT_SYMBOL_NS(sof_vangogh_ops, SND_SOC_SOF_AMD_COMMON);
142 
sof_vangogh_ops_init(struct snd_sof_dev * sdev)143 int sof_vangogh_ops_init(struct snd_sof_dev *sdev)
144 {
145 	const struct dmi_system_id *dmi_id;
146 
147 	/* common defaults */
148 	memcpy(&sof_vangogh_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
149 
150 	sof_vangogh_ops.drv = vangogh_sof_dai;
151 	sof_vangogh_ops.num_drv = ARRAY_SIZE(vangogh_sof_dai);
152 
153 	dmi_id = dmi_first_match(acp_sof_quirk_table);
154 	if (dmi_id && dmi_id->driver_data)
155 		sof_vangogh_ops.load_firmware = acp_sof_load_signed_firmware;
156 
157 	return 0;
158 }
159 
160 MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
161 MODULE_DESCRIPTION("VANGOGH SOF Driver");
162 MODULE_LICENSE("Dual BSD/GPL");
163