ASoC: Rename snd_soc_register_card() to snd_soc_init_card()
[linux-2.6/btrfs-unstable.git] / sound / soc / codecs / ad73311.c
blob0f4110f4bceba08092065d2001329a14ab7a9d02
1 /*
2 * ad73311.c -- ALSA Soc AD73311 codec support
4 * Copyright: Analog Device Inc.
5 * Author: Cliff Cai <cliff.cai@analog.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * Revision history
13 * 25th Sep 2008 Initial version.
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/device.h>
20 #include <sound/core.h>
21 #include <sound/pcm.h>
22 #include <sound/ac97_codec.h>
23 #include <sound/initval.h>
24 #include <sound/soc.h>
26 #include "ad73311.h"
28 struct snd_soc_dai ad73311_dai = {
29 .name = "AD73311",
30 .playback = {
31 .stream_name = "Playback",
32 .channels_min = 1,
33 .channels_max = 1,
34 .rates = SNDRV_PCM_RATE_8000,
35 .formats = SNDRV_PCM_FMTBIT_S16_LE, },
36 .capture = {
37 .stream_name = "Capture",
38 .channels_min = 1,
39 .channels_max = 1,
40 .rates = SNDRV_PCM_RATE_8000,
41 .formats = SNDRV_PCM_FMTBIT_S16_LE, },
43 EXPORT_SYMBOL_GPL(ad73311_dai);
45 static int ad73311_soc_probe(struct platform_device *pdev)
47 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
48 struct snd_soc_codec *codec;
49 int ret = 0;
51 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
52 if (codec == NULL)
53 return -ENOMEM;
54 mutex_init(&codec->mutex);
55 codec->name = "AD73311";
56 codec->owner = THIS_MODULE;
57 codec->dai = &ad73311_dai;
58 codec->num_dai = 1;
59 socdev->codec = codec;
60 INIT_LIST_HEAD(&codec->dapm_widgets);
61 INIT_LIST_HEAD(&codec->dapm_paths);
63 /* register pcms */
64 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
65 if (ret < 0) {
66 printk(KERN_ERR "ad73311: failed to create pcms\n");
67 goto pcm_err;
70 ret = snd_soc_init_card(socdev);
71 if (ret < 0) {
72 printk(KERN_ERR "ad73311: failed to register card\n");
73 goto register_err;
76 return ret;
78 register_err:
79 snd_soc_free_pcms(socdev);
80 pcm_err:
81 kfree(socdev->codec);
82 socdev->codec = NULL;
83 return ret;
86 static int ad73311_soc_remove(struct platform_device *pdev)
88 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
89 struct snd_soc_codec *codec = socdev->codec;
91 if (codec == NULL)
92 return 0;
93 snd_soc_free_pcms(socdev);
94 kfree(codec);
95 return 0;
98 struct snd_soc_codec_device soc_codec_dev_ad73311 = {
99 .probe = ad73311_soc_probe,
100 .remove = ad73311_soc_remove,
102 EXPORT_SYMBOL_GPL(soc_codec_dev_ad73311);
104 MODULE_DESCRIPTION("ASoC ad73311 driver");
105 MODULE_AUTHOR("Cliff Cai ");
106 MODULE_LICENSE("GPL");