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

« back to all changes in this revision

Viewing changes to alsa-kernel/Documentation/soc/codec.txt

  • 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:
27
27
 
28
28
1 - Codec DAI and PCM configuration
29
29
-----------------------------------
30
 
Each codec driver must have a struct snd_soc_codec_dai to define its DAI and
 
30
Each codec driver must have a struct snd_soc_dai_driver to define its DAI and
31
31
PCM capabilities and operations. This struct is exported so that it can be
32
32
registered with the core by your machine driver.
33
33
 
34
34
e.g.
35
35
 
36
 
struct snd_soc_codec_dai wm8731_dai = {
37
 
        .name = "WM8731",
38
 
        /* playback capabilities */
 
36
static struct snd_soc_dai_ops wm8731_dai_ops = {
 
37
        .prepare        = wm8731_pcm_prepare,
 
38
        .hw_params      = wm8731_hw_params,
 
39
        .shutdown       = wm8731_shutdown,
 
40
        .digital_mute   = wm8731_mute,
 
41
        .set_sysclk     = wm8731_set_dai_sysclk,
 
42
        .set_fmt        = wm8731_set_dai_fmt,
 
43
};
 
44
 
 
45
struct snd_soc_dai_driver wm8731_dai = {
 
46
        .name = "wm8731-hifi",
39
47
        .playback = {
40
48
                .stream_name = "Playback",
41
49
                .channels_min = 1,
42
50
                .channels_max = 2,
43
51
                .rates = WM8731_RATES,
44
52
                .formats = WM8731_FORMATS,},
45
 
        /* capture capabilities */
46
53
        .capture = {
47
54
                .stream_name = "Capture",
48
55
                .channels_min = 1,
49
56
                .channels_max = 2,
50
57
                .rates = WM8731_RATES,
51
58
                .formats = WM8731_FORMATS,},
52
 
        /* pcm operations - see section 4 below */
53
 
        .ops = {
54
 
                .prepare = wm8731_pcm_prepare,
55
 
                .hw_params = wm8731_hw_params,
56
 
                .shutdown = wm8731_shutdown,
57
 
        },
58
 
        /* DAI operations - see DAI.txt */
59
 
        .dai_ops = {
60
 
                .digital_mute = wm8731_mute,
61
 
                .set_sysclk = wm8731_set_dai_sysclk,
62
 
                .set_fmt = wm8731_set_dai_fmt,
63
 
        }
 
59
        .ops = &wm8731_dai_ops,
 
60
        .symmetric_rates = 1,
64
61
};
65
 
EXPORT_SYMBOL_GPL(wm8731_dai);
66
62
 
67
63
 
68
64
2 - Codec control IO
143
139
};
144
140
 
145
141
Please refer to the ALSA driver PCM documentation for details.
146
 
http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm
 
142
http://www.alsa-project.org/~iwai/writing-an-alsa-driver/
147
143
 
148
144
 
149
145
5 - DAPM description.
186
182
 
187
183
i.e.
188
184
 
189
 
static int wm8974_mute(struct snd_soc_codec *codec,
190
 
        struct snd_soc_codec_dai *dai, int mute)
 
185
static int wm8974_mute(struct snd_soc_dai *dai, int mute)
191
186
{
192
 
        u16 mute_reg = wm8974_read_reg_cache(codec, WM8974_DAC) & 0xffbf;
193
 
        if(mute)
194
 
                wm8974_write(codec, WM8974_DAC, mute_reg | 0x40);
 
187
        struct snd_soc_codec *codec = dai->codec;
 
188
        u16 mute_reg = snd_soc_read(codec, WM8974_DAC) & 0xffbf;
 
189
 
 
190
        if (mute)
 
191
                snd_soc_write(codec, WM8974_DAC, mute_reg | 0x40);
195
192
        else
196
 
                wm8974_write(codec, WM8974_DAC, mute_reg);
 
193
                snd_soc_write(codec, WM8974_DAC, mute_reg);
197
194
        return 0;
198
195
}