diff options
author | Cliff Cai <cliff.cai@analog.com> | 2008-09-27 04:57:26 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-10-12 20:16:12 -0400 |
commit | 0e77e78410245894e5ebde30dc68ced6daa81bce (patch) | |
tree | 04e6b348169b539373f4963986903f19e6effa7e /sound | |
parent | 5cabc1a8b3acc4babd69f2c91a6ab4468dac6663 (diff) |
ALSA: ASoC codec: AD73311 audio codec driver
Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/Kconfig | 4 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/ad73311.c | 107 | ||||
-rw-r--r-- | sound/soc/codecs/ad73311.h | 90 |
4 files changed, 203 insertions, 0 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index e0b9869df0f1..0507fcf66084 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -3,6 +3,7 @@ config SND_SOC_ALL_CODECS | |||
3 | depends on I2C | 3 | depends on I2C |
4 | select SPI | 4 | select SPI |
5 | select SPI_MASTER | 5 | select SPI_MASTER |
6 | select SND_SOC_AD73311 | ||
6 | select SND_SOC_AK4535 | 7 | select SND_SOC_AK4535 |
7 | select SND_SOC_CS4270 | 8 | select SND_SOC_CS4270 |
8 | select SND_SOC_SSM2602 | 9 | select SND_SOC_SSM2602 |
@@ -34,6 +35,9 @@ config SND_SOC_AC97_CODEC | |||
34 | config SND_SOC_AD1980 | 35 | config SND_SOC_AD1980 |
35 | tristate | 36 | tristate |
36 | 37 | ||
38 | config SND_SOC_AD73311 | ||
39 | tristate | ||
40 | |||
37 | config SND_SOC_AK4535 | 41 | config SND_SOC_AK4535 |
38 | tristate | 42 | tristate |
39 | 43 | ||
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index f977978a3409..07318445a1fd 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | snd-soc-ac97-objs := ac97.o | 1 | snd-soc-ac97-objs := ac97.o |
2 | snd-soc-ad1980-objs := ad1980.o | 2 | snd-soc-ad1980-objs := ad1980.o |
3 | snd-soc-ad73311-objs := ad73311.o | ||
3 | snd-soc-ak4535-objs := ak4535.o | 4 | snd-soc-ak4535-objs := ak4535.o |
4 | snd-soc-cs4270-objs := cs4270.o | 5 | snd-soc-cs4270-objs := cs4270.o |
5 | snd-soc-ssm2602-objs := ssm2602.o | 6 | snd-soc-ssm2602-objs := ssm2602.o |
@@ -20,6 +21,7 @@ snd-soc-wm9713-objs := wm9713.o | |||
20 | 21 | ||
21 | obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o | 22 | obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o |
22 | obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o | 23 | obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o |
24 | obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o | ||
23 | obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o | 25 | obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o |
24 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o | 26 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o |
25 | obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o | 27 | obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o |
diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c new file mode 100644 index 000000000000..37af8607b00a --- /dev/null +++ b/sound/soc/codecs/ad73311.c | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * ad73311.c -- ALSA Soc AD73311 codec support | ||
3 | * | ||
4 | * Copyright: Analog Device Inc. | ||
5 | * Author: Cliff Cai <cliff.cai@analog.com> | ||
6 | * | ||
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. | ||
11 | * | ||
12 | * Revision history | ||
13 | * 25th Sep 2008 Initial version. | ||
14 | */ | ||
15 | |||
16 | #include <linux/init.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/version.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/device.h> | ||
21 | #include <sound/core.h> | ||
22 | #include <sound/pcm.h> | ||
23 | #include <sound/ac97_codec.h> | ||
24 | #include <sound/initval.h> | ||
25 | #include <sound/soc.h> | ||
26 | |||
27 | #include "ad73311.h" | ||
28 | |||
29 | struct snd_soc_dai ad73311_dai = { | ||
30 | .name = "AD73311", | ||
31 | .playback = { | ||
32 | .stream_name = "Playback", | ||
33 | .channels_min = 1, | ||
34 | .channels_max = 1, | ||
35 | .rates = SNDRV_PCM_RATE_8000, | ||
36 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, | ||
37 | .capture = { | ||
38 | .stream_name = "Capture", | ||
39 | .channels_min = 1, | ||
40 | .channels_max = 1, | ||
41 | .rates = SNDRV_PCM_RATE_8000, | ||
42 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, | ||
43 | }; | ||
44 | EXPORT_SYMBOL_GPL(ad73311_dai); | ||
45 | |||
46 | static int ad73311_soc_probe(struct platform_device *pdev) | ||
47 | { | ||
48 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
49 | struct snd_soc_codec *codec; | ||
50 | int ret = 0; | ||
51 | |||
52 | codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | ||
53 | if (codec == NULL) | ||
54 | return -ENOMEM; | ||
55 | mutex_init(&codec->mutex); | ||
56 | codec->name = "AD73311"; | ||
57 | codec->owner = THIS_MODULE; | ||
58 | codec->dai = &ad73311_dai; | ||
59 | codec->num_dai = 1; | ||
60 | socdev->codec = codec; | ||
61 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
62 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
63 | |||
64 | /* register pcms */ | ||
65 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
66 | if (ret < 0) { | ||
67 | printk(KERN_ERR "ad73311: failed to create pcms\n"); | ||
68 | goto pcm_err; | ||
69 | } | ||
70 | |||
71 | ret = snd_soc_register_card(socdev); | ||
72 | if (ret < 0) { | ||
73 | printk(KERN_ERR "ad73311: failed to register card\n"); | ||
74 | goto register_err; | ||
75 | } | ||
76 | |||
77 | return ret; | ||
78 | |||
79 | register_err: | ||
80 | snd_soc_free_pcms(socdev); | ||
81 | pcm_err: | ||
82 | kfree(socdev->codec); | ||
83 | socdev->codec = NULL; | ||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static int ad73311_soc_remove(struct platform_device *pdev) | ||
88 | { | ||
89 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
90 | struct snd_soc_codec *codec = socdev->codec; | ||
91 | |||
92 | if (codec == NULL) | ||
93 | return 0; | ||
94 | snd_soc_free_pcms(socdev); | ||
95 | kfree(codec); | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | struct snd_soc_codec_device soc_codec_dev_ad73311 = { | ||
100 | .probe = ad73311_soc_probe, | ||
101 | .remove = ad73311_soc_remove, | ||
102 | }; | ||
103 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad73311); | ||
104 | |||
105 | MODULE_DESCRIPTION("ASoC ad73311 driver"); | ||
106 | MODULE_AUTHOR("Cliff Cai "); | ||
107 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/ad73311.h b/sound/soc/codecs/ad73311.h new file mode 100644 index 000000000000..507ce0c30edf --- /dev/null +++ b/sound/soc/codecs/ad73311.h | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * File: sound/soc/codec/ad73311.h | ||
3 | * Based on: | ||
4 | * Author: Cliff Cai <cliff.cai@analog.com> | ||
5 | * | ||
6 | * Created: Thur Sep 25, 2008 | ||
7 | * Description: definitions for AD73311 registers | ||
8 | * | ||
9 | * | ||
10 | * Modified: | ||
11 | * Copyright 2006 Analog Devices Inc. | ||
12 | * | ||
13 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or | ||
18 | * (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, see the file COPYING, or write | ||
27 | * to the Free Software Foundation, Inc., | ||
28 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
29 | */ | ||
30 | |||
31 | #ifndef __AD73311_H__ | ||
32 | #define __AD73311_H__ | ||
33 | |||
34 | #define AD_CONTROL 0x8000 | ||
35 | #define AD_DATA 0x0000 | ||
36 | #define AD_READ 0x4000 | ||
37 | #define AD_WRITE 0x0000 | ||
38 | |||
39 | /* Control register A */ | ||
40 | #define CTRL_REG_A (0 << 8) | ||
41 | |||
42 | #define REGA_MODE_PRO 0x00 | ||
43 | #define REGA_MODE_DATA 0x01 | ||
44 | #define REGA_MODE_MIXED 0x03 | ||
45 | #define REGA_DLB 0x04 | ||
46 | #define REGA_SLB 0x08 | ||
47 | #define REGA_DEVC(x) ((x & 0x7) << 4) | ||
48 | #define REGA_RESET 0x80 | ||
49 | |||
50 | /* Control register B */ | ||
51 | #define CTRL_REG_B (1 << 8) | ||
52 | |||
53 | #define REGB_DIRATE(x) (x & 0x3) | ||
54 | #define REGB_SCDIV(x) ((x & 0x3) << 2) | ||
55 | #define REGB_MCDIV(x) ((x & 0x7) << 4) | ||
56 | #define REGB_CEE (1 << 7) | ||
57 | |||
58 | /* Control register C */ | ||
59 | #define CTRL_REG_C (2 << 8) | ||
60 | |||
61 | #define REGC_PUDEV (1 << 0) | ||
62 | #define REGC_PUADC (1 << 3) | ||
63 | #define REGC_PUDAC (1 << 4) | ||
64 | #define REGC_PUREF (1 << 5) | ||
65 | #define REGC_REFUSE (1 << 6) | ||
66 | |||
67 | /* Control register D */ | ||
68 | #define CTRL_REG_D (3 << 8) | ||
69 | |||
70 | #define REGD_IGS(x) (x & 0x7) | ||
71 | #define REGD_RMOD (1 << 3) | ||
72 | #define REGD_OGS(x) ((x & 0x7) << 4) | ||
73 | #define REGD_MUTE (x << 7) | ||
74 | |||
75 | /* Control register E */ | ||
76 | #define CTRL_REG_E (4 << 8) | ||
77 | |||
78 | #define REGE_DA(x) (x & 0x1f) | ||
79 | #define REGE_IBYP (1 << 5) | ||
80 | |||
81 | /* Control register F */ | ||
82 | #define CTRL_REG_F (5 << 8) | ||
83 | |||
84 | #define REGF_SEEN (1 << 5) | ||
85 | #define REGF_INV (1 << 6) | ||
86 | #define REGF_ALB (1 << 7) | ||
87 | |||
88 | extern struct snd_soc_dai ad73311_dai; | ||
89 | extern struct snd_soc_codec_device soc_codec_dev_ad73311; | ||
90 | #endif | ||