~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to sound/soc/omap/sdp4430.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * sdp4430.c  --  SoC audio for TI OMAP4430 SDP
3
3
 *
4
 
 * Author: Misael Lopez Cruz <x0052729@ti.com>
 
4
 * Author: Misael Lopez Cruz <misael.lopez@ti.com>
 
5
 *         Liam Girdwood <lrg@ti.com>
5
6
 *
6
7
 * This program is free software; you can redistribute it and/or
7
8
 * modify it under the terms of the GNU General Public License
21
22
 
22
23
#include <linux/clk.h>
23
24
#include <linux/platform_device.h>
 
25
#include <linux/mfd/twl6040.h>
 
26
#include <linux/i2c.h>
 
27
 
24
28
#include <sound/core.h>
25
 
#include <linux/i2c.h>
26
29
#include <sound/pcm.h>
27
30
#include <sound/pcm_params.h>
28
31
#include <sound/soc.h>
 
32
#include <sound/soc-dapm.h>
29
33
#include <sound/jack.h>
 
34
#include <sound/soc-dsp.h>
30
35
 
31
36
#include <asm/mach-types.h>
32
37
#include <plat/hardware.h>
41
46
 
42
47
#define SDP4430_SND_DEV_ID 0
43
48
 
44
 
#ifdef CONFIG_SND_OMAP_SOC_HDMI
45
 
#include "omap-hdmi.h"
46
 
#endif
47
 
 
48
49
static int twl6040_power_mode;
49
50
static int mcbsp_cfg;
50
 
 
51
51
static struct i2c_client *tps6130x_client;
52
52
static struct i2c_board_info tps6130x_hwmon_info = {
53
53
        I2C_BOARD_INFO("tps6130x", 0x33),
70
70
        return 0;
71
71
}
72
72
 
73
 
static int sdp4430_modem_mcbsp_configure(struct snd_pcm_substream *substream,
74
 
                                         int flag)
75
 
{
76
 
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
77
 
        struct snd_pcm_substream *modem_substream;
78
 
        struct snd_soc_pcm_runtime *modem_rtd;
79
 
        int ret = 0;
80
 
 
81
 
        /* already configured, nothing to do */
82
 
        if (mcbsp_cfg == flag)
83
 
                return ret;
84
 
 
85
 
        if (flag) {
86
 
                modem_substream = snd_soc_get_dai_substream(rtd->card,
87
 
                                        OMAP_ABE_BE_MM_EXT1,
88
 
                                        substream->stream);
89
 
                if (unlikely(modem_substream == NULL)) {
90
 
                        ret = -ENODEV;
91
 
                        goto exit;
92
 
                }
93
 
 
94
 
                modem_rtd = modem_substream->private_data;
95
 
 
96
 
                /* Set cpu DAI configuration */
97
 
                ret = snd_soc_dai_set_fmt(modem_rtd->cpu_dai,
98
 
                                          SND_SOC_DAIFMT_I2S |
99
 
                                          SND_SOC_DAIFMT_NB_NF |
100
 
                                          SND_SOC_DAIFMT_CBM_CFM);
101
 
                if (unlikely(ret < 0)) {
102
 
                        printk(KERN_ERR "can't set Modem cpu DAI configuration\n");
103
 
                        goto exit;
104
 
                }
105
 
                mcbsp_cfg = 1;
106
 
        } else {
107
 
                mcbsp_cfg = 0;
108
 
        }
109
 
 
110
 
exit:
111
 
        return ret;
112
 
}
113
 
 
114
73
static int sdp4430_mcpdm_hw_params(struct snd_pcm_substream *substream,
115
74
        struct snd_pcm_hw_params *params)
116
75
{
117
76
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
118
77
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
119
 
        int clk_id, freq;
120
 
        int ret = 0;
 
78
        struct snd_soc_pcm_runtime *modem_rtd;
 
79
        struct snd_pcm_substream *modem_substream[2];
 
80
        struct snd_soc_dsp_params *dsp_params;
 
81
        int clk_id, freq, ret, stream = substream->stream;
121
82
 
122
83
        if (twl6040_power_mode) {
123
84
                clk_id = TWL6040_SYSCLK_SEL_HPPLL;
134
95
                printk(KERN_ERR "can't set codec system clock\n");
135
96
                return ret;
136
97
        }
137
 
 
138
 
        if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
139
 
                /* set Modem McBSP configuration  */
140
 
                ret = sdp4430_modem_mcbsp_configure(substream, 1);
141
 
        }
142
 
 
143
 
        return ret;
144
 
}
145
 
 
146
 
static int sdp4430_mcpdm_hw_free(struct snd_pcm_substream *substream)
147
 
{
148
 
        int ret = 0;
149
 
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
150
 
 
151
 
        if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
152
 
                /* freed Modem McBSP configuration */
153
 
                ret = sdp4430_modem_mcbsp_configure(substream, 0);
154
 
        }
155
 
 
 
