int mach_probe(struct snd_soc_machine *machine) { struct snd_soc_codec *codec; struct snd_soc_pcm_link *pcm_link; void * pdata = platform_get_drvdata(machine->pdev); struct wm1808 *wm1808 = to_wm1808_from_audio(pdata); int i, ret; pcm_link = list_first_entry(&machine->active_list, struct snd_soc_pcm_link, active_list); codec = pcm_link->codec; codec->control_data = wm1808; codec->ops->io_probe(codec, machine); /* set up imx_3stack specific audio path audio map */ for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(machine, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_MANUAL); /* register card with ALSA upper layers */ ret = snd_soc_register_card(machine); if (ret < 0) { err("%s: failed to register sound card\n", __FUNCTION__); snd_soc_machine_free(machine); return ret; } return 0; }
static int imx_3stack_mach_probe(struct snd_soc_machine *machine) { struct snd_soc_codec *codec; struct snd_soc_pcm_link *pcm_link; int i, ret; pcm_link = list_first_entry(&machine->active_list, struct snd_soc_pcm_link, active_list); codec = pcm_link->codec; codec->ops->io_probe(codec, machine); snd_soc_dapm_set_endpoint(machine, "RIN2", 0); /* Add imx_3stack specific widgets */ for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) { snd_soc_dapm_new_control(machine, codec, &imx_3stack_dapm_widgets[i]); } for (i = 0; i < ARRAY_SIZE(ak4647_machine_controls); i++) { ret = snd_ctl_add(machine->card, snd_soc_cnew(&ak4647_machine_controls[i], codec, NULL)); if (ret < 0) return ret; } /* set up imx_3stack specific audio path audio_mapnects */ for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(machine, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM); /* register card with ALSA upper layers */ ret = snd_soc_register_card(machine); if (ret < 0) { pr_err("%s: failed to register sound card\n", __func__); return ret; } return 0; }
static int mach_probe(struct snd_soc_machine *machine) { struct snd_soc_codec *codec; struct snd_soc_dai *codec_dai; struct snd_soc_pcm_link *pcm_link; struct platform_device *pdev = machine->pdev; struct mxc_sgtl5000_platform_data *plat = pdev->dev.platform_data; struct sgtl5000_platform_data *codec_data; struct imx_3stack_priv *priv; struct regulator *reg; int i, ret; pcm_link = list_first_entry(&machine->active_list, struct snd_soc_pcm_link, active_list); sgtl5000_3stack_pcm_link = pcm_link; codec = pcm_link->codec; codec_dai = pcm_link->codec_dai; codec_dai->ops->set_sysclk(codec_dai, 0, plat->sysclk, 0); priv = kzalloc(sizeof(struct imx_3stack_priv), GFP_KERNEL); if (!priv) return -ENOMEM; codec_data = kzalloc(sizeof(struct sgtl5000_platform_data), GFP_KERNEL); if (!codec_data) { ret = -ENOMEM; goto err_codec_data; } ret = -EINVAL; if (plat->init && plat->init()) goto err_plat_init; if (plat->vddio_reg) { reg = regulator_get(&pdev->dev, plat->vddio_reg); if (IS_ERR(reg)) goto err_reg_vddio; priv->reg_vddio = reg; } if (plat->vdda_reg) { reg = regulator_get(&pdev->dev, plat->vdda_reg); if (IS_ERR(reg)) goto err_reg_vdda; priv->reg_vdda = reg; } if (plat->vddd_reg) { reg = regulator_get(&pdev->dev, plat->vddd_reg); if (IS_ERR(reg)) goto err_reg_vddd; priv->reg_vddd = reg; } machine->platform_data = priv; if (priv->reg_vdda) { ret = regulator_set_voltage(priv->reg_vdda, plat->vdda); regulator_enable(priv->reg_vdda); } if (priv->reg_vddio) { regulator_set_voltage(priv->reg_vddio, plat->vddio); regulator_enable(priv->reg_vddio); } if (priv->reg_vddd) { regulator_set_voltage(priv->reg_vddd, plat->vddd); regulator_enable(priv->reg_vddd); } /* The SGTL5000 has an internal reset that is deasserted 8 SYS_MCLK cycles after all power rails have been brought up. After this time communication can start */ msleep(1); codec_data->vddio = plat->vddio / 1000; /* uV to mV */ codec_data->vdda = plat->vdda / 1000; codec_data->vddd = plat->vddd / 1000; codec->platform_data = codec_data; ret = codec->ops->io_probe(codec, machine); if (ret < 0) goto err_card_reg; gpio_activate_audio_ports(); imx_3stack_init_dam(plat->src_port, plat->ext_port); /* Add imx_3stack specific widgets */ for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) { snd_soc_dapm_new_control(machine, codec, &imx_3stack_dapm_widgets[i]); } /* set up imx_3stack specific audio path audio map */ for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(machine, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } /* connect and enable all imx_3stack SGTL5000 jacks (for now) */ snd_soc_dapm_set_endpoint(machine, "Line In Jack", 1); snd_soc_dapm_set_endpoint(machine, "Mic Jack", 1); snd_soc_dapm_set_endpoint(machine, "Line Out Jack", 1); snd_soc_dapm_set_endpoint(machine, "Headphone Jack", 1); sgtl5000_jack_func = 1; sgtl5000_spk_func = 1; snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM); snd_soc_dapm_sync_endpoints(machine); for (i = 0; i < ARRAY_SIZE(sgtl5000_machine_controls); i++) { ret = snd_ctl_add(machine->card, snd_soc_cnew(&sgtl5000_machine_controls[i], codec, NULL)); if (ret < 0) goto err_card_reg; } /* register card with ALSA upper layers */ ret = snd_soc_register_card(machine); if (ret < 0) { pr_err("%s: failed to register sound card\n", __func__); goto err_card_reg; } if (plat->hp_status()) ret = request_irq(plat->hp_irq, imx_headphone_detect_handler, IRQT_FALLING, pdev->name, machine); else ret = request_irq(plat->hp_irq, imx_headphone_detect_handler, IRQT_RISING, pdev->name, machine); if (ret < 0) { pr_err("%s: request irq failed\n", __func__); goto err_card_reg; } return 0; err_card_reg: if (priv->reg_vddd) regulator_put(priv->reg_vddd, &pdev->dev); err_reg_vddd: if (priv->reg_vdda) regulator_put(priv->reg_vdda, &pdev->dev); err_reg_vdda: if (priv->reg_vddio) regulator_put(priv->reg_vddio, &pdev->dev); err_reg_vddio: if (plat->finit) plat->finit(); err_plat_init: kfree(codec_data); codec->platform_data = NULL; err_codec_data: kfree(priv); machine->platform_data = NULL; return ret; }
static int imx_3stack_mach_probe(struct snd_soc_machine *machine) { struct snd_soc_codec *codec; struct snd_soc_pcm_link *pcm_link; int i, ret; pcm_link = list_first_entry(&machine->active_list, struct snd_soc_pcm_link, active_list); wm8903_3stack_pcm_link = pcm_link; codec = pcm_link->codec; gpio_activate_audio_ports(); codec->ops->io_probe(codec, machine); /* set unused imx_3stack WM8903 codec pins */ snd_soc_dapm_set_endpoint(machine, "IN2R", 0); snd_soc_dapm_set_endpoint(machine, "IN1R", 0); /* Add imx_3stack specific widgets */ for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) { snd_soc_dapm_new_control(machine, codec, &imx_3stack_dapm_widgets[i]); } for (i = 0; i < ARRAY_SIZE(imx_3stack_machine_controls); i++) { ret = snd_ctl_add(machine->card, snd_soc_cnew(&imx_3stack_machine_controls[i], codec, NULL)); if (ret < 0) return ret; } /* set up imx_3stack specific audio path audio map */ for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(machine, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } imx_3stack_ext_control(); snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM); snd_soc_dapm_sync_endpoints(machine); wm8903_hp_initialize_hp_detect(codec); wm8903_hp_status(codec); gpio_config(WM8903_IRQ_GPIO_PORT, WM8903_IRQ_GPIO_NUM, false, GPIO_INT_RISE_EDGE); gpio_request_irq(WM8903_IRQ_GPIO_PORT, WM8903_IRQ_GPIO_NUM, GPIO_LOW_PRIO, imx_headphone_detect_handler, 0, "headphone", pcm_link); /* register card with ALSA upper layers */ ret = snd_soc_register_card(machine); if (ret < 0) { pr_err("%s: failed to register sound card\n", __func__); return ret; } return 0; }