@@ -69,7 +69,6 @@ struct sma1303_priv {
struct mutex lock;
struct delayed_work check_fault_work;
bool amp_power_status;
- bool usage_status;
int num_of_pll_matches;
int retry_cnt;
unsigned int sys_clk_id;
@@ -375,66 +374,6 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol,
return 0;
}
-static int amp_usage_status_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
- int ret = -1;
-
- if (component == NULL) {
- pr_err("%s:component is NULL\n", __func__);
- return ret;
- }
- if (sma1303 == NULL) {
- pr_err("%s:sma1303 is NULL\n", __func__);
- return ret;
- }
- ucontrol->value.integer.value[0] = sma1303->usage_status;
-
- if (sma1303->usage_status)
- dev_info(component->dev, "Amplifier Power Control Enabled\n");
- else
- dev_info(component->dev, "Amplifier Power Control Disabled\n");
-
- return 0;
-}
-
-static int amp_usage_status_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
- int ret = -1;
-
- if (component == NULL) {
- pr_err("%s:component is NULL\n", __func__);
- return ret;
- }
- if (sma1303 == NULL) {
- pr_err("%s:sma1303 is NULL\n", __func__);
- return ret;
- }
-
- if ((sma1303->usage_status
- != ucontrol->value.integer.value[0])
- && (!ucontrol->value.integer.value[0])) {
- dev_info(component->dev, "%s\n", "Force AMP Power Down");
- ret = sma1303_shutdown(component);
- if (ret < 0) {
- ucontrol->value.integer.value[0]
- = sma1303->usage_status;
- return ret;
- }
-
- }
- sma1303->usage_status = ucontrol->value.integer.value[0];
-
- return 0;
-}
-
static const char * const sma1303_amp_mode_text[] = {
"1 Chip", "Mono on 2 chips", "Left in 2 chips", "Right in 2chips"};
@@ -928,10 +867,10 @@ static SOC_VALUE_ENUM_SINGLE_DECL(sma1303_sdo_source_enum,
sma1303_sdo_source_values);
static const struct snd_kcontrol_new sma1303_sdo_source_mux =
SOC_DAPM_ENUM("SDO Source", sma1303_sdo_source_enum);
+static const struct snd_kcontrol_new sma1303_enable_control =
+ SOC_DAPM_SINGLE_VIRT("Switch", 1);
static const struct snd_kcontrol_new sma1303_snd_controls[] = {
-SOC_SINGLE_EXT("Amplifier Usage", SND_SOC_NOPM, 0, 1, 0,
- amp_usage_status_get, amp_usage_status_put),
SOC_ENUM_EXT("Amplifier Mode", sma1303_amp_mode_enum,
sma1303_amp_mode_get, sma1303_amp_mode_put),
SOC_ENUM_EXT("Outport config", sma1303_outport_config_enum,
@@ -1048,14 +987,12 @@ static int sma1303_dac_event(struct snd_soc_dapm_widget *w,
{
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
- struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
dev_info(component->dev, "%s : PRE_PMU\n", __func__);
- if (sma1303->usage_status)
- sma1303_startup(component);
+ sma1303_startup(component);
break;
@@ -1130,11 +1067,13 @@ SND_SOC_DAPM_ADC_E("DAC_FEEDBACK", "Capture", SND_SOC_NOPM, 0, 0,
SND_SOC_DAPM_OUTPUT("SPK"),
SND_SOC_DAPM_INPUT("SDO"),
SND_SOC_DAPM_MUX("SDO Source", SND_SOC_NOPM, 0, 0, &sma1303_sdo_source_mux),
+SND_SOC_DAPM_SWITCH("AMP Enable", SND_SOC_NOPM, 0, 1, &sma1303_enable_control),
};
static const struct snd_soc_dapm_route sma1303_audio_map[] = {
{"DAC", NULL, "CLK_SUPPLY"},
-{"SPK", NULL, "DAC"},
+{"AMP Enable", "Switch", "DAC"},
+{"SPK", NULL, "AMP Enable"},
{"SDO Source", "Disable", "SDO"},
{"SDO Source", "Format_C", "SDO"},
{"SDO Source", "Mixer_Out", "SDO"},
@@ -1214,9 +1153,8 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream,
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- if (sma1303->usage_status &&
- (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_MCLK
- || sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK)) {
+ if (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_MCLK
+ || sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK) {
if (sma1303->last_bclk != bclk) {
if (sma1303->amp_power_status) {
@@ -2039,7 +1977,6 @@ static int sma1303_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, sma1303);
sma1303->amp_mode = ONE_CHIP_SOLUTION;
- sma1303->usage_status = true;
sma1303->amp_power_status = false;
sma1303->check_fault_status = true;
sma1303->pll_matches = sma1303_pll_matches;
Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com> Reported-by: Mark Brown <broonie@kernel.org> --- sound/soc/codecs/sma1303.c | 79 ++++---------------------------------- 1 file changed, 8 insertions(+), 71 deletions(-)