98
        list_for_each_entry(dsp_params, &rtd->dsp[stream].fe_clients, list_fe) {
 
99
 
 
100
                if (dsp_params->fe->cpu_dai->id != ABE_FRONTEND_DAI_MODEM)
 
101
                        continue;
 
102
 
 
103
                if (!mcbsp_cfg) {
 
104
                        modem_substream[stream] =
 
105
                                snd_soc_get_dai_substream(rtd->card,
 
106
                                                        OMAP_ABE_BE_MM_EXT1,
 
107
                                                        substream->stream);
 
108
                        if (modem_substream[stream] == NULL)
 
109
                                return -ENODEV;
 
110
 
 
111
                        modem_rtd = modem_substream[stream]->private_data;
 
112
 
 
113
                        /* Set cpu DAI configuration */
 
114
                        ret = snd_soc_dai_set_fmt(modem_rtd->cpu_dai,
 
115
                                          SND_SOC_DAIFMT_I2S |
 
116
                                          SND_SOC_DAIFMT_NB_NF |
 
117
                                          SND_SOC_DAIFMT_CBM_CFM);
 
118
                        mcbsp_cfg = 1;
 
119
                }
 
120
                if (ret < 0) {
 
121
                        printk(KERN_ERR "can't set Modem cpu DAI configuration\n");
 
122
                        return ret;
 
123
                }
 
124
        }
156
125
        return ret;
157
126
}
158
127
 
159
128
static struct snd_soc_ops sdp4430_mcpdm_ops = {
160
129
        .hw_params = sdp4430_mcpdm_hw_params,
161
 
        .hw_free = sdp4430_mcpdm_hw_free,
162
130
};
163
131
 
164
132
static int sdp4430_mcbsp_hw_params(struct snd_pcm_substream *substream,
221
189
                printk(KERN_ERR "can't set DMIC cpu system clock\n");
222
190
                return ret;
223
191
        }
224
 
 
225
192
        ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_DMIC_CLKDIV, 8);
226
193
        if (ret < 0) {
227
194
                printk(KERN_ERR "can't set DMIC cpu clock divider\n");
228
195
                return ret;
229
196
        }
230
 
 
231
 
        if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
232
 
                /* set Modem McBSP configuration  */
233
 
                ret = sdp4430_modem_mcbsp_configure(substream, 1);
234
 
        }
235
 
 
236
 
        return ret;
237
 
}
238
 
 
239
 
static int sdp4430_dmic_hw_free(struct snd_pcm_substream *substream)
240
 
{
241
 
        int ret = 0;
242
 
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
243
 
 
244
 
        if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
245
 
                /* freed Modem McBSP configuration */
246
 
                ret = sdp4430_modem_mcbsp_configure(substream, 0);
247
 
        }
248
 
 
249
 
        return ret;
 
197
        return 0;
250
198
}
251
199
 
252
200
static struct snd_soc_ops sdp4430_dmic_ops = {
253
201
        .hw_params = sdp4430_dmic_hw_params,
254
 
        .hw_free = sdp4430_dmic_hw_free,
255
202
};
256
203
 
257
204
static int mcbsp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
259
206
{
260
207
        struct snd_interval *channels = hw_param_interval(params,
261
208
                                       SNDRV_PCM_HW_PARAM_CHANNELS);
262
 
        unsigned int be_id;
263
 
 
264
 
        be_id = rtd->dai_link->be_id;
 
209
        unsigned int be_id = rtd->dai_link->be_id;
265
210
 
266
211
        if (be_id == OMAP_ABE_DAI_MM_FM)
267
212
                channels->min = 2;
268
213
        else if (be_id == OMAP_ABE_DAI_BT_VX)
269
214
                channels->min = 1;
270
 
 
271
215
        snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
272
216
                                    SNDRV_PCM_HW_PARAM_FIRST_MASK],
273
217
                                    SNDRV_PCM_FORMAT_S16_LE);
277
221
static int dmic_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
278
222
                        struct snd_pcm_hw_params *params)
279
223
{
 
224
        struct snd_interval *rate = hw_param_interval(params,
 
225
                        SNDRV_PCM_HW_PARAM_RATE);
 
226
 
 
227
        /* The ABE will covert the FE rate to 96k */
 
228
        rate->min = rate->max = 96000;
 
229
 
280
230
        snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
281
231
                                    SNDRV_PCM_HW_PARAM_FIRST_MASK],
282
232
                                    SNDRV_PCM_FORMAT_S32_LE);
330
280
/* SDP4430 machine DAPM */
331
281
static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = {
332
282
        SND_SOC_DAPM_MIC("Ext Mic", NULL),
333
 
        SND_SOC_DAPM_MIC("Ext DMic0", NULL),
334
 
        SND_SOC_DAPM_MIC("Ext DMic1", NULL),
335
 
        SND_SOC_DAPM_MIC("Ext DMic2", NULL),
336
283
        SND_SOC_DAPM_SPK("Ext Spk", NULL),
337
284
        SND_SOC_DAPM_MIC("Headset Mic", NULL),
338
285
        SND_SOC_DAPM_HP("Headset Stereophone", NULL),
339
286
        SND_SOC_DAPM_SPK("Earphone Spk", NULL),
340
287
        SND_SOC_DAPM_INPUT("Aux/FM Stereo In"),
 
288
        SND_SOC_DAPM_MIC("Digital Mic 0", NULL),
 
289
        SND_SOC_DAPM_MIC("Digital Mic 1", NULL),
 
290
        SND_SOC_DAPM_MIC("Digital Mic 2", NULL),
341
291
};
342
292
 
