mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
ASoC: msm8974: register backend DAI link of Taiko codec
Update DAI link to connect slimbus RX/TX port 0 to CPU. Change-Id: Id8aa2ca92ea9b1e0d51b6d3ccf113860a9147c44 Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
This commit is contained in:
parent
a1eb2beb6e
commit
25362f5d3f
1 changed files with 238 additions and 53 deletions
|
@ -26,7 +26,7 @@
|
|||
#include <asm/mach-types.h>
|
||||
#include <mach/socinfo.h>
|
||||
#include <qdsp6v2/msm-pcm-routing-v2.h>
|
||||
#include "../codecs/wcd9310.h"
|
||||
#include "../codecs/wcd9320.h"
|
||||
|
||||
/* 8974 machine driver */
|
||||
|
||||
|
@ -81,21 +81,7 @@ static int msm_headset_gpios_configured;
|
|||
static struct snd_soc_jack hs_jack;
|
||||
static struct snd_soc_jack button_jack;
|
||||
|
||||
static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
|
||||
bool dapm);
|
||||
|
||||
static struct tabla_mbhc_config mbhc_cfg = {
|
||||
.headset_jack = &hs_jack,
|
||||
.button_jack = &button_jack,
|
||||
.read_fw_bin = false,
|
||||
.calibration = NULL,
|
||||
.micbias = TABLA_MICBIAS2,
|
||||
.mclk_cb_fn = msm_enable_codec_ext_clk,
|
||||
.mclk_rate = TABLA_EXT_CLK_RATE,
|
||||
.gpio = 0, /* MBHC GPIO is not configured */
|
||||
.gpio_irq = 0,
|
||||
.gpio_level_insert = 1,
|
||||
};
|
||||
static struct mutex cdc_mclk_mutex;
|
||||
|
||||
static void msm_enable_ext_spk_amp_gpio(u32 spk_amp_gpio)
|
||||
{
|
||||
|
@ -244,6 +230,8 @@ static void msm_ext_control(struct snd_soc_codec *codec)
|
|||
{
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
|
||||
mutex_lock(&dapm->codec->mutex);
|
||||
|
||||
pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control);
|
||||
if (msm_spk_control == MSM8974_SPK_ON) {
|
||||
snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos");
|
||||
|
@ -258,17 +246,19 @@ static void msm_ext_control(struct snd_soc_codec *codec)
|
|||
}
|
||||
|
||||
snd_soc_dapm_sync(dapm);
|
||||
mutex_unlock(&dapm->codec->mutex);
|
||||
}
|
||||
|
||||
static int msm_get_spk(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control);
|
||||
ucontrol->value.integer.value[0] = msm_spk_control;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_set_spk(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
|
||||
|
||||
|
@ -280,8 +270,9 @@ static int msm_set_spk(struct snd_kcontrol *kcontrol,
|
|||
msm_ext_control(codec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int msm_spkramp_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *k, int event)
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event));
|
||||
|
||||
|
@ -318,12 +309,6 @@ static int msm_spkramp_event(struct snd_soc_dapm_widget *w,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
|
||||
bool dapm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_mclk_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
|
@ -453,14 +438,14 @@ static const struct soc_enum msm_enum[] = {
|
|||
|
||||
static const char *const btsco_rate_text[] = {"8000", "16000"};
|
||||
static const struct soc_enum msm_btsco_enum[] = {
|
||||
SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
|
||||
SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
|
||||
};
|
||||
|
||||
static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
|
||||
msm_slim_0_rx_ch);
|
||||
msm_slim_0_rx_ch);
|
||||
ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -471,7 +456,7 @@ static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
|
|||
msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
|
||||
|
||||
pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
|
||||
msm_slim_0_rx_ch);
|
||||
msm_slim_0_rx_ch);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -479,7 +464,7 @@ static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
|
||||
msm_slim_0_tx_ch);
|
||||
msm_slim_0_tx_ch);
|
||||
ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -489,16 +474,14 @@ static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
|
||||
|
||||
pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
|
||||
msm_slim_0_tx_ch);
|
||||
pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, msm_slim_0_tx_ch);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int msm_btsco_rate_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
pr_debug("%s: msm_btsco_rate = %d", __func__,
|
||||
msm_btsco_rate);
|
||||
pr_debug("%s: msm_btsco_rate = %d", __func__, msm_btsco_rate);
|
||||
ucontrol->value.integer.value[0] = msm_btsco_rate;
|
||||
return 0;
|
||||
}
|
||||
|
@ -517,33 +500,23 @@ static int msm_btsco_rate_put(struct snd_kcontrol *kcontrol,
|
|||
msm_btsco_rate = BTSCO_RATE_8KHZ;
|
||||
break;
|
||||
}
|
||||
pr_debug("%s: msm_btsco_rate = %d\n", __func__,
|
||||
msm_btsco_rate);
|
||||
pr_debug("%s: msm_btsco_rate = %d\n", __func__, msm_btsco_rate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new tabla_msm_controls[] = {
|
||||
SOC_ENUM_EXT("Speaker Function", msm_enum[0], msm_get_spk,
|
||||
msm_set_spk),
|
||||
SOC_ENUM_EXT("SLIM_0_RX Channels", msm_enum[1],
|
||||
msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
|
||||
SOC_ENUM_EXT("SLIM_0_TX Channels", msm_enum[2],
|
||||
msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new int_btsco_rate_mixer_controls[] = {
|
||||
SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0],
|
||||
msm_btsco_rate_get, msm_btsco_rate_put),
|
||||
msm_btsco_rate_get, msm_btsco_rate_put),
|
||||
};
|
||||
|
||||
static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_interval *rate = hw_param_interval(params,
|
||||
SNDRV_PCM_HW_PARAM_RATE);
|
||||
struct snd_interval *rate =
|
||||
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
|
||||
|
||||
struct snd_interval *channels = hw_param_interval(params,
|
||||
SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||
struct snd_interval *channels =
|
||||
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||
|
||||
/* PCM only supports mono output with 8khz sample rate */
|
||||
rate->min = rate->max = 8000;
|
||||
|
@ -629,6 +602,193 @@ static struct snd_soc_ops msm_auxpcm_be_ops = {
|
|||
.startup = msm_auxpcm_startup,
|
||||
.shutdown = msm_auxpcm_shutdown,
|
||||
};
|
||||
|
||||
static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_interval *rate = hw_param_interval(params,
|
||||
SNDRV_PCM_HW_PARAM_RATE);
|
||||
|
||||
struct snd_interval *channels =
|
||||
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||
|
||||
pr_debug("%s()\n", __func__);
|
||||
rate->min = rate->max = 48000;
|
||||
channels->min = channels->max = msm_slim_0_rx_ch;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_interval *rate = hw_param_interval(params,
|
||||
SNDRV_PCM_HW_PARAM_RATE);
|
||||
|
||||
struct snd_interval *channels = hw_param_interval(params,
|
||||
SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||
|
||||
pr_debug("%s()\n", __func__);
|
||||
rate->min = rate->max = 48000;
|
||||
channels->min = channels->max = msm_slim_0_tx_ch;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct soc_enum msm_snd_enum[] = {
|
||||
SOC_ENUM_SINGLE_EXT(2, spk_function),
|
||||
SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
|
||||
SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new msm_snd_controls[] = {
|
||||
SOC_ENUM_EXT("Speaker Function", msm_snd_enum[0], msm_get_spk,
|
||||
msm_set_spk),
|
||||
SOC_ENUM_EXT("SLIM_0_RX Channels", msm_snd_enum[1],
|
||||
msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
|
||||
SOC_ENUM_EXT("SLIM_0_TX Channels", msm_snd_enum[2],
|
||||
msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
|
||||
};
|
||||
|
||||
static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
int err;
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
|
||||
pr_info("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev));
|
||||
|
||||
if (machine_is_msm8960_liquid()) {
|
||||
top_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(19));
|
||||
bottom_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(18));
|
||||
}
|
||||
|
||||
rtd->pmdown_time = 0;
|
||||
|
||||
err = snd_soc_add_codec_controls(codec, msm_snd_controls,
|
||||
ARRAY_SIZE(msm_snd_controls));
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
|
||||
ARRAY_SIZE(msm_dapm_widgets));
|
||||
|
||||
snd_soc_dapm_add_routes(dapm, common_audio_map,
|
||||
ARRAY_SIZE(common_audio_map));
|
||||
|
||||
snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos");
|
||||
snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg");
|
||||
snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos");
|
||||
snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg");
|
||||
|
||||
snd_soc_dapm_sync(dapm);
|
||||
|
||||
err = snd_soc_jack_new(codec, "Headset Jack",
|
||||
(SND_JACK_HEADSET | SND_JACK_OC_HPHL |
|
||||
SND_JACK_OC_HPHR | SND_JACK_UNSUPPORTED),
|
||||
&hs_jack);
|
||||
if (err) {
|
||||
pr_err("failed to create new jack\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = snd_soc_jack_new(codec, "Button Jack",
|
||||
TAIKO_JACK_BUTTON_MASK, &button_jack);
|
||||
if (err) {
|
||||
pr_err("failed to create new jack\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int msm_snd_startup(struct snd_pcm_substream *substream)
|
||||
{
|
||||
pr_debug("%s(): substream = %s stream = %d\n", __func__,
|
||||
substream->name, substream->stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_snd_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
int ret = 0;
|
||||
unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
|
||||
unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
|
||||
unsigned int user_set_tx_ch = 0;
|
||||
|
||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||
pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch);
|
||||
ret = snd_soc_dai_get_channel_map(codec_dai,
|
||||
&tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to get codec chan map\n", __func__);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
|
||||
msm_slim_0_rx_ch, rx_ch);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to set cpu chan map\n", __func__);
|
||||
goto end;
|
||||
}
|
||||
ret = snd_soc_dai_set_channel_map(codec_dai, 0, 0,
|
||||
msm_slim_0_rx_ch, rx_ch);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to set codec channel map\n",
|
||||
__func__);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (codec_dai->id == 2)
|
||||
user_set_tx_ch = msm_slim_0_tx_ch;
|
||||
else if (codec_dai->id == 4)
|
||||
user_set_tx_ch = params_channels(params);
|
||||
|
||||
pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
|
||||
codec_dai->name, codec_dai->id, user_set_tx_ch);
|
||||
|
||||
ret = snd_soc_dai_get_channel_map(codec_dai,
|
||||
&tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to get codec chan map\n", __func__);
|
||||
goto end;
|
||||
}
|
||||
ret = snd_soc_dai_set_channel_map(cpu_dai,
|
||||
user_set_tx_ch, tx_ch, 0 , 0);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to set cpu chan map\n", __func__);
|
||||
goto end;
|
||||
}
|
||||
ret = snd_soc_dai_set_channel_map(codec_dai,
|
||||
user_set_tx_ch, tx_ch, 0, 0);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to set codec channel map\n",
|
||||
__func__);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void msm_snd_shutdown(struct snd_pcm_substream *substream)
|
||||
{
|
||||
pr_debug("%s(): substream = %s stream = %d\n", __func__,
|
||||
substream->name, substream->stream);
|
||||
}
|
||||
|
||||
static struct snd_soc_ops msm8974_be_ops = {
|
||||
.startup = msm_snd_startup,
|
||||
.hw_params = msm_snd_hw_params,
|
||||
.shutdown = msm_snd_shutdown,
|
||||
};
|
||||
|
||||
/* Digital audio interface glue - connects codec <---> CPU */
|
||||
static struct snd_soc_dai_link msm_dai[] = {
|
||||
/* FrontEnd DAI Links */
|
||||
|
@ -734,7 +894,33 @@ static struct snd_soc_dai_link msm_dai[] = {
|
|||
.be_id = MSM_BACKEND_DAI_AUXPCM_TX,
|
||||
.be_hw_params_fixup = msm_auxpcm_be_params_fixup,
|
||||
},
|
||||
|
||||
/* Backend DAI Links */
|
||||
{
|
||||
.name = LPASS_BE_SLIMBUS_0_RX,
|
||||
.stream_name = "Slimbus Playback",
|
||||
.cpu_dai_name = "msm-dai-q6-dev.16384",
|
||||
.platform_name = "msm-pcm-routing",
|
||||
.codec_name = "taiko_codec",
|
||||
.codec_dai_name = "taiko_rx1",
|
||||
.no_pcm = 1,
|
||||
.be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
|
||||
.init = &msm_audrx_init,
|
||||
.be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
|
||||
.ops = &msm8974_be_ops,
|
||||
.ignore_pmdown_time = 1, /* dai link has playback support */
|
||||
},
|
||||
{
|
||||
.name = LPASS_BE_SLIMBUS_0_TX,
|
||||
.stream_name = "Slimbus Capture",
|
||||
.cpu_dai_name = "msm-dai-q6-dev.16385",
|
||||
.platform_name = "msm-pcm-routing",
|
||||
.codec_name = "taiko_codec",
|
||||
.codec_dai_name = "taiko_tx1",
|
||||
.no_pcm = 1,
|
||||
.be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
|
||||
.be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
|
||||
.ops = &msm8974_be_ops,
|
||||
},
|
||||
};
|
||||
|
||||
struct snd_soc_card snd_soc_card_msm = {
|
||||
|
@ -756,6 +942,8 @@ static void msm_free_headset_mic_gpios(void)
|
|||
static int __init msm_audio_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mutex_init(&cdc_mclk_mutex);
|
||||
if (!machine_is_msm8974_sim()) {
|
||||
pr_err("%s: Not the right machine type\n", __func__);
|
||||
return -ENODEV;
|
||||
|
@ -763,7 +951,6 @@ static int __init msm_audio_init(void)
|
|||
msm_snd_device = platform_device_alloc("soc-audio", 0);
|
||||
if (!msm_snd_device) {
|
||||
pr_err("Platform device allocation failed\n");
|
||||
kfree(mbhc_cfg.calibration);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -771,7 +958,6 @@ static int __init msm_audio_init(void)
|
|||
ret = platform_device_add(msm_snd_device);
|
||||
if (ret) {
|
||||
platform_device_put(msm_snd_device);
|
||||
kfree(mbhc_cfg.calibration);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
|
@ -787,7 +973,6 @@ static void __exit msm_audio_exit(void)
|
|||
}
|
||||
msm_free_headset_mic_gpios();
|
||||
platform_device_unregister(msm_snd_device);
|
||||
kfree(mbhc_cfg.calibration);
|
||||
}
|
||||
module_exit(msm_audio_exit);
|
||||
|
||||
|
|
Loading…
Reference in a new issue