static int tegra_pcm_probe(struct snd_soc_platform *platform) { if(machine_is_kai() || machine_is_tegra_enterprise() || machine_is_cardhu()) platform->dapm.idle_bias_off = 1; return 0; }
static int __init cardhu_charger_late_init(void) { if (!machine_is_cardhu()) return 0; platform_device_register(&cardhu_charger_device); return 0; }
static int spdif_dit_probe(struct platform_device *pdev) { if (machine_is_kai() || machine_is_tegra_enterprise() || machine_is_cardhu() || machine_is_tai()) return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit1, &dit_stub_dai, 1); else return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit, &dit_stub_dai, 1); }
static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = codec->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); struct tegra_wm8903_platform_data *pdata = machine->pdata; int ret; machine->bias_level = SND_SOC_BIAS_STANDBY; if (machine_is_cardhu() || machine_is_ventana()) { ret = snd_soc_add_controls(codec, cardhu_controls, ARRAY_SIZE(cardhu_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets, ARRAY_SIZE(cardhu_dapm_widgets)); } else { ret = snd_soc_add_controls(codec, tegra_wm8903_default_controls, ARRAY_SIZE(tegra_wm8903_default_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, tegra_wm8903_default_dapm_widgets, ARRAY_SIZE(tegra_wm8903_default_dapm_widgets)); } snd_soc_dapm_add_routes(dapm, cardhu_audio_map, ARRAY_SIZE(cardhu_audio_map)); /* FIXME: Calculate automatically based on DAPM routes? */ snd_soc_dapm_nc_pin(dapm, "IN1R"); snd_soc_dapm_nc_pin(dapm, "IN2R"); snd_soc_dapm_nc_pin(dapm, "IN3L"); snd_soc_dapm_nc_pin(dapm, "IN3R"); snd_soc_dapm_nc_pin(dapm, "LINEOUTL"); snd_soc_dapm_nc_pin(dapm, "LINEOUTR"); snd_soc_dapm_disable_pin(dapm, "Int Mic"); snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin(dapm, "Int Spk"); snd_soc_dapm_enable_pin(dapm, "AUX"); snd_soc_dapm_sync(dapm); return 0; }
static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = codec->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); struct tegra_asoc_platform_data *pdata = machine->pdata; machine->bias_level = SND_SOC_BIAS_STANDBY; if (gpio_is_valid(pdata->gpio_hp_det)) { tegra_wm8903_hp_jack_gpio.gpio = pdata->gpio_hp_det; snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack); #ifndef CONFIG_SWITCH snd_soc_jack_add_pins(&tegra_wm8903_hp_jack, ARRAY_SIZE(tegra_wm8903_hp_jack_pins), tegra_wm8903_hp_jack_pins); #else snd_soc_jack_notifier_register(&tegra_wm8903_hp_jack, &tegra_wm8903_jack_detect_nb); #endif snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, 1, &tegra_wm8903_hp_jack_gpio); } snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, &tegra_wm8903_mic_jack); #ifndef CONFIG_SWITCH snd_soc_jack_add_pins(&tegra_wm8903_mic_jack, ARRAY_SIZE(tegra_wm8903_mic_jack_pins), tegra_wm8903_mic_jack_pins); #else snd_soc_jack_notifier_register(&tegra_wm8903_mic_jack, &tegra_wm8903_jack_detect_nb); #endif wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, machine_is_cardhu() ? SND_JACK_MICROPHONE : 0); ret = tegra_asoc_utils_register_ctls(&machine->util_data); if (ret < 0) return ret; snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); return 0; }
static int tegra_rt5631_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = codec->card; struct tegra_rt5631 *machine = snd_soc_card_get_drvdata(card); int ret; printk("%s+\n", __func__); if (machine_is_cardhu() || machine_is_ventana()) { ret = snd_soc_add_controls(codec, cardhu_controls, ARRAY_SIZE(cardhu_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets, ARRAY_SIZE(cardhu_dapm_widgets)); } else { ret = snd_soc_add_controls(codec, tegra_rt5631_default_controls, ARRAY_SIZE(tegra_rt5631_default_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, tegra_rt5631_default_dapm_widgets, ARRAY_SIZE(tegra_rt5631_default_dapm_widgets)); } snd_soc_dapm_add_routes(dapm, cardhu_audio_map, ARRAY_SIZE(cardhu_audio_map)); snd_soc_dapm_nc_pin(dapm, "MIC2"); snd_soc_dapm_nc_pin(dapm, "AXIL"); snd_soc_dapm_nc_pin(dapm, "AXIR"); snd_soc_dapm_nc_pin(dapm, "MONOIN_RXN"); snd_soc_dapm_nc_pin(dapm, "MONOIN_RXP"); snd_soc_dapm_nc_pin(dapm, "MONO"); snd_soc_dapm_disable_pin(dapm, "Int Mic"); snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin(dapm, "Int Spk"); snd_soc_dapm_disable_pin(dapm, "AUX"); snd_soc_dapm_sync(dapm); return 0; }
static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev) { struct snd_soc_card *card = &snd_soc_tegra_wm8903; struct tegra_wm8903 *machine; struct tegra_wm8903_platform_data *pdata; int ret; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data supplied\n"); return -EINVAL; } machine = kzalloc(sizeof(struct tegra_wm8903), GFP_KERNEL); if (!machine) { dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n"); return -ENOMEM; } machine->pdata = pdata; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); if (ret) goto err_free_machine; machine->spk_reg = regulator_get(&pdev->dev, "vdd_spk_amp"); if (IS_ERR(machine->spk_reg)) { dev_info(&pdev->dev, "No speaker regulator found\n"); machine->spk_reg = 0; } machine->dmic_reg = regulator_get(&pdev->dev, "vdd_dmic"); if (IS_ERR(machine->dmic_reg)) { dev_info(&pdev->dev, "No digital mic regulator found\n"); machine->dmic_reg = 0; } if (machine_is_cardhu()) { tegra_wm8903_dai[0].codec_name = "wm8903.4-001a", tegra_wm8903_dai[0].cpu_dai_name = "tegra30-i2s.1"; tegra_wm8903_dai[1].cpu_dai_name = "tegra30-spdif"; } #ifdef CONFIG_SWITCH /* Addd h2w swith class support */ ret = switch_dev_register(&tegra_wm8903_headset_switch); if (ret < 0) goto err_fini_utils; #endif card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_switch; } return 0; err_unregister_switch: #ifdef CONFIG_SWITCH switch_dev_unregister(&tegra_wm8903_headset_switch); #endif err_fini_utils: tegra_asoc_utils_fini(&machine->util_data); err_free_machine: kfree(machine); return ret; }
static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = codec->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); struct tegra_wm8903_platform_data *pdata = machine->pdata; int ret; if (gpio_is_valid(pdata->gpio_spkr_en)) { ret = gpio_request(pdata->gpio_spkr_en, "spkr_en"); if (ret) { dev_err(card->dev, "cannot get spkr_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_SPKR_EN; gpio_direction_output(pdata->gpio_spkr_en, 0); } if (gpio_is_valid(pdata->gpio_hp_mute)) { ret = gpio_request(pdata->gpio_hp_mute, "hp_mute"); if (ret) { dev_err(card->dev, "cannot get hp_mute gpio\n"); return ret; } machine->gpio_requested |= GPIO_HP_MUTE; gpio_direction_output(pdata->gpio_hp_mute, 0); } if (gpio_is_valid(pdata->gpio_int_mic_en)) { ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en"); if (ret) { dev_err(card->dev, "cannot get int_mic_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_INT_MIC_EN; /* Disable int mic; enable signal is active-high */ gpio_direction_output(pdata->gpio_int_mic_en, 0); } if (gpio_is_valid(pdata->gpio_ext_mic_en)) { ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en"); if (ret) { dev_err(card->dev, "cannot get ext_mic_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_EXT_MIC_EN; /* Enable ext mic; enable signal is active-low */ gpio_direction_output(pdata->gpio_ext_mic_en, 0); } if (machine_is_cardhu() || machine_is_ventana()) { ret = snd_soc_add_controls(codec, cardhu_controls, ARRAY_SIZE(cardhu_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets, ARRAY_SIZE(cardhu_dapm_widgets)); } else { ret = snd_soc_add_controls(codec, tegra_wm8903_default_controls, ARRAY_SIZE(tegra_wm8903_default_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, tegra_wm8903_default_dapm_widgets, ARRAY_SIZE(tegra_wm8903_default_dapm_widgets)); } if (machine_is_harmony()) { snd_soc_dapm_add_routes(dapm, harmony_audio_map, ARRAY_SIZE(harmony_audio_map)); } else if (machine_is_cardhu() || machine_is_ventana()) { snd_soc_dapm_add_routes(dapm, cardhu_audio_map, ARRAY_SIZE(cardhu_audio_map)); } else if (machine_is_seaboard()) { snd_soc_dapm_add_routes(dapm, seaboard_audio_map, ARRAY_SIZE(seaboard_audio_map)); } else if (machine_is_kaen()) { snd_soc_dapm_add_routes(dapm, kaen_audio_map, ARRAY_SIZE(kaen_audio_map)); } else { snd_soc_dapm_add_routes(dapm, aebl_audio_map, ARRAY_SIZE(aebl_audio_map)); } if (gpio_is_valid(pdata->gpio_hp_det)) { tegra_wm8903_hp_jack_gpio.gpio = pdata->gpio_hp_det; snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack); #ifndef CONFIG_SWITCH snd_soc_jack_add_pins(&tegra_wm8903_hp_jack, ARRAY_SIZE(tegra_wm8903_hp_jack_pins), tegra_wm8903_hp_jack_pins); #else snd_soc_jack_notifier_register(&tegra_wm8903_hp_jack, &tegra_wm8903_jack_detect_nb); #endif snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, 1, &tegra_wm8903_hp_jack_gpio); machine->gpio_requested |= GPIO_HP_DET; } snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, &tegra_wm8903_mic_jack); #ifndef CONFIG_SWITCH snd_soc_jack_add_pins(&tegra_wm8903_mic_jack, ARRAY_SIZE(tegra_wm8903_mic_jack_pins), tegra_wm8903_mic_jack_pins); #else snd_soc_jack_notifier_register(&tegra_wm8903_mic_jack, &tegra_wm8903_jack_detect_nb); #endif wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, 0); snd_soc_dapm_force_enable_pin(dapm, "Mic Bias"); /* FIXME: Calculate automatically based on DAPM routes? */ if (!machine_is_harmony() && !machine_is_ventana() && !machine_is_cardhu()) snd_soc_dapm_nc_pin(dapm, "IN1L"); if (!machine_is_seaboard() && !machine_is_aebl() && !machine_is_cardhu()) snd_soc_dapm_nc_pin(dapm, "IN1R"); snd_soc_dapm_nc_pin(dapm, "IN2L"); if (!machine_is_kaen()) snd_soc_dapm_nc_pin(dapm, "IN2R"); snd_soc_dapm_nc_pin(dapm, "IN3L"); snd_soc_dapm_nc_pin(dapm, "IN3R"); if (machine_is_aebl()) { snd_soc_dapm_nc_pin(dapm, "LON"); snd_soc_dapm_nc_pin(dapm, "RON"); snd_soc_dapm_nc_pin(dapm, "ROP"); snd_soc_dapm_nc_pin(dapm, "LOP"); } else { snd_soc_dapm_nc_pin(dapm, "LINEOUTR"); snd_soc_dapm_nc_pin(dapm, "LINEOUTL"); } snd_soc_dapm_sync(dapm); return 0; }
static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = codec->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); struct tegra_wm8903_platform_data *pdata = machine->pdata; int ret; machine->bias_level = SND_SOC_BIAS_STANDBY; if (gpio_is_valid(pdata->gpio_spkr_en)) { ret = gpio_request(pdata->gpio_spkr_en, "spkr_en"); if (ret) { dev_err(card->dev, "cannot get spkr_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_SPKR_EN; gpio_direction_output(pdata->gpio_spkr_en, 0); } if (gpio_is_valid(pdata->gpio_hp_mute)) { ret = gpio_request(pdata->gpio_hp_mute, "hp_mute"); if (ret) { dev_err(card->dev, "cannot get hp_mute gpio\n"); return ret; } machine->gpio_requested |= GPIO_HP_MUTE; gpio_direction_output(pdata->gpio_hp_mute, 0); } if (gpio_is_valid(pdata->gpio_int_mic_en)) { ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en"); if (ret) { dev_err(card->dev, "cannot get int_mic_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_INT_MIC_EN; /* Disable int mic; enable signal is active-high */ gpio_direction_output(pdata->gpio_int_mic_en, 0); } if (gpio_is_valid(pdata->gpio_ext_mic_en)) { ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en"); if (ret) { dev_err(card->dev, "cannot get ext_mic_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_EXT_MIC_EN; /* Enable ext mic; enable signal is active-low */ gpio_direction_output(pdata->gpio_ext_mic_en, 0); } #if defined(CONFIG_ARCH_ACER_T30) /* bypass switch enable gpio */ if (gpio_is_valid(pdata->gpio_bypass_switch_en)) { tegra_gpio_enable(pdata->gpio_bypass_switch_en); ret = gpio_request(pdata->gpio_bypass_switch_en, "bypass_switch_en"); if (ret) { dev_err(card->dev, "cannot get bypass_switch_en gpio\n"); return ret; } machine->gpio_requested |= GPIO_BYBASS_EN; /* Enable bypass switch; enable signal is active-high */ gpio_direction_output(pdata->gpio_bypass_switch_en, 0); } #endif #if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30) ret = snd_soc_add_controls(codec, cardhu_controls, ARRAY_SIZE(cardhu_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets, ARRAY_SIZE(cardhu_dapm_widgets)); snd_soc_dapm_add_routes(dapm, cardhu_audio_map, ARRAY_SIZE(cardhu_audio_map)); #else if (machine_is_cardhu() || machine_is_ventana()) { ret = snd_soc_add_controls(codec, cardhu_controls, ARRAY_SIZE(cardhu_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets, ARRAY_SIZE(cardhu_dapm_widgets)); } else { ret = snd_soc_add_controls(codec, tegra_wm8903_default_controls, ARRAY_SIZE(tegra_wm8903_default_controls)); if (ret < 0) return ret; snd_soc_dapm_new_controls(dapm, tegra_wm8903_default_dapm_widgets, ARRAY_SIZE(tegra_wm8903_default_dapm_widgets)); } if (machine_is_harmony()) { snd_soc_dapm_add_routes(dapm, harmony_audio_map, ARRAY_SIZE(harmony_audio_map)); } else if (machine_is_cardhu() || machine_is_ventana()) { snd_soc_dapm_add_routes(dapm, cardhu_audio_map, ARRAY_SIZE(cardhu_audio_map)); } else if (machine_is_seaboard()) { snd_soc_dapm_add_routes(dapm, seaboard_audio_map, ARRAY_SIZE(seaboard_audio_map)); } else if (machine_is_kaen()) { snd_soc_dapm_add_routes(dapm, kaen_audio_map, ARRAY_SIZE(kaen_audio_map)); } else { snd_soc_dapm_add_routes(dapm, aebl_audio_map, ARRAY_SIZE(aebl_audio_map)); } #endif #if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30) audio_data.gpio.debug_en = pdata->gpio_debug_switch_en; /* if debug on, will not enable headset */ if (gpio_is_valid(pdata->gpio_hp_det) && !is_debug_on()) { pr_info("[Audio]register headphone jack\n"); audio_data.gpio.hp_det = pdata->gpio_hp_det; #else if (gpio_is_valid(pdata->gpio_hp_det)) { #endif tegra_wm8903_hp_jack_gpio.gpio = pdata->gpio_hp_det; snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack); #ifndef CONFIG_SWITCH snd_soc_jack_add_pins(&tegra_wm8903_hp_jack, ARRAY_SIZE(tegra_wm8903_hp_jack_pins), tegra_wm8903_hp_jack_pins); #else snd_soc_jack_notifier_register(&tegra_wm8903_hp_jack, &tegra_wm8903_jack_detect_nb); #endif snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, 1, &tegra_wm8903_hp_jack_gpio); machine->gpio_requested |= GPIO_HP_DET; } snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, &tegra_wm8903_mic_jack); #if !defined(CONFIG_ARCH_ACER_T20) && !defined(CONFIG_ARCH_ACER_T30) #ifndef CONFIG_SWITCH snd_soc_jack_add_pins(&tegra_wm8903_mic_jack, ARRAY_SIZE(tegra_wm8903_mic_jack_pins), tegra_wm8903_mic_jack_pins); #else snd_soc_jack_notifier_register(&tegra_wm8903_mic_jack, &tegra_wm8903_jack_detect_nb); #endif #endif wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, machine_is_cardhu() ? SND_JACK_MICROPHONE : 0); snd_soc_dapm_force_enable_pin(dapm, "Mic Bias"); /* Disable Spk,Headphone,Line Out when wm8903 init */ #if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30) snd_soc_dapm_disable_pin(dapm, "Int Spk"); snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin(dapm, "LineOut"); snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin(dapm, "Int Mic"); #if !defined(CONFIG_ARCH_ACER_T30) snd_soc_dapm_disable_pin(dapm, "LineIn"); #endif audio_data.codec = codec; audio_data.gpio.spkr_en = pdata->gpio_spkr_en; audio_data.gpio.int_mic_en = pdata->gpio_int_mic_en; audio_data.gpio.bypass_en = pdata->gpio_bypass_switch_en; #else /* FIXME: Calculate automatically based on DAPM routes? */ if (!machine_is_harmony() && !machine_is_ventana() && !machine_is_cardhu()) snd_soc_dapm_nc_pin(dapm, "IN1L"); if (!machine_is_seaboard() && !machine_is_aebl() && !machine_is_cardhu()) snd_soc_dapm_nc_pin(dapm, "IN1R"); snd_soc_dapm_nc_pin(dapm, "IN2L"); if (!machine_is_kaen()) snd_soc_dapm_nc_pin(dapm, "IN2R"); snd_soc_dapm_nc_pin(dapm, "IN3L"); snd_soc_dapm_nc_pin(dapm, "IN3R"); if (machine_is_aebl()) { snd_soc_dapm_nc_pin(dapm, "LON"); snd_soc_dapm_nc_pin(dapm, "RON"); snd_soc_dapm_nc_pin(dapm, "ROP"); snd_soc_dapm_nc_pin(dapm, "LOP"); } else { snd_soc_dapm_nc_pin(dapm, "LINEOUTR"); snd_soc_dapm_nc_pin(dapm, "LINEOUTL"); } #endif snd_soc_dapm_sync(dapm); return 0; } static int tegra30_soc_set_bias_level(struct snd_soc_card *card, enum snd_soc_bias_level level) { struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); if (machine->bias_level == SND_SOC_BIAS_OFF && level != SND_SOC_BIAS_OFF) tegra_asoc_utils_clk_enable(&machine->util_data); return 0; } static int tegra30_soc_set_bias_level_post(struct snd_soc_card *card, enum snd_soc_bias_level level) { struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); if (machine->bias_level != SND_SOC_BIAS_OFF && level == SND_SOC_BIAS_OFF) tegra_asoc_utils_clk_disable(&machine->util_data); machine->bias_level = level; return 0 ; } static struct snd_soc_dai_link tegra_wm8903_dai[] = { { .name = "WM8903", .stream_name = "WM8903 PCM", .codec_name = "wm8903.0-001a", .platform_name = "tegra-pcm-audio", .cpu_dai_name = "tegra20-i2s.0", .codec_dai_name = "wm8903-hifi", .init = tegra_wm8903_init, .ops = &tegra_wm8903_ops, }, { .name = "SPDIF",
static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev) { struct snd_soc_card *card = &snd_soc_tegra_wm8903; struct tegra_wm8903 *machine; struct tegra_wm8903_platform_data *pdata; int ret; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data supplied\n"); return -EINVAL; } machine = kzalloc(sizeof(struct tegra_wm8903), GFP_KERNEL); if (!machine) { dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n"); return -ENOMEM; } machine->pdata = pdata; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev, card); if (ret) goto err_free_machine; if (machine_is_cardhu() || machine_is_ventana()) { machine->spk_reg = regulator_get(&pdev->dev, "vdd_spk_amp"); if (IS_ERR(machine->spk_reg)) { dev_info(&pdev->dev, "No speaker regulator found\n"); machine->spk_reg = 0; } } if (machine_is_ventana()) { machine->dmic_reg = regulator_get(&pdev->dev, "vdd_dmic"); if (IS_ERR(machine->dmic_reg)) { dev_info(&pdev->dev, "No digital mic" " regulator found\n"); machine->dmic_reg = 0; } } if (machine_is_cardhu()) { tegra_wm8903_dai[0].codec_name = "wm8903.4-001a", tegra_wm8903_dai[0].cpu_dai_name = "tegra30-i2s.1"; tegra_wm8903_dai[1].cpu_dai_name = "tegra30-spdif"; tegra_wm8903_dai[2].cpu_dai_name = "tegra30-i2s.3"; } #ifdef CONFIG_SWITCH /* Addd h2w swith class support */ ret = switch_dev_register(&tegra_wm8903_headset_switch); if (ret < 0) goto err_fini_utils; #endif card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); if (machine_is_cardhu() || machine_is_ventana()) { card->controls = cardhu_controls; card->num_controls = ARRAY_SIZE(cardhu_controls); card->dapm_widgets = cardhu_dapm_widgets; card->num_dapm_widgets = ARRAY_SIZE(cardhu_dapm_widgets); } else { card->controls = tegra_wm8903_default_controls; card->num_controls = ARRAY_SIZE(tegra_wm8903_default_controls); card->dapm_widgets = tegra_wm8903_default_dapm_widgets; card->num_dapm_widgets = ARRAY_SIZE(tegra_wm8903_default_dapm_widgets); } if (machine_is_harmony()) { card->dapm_routes = harmony_audio_map; card->num_dapm_routes = ARRAY_SIZE(harmony_audio_map); } else if (machine_is_ventana() || machine_is_cardhu()) { card->dapm_routes = cardhu_audio_map; card->num_dapm_routes = ARRAY_SIZE(cardhu_audio_map); } else if (machine_is_seaboard()) { card->dapm_routes = seaboard_audio_map; card->num_dapm_routes = ARRAY_SIZE(seaboard_audio_map); } else if (machine_is_kaen()) { card->dapm_routes = kaen_audio_map; card->num_dapm_routes = ARRAY_SIZE(kaen_audio_map); } else { card->dapm_routes = aebl_audio_map; card->num_dapm_routes = ARRAY_SIZE(aebl_audio_map); } ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_switch; } if (!card->instantiated) { ret = -ENODEV; dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_card; } return 0; err_unregister_card: snd_soc_unregister_card(card); err_unregister_switch: #ifdef CONFIG_SWITCH switch_dev_unregister(&tegra_wm8903_headset_switch); #endif err_fini_utils: tegra_asoc_utils_fini(&machine->util_data); err_free_machine: kfree(machine); return ret; }
static int tegra_wm8903_driver_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct snd_soc_card *card = &snd_soc_tegra_wm8903; struct tegra_wm8903 *machine; struct tegra_asoc_platform_data *pdata = pdev->dev.platform_data; int ret; if (!pdata && !pdev->dev.of_node) { dev_err(&pdev->dev, "No platform data supplied\n"); return -EINVAL; } machine = devm_kzalloc(&pdev->dev, sizeof(struct tegra_wm8903), GFP_KERNEL); if (!machine) { dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n"); ret = -ENOMEM; goto err; } pdata = &machine->pdata; machine->pdata = pdata; if (machine_is_cardhu() || machine_is_ventana()) { machine->spk_reg = regulator_get(&pdev->dev, "vdd_spk_amp"); if (IS_ERR(machine->spk_reg)) { dev_info(&pdev->dev, "No speaker regulator found\n"); machine->spk_reg = 0; } } if (machine_is_ventana()) { machine->dmic_reg = regulator_get(&pdev->dev, "vdd_dmic"); if (IS_ERR(machine->dmic_reg)) { dev_info(&pdev->dev, "No digital mic" " regulator found\n"); machine->dmic_reg = 0; } } if (machine_is_cardhu()) { tegra_wm8903_dai[0].codec_name = "wm8903.4-001a", tegra_wm8903_dai[0].cpu_dai_name = "tegra30-i2s.1"; tegra_wm8903_dai[1].cpu_dai_name = "tegra30-spdif"; tegra_wm8903_dai[2].cpu_dai_name = "tegra30-i2s.3"; } if (machine_is_curacao() || machine_is_dolak()) { tegra_wm8903_dai[0].codec_name = "wm8903.0-001a"; tegra_wm8903_dai[0].cpu_dai_name = "tegra30-i2s.0"; } #ifdef CONFIG_SWITCH /* Addd h2w swith class support */ ret = tegra_asoc_switch_register(&tegra_wm8903_headset_switch); if (ret < 0) goto err_fini_utils; #endif card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); if (pdev->dev.platform_data) { memcpy(pdata, card->dev->platform_data, sizeof(*pdata)); } else if (np) { pdata = devm_kzalloc(&pdev->dev, sizeof(struct tegra_asoc_platform_data), GFP_KERNEL); if (!pdata) { dev_err(&pdev->dev, "no memory for tegra_asoc_platform_data\n"); ret = -ENOMEM; goto err; } pdata->gpio_spkr_en = of_get_named_gpio(np, "nvidia,spkr-en-gpios", 0); if (pdata->gpio_spkr_en == -EPROBE_DEFER) return -EPROBE_DEFER; pdata->gpio_hp_mute = of_get_named_gpio(np, "nvidia,hp-mute-gpios", 0); if (pdata->gpio_hp_mute == -EPROBE_DEFER) return -EPROBE_DEFER; pdata->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); if (pdata->gpio_hp_det == -EPROBE_DEFER) return -EPROBE_DEFER; pdata->gpio_int_mic_en = of_get_named_gpio(np, "nvidia,int-mic-en-gpios", 0); if (pdata->gpio_int_mic_en == -EPROBE_DEFER) return -EPROBE_DEFER; pdata->gpio_ext_mic_en = of_get_named_gpio(np, "nvidia,ext-mic-en-gpios", 0); if (pdata->gpio_ext_mic_en == -EPROBE_DEFER) return -EPROBE_DEFER; } if (np) { card->controls = tegra_wm8903_controls; card->num_controls = ARRAY_SIZE(tegra_wm8903_controls); card->dapm_widgets = tegra_wm8903_default_dapm_widgets; card->num_dapm_widgets = ARRAY_SIZE(tegra_wm8903_default_dapm_widgets); ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) goto err; ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); if (ret) goto err; tegra_wm8903_dai[0].codec_name = NULL; tegra_wm8903_dai[0].codec_of_node = of_parse_phandle(np, "nvidia,audio-codec", 0); if (!tegra_wm8903_dai[0].codec_of_node) { dev_err(&pdev->dev, "Property 'nvidia,audio-codec' missing or invalid\n"); ret = -EINVAL; goto err; } tegra_wm8903_dai[0].cpu_dai_name = NULL; tegra_wm8903_dai[0].cpu_of_node = of_parse_phandle(np, "nvidia,i2s-controller", 0); if (!tegra_wm8903_dai[0].cpu_of_node) { dev_err(&pdev->dev, "Property 'nvidia,i2s-controller' missing or invalid\n"); ret = -EINVAL; goto err; } tegra_wm8903_dai[0].platform_name = NULL; tegra_wm8903_dai[0].platform_of_node = tegra_wm8903_dai.cpu_of_node; } else { if (machine_is_cardhu() || machine_is_ventana()) { card->controls = cardhu_controls; card->num_controls = ARRAY_SIZE(cardhu_controls); card->dapm_widgets = cardhu_dapm_widgets; card->num_dapm_widgets = ARRAY_SIZE(cardhu_dapm_widgets); } else if (machine_is_dolak()) { card->controls = dolak_controls; card->num_controls = ARRAY_SIZE(dolak_controls); card->dapm_widgets = dolak_dapm_widgets; card->num_dapm_widgets = ARRAY_SIZE(dolak_dapm_widgets); } else { card->controls = tegra_wm8903_controls; card->num_controls = ARRAY_SIZE(tegra_wm8903_controls); card->dapm_widgets = tegra_wm8903_default_dapm_widgets; card->num_dapm_widgets = ARRAY_SIZE(tegra_wm8903_default_dapm_widgets); } if (machine_is_ventana() || machine_is_cardhu()) { card->dapm_routes = cardhu_audio_map; card->num_dapm_routes = ARRAY_SIZE(cardhu_audio_map); } else if (machine_is_dolak()) { card->dapm_routes = dolak_audio_map; card->num_dapm_routes = ARRAY_SIZE(dolak_audio_map); } else { card->dapm_routes = harmony_audio_map; card->num_dapm_routes = ARRAY_SIZE(harmony_audio_map); } } if (gpio_is_valid(pdata->gpio_spkr_en)) { ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_spkr_en, GPIOF_OUT_INIT_LOW, "spkr_en"); if (ret) { dev_err(card->dev, "cannot get spkr_en gpio\n"); return ret; } } if (gpio_is_valid(pdata->gpio_hp_mute)) { ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_hp_mute, GPIOF_OUT_INIT_HIGH, "hp_mute"); if (ret) { dev_err(card->dev, "cannot get hp_mute gpio\n"); return ret; } } if (gpio_is_valid(pdata->gpio_int_mic_en)) { /* Disable int mic; enable signal is active-high */ ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_int_mic_en, GPIOF_OUT_INIT_LOW, "int_mic_en"); if (ret) { dev_err(card->dev, "cannot get int_mic_en gpio\n"); return ret; } } if (gpio_is_valid(pdata->gpio_ext_mic_en)) { /* Enable ext mic; enable signal is active-low */ ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_ext_mic_en, GPIOF_OUT_INIT_LOW, "ext_mic_en"); if (ret) { dev_err(card->dev, "cannot get ext_mic_en gpio\n"); return ret; } } ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev, card); if (ret) goto err; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_switch; } if (!card->instantiated) { ret = -ENODEV; dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_card; } #ifndef CONFIG_ARCH_TEGRA_2x_SOC ret = tegra_asoc_utils_set_parent(&machine->util_data, pdata->i2s_param[HIFI_CODEC].is_i2s_master); if (ret) { dev_err(&pdev->dev, "tegra_asoc_utils_set_parent failed (%d)\n", ret); goto err_unregister_card; } #endif return 0; err_unregister_card: snd_soc_unregister_card(card); err_unregister_switch: #ifdef CONFIG_SWITCH tegra_asoc_switch_unregister(&tegra_wm8903_headset_switch); err_fini_utils: #endif tegra_asoc_utils_fini(&machine->util_data); err: return ret; }
static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev) { struct snd_soc_card *card = &snd_soc_tegra_wm8903; struct tegra_wm8903 *machine; struct tegra_wm8903_platform_data *pdata; int ret; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data supplied\n"); return -EINVAL; } machine = kzalloc(sizeof(struct tegra_wm8903), GFP_KERNEL); if (!machine) { dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n"); return -ENOMEM; } machine->pdata = pdata; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev, card); if (ret) goto err_free_machine; if (machine_is_cardhu()) { tegra_wm8903_dai[0].codec_name = "wm8903.4-001a", tegra_wm8903_dai[0].cpu_dai_name = "tegra30-i2s.1"; tegra_wm8903_dai[1].cpu_dai_name = "tegra30-spdif"; tegra_wm8903_dai[2].cpu_dai_name = "tegra30-i2s.3"; } card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_fini_utils; } if (!card->instantiated) { ret = -ENODEV; dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_card; } return 0; err_unregister_card: snd_soc_unregister_card(card); err_fini_utils: tegra_asoc_utils_fini(&machine->util_data); err_free_machine: kfree(machine); return ret; }