343
293
static const struct snd_soc_dapm_route audio_map[] = {
344
 
        /* External Mics: MAINMIC, SUBMIC and DMICs with bias */
 
294
        /* External Mics: MAINMIC, SUBMIC with bias*/
345
295
        {"MAINMIC", NULL, "Main Mic Bias"},
346
296
        {"SUBMIC", NULL, "Main Mic Bias"},
347
297
        {"Main Mic Bias", NULL, "Ext Mic"},
348
298
 
349
 
        {"DMIC0", NULL, "Digital Mic1 Bias"},
350
 
        {"Digital Mic1 Bias", NULL, "Ext DMic0"},
351
 
 
352
 
        {"DMIC1", NULL, "Digital Mic1 Bias"},
353
 
        {"Digital Mic1 Bias", NULL, "Ext DMic1"},
354
 
 
355
 
        {"DMIC2", NULL, "Digital Mic1 Bias"},
356
 
        {"Digital Mic1 Bias", NULL, "Ext DMic2"},
357
 
 
358
299
        /* External Speakers: HFL, HFR */
359
300
        {"Ext Spk", NULL, "HFL"},
360
301
        {"Ext Spk", NULL, "HFR"},
373
314
        /* Aux/FM Stereo In: AFML, AFMR */
374
315
        {"AFML", NULL, "Aux/FM Stereo In"},
375
316
        {"AFMR", NULL, "Aux/FM Stereo In"},
 
317
 
 
318
        /* Digital Mics: DMic0, DMic1, DMic2 with bias */
 
319
        {"DMIC0", NULL, "Digital Mic1 Bias"},
 
320
        {"Digital Mic1 Bias", NULL, "Digital Mic 0"},
 
321
 
 
322
        {"DMIC1", NULL, "Digital Mic1 Bias"},
 
323
        {"Digital Mic1 Bias", NULL, "Digital Mic 1"},
 
324
 
 
325
        {"DMIC2", NULL, "Digital Mic1 Bias"},
 
326
        {"Digital Mic1 Bias", NULL, "Digital Mic 2"},
376
327
};
377
328
 
378
 
static int sdp4430_twl6040_init_hs(struct snd_soc_pcm_runtime *rtd)
 
329
static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd)
379
330
{
380
331
        struct snd_soc_codec *codec = rtd->codec;
381
332
        struct snd_soc_dapm_context *dapm = &codec->dapm;
398
349
 
399
350
        /* SDP4430 connected pins */
400
351
        snd_soc_dapm_enable_pin(dapm, "Ext Mic");
401
 
        snd_soc_dapm_enable_pin(dapm, "Ext DMic0");
402
 
        snd_soc_dapm_enable_pin(dapm, "Ext DMic1");
403
 
        snd_soc_dapm_enable_pin(dapm, "Ext DMic2");
404
352
        snd_soc_dapm_enable_pin(dapm, "Ext Spk");
405
353
        snd_soc_dapm_enable_pin(dapm, "AFML");
406
354
        snd_soc_dapm_enable_pin(dapm, "AFMR");
407
 
        snd_soc_dapm_disable_pin(dapm, "Headset Mic");
408
 
        snd_soc_dapm_disable_pin(dapm, "Headset Stereophone");
 
355
        snd_soc_dapm_enable_pin(dapm, "Headset Mic");
 
356
        snd_soc_dapm_enable_pin(dapm, "Headset Stereophone");
409
357
 
410
 
        /* allow modem audio paths to run during suspend */
 
358
        /* allow audio paths from the audio modem to run during suspend */
411
359
        snd_soc_dapm_ignore_suspend(dapm, "Ext Mic");
412
 
        snd_soc_dapm_ignore_suspend(dapm, "Ext DMic0");
413
 
        snd_soc_dapm_ignore_suspend(dapm, "Ext DMic1");
414
 
        snd_soc_dapm_ignore_suspend(dapm, "Ext DMic2");
415
360
        snd_soc_dapm_ignore_suspend(dapm, "Ext Spk");
416
361
        snd_soc_dapm_ignore_suspend(dapm, "AFML");
417
362
        snd_soc_dapm_ignore_suspend(dapm, "AFMR");
418
363
        snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
419
364
        snd_soc_dapm_ignore_suspend(dapm, "Headset Stereophone");
 
365
        snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 0");
 
366
        snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 1");
 
367
        snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 2");
420
368
 
421
369
        ret = snd_soc_dapm_sync(dapm);
422
370
        if (ret)
442
390
        return ret;
443
391
}
444
392
 
445
 
static int sdp4430_twl6040_init_hf(struct snd_soc_pcm_runtime *rtd)
 
393
static int sdp4430_twl6040_dl2_init(struct snd_soc_pcm_runtime *rtd)
446
394
{
447
 
        /* wait 500 ms before switching of HS power */
 
395
        /* wait 500 ms before switching of HF power */
448
396
        rtd->pmdown_time = 500;
 
397
 
449
398
        return 0;
450
399
}
451
400
 
 
401
/* SDP4430 digital microphones DAPM */
 
402
static const struct snd_soc_dapm_widget sdp4430_dmic_dapm_widgets[] = {
 
403
        SND_SOC_DAPM_MIC("Digital Mic Legacy", NULL),
 
404
};
 
405
 
 
406
static const struct snd_soc_dapm_route dmic_audio_map[] = {
 
407
        {"DMic", NULL, "Digital Mic1 Bias"},
 
408
        {"Digital Mic1 Bias", NULL, "Digital Mic Legacy"},
 
409
};
 
