• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/sound/soc/codecs/
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
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>
23
24#include "ad73311.h"
25
26struct snd_soc_dai ad73311_dai = {
27	.name = "AD73311",
28	.playback = {
29		.stream_name = "Playback",
30		.channels_min = 1,
31		.channels_max = 1,
32		.rates = SNDRV_PCM_RATE_8000,
33		.formats = SNDRV_PCM_FMTBIT_S16_LE, },
34	.capture = {
35		.stream_name = "Capture",
36		.channels_min = 1,
37		.channels_max = 1,
38		.rates = SNDRV_PCM_RATE_8000,
39		.formats = SNDRV_PCM_FMTBIT_S16_LE, },
40};
41EXPORT_SYMBOL_GPL(ad73311_dai);
42
43static int ad73311_soc_probe(struct platform_device *pdev)
44{
45	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
46	struct snd_soc_codec *codec;
47	int ret = 0;
48
49	codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
50	if (codec == NULL)
51		return -ENOMEM;
52	mutex_init(&codec->mutex);
53	codec->name = "AD73311";
54	codec->owner = THIS_MODULE;
55	codec->dai = &ad73311_dai;
56	codec->num_dai = 1;
57	socdev->card->codec = codec;
58	INIT_LIST_HEAD(&codec->dapm_widgets);
59	INIT_LIST_HEAD(&codec->dapm_paths);
60
61	/* register pcms */
62	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
63	if (ret < 0) {
64		printk(KERN_ERR "ad73311: failed to create pcms\n");
65		goto pcm_err;
66	}
67
68	return ret;
69
70pcm_err:
71	kfree(socdev->card->codec);
72	socdev->card->codec = NULL;
73	return ret;
74}
75
76static int ad73311_soc_remove(struct platform_device *pdev)
77{
78	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
79	struct snd_soc_codec *codec = socdev->card->codec;
80
81	if (codec == NULL)
82		return 0;
83	snd_soc_free_pcms(socdev);
84	kfree(codec);
85	return 0;
86}
87
88struct snd_soc_codec_device soc_codec_dev_ad73311 = {
89	.probe = 	ad73311_soc_probe,
90	.remove = 	ad73311_soc_remove,
91};
92EXPORT_SYMBOL_GPL(soc_codec_dev_ad73311);
93
94static int __init ad73311_init(void)
95{
96	return snd_soc_register_dai(&ad73311_dai);
97}
98module_init(ad73311_init);
99
100static void __exit ad73311_exit(void)
101{
102	snd_soc_unregister_dai(&ad73311_dai);
103}
104module_exit(ad73311_exit);
105
106MODULE_DESCRIPTION("ASoC ad73311 driver");
107MODULE_AUTHOR("Cliff Cai ");
108MODULE_LICENSE("GPL");
109