Skip to content

Commit 1b13074

Browse files
committed
ASoC: Intel: sof_sdw_rt1316: add BQ params for the Dell models
The Dell SKU 0B00/0B01/0AFE/0AFF model needs the BQ params for the tweeter/woofer. Signed-off-by: Shuming Fan <shumingf@realtek.com> Reviewed-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Link: https://lore.kernel.org/r/20221109091317.17240-1-shumingf@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org> Author: Shuming Fan <shumingf@realtek.com> Date: Wed Nov 9 17:13:17 2022 +0800 Signed-off-by: Jaroslav Kysela <jkysela@redhat.com> (cherry picked from commit cf6946d) Bugzilla: https://bugzilla.redhat.com/2140419
1 parent ab00bdc commit 1b13074

File tree

4 files changed

+259
-0
lines changed

4 files changed

+259
-0
lines changed

sound/soc/intel/boards/sof_sdw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
518518
.direction = {true, true},
519519
.dai_name = "rt1316-aif",
520520
.init = sof_sdw_rt1316_init,
521+
.exit = sof_sdw_rt1316_exit,
521522
.codec_type = SOF_SDW_CODEC_TYPE_AMP,
522523
},
523524
{

sound/soc/intel/boards/sof_sdw_amp_coeff_tables.h

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define SND_SOC_SOF_SDW_AMP_COEFF_H
1010

1111
#define RT1308_MAX_BQ_REG 480
12+
#define RT1316_MAX_BQ_REG 580
1213

1314
static const u8 dell_0a5d_bq_params[] = {
1415
0xb0, 0xc5, 0x00, /* address: 0xc5b0; data: 0x00 */
@@ -159,4 +160,141 @@ static const u8 dell_0a5d_bq_params[] = {
159160
0x50, 0xc5, 0x01,
160161
};
161162

163+
static const u8 dell_0b00_bq_params[] = {
164+
0x03, 0xc2, 0x00,
165+
0x04, 0xc2, 0xb2,
166+
0x05, 0xc2, 0xe0,
167+
0x06, 0xc2, 0x3a,
168+
0x07, 0xc2, 0x01,
169+
0x08, 0xc2, 0x65,
170+
0x09, 0xc2, 0xc0,
171+
0x0a, 0xc2, 0x75,
172+
0x0b, 0xc2, 0x00,
173+
0x0c, 0xc2, 0xb2,
174+
0x0d, 0xc2, 0xe0,
175+
0x0e, 0xc2, 0x3a,
176+
0x0f, 0xc2, 0xf7,
177+
0x10, 0xc2, 0x4d,
178+
0x11, 0xc2, 0x5b,
179+
0x12, 0xc2, 0xe9,
180+
0x13, 0xc2, 0x03,
181+
0x14, 0xc2, 0x7e,
182+
0x15, 0xc2, 0x25,
183+
0x16, 0xc2, 0x01,
184+
0x17, 0xc2, 0x07,
185+
0x18, 0xc2, 0xfd,
186+
0x19, 0xc2, 0x15,
187+
0x1a, 0xc2, 0x04,
188+
0x1b, 0xc2, 0xf0,
189+
0x1c, 0xc2, 0x05,
190+
0x1d, 0xc2, 0xd5,
191+
0x1e, 0xc2, 0xf7,
192+
0x1f, 0xc2, 0x07,
193+
0x20, 0xc2, 0xfd,
194+
0x21, 0xc2, 0x15,
195+
0x22, 0xc2, 0x04,
196+
0x23, 0xc2, 0xf0,
197+
0x24, 0xc2, 0x05,
198+
0x25, 0xc2, 0xd8,
199+
0x26, 0xc2, 0x17,
200+
0x27, 0xc2, 0x07,
201+
0x28, 0xc2, 0xfa,
202+
0x29, 0xc2, 0x2c,
203+
0x2a, 0xc2, 0x29,
204+
0x2b, 0xc2, 0x07,
205+
0x2c, 0xc2, 0x74,
206+
0x2d, 0xc2, 0xe0,
207+
0x2e, 0xc2, 0x33,
208+
0x2f, 0xc2, 0xf1,
209+
0x30, 0xc2, 0x16,
210+
0x31, 0xc2, 0x3f,
211+
0x32, 0xc2, 0x9b,
212+
0x33, 0xc2, 0x07,
213+
0x34, 0xc2, 0x74,
214+
0x35, 0xc2, 0xe0,
215+
0x36, 0xc2, 0x33,
216+
0x37, 0xc2, 0xf1,
217+
0x38, 0xc2, 0x29,
218+
0x39, 0xc2, 0xb0,
219+
0x3a, 0xc2, 0x4d,
220+
0x3b, 0xc2, 0x06,
221+
0x3c, 0xc2, 0xfd,
222+
0x3d, 0xc2, 0x31,
223+
0x3e, 0xc2, 0x18,
224+
0x3f, 0xc2, 0x07,
225+
0x40, 0xc2, 0xfd,
226+
0x41, 0xc2, 0x15,
227+
0x42, 0xc2, 0x04,
228+
0x43, 0xc2, 0xf0,
229+
0x44, 0xc2, 0x05,
230+
0x45, 0xc2, 0xd5,
231+
0x46, 0xc2, 0xf7,
232+
0x47, 0xc2, 0x07,
233+
0x48, 0xc2, 0xfd,
234+
0x49, 0xc2, 0x15,
235+
0x4a, 0xc2, 0x04,
236+
0x4b, 0xc2, 0xf0,
237+
0x4c, 0xc2, 0x05,
238+
0x4d, 0xc2, 0xd8,
239+
0x4e, 0xc2, 0x17,
240+
0x4f, 0xc2, 0x07,
241+
0x50, 0xc2, 0xfa,
242+
0x51, 0xc2, 0x2c,
243+
0x52, 0xc2, 0x29,
244+
0x0b, 0xc0, 0x30,
245+
0x80, 0xc3, 0x13,
246+
0x81, 0xc3, 0x88,
247+
0x82, 0xc3, 0x17,
248+
0x83, 0xc3, 0x70,
249+
0x84, 0xc3, 0x00,
250+
0x85, 0xc3, 0x00,
251+
0x86, 0xc3, 0xff,
252+
0x87, 0xc3, 0xee,
253+
0x88, 0xc3, 0x02,
254+
0x92, 0xc3, 0x00,
255+
0x93, 0xc3, 0x14,
256+
0x94, 0xc3, 0x00,
257+
0x95, 0xc3, 0x14,
258+
0x96, 0xc3, 0x00,
259+
0x97, 0xc3, 0x00,
260+
0x98, 0xc3, 0x00,
261+
0x99, 0xc3, 0x00,
262+
0x9a, 0xc3, 0x01,
263+
0x89, 0xc3, 0x03,
264+
0x8a, 0xc3, 0xe8,
265+
0x8b, 0xc3, 0x03,
266+
0x8c, 0xc3, 0xb6,
267+
0x8d, 0xc3, 0x00,
268+
0x8e, 0xc3, 0x00,
269+
0x8f, 0xc3, 0xff,
270+
0x90, 0xc3, 0xee,
271+
0x91, 0xc3, 0x01,
272+
0x9b, 0xc3, 0x00,
273+
0x9c, 0xc3, 0x14,
274+
0x9d, 0xc3, 0x00,
275+
0x9e, 0xc3, 0x14,
276+
0x9f, 0xc3, 0x00,
277+
0xa0, 0xc3, 0x00,
278+
0xa1, 0xc3, 0x00,
279+
0xa2, 0xc3, 0x00,
280+
0xa3, 0xc3, 0x01,
281+
0x61, 0xc2, 0x08,
282+
0x62, 0xc2, 0x00,
283+
0x63, 0xc2, 0x00,
284+
0x64, 0xc2, 0x00,
285+
0x65, 0xc2, 0x08,
286+
0x66, 0xc2, 0x00,
287+
0x67, 0xc2, 0x00,
288+
0x68, 0xc2, 0x00,
289+
0x69, 0xc2, 0x08,
290+
0x6a, 0xc2, 0x00,
291+
0x6b, 0xc2, 0x00,
292+
0x6c, 0xc2, 0x00,
293+
0x6d, 0xc2, 0x08,
294+
0x6e, 0xc2, 0x00,
295+
0x6f, 0xc2, 0x00,
296+
0x70, 0xc2, 0x00,
297+
0x00, 0xc2, 0xc0,
298+
};
299+
162300
#endif

sound/soc/intel/boards/sof_sdw_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int sof_sdw_rt1316_init(struct snd_soc_card *card,
141141
struct snd_soc_dai_link *dai_links,
142142
struct sof_sdw_codec_info *info,
143143
bool playback);
144+
int sof_sdw_rt1316_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
144145

145146
/* RT1318 support */
146147
int sof_sdw_rt1318_init(struct snd_soc_card *card,

sound/soc/intel/boards/sof_sdw_rt1316.c

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,83 @@
1111
#include <sound/soc.h>
1212
#include <sound/soc-acpi.h>
1313
#include <sound/soc-dapm.h>
14+
#include <linux/soundwire/sdw.h>
15+
#include <linux/soundwire/sdw_type.h>
16+
#include <linux/dmi.h>
1417
#include "sof_sdw_common.h"
18+
#include "sof_sdw_amp_coeff_tables.h"
19+
20+
struct rt1316_platform_data {
21+
const unsigned char *bq_params;
22+
const unsigned int bq_params_cnt;
23+
};
24+
25+
static const struct rt1316_platform_data dell_0b00_platform_data = {
26+
.bq_params = dell_0b00_bq_params,
27+
.bq_params_cnt = ARRAY_SIZE(dell_0b00_bq_params),
28+
};
29+
30+
static const struct dmi_system_id dmi_platform_data[] = {
31+
/* AlderLake devices */
32+
{
33+
.matches = {
34+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
35+
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0B00")
36+
},
37+
.driver_data = (void *)&dell_0b00_platform_data,
38+
},
39+
{
40+
.matches = {
41+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
42+
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0B01")
43+
},
44+
.driver_data = (void *)&dell_0b00_platform_data,
45+
},
46+
{
47+
.matches = {
48+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
49+
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0AFF")
50+
},
51+
.driver_data = (void *)&dell_0b00_platform_data,
52+
},
53+
{
54+
.matches = {
55+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
56+
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0AFE")
57+
},
58+
.driver_data = (void *)&dell_0b00_platform_data,
59+
},
60+
};
61+
62+
static int rt1316_add_device_props(struct device *sdw_dev)
63+
{
64+
struct property_entry props[3] = {};
65+
struct fwnode_handle *fwnode;
66+
const struct dmi_system_id *dmi_data;
67+
const struct rt1316_platform_data *pdata;
68+
unsigned char params[RT1316_MAX_BQ_REG];
69+
int ret;
70+
71+
dmi_data = dmi_first_match(dmi_platform_data);
72+
if (!dmi_data)
73+
return 0;
74+
75+
pdata = dmi_data->driver_data;
76+
memcpy(&params, pdata->bq_params, sizeof(unsigned char) * pdata->bq_params_cnt);
77+
78+
props[0] = PROPERTY_ENTRY_U8_ARRAY("realtek,bq-params", params);
79+
props[1] = PROPERTY_ENTRY_U32("realtek,bq-params-cnt", pdata->bq_params_cnt);
80+
81+
fwnode = fwnode_create_software_node(props, NULL);
82+
if (IS_ERR(fwnode))
83+
return PTR_ERR(fwnode);
84+
85+
ret = device_add_software_node(sdw_dev, to_software_node(fwnode));
86+
87+
fwnode_handle_put(fwnode);
88+
89+
return ret;
90+
}
1591

1692
static const struct snd_soc_dapm_widget rt1316_widgets[] = {
1793
SND_SOC_DAPM_SPK("Speaker", NULL),
@@ -89,12 +165,33 @@ static int all_spk_init(struct snd_soc_pcm_runtime *rtd)
89165
return second_spk_init(rtd);
90166
}
91167

168+
int sof_sdw_rt1316_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
169+
{
170+
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
171+
172+
if (ctx->amp_dev1) {
173+
device_remove_software_node(ctx->amp_dev1);
174+
put_device(ctx->amp_dev1);
175+
}
176+
177+
if (ctx->amp_dev2) {
178+
device_remove_software_node(ctx->amp_dev2);
179+
put_device(ctx->amp_dev2);
180+
}
181+
182+
return 0;
183+
}
184+
92185
int sof_sdw_rt1316_init(struct snd_soc_card *card,
93186
const struct snd_soc_acpi_link_adr *link,
94187
struct snd_soc_dai_link *dai_links,
95188
struct sof_sdw_codec_info *info,
96189
bool playback)
97190
{
191+
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
192+
struct device *sdw_dev1, *sdw_dev2;
193+
int ret;
194+
98195
/* Count amp number and do init on playback link only. */
99196
if (!playback)
100197
return 0;
@@ -104,6 +201,28 @@ int sof_sdw_rt1316_init(struct snd_soc_card *card,
104201
dai_links->init = first_spk_init;
105202

106203
if (info->amp_num == 2) {
204+
sdw_dev1 = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name);
205+
if (!sdw_dev1)
206+
return -EPROBE_DEFER;
207+
208+
ret = rt1316_add_device_props(sdw_dev1);
209+
if (ret < 0) {
210+
put_device(sdw_dev1);
211+
return ret;
212+
}
213+
ctx->amp_dev1 = sdw_dev1;
214+
215+
sdw_dev2 = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[1].name);
216+
if (!sdw_dev2)
217+
return -EPROBE_DEFER;
218+
219+
ret = rt1316_add_device_props(sdw_dev2);
220+
if (ret < 0) {
221+
put_device(sdw_dev2);
222+
return ret;
223+
}
224+
ctx->amp_dev2 = sdw_dev2;
225+
107226
/*
108227
* if two 1316s are in one dai link, the init function
109228
* in this dai link will be first set for the first speaker,

0 commit comments

Comments
 (0)