xref: /linux/sound/soc/sof/amd/renoir.c (revision cf21f328fcafacf4f96e7a30ef9dceede1076378)
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) 2021 Advanced Micro Devices, Inc.
7 //
8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
9 
10 /*
11  * Hardware interface for Audio DSP on Renoir 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_BT_INSTANCE		0
23 #define I2S_SP_INSTANCE		1
24 #define PDM_DMIC_INSTANCE	2
25 #define I2S_SP_VIRTUAL_INSTANCE	3
26 
27 static struct snd_soc_dai_driver renoir_sof_dai[] = {
28 	[I2S_BT_INSTANCE] = {
29 		.id = I2S_BT_INSTANCE,
30 		.name = "acp-sof-bt",
31 		.playback = {
32 			.rates = SNDRV_PCM_RATE_8000_96000,
33 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
34 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
35 			.channels_min = 2,
36 			.channels_max = 8,
37 			.rate_min = 8000,
38 			.rate_max = 96000,
39 		},
40 		.capture = {
41 			.rates = SNDRV_PCM_RATE_8000_48000,
42 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
43 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
44 			/* Supporting only stereo for I2S BT controller capture */
45 			.channels_min = 2,
46 			.channels_max = 2,
47 			.rate_min = 8000,
48 			.rate_max = 48000,
49 		},
50 		.probe = &acp_dai_probe,
51 	},
52 
53 	[I2S_SP_INSTANCE] = {
54 		.id = I2S_SP_INSTANCE,
55 		.name = "acp-sof-sp",
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 SP controller capture */
70 			.channels_min = 2,
71 			.channels_max = 2,
72 			.rate_min = 8000,
73 			.rate_max = 48000,
74 		},
75 		.probe = &acp_dai_probe,
76 	},
77 
78 	[PDM_DMIC_INSTANCE] = {
79 		.id = PDM_DMIC_INSTANCE,
80 		.name = "acp-sof-dmic",
81 		.capture = {
82 			.rates = SNDRV_PCM_RATE_8000_48000,
83 			.formats = SNDRV_PCM_FMTBIT_S32_LE,
84 			.channels_min = 2,
85 			.channels_max = 4,
86 			.rate_min = 8000,
87 			.rate_max = 48000,
88 		},
89 	},
90 
91 	[I2S_SP_VIRTUAL_INSTANCE] = {
92 		.id = I2S_SP_VIRTUAL_INSTANCE,
93 		.name = "acp-sof-sp-virtual",
94 		.playback = {
95 			.rates = SNDRV_PCM_RATE_8000_96000,
96 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
97 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
98 			.channels_min = 2,
99 			.channels_max = 8,
100 			.rate_min = 8000,
101 			.rate_max = 96000,
102 		},
103 		.probe = &acp_dai_probe,
104 	},
105 };
106 
107 /* Renoir ops */
108 struct snd_sof_dsp_ops sof_renoir_ops;
109 EXPORT_SYMBOL_NS(sof_renoir_ops, SND_SOC_SOF_AMD_COMMON);
110 
111 int sof_renoir_ops_init(struct snd_sof_dev *sdev)
112 {
113 	/* common defaults */
114 	memcpy(&sof_renoir_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
115 
116 	sof_renoir_ops.drv = renoir_sof_dai;
117 	sof_renoir_ops.num_drv = ARRAY_SIZE(renoir_sof_dai);
118 
119 	return 0;
120 }
121 
122 MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
123 MODULE_DESCRIPTION("RENOIR SOF Driver");
124 MODULE_LICENSE("Dual BSD/GPL");
125