forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
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,14 +385,26 @@
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 }
400393
401394 /* Please keep this list alphabetically sorted */
402395 static const struct dmi_system_id byt_rt5640_quirk_table[] = {
396
+ { /* Acer Iconia One 7 B1-750 */
397
+ .matches = {
398
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
399
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "VESPA2"),
400
+ },
401
+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
402
+ BYT_RT5640_JD_SRC_JD1_IN4P |
403
+ BYT_RT5640_OVCD_TH_1500UA |
404
+ BYT_RT5640_OVCD_SF_0P75 |
405
+ BYT_RT5640_SSP0_AIF1 |
406
+ BYT_RT5640_MCLK_EN),
407
+ },
403408 { /* Acer Iconia Tab 8 W1-810 */
404409 .matches = {
405410 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"),
....@@ -438,6 +443,21 @@
438443 BYT_RT5640_MCLK_EN),
439444 },
440445 {
446
+ /* Advantech MICA-071 */
447
+ .matches = {
448
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Advantech"),
449
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MICA-071"),
450
+ },
451
+ /* OVCD Th = 1500uA to reliable detect head-phones vs -set */
452
+ .driver_data = (void *)(BYT_RT5640_IN3_MAP |
453
+ BYT_RT5640_JD_SRC_JD2_IN4N |
454
+ BYT_RT5640_OVCD_TH_1500UA |
455
+ BYT_RT5640_OVCD_SF_0P75 |
456
+ BYT_RT5640_MONO_SPEAKER |
457
+ BYT_RT5640_DIFF_MIC |
458
+ BYT_RT5640_MCLK_EN),
459
+ },
460
+ {
441461 .matches = {
442462 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
443463 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 80 Cesium"),
....@@ -451,6 +471,18 @@
451471 .matches = {
452472 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
453473 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"),
474
+ },
475
+ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
476
+ BYT_RT5640_JD_SRC_JD2_IN4N |
477
+ BYT_RT5640_OVCD_TH_2000UA |
478
+ BYT_RT5640_OVCD_SF_0P75 |
479
+ BYT_RT5640_SSP0_AIF1 |
480
+ BYT_RT5640_MCLK_EN),
481
+ },
482
+ {
483
+ .matches = {
484
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
485
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
454486 },
455487 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
456488 BYT_RT5640_JD_SRC_JD2_IN4N |
....@@ -587,10 +619,33 @@
587619 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
588620 BYT_RT5640_MCLK_EN),
589621 },
590
- { /* HP Pavilion x2 10-n000nd */
622
+ { /* HP Pavilion x2 10-k0XX, 10-n0XX */
591623 .matches = {
592
- DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
593
- DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"),
624
+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
625
+ DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"),
626
+ },
627
+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
628
+ BYT_RT5640_JD_SRC_JD2_IN4N |
629
+ BYT_RT5640_OVCD_TH_1500UA |
630
+ BYT_RT5640_OVCD_SF_0P75 |
631
+ BYT_RT5640_SSP0_AIF1 |
632
+ BYT_RT5640_MCLK_EN),
633
+ },
634
+ { /* HP Pavilion x2 10-p0XX */
635
+ .matches = {
636
+ DMI_MATCH(DMI_SYS_VENDOR, "HP"),
637
+ DMI_MATCH(DMI_PRODUCT_NAME, "HP x2 Detachable 10-p0XX"),
638
+ },
639
+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
640
+ BYT_RT5640_JD_SRC_JD1_IN4P |
641
+ BYT_RT5640_OVCD_TH_2000UA |
642
+ BYT_RT5640_OVCD_SF_0P75 |
643
+ BYT_RT5640_MCLK_EN),
644
+ },
645
+ { /* HP Pro Tablet 408 */
646
+ .matches = {
647
+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
648
+ DMI_MATCH(DMI_PRODUCT_NAME, "HP Pro Tablet 408"),
594649 },
595650 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
596651 BYT_RT5640_JD_SRC_JD2_IN4N |
....@@ -780,6 +835,33 @@
780835 BYT_RT5640_SSP0_AIF2 |
781836 BYT_RT5640_MCLK_EN),
782837 },
838
+ { /* Point of View Mobii TAB-P1005W-232 (V2.0) */
839
+ .matches = {
840
+ DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "POV"),
841
+ DMI_EXACT_MATCH(DMI_BOARD_NAME, "I102A"),
842
+ },
843
+ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
844
+ BYT_RT5640_JD_SRC_JD2_IN4N |
845
+ BYT_RT5640_OVCD_TH_2000UA |
846
+ BYT_RT5640_OVCD_SF_0P75 |
847
+ BYT_RT5640_DIFF_MIC |
848
+ BYT_RT5640_SSP0_AIF1 |
849
+ BYT_RT5640_MCLK_EN),
850
+ },
851
+ {
852
+ /* Prowise PT301 */
853
+ .matches = {
854
+ DMI_MATCH(DMI_SYS_VENDOR, "Prowise"),
855
+ DMI_MATCH(DMI_PRODUCT_NAME, "PT301"),
856
+ },
857
+ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
858
+ BYT_RT5640_JD_SRC_JD2_IN4N |
859
+ BYT_RT5640_OVCD_TH_2000UA |
860
+ BYT_RT5640_OVCD_SF_0P75 |
861
+ BYT_RT5640_DIFF_MIC |
862
+ BYT_RT5640_SSP0_AIF1 |
863
+ BYT_RT5640_MCLK_EN),
864
+ },
783865 {
784866 /* Teclast X89 */
785867 .matches = {
....@@ -917,7 +999,7 @@
917999 {
9181000 struct snd_soc_card *card = runtime->card;
9191001 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
920
- struct snd_soc_component *component = runtime->codec_dai->component;
1002
+ struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
9211003 const struct snd_soc_dapm_route *custom_map;
9221004 int num_routes;
9231005 int ret;
....@@ -991,16 +1073,13 @@
9911073 ret = snd_soc_dapm_add_routes(&card->dapm,
9921074 byt_rt5640_mono_spk_map,
9931075 ARRAY_SIZE(byt_rt5640_mono_spk_map));
994
- } else {
1076
+ } else if (!(byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)) {
9951077 ret = snd_soc_dapm_add_routes(&card->dapm,
9961078 byt_rt5640_stereo_spk_map,
9971079 ARRAY_SIZE(byt_rt5640_stereo_spk_map));
9981080 }
9991081 if (ret)
10001082 return ret;
1001
-
1002
- snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
1003
- snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker");
10041083
10051084 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
10061085 /*
....@@ -1045,14 +1124,6 @@
10451124 return 0;
10461125 }
10471126
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
-
10561127 static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd,
10571128 struct snd_pcm_hw_params *params)
10581129 {
....@@ -1060,65 +1131,43 @@
10601131 SNDRV_PCM_HW_PARAM_RATE);
10611132 struct snd_interval *channels = hw_param_interval(params,
10621133 SNDRV_PCM_HW_PARAM_CHANNELS);
1063
- int ret;
1134
+ int ret, bits;
10641135
10651136 /* The DSP will covert the FE rate to 48k, stereo */
10661137 rate->min = rate->max = 48000;
10671138 channels->min = channels->max = 2;
10681139
10691140 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1070
- (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1071
-
1141
+ (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
10721142 /* set SSP0 to 16-bit */
10731143 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
-
1144
+ bits = 16;
10961145 } else {
1097
-
10981146 /* set SSP2 to 24-bit */
10991147 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
- }
1148
+ bits = 24;
11211149 }
1150
+
1151
+ /*
1152
+ * Default mode for SSP configuration is TDM 4 slot, override config
1153
+ * with explicit setting to I2S 2ch. The word length is set with
1154
+ * dai_set_tdm_slot() since there is no other API exposed
1155
+ */
1156
+ ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0),
1157
+ SND_SOC_DAIFMT_I2S |
1158
+ SND_SOC_DAIFMT_NB_NF |
1159
+ SND_SOC_DAIFMT_CBS_CFS);
1160
+ if (ret < 0) {
1161
+ dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1162
+ return ret;
1163
+ }
1164
+
1165
+ ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), 0x3, 0x3, 2, bits);
1166
+ if (ret < 0) {
1167
+ dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1168
+ return ret;
1169
+ }
1170
+
11221171 return 0;
11231172 }
11241173
....@@ -1136,58 +1185,69 @@
11361185 .hw_params = byt_rt5640_aif1_hw_params,
11371186 };
11381187
1188
+SND_SOC_DAILINK_DEF(dummy,
1189
+ DAILINK_COMP_ARRAY(COMP_DUMMY()));
1190
+
1191
+SND_SOC_DAILINK_DEF(media,
1192
+ DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
1193
+
1194
+SND_SOC_DAILINK_DEF(deepbuffer,
1195
+ DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
1196
+
1197
+SND_SOC_DAILINK_DEF(ssp2_port,
1198
+ /* overwritten for ssp0 routing */
1199
+ DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
1200
+SND_SOC_DAILINK_DEF(ssp2_codec,
1201
+ DAILINK_COMP_ARRAY(COMP_CODEC(
1202
+ /* overwritten with HID */ "i2c-10EC5640:00",
1203
+ /* changed w/ quirk */ "rt5640-aif1")));
1204
+
1205
+SND_SOC_DAILINK_DEF(platform,
1206
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
1207
+
11391208 static struct snd_soc_dai_link byt_rt5640_dais[] = {
11401209 [MERR_DPCM_AUDIO] = {
11411210 .name = "Baytrail Audio Port",
11421211 .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",
11471212 .nonatomic = true,
11481213 .dynamic = 1,
11491214 .dpcm_playback = 1,
11501215 .dpcm_capture = 1,
11511216 .ops = &byt_rt5640_aif1_ops,
1217
+ SND_SOC_DAILINK_REG(media, dummy, platform),
11521218 },
11531219 [MERR_DPCM_DEEP_BUFFER] = {
11541220 .name = "Deep-Buffer Audio Port",
11551221 .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",
11601222 .nonatomic = true,
11611223 .dynamic = 1,
11621224 .dpcm_playback = 1,
11631225 .ops = &byt_rt5640_aif1_ops,
1226
+ SND_SOC_DAILINK_REG(deepbuffer, dummy, platform),
11641227 },
11651228 /* back ends */
11661229 {
11671230 .name = "SSP2-Codec",
11681231 .id = 0,
1169
- .cpu_dai_name = "ssp2-port", /* overwritten for ssp0 routing */
1170
- .platform_name = "sst-mfld-platform",
11711232 .no_pcm = 1,
1172
- .codec_dai_name = "rt5640-aif1", /* changed w/ quirk */
1173
- .codec_name = "i2c-10EC5640:00", /* overwritten with HID */
11741233 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
11751234 | SND_SOC_DAIFMT_CBS_CFS,
11761235 .be_hw_params_fixup = byt_rt5640_codec_fixup,
1177
- .ignore_suspend = 1,
11781236 .nonatomic = true,
11791237 .dpcm_playback = 1,
11801238 .dpcm_capture = 1,
11811239 .init = byt_rt5640_init,
11821240 .ops = &byt_rt5640_be_ssp2_ops,
1241
+ SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform),
11831242 },
11841243 };
11851244
11861245 /* SoC card */
11871246 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" */
1247
+#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
11901248 static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
1249
+#endif
1250
+static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */
11911251
11921252 static int byt_rt5640_suspend(struct snd_soc_card *card)
11931253 {
....@@ -1196,7 +1256,7 @@
11961256 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
11971257 return 0;
11981258
1199
- list_for_each_entry(component, &card->component_dev_list, card_list) {
1259
+ for_each_card_components(card, component) {
12001260 if (!strcmp(component->name, byt_rt5640_codec_name)) {
12011261 dev_dbg(component->dev, "disabling jack detect before suspend\n");
12021262 snd_soc_component_set_jack(component, NULL, NULL);
....@@ -1215,7 +1275,7 @@
12151275 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
12161276 return 0;
12171277
1218
- list_for_each_entry(component, &card->component_dev_list, card_list) {
1278
+ for_each_card_components(card, component) {
12191279 if (!strcmp(component->name, byt_rt5640_codec_name)) {
12201280 dev_dbg(component->dev, "re-enabling jack detect after resume\n");
12211281 snd_soc_component_set_jack(component, &priv->jack, NULL);
....@@ -1226,8 +1286,18 @@
12261286 return 0;
12271287 }
12281288
1289
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
1290
+/* use space before codec name to simplify card ID, and simplify driver name */
1291
+#define CARD_NAME "bytcht rt5640" /* card name will be 'sof-bytcht rt5640' */
1292
+#define DRIVER_NAME "SOF"
1293
+#else
1294
+#define CARD_NAME "bytcr-rt5640"
1295
+#define DRIVER_NAME NULL /* card name will be used for driver name */
1296
+#endif
1297
+
12291298 static struct snd_soc_card byt_rt5640_card = {
1230
- .name = "bytcr-rt5640",
1299
+ .name = CARD_NAME,
1300
+ .driver_name = DRIVER_NAME,
12311301 .owner = THIS_MODULE,
12321302 .dai_link = byt_rt5640_dais,
12331303 .num_links = ARRAY_SIZE(byt_rt5640_dais),
....@@ -1240,18 +1310,6 @@
12401310 .resume_post = byt_rt5640_resume,
12411311 };
12421312
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
-
12551313 struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
12561314 u64 aif_value; /* 1: AIF1, 2: AIF2 */
12571315 u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
....@@ -1259,14 +1317,16 @@
12591317
12601318 static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
12611319 {
1262
- const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3" };
1320
+ static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3" };
1321
+ __maybe_unused const char *spk_type;
12631322 const struct dmi_system_id *dmi_id;
12641323 struct byt_rt5640_private *priv;
12651324 struct snd_soc_acpi_mach *mach;
1266
- const char *i2c_name = NULL;
1325
+ const char *platform_name;
1326
+ struct acpi_device *adev;
12671327 int ret_val = 0;
12681328 int dai_index = 0;
1269
- int i;
1329
+ int i, cfg_spk;
12701330
12711331 is_bytcr = false;
12721332 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
....@@ -1280,30 +1340,28 @@
12801340
12811341 /* fix index of codec dai */
12821342 for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
1283
- if (!strcmp(byt_rt5640_dais[i].codec_name, "i2c-10EC5640:00")) {
1343
+ if (!strcmp(byt_rt5640_dais[i].codecs->name,
1344
+ "i2c-10EC5640:00")) {
12841345 dai_index = i;
12851346 break;
12861347 }
12871348 }
12881349
12891350 /* fixup codec name based on HID */
1290
- i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
1291
- if (i2c_name) {
1351
+ adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
1352
+ if (adev) {
12921353 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;
1354
+ "i2c-%s", acpi_dev_name(adev));
1355
+ put_device(&adev->dev);
1356
+ byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
12961357 }
12971358
12981359 /*
12991360 * swap SSP0 if bytcr is detected
13001361 * (will be overridden if DMI quirk is detected)
13011362 */
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)
1363
+ if (soc_intel_is_byt()) {
1364
+ if (mach->mach_params.acpi_ipc_irq_index == 0)
13071365 is_bytcr = true;
13081366 }
13091367
....@@ -1366,9 +1424,9 @@
13661424 dmi_id = dmi_first_match(byt_rt5640_quirk_table);
13671425 if (dmi_id)
13681426 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);
1427
+ if (quirk_override != -1) {
1428
+ dev_info(&pdev->dev, "Overriding quirk 0x%lx => 0x%x\n",
1429
+ byt_rt5640_quirk, quirk_override);
13721430 byt_rt5640_quirk = quirk_override;
13731431 }
13741432
....@@ -1380,28 +1438,12 @@
13801438 log_quirks(&pdev->dev);
13811439
13821440 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
- }
1441
+ (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2))
1442
+ byt_rt5640_dais[dai_index].codecs->dai_name = "rt5640-aif2";
13931443
13941444 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
- }
1445
+ (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2))
1446
+ byt_rt5640_dais[dai_index].cpus->dai_name = "ssp0-port";
14051447
14061448 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
14071449 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
....@@ -1423,12 +1465,35 @@
14231465 }
14241466 }
14251467
1468
+ if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) {
1469
+ cfg_spk = 0;
1470
+ spk_type = "none";
1471
+ } else if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) {
1472
+ cfg_spk = 1;
1473
+ spk_type = "mono";
1474
+ } else {
1475
+ cfg_spk = 2;
1476
+ spk_type = "stereo";
1477
+ }
1478
+
1479
+ snprintf(byt_rt5640_components, sizeof(byt_rt5640_components),
1480
+ "cfg-spk:%d cfg-mic:%s", cfg_spk,
1481
+ map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
1482
+ byt_rt5640_card.components = byt_rt5640_components;
1483
+#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
14261484 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",
1485
+ "bytcr-rt5640-%s-spk-%s-mic", spk_type,
14301486 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
14311487 byt_rt5640_card.long_name = byt_rt5640_long_name;
1488
+#endif
1489
+
1490
+ /* override plaform name, if required */
1491
+ platform_name = mach->mach_params.platform;
1492
+
1493
+ ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card,
1494
+ platform_name);
1495
+ if (ret_val)
1496
+ return ret_val;
14321497
14331498 ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card);
14341499
....@@ -1444,6 +1509,9 @@
14441509 static struct platform_driver snd_byt_rt5640_mc_driver = {
14451510 .driver = {
14461511 .name = "bytcr_rt5640",
1512
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
1513
+ .pm = &snd_soc_pm_ops,
1514
+#endif
14471515 },
14481516 .probe = snd_byt_rt5640_mc_probe,
14491517 };