forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/intel/boards/bytcr_rt5640.c
....@@ -1,18 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform
34 *
45 * Copyright (C) 2014 Intel Corp
56 * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
67 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; version 2 of the License.
11
- *
12
- * This program is distributed in the hope that it will be useful, but
13
- * WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * General Public License for more details.
168 *
179 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1810 */
....@@ -28,8 +20,6 @@
2820 #include <linux/dmi.h>
2921 #include <linux/input.h>
3022 #include <linux/slab.h>
31
-#include <asm/cpu_device_id.h>
32
-#include <asm/platform_sst_audio.h>
3323 #include <sound/pcm.h>
3424 #include <sound/pcm_params.h>
3525 #include <sound/soc.h>
....@@ -38,7 +28,7 @@
3828 #include <dt-bindings/sound/rt5640.h>
3929 #include "../../codecs/rt5640.h"
4030 #include "../atom/sst-atom-controls.h"
41
-#include "../common/sst-dsp.h"
31
+#include "../common/soc-intel-quirks.h"
4232
4333 enum {
4434 BYT_RT5640_DMIC1_MAP,
....@@ -81,6 +71,7 @@
8171 #define BYT_RT5640_SSP0_AIF2 BIT(21)
8272 #define BYT_RT5640_MCLK_EN BIT(22)
8373 #define BYT_RT5640_MCLK_25MHZ BIT(23)
74
+#define BYT_RT5640_NO_SPEAKERS BIT(24)
8475
8576 #define BYTCR_INPUT_DEFAULTS \
8677 (BYT_RT5640_IN3_MAP | \
....@@ -99,8 +90,8 @@
9990 static bool is_bytcr;
10091
10192 static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN;
102
-static unsigned int quirk_override;
103
-module_param_named(quirk, quirk_override, uint, 0444);
93
+static int quirk_override = -1;
94
+module_param_named(quirk, quirk_override, int, 0444);
10495 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
10596
10697 static void log_quirks(struct device *dev)
....@@ -142,6 +133,8 @@
142133 dev_info(dev, "quirk JD_NOT_INV enabled\n");
143134 if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER)
144135 dev_info(dev, "quirk MONO_SPEAKER enabled\n");
136
+ if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)
137
+ dev_info(dev, "quirk NO_SPEAKERS enabled\n");
145138 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
146139 dev_info(dev, "quirk DIFF_MIC enabled\n");
147140 if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
....@@ -392,8 +385,8 @@
392385 static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream,
393386 struct snd_pcm_hw_params *params)
394387 {
395
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
396
- struct snd_soc_dai *dai = rtd->codec_dai;
388
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
389
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
397390
398391 return byt_rt5640_prepare_and_enable_pll1(dai, params_rate(params));
399392 }
....@@ -451,6 +444,18 @@
451444 .matches = {
452445 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
453446 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"),
447
+ },
448
+ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
449
+ BYT_RT5640_JD_SRC_JD2_IN4N |
450
+ BYT_RT5640_OVCD_TH_2000UA |
451
+ BYT_RT5640_OVCD_SF_0P75 |
452
+ BYT_RT5640_SSP0_AIF1 |
453
+ BYT_RT5640_MCLK_EN),
454
+ },
455
+ {
456
+ .matches = {
457
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
458
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
454459 },
455460 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
456461 BYT_RT5640_JD_SRC_JD2_IN4N |
....@@ -587,10 +592,33 @@
587592 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
588593 BYT_RT5640_MCLK_EN),
589594 },
590
- { /* HP Pavilion x2 10-n000nd */
595
+ { /* HP Pavilion x2 10-k0XX, 10-n0XX */
591596 .matches = {
592
- DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
593
- DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"),
597
+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
598
+ DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"),
599
+ },
600
+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
601
+ BYT_RT5640_JD_SRC_JD2_IN4N |
602
+ BYT_RT5640_OVCD_TH_1500UA |
603
+ BYT_RT5640_OVCD_SF_0P75 |
604
+ BYT_RT5640_SSP0_AIF1 |
605
+ BYT_RT5640_MCLK_EN),
606
+ },
607
+ { /* HP Pavilion x2 10-p0XX */
608
+ .matches = {
609
+ DMI_MATCH(DMI_SYS_VENDOR, "HP"),
610
+ DMI_MATCH(DMI_PRODUCT_NAME, "HP x2 Detachable 10-p0XX"),
611
+ },
612
+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
613
+ BYT_RT5640_JD_SRC_JD1_IN4P |
614
+ BYT_RT5640_OVCD_TH_2000UA |
615
+ BYT_RT5640_OVCD_SF_0P75 |
616
+ BYT_RT5640_MCLK_EN),
617
+ },
618
+ { /* HP Pro Tablet 408 */
619
+ .matches = {
620
+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
621
+ DMI_MATCH(DMI_PRODUCT_NAME, "HP Pro Tablet 408"),
594622 },
595623 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
596624 BYT_RT5640_JD_SRC_JD2_IN4N |
....@@ -780,6 +808,33 @@
780808 BYT_RT5640_SSP0_AIF2 |
781809 BYT_RT5640_MCLK_EN),
782810 },
811
+ { /* Point of View Mobii TAB-P1005W-232 (V2.0) */
812
+ .matches = {
813
+ DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "POV"),
814
+ DMI_EXACT_MATCH(DMI_BOARD_NAME, "I102A"),
815
+ },
816
+ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
817
+ BYT_RT5640_JD_SRC_JD2_IN4N |
818
+ BYT_RT5640_OVCD_TH_2000UA |
819
+ BYT_RT5640_OVCD_SF_0P75 |
820
+ BYT_RT5640_DIFF_MIC |
821
+ BYT_RT5640_SSP0_AIF1 |
822
+ BYT_RT5640_MCLK_EN),
823
+ },
824
+ {
825
+ /* Prowise PT301 */
826
+ .matches = {
827
+ DMI_MATCH(DMI_SYS_VENDOR, "Prowise"),
828
+ DMI_MATCH(DMI_PRODUCT_NAME, "PT301"),
829
+ },
830
+ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
831
+ BYT_RT5640_JD_SRC_JD2_IN4N |
832
+ BYT_RT5640_OVCD_TH_2000UA |
833
+ BYT_RT5640_OVCD_SF_0P75 |
834
+ BYT_RT5640_DIFF_MIC |
835
+ BYT_RT5640_SSP0_AIF1 |
836
+ BYT_RT5640_MCLK_EN),
837
+ },
783838 {
784839 /* Teclast X89 */
785840 .matches = {
....@@ -917,7 +972,7 @@
917972 {
918973 struct snd_soc_card *card = runtime->card;
919974 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
920
- struct snd_soc_component *component = runtime->codec_dai->component;
975
+ struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
921976 const struct snd_soc_dapm_route *custom_map;
922977 int num_routes;
923978 int ret;
....@@ -991,16 +1046,13 @@
9911046 ret = snd_soc_dapm_add_routes(&card->dapm,
9921047 byt_rt5640_mono_spk_map,
9931048 ARRAY_SIZE(byt_rt5640_mono_spk_map));
994
- } else {
1049
+ } else if (!(byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)) {
9951050 ret = snd_soc_dapm_add_routes(&card->dapm,
9961051 byt_rt5640_stereo_spk_map,
9971052 ARRAY_SIZE(byt_rt5640_stereo_spk_map));
9981053 }
9991054 if (ret)
10001055 return ret;
1001
-
1002
- snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
1003
- snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker");
10041056
10051057 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
10061058 /*
....@@ -1045,14 +1097,6 @@
10451097 return 0;
10461098 }
10471099
1048
-static const struct snd_soc_pcm_stream byt_rt5640_dai_params = {
1049
- .formats = SNDRV_PCM_FMTBIT_S24_LE,
1050
- .rate_min = 48000,
1051
- .rate_max = 48000,
1052
- .channels_min = 2,
1053
- .channels_max = 2,
1054
-};
1055
-
10561100 static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd,
10571101 struct snd_pcm_hw_params *params)
10581102 {
....@@ -1060,65 +1104,43 @@
10601104 SNDRV_PCM_HW_PARAM_RATE);
10611105 struct snd_interval *channels = hw_param_interval(params,
10621106 SNDRV_PCM_HW_PARAM_CHANNELS);
1063
- int ret;
1107
+ int ret, bits;
10641108
10651109 /* The DSP will covert the FE rate to 48k, stereo */
10661110 rate->min = rate->max = 48000;
10671111 channels->min = channels->max = 2;
10681112
10691113 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1070
- (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1071
-
1114
+ (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
10721115 /* set SSP0 to 16-bit */
10731116 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
1074
-
1075
- /*
1076
- * Default mode for SSP configuration is TDM 4 slot, override config
1077
- * with explicit setting to I2S 2ch 16-bit. The word length is set with
1078
- * dai_set_tdm_slot() since there is no other API exposed
1079
- */
1080
- ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
1081
- SND_SOC_DAIFMT_I2S |
1082
- SND_SOC_DAIFMT_NB_NF |
1083
- SND_SOC_DAIFMT_CBS_CFS
1084
- );
1085
- if (ret < 0) {
1086
- dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1087
- return ret;
1088
- }
1089
-
1090
- ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16);
1091
- if (ret < 0) {
1092
- dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1093
- return ret;
1094
- }
1095
-
1117
+ bits = 16;
10961118 } else {
1097
-
10981119 /* set SSP2 to 24-bit */
10991120 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
1100
-
1101
- /*
1102
- * Default mode for SSP configuration is TDM 4 slot, override config
1103
- * with explicit setting to I2S 2ch 24-bit. The word length is set with
1104
- * dai_set_tdm_slot() since there is no other API exposed
1105
- */
1106
- ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
1107
- SND_SOC_DAIFMT_I2S |
1108
- SND_SOC_DAIFMT_NB_NF |
1109
- SND_SOC_DAIFMT_CBS_CFS
1110
- );
1111
- if (ret < 0) {
1112
- dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1113
- return ret;
1114
- }
1115
-
1116
- ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24);
1117
- if (ret < 0) {
1118
- dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1119
- return ret;
1120
- }
1121
+ bits = 24;
11211122 }
1123
+
1124
+ /*
1125
+ * Default mode for SSP configuration is TDM 4 slot, override config
1126
+ * with explicit setting to I2S 2ch. The word length is set with
1127
+ * dai_set_tdm_slot() since there is no other API exposed
1128
+ */
1129
+ ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0),
1130
+ SND_SOC_DAIFMT_I2S |
1131
+ SND_SOC_DAIFMT_NB_NF |
1132
+ SND_SOC_DAIFMT_CBS_CFS);
1133
+ if (ret < 0) {
1134
+ dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1135
+ return ret;
1136
+ }
1137
+
1138
+ ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), 0x3, 0x3, 2, bits);
1139
+ if (ret < 0) {
1140
+ dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1141
+ return ret;
1142
+ }
1143
+
11221144 return 0;
11231145 }
11241146
....@@ -1136,58 +1158,69 @@
11361158 .hw_params = byt_rt5640_aif1_hw_params,
11371159 };
11381160
1161
+SND_SOC_DAILINK_DEF(dummy,
1162
+ DAILINK_COMP_ARRAY(COMP_DUMMY()));
1163
+
1164
+SND_SOC_DAILINK_DEF(media,
1165
+ DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
1166
+
1167
+SND_SOC_DAILINK_DEF(deepbuffer,
1168
+ DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
1169
+
1170
+SND_SOC_DAILINK_DEF(ssp2_port,
1171
+ /* overwritten for ssp0 routing */
1172
+ DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
1173
+SND_SOC_DAILINK_DEF(ssp2_codec,
1174
+ DAILINK_COMP_ARRAY(COMP_CODEC(
1175
+ /* overwritten with HID */ "i2c-10EC5640:00",
1176
+ /* changed w/ quirk */ "rt5640-aif1")));
1177
+
1178
+SND_SOC_DAILINK_DEF(platform,
1179
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
1180
+
11391181 static struct snd_soc_dai_link byt_rt5640_dais[] = {
11401182 [MERR_DPCM_AUDIO] = {
11411183 .name = "Baytrail Audio Port",
11421184 .stream_name = "Baytrail Audio",
1143
- .cpu_dai_name = "media-cpu-dai",
1144
- .codec_dai_name = "snd-soc-dummy-dai",
1145
- .codec_name = "snd-soc-dummy",
1146
- .platform_name = "sst-mfld-platform",
11471185 .nonatomic = true,
11481186 .dynamic = 1,
11491187 .dpcm_playback = 1,
11501188 .dpcm_capture = 1,
11511189 .ops = &byt_rt5640_aif1_ops,
1190
+ SND_SOC_DAILINK_REG(media, dummy, platform),
11521191 },
11531192 [MERR_DPCM_DEEP_BUFFER] = {
11541193 .name = "Deep-Buffer Audio Port",
11551194 .stream_name = "Deep-Buffer Audio",
1156
- .cpu_dai_name = "deepbuffer-cpu-dai",
1157
- .codec_dai_name = "snd-soc-dummy-dai",
1158
- .codec_name = "snd-soc-dummy",
1159
- .platform_name = "sst-mfld-platform",
11601195 .nonatomic = true,
11611196 .dynamic = 1,
11621197 .dpcm_playback = 1,
11631198 .ops = &byt_rt5640_aif1_ops,
1199
+ SND_SOC_DAILINK_REG(deepbuffer, dummy, platform),
11641200 },
11651201 /* back ends */
11661202 {
11671203 .name = "SSP2-Codec",
11681204 .id = 0,
1169
- .cpu_dai_name = "ssp2-port", /* overwritten for ssp0 routing */
1170
- .platform_name = "sst-mfld-platform",
11711205 .no_pcm = 1,
1172
- .codec_dai_name = "rt5640-aif1", /* changed w/ quirk */
1173
- .codec_name = "i2c-10EC5640:00", /* overwritten with HID */
11741206 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
11751207 | SND_SOC_DAIFMT_CBS_CFS,
11761208 .be_hw_params_fixup = byt_rt5640_codec_fixup,
1177
- .ignore_suspend = 1,
11781209 .nonatomic = true,
11791210 .dpcm_playback = 1,
11801211 .dpcm_capture = 1,
11811212 .init = byt_rt5640_init,
11821213 .ops = &byt_rt5640_be_ssp2_ops,
1214
+ SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform),
11831215 },
11841216 };
11851217
11861218 /* SoC card */
11871219 static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN];
1188
-static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */
1189
-static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
1220
+#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
11901221 static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
1222
+#endif
1223
+static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */
11911224
11921225 static int byt_rt5640_suspend(struct snd_soc_card *card)
11931226 {
....@@ -1196,7 +1229,7 @@
11961229 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
11971230 return 0;
11981231
1199
- list_for_each_entry(component, &card->component_dev_list, card_list) {
1232
+ for_each_card_components(card, component) {
12001233 if (!strcmp(component->name, byt_rt5640_codec_name)) {
12011234 dev_dbg(component->dev, "disabling jack detect before suspend\n");
12021235 snd_soc_component_set_jack(component, NULL, NULL);
....@@ -1215,7 +1248,7 @@
12151248 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
12161249 return 0;
12171250
1218
- list_for_each_entry(component, &card->component_dev_list, card_list) {
1251
+ for_each_card_components(card, component) {
12191252 if (!strcmp(component->name, byt_rt5640_codec_name)) {
12201253 dev_dbg(component->dev, "re-enabling jack detect after resume\n");
12211254 snd_soc_component_set_jack(component, &priv->jack, NULL);
....@@ -1226,8 +1259,18 @@
12261259 return 0;
12271260 }
12281261
1262
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
1263
+/* use space before codec name to simplify card ID, and simplify driver name */
1264
+#define CARD_NAME "bytcht rt5640" /* card name will be 'sof-bytcht rt5640' */
1265
+#define DRIVER_NAME "SOF"
1266
+#else
1267
+#define CARD_NAME "bytcr-rt5640"
1268
+#define DRIVER_NAME NULL /* card name will be used for driver name */
1269
+#endif
1270
+
12291271 static struct snd_soc_card byt_rt5640_card = {
1230
- .name = "bytcr-rt5640",
1272
+ .name = CARD_NAME,
1273
+ .driver_name = DRIVER_NAME,
12311274 .owner = THIS_MODULE,
12321275 .dai_link = byt_rt5640_dais,
12331276 .num_links = ARRAY_SIZE(byt_rt5640_dais),
....@@ -1240,18 +1283,6 @@
12401283 .resume_post = byt_rt5640_resume,
12411284 };
12421285
1243
-static bool is_valleyview(void)
1244
-{
1245
- static const struct x86_cpu_id cpu_ids[] = {
1246
- { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
1247
- {}
1248
- };
1249
-
1250
- if (!x86_match_cpu(cpu_ids))
1251
- return false;
1252
- return true;
1253
-}
1254
-
12551286 struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
12561287 u64 aif_value; /* 1: AIF1, 2: AIF2 */
12571288 u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
....@@ -1259,14 +1290,16 @@
12591290
12601291 static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
12611292 {
1262
- const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3" };
1293
+ static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3" };
1294
+ __maybe_unused const char *spk_type;
12631295 const struct dmi_system_id *dmi_id;
12641296 struct byt_rt5640_private *priv;
12651297 struct snd_soc_acpi_mach *mach;
1266
- const char *i2c_name = NULL;
1298
+ const char *platform_name;
1299
+ struct acpi_device *adev;
12671300 int ret_val = 0;
12681301 int dai_index = 0;
1269
- int i;
1302
+ int i, cfg_spk;
12701303
12711304 is_bytcr = false;
12721305 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
....@@ -1280,30 +1313,28 @@
12801313
12811314 /* fix index of codec dai */
12821315 for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
1283
- if (!strcmp(byt_rt5640_dais[i].codec_name, "i2c-10EC5640:00")) {
1316
+ if (!strcmp(byt_rt5640_dais[i].codecs->name,
1317
+ "i2c-10EC5640:00")) {
12841318 dai_index = i;
12851319 break;
12861320 }
12871321 }
12881322
12891323 /* fixup codec name based on HID */
1290
- i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
1291
- if (i2c_name) {
1324
+ adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
1325
+ if (adev) {
12921326 snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
1293
- "%s%s", "i2c-", i2c_name);
1294
-
1295
- byt_rt5640_dais[dai_index].codec_name = byt_rt5640_codec_name;
1327
+ "i2c-%s", acpi_dev_name(adev));
1328
+ put_device(&adev->dev);
1329
+ byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
12961330 }
12971331
12981332 /*
12991333 * swap SSP0 if bytcr is detected
13001334 * (will be overridden if DMI quirk is detected)
13011335 */
1302
- if (is_valleyview()) {
1303
- struct sst_platform_info *p_info = mach->pdata;
1304
- const struct sst_res_info *res_info = p_info->res_info;
1305
-
1306
- if (res_info->acpi_ipc_irq_index == 0)
1336
+ if (soc_intel_is_byt()) {
1337
+ if (mach->mach_params.acpi_ipc_irq_index == 0)
13071338 is_bytcr = true;
13081339 }
13091340
....@@ -1366,9 +1397,9 @@
13661397 dmi_id = dmi_first_match(byt_rt5640_quirk_table);
13671398 if (dmi_id)
13681399 byt_rt5640_quirk = (unsigned long)dmi_id->driver_data;
1369
- if (quirk_override) {
1370
- dev_info(&pdev->dev, "Overriding quirk 0x%x => 0x%x\n",
1371
- (unsigned int)byt_rt5640_quirk, quirk_override);
1400
+ if (quirk_override != -1) {
1401
+ dev_info(&pdev->dev, "Overriding quirk 0x%lx => 0x%x\n",
1402
+ byt_rt5640_quirk, quirk_override);
13721403 byt_rt5640_quirk = quirk_override;
13731404 }
13741405
....@@ -1380,28 +1411,12 @@
13801411 log_quirks(&pdev->dev);
13811412
13821413 if ((byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) ||
1383
- (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1384
-
1385
- /* fixup codec aif name */
1386
- snprintf(byt_rt5640_codec_aif_name,
1387
- sizeof(byt_rt5640_codec_aif_name),
1388
- "%s", "rt5640-aif2");
1389
-
1390
- byt_rt5640_dais[dai_index].codec_dai_name =
1391
- byt_rt5640_codec_aif_name;
1392
- }
1414
+ (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2))
1415
+ byt_rt5640_dais[dai_index].codecs->dai_name = "rt5640-aif2";
13931416
13941417 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1395
- (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1396
-
1397
- /* fixup cpu dai name name */
1398
- snprintf(byt_rt5640_cpu_dai_name,
1399
- sizeof(byt_rt5640_cpu_dai_name),
1400
- "%s", "ssp0-port");
1401
-
1402
- byt_rt5640_dais[dai_index].cpu_dai_name =
1403
- byt_rt5640_cpu_dai_name;
1404
- }
1418
+ (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2))
1419
+ byt_rt5640_dais[dai_index].cpus->dai_name = "ssp0-port";
14051420
14061421 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
14071422 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
....@@ -1423,12 +1438,35 @@
14231438 }
14241439 }
14251440
1441
+ if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) {
1442
+ cfg_spk = 0;
1443
+ spk_type = "none";
1444
+ } else if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) {
1445
+ cfg_spk = 1;
1446
+ spk_type = "mono";
1447
+ } else {
1448
+ cfg_spk = 2;
1449
+ spk_type = "stereo";
1450
+ }
1451
+
1452
+ snprintf(byt_rt5640_components, sizeof(byt_rt5640_components),
1453
+ "cfg-spk:%d cfg-mic:%s", cfg_spk,
1454
+ map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
1455
+ byt_rt5640_card.components = byt_rt5640_components;
1456
+#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
14261457 snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
1427
- "bytcr-rt5640-%s-spk-%s-mic",
1428
- (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ?
1429
- "mono" : "stereo",
1458
+ "bytcr-rt5640-%s-spk-%s-mic", spk_type,
14301459 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
14311460 byt_rt5640_card.long_name = byt_rt5640_long_name;
1461
+#endif
1462
+
1463
+ /* override plaform name, if required */
1464
+ platform_name = mach->mach_params.platform;
1465
+
1466
+ ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card,
1467
+ platform_name);
1468
+ if (ret_val)
1469
+ return ret_val;
14321470
14331471 ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card);
14341472
....@@ -1444,6 +1482,9 @@
14441482 static struct platform_driver snd_byt_rt5640_mc_driver = {
14451483 .driver = {
14461484 .name = "bytcr_rt5640",
1485
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
1486
+ .pm = &snd_soc_pm_ops,
1487
+#endif
14471488 },
14481489 .probe = snd_byt_rt5640_mc_probe,
14491490 };