tlv320aic32x4.c (59cd4f435ee972b8fb87d50ea36d76929aabf3a3) tlv320aic32x4.c (3694f996be5cb8374bd224f4e5462c945d359843)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * linux/sound/soc/codecs/tlv320aic32x4.c
4 *
5 * Copyright 2011 Vista Silicon S.L.
6 *
7 * Author: Javier Martin <javier.martin@vista-silicon.com>
8 *

--- 236 unchanged lines hidden (view full) ---

245/* 0dB min, 0.5dB steps */
246static DECLARE_TLV_DB_SCALE(tlv_step_0_5, 0, 50, 0);
247/* -63.5dB min, 0.5dB steps */
248static DECLARE_TLV_DB_SCALE(tlv_pcm, -6350, 50, 0);
249/* -6dB min, 1dB steps */
250static DECLARE_TLV_DB_SCALE(tlv_driver_gain, -600, 100, 0);
251/* -12dB min, 0.5dB steps */
252static DECLARE_TLV_DB_SCALE(tlv_adc_vol, -1200, 50, 0);
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * linux/sound/soc/codecs/tlv320aic32x4.c
4 *
5 * Copyright 2011 Vista Silicon S.L.
6 *
7 * Author: Javier Martin <javier.martin@vista-silicon.com>
8 *

--- 236 unchanged lines hidden (view full) ---

245/* 0dB min, 0.5dB steps */
246static DECLARE_TLV_DB_SCALE(tlv_step_0_5, 0, 50, 0);
247/* -63.5dB min, 0.5dB steps */
248static DECLARE_TLV_DB_SCALE(tlv_pcm, -6350, 50, 0);
249/* -6dB min, 1dB steps */
250static DECLARE_TLV_DB_SCALE(tlv_driver_gain, -600, 100, 0);
251/* -12dB min, 0.5dB steps */
252static DECLARE_TLV_DB_SCALE(tlv_adc_vol, -1200, 50, 0);
253/* -6dB min, 1dB steps */
254static DECLARE_TLV_DB_SCALE(tlv_tas_driver_gain, -5850, 50, 0);
253
254static DECLARE_TLV_DB_LINEAR(tlv_spk_vol, TLV_DB_GAIN_MUTE, 0);
255static DECLARE_TLV_DB_SCALE(tlv_amp_vol, 0, 600, 1);
256
257static const char * const lo_cm_text[] = {
258 "Full Chip", "1.65V",
259};
260
261static SOC_ENUM_SINGLE_DECL(lo_cm_enum, AIC32X4_CMMODE, 3, lo_cm_text);
262

--- 414 unchanged lines hidden (view full) ---

677 (dosr & 0xff));
678
679 return 0;
680}
681
682static int aic32x4_set_processing_blocks(struct snd_soc_component *component,
683 u8 r_block, u8 p_block)
684{
255static DECLARE_TLV_DB_SCALE(tlv_amp_vol, 0, 600, 1);
256
257static const char * const lo_cm_text[] = {
258 "Full Chip", "1.65V",
259};
260
261static SOC_ENUM_SINGLE_DECL(lo_cm_enum, AIC32X4_CMMODE, 3, lo_cm_text);
262

--- 414 unchanged lines hidden (view full) ---

677 (dosr & 0xff));
678
679 return 0;
680}
681
682static int aic32x4_set_processing_blocks(struct snd_soc_component *component,
683 u8 r_block, u8 p_block)
684{
685 struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component);
685 if (r_block > 18 || p_block > 25)
686 return -EINVAL;
686
687
687 if (aic32x4->type == AIC32X4_TYPE_TAS2505) {
688 if (r_block || p_block > 3)
689 return -EINVAL;
688 snd_soc_component_write(component, AIC32X4_ADCSPB, r_block);
689 snd_soc_component_write(component, AIC32X4_DACSPB, p_block);
690
690
691 snd_soc_component_write(component, AIC32X4_DACSPB, p_block);
692 } else { /* AIC32x4 */
693 if (r_block > 18 || p_block > 25)
694 return -EINVAL;
695
696 snd_soc_component_write(component, AIC32X4_ADCSPB, r_block);
697 snd_soc_component_write(component, AIC32X4_DACSPB, p_block);
698 }
699
700 return 0;
701}
702
703static int aic32x4_setup_clocks(struct snd_soc_component *component,
704 unsigned int sample_rate, unsigned int channels,
705 unsigned int bit_depth)
706{
691 return 0;
692}
693
694static int aic32x4_setup_clocks(struct snd_soc_component *component,
695 unsigned int sample_rate, unsigned int channels,
696 unsigned int bit_depth)
697{
707 struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component);
708 u8 aosr;
709 u16 dosr;
710 u8 adc_resource_class, dac_resource_class;
711 u8 madc, nadc, mdac, ndac, max_nadc, min_mdac, max_ndac;
712 u8 dosr_increment;
713 u16 max_dosr, min_dosr;
714 unsigned long adc_clock_rate, dac_clock_rate;
715 int ret;

