diff options
Diffstat (limited to 'sound/soc/ti/rx51.c')
| -rw-r--r-- | sound/soc/ti/rx51.c | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/sound/soc/ti/rx51.c b/sound/soc/ti/rx51.c index 322c398d209b..7eeb12e5066c 100644 --- a/sound/soc/ti/rx51.c +++ b/sound/soc/ti/rx51.c @@ -10,7 +10,6 @@ */ #include <linux/delay.h> -#include <linux/gpio.h> #include <linux/platform_device.h> #include <linux/gpio/consumer.h> #include <linux/module.h> @@ -33,7 +32,6 @@ enum { struct rx51_audio_pdata { struct gpio_desc *tvout_selection_gpio; - struct gpio_desc *jack_detection_gpio; struct gpio_desc *eci_sw_gpio; struct gpio_desc *speaker_amp_gpio; }; @@ -44,7 +42,7 @@ static int rx51_jack_func; static void rx51_ext_control(struct snd_soc_dapm_context *dapm) { - struct snd_soc_card *card = dapm->card; + struct snd_soc_card *card = snd_soc_dapm_to_card(dapm); struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); int hp = 0, hs = 0, tvout = 0; @@ -90,11 +88,11 @@ static void rx51_ext_control(struct snd_soc_dapm_context *dapm) static int rx51_startup(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_card *card = rtd->card; + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(rtd->card); snd_pcm_hw_constraint_single(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2); - rx51_ext_control(&card->dapm); + rx51_ext_control(dapm); return 0; } @@ -102,8 +100,8 @@ static int rx51_startup(struct snd_pcm_substream *substream) static int rx51_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); /* Set the codec system clock for DAC and ADC */ return snd_soc_dai_set_sysclk(codec_dai, 0, 19200000, @@ -127,12 +125,13 @@ static int rx51_set_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); if (rx51_spk_func == ucontrol->value.enumerated.item[0]) return 0; rx51_spk_func = ucontrol->value.enumerated.item[0]; - rx51_ext_control(&card->dapm); + rx51_ext_control(dapm); return 1; } @@ -141,7 +140,7 @@ static int rx51_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { struct snd_soc_dapm_context *dapm = w->dapm; - struct snd_soc_card *card = dapm->card; + struct snd_soc_card *card = snd_soc_dapm_to_card(dapm); struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); gpiod_set_raw_value_cansleep(pdata->speaker_amp_gpio, @@ -162,12 +161,13 @@ static int rx51_set_input(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); if (rx51_dmic_func == ucontrol->value.enumerated.item[0]) return 0; rx51_dmic_func = ucontrol->value.enumerated.item[0]; - rx51_ext_control(&card->dapm); + rx51_ext_control(dapm); return 1; } @@ -184,12 +184,13 @@ static int rx51_set_jack(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); if (rx51_jack_func == ucontrol->value.enumerated.item[0]) return 0; rx51_jack_func = ucontrol->value.enumerated.item[0]; - rx51_ext_control(&card->dapm); + rx51_ext_control(dapm); return 1; } @@ -198,7 +199,7 @@ static struct snd_soc_jack rx51_av_jack; static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = { { - .name = "avdet-gpio", + .name = "jack-detection", .report = SND_JACK_HEADSET, .invert = 1, .debounce_time = 200, @@ -263,7 +264,6 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = { static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card = rtd->card; - struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); int err; snd_soc_limit_volume(card, "TPA6130A2 Headphone Playback Volume", 42); @@ -283,9 +283,9 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) return err; } - /* prepare gpio for snd_soc_jack_add_gpios */ - rx51_av_jack_gpios[0].gpio = desc_to_gpio(pdata->jack_detection_gpio); - devm_gpiod_put(card->dev, pdata->jack_detection_gpio); + rx51_av_jack_gpios[0].gpiod_dev = card->dev; + /* Name is assigned in the struct */ + rx51_av_jack_gpios[0].idx = 0; err = snd_soc_jack_add_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), @@ -310,7 +310,7 @@ static struct snd_soc_dai_link rx51_dai[] = { .name = "TLV320AIC34", .stream_name = "AIC34", .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | - SND_SOC_DAIFMT_CBM_CFM, + SND_SOC_DAIFMT_CBP_CFP, .init = rx51_aic34_init, .ops = &rx51_ops, SND_SOC_DAILINK_REG(aic34), @@ -374,7 +374,7 @@ static int rx51_soc_probe(struct platform_device *pdev) dai_node = of_parse_phandle(np, "nokia,cpu-dai", 0); if (!dai_node) { - dev_err(&pdev->dev, "McBSP node is not provided\n"); + dev_err(card->dev, "McBSP node is not provided\n"); return -EINVAL; } rx51_dai[0].cpus->dai_name = NULL; @@ -384,7 +384,7 @@ static int rx51_soc_probe(struct platform_device *pdev) dai_node = of_parse_phandle(np, "nokia,audio-codec", 0); if (!dai_node) { - dev_err(&pdev->dev, "Codec node is not provided\n"); + dev_err(card->dev, "Codec node is not provided\n"); return -EINVAL; } rx51_dai[0].codecs->name = NULL; @@ -392,7 +392,7 @@ static int rx51_soc_probe(struct platform_device *pdev) dai_node = of_parse_phandle(np, "nokia,audio-codec", 1); if (!dai_node) { - dev_err(&pdev->dev, "Auxiliary Codec node is not provided\n"); + dev_err(card->dev, "Auxiliary Codec node is not provided\n"); return -EINVAL; } rx51_aux_dev[0].dlc.name = NULL; @@ -402,7 +402,7 @@ static int rx51_soc_probe(struct platform_device *pdev) dai_node = of_parse_phandle(np, "nokia,headphone-amplifier", 0); if (!dai_node) { - dev_err(&pdev->dev, "Headphone amplifier node is not provided\n"); + dev_err(card->dev, "Headphone amplifier node is not provided\n"); return -EINVAL; } rx51_aux_dev[1].dlc.name = NULL; @@ -411,7 +411,7 @@ static int rx51_soc_probe(struct platform_device *pdev) rx51_codec_conf[1].dlc.of_node = dai_node; } - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(card->dev, sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) return -ENOMEM; @@ -425,14 +425,6 @@ static int rx51_soc_probe(struct platform_device *pdev) return PTR_ERR(pdata->tvout_selection_gpio); } - pdata->jack_detection_gpio = devm_gpiod_get(card->dev, - "jack-detection", - GPIOD_ASIS); - if (IS_ERR(pdata->jack_detection_gpio)) { - dev_err(card->dev, "could not get jack detection gpio\n"); - return PTR_ERR(pdata->jack_detection_gpio); - } - pdata->eci_sw_gpio = devm_gpiod_get(card->dev, "eci-switch", GPIOD_OUT_HIGH); if (IS_ERR(pdata->eci_sw_gpio)) { @@ -450,7 +442,7 @@ static int rx51_soc_probe(struct platform_device *pdev) err = devm_snd_soc_register_card(card->dev, card); if (err) { - dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", err); + dev_err(card->dev, "snd_soc_register_card failed (%d)\n", err); return err; } |
