1 From cc1a511f1a582e2fbf9fa1e257f6b88cbcc2e0d9 Mon Sep 17 00:00:00 2001
2 From: paul-1 <6473457+paul-1@users.noreply.github.com>
3 Date: Sat, 7 Nov 2020 12:01:44 -0500
4 Subject: [PATCH] Update volume controls in Allo Piano Dac Plus
6 Put control scaling back to 255.
7 Clean up what master/sub volume controls set in codec.
8 Remove more unneeded mixer controls.
10 Signed-off-by: Paul Hermann <paul@picoreplayer.org>
12 sound/soc/bcm/allo-piano-dac-plus.c | 56 +++++++++++++++++------------
13 1 file changed, 33 insertions(+), 23 deletions(-)
15 --- a/sound/soc/bcm/allo-piano-dac-plus.c
16 +++ b/sound/soc/bcm/allo-piano-dac-plus.c
17 @@ -420,6 +420,7 @@ static int pcm512x_get_reg_sub(struct sn
18 unsigned int right_val = 0;
20 rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
22 ret = snd_soc_component_read(rtd->codec_dais[1]->component,
23 PCM512x_DIGITAL_VOLUME_3, &right_val);
25 @@ -465,17 +466,20 @@ static int pcm512x_set_reg_sub(struct sn
29 - if (glb_ptr->dual_mode != 1) {
30 + // When in Dual Mono, Sub vol control should not set anything.
31 + if (glb_ptr->dual_mode != 1) { //Not in Dual Mono mode
33 ret = snd_soc_component_write(rtd->codec_dais[1]->component,
34 PCM512x_DIGITAL_VOLUME_2, (~left_val));
39 - ret = snd_soc_component_write(rtd->codec_dais[1]->component,
40 - PCM512x_DIGITAL_VOLUME_3, (~right_val));
43 + ret = snd_soc_component_write(rtd->codec_dais[1]->component,
44 + PCM512x_DIGITAL_VOLUME_3, (~right_val));
52 @@ -540,7 +544,7 @@ static int pcm512x_get_reg_master(struct
56 - if (glb_ptr->dual_mode == 1) {
57 + if (glb_ptr->dual_mode == 1) { // in Dual Mono mode
58 ret = snd_soc_component_read(rtd->codec_dais[1]->component,
59 PCM512x_DIGITAL_VOLUME_3, &right_val);
61 @@ -582,8 +586,21 @@ static int pcm512x_set_reg_master(struct
65 - if (glb_ptr->dual_mode != 1) {
66 + if (glb_ptr->dual_mode == 1) { //in Dual Mono Mode
68 + ret = snd_soc_component_write(rtd->codec_dais[0]->component,
69 + PCM512x_DIGITAL_VOLUME_2, (~left_val));
73 ret = snd_soc_component_write(rtd->codec_dais[1]->component,
74 + PCM512x_DIGITAL_VOLUME_3, (~right_val));
80 + ret = snd_soc_component_write(rtd->codec_dais[0]->component,
81 PCM512x_DIGITAL_VOLUME_2, (~left_val));
84 @@ -594,16 +611,6 @@ static int pcm512x_set_reg_master(struct
89 - ret = snd_soc_component_write(rtd->codec_dais[1]->component,
90 - PCM512x_DIGITAL_VOLUME_3, (~right_val));
94 - ret = snd_soc_component_write(rtd->codec_dais[0]->component,
95 - PCM512x_DIGITAL_VOLUME_2, (~left_val));
101 @@ -697,7 +704,7 @@ static const struct snd_kcontrol_new all
103 SOC_DOUBLE_R_EXT_TLV("Subwoofer Playback Volume",
104 PCM512x_DIGITAL_VOLUME_2,
105 - PCM512x_DIGITAL_VOLUME_3, 0, 207, 1,
106 + PCM512x_DIGITAL_VOLUME_3, 0, 255, 1,
110 @@ -711,7 +718,7 @@ static const struct snd_kcontrol_new all
112 SOC_DOUBLE_R_EXT_TLV("Master Playback Volume",
113 PCM512x_DIGITAL_VOLUME_2,
114 - PCM512x_DIGITAL_VOLUME_3, 0, 207, 1,
115 + PCM512x_DIGITAL_VOLUME_3, 0, 255, 1,
116 pcm512x_get_reg_master,
117 pcm512x_set_reg_master,
119 @@ -737,7 +744,11 @@ static const char * const codec_ctl_name
122 "Volume Ramp Down Emergency Rate",
123 - "Volume Ramp Down Emergency Step"
124 + "Volume Ramp Down Emergency Step",
125 + "Volume Ramp Up Rate",
126 + "Volume Ramp Down Rate",
127 + "Volume Ramp Up Step",
128 + "Volume Ramp Down Step"
131 static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
132 @@ -774,8 +785,7 @@ static int snd_allo_piano_dac_init(struc
134 // Remove codec controls
135 for (i = 0; i < ARRAY_SIZE(codec_ctl_pfx); i++) {
136 - // Start at 1, leave the Digital Volume control.
137 - for (j = 1; j < ARRAY_SIZE(codec_ctl_name); j++) {
138 + for (j = 0; j < ARRAY_SIZE(codec_ctl_name); j++) {
141 sprintf(cname, "%s %s", codec_ctl_pfx[i], codec_ctl_name[j]);