static int msm8960_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; pr_debug("%s()\n", __func__); err = snd_soc_add_controls(codec, tabla_msm8960_controls, ARRAY_SIZE(tabla_msm8960_controls)); if (err < 0) return err; snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets, ARRAY_SIZE(msm8960_dapm_widgets)); snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_enable_pin(dapm, "Ext Spk"); snd_soc_dapm_sync(dapm); err = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } tabla_hs_detect(codec, &hs_jack, &tabla_cal); return 0; }
static int msm8960_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; pr_debug("%s()\n", __func__); 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_controls(codec, tabla_msm8960_controls, ARRAY_SIZE(tabla_msm8960_controls)); if (err < 0) return err; snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets, ARRAY_SIZE(msm8960_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), &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", TABLA_JACK_BUTTON_MASK, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } tabla_hs_detect(codec, &hs_jack, &button_jack, tabla_mbhc_cal, TABLA_MICBIAS2, msm8960_enable_codec_ext_clk, 0, TABLA_EXT_CLK_RATE); return 0; }
static int mdm9615_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_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); rtd->pmdown_time = 0; err = snd_soc_add_controls(codec, tabla_mdm9615_controls, ARRAY_SIZE(tabla_mdm9615_controls)); if (err < 0) return err; snd_soc_dapm_new_controls(dapm, mdm9615_dapm_widgets, ARRAY_SIZE(mdm9615_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), &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", TABLA_JACK_BUTTON_MASK, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } codec_clk = clk_get(cpu_dai->dev, "osr_clk"); tabla_hs_detect(codec, &hs_jack, &button_jack, tabla_mbhc_cal, TABLA_MICBIAS2, mdm9615_enable_codec_ext_clk, 0, TABLA_EXT_CLK_RATE); return 0; }
static int msm8960_audrx_init(struct snd_soc_pcm_runtime *rtd) { int err; #ifdef CONFIG_PANTECH_SND //kdkim #if defined(T_STARQ) || defined(T_OSCAR) || defined(T_EF45K) || defined(T_EF46L) || defined(T_EF47S) int ret = 0; int hw_rev; #endif #endif struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; #ifndef CONFIG_PANTECH_SND //Qualcomm original...kdkim struct pm_gpio jack_gpio_cfg = { .direction = PM_GPIO_DIR_IN, .pull = PM_GPIO_PULL_UP_1P5, .function = PM_GPIO_FUNC_NORMAL, .vin_sel = 2, .inv_int_pol = 0, }; #endif pr_debug("%s()\n", __func__); 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_controls(codec, tabla_msm8960_controls, ARRAY_SIZE(tabla_msm8960_controls)); if (err < 0) return err; snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets, ARRAY_SIZE(msm8960_dapm_widgets)); #ifdef CONFIG_PANTECH_SND if(wcd9310_tablaVersionStatusGet()) //Tabla CS Version snd_soc_dapm_add_routes(dapm, common_cs_audio_map, ARRAY_SIZE(common_cs_audio_map)); else //Tabla ES Version snd_soc_dapm_add_routes(dapm, common_audio_map, ARRAY_SIZE(common_audio_map)); #else //Qualcomm Original Source snd_soc_dapm_add_routes(dapm, common_audio_map, ARRAY_SIZE(common_audio_map)); #endif 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), &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", TABLA_JACK_BUTTON_MASK, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } #ifdef CONFIG_PANTECH_SND //kdkim hw_rev = get_hw_revision(); pr_debug("########### msm8960 hw_rev : %d\n", hw_rev); #if defined(T_STARQ) if(hw_rev < 5) { mbhc_cfg.gpio = 0; mbhc_cfg.gpio_irq = 0; } #elif defined(T_OSCAR) if(hw_rev < 4) { /*revision is checked by elecjang 20120326*/ mbhc_cfg.gpio = 0; mbhc_cfg.gpio_irq = 0; } #elif defined(T_EF47S) || defined(T_EF45K) if(hw_rev < 5) { mbhc_cfg.gpio = 0; mbhc_cfg.gpio_irq = 0; } #elif defined(T_EF46L) if(hw_rev < 4) { mbhc_cfg.gpio = 0; mbhc_cfg.gpio_irq = 0; } #endif #endif #ifdef CONFIG_PANTECH_SND //kdkim #if defined(T_STARQ) || defined(T_OSCAR) || defined(T_EF45K) || defined(T_EF46L) || defined(T_EF47S) if (mbhc_cfg.gpio) { ret = gpio_request(JACK_DETECT_GPIO, "headset_detect"); if(ret){ pr_err("%s: gpio_request failed %d\n", __func__, ret); headset_gpio_config = false; gpio_free(JACK_DETECT_GPIO); } ret = gpio_direction_input(mbhc_cfg.gpio); if(ret){ pr_err("%s: gpio_direction_input failed %d\n", __func__, ret); headset_gpio_config = false; gpio_free(JACK_DETECT_GPIO); } mbhc_cfg.gpio_irq = gpio_to_irq(mbhc_cfg.gpio); } #endif #else //Qualcomm original if (GPIO_DETECT_USED) { mbhc_cfg.gpio = PM8921_GPIO_PM_TO_SYS(JACK_DETECT_GPIO); mbhc_cfg.gpio_irq = JACK_DETECT_INT; } if (mbhc_cfg.gpio) { err = pm8xxx_gpio_config(mbhc_cfg.gpio, &jack_gpio_cfg); if (err) { pr_err("%s: pm8xxx_gpio_config failed %d\n", __func__, err); return err; } } #endif err = tabla_hs_detect(codec, &mbhc_cfg); return err; } static struct snd_soc_dsp_link lpa_fe_media = { .playback = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; static struct snd_soc_dsp_link fe_media = { .playback = true, .capture = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; /* bi-directional media definition for hostless PCM device */ static struct snd_soc_dsp_link bidir_hl_media = { .playback = true, .capture = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; static struct snd_soc_dsp_link hdmi_rx_hl = { .playback = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; static int msm8960_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 = msm8960_slim_0_rx_ch; return 0; } static int msm8960_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 = msm8960_slim_0_tx_ch; return 0; } static int msm8960_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); pr_debug("%s()\n", __func__); rate->min = rate->max = 48000; return 0; } static int msm8960_hdmi_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 channels->min %u channels->max %u ()\n", __func__, channels->min, channels->max); rate->min = rate->max = 48000; return 0; } static int msm8960_btsco_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); rate->min = rate->max = msm8960_btsco_rate; channels->min = channels->max = msm8960_btsco_ch; return 0; } static int msm8960_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 *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); /* PCM only supports mono output with 8khz sample rate */ rate->min = rate->max = 8000; channels->min = channels->max = 1; return 0; } static int msm8960_aux_pcm_get_gpios(void) { int ret = 0; pr_debug("%s\n", __func__); ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", __func__, GPIO_AUX_PCM_DOUT); goto fail_dout; } ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", __func__, GPIO_AUX_PCM_DIN); goto fail_din; } ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", __func__, GPIO_AUX_PCM_SYNC); goto fail_sync; } ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", __func__, GPIO_AUX_PCM_CLK); goto fail_clk; } return 0; fail_clk: gpio_free(GPIO_AUX_PCM_SYNC); fail_sync: gpio_free(GPIO_AUX_PCM_DIN); fail_din: gpio_free(GPIO_AUX_PCM_DOUT); fail_dout: return ret; } static int msm8960_aux_pcm_free_gpios(void) { gpio_free(GPIO_AUX_PCM_DIN); gpio_free(GPIO_AUX_PCM_DOUT); gpio_free(GPIO_AUX_PCM_SYNC); gpio_free(GPIO_AUX_PCM_CLK); return 0; } static int msm8960_startup(struct snd_pcm_substream *substream) { pr_debug("%s(): substream = %s stream = %d\n", __func__, substream->name, substream->stream); return 0; } static int msm8960_auxpcm_startup(struct snd_pcm_substream *substream) { int ret = 0; pr_debug("%s(): substream = %s\n", __func__, substream->name); ret = msm8960_aux_pcm_get_gpios(); if (ret < 0) { pr_err("%s: Aux PCM GPIO request failed\n", __func__); return -EINVAL; } return 0; } static void msm8960_auxpcm_shutdown(struct snd_pcm_substream *substream) { pr_debug("%s(): substream = %s\n", __func__, substream->name); msm8960_aux_pcm_free_gpios(); }
static int msm8960_audrx_init(struct snd_soc_pcm_runtime *rtd) { int err, use_pmic; struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct pm_gpio jack_gpio_cfg = { .direction = PM_GPIO_DIR_IN, .pull = PM_GPIO_PULL_NO, .function = PM_GPIO_FUNC_NORMAL, .vin_sel = 2, .inv_int_pol = 0, }; pr_debug("%s()\n", __func__); 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_controls(codec, tabla_msm8960_controls, ARRAY_SIZE(tabla_msm8960_controls)); if (err < 0) return err; #ifdef CONFIG_INPUT_SIMPLE_REMOTE use_pmic = 1; #else use_pmic = 0; #endif /* CONFIG_INPUT_SIMPLE_REMOTE */ #ifdef CONFIG_INPUT_MBHC_MIC_BIAS_SWITCHING_GPIO use_pmic = msm8960_read_is_pmic_used(); #endif /* CONFIG_INPUT_MBHC_MIC_BIAS_SWITCHING_GPIO */ if (use_pmic) { pr_debug("%s: Enables PMIC.\n", __func__); snd_soc_dapm_new_controls(dapm, blue_msm8960_dapm_widgets, ARRAY_SIZE(blue_msm8960_dapm_widgets)); } else { pr_debug("%s: Does NOT enable PMIC.\n", __func__); snd_soc_dapm_new_controls(dapm, blue_msm8960_dapm_widgets_no_pmic, ARRAY_SIZE(blue_msm8960_dapm_widgets_no_pmic)); } snd_soc_dapm_add_routes(dapm, blue_audio_map, ARRAY_SIZE(blue_audio_map)); snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom"); snd_soc_dapm_enable_pin(dapm, "Ext Spk Top"); snd_soc_dapm_sync(dapm); err = snd_soc_jack_new(codec, "Headset Jack", (SND_JACK_HEADSET | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR), &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", TABLA_JACK_BUTTON_MASK, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } if (hs_detect_use_gpio && !use_pmic) { pr_debug("%s: Using MBHC+GPIO-detect on gpio %d", __func__, JACK_DETECT_GPIO); mbhc_cfg.gpio = PM8921_GPIO_PM_TO_SYS(JACK_DETECT_GPIO); mbhc_cfg.gpio_irq = JACK_DETECT_INT; } else { pr_debug("%s: Does not use MBHC+GPIO-detect", __func__); } if (mbhc_cfg.gpio) { err = pm8xxx_gpio_config(mbhc_cfg.gpio, &jack_gpio_cfg); if (err) { pr_err("%s: pm8xxx_gpio_config failed %d\n", __func__, err); return err; } } #ifdef CONFIG_INPUT_MBHC_HEADSET_CONTROL if (!use_pmic) { mbhc_cfg.read_fw_bin = hs_detect_use_firmware; err = tabla_hs_detect(codec, &mbhc_cfg); } #endif /* CONFIG_INPUT_MBHC_HEADSET_CONTROL */ return err; } static struct snd_soc_dsp_link lpa_fe_media = { .playback = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; static struct snd_soc_dsp_link fe_media = { .playback = true, .capture = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; /* bi-directional media definition for hostless PCM device */ static struct snd_soc_dsp_link bidir_hl_media = { .playback = true, .capture = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; static struct snd_soc_dsp_link hdmi_rx_hl = { .playback = true, .trigger = { SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST }, }; static int msm8960_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 = msm8960_slim_0_rx_ch; return 0; } static int msm8960_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 = msm8960_slim_0_tx_ch; return 0; } static int msm8960_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); pr_debug("%s()\n", __func__); rate->min = rate->max = 48000; return 0; } static int msm8960_hdmi_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 channels->min %u channels->max %u ()\n", __func__, channels->min, channels->max); rate->min = rate->max = 48000; return 0; } static int msm8960_btsco_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); rate->min = rate->max = msm8960_btsco_rate; channels->min = channels->max = msm8960_btsco_ch; return 0; } static int msm8960_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 *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); /* PCM only supports mono output with 8khz sample rate */ rate->min = rate->max = 8000; channels->min = channels->max = 1; return 0; } static int msm8960_aux_pcm_get_gpios(void) { int ret = 0; pr_debug("%s\n", __func__); ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", __func__, GPIO_AUX_PCM_DOUT); goto fail_dout; } ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", __func__, GPIO_AUX_PCM_DIN); goto fail_din; } ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", __func__, GPIO_AUX_PCM_SYNC); goto fail_sync; } ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", __func__, GPIO_AUX_PCM_CLK); goto fail_clk; } return 0; fail_clk: gpio_free(GPIO_AUX_PCM_SYNC); fail_sync: gpio_free(GPIO_AUX_PCM_DIN); fail_din: gpio_free(GPIO_AUX_PCM_DOUT); fail_dout: return ret; } static int msm8960_aux_pcm_free_gpios(void) { gpio_free(GPIO_AUX_PCM_DIN); gpio_free(GPIO_AUX_PCM_DOUT); gpio_free(GPIO_AUX_PCM_SYNC); gpio_free(GPIO_AUX_PCM_CLK); return 0; } static int msm8960_startup(struct snd_pcm_substream *substream) { pr_debug("%s(): substream = %s stream = %d\n", __func__, substream->name, substream->stream); return 0; } static int msm8960_auxpcm_startup(struct snd_pcm_substream *substream) { int ret = 0; pr_debug("%s(): substream = %s\n", __func__, substream->name); ret = msm8960_aux_pcm_get_gpios(); if (ret < 0) { pr_err("%s: Aux PCM GPIO request failed\n", __func__); return -EINVAL; } return 0; } static void msm8960_auxpcm_shutdown(struct snd_pcm_substream *substream) { pr_debug("%s(): substream = %s\n", __func__, substream->name); msm8960_aux_pcm_free_gpios(); }
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; u8 tabla_version; pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); rtd->pmdown_time = 0; if (system_rev == 1) { //XB lower the receiver gain err = snd_soc_add_codec_controls(codec, tabla_xbvol_controls, ARRAY_SIZE(tabla_xbvol_controls)); if (err < 0) return err; } snd_soc_dapm_new_controls(dapm, msm_dapm_widgets, ARRAY_SIZE(msm_dapm_widgets)); snd_soc_dapm_new_controls(dapm, fighter_dapm_widgets, ARRAY_SIZE(fighter_dapm_widgets)); snd_soc_dapm_add_routes(dapm, common_audio_map, ARRAY_SIZE(common_audio_map)); /* determine HW connection based on codec revision */ tabla_version = snd_soc_read(codec, TABLA_A_CHIP_VERSION); tabla_version &= 0x1F; pr_err("%s : Tabla version %u\n", __func__, (u32)tabla_version); if ((tabla_version == TABLA_VERSION_1_0) || (tabla_version == TABLA_VERSION_1_1)) { snd_soc_dapm_add_routes(dapm, tabla_1_x_audio_map, ARRAY_SIZE(tabla_1_x_audio_map)); } else { snd_soc_dapm_add_routes(dapm, tabla_2_x_audio_map, ARRAY_SIZE(tabla_2_x_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), &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", SND_JACK_BTN_0, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } codec_clk = clk_get(cpu_dai->dev, "osr_clk"); /* Do not pass MBHC calibration data to disable HS detection. * Otherwise, sending project-based cal-data to enable * MBHC mechanism that tabla provides */ tabla_hs_detect(codec, &mbhc_cfg); return 0; }
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_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); /*if (machine_is_msm_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_controls(codec, tabla_msm_controls, ARRAY_SIZE(tabla_msm_controls)); if (err < 0) return err; snd_soc_dapm_new_controls(dapm, apq8064_dapm_widgets, ARRAY_SIZE(apq8064_dapm_widgets)); snd_soc_dapm_add_routes(dapm, apq8064_common_audio_map, ARRAY_SIZE(apq8064_common_audio_map)); if (machine_is_apq8064_mtp()) { snd_soc_dapm_add_routes(dapm, apq8064_mtp_audio_map, ARRAY_SIZE(apq8064_mtp_audio_map)); } else { snd_soc_dapm_add_routes(dapm, apq8064_liquid_cdp_audio_map, ARRAY_SIZE(apq8064_liquid_cdp_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), &hs_jack); if (err) { pr_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", TABLA_JACK_BUTTON_MASK, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } codec_clk = clk_get(cpu_dai->dev, "osr_clk"); err = tabla_hs_detect(codec, &mbhc_cfg); return err; }
static int msm8960_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; u8 tabla_version; pr_aud_info("%s()\n", __func__); rtd->pmdown_time = 0; err = snd_soc_add_controls(codec, tabla_msm8960_controls, ARRAY_SIZE(tabla_msm8960_controls)); if (err < 0) return err; snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets, ARRAY_SIZE(msm8960_dapm_widgets)); snd_soc_dapm_new_controls(dapm, fighter_dapm_widgets, ARRAY_SIZE(fighter_dapm_widgets)); snd_soc_dapm_add_routes(dapm, common_audio_map, ARRAY_SIZE(common_audio_map)); /* determine HW connection based on codec revision */ tabla_version = snd_soc_read(codec, TABLA_A_CHIP_VERSION); tabla_version &= 0x1F; pr_aud_info("%s : Tabla version %u\n", __func__, (u32)tabla_version); if ((tabla_version == TABLA_VERSION_1_0) || (tabla_version == TABLA_VERSION_1_1)) { snd_soc_dapm_add_routes(dapm, tabla_1_x_audio_map, ARRAY_SIZE(tabla_1_x_audio_map)); } else { snd_soc_dapm_add_routes(dapm, tabla_2_x_audio_map, ARRAY_SIZE(tabla_2_x_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 USB AMP Pos"); snd_soc_dapm_enable_pin(dapm, "Ext USB AMP 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), &hs_jack); if (err) { pr_aud_err("failed to create new jack\n"); return err; } err = snd_soc_jack_new(codec, "Button Jack", SND_JACK_BTN_0, &button_jack); if (err) { pr_aud_err("failed to create new jack\n"); return err; } /* Do not pass MBHC calibration data to disable HS detection. * Otherwise, sending project-based cal-data to enable * MBHC mechanism that tabla provides */ tabla_hs_detect(codec, &hs_jack, &button_jack, NULL, TABLA_MICBIAS2, msm8960_enable_codec_ext_clk, 0, TABLA_EXT_CLK_RATE); return 0; }
static int msm8960_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; struct pm_gpio jack_gpio_cfg = { .direction = PM_GPIO_DIR_IN, .pull = PM_GPIO_PULL_UP_1P5, .function = PM_GPIO_FUNC_NORMAL, .vin_sel = 2, .inv_int_pol = 0, }; pr_debug("%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)); } snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets, ARRAY_SIZE(msm8960_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", TABLA_JACK_BUTTON_MASK, &button_jack); if (err) { pr_err("failed to create new jack\n"); return err; } codec_clk = clk_get(cpu_dai->dev, "osr_clk"); if (machine_is_msm8960_cdp()) mbhc_cfg.swap_gnd_mic = msm8960_swap_gnd_mic; if (hs_detect_use_gpio) { mbhc_cfg.gpio = PM8921_GPIO_PM_TO_SYS(JACK_DETECT_GPIO); mbhc_cfg.gpio_irq = JACK_DETECT_INT; } if (mbhc_cfg.gpio) { err = pm8xxx_gpio_config(mbhc_cfg.gpio, &jack_gpio_cfg); if (err) { pr_err("%s: pm8xxx_gpio_config JACK_DETECT failed %d\n", __func__, err); return err; } } mbhc_cfg.read_fw_bin = hs_detect_use_firmware; err = tabla_hs_detect(codec, &mbhc_cfg); return err; } static int msm8960_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 = msm8960_slim_0_rx_ch; return 0; } static int msm8960_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 = msm8960_slim_0_tx_ch; return 0; } static int msm8960_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); pr_debug("%s()\n", __func__); rate->min = rate->max = 48000; return 0; } static int msm8960_hdmi_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 channels->min %u channels->max %u ()\n", __func__, channels->min, channels->max); rate->min = rate->max = 48000; return 0; } static int msm8960_btsco_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); rate->min = rate->max = msm8960_btsco_rate; channels->min = channels->max = msm8960_btsco_ch; return 0; } static int msm8960_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 *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); rate->min = rate->max = msm8960_auxpcm_rate; /* PCM only supports mono output */ channels->min = channels->max = 1; return 0; } static int msm8960_proxy_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); pr_debug("%s()\n", __func__); rate->min = rate->max = 48000; return 0; } static int msm8960_aux_pcm_get_gpios(void) { int ret = 0; pr_debug("%s\n", __func__); ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", __func__, GPIO_AUX_PCM_DOUT); goto fail_dout; } ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", __func__, GPIO_AUX_PCM_DIN); goto fail_din; } ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", __func__, GPIO_AUX_PCM_SYNC); goto fail_sync; } ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); if (ret < 0) { pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", __func__, GPIO_AUX_PCM_CLK); goto fail_clk; } return 0; fail_clk: gpio_free(GPIO_AUX_PCM_SYNC); fail_sync: gpio_free(GPIO_AUX_PCM_DIN); fail_din: gpio_free(GPIO_AUX_PCM_DOUT); fail_dout: return ret; }