410
 
 
411
static int sdp4430_dmic_init(struct snd_soc_pcm_runtime *rtd)
 
412
{
 
413
        struct snd_soc_codec *codec = rtd->codec;
 
414
        struct snd_soc_dapm_context *dapm = &codec->dapm;
 
415
        int ret;
 
416
 
 
417
        ret = snd_soc_dapm_new_controls(dapm, sdp4430_dmic_dapm_widgets,
 
418
                                ARRAY_SIZE(sdp4430_dmic_dapm_widgets));
 
419
        if (ret)
 
420
                return ret;
 
421
 
 
422
        ret = snd_soc_dapm_add_routes(dapm, dmic_audio_map,
 
423
                                ARRAY_SIZE(dmic_audio_map));
 
424
        if (ret)
 
425
                return ret;
 
426
 
 
427
        snd_soc_dapm_enable_pin(dapm, "Digital Mic Legacy");
 
428
 
 
429
        ret = snd_soc_dapm_sync(dapm);
 
430
 
 
431
        return ret;
 
432
}
 
433
 
452
434
/* TODO: make this a separate BT CODEC driver or DUMMY */
453
435
static struct snd_soc_dai_driver dai[] = {
454
436
{
494
476
                .stream_name = "Playback",
495
477
                .channels_min = 2,
496
478
                .channels_max = 8,
497
 
                .rates = SNDRV_PCM_RATE_48000,
498
 
                .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 
479
                .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
 
480
                                SNDRV_PCM_RATE_48000,
 
481
                .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
499
482
        },
500
483
},
501
484
};
502
485
 
503
486
static const char *mm1_be[] = {
504
 
        OMAP_ABE_BE_PDM_DL1,
505
 
        OMAP_ABE_BE_PDM_UL1,
506
 
        OMAP_ABE_BE_PDM_DL2,
507
 
        OMAP_ABE_BE_BT_VX,
508
 
        OMAP_ABE_BE_MM_EXT0,
509
 
        OMAP_ABE_BE_DMIC0,
510
 
        OMAP_ABE_BE_DMIC1,
511
 
        OMAP_ABE_BE_DMIC2,
 
487
                OMAP_ABE_BE_PDM_DL1,
 
488
                OMAP_ABE_BE_PDM_UL1,
 
489
                OMAP_ABE_BE_PDM_DL2,
 
490
                OMAP_ABE_BE_BT_VX,
 
491
                OMAP_ABE_BE_MM_EXT0,
 
492
                OMAP_ABE_BE_DMIC0,
 
493
                OMAP_ABE_BE_DMIC1,
 
494
                OMAP_ABE_BE_DMIC2,
 
495
};
 
496
 
 
497
struct snd_soc_dsp_link fe_media = {
 
498
        .supported_be   = mm1_be,
 
499
        .num_be                 = ARRAY_SIZE(mm1_be),
 
500
        .fe_playback_channels   = 2,
 
501
        .fe_capture_channels    = 8,
 
502
        .trigger =
 
503
                {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE},
512
504
};
513
505
 
514
506
static const char *mm2_be[] = {
515
 
        OMAP_ABE_BE_PDM_UL1,
516
 
        OMAP_ABE_BE_BT_VX,
517
 
        OMAP_ABE_BE_MM_EXT0,
518
 
        OMAP_ABE_BE_DMIC0,
519
 
        OMAP_ABE_BE_DMIC1,
520
 
        OMAP_ABE_BE_DMIC2,
 
507
                OMAP_ABE_BE_PDM_UL1,
 
508
                OMAP_ABE_BE_BT_VX,
 
509
                OMAP_ABE_BE_MM_EXT0,
 
510
                OMAP_ABE_BE_DMIC0,
 
511
                OMAP_ABE_BE_DMIC1,
 
512
                OMAP_ABE_BE_DMIC2,
 
513
};
 
514
 
 
515
struct snd_soc_dsp_link fe_media_capture = {
 
516
        .supported_be   = mm2_be,
 
517
        .num_be                 = ARRAY_SIZE(mm2_be),
 
518
        .fe_capture_channels    = 8,
 
519
        .trigger =
 
520
                {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE},
521
521
};
522
522
 
523
523
static const char *tones_be[] = {
524
 
        OMAP_ABE_BE_PDM_DL1,
525
 
        OMAP_ABE_BE_PDM_DL2,
526
 
        OMAP_ABE_BE_BT_VX,
527
 
        OMAP_ABE_BE_MM_EXT0,
 
524
                OMAP_ABE_BE_PDM_DL1,
 
525
                OMAP_ABE_BE_PDM_DL2,
 
526
                OMAP_ABE_BE_BT_VX,
 
527
                OMAP_ABE_BE_MM_EXT0,
 
528
};
 
529
 
 
530
struct snd_soc_dsp_link fe_tones = {
 
531
        .supported_be   = tones_be,
 
532
        .num_be                 = ARRAY_SIZE(tones_be),
 
533
        .fe_playback_channels   = 2,
 
534
        .trigger =
 
535
                {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE},
528
536
};
529
537
 
530
538
static const char *vib_be[] = {
531
 
        OMAP_ABE_BE_PDM_VIB,
 
539
                OMAP_ABE_BE_PDM_VIB,
 
540
};
 
