firmware-utils: bump to git HEAD
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-1022-Update-volume-controls-in-Allo-Piano-Dac-Plus.patch
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
5
6 Put control scaling back to 255.
7 Clean up what master/sub volume controls set in codec.
8 Remove more unneeded mixer controls.
9
10 Signed-off-by: Paul Hermann <paul@picoreplayer.org>
11 ---
12 sound/soc/bcm/allo-piano-dac-plus.c | 56 +++++++++++++++++------------
13 1 file changed, 33 insertions(+), 23 deletions(-)
14
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;
19 int ret;
20 rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
21 +
22 ret = snd_soc_component_read(rtd->codec_dais[1]->component,
23 PCM512x_DIGITAL_VOLUME_3, &right_val);
24 if (ret < 0)
25 @@ -465,17 +466,20 @@ static int pcm512x_set_reg_sub(struct sn
26 ret);
27 }
28
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
32 +
33 ret = snd_soc_component_write(rtd->codec_dais[1]->component,
34 PCM512x_DIGITAL_VOLUME_2, (~left_val));
35 if (ret < 0)
36 return ret;
37 - }
38
39 - ret = snd_soc_component_write(rtd->codec_dais[1]->component,
40 - PCM512x_DIGITAL_VOLUME_3, (~right_val));
41 - if (ret < 0)
42 - return ret;
43 + ret = snd_soc_component_write(rtd->codec_dais[1]->component,
44 + PCM512x_DIGITAL_VOLUME_3, (~right_val));
45 + if (ret < 0)
46 + return ret;
47 +
48 + }
49
50 return 1;
51 }
52 @@ -540,7 +544,7 @@ static int pcm512x_get_reg_master(struct
53 if ( ret < 0)
54 return ret;
55
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);
60 if (ret < 0)
61 @@ -582,8 +586,21 @@ static int pcm512x_set_reg_master(struct
62 ret);
63 }
64
65 - if (glb_ptr->dual_mode != 1) {
66 + if (glb_ptr->dual_mode == 1) { //in Dual Mono Mode
67 +
68 + ret = snd_soc_component_write(rtd->codec_dais[0]->component,
69 + PCM512x_DIGITAL_VOLUME_2, (~left_val));
70 + if (ret < 0)
71 + return ret;
72 +
73 ret = snd_soc_component_write(rtd->codec_dais[1]->component,
74 + PCM512x_DIGITAL_VOLUME_3, (~right_val));
75 + if (ret < 0)
76 + return ret;
77 +
78 + } else {
79 +
80 + ret = snd_soc_component_write(rtd->codec_dais[0]->component,
81 PCM512x_DIGITAL_VOLUME_2, (~left_val));
82 if (ret < 0)
83 return ret;
84 @@ -594,16 +611,6 @@ static int pcm512x_set_reg_master(struct
85 return ret;
86
87 }
88 -
89 - ret = snd_soc_component_write(rtd->codec_dais[1]->component,
90 - PCM512x_DIGITAL_VOLUME_3, (~right_val));
91 - if (ret < 0)
92 - return ret;
93 -
94 - ret = snd_soc_component_write(rtd->codec_dais[0]->component,
95 - PCM512x_DIGITAL_VOLUME_2, (~left_val));
96 - if (ret < 0)
97 - return ret;
98 return 1;
99 }
100
101 @@ -697,7 +704,7 @@ static const struct snd_kcontrol_new all
102
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,
107 pcm512x_get_reg_sub,
108 pcm512x_set_reg_sub,
109 digital_tlv_sub),
110 @@ -711,7 +718,7 @@ static const struct snd_kcontrol_new all
111
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,
118 digital_tlv_master),
119 @@ -737,7 +744,11 @@ static const char * const codec_ctl_name
120 "Max Overclock DSP",
121 "Max Overclock PLL",
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"
129 };
130
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
133
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++) {
139 char cname[256];
140
141 sprintf(cname, "%s %s", codec_ctl_pfx[i], codec_ctl_name[j]);