|
@@ -169,6 +169,34 @@ static int swr_dmic_tx_master_port_put(struct snd_kcontrol *kcontrol,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int swr_dmic_port_enable(struct snd_soc_dapm_widget *w,
|
|
|
+ struct snd_kcontrol *kcontrol, int event)
|
|
|
+{
|
|
|
+ int ret = 0;
|
|
|
+ struct snd_soc_component *component =
|
|
|
+ snd_soc_dapm_to_component(w->dapm);
|
|
|
+ struct swr_dmic_priv *swr_dmic =
|
|
|
+ snd_soc_component_get_drvdata(component);
|
|
|
+
|
|
|
+ u8 ch_mask = 0x01; // only DpnChannelEN1 register is available
|
|
|
+ u8 num_port = 1;
|
|
|
+ u8 port_id = swr_dmic->port_type;
|
|
|
+ u8 port_type = swr_dmic->tx_master_port_map[port_id];
|
|
|
+
|
|
|
+ switch (event) {
|
|
|
+ case SND_SOC_DAPM_POST_PMU:
|
|
|
+ ret = swr_slvdev_datapath_control(swr_dmic->swr_slave,
|
|
|
+ swr_dmic->swr_slave->dev_num, true);
|
|
|
+ break;
|
|
|
+ case SND_SOC_DAPM_PRE_PMD:
|
|
|
+ ret = swr_disconnect_port(swr_dmic->swr_slave,
|
|
|
+ &port_id, num_port, &ch_mask, &port_type);
|
|
|
+ break;
|
|
|
+ };
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
static int dmic_swr_ctrl(struct snd_soc_dapm_widget *w,
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
|
|
{
|
|
@@ -189,31 +217,26 @@ static int dmic_swr_ctrl(struct snd_soc_dapm_widget *w,
|
|
|
* Port 1 is high quality / 2.4 or 3.072 Mbps
|
|
|
* Port 2 is listen low power / 0.6 or 0.768 Mbps
|
|
|
*/
|
|
|
- if(swr_dmic->port_type)
|
|
|
+ if(swr_dmic->port_type == SWR_DMIC_HIFI_PORT)
|
|
|
ch_rate = SWR_CLK_RATE_2P4MHZ;
|
|
|
else
|
|
|
- ch_rate = SWR_CLK_RATE_4P8MHZ;
|
|
|
+ ch_rate = SWR_CLK_RATE_0P6MHZ;
|
|
|
|
|
|
port_type = swr_dmic->tx_master_port_map[port_id];
|
|
|
|
|
|
+ dev_dbg(component->dev, "%s port_type: %d event: %d\n", __func__,
|
|
|
+ port_type, event);
|
|
|
+
|
|
|
switch (event) {
|
|
|
case SND_SOC_DAPM_PRE_PMU:
|
|
|
ret = swr_connect_port(swr_dmic->swr_slave, &port_id,
|
|
|
num_port, &ch_mask, &ch_rate,
|
|
|
&num_ch, &port_type);
|
|
|
break;
|
|
|
- case SND_SOC_DAPM_POST_PMU:
|
|
|
- ret = swr_slvdev_datapath_control(swr_dmic->swr_slave,
|
|
|
- swr_dmic->swr_slave->dev_num, true);
|
|
|
- break;
|
|
|
- case SND_SOC_DAPM_PRE_PMD:
|
|
|
+ case SND_SOC_DAPM_POST_PMD:
|
|
|
ret = swr_slvdev_datapath_control(swr_dmic->swr_slave,
|
|
|
swr_dmic->swr_slave->dev_num, false);
|
|
|
break;
|
|
|
- case SND_SOC_DAPM_POST_PMD:
|
|
|
- ret = swr_disconnect_port(swr_dmic->swr_slave,
|
|
|
- &port_id, num_port, &ch_mask, &port_type);
|
|
|
- break;
|
|
|
};
|
|
|
|
|
|
return ret;
|
|
@@ -276,8 +299,7 @@ static const struct snd_kcontrol_new dmic_switch[] = {
|
|
|
static const struct snd_soc_dapm_widget swr_dmic_dapm_widgets[] = {
|
|
|
SND_SOC_DAPM_MIXER_E("SWR_DMIC_MIXER", SND_SOC_NOPM, 0, 0,
|
|
|
dmic_switch, ARRAY_SIZE(dmic_switch), dmic_swr_ctrl,
|
|
|
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
|
|
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
|
|
|
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
|
|
|
|
|
|
SND_SOC_DAPM_INPUT("SWR_DMIC"),
|
|
|
|
|
@@ -285,14 +307,17 @@ static const struct snd_soc_dapm_widget swr_dmic_dapm_widgets[] = {
|
|
|
swr_dmic_enable_supply,
|
|
|
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
|
|
SND_SOC_DAPM_POST_PMD),
|
|
|
-
|
|
|
+ SND_SOC_DAPM_OUT_DRV_E("SMIC_PORT_EN", SND_SOC_NOPM, 0, 0, NULL, 0,
|
|
|
+ swr_dmic_port_enable,
|
|
|
+ SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
|
|
|
SND_SOC_DAPM_OUTPUT("SWR_DMIC_OUTPUT"),
|
|
|
};
|
|
|
|
|
|
static const struct snd_soc_dapm_route swr_dmic_audio_map[] = {
|
|
|
{"SWR_DMIC", NULL, "SMIC_SUPPLY"},
|
|
|
{"SWR_DMIC_MIXER", "Switch", "SWR_DMIC"},
|
|
|
- {"SWR_DMIC_OUTPUT", NULL, "SWR_DMIC_MIXER"},
|
|
|
+ {"SMIC_PORT_EN", NULL, "SWR_DMIC_MIXER"},
|
|
|
+ {"SWR_DMIC_OUTPUT", NULL, "SMIC_PORT_EN"},
|
|
|
};
|
|
|
|
|
|
static int swr_dmic_codec_probe(struct snd_soc_component *component)
|
|
@@ -590,6 +615,7 @@ static int swr_dmic_reset(struct swr_device *pdev)
|
|
|
usleep_range(1000, 1100);
|
|
|
}
|
|
|
pdev->dev_num = devnum;
|
|
|
+ dev_dbg(&pdev->dev, "%s: devnum: %d\n", __func__, devnum);
|
|
|
|
|
|
return 0;
|
|
|
}
|