.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * card driver for models with PCM1796 DACs (Xonar D2/D2X/HDAV1.3/ST/STX) |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> |
---|
5 | | - * |
---|
6 | | - * |
---|
7 | | - * This driver is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License, version 2. |
---|
9 | | - * |
---|
10 | | - * This driver is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this driver; if not, see <http://www.gnu.org/licenses/>. |
---|
17 | 6 | */ |
---|
18 | 7 | |
---|
19 | 8 | /* |
---|
.. | .. |
---|
331 | 320 | struct xonar_pcm179x *data = chip->model_data; |
---|
332 | 321 | |
---|
333 | 322 | data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = |
---|
334 | | - PCM1796_DMF_DISABLED | PCM1796_FMT_24_I2S | PCM1796_ATLD; |
---|
| 323 | + PCM1796_FMT_24_I2S | PCM1796_ATLD; |
---|
335 | 324 | if (!data->broken_i2c) |
---|
336 | 325 | data->pcm1796_regs[0][18 - PCM1796_REG_BASE] |= PCM1796_MUTE; |
---|
337 | 326 | data->pcm1796_regs[0][19 - PCM1796_REG_BASE] = |
---|
.. | .. |
---|
471 | 460 | |
---|
472 | 461 | data->generic.anti_pop_delay = 100; |
---|
473 | 462 | data->h6 = chip->model.dac_channels_mixer > 2; |
---|
474 | | - data->has_cs2000 = 1; |
---|
| 463 | + data->has_cs2000 = true; |
---|
475 | 464 | data->cs2000_regs[CS2000_FUN_CFG_1] = CS2000_REF_CLK_DIV_1; |
---|
476 | 465 | data->broken_i2c = true; |
---|
477 | 466 | |
---|
.. | .. |
---|
513 | 502 | xonar_init_ext_power(chip); |
---|
514 | 503 | |
---|
515 | 504 | data->generic.anti_pop_delay = 100; |
---|
516 | | - data->has_cs2000 = 1; |
---|
| 505 | + data->has_cs2000 = true; |
---|
517 | 506 | data->cs2000_regs[CS2000_FUN_CFG_1] = CS2000_REF_CLK_DIV_1; |
---|
518 | 507 | |
---|
519 | 508 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, |
---|
.. | .. |
---|
621 | 610 | pcm1796_write_cached(chip, i, 20, reg); |
---|
622 | 611 | } |
---|
623 | 612 | |
---|
| 613 | +static void update_pcm1796_deemph(struct oxygen *chip) |
---|
| 614 | +{ |
---|
| 615 | + struct xonar_pcm179x *data = chip->model_data; |
---|
| 616 | + unsigned int i; |
---|
| 617 | + u8 reg; |
---|
| 618 | + |
---|
| 619 | + reg = data->pcm1796_regs[0][18 - PCM1796_REG_BASE] & ~PCM1796_DMF_MASK; |
---|
| 620 | + if (data->current_rate == 48000) |
---|
| 621 | + reg |= PCM1796_DMF_48; |
---|
| 622 | + else if (data->current_rate == 44100) |
---|
| 623 | + reg |= PCM1796_DMF_441; |
---|
| 624 | + else if (data->current_rate == 32000) |
---|
| 625 | + reg |= PCM1796_DMF_32; |
---|
| 626 | + for (i = 0; i < data->dacs; ++i) |
---|
| 627 | + pcm1796_write_cached(chip, i, 18, reg); |
---|
| 628 | +} |
---|
| 629 | + |
---|
624 | 630 | static void set_pcm1796_params(struct oxygen *chip, |
---|
625 | 631 | struct snd_pcm_hw_params *params) |
---|
626 | 632 | { |
---|
.. | .. |
---|
629 | 635 | msleep(1); |
---|
630 | 636 | data->current_rate = params_rate(params); |
---|
631 | 637 | update_pcm1796_oversampling(chip); |
---|
| 638 | + update_pcm1796_deemph(chip); |
---|
632 | 639 | } |
---|
633 | 640 | |
---|
634 | 641 | static void update_pcm1796_volume(struct oxygen *chip) |
---|
.. | .. |
---|
653 | 660 | unsigned int i; |
---|
654 | 661 | u8 value; |
---|
655 | 662 | |
---|
656 | | - value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_I2S | PCM1796_ATLD; |
---|
| 663 | + value = data->pcm1796_regs[0][18 - PCM1796_REG_BASE]; |
---|
657 | 664 | if (chip->dac_mute) |
---|
658 | 665 | value |= PCM1796_MUTE; |
---|
| 666 | + else |
---|
| 667 | + value &= ~PCM1796_MUTE; |
---|
659 | 668 | for (i = 0; i < data->dacs; ++i) |
---|
660 | 669 | pcm1796_write_cached(chip, i, 18, value); |
---|
661 | 670 | } |
---|
.. | .. |
---|
775 | 784 | .info = rolloff_info, |
---|
776 | 785 | .get = rolloff_get, |
---|
777 | 786 | .put = rolloff_put, |
---|
| 787 | +}; |
---|
| 788 | + |
---|
| 789 | +static int deemph_get(struct snd_kcontrol *ctl, |
---|
| 790 | + struct snd_ctl_elem_value *value) |
---|
| 791 | +{ |
---|
| 792 | + struct oxygen *chip = ctl->private_data; |
---|
| 793 | + struct xonar_pcm179x *data = chip->model_data; |
---|
| 794 | + |
---|
| 795 | + value->value.integer.value[0] = |
---|
| 796 | + !!(data->pcm1796_regs[0][18 - PCM1796_REG_BASE] & PCM1796_DME); |
---|
| 797 | + return 0; |
---|
| 798 | +} |
---|
| 799 | + |
---|
| 800 | +static int deemph_put(struct snd_kcontrol *ctl, |
---|
| 801 | + struct snd_ctl_elem_value *value) |
---|
| 802 | +{ |
---|
| 803 | + struct oxygen *chip = ctl->private_data; |
---|
| 804 | + struct xonar_pcm179x *data = chip->model_data; |
---|
| 805 | + unsigned int i; |
---|
| 806 | + int changed; |
---|
| 807 | + u8 reg; |
---|
| 808 | + |
---|
| 809 | + mutex_lock(&chip->mutex); |
---|
| 810 | + reg = data->pcm1796_regs[0][18 - PCM1796_REG_BASE]; |
---|
| 811 | + if (!value->value.integer.value[0]) |
---|
| 812 | + reg &= ~PCM1796_DME; |
---|
| 813 | + else |
---|
| 814 | + reg |= PCM1796_DME; |
---|
| 815 | + changed = reg != data->pcm1796_regs[0][18 - PCM1796_REG_BASE]; |
---|
| 816 | + if (changed) { |
---|
| 817 | + for (i = 0; i < data->dacs; ++i) |
---|
| 818 | + pcm1796_write(chip, i, 18, reg); |
---|
| 819 | + } |
---|
| 820 | + mutex_unlock(&chip->mutex); |
---|
| 821 | + return changed; |
---|
| 822 | +} |
---|
| 823 | + |
---|
| 824 | +static const struct snd_kcontrol_new deemph_control = { |
---|
| 825 | + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
---|
| 826 | + .name = "De-emphasis Playback Switch", |
---|
| 827 | + .info = snd_ctl_boolean_mono_info, |
---|
| 828 | + .get = deemph_get, |
---|
| 829 | + .put = deemph_put, |
---|
778 | 830 | }; |
---|
779 | 831 | |
---|
780 | 832 | static const struct snd_kcontrol_new hdav_hdmi_control = { |
---|
.. | .. |
---|
1011 | 1063 | snd_ctl_new1(&rolloff_control, chip)); |
---|
1012 | 1064 | if (err < 0) |
---|
1013 | 1065 | return err; |
---|
| 1066 | + err = snd_ctl_add(chip->card, |
---|
| 1067 | + snd_ctl_new1(&deemph_control, chip)); |
---|
| 1068 | + if (err < 0) |
---|
| 1069 | + return err; |
---|
1014 | 1070 | } |
---|
1015 | 1071 | return 0; |
---|
1016 | 1072 | } |
---|