541
 
 
542
struct snd_soc_dsp_link fe_vib = {
 
543
        .supported_be   = vib_be,
 
544
        .num_be                 = ARRAY_SIZE(vib_be),
 
545
        .fe_playback_channels   = 2,
 
546
        .trigger =
 
547
                {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE},
532
548
};
533
549
 
534
550
static const char *modem_be[] = {
535
 
        OMAP_ABE_BE_PDM_DL1,
536
 
        OMAP_ABE_BE_PDM_UL1,
537
 
        OMAP_ABE_BE_PDM_DL2,
538
 
        OMAP_ABE_BE_BT_VX,
539
 
        OMAP_ABE_BE_DMIC0,
540
 
        OMAP_ABE_BE_DMIC1,
541
 
        OMAP_ABE_BE_DMIC2,
 
551
                OMAP_ABE_BE_PDM_DL1,
 
552
                OMAP_ABE_BE_PDM_UL1,
 
553
                OMAP_ABE_BE_PDM_DL2,
 
554
                OMAP_ABE_BE_BT_VX,
 
555
                OMAP_ABE_BE_DMIC0,
 
556
                OMAP_ABE_BE_DMIC1,
 
557
                OMAP_ABE_BE_DMIC2,
 
558
};
 
559
 
 
560
struct snd_soc_dsp_link fe_modem = {
 
561
        .supported_be   = modem_be,
 
562
        .num_be                 = ARRAY_SIZE(modem_be),
 
563
        .fe_playback_channels   = 2,
 
564
        .fe_capture_channels    = 2,
 
565
        .trigger =
 
566
                {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE},
542
567
};
543
568
 
544
569
static const char *mm_lp_be[] = {
545
 
        OMAP_ABE_BE_PDM_DL1,
546
 
        OMAP_ABE_BE_PDM_DL2,
547
 
        OMAP_ABE_BE_BT_VX,
548
 
        OMAP_ABE_BE_MM_EXT0,
 
570
                OMAP_ABE_BE_PDM_DL1,
 
571
                OMAP_ABE_BE_PDM_DL2,
 
572
                OMAP_ABE_BE_BT_VX,
 
573
                OMAP_ABE_BE_MM_EXT0,
549
574
};
550
575
 
 
576
struct snd_soc_dsp_link fe_lp_media = {
 
577
        .supported_be   = mm_lp_be,
 
578
        .num_be                 = ARRAY_SIZE(mm_lp_be),
 
579
        .fe_playback_channels   = 2,
 
580
        .trigger =
 
581
                {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE},
 
582
};
551
583
/* Digital audio interface glue - connects codec <--> CPU */
 
584
 
 
585
#if 0
 
586
static struct snd_soc_dai_link sdp4430_dai = {
 
587
        .name = "TWL6040",
 
588
        .stream_name = "TWL6040",
 
589
        .cpu_dai_name ="omap-mcpdm-dai",
 
590
        .codec_dai_name = "twl6040-hifi",
 
591
        .platform_name = "omap-pcm-audio",
 
592
        .codec_name = "twl6040-codec",
 
593
        .init = sdp4430_twl6040_init,
 
594
        .ops = &sdp4430_ops,
 
595
};
 
596
 
 
597
#endif
 
