hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/codecs/ssm2602.c
....@@ -1,31 +1,17 @@
1
-/*
2
- * File: sound/soc/codecs/ssm2602.c
3
- * Author: Cliff Cai <Cliff.Cai@analog.com>
4
- *
5
- * Created: Tue June 06 2008
6
- * Description: Driver for ssm2602 sound chip
7
- *
8
- * Modified:
9
- * Copyright 2008 Analog Devices Inc.
10
- *
11
- * Bugs: Enter bugs at http://blackfin.uclinux.org/
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2 of the License, or
16
- * (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, see the file COPYING, or write
25
- * to the Free Software Foundation, Inc.,
26
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
- */
1
+// SPDX-License-Identifier: GPL-2.0-or-later
2
+//
3
+// File: sound/soc/codecs/ssm2602.c
4
+// Author: Cliff Cai <Cliff.Cai@analog.com>
5
+//
6
+// Created: Tue June 06 2008
7
+// Description: Driver for ssm2602 sound chip
8
+//
9
+// Modified:
10
+// Copyright 2008 Analog Devices Inc.
11
+//
12
+// Bugs: Enter bugs at http://blackfin.uclinux.org/
2813
14
+#include <linux/delay.h>
2915 #include <linux/module.h>
3016 #include <linux/regmap.h>
3117 #include <linux/slab.h>
....@@ -111,7 +97,6 @@
11197
11298 SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0),
11399 SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 8, 1, 0),
114
-SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1),
115100 };
116101
117102 /* Output Mixer */
....@@ -121,9 +106,30 @@
121106 SOC_DAPM_SINGLE("Mic Sidetone Switch", SSM2602_APANA, 5, 1, 0),
122107 };
123108
109
+static const struct snd_kcontrol_new mic_ctl =
110
+ SOC_DAPM_SINGLE("Switch", SSM2602_APANA, 1, 1, 1);
111
+
124112 /* Input mux */
125113 static const struct snd_kcontrol_new ssm2602_input_mux_controls =
126114 SOC_DAPM_ENUM("Input Select", ssm2602_enum[0]);
115
+
116
+static int ssm2602_mic_switch_event(struct snd_soc_dapm_widget *w,
117
+ struct snd_kcontrol *kcontrol, int event)
118
+{
119
+ /*
120
+ * According to the ssm2603 data sheet (control register sequencing),
121
+ * the digital core should be activated only after all necessary bits
122
+ * in the power register are enabled, and a delay determined by the
123
+ * decoupling capacitor on the VMID pin has passed. If the digital core
124
+ * is activated too early, or even before the ADC is powered up, audible
125
+ * artifacts appear at the beginning and end of the recorded signal.
126
+ *
127
+ * In practice, audible artifacts disappear well over 500 ms.
128
+ */
129
+ msleep(500);
130
+
131
+ return 0;
132
+}
127133
128134 static const struct snd_soc_dapm_widget ssm260x_dapm_widgets[] = {
129135 SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1),
....@@ -145,6 +151,9 @@
145151
146152 SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &ssm2602_input_mux_controls),
147153 SND_SOC_DAPM_MICBIAS("Mic Bias", SSM2602_PWR, 1, 1),
154
+
155
+SND_SOC_DAPM_SWITCH_E("Mic Switch", SSM2602_APANA, 1, 1, &mic_ctl,
156
+ ssm2602_mic_switch_event, SND_SOC_DAPM_PRE_PMU),
148157
149158 SND_SOC_DAPM_OUTPUT("LHPOUT"),
150159 SND_SOC_DAPM_OUTPUT("RHPOUT"),
....@@ -178,8 +187,10 @@
178187 {"LHPOUT", NULL, "Output Mixer"},
179188
180189 {"Input Mux", "Line", "Line Input"},
181
- {"Input Mux", "Mic", "Mic Bias"},
190
+ {"Input Mux", "Mic", "Mic Switch"},
182191 {"ADC", NULL, "Input Mux"},
192
+
193
+ {"Mic Switch", NULL, "Mic Bias"},
183194
184195 {"Mic Bias", NULL, "MICIN"},
185196 };
....@@ -327,7 +338,7 @@
327338 return 0;
328339 }
329340
330
-static int ssm2602_mute(struct snd_soc_dai *dai, int mute)
341
+static int ssm2602_mute(struct snd_soc_dai *dai, int mute, int direction)
331342 {
332343 struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(dai->component);
333344
....@@ -494,9 +505,10 @@
494505 static const struct snd_soc_dai_ops ssm2602_dai_ops = {
495506 .startup = ssm2602_startup,
496507 .hw_params = ssm2602_hw_params,
497
- .digital_mute = ssm2602_mute,
508
+ .mute_stream = ssm2602_mute,
498509 .set_sysclk = ssm2602_set_dai_sysclk,
499510 .set_fmt = ssm2602_set_dai_fmt,
511
+ .no_capture_mute = 1,
500512 };
501513
502514 static struct snd_soc_dai_driver ssm2602_dai = {