aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/virtuoso.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-05-13 03:21:48 -0400
committerJaroslav Kysela <perex@perex.cz>2008-05-19 07:19:16 -0400
commitbbbfb5526650cb9d01c5c230a4e3cbbc18474c41 (patch)
treee4e210c41214d6018dd2a623b19f65236d634b51 /sound/pci/oxygen/virtuoso.c
parente58aee95806c9d2bbcfc84cb85ce958e360165ef (diff)
[ALSA] oxygen: simplify DAC volume initialization
When initializing the DAC volume registers, we can just use the generic volume update functions instead of setting the registers manually. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/virtuoso.c')
-rw-r--r--sound/pci/oxygen/virtuoso.c123
1 files changed, 57 insertions, 66 deletions
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 110786b2e3b8..bd9e28583518 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -182,6 +182,28 @@ static void xonar_common_init(struct oxygen *chip)
182 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); 182 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
183} 183}
184 184
185static void update_pcm1796_volume(struct oxygen *chip)
186{
187 unsigned int i;
188
189 for (i = 0; i < 4; ++i) {
190 pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]);
191 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]);
192 }
193}
194
195static void update_pcm1796_mute(struct oxygen *chip)
196{
197 unsigned int i;
198 u8 value;
199
200 value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD;
201 if (chip->dac_mute)
202 value |= PCM1796_MUTE;
203 for (i = 0; i < 4; ++i)
204 pcm1796_write(chip, i, 18, value);
205}
206
185static void xonar_d2_init(struct oxygen *chip) 207static void xonar_d2_init(struct oxygen *chip)
186{ 208{
187 struct xonar_data *data = chip->model_data; 209 struct xonar_data *data = chip->model_data;
@@ -192,14 +214,12 @@ static void xonar_d2_init(struct oxygen *chip)
192 data->pcm1796_oversampling = PCM1796_OS_64; 214 data->pcm1796_oversampling = PCM1796_OS_64;
193 215
194 for (i = 0; i < 4; ++i) { 216 for (i = 0; i < 4; ++i) {
195 pcm1796_write(chip, i, 18, PCM1796_MUTE | PCM1796_DMF_DISABLED |
196 PCM1796_FMT_24_LJUST | PCM1796_ATLD);
197 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 217 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1);
198 pcm1796_write(chip, i, 20, data->pcm1796_oversampling); 218 pcm1796_write(chip, i, 20, data->pcm1796_oversampling);
199 pcm1796_write(chip, i, 21, 0); 219 pcm1796_write(chip, i, 21, 0);
200 pcm1796_write(chip, i, 16, 0x0f); /* set ATL/ATR after ATLD */
201 pcm1796_write(chip, i, 17, 0x0f);
202 } 220 }
221 update_pcm1796_mute(chip); /* set ATLD before ATL/ATR */
222 update_pcm1796_volume(chip);
203 223
204 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT); 224 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT);
205 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT); 225 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT);
@@ -221,6 +241,37 @@ static void xonar_d2x_init(struct oxygen *chip)
221 xonar_d2_init(chip); 241 xonar_d2_init(chip);
222} 242}
223 243
244static void update_cs4362a_volumes(struct oxygen *chip)
245{
246 u8 mute;
247
248 mute = chip->dac_mute ? CS4362A_MUTE : 0;
249 cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute);
250 cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute);
251 cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute);
252 cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute);
253 cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute);
254 cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute);
255}
256
257static void update_cs43xx_volume(struct oxygen *chip)
258{
259 cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2);
260 cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2);
261 update_cs4362a_volumes(chip);
262}
263
264static void update_cs43xx_mute(struct oxygen *chip)
265{
266 u8 reg;
267
268 reg = CS4398_MUTEP_LOW | CS4398_PAMUTE;
269 if (chip->dac_mute)
270 reg |= CS4398_MUTE_B | CS4398_MUTE_A;
271 cs4398_write(chip, 4, reg);
272 update_cs4362a_volumes(chip);
273}
274
224static void xonar_dx_init(struct oxygen *chip) 275static void xonar_dx_init(struct oxygen *chip)
225{ 276{
226 struct xonar_data *data = chip->model_data; 277 struct xonar_data *data = chip->model_data;
@@ -245,9 +296,6 @@ static void xonar_dx_init(struct oxygen *chip)
245 /* configure */ 296 /* configure */
246 cs4398_write(chip, 2, data->cs4398_fm); 297 cs4398_write(chip, 2, data->cs4398_fm);
247 cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L); 298 cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L);
248 cs4398_write(chip, 4, CS4398_MUTEP_LOW | CS4398_PAMUTE);
249 cs4398_write(chip, 5, 0xfe);
250 cs4398_write(chip, 6, 0xfe);
251 cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP | 299 cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP |
252 CS4398_ZERO_CROSS | CS4398_SOFT_RAMP); 300 CS4398_ZERO_CROSS | CS4398_SOFT_RAMP);
253 cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST); 301 cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST);
@@ -256,14 +304,10 @@ static void xonar_dx_init(struct oxygen *chip)
256 cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE); 304 cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE);
257 cs4362a_write(chip, 0x05, 0); 305 cs4362a_write(chip, 0x05, 0);
258 cs4362a_write(chip, 0x06, data->cs4362a_fm); 306 cs4362a_write(chip, 0x06, data->cs4362a_fm);
259 cs4362a_write(chip, 0x07, 0x7f | CS4362A_MUTE);
260 cs4362a_write(chip, 0x08, 0x7f | CS4362A_MUTE);
261 cs4362a_write(chip, 0x09, data->cs4362a_fm); 307 cs4362a_write(chip, 0x09, data->cs4362a_fm);
262 cs4362a_write(chip, 0x0a, 0x7f | CS4362A_MUTE);
263 cs4362a_write(chip, 0x0b, 0x7f | CS4362A_MUTE);
264 cs4362a_write(chip, 0x0c, data->cs4362a_fm); 308 cs4362a_write(chip, 0x0c, data->cs4362a_fm);
265 cs4362a_write(chip, 0x0d, 0x7f | CS4362A_MUTE); 309 update_cs43xx_volume(chip);
266 cs4362a_write(chip, 0x0e, 0x7f | CS4362A_MUTE); 310 update_cs43xx_mute(chip);
267 /* clear power down */ 311 /* clear power down */
268 cs4398_write(chip, 8, CS4398_CPEN); 312 cs4398_write(chip, 8, CS4398_CPEN);
269 cs4362a_write(chip, 0x01, CS4362A_CPEN); 313 cs4362a_write(chip, 0x01, CS4362A_CPEN);
@@ -306,28 +350,6 @@ static void set_pcm1796_params(struct oxygen *chip,
306 pcm1796_write(chip, i, 20, data->pcm1796_oversampling); 350 pcm1796_write(chip, i, 20, data->pcm1796_oversampling);
307} 351}
308 352
309static void update_pcm1796_volume(struct oxygen *chip)
310{
311 unsigned int i;
312
313 for (i = 0; i < 4; ++i) {
314 pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]);
315 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]);
316 }
317}
318
319static void update_pcm1796_mute(struct oxygen *chip)
320{
321 unsigned int i;
322 u8 value;
323
324 value = PCM1796_FMT_24_LJUST | PCM1796_ATLD;
325 if (chip->dac_mute)
326 value |= PCM1796_MUTE;
327 for (i = 0; i < 4; ++i)
328 pcm1796_write(chip, i, 18, value);
329}
330
331static void set_cs53x1_params(struct oxygen *chip, 353static void set_cs53x1_params(struct oxygen *chip,
332 struct snd_pcm_hw_params *params) 354 struct snd_pcm_hw_params *params)
333{ 355{
@@ -366,37 +388,6 @@ static void set_cs43xx_params(struct oxygen *chip,
366 cs4362a_write(chip, 0x0c, data->cs4362a_fm); 388 cs4362a_write(chip, 0x0c, data->cs4362a_fm);
367} 389}
368 390
369static void update_cs4362a_volumes(struct oxygen *chip)
370{
371 u8 mute;
372
373 mute = chip->dac_mute ? CS4362A_MUTE : 0;
374 cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute);
375 cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute);
376 cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute);
377 cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute);
378 cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute);
379 cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute);
380}
381
382static void update_cs43xx_volume(struct oxygen *chip)
383{
384 cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2);
385 cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2);
386 update_cs4362a_volumes(chip);
387}
388
389static void update_cs43xx_mute(struct oxygen *chip)
390{
391 u8 reg;
392
393 reg = CS4398_MUTEP_LOW | CS4398_PAMUTE;
394 if (chip->dac_mute)
395 reg |= CS4398_MUTE_B | CS4398_MUTE_A;
396 cs4398_write(chip, 4, reg);
397 update_cs4362a_volumes(chip);
398}
399
400static void xonar_gpio_changed(struct oxygen *chip) 391static void xonar_gpio_changed(struct oxygen *chip)
401{ 392{
402 struct xonar_data *data = chip->model_data; 393 struct xonar_data *data = chip->model_data;