X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sound%2Fsoc%2Fpxa%2Fcorgi.c;h=863367ad89ce6aa1b173914f8c2541903d4f9846;hb=022658beab5581ecc1d325d60857f2fc464da22f;hp=b0e2fb720910533d442be66e68db112dbbc93dce;hpb=5d22df200beccb1dea26fe4d8684ed93ae2f0aeb;p=deliverable%2Flinux.git diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index b0e2fb720910..863367ad89ce 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -45,10 +45,8 @@ static int corgi_jack_func; static int corgi_spk_func; -static void corgi_ext_control(struct snd_soc_codec *codec) +static void corgi_ext_control(struct snd_soc_dapm_context *dapm) { - struct snd_soc_dapm_context *dapm = &codec->dapm; - /* set up jack connection */ switch (corgi_jack_func) { case CORGI_HP: @@ -104,7 +102,7 @@ static int corgi_startup(struct snd_pcm_substream *substream) mutex_lock(&codec->mutex); /* check the jack status at stream startup */ - corgi_ext_control(codec); + corgi_ext_control(&codec->dapm); mutex_unlock(&codec->mutex); @@ -142,18 +140,6 @@ static int corgi_hw_params(struct snd_pcm_substream *substream, break; } - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* set the codec system clock for DAC and ADC */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, clk, SND_SOC_CLOCK_IN); @@ -185,13 +171,13 @@ static int corgi_get_jack(struct snd_kcontrol *kcontrol, static int corgi_set_jack(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (corgi_jack_func == ucontrol->value.integer.value[0]) return 0; corgi_jack_func = ucontrol->value.integer.value[0]; - corgi_ext_control(codec); + corgi_ext_control(&card->dapm); return 1; } @@ -205,13 +191,13 @@ static int corgi_get_spk(struct snd_kcontrol *kcontrol, static int corgi_set_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (corgi_spk_func == ucontrol->value.integer.value[0]) return 0; corgi_spk_func = ucontrol->value.integer.value[0]; - corgi_ext_control(codec); + corgi_ext_control(&card->dapm); return 1; } @@ -239,7 +225,7 @@ SND_SOC_DAPM_HP("Headset Jack", NULL), }; /* Corgi machine audio map (connections to the codec pins) */ -static const struct snd_soc_dapm_route audio_map[] = { +static const struct snd_soc_dapm_route corgi_audio_map[] = { /* headset Jack - in = micin, out = LHPOUT*/ {"Headset Jack", NULL, "LHPOUT"}, @@ -281,24 +267,10 @@ static int corgi_wm8731_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; - int err; snd_soc_dapm_nc_pin(dapm, "LLINEIN"); snd_soc_dapm_nc_pin(dapm, "RLINEIN"); - /* Add corgi specific controls */ - err = snd_soc_add_controls(codec, wm8731_corgi_controls, - ARRAY_SIZE(wm8731_corgi_controls)); - if (err < 0) - return err; - - /* Add corgi specific widgets */ - snd_soc_dapm_new_controls(dapm, wm8731_dapm_widgets, - ARRAY_SIZE(wm8731_dapm_widgets)); - - /* Set up corgi specific audio path audio_map */ - snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); - return 0; } @@ -311,48 +283,61 @@ static struct snd_soc_dai_link corgi_dai = { .platform_name = "pxa-pcm-audio", .codec_name = "wm8731.0-001b", .init = corgi_wm8731_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &corgi_ops, }; /* corgi audio machine driver */ -static struct snd_soc_card snd_soc_corgi = { +static struct snd_soc_card corgi = { .name = "Corgi", + .owner = THIS_MODULE, .dai_link = &corgi_dai, .num_links = 1, -}; -static struct platform_device *corgi_snd_device; + .controls = wm8731_corgi_controls, + .num_controls = ARRAY_SIZE(wm8731_corgi_controls), + .dapm_widgets = wm8731_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), + .dapm_routes = corgi_audio_map, + .num_dapm_routes = ARRAY_SIZE(corgi_audio_map), +}; -static int __init corgi_init(void) +static int __devinit corgi_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &corgi; int ret; - if (!(machine_is_corgi() || machine_is_shepherd() || - machine_is_husky())) - return -ENODEV; - - corgi_snd_device = platform_device_alloc("soc-audio", -1); - if (!corgi_snd_device) - return -ENOMEM; - - platform_set_drvdata(corgi_snd_device, &snd_soc_corgi); - ret = platform_device_add(corgi_snd_device); + card->dev = &pdev->dev; + ret = snd_soc_register_card(card); if (ret) - platform_device_put(corgi_snd_device); - + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); return ret; } -static void __exit corgi_exit(void) +static int __devexit corgi_remove(struct platform_device *pdev) { - platform_device_unregister(corgi_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + return 0; } -module_init(corgi_init); -module_exit(corgi_exit); +static struct platform_driver corgi_driver = { + .driver = { + .name = "corgi-audio", + .owner = THIS_MODULE, + }, + .probe = corgi_probe, + .remove = __devexit_p(corgi_remove), +}; + +module_platform_driver(corgi_driver); /* Module information */ MODULE_AUTHOR("Richard Purdie"); MODULE_DESCRIPTION("ALSA SoC Corgi"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:corgi-audio");