~ubuntu-branches/ubuntu/precise/alsa-driver/precise

« back to all changes in this revision

Viewing changes to alsa-kernel/soc/codecs/pcm3008.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2011-02-21 18:06:40 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20110221180640-a8p2yxtvgf7xbxub
Tags: 1.0.24+dfsg-0ubuntu1
* New upstream release
* Refreshed patches:
  - distinguish_kernel_makefile_and_source_dirs.patch
  - debian_dfsg_configure.patch
* debian/control: Update Vcs-bzr field to point to new branch location

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#define PCM3008_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |    \
33
33
                       SNDRV_PCM_RATE_48000)
34
34
 
35
 
struct snd_soc_dai pcm3008_dai = {
36
 
        .name = "PCM3008 HiFi",
 
35
static struct snd_soc_dai_driver pcm3008_dai = {
 
36
        .name = "pcm3008-hifi",
37
37
        .playback = {
38
38
                .stream_name = "PCM3008 Playback",
39
39
                .channels_min = 1,
49
49
                .formats = SNDRV_PCM_FMTBIT_S16_LE,
50
50
        },
51
51
};
52
 
EXPORT_SYMBOL_GPL(pcm3008_dai);
53
52
 
54
53
static void pcm3008_gpio_free(struct pcm3008_setup_data *setup)
55
54
{
59
58
        gpio_free(setup->pdda_pin);
60
59
}
61
60
 
62
 
static int pcm3008_soc_probe(struct platform_device *pdev)
 
61
static int pcm3008_soc_probe(struct snd_soc_codec *codec)
63
62
{
64
 
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
65
 
        struct snd_soc_codec *codec;
66
 
        struct pcm3008_setup_data *setup = socdev->codec_data;
 
63
        struct pcm3008_setup_data *setup = codec->dev->platform_data;
67
64
        int ret = 0;
68
65
 
69
66
        printk(KERN_INFO "PCM3008 SoC Audio Codec %s\n", PCM3008_VERSION);
70
67
 
71
 
        socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
72
 
        if (!socdev->card->codec)
73
 
                return -ENOMEM;
74
 
 
75
 
        codec = socdev->card->codec;
76
 
        mutex_init(&codec->mutex);
77
 
 
78
 
        codec->name = "PCM3008";
79
 
        codec->owner = THIS_MODULE;
80
 
        codec->dai = &pcm3008_dai;
81
 
        codec->num_dai = 1;
82
 
        codec->write = NULL;
83
 
        codec->read = NULL;
84
 
        INIT_LIST_HEAD(&codec->dapm_widgets);
85
 
        INIT_LIST_HEAD(&codec->dapm_paths);
86
 
 
87
 
        /* Register PCMs. */
88
 
        ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
89
 
        if (ret < 0) {
90
 
                printk(KERN_ERR "pcm3008: failed to create pcms\n");
91
 
                goto pcm_err;
92
 
        }
93
 
 
94
68
        /* DEM1  DEM0  DE-EMPHASIS_MODE
95
69
         * Low   Low   De-emphasis 44.1 kHz ON
96
70
         * Low   High  De-emphasis OFF
130
104
 
131
105
gpio_err:
132
106
        pcm3008_gpio_free(setup);
133
 
pcm_err:
134
 
        kfree(socdev->card->codec);
135
107
 
136
108
        return ret;
137
109
}
138
110
 
139
 
static int pcm3008_soc_remove(struct platform_device *pdev)
 
111
static int pcm3008_soc_remove(struct snd_soc_codec *codec)
140
112
{
141
 
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
142
 
        struct snd_soc_codec *codec = socdev->card->codec;
143
 
        struct pcm3008_setup_data *setup = socdev->codec_data;
144
 
 
145
 
        if (!codec)
146
 
                return 0;
 
113
        struct pcm3008_setup_data *setup = codec->dev->platform_data;
147
114
 
148
115
        pcm3008_gpio_free(setup);
149
 
        snd_soc_free_pcms(socdev);
150
 
        kfree(socdev->card->codec);
151
 
 
152
116
        return 0;
153
117
}
154
118
 
155
119
#ifdef CONFIG_PM
156
 
static int pcm3008_soc_suspend(struct platform_device *pdev, pm_message_t msg)
 
120
static int pcm3008_soc_suspend(struct snd_soc_codec *codec, pm_message_t msg)
157
121
{
158
 
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
159
 
        struct pcm3008_setup_data *setup = socdev->codec_data;
 
122
        struct pcm3008_setup_data *setup = codec->dev->platform_data;
160
123
 
161
124
        gpio_set_value(setup->pdad_pin, 0);
162
125
        gpio_set_value(setup->pdda_pin, 0);
164
127
        return 0;
165
128
}
166
129
 
167
 
static int pcm3008_soc_resume(struct platform_device *pdev)
 
130
static int pcm3008_soc_resume(struct snd_soc_codec *codec)
168
131
{
169
 
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
170
 
        struct pcm3008_setup_data *setup = socdev->codec_data;
 
132
        struct pcm3008_setup_data *setup = codec->dev->platform_data;
171
133
 
172
134
        gpio_set_value(setup->pdad_pin, 1);
173
135
        gpio_set_value(setup->pdda_pin, 1);
179
141
#define pcm3008_soc_resume NULL
180
142
#endif
181
143
 
182
 
struct snd_soc_codec_device soc_codec_dev_pcm3008 = {
 
144
static struct snd_soc_codec_driver soc_codec_dev_pcm3008 = {
183
145
        .probe =        pcm3008_soc_probe,
184
146
        .remove =       pcm3008_soc_remove,
185
147
        .suspend =      pcm3008_soc_suspend,
186
148
        .resume =       pcm3008_soc_resume,
187
149
};
188
 
EXPORT_SYMBOL_GPL(soc_codec_dev_pcm3008);
189
 
 
190
 
static int __init pcm3008_init(void)
191
 
{
192
 
        return snd_soc_register_dai(&pcm3008_dai);
193
 
}
194
 
module_init(pcm3008_init);
 
150
 
 
151
static int __devinit pcm3008_codec_probe(struct platform_device *pdev)
 
152
{
 
153
        return snd_soc_register_codec(&pdev->dev,
 
154
                        &soc_codec_dev_pcm3008, &pcm3008_dai, 1);
 
155
}
 
156
 
 
157
static int __devexit pcm3008_codec_remove(struct platform_device *pdev)
 
158
{
 
159
        snd_soc_unregister_codec(&pdev->dev);
 
160
        return 0;
 
161
}
 
162
 
 
163
MODULE_ALIAS("platform:pcm3008-codec");
 
164
 
 
165
static struct platform_driver pcm3008_codec_driver = {
 
166
        .probe          = pcm3008_codec_probe,
 
167
        .remove         = __devexit_p(pcm3008_codec_remove),
 
168
        .driver         = {
 
169
                .name   = "pcm3008-codec",
 
170
                .owner  = THIS_MODULE,
 
171
        },
 
172
};
 
173
 
 
174
static int __init pcm3008_modinit(void)
 
175
{
 
176
        return platform_driver_register(&pcm3008_codec_driver);
 
177
}
 
178
module_init(pcm3008_modinit);
195
179
 
196
180
static void __exit pcm3008_exit(void)
197
181
{
198
 
        snd_soc_unregister_dai(&pcm3008_dai);
 
182
        platform_driver_unregister(&pcm3008_codec_driver);
199
183
}
200
184
module_exit(pcm3008_exit);
201
185