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/xonar_pcm179x.c | |
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/xonar_pcm179x.c')
-rw-r--r-- | sound/pci/oxygen/xonar_pcm179x.c | 82 |
1 files changed, 25 insertions, 57 deletions
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; |