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 #include <linux/init.h>
14 #include <linux/slab.h>
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/device.h>
18 #include <sound/core.h>
19 #include <sound/pcm.h>
20 #include <sound/ac97_codec.h>
21 #include <sound/initval.h>
22 #include <sound/soc.h>
26 struct snd_soc_dai ad73311_dai
= {
29 .stream_name
= "Playback",
32 .rates
= SNDRV_PCM_RATE_8000
,
33 .formats
= SNDRV_PCM_FMTBIT_S16_LE
, },
35 .stream_name
= "Capture",
38 .rates
= SNDRV_PCM_RATE_8000
,
39 .formats
= SNDRV_PCM_FMTBIT_S16_LE
, },
41 EXPORT_SYMBOL_GPL(ad73311_dai
);
43 static int ad73311_soc_probe(struct platform_device
*pdev
)
45 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
46 struct snd_soc_codec
*codec
;
49 codec
= kzalloc(sizeof(struct snd_soc_codec
), GFP_KERNEL
);
52 mutex_init(&codec
->mutex
);
53 codec
->name
= "AD73311";
54 codec
->owner
= THIS_MODULE
;
55 codec
->dai
= &ad73311_dai
;
57 socdev
->card
->codec
= codec
;
58 INIT_LIST_HEAD(&codec
->dapm_widgets
);
59 INIT_LIST_HEAD(&codec
->dapm_paths
);
62 ret
= snd_soc_new_pcms(socdev
, SNDRV_DEFAULT_IDX1
, SNDRV_DEFAULT_STR1
);
64 printk(KERN_ERR
"ad73311: failed to create pcms\n");
71 kfree(socdev
->card
->codec
);
72 socdev
->card
->codec
= NULL
;
76 static int ad73311_soc_remove(struct platform_device
*pdev
)
78 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
79 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
83 snd_soc_free_pcms(socdev
);
88 struct snd_soc_codec_device soc_codec_dev_ad73311
= {
89 .probe
= ad73311_soc_probe
,
90 .remove
= ad73311_soc_remove
,
92 EXPORT_SYMBOL_GPL(soc_codec_dev_ad73311
);
94 static int __init
ad73311_init(void)
96 return snd_soc_register_dai(&ad73311_dai
);
98 module_init(ad73311_init
);
100 static void __exit
ad73311_exit(void)
102 snd_soc_unregister_dai(&ad73311_dai
);
104 module_exit(ad73311_exit
);
106 MODULE_DESCRIPTION("ASoC ad73311 driver");
107 MODULE_AUTHOR("Cliff Cai ");
108 MODULE_LICENSE("GPL");