diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2011-01-10 10:14:52 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-01-10 10:46:31 -0500 |
commit | 5b8bf2a54fb13e40519ee846ce27bc8a2d7a7878 (patch) | |
tree | 2aa57e62574054f6f9d5d8bf5eb55c72c227e787 /sound/pci/oxygen | |
parent | bc29e262c3062682c6099bd455ae8544916f723e (diff) |
ALSA: oxygen: simplify model-specific MCLK handling
Replace the get_i2s_mclk callback with tables of MCLK values. This
simplifies the MCLK-handling code in both the framework and the model-
specific drivers.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r-- | sound/pci/oxygen/oxygen.c | 3 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen.h | 10 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_lib.c | 36 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_pcm.c | 39 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_regs.h | 8 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_cs43xx.c | 3 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_pcm179x.c | 82 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_wm87x6.c | 3 |
8 files changed, 89 insertions, 95 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index fe7ed4fc9f46..784d500c700f 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -568,7 +568,6 @@ static const struct oxygen_model model_generic = { | |||
568 | .mixer_init = generic_wm8785_mixer_init, | 568 | .mixer_init = generic_wm8785_mixer_init, |
569 | .cleanup = generic_cleanup, | 569 | .cleanup = generic_cleanup, |
570 | .resume = generic_resume, | 570 | .resume = generic_resume, |
571 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
572 | .set_dac_params = set_ak4396_params, | 571 | .set_dac_params = set_ak4396_params, |
573 | .set_adc_params = set_wm8785_params, | 572 | .set_adc_params = set_wm8785_params, |
574 | .update_dac_volume = update_ak4396_volume, | 573 | .update_dac_volume = update_ak4396_volume, |
@@ -589,6 +588,8 @@ static const struct oxygen_model model_generic = { | |||
589 | .dac_volume_max = 255, | 588 | .dac_volume_max = 255, |
590 | .function_flags = OXYGEN_FUNCTION_SPI | | 589 | .function_flags = OXYGEN_FUNCTION_SPI | |
591 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | 590 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
591 | .dac_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
592 | .adc_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
592 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 593 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
593 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 594 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
594 | }; | 595 | }; |
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index 70eff3747158..2c5fb9edcb11 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h | |||
@@ -16,6 +16,10 @@ | |||
16 | #define PCM_AC97 5 | 16 | #define PCM_AC97 5 |
17 | #define PCM_COUNT 6 | 17 | #define PCM_COUNT 6 |
18 | 18 | ||
19 | #define OXYGEN_MCLKS(f_single, f_double, f_quad) ((MCLK_##f_single << 0) | \ | ||
20 | (MCLK_##f_double << 2) | \ | ||
21 | (MCLK_##f_quad << 4)) | ||
22 | |||
19 | #define OXYGEN_IO_SIZE 0x100 | 23 | #define OXYGEN_IO_SIZE 0x100 |
20 | 24 | ||
21 | #define OXYGEN_EEPROM_ID 0x434d /* "CM" */ | 25 | #define OXYGEN_EEPROM_ID 0x434d /* "CM" */ |
@@ -81,8 +85,6 @@ struct oxygen_model { | |||
81 | void (*resume)(struct oxygen *chip); | 85 | void (*resume)(struct oxygen *chip); |
82 | void (*pcm_hardware_filter)(unsigned int channel, | 86 | void (*pcm_hardware_filter)(unsigned int channel, |
83 | struct snd_pcm_hardware *hardware); | 87 | struct snd_pcm_hardware *hardware); |
84 | unsigned int (*get_i2s_mclk)(struct oxygen *chip, unsigned int channel, | ||
85 | struct snd_pcm_hw_params *hw_params); | ||
86 | void (*set_dac_params)(struct oxygen *chip, | 88 | void (*set_dac_params)(struct oxygen *chip, |
87 | struct snd_pcm_hw_params *params); | 89 | struct snd_pcm_hw_params *params); |
88 | void (*set_adc_params)(struct oxygen *chip, | 90 | void (*set_adc_params)(struct oxygen *chip, |
@@ -105,6 +107,8 @@ struct oxygen_model { | |||
105 | u8 dac_volume_max; | 107 | u8 dac_volume_max; |
106 | u8 misc_flags; | 108 | u8 misc_flags; |
107 | u8 function_flags; | 109 | u8 function_flags; |
110 | u8 dac_mclks; | ||
111 | u8 adc_mclks; | ||
108 | u16 dac_i2s_format; | 112 | u16 dac_i2s_format; |
109 | u16 adc_i2s_format; | 113 | u16 adc_i2s_format; |
110 | }; | 114 | }; |
@@ -171,8 +175,6 @@ void oxygen_update_spdif_source(struct oxygen *chip); | |||
171 | /* oxygen_pcm.c */ | 175 | /* oxygen_pcm.c */ |
172 | 176 | ||
173 | int oxygen_pcm_init(struct oxygen *chip); | 177 | int oxygen_pcm_init(struct oxygen *chip); |
174 | unsigned int oxygen_default_i2s_mclk(struct oxygen *chip, unsigned int channel, | ||
175 | struct snd_pcm_hw_params *hw_params); | ||
176 | 178 | ||
177 | /* oxygen_io.c */ | 179 | /* oxygen_io.c */ |
178 | 180 | ||
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index c44c91e6fb18..77e1f0805633 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c | |||
@@ -414,28 +414,40 @@ static void oxygen_init(struct oxygen *chip) | |||
414 | (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); | 414 | (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); |
415 | oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); | 415 | oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); |
416 | oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, | 416 | oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, |
417 | OXYGEN_RATE_48000 | chip->model.dac_i2s_format | | 417 | OXYGEN_RATE_48000 | |
418 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | | 418 | chip->model.dac_i2s_format | |
419 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | 419 | OXYGEN_I2S_MCLK(chip->model.dac_mclks) | |
420 | OXYGEN_I2S_BITS_16 | | ||
421 | OXYGEN_I2S_MASTER | | ||
422 | OXYGEN_I2S_BCLK_64); | ||
420 | if (chip->model.device_config & CAPTURE_0_FROM_I2S_1) | 423 | if (chip->model.device_config & CAPTURE_0_FROM_I2S_1) |
421 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, | 424 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, |
422 | OXYGEN_RATE_48000 | chip->model.adc_i2s_format | | 425 | OXYGEN_RATE_48000 | |
423 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | | 426 | chip->model.adc_i2s_format | |
424 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | 427 | OXYGEN_I2S_MCLK(chip->model.adc_mclks) | |
428 | OXYGEN_I2S_BITS_16 | | ||
429 | OXYGEN_I2S_MASTER | | ||
430 | OXYGEN_I2S_BCLK_64); | ||
425 | else | 431 | else |
426 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, | 432 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, |
427 | OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); | 433 | OXYGEN_I2S_MASTER | |
434 | OXYGEN_I2S_MUTE_MCLK); | ||
428 | if (chip->model.device_config & (CAPTURE_0_FROM_I2S_2 | | 435 | if (chip->model.device_config & (CAPTURE_0_FROM_I2S_2 | |
429 | CAPTURE_2_FROM_I2S_2)) | 436 | CAPTURE_2_FROM_I2S_2)) |
430 | oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, | 437 | oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, |
431 | OXYGEN_RATE_48000 | chip->model.adc_i2s_format | | 438 | OXYGEN_RATE_48000 | |
432 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | | 439 | chip->model.adc_i2s_format | |
433 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | 440 | OXYGEN_I2S_MCLK(chip->model.adc_mclks) | |
441 | OXYGEN_I2S_BITS_16 | | ||
442 | OXYGEN_I2S_MASTER | | ||
443 | OXYGEN_I2S_BCLK_64); | ||
434 | else | 444 | else |
435 | oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, | 445 | oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, |
436 | OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); | 446 | OXYGEN_I2S_MASTER | |
447 | OXYGEN_I2S_MUTE_MCLK); | ||
437 | oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, | 448 | oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, |
438 | OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); | 449 | OXYGEN_I2S_MASTER | |
450 | OXYGEN_I2S_MUTE_MCLK); | ||
439 | oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, | 451 | oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, |
440 | OXYGEN_SPDIF_OUT_ENABLE | | 452 | OXYGEN_SPDIF_OUT_ENABLE | |
441 | OXYGEN_SPDIF_LOOPBACK); | 453 | OXYGEN_SPDIF_LOOPBACK); |
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index dc3c68f76df4..d5533e34ece9 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -274,17 +274,6 @@ static unsigned int oxygen_rate(struct snd_pcm_hw_params *hw_params) | |||
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | unsigned int oxygen_default_i2s_mclk(struct oxygen *chip, | ||
278 | unsigned int channel, | ||
279 | struct snd_pcm_hw_params *hw_params) | ||
280 | { | ||
281 | if (params_rate(hw_params) <= 96000) | ||
282 | return OXYGEN_I2S_MCLK_256; | ||
283 | else | ||
284 | return OXYGEN_I2S_MCLK_128; | ||
285 | } | ||
286 | EXPORT_SYMBOL(oxygen_default_i2s_mclk); | ||
287 | |||
288 | static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params) | 277 | static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params) |
289 | { | 278 | { |
290 | if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE) | 279 | if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE) |
@@ -344,6 +333,26 @@ static int oxygen_hw_params(struct snd_pcm_substream *substream, | |||
344 | return 0; | 333 | return 0; |
345 | } | 334 | } |
346 | 335 | ||
336 | static u16 get_mclk(struct oxygen *chip, unsigned int channel, | ||
337 | struct snd_pcm_hw_params *params) | ||
338 | { | ||
339 | unsigned int mclks, shift; | ||
340 | |||
341 | if (channel == PCM_MULTICH) | ||
342 | mclks = chip->model.dac_mclks; | ||
343 | else | ||
344 | mclks = chip->model.adc_mclks; | ||
345 | |||
346 | if (params_rate(params) <= 48000) | ||
347 | shift = 0; | ||
348 | else if (params_rate(params) <= 96000) | ||
349 | shift = 2; | ||
350 | else | ||
351 | shift = 4; | ||
352 | |||
353 | return OXYGEN_I2S_MCLK(mclks >> shift); | ||
354 | } | ||
355 | |||
347 | static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, | 356 | static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, |
348 | struct snd_pcm_hw_params *hw_params) | 357 | struct snd_pcm_hw_params *hw_params) |
349 | { | 358 | { |
@@ -360,8 +369,8 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, | |||
360 | OXYGEN_REC_FORMAT_A_MASK); | 369 | OXYGEN_REC_FORMAT_A_MASK); |
361 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, | 370 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, |
362 | oxygen_rate(hw_params) | | 371 | oxygen_rate(hw_params) | |
363 | chip->model.get_i2s_mclk(chip, PCM_A, hw_params) | | ||
364 | chip->model.adc_i2s_format | | 372 | chip->model.adc_i2s_format | |
373 | get_mclk(chip, PCM_A, hw_params) | | ||
365 | oxygen_i2s_bits(hw_params), | 374 | oxygen_i2s_bits(hw_params), |
366 | OXYGEN_I2S_RATE_MASK | | 375 | OXYGEN_I2S_RATE_MASK | |
367 | OXYGEN_I2S_FORMAT_MASK | | 376 | OXYGEN_I2S_FORMAT_MASK | |
@@ -396,9 +405,8 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, | |||
396 | if (!is_ac97) | 405 | if (!is_ac97) |
397 | oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, | 406 | oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, |
398 | oxygen_rate(hw_params) | | 407 | oxygen_rate(hw_params) | |
399 | chip->model.get_i2s_mclk(chip, PCM_B, | ||
400 | hw_params) | | ||
401 | chip->model.adc_i2s_format | | 408 | chip->model.adc_i2s_format | |
409 | get_mclk(chip, PCM_B, hw_params) | | ||
402 | oxygen_i2s_bits(hw_params), | 410 | oxygen_i2s_bits(hw_params), |
403 | OXYGEN_I2S_RATE_MASK | | 411 | OXYGEN_I2S_RATE_MASK | |
404 | OXYGEN_I2S_FORMAT_MASK | | 412 | OXYGEN_I2S_FORMAT_MASK | |
@@ -479,8 +487,7 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
479 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | 487 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, |
480 | oxygen_rate(hw_params) | | 488 | oxygen_rate(hw_params) | |
481 | chip->model.dac_i2s_format | | 489 | chip->model.dac_i2s_format | |
482 | chip->model.get_i2s_mclk(chip, PCM_MULTICH, | 490 | get_mclk(chip, PCM_MULTICH, hw_params) | |
483 | hw_params) | | ||
484 | oxygen_i2s_bits(hw_params), | 491 | oxygen_i2s_bits(hw_params), |
485 | OXYGEN_I2S_RATE_MASK | | 492 | OXYGEN_I2S_RATE_MASK | |
486 | OXYGEN_I2S_FORMAT_MASK | | 493 | OXYGEN_I2S_FORMAT_MASK | |
diff --git a/sound/pci/oxygen/oxygen_regs.h b/sound/pci/oxygen/oxygen_regs.h index 331d3d96fa21..63dc7a0ab555 100644 --- a/sound/pci/oxygen/oxygen_regs.h +++ b/sound/pci/oxygen/oxygen_regs.h | |||
@@ -139,9 +139,11 @@ | |||
139 | #define OXYGEN_I2S_FORMAT_I2S 0x0000 | 139 | #define OXYGEN_I2S_FORMAT_I2S 0x0000 |
140 | #define OXYGEN_I2S_FORMAT_LJUST 0x0008 | 140 | #define OXYGEN_I2S_FORMAT_LJUST 0x0008 |
141 | #define OXYGEN_I2S_MCLK_MASK 0x0030 /* MCLK/LRCK */ | 141 | #define OXYGEN_I2S_MCLK_MASK 0x0030 /* MCLK/LRCK */ |
142 | #define OXYGEN_I2S_MCLK_128 0x0000 | 142 | #define OXYGEN_I2S_MCLK_SHIFT 4 |
143 | #define OXYGEN_I2S_MCLK_256 0x0010 | 143 | #define MCLK_128 0 |
144 | #define OXYGEN_I2S_MCLK_512 0x0020 | 144 | #define MCLK_256 1 |
145 | #define MCLK_512 2 | ||
146 | #define OXYGEN_I2S_MCLK(f) (((f) & 3) << OXYGEN_I2S_MCLK_SHIFT) | ||
145 | #define OXYGEN_I2S_BITS_MASK 0x00c0 | 147 | #define OXYGEN_I2S_BITS_MASK 0x00c0 |
146 | #define OXYGEN_I2S_BITS_16 0x0000 | 148 | #define OXYGEN_I2S_BITS_16 0x0000 |
147 | #define OXYGEN_I2S_BITS_20 0x0040 | 149 | #define OXYGEN_I2S_BITS_20 0x0040 |
diff --git a/sound/pci/oxygen/xonar_cs43xx.c b/sound/pci/oxygen/xonar_cs43xx.c index a25197ca39a1..b651938f3248 100644 --- a/sound/pci/oxygen/xonar_cs43xx.c +++ b/sound/pci/oxygen/xonar_cs43xx.c | |||
@@ -412,7 +412,6 @@ static const struct oxygen_model model_xonar_d1 = { | |||
412 | .cleanup = xonar_d1_cleanup, | 412 | .cleanup = xonar_d1_cleanup, |
413 | .suspend = xonar_d1_suspend, | 413 | .suspend = xonar_d1_suspend, |
414 | .resume = xonar_d1_resume, | 414 | .resume = xonar_d1_resume, |
415 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
416 | .set_dac_params = set_cs43xx_params, | 415 | .set_dac_params = set_cs43xx_params, |
417 | .set_adc_params = xonar_set_cs53x1_params, | 416 | .set_adc_params = xonar_set_cs53x1_params, |
418 | .update_dac_volume = update_cs43xx_volume, | 417 | .update_dac_volume = update_cs43xx_volume, |
@@ -431,6 +430,8 @@ static const struct oxygen_model model_xonar_d1 = { | |||
431 | .dac_volume_min = 127 - 60, | 430 | .dac_volume_min = 127 - 60, |
432 | .dac_volume_max = 127, | 431 | .dac_volume_max = 127, |
433 | .function_flags = OXYGEN_FUNCTION_2WIRE, | 432 | .function_flags = OXYGEN_FUNCTION_2WIRE, |
433 | .dac_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
434 | .adc_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
434 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 435 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
435 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 436 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
436 | }; | 437 | }; |
diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c index e15ecee2ccf7..9787193f6ed3 100644 --- a/sound/pci/oxygen/xonar_pcm179x.c +++ b/sound/pci/oxygen/xonar_pcm179x.c | |||
@@ -335,10 +335,6 @@ static void pcm1796_init(struct oxygen *chip) | |||
335 | data->h6 ? PCM1796_OS_64 : PCM1796_OS_128; | 335 | data->h6 ? PCM1796_OS_64 : PCM1796_OS_128; |
336 | pcm1796_registers_init(chip); | 336 | pcm1796_registers_init(chip); |
337 | data->current_rate = 48000; | 337 | data->current_rate = 48000; |
338 | if (!data->h6) | ||
339 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | ||
340 | OXYGEN_I2S_MCLK_512, | ||
341 | OXYGEN_I2S_MCLK_MASK); | ||
342 | } | 338 | } |
343 | 339 | ||
344 | static void xonar_d2_init(struct oxygen *chip) | 340 | static void xonar_d2_init(struct oxygen *chip) |
@@ -476,7 +472,7 @@ static void xonar_st_init(struct oxygen *chip) | |||
476 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, | 472 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, |
477 | OXYGEN_RATE_48000 | | 473 | OXYGEN_RATE_48000 | |
478 | OXYGEN_I2S_FORMAT_I2S | | 474 | OXYGEN_I2S_FORMAT_I2S | |
479 | (data->h6 ? OXYGEN_I2S_MCLK_256 : OXYGEN_I2S_MCLK_512) | | 475 | OXYGEN_I2S_MCLK(data->h6 ? MCLK_256 : MCLK_512) | |
480 | OXYGEN_I2S_BITS_16 | | 476 | OXYGEN_I2S_BITS_16 | |
481 | OXYGEN_I2S_MASTER | | 477 | OXYGEN_I2S_MASTER | |
482 | OXYGEN_I2S_BCLK_64); | 478 | OXYGEN_I2S_BCLK_64); |
@@ -560,26 +556,6 @@ static void xonar_st_resume(struct oxygen *chip) | |||
560 | xonar_stx_resume(chip); | 556 | xonar_stx_resume(chip); |
561 | } | 557 | } |
562 | 558 | ||
563 | static unsigned int mclk_from_rate(struct oxygen *chip, unsigned int rate) | ||
564 | { | ||
565 | struct xonar_pcm179x *data = chip->model_data; | ||
566 | |||
567 | if (rate <= 48000) | ||
568 | return data->h6 ? OXYGEN_I2S_MCLK_256 : OXYGEN_I2S_MCLK_512; | ||
569 | else | ||
570 | return OXYGEN_I2S_MCLK_128; | ||
571 | } | ||
572 | |||
573 | static unsigned int get_pcm1796_i2s_mclk(struct oxygen *chip, | ||
574 | unsigned int channel, | ||
575 | struct snd_pcm_hw_params *params) | ||
576 | { | ||
577 | if (channel == PCM_MULTICH) | ||
578 | return mclk_from_rate(chip, params_rate(params)); | ||
579 | else | ||
580 | return oxygen_default_i2s_mclk(chip, channel, params); | ||
581 | } | ||
582 | |||
583 | static void update_pcm1796_oversampling(struct oxygen *chip) | 559 | static void update_pcm1796_oversampling(struct oxygen *chip) |
584 | { | 560 | { |
585 | struct xonar_pcm179x *data = chip->model_data; | 561 | struct xonar_pcm179x *data = chip->model_data; |
@@ -640,45 +616,32 @@ static void update_cs2000_rate(struct oxygen *chip, unsigned int rate) | |||
640 | 616 | ||
641 | switch (rate) { | 617 | switch (rate) { |
642 | case 32000: | 618 | case 32000: |
643 | if (data->h6) | ||
644 | rate_mclk = OXYGEN_RATE_32000 | OXYGEN_I2S_MCLK_256; | ||
645 | else | ||
646 | rate_mclk = OXYGEN_RATE_32000 | OXYGEN_I2S_MCLK_512; | ||
647 | break; | ||
648 | case 44100: | ||
649 | if (data->h6) | ||
650 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_256; | ||
651 | else | ||
652 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_512; | ||
653 | break; | ||
654 | default: /* 48000 */ | ||
655 | if (data->h6) | ||
656 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_256; | ||
657 | else | ||
658 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_512; | ||
659 | break; | ||
660 | case 64000: | 619 | case 64000: |
661 | rate_mclk = OXYGEN_RATE_32000 | OXYGEN_I2S_MCLK_256; | 620 | rate_mclk = OXYGEN_RATE_32000; |
662 | break; | 621 | break; |
622 | case 44100: | ||
663 | case 88200: | 623 | case 88200: |
664 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_256; | ||
665 | break; | ||
666 | case 96000: | ||
667 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_256; | ||
668 | break; | ||
669 | case 176400: | 624 | case 176400: |
670 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_512; | 625 | rate_mclk = OXYGEN_RATE_44100; |
671 | break; | 626 | break; |
627 | default: | ||
628 | case 48000: | ||
629 | case 96000: | ||
672 | case 192000: | 630 | case 192000: |
673 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_512; | 631 | rate_mclk = OXYGEN_RATE_48000; |
674 | break; | 632 | break; |
675 | } | 633 | } |
676 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, rate_mclk, | 634 | |
677 | OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_MCLK_MASK); | 635 | if (rate <= 96000 && (rate > 48000 || data->h6)) { |
678 | if ((rate_mclk & OXYGEN_I2S_MCLK_MASK) <= OXYGEN_I2S_MCLK_256) | 636 | rate_mclk |= OXYGEN_I2S_MCLK(MCLK_256); |
679 | reg = CS2000_REF_CLK_DIV_1; | 637 | reg = CS2000_REF_CLK_DIV_1; |
680 | else | 638 | } else { |
639 | rate_mclk |= OXYGEN_I2S_MCLK(MCLK_512); | ||
681 | reg = CS2000_REF_CLK_DIV_2; | 640 | reg = CS2000_REF_CLK_DIV_2; |
641 | } | ||
642 | |||
643 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, rate_mclk, | ||
644 | OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_MCLK_MASK); | ||
682 | cs2000_write_cached(chip, CS2000_FUN_CFG_1, reg); | 645 | cs2000_write_cached(chip, CS2000_FUN_CFG_1, reg); |
683 | msleep(3); /* PLL lock delay */ | 646 | msleep(3); /* PLL lock delay */ |
684 | } | 647 | } |
@@ -1047,7 +1010,6 @@ static const struct oxygen_model model_xonar_d2 = { | |||
1047 | .cleanup = xonar_d2_cleanup, | 1010 | .cleanup = xonar_d2_cleanup, |
1048 | .suspend = xonar_d2_suspend, | 1011 | .suspend = xonar_d2_suspend, |
1049 | .resume = xonar_d2_resume, | 1012 | .resume = xonar_d2_resume, |
1050 | .get_i2s_mclk = get_pcm1796_i2s_mclk, | ||
1051 | .set_dac_params = set_pcm1796_params, | 1013 | .set_dac_params = set_pcm1796_params, |
1052 | .set_adc_params = xonar_set_cs53x1_params, | 1014 | .set_adc_params = xonar_set_cs53x1_params, |
1053 | .update_dac_volume = update_pcm1796_volume, | 1015 | .update_dac_volume = update_pcm1796_volume, |
@@ -1069,6 +1031,8 @@ static const struct oxygen_model model_xonar_d2 = { | |||
1069 | .misc_flags = OXYGEN_MISC_MIDI, | 1031 | .misc_flags = OXYGEN_MISC_MIDI, |
1070 | .function_flags = OXYGEN_FUNCTION_SPI | | 1032 | .function_flags = OXYGEN_FUNCTION_SPI | |
1071 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | 1033 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
1034 | .dac_mclks = OXYGEN_MCLKS(512, 128, 128), | ||
1035 | .adc_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
1072 | .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, | 1036 | .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, |
1073 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 1037 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
1074 | }; | 1038 | }; |
@@ -1082,7 +1046,6 @@ static const struct oxygen_model model_xonar_hdav = { | |||
1082 | .suspend = xonar_hdav_suspend, | 1046 | .suspend = xonar_hdav_suspend, |
1083 | .resume = xonar_hdav_resume, | 1047 | .resume = xonar_hdav_resume, |
1084 | .pcm_hardware_filter = xonar_hdmi_pcm_hardware_filter, | 1048 | .pcm_hardware_filter = xonar_hdmi_pcm_hardware_filter, |
1085 | .get_i2s_mclk = get_pcm1796_i2s_mclk, | ||
1086 | .set_dac_params = set_hdav_params, | 1049 | .set_dac_params = set_hdav_params, |
1087 | .set_adc_params = xonar_set_cs53x1_params, | 1050 | .set_adc_params = xonar_set_cs53x1_params, |
1088 | .update_dac_volume = update_pcm1796_volume, | 1051 | .update_dac_volume = update_pcm1796_volume, |
@@ -1102,6 +1065,8 @@ static const struct oxygen_model model_xonar_hdav = { | |||
1102 | .dac_volume_max = 255, | 1065 | .dac_volume_max = 255, |
1103 | .misc_flags = OXYGEN_MISC_MIDI, | 1066 | .misc_flags = OXYGEN_MISC_MIDI, |
1104 | .function_flags = OXYGEN_FUNCTION_2WIRE, | 1067 | .function_flags = OXYGEN_FUNCTION_2WIRE, |
1068 | .dac_mclks = OXYGEN_MCLKS(512, 128, 128), | ||
1069 | .adc_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
1105 | .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, | 1070 | .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, |
1106 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 1071 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
1107 | }; | 1072 | }; |
@@ -1114,7 +1079,6 @@ static const struct oxygen_model model_xonar_st = { | |||
1114 | .cleanup = xonar_st_cleanup, | 1079 | .cleanup = xonar_st_cleanup, |
1115 | .suspend = xonar_st_suspend, | 1080 | .suspend = xonar_st_suspend, |
1116 | .resume = xonar_st_resume, | 1081 | .resume = xonar_st_resume, |
1117 | .get_i2s_mclk = get_pcm1796_i2s_mclk, | ||
1118 | .set_dac_params = set_st_params, | 1082 | .set_dac_params = set_st_params, |
1119 | .set_adc_params = xonar_set_cs53x1_params, | 1083 | .set_adc_params = xonar_set_cs53x1_params, |
1120 | .update_dac_volume = update_pcm1796_volume, | 1084 | .update_dac_volume = update_pcm1796_volume, |
@@ -1132,6 +1096,8 @@ static const struct oxygen_model model_xonar_st = { | |||
1132 | .dac_volume_min = 255 - 2*60, | 1096 | .dac_volume_min = 255 - 2*60, |
1133 | .dac_volume_max = 255, | 1097 | .dac_volume_max = 255, |
1134 | .function_flags = OXYGEN_FUNCTION_2WIRE, | 1098 | .function_flags = OXYGEN_FUNCTION_2WIRE, |
1099 | .dac_mclks = OXYGEN_MCLKS(512, 128, 128), | ||
1100 | .adc_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
1135 | .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, | 1101 | .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, |
1136 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 1102 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
1137 | }; | 1103 | }; |
@@ -1159,6 +1125,7 @@ int __devinit get_xonar_pcm179x_model(struct oxygen *chip, | |||
1159 | case GPIO_DB_H6: | 1125 | case GPIO_DB_H6: |
1160 | chip->model.shortname = "Xonar HDAV1.3+H6"; | 1126 | chip->model.shortname = "Xonar HDAV1.3+H6"; |
1161 | chip->model.dac_channels_mixer = 8; | 1127 | chip->model.dac_channels_mixer = 8; |
1128 | chip->model.dac_mclks = OXYGEN_MCLKS(256, 128, 128); | ||
1162 | break; | 1129 | break; |
1163 | } | 1130 | } |
1164 | break; | 1131 | break; |
@@ -1174,6 +1141,7 @@ int __devinit get_xonar_pcm179x_model(struct oxygen *chip, | |||
1174 | chip->model.control_filter = xonar_st_h6_control_filter; | 1141 | chip->model.control_filter = xonar_st_h6_control_filter; |
1175 | chip->model.dac_channels_pcm = 8; | 1142 | chip->model.dac_channels_pcm = 8; |
1176 | chip->model.dac_channels_mixer = 8; | 1143 | chip->model.dac_channels_mixer = 8; |
1144 | chip->model.dac_mclks = OXYGEN_MCLKS(256, 128, 128); | ||
1177 | break; | 1145 | break; |
1178 | } | 1146 | } |
1179 | break; | 1147 | break; |
diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index da92cc24eed2..4f9657084603 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c | |||
@@ -1122,7 +1122,6 @@ static const struct oxygen_model model_xonar_ds = { | |||
1122 | .suspend = xonar_ds_suspend, | 1122 | .suspend = xonar_ds_suspend, |
1123 | .resume = xonar_ds_resume, | 1123 | .resume = xonar_ds_resume, |
1124 | .pcm_hardware_filter = wm8776_adc_hardware_filter, | 1124 | .pcm_hardware_filter = wm8776_adc_hardware_filter, |
1125 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
1126 | .set_dac_params = set_wm87x6_dac_params, | 1125 | .set_dac_params = set_wm87x6_dac_params, |
1127 | .set_adc_params = set_wm8776_adc_params, | 1126 | .set_adc_params = set_wm8776_adc_params, |
1128 | .update_dac_volume = update_wm87x6_volume, | 1127 | .update_dac_volume = update_wm87x6_volume, |
@@ -1140,6 +1139,8 @@ static const struct oxygen_model model_xonar_ds = { | |||
1140 | .dac_volume_min = 255 - 2*60, | 1139 | .dac_volume_min = 255 - 2*60, |
1141 | .dac_volume_max = 255, | 1140 | .dac_volume_max = 255, |
1142 | .function_flags = OXYGEN_FUNCTION_SPI, | 1141 | .function_flags = OXYGEN_FUNCTION_SPI, |
1142 | .dac_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
1143 | .adc_mclks = OXYGEN_MCLKS(256, 256, 128), | ||
1143 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 1144 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
1144 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 1145 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
1145 | }; | 1146 | }; |