598
 
 
599
static struct snd_soc_dai_link sdp4430_dai[] = {
 
600
 
 
601
/*
 
602
 * Frontend DAIs - i.e. userspace visible interfaces (ALSA PCMs)
 
603
 */
 
604
 
 
605
        {
 
606
                .name = "SDP4430 Media",
 
607
                .stream_name = "Multimedia",
 
608
 
 
609
                /* ABE components - MM-UL & MM_DL */
 
610
                .cpu_dai_name = "MultiMedia1",
 
611
                .platform_name = "omap-pcm-audio",
 
612
 
 
613
                .dynamic = 1, /* BE is dynamic */
 
614
                .dsp_link = &fe_media,
 
615
        },
 
616
        {
 
617
                .name = "SDP4430 Media Capture",
 
618
                .stream_name = "Multimedia Capture",
 
619
 
 
620
                /* ABE components - MM-UL2 */
 
621
                .cpu_dai_name = "MultiMedia2",
 
622
                .platform_name = "omap-pcm-audio",
 
623
 
 
624
                .dynamic = 1, /* BE is dynamic */
 
625
                .dsp_link = &fe_media_capture,
 
626
        },
 
627
        {
 
628
                .name = "SDP4430 Voice",
 
629
                .stream_name = "Voice",
 
630
 
 
631
                /* ABE components - VX-UL & VX-DL */
 
632
                .cpu_dai_name = "Voice",
 
633
                .platform_name = "omap-pcm-audio",
 
634
 
 
635
                .dynamic = 1, /* BE is dynamic */
 
636
                .dsp_link = &fe_media,
 
637
                .no_host_mode = SND_SOC_DAI_LINK_OPT_HOST,
 
638
        },
 
639
        {
 
640
                .name = "SDP4430 Tones Playback",
 
641
                .stream_name = "Tone Playback",
 
642
 
 
643
                /* ABE components - TONES_DL */
 
644
                .cpu_dai_name = "Tones",
 
645
                .platform_name = "omap-pcm-audio",
 
646
 
 
647
                .dynamic = 1, /* BE is dynamic */
 
648
                .dsp_link = &fe_tones,
 
649
        },
 
650
        {
 
651
                .name = "SDP4430 Vibra Playback",
 
652
                .stream_name = "VIB-DL",
 
653
 
 
654
                /* ABE components - DMIC UL 2 */
 
655
                .cpu_dai_name = "Vibra",
 
656
                .platform_name = "omap-pcm-audio",
 
657
 
 
658
                .dynamic = 1, /* BE is dynamic */
 
659
                .dsp_link = &fe_vib,
 
660
        },
 
661
        {
 
662
                .name = "SDP4430 MODEM",
 
663
                .stream_name = "MODEM",
 
664
 
 
665
                /* ABE components - MODEM <-> McBSP2 */
 
666
                .cpu_dai_name = "MODEM",
 
667
                .platform_name = "aess",
 
668
 
 
669
                .dynamic = 1, /* BE is dynamic */
 
670
                .dsp_link = &fe_modem,
 
671
                .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
 
672
                .ignore_suspend = 1,
 
673
        },
 
674
        {
 
675
                .name = "SDP4430 Media LP",
 
676
                .stream_name = "Multimedia",
 
677
 
 
678
                /* ABE components - MM-DL (mmap) */
 
679
                .cpu_dai_name = "MultiMedia1 LP",
 
680
                .platform_name = "aess",
 
681
 
 
682
                .dynamic = 1, /* BE is dynamic */
 
683
                .dsp_link = &fe_lp_media,
 
684
        },
 
685
        {
 
686
                .name = "Legacy McBSP",
 
687
                .stream_name = "Multimedia",
 
688
 
 
689
                /* ABE components - MCBSP2 - MM-EXT */
 
690
                .cpu_dai_name = "omap-mcbsp-dai.1",
 
691
                .platform_name = "omap-pcm-audio",
 
692
 
 
693
                /* FM */
 
694
                .codec_dai_name = "FM Digital",
 
695
 
 
696
                .no_codec = 1, /* TODO: have a dummy CODEC */
 
697
                .ops = &sdp4430_mcbsp_ops,
 
698
        },
 
699
        {
 
700
                .name = "Legacy McPDM",
 
701
                .stream_name = "Headset Playback",
 
702
 
 
703
                /* ABE components - DL1 */
 
704
                .cpu_dai_name = "mcpdm-dl",
 
705
                .platform_name = "omap-pcm-audio",
 
706
 
 
707
                /* Phoenix - DL1 DAC */
 
708
                .codec_dai_name =  "twl6040-dl1",
 
709
                .codec_name = "twl6040-codec",
 
710
 
 
711
                .ops = &sdp4430_mcpdm_ops,
 
712
        },
 
713
        {
 
714
                .name = "Legacy DMIC",
 
715
                .stream_name = "DMIC Capture",
 
716
 
 
717
                /* ABE components - DMIC0 */
 
718
                .cpu_dai_name = "omap-dmic-dai-0",
 
719
                .platform_name = "omap-pcm-audio",
 
720
 
 
721
                /* DMIC codec */
 
722
                .codec_dai_name = "dmic-hifi",
 
723
                .codec_name = "dmic-codec.0",
 
724
 
 
725
                .init = sdp4430_dmic_init,
 
726
                .ops = &sdp4430_dmic_ops,
 
727
        },
 
728
 
 
729
/*
 
730
 * Backend DAIs - i.e. dynamically matched interfaces, invisible to userspace.
 
731
 * Matched to above interfaces at runtime, based upon use case.
 
732
 */
 
733
 
 
734
        {
 
735
                .name = OMAP_ABE_BE_PDM_DL1,
 
736
                .stream_name = "HS Playback",
 
737
 
 
738
                /* ABE components - DL1 */
 
739
                .cpu_dai_name = "mcpdm-dl1",
 
740
                .platform_name = "aess",
 
741
 
 
742
                /* Phoenix - DL1 DAC */
 
743
                .codec_dai_name =  "twl6040-dl1",
 
744
                .codec_name = "twl6040-codec",
 
745
 
 
746
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
747
                .init = sdp4430_twl6040_init,
 
748
                .ops = &sdp4430_mcpdm_ops,
 
749
                .be_id = OMAP_ABE_DAI_PDM_DL1,
 
750
        },
 
751
        {
 
752
                .name = OMAP_ABE_BE_PDM_UL1,
 
753
                .stream_name = "Analog Capture",
 
754
 
 
755
                /* ABE components - UL1 */
 
756
                .cpu_dai_name = "mcpdm-ul1",
 
757
                .platform_name = "aess",
 
758
 
 
759
                /* Phoenix - UL ADC */
 
760
                .codec_dai_name =  "twl6040-ul",
 
761
                .codec_name = "twl6040-codec",
 
762
 
 
763
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
764
                .ops = &sdp4430_mcpdm_ops,
 
765
                .be_id = OMAP_ABE_DAI_PDM_UL,
 
766
        },
 
767
        {
 
768
                .name = OMAP_ABE_BE_PDM_DL2,
 
769
                .stream_name = "HF Playback",
 
770
 
 
771
                /* ABE components - DL2 */
 
772
                .cpu_dai_name = "mcpdm-dl2",
 
773
                .platform_name = "aess",
 
774
 
 
775
                /* Phoenix - DL2 DAC */
 
776
                .codec_dai_name =  "twl6040-dl2",
 
777
                .codec_name = "twl6040-codec",
 
778
 
 
779
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
780
                .init = sdp4430_twl6040_dl2_init,
 
781
                .ops = &sdp4430_mcpdm_ops,
 
782
                .be_id = OMAP_ABE_DAI_PDM_DL2,
 
783
        },
 
784
        {
 
785
                .name = OMAP_ABE_BE_PDM_VIB,
 
786
                .stream_name = "Vibra",
 
787
 
 
788
                /* ABE components - VIB1 DL */
 
789
                .cpu_dai_name = "mcpdm-vib",
 
790
                .platform_name = "aess",
 
791
 
 
792
                /* Phoenix - PDM to PWM */
 
793
                .codec_dai_name =  "twl6040-vib",
 
794
                .codec_name = "twl6040-codec",
 
795
 
 
796
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
797
                .ops = &sdp4430_mcpdm_ops,
 
798
                .be_id = OMAP_ABE_DAI_PDM_VIB,
 
799
        },
 
800
        {
 
801
                .name = OMAP_ABE_BE_BT_VX,
 
802
                .stream_name = "BT",
 
803
 
 
804
                /* ABE components - MCBSP1 - BT-VX */
 
805
                .cpu_dai_name = "omap-mcbsp-dai.0",
 
806
                .platform_name = "aess",
 
807
 
 
808
                /* Bluetooth */
 
809
                .codec_dai_name = "Bluetooth",
 
810
 
 
811
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
812
                .no_codec = 1, /* TODO: have a dummy CODEC */
 
813
                .be_hw_params_fixup = mcbsp_be_hw_params_fixup,
 
814
                .ops = &sdp4430_mcbsp_ops,
 
815
                .be_id = OMAP_ABE_DAI_BT_VX,
 
816
        },
 
817
        {
 
818
                .name = OMAP_ABE_BE_MM_EXT0,
 
819
                .stream_name = "FM",
 
820
 
 
821
                /* ABE components - MCBSP2 - MM-EXT */
 
822
                .cpu_dai_name = "omap-mcbsp-dai.1",
 
823
                .platform_name = "aess",
 
824
 
 
825
                /* FM */
 
826
                .codec_dai_name = "FM Digital",
 
827
 
 
828
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
829
                .no_codec = 1, /* TODO: have a dummy CODEC */
 
830
                .be_hw_params_fixup = mcbsp_be_hw_params_fixup,
 
831
                .ops = &sdp4430_mcbsp_ops,
 
832
                .be_id = OMAP_ABE_DAI_MM_FM,
 
833
        },
 
834
        {
 
835
                .name = OMAP_ABE_BE_MM_EXT1,
 
836
                .stream_name = "MODEM",
 
837
 
 
838
                /* ABE components - MCBSP2 - MM-EXT */
 
839
                .cpu_dai_name = "omap-mcbsp-dai.1",
 
840
                .platform_name = "aess",
 
841
 
 
842
                /* MODEM */
 
843
                .codec_dai_name = "MODEM",
 
844
 
 
845
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
846
                .no_codec = 1, /* TODO: have a dummy CODEC */
 
847
                .be_hw_params_fixup = mcbsp_be_hw_params_fixup,
 
848
                .ops = &sdp4430_mcbsp_ops,
 
849
                .be_id = OMAP_ABE_DAI_MODEM,
 
850
                .ignore_suspend = 1,
 
851
        },
 
852
        {
 
853
                .name = OMAP_ABE_BE_DMIC0,
 
854
                .stream_name = "DMIC0",
 
855
 
 
856
                /* ABE components - DMIC UL 1 */
 
857
                .cpu_dai_name = "omap-dmic-abe-dai-0",
 
858
                .platform_name = "aess",
 
859
 
 
860
                /* DMIC 0 */
 
861
                .codec_dai_name = "dmic-hifi",
 
862
                .codec_name = "dmic-codec.0",
 
863
                .ops = &sdp4430_dmic_ops,
 
864
 
 
865
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
866
                .be_hw_params_fixup = dmic_be_hw_params_fixup,
 
867
                .be_id = OMAP_ABE_DAI_DMIC0,
 
868
        },
 
869
        {
 
870
                .name = OMAP_ABE_BE_DMIC1,
 
871
                .stream_name = "DMIC1",
 
872
 
 
873
                /* ABE components - DMIC UL 1 */
 
874
                .cpu_dai_name = "omap-dmic-abe-dai-1",
 
875
                .platform_name = "aess",
 
876
 
 
877
                /* DMIC 1 */
 
878
                .codec_dai_name = "dmic-hifi",
 
879
                .codec_name = "dmic-codec.1",
 
880
                .ops = &sdp4430_dmic_ops,
 
881
 
 
882
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
883
                .be_hw_params_fixup = dmic_be_hw_params_fixup,
 
884
                .be_id = OMAP_ABE_DAI_DMIC1,
 
885
        },
 
886
        {
 
887
                .name = OMAP_ABE_BE_DMIC2,
 
888
                .stream_name = "DMIC2",
 
889
 
 
890
                /* ABE components - DMIC UL 2 */
 
891
                .cpu_dai_name = "omap-dmic-abe-dai-2",
 
892
                .platform_name = "aess",
 
893
 
 
894
                /* DMIC 2 */
 
895
                .codec_dai_name = "dmic-hifi",
 
896
                .codec_name = "dmic-codec.2",
 
897
                .ops = &sdp4430_dmic_ops,
 
898
 
 
899
                .no_pcm = 1, /* don't create ALSA pcm for this */
 
900
                .be_hw_params_fixup = dmic_be_hw_params_fixup,
 
901
                .be_id = OMAP_ABE_DAI_DMIC2,
 
902
        },
 
903
};
 
