static int smdkc110_wm8994_init(struct snd_soc_codec *codec) { #if 0 debug_msg("%s\n", __FUNCTION__); /* Add smdkc110 specific controls */ for (i = 0; i < ARRAY_SIZE(wm8580_smdkc110_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8580_smdkc110_controls[i], codec, NULL)); if (err < 0) return err; } /* Add smdkc110 specific widgets */ snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets, ARRAY_SIZE(wm8580_dapm_widgets)); /* Set up smdkc110 specific audio path audio_map */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); /* No jack detect - mark all jacks as enabled */ for (i = 0; i < ARRAY_SIZE(wm8580_dapm_widgets); i++) snd_soc_dapm_enable_pin(codec, wm8580_dapm_widgets[i].name); /* Setup Default Route */ smdkc110_play_opt = PLAY_STEREO; smdkc110_rec_opt = REC_LINE; smdkc110_ext_control(codec); #endif return 0; }
/* * Pavo for a jzcodec as connected on jz4740 Device */ static int pavo_jzcodec_init(struct snd_soc_codec *codec) { int i, err; snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0); snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0); /* Add pavo specific controls */ for (i = 0; i < ARRAY_SIZE(jzcodec_pavo_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&jzcodec_pavo_controls[i],codec, NULL)); if (err < 0) return err; } /* Add pavo specific widgets */ for(i = 0; i < ARRAY_SIZE(jzcodec_dapm_widgets); i++) { snd_soc_dapm_new_control(codec, &jzcodec_dapm_widgets[i]); } /* Set up pavo specific audio path audio_map */ for(i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(codec, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } snd_soc_dapm_sync_endpoints(codec); return 0; }
/* * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device */ static int spitz_wm8750_init(struct snd_soc_codec *codec) { int i, err; /* NC codec pins */ snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0); snd_soc_dapm_set_endpoint(codec, "LINPUT2", 0); snd_soc_dapm_set_endpoint(codec, "RINPUT2", 0); snd_soc_dapm_set_endpoint(codec, "LINPUT3", 0); snd_soc_dapm_set_endpoint(codec, "RINPUT3", 0); snd_soc_dapm_set_endpoint(codec, "OUT3", 0); snd_soc_dapm_set_endpoint(codec, "MONO", 0); /* Add spitz specific controls */ for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL)); if (err < 0) return err; } /* Add spitz specific widgets */ for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]); /* Set up spitz specific audio path audio_map */ for (i = 0; audio_map[i][0] != NULL; i++) snd_soc_dapm_connect_input(codec, audio_map[i][0], audio_map[i][1], audio_map[i][2]); snd_soc_dapm_sync_endpoints(codec); return 0; }
static int h5000_ak4535_init (struct snd_soc_codec *codec) { int i, err; /* NC codec pins */ snd_soc_dapm_set_endpoint (codec, "MOUT1", 0); snd_soc_dapm_set_endpoint (codec, "LOUT", 0); snd_soc_dapm_set_endpoint (codec, "ROUT", 0); snd_soc_dapm_set_endpoint (codec, "MOUT2", 0); /* FIXME: These pins are marked as INPUTS */ snd_soc_dapm_set_endpoint (codec, "MIN", 0); /* FIXME: and OUTPUTS in ak4535.c . We need to do this in order */ snd_soc_dapm_set_endpoint (codec, "AIN", 0); /* FIXME: to get DAPM working properly, because the pins are connected */ snd_soc_dapm_set_endpoint (codec, "MICOUT", 0); /* FIXME: OUTPUT -> INPUT. */ /* Add h5000 specific controls */ for (i = 0; i < ARRAY_SIZE (ak4535_h5000_controls); i++) { err = snd_ctl_add (codec->card, snd_soc_cnew (&ak4535_h5000_controls[i], codec, NULL)); if (err < 0) return err; }; /* Add h5000 specific widgets */ for (i = 0; i < ARRAY_SIZE (ak4535_dapm_widgets); i++) { snd_soc_dapm_new_control (codec, &ak4535_dapm_widgets [i]); }; /* Set up h5000 specific audio path audio_map */ for (i = 0; audio_map [i][0] != NULL; i++) { snd_soc_dapm_connect_input (codec, audio_map [i][0], audio_map [i][1], audio_map [i][2]); }; snd_soc_dapm_sync_endpoints (codec); return 0; };
/* * This is an example machine initialisation for a wm8580 connected to a * smdk2450. It is missing logic to detect hp/mic insertions and logic * to re-route the audio in such an event. */ static int smdk_wm8580_init(struct snd_soc_codec *codec) { int i, err; /* set endpoints to default mode */ set_scenario_endpoints(codec, SMDK_AUDIO_OFF); /* Add smdk2450 specific widgets */ for (i = 0; i < ARRAY_SIZE(wm8580_dapm_widgets); i++) snd_soc_dapm_new_control(codec, &wm8580_dapm_widgets[i]); /* add smdk2450 specific controls */ for (i = 0; i < ARRAY_SIZE(wm8580_smdk_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8580_smdk_controls[i], codec, NULL)); if (err < 0) return err; } /* set up smdk2450 specific audio path audio_mapnects */ for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(codec, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } /* always connected */ snd_soc_dapm_set_endpoint(codec, "Mic1 Jack", 1); snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1); snd_soc_dapm_set_endpoint(codec, "Line In Jack", 1); snd_soc_dapm_sync_endpoints(codec); return 0; }
/* * Pavo for a jzcodec as connected on jz4740 Device */ static int pavo_jzcodec_init(struct snd_soc_codec *codec) { int i, err; snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN"); /* Add pavo specific controls */ for (i = 0; i < ARRAY_SIZE(jzcodec_pavo_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&jzcodec_pavo_controls[i],codec, NULL)); if (err < 0) return err; } /* Add pavo specific widgets */ for(i = 0; i < ARRAY_SIZE(jzcodec_dapm_widgets); i++) { snd_soc_dapm_new_control(codec, &jzcodec_dapm_widgets[i]); } // snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); return 0; }
/* * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device */ static int spitz_wm8750_init(struct snd_soc_codec *codec) { int i, err; /* NC codec pins */ snd_soc_dapm_disable_pin(codec, "RINPUT1"); snd_soc_dapm_disable_pin(codec, "LINPUT2"); snd_soc_dapm_disable_pin(codec, "RINPUT2"); snd_soc_dapm_disable_pin(codec, "LINPUT3"); snd_soc_dapm_disable_pin(codec, "RINPUT3"); snd_soc_dapm_disable_pin(codec, "OUT3"); snd_soc_dapm_disable_pin(codec, "MONO"); /* Add spitz specific controls */ for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL)); if (err < 0) return err; } /* Add spitz specific widgets */ snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, ARRAY_SIZE(wm8750_dapm_widgets)); /* Set up spitz specific audio paths */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); return 0; }
static int tosa_ac97_init(struct snd_soc_codec *codec) { int i, err; snd_soc_dapm_disable_pin(codec, "OUT3"); snd_soc_dapm_disable_pin(codec, "MONOOUT"); /* add tosa specific controls */ for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&tosa_controls[i],codec, NULL)); if (err < 0) return err; } /* add tosa specific widgets */ snd_soc_dapm_new_controls(codec, tosa_dapm_widgets, ARRAY_SIZE(tosa_dapm_widgets)); /* set up tosa specific audio path audio_map */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); return 0; }
static int n810_aic33_init(struct snd_soc_codec *codec) { int i, err; /* Not connected */ snd_soc_dapm_disable_pin(codec, "MONO_LOUT"); snd_soc_dapm_disable_pin(codec, "HPLCOM"); snd_soc_dapm_disable_pin(codec, "HPRCOM"); /* Add N810 specific controls */ for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&aic33_n810_controls[i], codec, NULL)); if (err < 0) return err; } /* Add N810 specific widgets */ snd_soc_dapm_new_controls(codec, aic33_dapm_widgets, ARRAY_SIZE(aic33_dapm_widgets)); /* Set up N810 specific audio path audio_map */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); return 0; }
static int imx_3stack_wm8350_init(struct snd_soc_codec *codec) { struct imx_3stack_priv *priv = &machine_priv; struct wm8350 *wm8350 = priv->wm8350; int i, ret; codec->control_data = wm8350; /* Add imx_3stack specific controls */ for (i = 0; i < ARRAY_SIZE(wm8350_machine_controls); i++) { ret = snd_ctl_add(codec->card, snd_soc_cnew(&wm8350_machine_controls[i], codec, NULL)); if (ret < 0) return ret; } /* Add imx_3stack specific widgets */ snd_soc_dapm_new_controls(codec, imx_3stack_dapm_widgets, ARRAY_SIZE(imx_3stack_dapm_widgets)); /* Set up imx_3stack specific audio path audio_map */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); return 0; }
/* add non dapm controls */ static int ad1980_add_controls(struct snd_soc_codec *codec) { int err, i; for (i = 0; i < ARRAY_SIZE(ad1980_snd_ac97_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew( &ad1980_snd_ac97_controls[i], codec, NULL)); if (err < 0) return err; } return 0; }
/* add non dapm controls */ static int jzcodec_add_controls(struct snd_soc_codec *codec) { int err, i; for (i = 0; i < ARRAY_SIZE(jzcodec_snd_controls); i++) { if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&jzcodec_snd_controls[i], codec, NULL))) < 0) return err; } return 0; }
/* add non dapm controls */ static int wm8350_add_controls(struct snd_soc_codec *codec, struct snd_card *card) { int err, i; for (i = 0; i < ARRAY_SIZE(wm8350_snd_controls); i++) { err = snd_ctl_add(card, snd_soc_cnew(&wm8350_snd_controls[i], codec, NULL)); if (err < 0) return err; } return 0; }
static int imx_3stack_alc5623_init(struct snd_soc_codec *codec) { int i, ret; #if defined(CONFIG_MXC_ASRC) || defined(CONFIG_MXC_ASRC_MODULE) for (i = 0; i < ARRAY_SIZE(asrc_controls); i++) { ret = snd_ctl_add(codec->card, snd_soc_cnew(&asrc_controls[i], codec, NULL)); if (ret < 0) return ret; } asrc_ssi_data.output_sample_rate = alc5623_rates[asrc_func]; #endif /* Add imx_3stack specific controls */ for (i = 0; i < ARRAY_SIZE(alc5623_machine_controls); i++) { ret = snd_ctl_add(codec->card, snd_soc_cnew(&alc5623_machine_controls[i], codec, NULL)); if (ret < 0) return ret; } /* Add imx_3stack specific widgets */ snd_soc_dapm_new_controls(codec, imx_3stack_dapm_widgets, ARRAY_SIZE(imx_3stack_dapm_widgets)); /* Set up imx_3stack specific audio path audio_map */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_disable_pin(codec, "Line In Jack"); snd_soc_dapm_sync(codec); 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 evm_ak4588_control_init(struct snd_soc_codec *codec) { struct snd_soc_ak4588_codec *ak4588 = codec->private_data; int i, err; ak4588->sw_reg_get = mcasp_serializer_control_get; ak4588->sw_reg_set = mcasp_serializer_control_set; for (i = 0; i < ARRAY_SIZE(ak4588_serializer_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&ak4588_serializer_controls[i], codec, NULL)); if (err < 0) return err; } return 0; }
/* * This is an example machine initialisation for a adau1761 connected to a * s5p6440. It is missing logic to detect hp/mic insertions and logic * to re-route the audio in such an event. */ static int s5p6440_adau1761_init(struct snd_soc_codec *codec) { int i, err; /* Add s5p6440 specific widgets */ snd_soc_dapm_new_controls(codec, adau1761_dapm_widgets, ARRAY_SIZE(adau1761_dapm_widgets)); /* add s5p6440 specific controls */ for (i = 0; i < ARRAY_SIZE(adau1761_s5p6440_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&adau1761_s5p6440_controls[i], codec, NULL)); if (err < 0) return err; } tomtom_add_nashville_controls(codec->card, codec); /* set up s5p6440 specific audio paths */ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); /* always connected */ snd_soc_dapm_enable_pin(codec, "Headphones"); snd_soc_dapm_enable_pin(codec, "MicIn"); snd_soc_dapm_enable_pin(codec, "LineIn"); snd_soc_dapm_enable_pin(codec, "Speaker"); /* not connected */ snd_soc_dapm_nc_pin(codec, "LMICIN"); snd_soc_dapm_nc_pin(codec, "RMICIN"); snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN"); snd_soc_dapm_nc_pin(codec, "LOUT"); snd_soc_dapm_nc_pin(codec, "LHPOUT"); snd_soc_dapm_nc_pin(codec, "ROUT"); snd_soc_dapm_nc_pin(codec, "RHPOUT"); // snd_soc_dapm_nc_pin(codec, "MONOOUT"); /* set endpoints to default mode & sync with DAPM */ set_scenario_endpoints(codec, S5P6440_CAPTURE_LINE_HP_SPKR_OUT); return 0; }
/* * This is an example machine initialisation for a wm8990 connected to a * smdk6410. It is missing logic to detect hp/mic insertions and logic * to re-route the audio in such an event. */ static int smdk6410_wm8990_init(struct snd_soc_codec *codec) { int i, err; /* Add smdk6410 specific widgets */ for (i = 0; i < ARRAY_SIZE(wm8990_dapm_widgets); i++) snd_soc_dapm_new_control(codec, &wm8990_dapm_widgets[i]); /* add smdk6410 specific controls */ for (i = 0; i < ARRAY_SIZE(wm8990_smdk6410_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8990_smdk6410_controls[i], codec, NULL)); if (err < 0) return err; } /* set up smdk6410 specific audio paths */ for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(codec, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } /* not connected */ snd_soc_dapm_set_endpoint(codec, "RIN1", 0); snd_soc_dapm_set_endpoint(codec, "LIN3", 0); snd_soc_dapm_set_endpoint(codec, "LIN4", 0); snd_soc_dapm_set_endpoint(codec, "RIN3", 0); snd_soc_dapm_set_endpoint(codec, "RIN4", 0); snd_soc_dapm_set_endpoint(codec, "OUT3", 0); snd_soc_dapm_set_endpoint(codec, "OUT4", 0); snd_soc_dapm_set_endpoint(codec, "SPKP", 0); snd_soc_dapm_set_endpoint(codec, "SPKN", 0); snd_soc_dapm_set_endpoint(codec, "ROP", 0); snd_soc_dapm_set_endpoint(codec, "RON", 0); snd_soc_dapm_set_endpoint(codec, "LOP", 0); snd_soc_dapm_set_endpoint(codec, "LON", 0); /* set endpoints to default mode & sync with DAPM */ set_scenario_endpoints(codec, SMDK6410_STEREO_TO_HEADPHONES); return 0; }
static int imx_3stack_ak4647_init(struct snd_soc_codec *codec) { int i, ret; for (i = 0; i < ARRAY_SIZE(ak4647_card_controls); i++) { ret = snd_ctl_add(codec->card, snd_soc_cnew(&ak4647_card_controls[i], codec, NULL)); if (ret < 0) return ret; } snd_soc_dapm_new_controls(codec, imx_3stack_dapm_widgets, ARRAY_SIZE(imx_3stack_dapm_widgets)); snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); return 0; }
static int cs4344_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = cs4344_codec; int ret = 0; int i = 0; printk ("****** started cs4344 ******\n"); BUG_ON(cs4344_codec == NULL); socdev->card->codec = cs4344_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { printk(KERN_ERR "cs4344: failed to create pcms\n"); goto pcm_err; } for (i = 0; i < ARRAY_SIZE(cs4344_snd_controls); i++) { struct snd_kcontrol *kctrl = snd_soc_cnew(&cs4344_snd_controls[i], codec, NULL); ret = snd_ctl_add(codec->card, kctrl); if (ret < 0) { printk (KERN_ERR "cs4344: failed to add control\n"); goto card_err; } } return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: return ret; }
/* * This is an example machine initialisation for a wm8753 connected to a * mx31ads II. It is missing logic to detect hp/mic insertions and logic * to re-route the audio in such an event. */ static int mx31ads_wm8753_init(struct snd_soc_codec *codec) { int i, err; /* set up mx31ads codec pins */ snd_soc_dapm_disable_pin(codec, "RXP", 0); snd_soc_dapm_disable_pin(codec, "RXN", 0); snd_soc_dapm_disable_pin(codec, "MIC2", 0); /* add mx31ads specific controls */ for (i = 0; i < ARRAY_SIZE(wm8753_mx31ads_controls); i++) { if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8753_mx31ads_controls[i],codec, NULL))) < 0) return err; } /* set up mx31ads specific audio path audio_mapnects */ for(i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(codec, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } snd_soc_dapm_sync(codec); return 0; }
/* * This is an example machine initialisation for a wm8987 connected to a * imapx200. It is missing logic to detect hp/mic insertions and logic * to re-route the audio in such an event. */ static int imapx200_wm8987_init(struct snd_soc_codec *codec) { int i, err; /* set endpoints to default mode */ // set_scenario_endpoints(codec, IMAPX200_AUDIO_OFF); /* Add imapx200 specific widgets */ for (i = 0; i < ARRAY_SIZE(wm8987_dapm_widgets); i++) snd_soc_dapm_new_control(codec, &wm8987_dapm_widgets[i]); /* add imapx200 specific controls */ for (i = 0; i < ARRAY_SIZE(wm8987_imapx200_controls); i++) { err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8987_imapx200_controls[i], codec, NULL)); if (err < 0) return err; } /* set up imapx200 specific audio path audio_mapnects */ #if 1 for (i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(codec, audio_map[i][0], audio_map[i][1], audio_map[i][2]); } #endif // snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); /* always connected */ snd_soc_dapm_enable_pin(codec, "Mic Bias"); snd_soc_dapm_enable_pin(codec, "Headphone Jack"); snd_soc_dapm_enable_pin(codec, "Line In Jack"); snd_soc_dapm_sync(codec); return 0; }
static int imx_3stack_cs42888_init(struct snd_soc_codec *codec) { #if defined(CONFIG_MXC_ASRC) || defined(CONFIG_MXC_ASRC_MODULE) int i; int ret; for (i = 0; i < ARRAY_SIZE(asrc_controls); i++) { ret = snd_ctl_add(codec->card, snd_soc_cnew(&asrc_controls[i], codec, NULL)); if (ret < 0) return ret; } asrc_esai_data.output_sample_rate = asrc_rates[asrc_func + 4]; #endif snd_soc_dapm_new_controls(codec, imx_3stack_dapm_widgets, ARRAY_SIZE(imx_3stack_dapm_widgets)); snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(codec); 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); 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; }
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; }
/* * Initialize the I2C interface of the CS4270 * * This function is called for whenever the I2C subsystem finds a device * at a particular address. * * Note: snd_soc_new_pcms() must be called before this function can be called, * because of snd_ctl_add(). */ static int cs4270_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct snd_soc_device *socdev = cs4270_socdev; struct snd_soc_codec *codec = socdev->codec; int i; int ret = 0; /* Probing all possible addresses has one drawback: if there are multiple CS4270s on the bus, then you cannot specify which socdev is matched with which CS4270. For now, we just reject this I2C device if the socdev already has one attached. */ if (codec->control_data) return -ENODEV; /* Note: codec_dai->codec is NULL here */ codec->reg_cache = kzalloc(CS4270_NUMREGS, GFP_KERNEL); if (!codec->reg_cache) { printk(KERN_ERR "cs4270: could not allocate register cache\n"); ret = -ENOMEM; goto error; } /* Verify that we have a CS4270 */ ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); if (ret < 0) { printk(KERN_ERR "cs4270: failed to read I2C\n"); goto error; } /* The top four bits of the chip ID should be 1100. */ if ((ret & 0xF0) != 0xC0) { /* The device at this address is not a CS4270 codec */ ret = -ENODEV; goto error; } printk(KERN_INFO "cs4270: found device at I2C address %X\n", i2c_client->addr); printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF); codec->control_data = i2c_client; codec->read = cs4270_read_reg_cache; codec->write = cs4270_i2c_write; codec->reg_cache_size = CS4270_NUMREGS; /* The I2C interface is set up, so pre-fill our register cache */ ret = cs4270_fill_cache(codec); if (ret < 0) { printk(KERN_ERR "cs4270: failed to fill register cache\n"); goto error; } /* Add the non-DAPM controls */ for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { struct snd_kcontrol *kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); ret = snd_ctl_add(codec->card, kctrl); if (ret < 0) goto error; } i2c_set_clientdata(i2c_client, codec); return 0; error: codec->control_data = NULL; kfree(codec->reg_cache); codec->reg_cache = NULL; codec->reg_cache_size = 0; return ret; }