static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *bolero_component = NULL;
struct snd_soc_component *component = NULL;
struct snd_soc_dapm_context *dapm = NULL;
int ret = 0;
void *mbhc_calibration;
struct snd_info_entry *entry;
struct snd_card *card = NULL;
struct msm_asoc_mach_data *pdata =
snd_soc_card_get_drvdata(rtd->card);
pr_err("%s:: enter \n", __func__);
bolero_component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
if (!bolero_component) {
pr_err("%s: could not find component for bolero_codec\n",
__func__);
return -EINVAL;
}
pr_err("%s:: bolero comp lookup done\n", __func__);
dapm = snd_soc_component_get_dapm(bolero_component);
snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
ARRAY_SIZE(msm_int_dapm_widgets));
pr_err("%s:: dapm new controls msm_int_dapm_widgets \n", __func__);
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
snd_soc_dapm_sync(dapm);
card = rtd->card->snd_card;
if (!pdata->codec_root) {
entry = msm_snd_info_create_subdir(card->module, "codecs",
card->proc_root);
if (!entry) {
pr_debug("%s: Cannot create codecs module entry\n",
__func__);
ret = 0;
goto err;
}
pdata->codec_root = entry;
}
bolero_info_create_codec_entry(pdata->codec_root, bolero_component);
bolero_register_wake_irq(bolero_component, false);
component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
if (!component)
component = snd_soc_rtdcom_lookup(rtd, "rouleur_codec");
if (!component)
component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
if (!component) {
pr_err("%s component is NULL\n", __func__);
return -EINVAL;
}
dapm = snd_soc_component_get_dapm(component);
card = component->card->snd_card;
pdata = snd_soc_card_get_drvdata(component->card);
if (!pdata)
return -EINVAL;
if (!pdata->codec_root) {
entry = msm_snd_info_create_subdir(card->module, "codecs",
card->proc_root);
if (!entry) {
dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
__func__);
ret = 0;
goto mbhc_cfg_cal;
}
pdata->codec_root = entry;
}
if (!strncmp(component->driver->name, WCD937X_DRV_NAME, 13)) {
wcd937x_info_create_codec_entry(pdata->codec_root, component);
bolero_set_port_map(bolero_component,
ARRAY_SIZE(sm_port_map),
sm_port_map);
}
if (!strncmp(component->driver->name, "rouleur_codec", 13)) {
rouleur_info_create_codec_entry(pdata->codec_root, component);
bolero_set_port_map(bolero_component,
ARRAY_SIZE(sm_port_map_rouleur),
sm_port_map_rouleur);
}
snd_soc_dapm_ignore_suspend(dapm, "EAR");
snd_soc_dapm_ignore_suspend(dapm, "AUX");
snd_soc_dapm_ignore_suspend(dapm, "LO");
snd_soc_dapm_ignore_suspend(dapm, "HPHL");
snd_soc_dapm_ignore_suspend(dapm, "HPHR");
snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
snd_soc_dapm_sync(dapm);
codec_reg_done = true;
msm_common_dai_link_init(rtd);
mbhc_cfg_cal:
if (!strncmp(component->driver->name, WCD937X_DRV_NAME, 13)) {
mbhc_calibration = def_wcd_mbhc_cal();
if (!mbhc_calibration)
return -ENOMEM;
wcd_mbhc_cfg.calibration = mbhc_calibration;
ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
}
if (!strncmp(component->driver->name, "rouleur_codec", 13)) {
pr_debug("%s rouleur_codec mbhc_calibration \n" ,__func__);
mbhc_calibration = def_rouleur_mbhc_cal();
if (!mbhc_calibration)
return -ENOMEM;
wcd_mbhc_cfg.calibration = mbhc_calibration;
ret = 0;
ret = rouleur_mbhc_hs_detect(component, &wcd_mbhc_cfg);
}
if (ret) {
dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
__func__, ret);
goto err_hs_detect;
}
#ifdef CONFIG_SND_SOC_FS181X
ret = frsm_add_codec_controls(component);
if (ret < 0) {
pr_err("%s: fs181x add_codec_controls failed, err %d\n", __func__, ret);
};
#endif
#ifdef CONFIG_SND_SOC_OCA72XXX
ret = oca72xxx_add_codec_controls((void *)component);
if (ret < 0) {
pr_err("%s: oca72xxx add_codec_controls failed, err %d\n", __func__, ret);
};
#endif
return 0;
err_hs_detect:
kfree(mbhc_calibration);
err:
pr_err("%s:: return %d \n", __func__, ret);
return ret;
}
static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
{
struct msm_asoc_mach_data *pdata =
snd_soc_card_get_drvdata(rtd->card);
int ret = 0;
if (pdata->wsa_max_devs == 0)
pr_info("%s: WSA is not enabled\n", __func__);
msm_common_dai_link_init(rtd);
return ret;
}