904
 
 
905
 
 
906
#if 0
552
907
static struct snd_soc_dai_link sdp4430_dai[] = {
553
908
 
554
909
/*
653
1008
                .fe_playback_channels = 2,
654
1009
                .no_host_mode = SND_SOC_DAI_LINK_OPT_HOST,
655
1010
        },
656
 
#ifdef CONFIG_SND_OMAP_SOC_HDMI
657
 
        {
658
 
                .name = "hdmi",
659
 
                .stream_name = "HDMI",
660
 
 
661
 
                .cpu_dai_name = "hdmi-dai",
662
 
                .platform_name = "omap-pcm-audio",
663
 
 
664
 
                /* HDMI*/
665
 
                .codec_dai_name = "HDMI",
666
 
 
667
 
                .no_codec = 1,
668
 
        },
669
 
#endif
670
1011
        {
671
1012
                .name = "Legacy McBSP",
672
1013
                .stream_name = "Multimedia",
896
1237
        },
897
1238
};
898
1239
 
 
1240
#endif
 
1241
 
899
1242
/* Audio machine driver */
900
1243
static struct snd_soc_card snd_soc_sdp4430 = {
901
 
        .name = "SDP4430",
902
 
        .long_name = "TI OMAP4 SDP4430 Board",
 
1244
        .driver_name = "OMAP4",
 
1245
        .long_name = "TI OMAP4 Board",
903
1246
        .dai_link = sdp4430_dai,
904
1247
        .num_links = ARRAY_SIZE(sdp4430_dai),
905
1248
};
906
1249
 
