| .. | .. |
|---|
| 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/ |
|---|
| 28 | 13 | |
|---|
| 14 | +#include <linux/delay.h> |
|---|
| 29 | 15 | #include <linux/module.h> |
|---|
| 30 | 16 | #include <linux/regmap.h> |
|---|
| 31 | 17 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 111 | 97 | |
|---|
| 112 | 98 | SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0), |
|---|
| 113 | 99 | SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 8, 1, 0), |
|---|
| 114 | | -SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1), |
|---|
| 115 | 100 | }; |
|---|
| 116 | 101 | |
|---|
| 117 | 102 | /* Output Mixer */ |
|---|
| .. | .. |
|---|
| 121 | 106 | SOC_DAPM_SINGLE("Mic Sidetone Switch", SSM2602_APANA, 5, 1, 0), |
|---|
| 122 | 107 | }; |
|---|
| 123 | 108 | |
|---|
| 109 | +static const struct snd_kcontrol_new mic_ctl = |
|---|
| 110 | + SOC_DAPM_SINGLE("Switch", SSM2602_APANA, 1, 1, 1); |
|---|
| 111 | + |
|---|
| 124 | 112 | /* Input mux */ |
|---|
| 125 | 113 | static const struct snd_kcontrol_new ssm2602_input_mux_controls = |
|---|
| 126 | 114 | 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 | +} |
|---|
| 127 | 133 | |
|---|
| 128 | 134 | static const struct snd_soc_dapm_widget ssm260x_dapm_widgets[] = { |
|---|
| 129 | 135 | SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1), |
|---|
| .. | .. |
|---|
| 145 | 151 | |
|---|
| 146 | 152 | SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &ssm2602_input_mux_controls), |
|---|
| 147 | 153 | 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), |
|---|
| 148 | 157 | |
|---|
| 149 | 158 | SND_SOC_DAPM_OUTPUT("LHPOUT"), |
|---|
| 150 | 159 | SND_SOC_DAPM_OUTPUT("RHPOUT"), |
|---|
| .. | .. |
|---|
| 178 | 187 | {"LHPOUT", NULL, "Output Mixer"}, |
|---|
| 179 | 188 | |
|---|
| 180 | 189 | {"Input Mux", "Line", "Line Input"}, |
|---|
| 181 | | - {"Input Mux", "Mic", "Mic Bias"}, |
|---|
| 190 | + {"Input Mux", "Mic", "Mic Switch"}, |
|---|
| 182 | 191 | {"ADC", NULL, "Input Mux"}, |
|---|
| 192 | + |
|---|
| 193 | + {"Mic Switch", NULL, "Mic Bias"}, |
|---|
| 183 | 194 | |
|---|
| 184 | 195 | {"Mic Bias", NULL, "MICIN"}, |
|---|
| 185 | 196 | }; |
|---|
| .. | .. |
|---|
| 327 | 338 | return 0; |
|---|
| 328 | 339 | } |
|---|
| 329 | 340 | |
|---|
| 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) |
|---|
| 331 | 342 | { |
|---|
| 332 | 343 | struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(dai->component); |
|---|
| 333 | 344 | |
|---|
| .. | .. |
|---|
| 494 | 505 | static const struct snd_soc_dai_ops ssm2602_dai_ops = { |
|---|
| 495 | 506 | .startup = ssm2602_startup, |
|---|
| 496 | 507 | .hw_params = ssm2602_hw_params, |
|---|
| 497 | | - .digital_mute = ssm2602_mute, |
|---|
| 508 | + .mute_stream = ssm2602_mute, |
|---|
| 498 | 509 | .set_sysclk = ssm2602_set_dai_sysclk, |
|---|
| 499 | 510 | .set_fmt = ssm2602_set_dai_fmt, |
|---|
| 511 | + .no_capture_mute = 1, |
|---|
| 500 | 512 | }; |
|---|
| 501 | 513 | |
|---|
| 502 | 514 | static struct snd_soc_dai_driver ssm2602_dai = { |
|---|