--- 10 unchanged lines hidden (view full) ---

726 if (ret)
727 return ret;
728
729 if (sample_rate <= 48000) {
730 aosr = 128;
731 adc_resource_class = 6;
732 dac_resource_class = 8;
733 dosr_increment = 8;
698 u8 aosr;
699 u16 dosr;
700 u8 adc_resource_class, dac_resource_class;
701 u8 madc, nadc, mdac, ndac, max_nadc, min_mdac, max_ndac;
702 u8 dosr_increment;
703 u16 max_dosr, min_dosr;
704 unsigned long adc_clock_rate, dac_clock_rate;
705 int ret;

--- 10 unchanged lines hidden (view full) ---

716 if (ret)
717 return ret;
718
719 if (sample_rate <= 48000) {
720 aosr = 128;
721 adc_resource_class = 6;
722 dac_resource_class = 8;
723 dosr_increment = 8;
734 if (aic32x4->type == AIC32X4_TYPE_TAS2505)
735 aic32x4_set_processing_blocks(component, 0, 1);
736 else
737 aic32x4_set_processing_blocks(component, 1, 1);
724 aic32x4_set_processing_blocks(component, 1, 1);
738 } else if (sample_rate <= 96000) {
739 aosr = 64;
740 adc_resource_class = 6;
741 dac_resource_class = 8;
742 dosr_increment = 4;
725 } else if (sample_rate <= 96000) {
726 aosr = 64;
727 adc_resource_class = 6;
728 dac_resource_class = 8;
729 dosr_increment = 4;
743 if (aic32x4->type == AIC32X4_TYPE_TAS2505)
744 aic32x4_set_processing_blocks(component, 0, 1);
745 else
746 aic32x4_set_processing_blocks(component, 1, 9);
730 aic32x4_set_processing_blocks(component, 1, 9);
747 } else if (sample_rate == 192000) {
748 aosr = 32;
749 adc_resource_class = 3;
750 dac_resource_class = 4;
751 dosr_increment = 2;
731 } else if (sample_rate == 192000) {
732 aosr = 32;
733 adc_resource_class = 3;
734 dac_resource_class = 4;
735 dosr_increment = 2;
752 if (aic32x4->type == AIC32X4_TYPE_TAS2505)
753 aic32x4_set_processing_blocks(component, 0, 1);
754 else
755 aic32x4_set_processing_blocks(component, 13, 19);
736 aic32x4_set_processing_blocks(component, 13, 19);
756 } else {
757 dev_err(component->dev, "Sampling rate not supported\n");
758 return -EINVAL;
759 }
760
761 madc = DIV_ROUND_UP((32 * adc_resource_class), aosr);
762 max_dosr = (AIC32X4_MAX_DOSR_FREQ / sample_rate / dosr_increment) *
763 dosr_increment;

--- 313 unchanged lines hidden (view full) ---

1077 .suspend_bias_off = 1,
1078 .idle_bias_on = 1,
1079 .use_pmdown_time = 1,
1080 .endianness = 1,
1081 .non_legacy_dai_naming = 1,
1082};
1083
1084static const struct snd_kcontrol_new aic32x4_tas2505_snd_controls[] = {
737 } else {
738 dev_err(component->dev, "Sampling rate not supported\n");
739 return -EINVAL;
740 }
741
742 madc = DIV_ROUND_UP((32 * adc_resource_class), aosr);
743 max_dosr = (AIC32X4_MAX_DOSR_FREQ / sample_rate / dosr_increment) *
744 dosr_increment;

--- 313 unchanged lines hidden (view full) ---