907
1250
static struct platform_device *sdp4430_snd_device;
 
1251
static struct i2c_adapter *adapter;
908
1252
 
909
1253
static int __init sdp4430_soc_init(void)
910
1254
{
911
 
        struct i2c_adapter *adapter;
912
1255
        int ret;
913
1256
 
914
1257
        if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda()) {
916
1259
                return -ENODEV;
917
1260
        }
918
1261
        printk(KERN_INFO "SDP4430 SoC init\n");
 
1262
        if (machine_is_omap_4430sdp())
 
1263
                snd_soc_sdp4430.name = "SDP4430";
 
1264
        else if (machine_is_omap4_panda())
 
1265
                snd_soc_sdp4430.name = "Panda";
919
1266
 
920
1267
        sdp4430_snd_device = platform_device_alloc("soc-audio",
921
1268
                SDP4430_SND_DEV_ID);
924
1271
                return -ENOMEM;
925
1272
        }
926
1273
 
927
 
        snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));
928
 
 
 
1274
        ret = snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));
 
1275
        if (ret < 0)
 
1276
                goto err_dai;
929
1277
        platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);
930
1278
 
931
1279
        ret = platform_device_add(sdp4430_snd_device);
932
1280
        if (ret)
933
 
                goto err;
 
1281
                goto err_dev;
934
1282
 
935
 
        adapter = i2c_get_adapter(1);
936
 
        if (!adapter) {
937
 
                printk(KERN_ERR "can't get i2c adapter\n");
938
 
                return -ENODEV;
939
 
        }
 
1283
        adapter = i2c_get_adapter(1);
 
1284
        if (!adapter) {
 
1285
                printk(KERN_ERR "can't get i2c adapter\n");
 
1286
                ret = -ENODEV;
 
1287
                goto err_adap;
 
1288
        }
940
1289
 
941
1290
        tps6130x_client = i2c_new_device(adapter, &tps6130x_hwmon_info);
942
1291
        if (!tps6130x_client) {
943
 
                printk(KERN_ERR "can't add i2c device\n");
944
 
                return -ENODEV;
945
 
        }
 
1292
                printk(KERN_ERR "can't add i2c device\n");
 
1293
                ret = -ENODEV;
 
1294
                goto err_i2c;
 
1295
        }
946
1296
 
947
1297
        /* Only configure the TPS6130x on SDP4430 */
948
1298
        if (machine_is_omap_4430sdp())
950
1300
 
951
1301
        return 0;
952
1302
 
953
 
err:
954
 
        printk(KERN_ERR "Unable to add platform device\n");
 
1303
err_i2c:
 
1304
        i2c_put_adapter(adapter);
 
1305
err_adap:
 
1306
        platform_device_del(sdp4430_snd_device);
 
1307
err_dev:
 
1308
        snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai));
 
1309
err_dai:
955
1310
        platform_device_put(sdp4430_snd_device);
956
1311
        return ret;
957
1312
}
960
1315
static void __exit sdp4430_soc_exit(void)
961
1316
{
962
1317
        platform_device_unregister(sdp4430_snd_device);
 
1318
        snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai));
963
1319
        i2c_unregister_device(tps6130x_client);
 
1320
        i2c_put_adapter(adapter);
964
1321
}
965
1322
module_exit(sdp4430_soc_exit);
966
1323