@@ -374,190 +374,6 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol,
return 0;
}
-static const char * const sma1303_amp_mode_text[] = {
- "1 Chip", "Mono on 2 chips", "Left in 2 chips", "Right in 2chips"};
-
-static const struct soc_enum sma1303_amp_mode_enum =
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_amp_mode_text),
- sma1303_amp_mode_text);
-static int sma1303_amp_mode_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->amp_mode;
-
- switch (sma1303->amp_mode) {
- case ONE_CHIP_SOLUTION:
- dev_info(component->dev, "Amplifier 1 Chip Solution\n");
- break;
- case MONO_TWO_CHIP_SOLUTION:
- dev_info(component->dev, "Amplifier Mono 2 Chips Solution\n");
- break;
- case LEFT_TWO_CHIP_SOLUTION:
- dev_info(component->dev, "Amplifier Stereo(Left) 2 Chips Solution\n");
- break;
- case RIGHT_TWO_CHIP_SOLUTION:
- dev_info(component->dev, "Amplifier Stereo(Right) 2 Chips Solution\n");
- break;
- default:
- dev_err(component->dev, "Invalid Value");
- return ret;
- }
- return 0;
-
-}
-
-static int sma1303_amp_mode_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 = 0;
-
- if (component == NULL) {
- pr_err("%s:component is NULL\n", __func__);
- return -1;
- }
- if (sma1303 == NULL) {
- pr_err("%s:sma1303 is NULL\n", __func__);
- return -1;
- }
-
- sma1303->amp_mode = ucontrol->value.integer.value[0];
-
- switch (sma1303->amp_mode) {
- case ONE_CHIP_SOLUTION:
- case MONO_TWO_CHIP_SOLUTION:
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_11_SYSTEM_CTRL2,
- MONOMIX_MASK, MONOMIX_ON);
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_11_SYSTEM_CTRL2,
- LR_DATA_SW_MASK, LR_DATA_SW_NORMAL);
- break;
- case LEFT_TWO_CHIP_SOLUTION:
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_11_SYSTEM_CTRL2,
- MONOMIX_MASK, MONOMIX_OFF);
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_11_SYSTEM_CTRL2,
- LR_DATA_SW_MASK, LR_DATA_SW_NORMAL);
- break;
- case RIGHT_TWO_CHIP_SOLUTION:
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_11_SYSTEM_CTRL2,
- MONOMIX_MASK, MONOMIX_OFF);
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_11_SYSTEM_CTRL2,
- LR_DATA_SW_MASK, LR_DATA_SW_SWAP);
- break;
- default:
- dev_err(component->dev, "Invalid Value");
- ret += -1;
- }
-
- return ret;
-}
-
-static const char * const sma1303_outport_config_text[] = {
- "Enable", "Disable"};
-
-static const struct soc_enum sma1303_outport_config_enum =
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_outport_config_text),
- sma1303_outport_config_text);
-
-static int sma1303_outport_config_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, data, val;
-
- 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;
- }
-
- ret = sma1303_regmap_read(sma1303, SMA1303_09_OUTPUT_CTRL, &data);
- if (ret < 0) {
- dev_err(component->dev,
- "Failed to read, register: %x ret: %d\n",
- SMA1303_09_OUTPUT_CTRL, ret);
- return ret;
- }
-
- val = data & PORT_CONFIG_MASK;
- switch (val) {
- case INPUT_PORT_ONLY:
- ucontrol->value.integer.value[0] = 1;
- break;
- case OUTPUT_PORT_ENABLE:
- ucontrol->value.integer.value[0] = 0;
- break;
- default:
- dev_err(component->dev,
- "Invalid value, register: %x value: %d\n",
- SMA1303_09_OUTPUT_CTRL, val);
- return ret;
- }
-
- return 0;
-}
-
-static int sma1303_outport_config_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 sel = (int)ucontrol->value.integer.value[0];
- int val, 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;
- }
-
- switch (sel) {
- case 0:
- val = OUTPUT_PORT_ENABLE;
- break;
- case 1:
- val = INPUT_PORT_ONLY;
- break;
- default:
- dev_err(component->dev,
- "Invalid value, register: %x\n",
- SMA1303_09_OUTPUT_CTRL);
- return ret;
- }
-
- return sma1303_regmap_update_bits(sma1303,
- SMA1303_09_OUTPUT_CTRL, PORT_CONFIG_MASK, val);
-}
-
static const char * const sma1303_spkmute_text[] = {
"Unmute", "Mute"};
@@ -566,111 +382,6 @@ static const struct soc_enum sma1303_spkmute_enum =
ARRAY_SIZE(sma1303_spkmute_text),
sma1303_spkmute_text);
-static const char * const sma1303_spkmode_text[] = {
- "Off", "On"};
-
-static const struct soc_enum sma1303_spkmode_enum =
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_spkmode_text),
- sma1303_spkmode_text);
-
-static int sma1303_spkmode_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 val, data, 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;
- }
-
- ret = sma1303_regmap_read(sma1303, SMA1303_10_SYSTEM_CTRL1, &data);
- if (ret < 0) {
- dev_err(component->dev,
- "Failed to read, register: %x ret: %d\n",
- SMA1303_10_SYSTEM_CTRL1, ret);
- return ret;
- }
-
- val = data & SPK_MODE_MASK;
- if (sma1303->amp_mode == ONE_CHIP_SOLUTION) {
- switch (val) {
- case SPK_OFF:
- ucontrol->value.integer.value[0] = 0;
- break;
- case SPK_MONO:
- ucontrol->value.integer.value[0] = 1;
- break;
- default:
- dev_err(component->dev,
- "Invalid value, register: %x\n",
- SMA1303_10_SYSTEM_CTRL1);
- return ret;
- }
- } else {
- switch (val) {
- case SPK_OFF:
- ucontrol->value.integer.value[0] = 0;
- break;
- case SPK_STEREO:
- ucontrol->value.integer.value[0] = 1;
- break;
- default:
- dev_err(component->dev,
- "Invalid value, register: %x\n",
- SMA1303_10_SYSTEM_CTRL1);
- return ret;
- }
- }
-
- return 0;
-}
-
-static int sma1303_spkmode_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 sel = (int)ucontrol->value.integer.value[0];
- int val, 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;
- }
-
- switch (sel) {
- case 0:
- val = SPK_OFF;
- break;
- case 1:
- if (sma1303->amp_mode == ONE_CHIP_SOLUTION)
- val = SPK_MONO;
- else
- val = SPK_STEREO;
- break;
- default:
- dev_err(component->dev,
- "Invalid value, register: %x\n",
- SMA1303_10_SYSTEM_CTRL1);
- return ret;
- }
-
- return sma1303_regmap_update_bits(sma1303,
- SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, val);
-}
-
static int postscaler_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -852,41 +563,18 @@ static int sma1303_o_format_put(struct snd_kcontrol *kcontrol,
SMA1303_A4_TOP_MAN3, O_FORMAT_MASK, val);
}
-static const char * const sma1303_sdo_source_texts[] = {
- "Disable", "Format_C", "Mixer_Out", "After_DSP", "After_Post"};
-static const unsigned int sma1303_sdo_source_values[] = {
- OUT_SEL_DISABLE,
- FORMAT_CONVERTER,
- MIXER_OUTPUT,
- SPEAKER_PATH,
- POSTSCALER_OUTPUT};
-static SOC_VALUE_ENUM_SINGLE_DECL(sma1303_sdo_source_enum,
- SMA1303_09_OUTPUT_CTRL,
- 0, PORT_OUT_SEL_MASK,
- sma1303_sdo_source_texts,
- 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 char * const sma1303_aif_in_source_text[] = {
+ "Mono", "Left", "Right"};
+static const char * const sma1303_aif_out_source_text[] = {
+ "Disable", "After_FmtC", "After_Mixer", "After_DSP", "After_Post",
+ "Clk_PLL", "Clk_OSC"};
-static const struct snd_kcontrol_new sma1303_snd_controls[] = {
-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,
- sma1303_outport_config_get, sma1303_outport_config_put),
-SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL,
- 0, 167, 1, sma1303_spk_tlv),
-SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum),
-SOC_ENUM_EXT("Speaker Output", sma1303_spkmode_enum,
- sma1303_spkmode_get, sma1303_spkmode_put),
-SND_SOC_BYTES_EXT("Postscaler Set", 1,
- postscaler_get, postscaler_put),
-SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum,
- sma1303_postscaler_config_get, sma1303_postscaler_config_put),
-SOC_ENUM_EXT("Output Format", sma1303_o_format_enum,
- sma1303_o_format_get, sma1303_o_format_put),
-};
+static const struct soc_enum sma1303_aif_in_source_enum =
+ SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_aif_in_source_text),
+ sma1303_aif_in_source_text);
+static const struct soc_enum sma1303_aif_out_source_enum =
+ SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_aif_out_source_text),
+ sma1303_aif_out_source_text);
static int sma1303_startup(struct snd_soc_component *component)
{
@@ -905,7 +593,7 @@ static int sma1303_startup(struct snd_soc_component *component)
ret += sma1303_regmap_update_bits(sma1303,
SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_ON);
- if (sma1303->amp_mode == ONE_CHIP_SOLUTION)
+ if (sma1303->amp_mode == SMA1303_MONO)
ret += sma1303_regmap_update_bits(sma1303,
SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_MONO);
else
@@ -963,62 +651,157 @@ static int sma1303_shutdown(struct snd_soc_component *component)
return ret;
}
-static int sma1303_clk_supply_event(struct snd_soc_dapm_widget *w,
+static int sma1303_aif_in_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
+ snd_soc_dapm_to_component(w->dapm);
+ struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+ unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]);
+ int ret = 0;
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
- dev_info(component->dev, "%s : PRE_PMU\n", __func__);
- break;
+ switch (mux) {
+ case 0:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_11_SYSTEM_CTRL2,
+ MONOMIX_MASK,
+ MONOMIX_ON);
+ ret += sma1303->amp_mode = SMA1303_MONO;
+ break;
+ case 1:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_11_SYSTEM_CTRL2,
+ MONOMIX_MASK,
+ MONOMIX_OFF);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_11_SYSTEM_CTRL2,
+ LR_DATA_SW_MASK,
+ LR_DATA_SW_NORMAL);
+ ret += sma1303->amp_mode = SMA1303_STEREO;
+ break;
+ case 2:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_11_SYSTEM_CTRL2,
+ MONOMIX_MASK,
+ MONOMIX_OFF);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_11_SYSTEM_CTRL2,
+ LR_DATA_SW_MASK,
+ LR_DATA_SW_NORMAL);
+ sma1303->amp_mode = SMA1303_STEREO;
+ break;
+ default:
+ dev_err(sma1303->dev, "%s : Invald value (%d)\n",
+ __func__, mux);
+ return -EINVAL;
+ }
- case SND_SOC_DAPM_POST_PMD:
- dev_info(component->dev, "%s : POST_PMD\n", __func__);
- break;
+ dev_info(sma1303->dev, "%s : Source : %s\n", __func__,
+ sma1303_aif_in_source_text[mux]);
+ break;
}
-
- return 0;
+ return ret;
}
-static int sma1303_dac_event(struct snd_soc_dapm_widget *w,
+static int sma1303_aif_out_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
+ snd_soc_dapm_to_component(w->dapm);
+ struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+ unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]);
+ int ret = 0;
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
- dev_info(component->dev, "%s : PRE_PMU\n", __func__);
-
- sma1303_startup(component);
-
- break;
-
- case SND_SOC_DAPM_POST_PMU:
- dev_info(component->dev, "%s : POST_PMU\n", __func__);
-
- break;
-
- case SND_SOC_DAPM_PRE_PMD:
- dev_info(component->dev, "%s : PRE_PMD\n", __func__);
-
- sma1303_shutdown(component);
-
- break;
-
- case SND_SOC_DAPM_POST_PMD:
- dev_info(component->dev, "%s : POST_PMD\n", __func__);
+ switch (mux) {
+ case 0:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ NORMAL_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_09_OUTPUT_CTRL,
+ PORT_OUT_SEL_MASK,
+ OUT_SEL_DISABLE);
+ break;
+ case 1:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ NORMAL_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_09_OUTPUT_CTRL,
+ PORT_OUT_SEL_MASK,
+ FORMAT_CONVERTER);
+ break;
+ case 2:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ NORMAL_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_09_OUTPUT_CTRL,
+ PORT_OUT_SEL_MASK,
+ MIXER_OUTPUT);
+ break;
+ case 3:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ NORMAL_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_09_OUTPUT_CTRL,
+ PORT_OUT_SEL_MASK,
+ SPEAKER_PATH);
+ break;
+ case 4:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ NORMAL_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_09_OUTPUT_CTRL,
+ PORT_OUT_SEL_MASK,
+ POSTSCALER_OUTPUT);
+ break;
+ case 5:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ CLK_OUT_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ MON_OSC_PLL_MASK,
+ PLL_SDO);
+ break;
+ case 6:
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ TEST_CLKO_EN_MASK,
+ CLK_OUT_SDO);
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_A3_TOP_MAN2,
+ MON_OSC_PLL_MASK,
+ PLL_OSC);
+ break;
+ default:
+ dev_err(sma1303->dev, "%s : Invald value (%d)\n",
+ __func__, mux);
+ return -EINVAL;
+ }
+ dev_info(sma1303->dev, "%s : Source : %s\n", __func__,
+ sma1303_aif_out_source_text[mux]);
break;
}
-
- return 0;
+ return ret;
}
-static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
+static int sma1303_sdo_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
@@ -1027,59 +810,132 @@ static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w,
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
- dev_info(component->dev,
- "%s : DAC feedback ON\n", __func__);
+ dev_info(sma1303->dev,
+ "%s : SND_SOC_DAPM_PRE_PMU\n", __func__);
ret += sma1303_regmap_update_bits(sma1303,
SMA1303_09_OUTPUT_CTRL,
- PORT_CONFIG_MASK|PORT_OUT_SEL_MASK,
- OUTPUT_PORT_ENABLE|SPEAKER_PATH);
-
+ PORT_CONFIG_MASK,
+ OUTPUT_PORT_ENABLE);
ret += sma1303_regmap_update_bits(sma1303,
SMA1303_A3_TOP_MAN2,
- SDO_OUTPUT_MASK, NORMAL_OUT);
+ SDO_OUTPUT_MASK,
+ NORMAL_OUT);
break;
-
- case SND_SOC_DAPM_PRE_PMD:
- dev_info(component->dev,
- "%s : DAC feedback OFF\n", __func__);
+ case SND_SOC_DAPM_POST_PMD:
+ dev_info(sma1303->dev,
+ "%s : SND_SOC_DAPM_POST_PMD\n", __func__);
ret += sma1303_regmap_update_bits(sma1303,
SMA1303_09_OUTPUT_CTRL,
- PORT_OUT_SEL_MASK, OUT_SEL_DISABLE);
-
+ PORT_CONFIG_MASK,
+ INPUT_PORT_ONLY);
ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_A3_TOP_MAN2, SDO_OUTPUT_MASK,
+ SMA1303_A3_TOP_MAN2,
+ SDO_OUTPUT_MASK,
HIGH_Z_OUT);
break;
}
+ return ret;
+}
+
+static int sma1303_power_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ struct snd_soc_component *component =
+ snd_soc_dapm_to_component(w->dapm);
+ struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+ int ret = 0;
+ switch (event) {
+ case SND_SOC_DAPM_POST_PMU:
+ dev_info(sma1303->dev,
+ "%s : SND_SOC_DAPM_POST_PMU\n", __func__);
+ ret = sma1303_startup(component);
+ break;
+ case SND_SOC_DAPM_PRE_PMD:
+ dev_info(sma1303->dev,
+ "%s : SND_SOC_DAPM_PRE_PMD\n", __func__);
+ ret = sma1303_shutdown(component);
+ break;
+ }
return ret;
}
+static const struct snd_kcontrol_new sma1303_aif_in_source_control =
+ SOC_DAPM_ENUM("AIF IN Source", sma1303_aif_in_source_enum);
+static const struct snd_kcontrol_new sma1303_aif_out_source_control =
+ SOC_DAPM_ENUM("AIF OUT Source", sma1303_aif_out_source_enum);
+static const struct snd_kcontrol_new sma1303_sdo_control =
+ SOC_DAPM_SINGLE_VIRT("Switch", 1);
+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_TLV("Speaker Volume", SMA1303_0A_SPK_VOL,
+ 0, 167, 1, sma1303_spk_tlv),
+SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum),
+SND_SOC_BYTES_EXT("Postscaler Set", 1,
+ postscaler_get, postscaler_put),
+SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum,
+ sma1303_postscaler_config_get, sma1303_postscaler_config_put),
+SOC_ENUM_EXT("Output Format", sma1303_o_format_enum,
+ sma1303_o_format_get, sma1303_o_format_put),
+};
+
static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = {
-SND_SOC_DAPM_SUPPLY("CLK_SUPPLY", SND_SOC_NOPM, 0, 0, sma1303_clk_supply_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-SND_SOC_DAPM_DAC_E("DAC", "Playback", SND_SOC_NOPM, 0, 0, sma1303_dac_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
-SND_SOC_DAPM_ADC_E("DAC_FEEDBACK", "Capture", SND_SOC_NOPM, 0, 0,
- sma1303_dac_feedback_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
-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),
+ /* platform domain */
+ SND_SOC_DAPM_OUTPUT("SPK"),
+ SND_SOC_DAPM_INPUT("SDO"),
+
+ /* path domain */
+ SND_SOC_DAPM_MUX_E("AIF IN Source", SND_SOC_NOPM, 0, 0,
+ &sma1303_aif_in_source_control,
+ sma1303_aif_in_event,
+ SND_SOC_DAPM_PRE_PMU),
+ SND_SOC_DAPM_MUX_E("AIF OUT Source", SND_SOC_NOPM, 0, 0,
+ &sma1303_aif_out_source_control,
+ sma1303_aif_out_event,
+ SND_SOC_DAPM_PRE_PMU),
+ SND_SOC_DAPM_SWITCH_E("SDO Enable", SND_SOC_NOPM, 0, 0,
+ &sma1303_sdo_control,
+ sma1303_sdo_event,
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+ SND_SOC_DAPM_MIXER("Entry", SND_SOC_NOPM, 0, 0, NULL, 0),
+ SND_SOC_DAPM_OUT_DRV_E("AMP Power", SND_SOC_NOPM, 0, 0, NULL, 0,
+ sma1303_power_event,
+ SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+ SND_SOC_DAPM_SWITCH("AMP Enable", SND_SOC_NOPM, 0, 1,
+ &sma1303_enable_control),
+
+ /* stream domain */
+ SND_SOC_DAPM_AIF_IN("AIF IN", "Playback", 0, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0),
};
static const struct snd_soc_dapm_route sma1303_audio_map[] = {
-{"DAC", NULL, "CLK_SUPPLY"},
-{"AMP Enable", "Switch", "DAC"},
-{"SPK", NULL, "AMP Enable"},
-{"SDO Source", "Disable", "SDO"},
-{"SDO Source", "Format_C", "SDO"},
-{"SDO Source", "Mixer_Out", "SDO"},
-{"SDO Source", "After_DSP", "SDO"},
-{"SDO Source", "After_Post", "SDO"},
-{"DAC_FEEDBACK", NULL, "SDO Source"},
+ /* Playback */
+ {"AIF IN Source", "Mono", "AIF IN"},
+ {"AIF IN Source", "Left", "AIF IN"},
+ {"AIF IN Source", "Right", "AIF IN"},
+
+ {"SDO Enable", "Switch", "AIF IN"},
+ {"AIF OUT Source", "Disable", "SDO Enable"},
+ {"AIF OUT Source", "After_FmtC", "SDO Enable"},
+ {"AIF OUT Source", "After_Mixer", "SDO Enable"},
+ {"AIF OUT Source", "After_DSP", "SDO Enable"},
+ {"AIF OUT Source", "After_Post", "SDO Enable"},
+ {"AIF OUT Source", "Clk_PLL", "SDO Enable"},
+ {"AIF OUT Source", "Clk_OSC", "SDO Enable"},
+
+ {"Entry", NULL, "AIF OUT Source"},
+ {"Entry", NULL, "AIF IN Source"},
+
+ {"AMP Power", NULL, "Entry"},
+
+ {"AMP Enable", "Switch", "AMP Power"},
+ {"SPK", NULL, "AMP Enable"},
+
+ /* Capture */
+ {"AIF OUT", NULL, "AMP Enable"},
};
static int sma1303_setup_pll(struct snd_soc_component *component,
@@ -1976,7 +1832,7 @@ static int sma1303_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, sma1303);
- sma1303->amp_mode = ONE_CHIP_SOLUTION;
+ sma1303->amp_mode = SMA1303_MONO;
sma1303->amp_power_status = false;
sma1303->check_fault_status = true;
sma1303->pll_matches = sma1303_pll_matches;
@@ -28,12 +28,10 @@ void sma1303_set_callback_func(struct callback_ops ops);
#define SMA1303_PLL_CLKIN_MCLK 0x02
#define SMA1303_PLL_CLKIN_BCLK 0x03
-#define ONE_CHIP_SOLUTION 0x00
-#define MONO_TWO_CHIP_SOLUTION 0x01
-#define LEFT_TWO_CHIP_SOLUTION 0x02
-#define RIGHT_TWO_CHIP_SOLUTION 0x03
+#define SMA1303_MONO 0x00
+#define SMA1303_STEREO 0x01
-#define SMA1303_I2C_RETRY_COUNT 3
+#define SMA1303_I2C_RETRY_COUNT 3
/*
* SMA1303 Register Definition
Remove the control of 'amp_mode', and add the 'AIF IN' in DAPM. Remove the outport and add SDO Enable event in DAPM. In DAPM, instead of DAC and ADC, AIF IN & OUT were used, and AMP power control was added. Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com> Reported-by: Mark Brown <broonie@kernel.org> --- sound/soc/codecs/sma1303.c | 644 ++++++++++++++----------------------- sound/soc/codecs/sma1303.h | 8 +- 2 files changed, 253 insertions(+), 399 deletions(-)