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.
13 * 25th Sep 2008 Initial version.
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>
29 struct snd_soc_dai ad73311_dai = {
32 .stream_name = "Playback",
35 .rates = SNDRV_PCM_RATE_8000,
36 .formats = SNDRV_PCM_FMTBIT_S16_LE, },
38 .stream_name = "Capture",
41 .rates = SNDRV_PCM_RATE_8000,
42 .formats = SNDRV_PCM_FMTBIT_S16_LE, },
44 EXPORT_SYMBOL_GPL(ad73311_dai);
46 static int ad73311_soc_probe(struct platform_device *pdev)
48 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
49 struct snd_soc_codec *codec;
52 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
55 mutex_init(&codec->mutex);
56 codec->name = "AD73311";
57 codec->owner = THIS_MODULE;
58 codec->dai = &ad73311_dai;
60 socdev->codec = codec;
61 INIT_LIST_HEAD(&codec->dapm_widgets);
62 INIT_LIST_HEAD(&codec->dapm_paths);
65 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
67 printk(KERN_ERR "ad73311: failed to create pcms\n");
71 ret = snd_soc_register_card(socdev);
73 printk(KERN_ERR "ad73311: failed to register card\n");
80 snd_soc_free_pcms(socdev);
87 static int ad73311_soc_remove(struct platform_device *pdev)
89 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
90 struct snd_soc_codec *codec = socdev->codec;
94 snd_soc_free_pcms(socdev);
99 struct snd_soc_codec_device soc_codec_dev_ad73311 = {
100 .probe = ad73311_soc_probe,
101 .remove = ad73311_soc_remove,
103 EXPORT_SYMBOL_GPL(soc_codec_dev_ad73311);
105 MODULE_DESCRIPTION("ASoC ad73311 driver");
106 MODULE_AUTHOR("Cliff Cai ");
107 MODULE_LICENSE("GPL");