asoc: Add machine driver support for wcd937x
Add machine driver support for WCD937x. Change-Id: I863b95255caf99565dfc7c74b0f54891f58dc0df Signed-off-by: Faiz Nabi Kuchay <quic_fkuchay@quicinc.com>
This commit is contained in:

committed by
Faiz Kuchay

parent
ba09b0efd6
commit
a3a1e552fa
@@ -33,9 +33,11 @@
|
|||||||
#include "device_event.h"
|
#include "device_event.h"
|
||||||
#include "asoc/msm-cdc-pinctrl.h"
|
#include "asoc/msm-cdc-pinctrl.h"
|
||||||
#include "asoc/wcd-mbhc-v2.h"
|
#include "asoc/wcd-mbhc-v2.h"
|
||||||
|
#include "codecs/wcd937x/wcd937x-mbhc.h"
|
||||||
#include "codecs/wcd939x/wcd939x-mbhc.h"
|
#include "codecs/wcd939x/wcd939x-mbhc.h"
|
||||||
#include "codecs/wsa884x/wsa884x.h"
|
#include "codecs/wsa884x/wsa884x.h"
|
||||||
#include "codecs/wsa883x/wsa883x.h"
|
#include "codecs/wsa883x/wsa883x.h"
|
||||||
|
#include "codecs/wcd937x/wcd937x.h"
|
||||||
#include "codecs/wcd939x/wcd939x.h"
|
#include "codecs/wcd939x/wcd939x.h"
|
||||||
#include "codecs/lpass-cdc/lpass-cdc.h"
|
#include "codecs/lpass-cdc/lpass-cdc.h"
|
||||||
#include <bindings/audio-codec-port-types.h>
|
#include <bindings/audio-codec-port-types.h>
|
||||||
@@ -64,6 +66,11 @@
|
|||||||
#define STEREO_SPEAKER 2
|
#define STEREO_SPEAKER 2
|
||||||
#define QUAD_SPEAKER 4
|
#define QUAD_SPEAKER 4
|
||||||
|
|
||||||
|
enum {
|
||||||
|
WCD937X_DEV_INDEX,
|
||||||
|
WCD939X_DEV_INDEX,
|
||||||
|
};
|
||||||
|
|
||||||
struct msm_asoc_mach_data {
|
struct msm_asoc_mach_data {
|
||||||
struct snd_info_entry *codec_root;
|
struct snd_info_entry *codec_root;
|
||||||
struct msm_common_pdata *common_pdata;
|
struct msm_common_pdata *common_pdata;
|
||||||
@@ -83,6 +90,7 @@ struct msm_asoc_mach_data {
|
|||||||
int backend_used;
|
int backend_used;
|
||||||
struct prm_earpa_hw_intf_config upd_config;
|
struct prm_earpa_hw_intf_config upd_config;
|
||||||
bool dedicated_wsa2; /* used to define how wsa2 slave devices are used */
|
bool dedicated_wsa2; /* used to define how wsa2 slave devices are used */
|
||||||
|
int wcd_used;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool is_initial_boot;
|
static bool is_initial_boot;
|
||||||
@@ -195,6 +203,7 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
|
|||||||
u8 dev_num = 0;
|
u8 dev_num = 0;
|
||||||
struct snd_soc_component *component = NULL;
|
struct snd_soc_component *component = NULL;
|
||||||
struct msm_asoc_mach_data *pdata = NULL;
|
struct msm_asoc_mach_data *pdata = NULL;
|
||||||
|
char wcd_name[20];
|
||||||
|
|
||||||
if (!rtd) {
|
if (!rtd) {
|
||||||
pr_err_ratelimited("%s: rtd is NULL\n", __func__);
|
pr_err_ratelimited("%s: rtd is NULL\n", __func__);
|
||||||
@@ -227,7 +236,12 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
|
if (pdata->wcd_used == WCD937X_DEV_INDEX)
|
||||||
|
strscpy(wcd_name, WCD937X_DRV_NAME, sizeof(WCD937X_DRV_NAME));
|
||||||
|
else
|
||||||
|
strscpy(wcd_name, WCD939X_DRV_NAME, sizeof(WCD939X_DRV_NAME));
|
||||||
|
|
||||||
|
component = snd_soc_rtdcom_lookup(rtd, wcd_name);
|
||||||
if (!component) {
|
if (!component) {
|
||||||
pr_err("%s component is NULL\n", __func__);
|
pr_err("%s component is NULL\n", __func__);
|
||||||
return;
|
return;
|
||||||
@@ -240,7 +254,11 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
|
|||||||
else
|
else
|
||||||
pdata->get_dev_num = wsa884x_codec_get_dev_num;
|
pdata->get_dev_num = wsa884x_codec_get_dev_num;
|
||||||
} else {
|
} else {
|
||||||
pdata->get_dev_num = wcd939x_codec_get_dev_num;
|
if (pdata->wcd_used == WCD937X_DEV_INDEX) {
|
||||||
|
pdata->get_dev_num = wcd937x_codec_get_dev_num;
|
||||||
|
} else if (pdata->wcd_used == WCD939X_DEV_INDEX) {
|
||||||
|
pdata->get_dev_num = wcd939x_codec_get_dev_num;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pdata->get_dev_num) {
|
if (!pdata->get_dev_num) {
|
||||||
@@ -1399,6 +1417,7 @@ static int msm_snd_card_late_probe(struct snd_soc_card *card)
|
|||||||
struct msm_asoc_mach_data *pdata;
|
struct msm_asoc_mach_data *pdata;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
void *mbhc_calibration;
|
void *mbhc_calibration;
|
||||||
|
char wcd_name[20];
|
||||||
|
|
||||||
pdata = snd_soc_card_get_drvdata(card);
|
pdata = snd_soc_card_get_drvdata(card);
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
@@ -1415,7 +1434,12 @@ static int msm_snd_card_late_probe(struct snd_soc_card *card)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
|
if (pdata->wcd_used == WCD937X_DEV_INDEX)
|
||||||
|
strscpy(wcd_name, WCD937X_DRV_NAME, sizeof(WCD937X_DRV_NAME));
|
||||||
|
else
|
||||||
|
strscpy(wcd_name, WCD939X_DRV_NAME, sizeof(WCD939X_DRV_NAME));
|
||||||
|
|
||||||
|
component = snd_soc_rtdcom_lookup(rtd, wcd_name);
|
||||||
if (!component) {
|
if (!component) {
|
||||||
pr_err("%s component is NULL\n", __func__);
|
pr_err("%s component is NULL\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -1432,6 +1456,16 @@ static int msm_snd_card_late_probe(struct snd_soc_card *card)
|
|||||||
wcd_mbhc_cfg.usbss_hsj_connect_enable = true;
|
wcd_mbhc_cfg.usbss_hsj_connect_enable = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
switch (pdata->wcd_used) {
|
||||||
|
case WCD937X_DEV_INDEX:
|
||||||
|
ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
|
||||||
|
break;
|
||||||
|
case WCD939X_DEV_INDEX:
|
||||||
|
ret = wcd939x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
ret = wcd939x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
|
ret = wcd939x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
|
dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
|
||||||
@@ -1934,14 +1968,23 @@ static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||||||
|
|
||||||
component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
|
component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
|
||||||
if (!component) {
|
if (!component) {
|
||||||
pr_err("%s could not find component for %s\n",
|
component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
|
||||||
__func__, WCD939X_DRV_NAME);
|
if (!component) {
|
||||||
return -EINVAL;
|
pr_err("%s component is NULL\n", __func__);
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
pdata->wcd_used = WCD937X_DEV_INDEX;
|
||||||
|
} else {
|
||||||
|
pdata->wcd_used = WCD939X_DEV_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
dapm = snd_soc_component_get_dapm(component);
|
dapm = snd_soc_component_get_dapm(component);
|
||||||
card = component->card->snd_card;
|
card = component->card->snd_card;
|
||||||
|
|
||||||
snd_soc_dapm_ignore_suspend(dapm, "EAR");
|
snd_soc_dapm_ignore_suspend(dapm, "EAR");
|
||||||
|
if (pdata->wcd_used != WCD939X_DEV_INDEX)
|
||||||
|
snd_soc_dapm_ignore_suspend(dapm, "AUX");
|
||||||
snd_soc_dapm_ignore_suspend(dapm, "HPHL");
|
snd_soc_dapm_ignore_suspend(dapm, "HPHL");
|
||||||
snd_soc_dapm_ignore_suspend(dapm, "HPHR");
|
snd_soc_dapm_ignore_suspend(dapm, "HPHR");
|
||||||
snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
|
snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
|
||||||
@@ -1961,14 +2004,19 @@ static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||||||
}
|
}
|
||||||
pdata->codec_root = entry;
|
pdata->codec_root = entry;
|
||||||
}
|
}
|
||||||
wcd939x_info_create_codec_entry(pdata->codec_root, component);
|
if (pdata->wcd_used == WCD937X_DEV_INDEX) {
|
||||||
|
wcd937x_info_create_codec_entry(pdata->codec_root, component);
|
||||||
codec_variant = wcd939x_get_codec_variant(component);
|
codec_variant = wcd937x_get_codec_variant(component);
|
||||||
dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
|
dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
|
||||||
if (codec_variant == WCD9395)
|
} else {
|
||||||
ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
|
wcd939x_info_create_codec_entry(pdata->codec_root, component);
|
||||||
else
|
codec_variant = wcd939x_get_codec_variant(component);
|
||||||
ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
|
dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
|
||||||
|
if (codec_variant == WCD9395)
|
||||||
|
ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
|
||||||
|
else
|
||||||
|
ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
|
dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
|
||||||
@@ -1978,7 +2026,7 @@ static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||||||
done:
|
done:
|
||||||
codec_reg_done = true;
|
codec_reg_done = true;
|
||||||
msm_common_dai_link_init(rtd);
|
msm_common_dai_link_init(rtd);
|
||||||
|
exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user