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

« back to all changes in this revision

Viewing changes to alsa-kernel/soc/pxa/raumfeld.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:
22
22
#include <linux/gpio.h>
23
23
#include <sound/pcm.h>
24
24
#include <sound/soc.h>
25
 
#include <sound/soc-dapm.h>
26
25
 
27
26
#include <asm/mach-types.h>
28
27
 
29
 
#include "../codecs/cs4270.h"
30
 
#include "../codecs/ak4104.h"
31
 
#include "pxa2xx-pcm.h"
32
28
#include "pxa-ssp.h"
33
29
 
34
30
#define GPIO_SPDIF_RESET        (38)
71
67
static int raumfeld_cs4270_startup(struct snd_pcm_substream *substream)
72
68
{
73
69
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
74
 
        struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
 
70
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
75
71
 
76
72
        /* set freq to 0 to enable all possible codec sample rates */
77
73
        return snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
80
76
static void raumfeld_cs4270_shutdown(struct snd_pcm_substream *substream)
81
77
{
82
78
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
83
 
        struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
 
79
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
84
80
 
85
81
        /* set freq to 0 to enable all possible codec sample rates */
86
82
        snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
90
86
                                     struct snd_pcm_hw_params *params)
91
87
{
92
88
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
93
 
        struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
94
 
        struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
 
89
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
 
90
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
95
91
        unsigned int fmt, clk = 0;
96
92
        int ret = 0;
97
93
 
167
163
        return 0;
168
164
}
169
165
 
170
 
static struct snd_soc_dai_link raumfeld_line_dai = {
171
 
        .name           = "CS4270",
172
 
        .stream_name    = "CS4270",
173
 
        .cpu_dai        = &pxa_ssp_dai[PXA_DAI_SSP1],
174
 
        .codec_dai      = &cs4270_dai,
175
 
        .ops            = &raumfeld_cs4270_ops,
176
 
};
177
 
 
178
 
static struct snd_soc_card snd_soc_line_raumfeld = {
179
 
        .name           = "Raumfeld analog",
180
 
        .platform       = &pxa2xx_soc_platform,
181
 
        .dai_link       = &raumfeld_line_dai,
182
 
        .suspend_post   = raumfeld_line_suspend,
183
 
        .resume_pre     = raumfeld_line_resume,
184
 
        .num_links      = 1,
185
 
};
186
 
 
187
 
 
188
166
/* AK4104 */
189
167
 
190
168
static int raumfeld_ak4104_hw_params(struct snd_pcm_substream *substream,
191
169
                                     struct snd_pcm_hw_params *params)
192
170
{
193
171
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
194
 
        struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
195
 
        struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
 
172
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
 
173
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
196
174
        int fmt, ret = 0, clk = 0;
197
175
 
198
176
        switch (params_rate(params)) {
247
225
        .hw_params = raumfeld_ak4104_hw_params,
248
226
};
249
227
 
250
 
static struct snd_soc_dai_link raumfeld_spdif_dai = {
 
228
static struct snd_soc_dai_link raumfeld_dai[] = {
 
229
{
251
230
        .name           = "ak4104",
252
231
        .stream_name    = "Playback",
253
 
        .cpu_dai        = &pxa_ssp_dai[PXA_DAI_SSP2],
254
 
        .codec_dai      = &ak4104_dai,
 
232
        .cpu_dai_name = "pxa-ssp-dai.1",
 
233
        .codec_dai_name = "ak4104-hifi",
 
234
        .platform_name = "pxa-pcm-audio",
255
235
        .ops            = &raumfeld_ak4104_ops,
256
 
};
257
 
 
258
 
static struct snd_soc_card snd_soc_spdif_raumfeld = {
259
 
        .name           = "Raumfeld S/PDIF",
260
 
        .platform       = &pxa2xx_soc_platform,
261
 
        .dai_link       = &raumfeld_spdif_dai,
262
 
        .num_links      = 1
263
 
};
264
 
 
265
 
/* raumfeld_audio audio subsystem */
266
 
static struct snd_soc_device raumfeld_line_devdata = {
267
 
        .card = &snd_soc_line_raumfeld,
268
 
        .codec_dev = &soc_codec_device_cs4270,
269
 
};
270
 
 
271
 
static struct snd_soc_device raumfeld_spdif_devdata = {
272
 
        .card = &snd_soc_spdif_raumfeld,
273
 
        .codec_dev = &soc_codec_device_ak4104,
274
 
};
275
 
 
276
 
static struct platform_device *raumfeld_audio_line_device;
277
 
static struct platform_device *raumfeld_audio_spdif_device;
 
236
        .codec_name = "ak4104-codec.0",
 
237
},
 
238
{
 
239
        .name           = "CS4270",
 
240
        .stream_name    = "CS4270",
 
241
        .cpu_dai_name = "pxa-ssp-dai.0",
 
242
        .platform_name = "pxa-pcm-audio",
 
243
        .codec_dai_name = "cs4270-hifi",
 
244
        .codec_name = "cs4270-codec.0-0048",
 
245
        .ops            = &raumfeld_cs4270_ops,
 
246
},};
 
247
 
 
248
static struct snd_soc_card snd_soc_raumfeld = {
 
249
        .name           = "Raumfeld",
 
250
        .dai_link       = raumfeld_dai,
 
251
        .suspend_post   = raumfeld_line_suspend,
 
252
        .resume_pre     = raumfeld_line_resume,
 
253
        .num_links      = ARRAY_SIZE(raumfeld_dai),
 
254
};
 
255
 
 
256
static struct platform_device *raumfeld_audio_device;
278
257
 
279
258
static int __init raumfeld_audio_init(void)
280
259
{
292
271
 
293
272
        set_max9485_clk(MAX9485_MCLK_FREQ_122880);
294
273
 
295
 
        /* LINE */
296
 
        raumfeld_audio_line_device = platform_device_alloc("soc-audio", 0);
297
 
        if (!raumfeld_audio_line_device)
 
274
        /* Register LINE and SPDIF */
 
275
        raumfeld_audio_device = platform_device_alloc("soc-audio", 0);
 
276
        if (!raumfeld_audio_device)
298
277
                return -ENOMEM;
299
278
 
300
 
        platform_set_drvdata(raumfeld_audio_line_device,
301
 
                             &raumfeld_line_devdata);
302
 
        raumfeld_line_devdata.dev = &raumfeld_audio_line_device->dev;
303
 
        ret = platform_device_add(raumfeld_audio_line_device);
304
 
        if (ret)
305
 
                platform_device_put(raumfeld_audio_line_device);
 
279
        platform_set_drvdata(raumfeld_audio_device,
 
280
                             &snd_soc_raumfeld);
 
281
        ret = platform_device_add(raumfeld_audio_device);
306
282
 
307
283
        /* no S/PDIF on Speakers */
308
284
        if (machine_is_raumfeld_speaker())
309
285
                return ret;
310
286
 
311
 
        /* S/PDIF */
312
 
        raumfeld_audio_spdif_device = platform_device_alloc("soc-audio", 1);
313
 
        if (!raumfeld_audio_spdif_device) {
314
 
                platform_device_put(raumfeld_audio_line_device);
315
 
                return -ENOMEM;
316
 
        }
317
 
 
318
 
        platform_set_drvdata(raumfeld_audio_spdif_device,
319
 
                             &raumfeld_spdif_devdata);
320
 
        raumfeld_spdif_devdata.dev = &raumfeld_audio_spdif_device->dev;
321
 
        ret = platform_device_add(raumfeld_audio_spdif_device);
322
 
        if (ret) {
323
 
                platform_device_put(raumfeld_audio_line_device);
324
 
                platform_device_put(raumfeld_audio_spdif_device);
325
 
        }
326
 
 
327
287
        raumfeld_enable_audio(true);
328
288
 
329
289
        return ret;
333
293
{
334
294
        raumfeld_enable_audio(false);
335
295
 
336
 
        platform_device_unregister(raumfeld_audio_line_device);
337
 
 
338
 
        if (machine_is_raumfeld_connector())
339
 
                platform_device_unregister(raumfeld_audio_spdif_device);
 
296
        platform_device_unregister(raumfeld_audio_device);
340
297
 
341
298
        i2c_unregister_device(max9486_client);
342
299