~diwic/sound-2.6/filtered

« back to all changes in this revision

Viewing changes to soc/codecs/wm_hubs.c

  • Committer: Takashi Iwai
  • Date: 2011-08-12 17:48:16 UTC
  • mfrom: (2927.505.40)
  • Revision ID: git-v1:2b3eb625c1695190b9e9bad701b026d53606f4c6
Merge branch 'topic/asoc'

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <linux/pm.h>
19
19
#include <linux/i2c.h>
20
20
#include <linux/platform_device.h>
 
21
#include <linux/mfd/wm8994/registers.h>
21
22
#include <sound/core.h>
22
23
#include <sound/pcm.h>
23
24
#include <sound/pcm_params.h>
116
117
{
117
118
        struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
118
119
        s8 offset;
119
 
        u16 reg, reg_l, reg_r, dcs_cfg;
 
120
        u16 reg, reg_l, reg_r, dcs_cfg, dcs_reg;
 
121
 
 
122
        switch (hubs->dcs_readback_mode) {
 
123
        case 2:
 
124
                dcs_reg = WM8994_DC_SERVO_4E;
 
125
                break;
 
126
        default:
 
127
                dcs_reg = WM8993_DC_SERVO_3;
 
128
                break;
 
129
        }
120
130
 
121
131
        /* If we're using a digital only path and have a previously
122
132
         * callibrated DC servo offset stored then use that. */
123
133
        if (hubs->class_w && hubs->class_w_dcs) {
124
134
                dev_dbg(codec->dev, "Using cached DC servo offset %x\n",
125
135
                        hubs->class_w_dcs);
126
 
                snd_soc_write(codec, WM8993_DC_SERVO_3, hubs->class_w_dcs);
 
136
                snd_soc_write(codec, dcs_reg, hubs->class_w_dcs);
127
137
                wait_for_dc_servo(codec,
128
138
                                  WM8993_DCS_TRIG_DAC_WR_0 |
129
139
                                  WM8993_DCS_TRIG_DAC_WR_1);
154
164
                reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2)
155
165
                        & WM8993_DCS_INTEG_CHAN_1_MASK;
156
166
                break;
 
167
        case 2:
157
168
        case 1:
158
 
                reg = snd_soc_read(codec, WM8993_DC_SERVO_3);
 
169
                reg = snd_soc_read(codec, dcs_reg);
159
170
                reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK)
160
171
                        >> WM8993_DCS_DAC_WR_VAL_1_SHIFT;
161
172
                reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK;
168
179
        dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r);
169
180
 
170
181
        /* Apply correction to DC servo result */
171
 
        if (hubs->dcs_codes) {
172
 
                dev_dbg(codec->dev, "Applying %d code DC servo correction\n",
173
 
                        hubs->dcs_codes);
 
182
        if (hubs->dcs_codes_l || hubs->dcs_codes_r) {
 
183
                dev_dbg(codec->dev,
 
184
                        "Applying %d/%d code DC servo correction\n",
 
185
                        hubs->dcs_codes_l, hubs->dcs_codes_r);
174
186
 
175
187
                /* HPOUT1R */
176
188
                offset = reg_r;
177
 
                offset += hubs->dcs_codes;
 
189
                offset += hubs->dcs_codes_r;
178
190
                dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT;
179
191
 
180
192
                /* HPOUT1L */
181
193
                offset = reg_l;
182
 
                offset += hubs->dcs_codes;
 
194
                offset += hubs->dcs_codes_l;
183
195
                dcs_cfg |= (u8)offset;
184
196
 
185
197
                dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg);
186
198
 
187
199
                /* Do it */
188
 
                snd_soc_write(codec, WM8993_DC_SERVO_3, dcs_cfg);
 
200
                snd_soc_write(codec, dcs_reg, dcs_cfg);
189
201
                wait_for_dc_servo(codec,
190
202
                                  WM8993_DCS_TRIG_DAC_WR_0 |
191
203
                                  WM8993_DCS_TRIG_DAC_WR_1);
217
229
 
218
230
        /* If we're applying an offset correction then updating the
219
231
         * callibration would be likely to introduce further offsets. */
220
 
        if (hubs->dcs_codes || hubs->no_series_update)
 
232
        if (hubs->dcs_codes_l || hubs->dcs_codes_r || hubs->no_series_update)
221
233
                return ret;
222
234
 
223
235
        /* Only need to do this if the outputs are active */