1058 .suspend_bias_off = 1,
1059 .idle_bias_on = 1,
1060 .use_pmdown_time = 1,
1061 .endianness = 1,
1062 .non_legacy_dai_naming = 1,
1063};
1064
1065static const struct snd_kcontrol_new aic32x4_tas2505_snd_controls[] = {
1085 SOC_SINGLE_S8_TLV("PCM Playback Volume",
1086 AIC32X4_LDACVOL, -0x7f, 0x30, tlv_pcm),
1066 SOC_DOUBLE_R_S_TLV("PCM Playback Volume", AIC32X4_LDACVOL,
1067 AIC32X4_LDACVOL, 0, -0x7f, 0x30, 7, 0, tlv_pcm),
1087 SOC_ENUM("DAC Playback PowerTune Switch", l_ptm_enum),
1068 SOC_ENUM("DAC Playback PowerTune Switch", l_ptm_enum),
1069 SOC_DOUBLE_R_S_TLV("HP Driver Playback Volume", AIC32X4_HPLGAIN,
1070 AIC32X4_HPLGAIN, 0, -0x6, 0x1d, 5, 0,
1071 tlv_driver_gain),
1072 SOC_DOUBLE_R("HP DAC Playback Switch", AIC32X4_HPLGAIN,
1073 AIC32X4_HPLGAIN, 6, 0x01, 1),
1088
1074
1089 SOC_SINGLE_TLV("HP Driver Gain Volume",
1090 AIC32X4_HPLGAIN, 0, 0x74, 1, tlv_tas_driver_gain),
1091 SOC_SINGLE("HP DAC Playback Switch", AIC32X4_HPLGAIN, 6, 1, 1),
1092
1093 SOC_SINGLE_TLV("Speaker Driver Playback Volume",
1094 TAS2505_SPKVOL1, 0, 0x74, 1, tlv_tas_driver_gain),
1095 SOC_SINGLE_TLV("Speaker Amplifier Playback Volume",
1096 TAS2505_SPKVOL2, 4, 5, 0, tlv_amp_vol),
1097
1098 SOC_SINGLE("Auto-mute Switch", AIC32X4_DACMUTE, 4, 7, 0),
1075 SOC_SINGLE("Auto-mute Switch", AIC32X4_DACMUTE, 4, 7, 0),
1076
1077 SOC_SINGLE_RANGE_TLV("Speaker Driver Playback Volume", TAS2505_SPKVOL1,
1078 0, 0, 117, 1, tlv_spk_vol),
1079 SOC_SINGLE_TLV("Speaker Amplifier Playback Volume", TAS2505_SPKVOL2,
1080 4, 5, 0, tlv_amp_vol),
1099};
1100
1101static const struct snd_kcontrol_new hp_output_mixer_controls[] = {
1102 SOC_DAPM_SINGLE("DAC Switch", AIC32X4_HPLROUTE, 3, 1, 0),
1103};
1104
1105static const struct snd_soc_dapm_widget aic32x4_tas2505_dapm_widgets[] = {
1106 SND_SOC_DAPM_DAC("DAC", "Playback", AIC32X4_DACSETUP, 7, 0),

--- 19 unchanged lines hidden (view full) ---

1126 {"Speaker", NULL, "Speaker Driver"},
1127};
1128
1129static struct snd_soc_dai_driver aic32x4_tas2505_dai = {
1130 .name = "tas2505-hifi",
1131 .playback = {
1132 .stream_name = "Playback",
1133 .channels_min = 1,
1081};
1082
1083static const struct snd_kcontrol_new hp_output_mixer_controls[] = {
1084 SOC_DAPM_SINGLE("DAC Switch", AIC32X4_HPLROUTE, 3, 1, 0),
1085};
1086
1087static const struct snd_soc_dapm_widget aic32x4_tas2505_dapm_widgets[] = {
1088 SND_SOC_DAPM_DAC("DAC", "Playback", AIC32X4_DACSETUP, 7, 0),

--- 19 unchanged lines hidden (view full) ---

1108 {"Speaker", NULL, "Speaker Driver"},
1109};
1110
1111static struct snd_soc_dai_driver aic32x4_tas2505_dai = {
1112 .name = "tas2505-hifi",
1113 .playback = {
1114 .stream_name = "Playback",
1115 .channels_min = 1,
1134 .channels_max = 1,
1116 .channels_max = 2,
1135 .rates = SNDRV_PCM_RATE_8000_96000,
1136 .formats = AIC32X4_FORMATS,},
1137 .ops = &aic32x4_ops,
1138 .symmetric_rate = 1,
1139};
1140
1141static int aic32x4_tas2505_component_probe(struct snd_soc_component *component)
1142{

--- 291 unchanged lines hidden ---
1117 .rates = SNDRV_PCM_RATE_8000_96000,
1118 .formats = AIC32X4_FORMATS,},
1119 .ops = &aic32x4_ops,
1120 .symmetric_rate = 1,
1121};
1122
1123static int aic32x4_tas2505_component_probe(struct snd_soc_component *component)
1124{

--- 291 unchanged lines hidden ---