@@ -26,51 +26,162 @@ static const struct reg_default tegra186_dspk_reg_defaults[] = {
26
26
{ TEGRA186_DSPK_CODEC_CTRL , 0x03000000 },
27
27
};
28
28
29
- static int tegra186_dspk_get_control (struct snd_kcontrol * kcontrol ,
29
+ static int tegra186_dspk_get_fifo_th (struct snd_kcontrol * kcontrol ,
30
30
struct snd_ctl_elem_value * ucontrol )
31
31
{
32
32
struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
33
33
struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
34
34
35
- if (strstr (kcontrol -> id .name , "FIFO Threshold" ))
36
- ucontrol -> value .integer .value [0 ] = dspk -> rx_fifo_th ;
37
- else if (strstr (kcontrol -> id .name , "OSR Value" ))
38
- ucontrol -> value .integer .value [0 ] = dspk -> osr_val ;
39
- else if (strstr (kcontrol -> id .name , "LR Polarity Select" ))
40
- ucontrol -> value .integer .value [0 ] = dspk -> lrsel ;
41
- else if (strstr (kcontrol -> id .name , "Channel Select" ))
42
- ucontrol -> value .integer .value [0 ] = dspk -> ch_sel ;
43
- else if (strstr (kcontrol -> id .name , "Mono To Stereo" ))
44
- ucontrol -> value .integer .value [0 ] = dspk -> mono_to_stereo ;
45
- else if (strstr (kcontrol -> id .name , "Stereo To Mono" ))
46
- ucontrol -> value .integer .value [0 ] = dspk -> stereo_to_mono ;
35
+ ucontrol -> value .integer .value [0 ] = dspk -> rx_fifo_th ;
47
36
48
37
return 0 ;
49
38
}
50
39
51
- static int tegra186_dspk_put_control (struct snd_kcontrol * kcontrol ,
40
+ static int tegra186_dspk_put_fifo_th (struct snd_kcontrol * kcontrol ,
52
41
struct snd_ctl_elem_value * ucontrol )
53
42
{
54
43
struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
55
44
struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
56
- int val = ucontrol -> value .integer .value [0 ];
57
-
58
- if (strstr (kcontrol -> id .name , "FIFO Threshold" ))
59
- dspk -> rx_fifo_th = val ;
60
- else if (strstr (kcontrol -> id .name , "OSR Value" ))
61
- dspk -> osr_val = val ;
62
- else if (strstr (kcontrol -> id .name , "LR Polarity Select" ))
63
- dspk -> lrsel = val ;
64
- else if (strstr (kcontrol -> id .name , "Channel Select" ))
65
- dspk -> ch_sel = val ;
66
- else if (strstr (kcontrol -> id .name , "Mono To Stereo" ))
67
- dspk -> mono_to_stereo = val ;
68
- else if (strstr (kcontrol -> id .name , "Stereo To Mono" ))
69
- dspk -> stereo_to_mono = val ;
45
+ int value = ucontrol -> value .integer .value [0 ];
46
+
47
+ if (value == dspk -> rx_fifo_th )
48
+ return 0 ;
49
+
50
+ dspk -> rx_fifo_th = value ;
51
+
52
+ return 1 ;
53
+ }
54
+
55
+ static int tegra186_dspk_get_osr_val (struct snd_kcontrol * kcontrol ,
56
+ struct snd_ctl_elem_value * ucontrol )
57
+ {
58
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
59
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
60
+
61
+ ucontrol -> value .enumerated .item [0 ] = dspk -> osr_val ;
70
62
71
63
return 0 ;
72
64
}
73
65
66
+ static int tegra186_dspk_put_osr_val (struct snd_kcontrol * kcontrol ,
67
+ struct snd_ctl_elem_value * ucontrol )
68
+ {
69
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
70
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
71
+ unsigned int value = ucontrol -> value .enumerated .item [0 ];
72
+
73
+ if (value == dspk -> osr_val )
74
+ return 0 ;
75
+
76
+ dspk -> osr_val = value ;
77
+
78
+ return 1 ;
79
+ }
80
+
81
+ static int tegra186_dspk_get_pol_sel (struct snd_kcontrol * kcontrol ,
82
+ struct snd_ctl_elem_value * ucontrol )
83
+ {
84
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
85
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
86
+
87
+ ucontrol -> value .enumerated .item [0 ] = dspk -> lrsel ;
88
+
89
+ return 0 ;
90
+ }
91
+
92
+ static int tegra186_dspk_put_pol_sel (struct snd_kcontrol * kcontrol ,
93
+ struct snd_ctl_elem_value * ucontrol )
94
+ {
95
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
96
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
97
+ unsigned int value = ucontrol -> value .enumerated .item [0 ];
98
+
99
+ if (value == dspk -> lrsel )
100
+ return 0 ;
101
+
102
+ dspk -> lrsel = value ;
103
+
104
+ return 1 ;
105
+ }
106
+
107
+ static int tegra186_dspk_get_ch_sel (struct snd_kcontrol * kcontrol ,
108
+ struct snd_ctl_elem_value * ucontrol )
109
+ {
110
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
111
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
112
+
113
+ ucontrol -> value .enumerated .item [0 ] = dspk -> ch_sel ;
114
+
115
+ return 0 ;
116
+ }
117
+
118
+ static int tegra186_dspk_put_ch_sel (struct snd_kcontrol * kcontrol ,
119
+ struct snd_ctl_elem_value * ucontrol )
120
+ {
121
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
122
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
123
+ unsigned int value = ucontrol -> value .enumerated .item [0 ];
124
+
125
+ if (value == dspk -> ch_sel )
126
+ return 0 ;
127
+
128
+ dspk -> ch_sel = value ;
129
+
130
+ return 1 ;
131
+ }
132
+
133
+ static int tegra186_dspk_get_mono_to_stereo (struct snd_kcontrol * kcontrol ,
134
+ struct snd_ctl_elem_value * ucontrol )
135
+ {
136
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
137
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
138
+
139
+ ucontrol -> value .enumerated .item [0 ] = dspk -> mono_to_stereo ;
140
+
141
+ return 0 ;
142
+ }
143
+
144
+ static int tegra186_dspk_put_mono_to_stereo (struct snd_kcontrol * kcontrol ,
145
+ struct snd_ctl_elem_value * ucontrol )
146
+ {
147
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
148
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
149
+ unsigned int value = ucontrol -> value .enumerated .item [0 ];
150
+
151
+ if (value == dspk -> mono_to_stereo )
152
+ return 0 ;
153
+
154
+ dspk -> mono_to_stereo = value ;
155
+
156
+ return 1 ;
157
+ }
158
+
159
+ static int tegra186_dspk_get_stereo_to_mono (struct snd_kcontrol * kcontrol ,
160
+ struct snd_ctl_elem_value * ucontrol )
161
+ {
162
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
163
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
164
+
165
+ ucontrol -> value .enumerated .item [0 ] = dspk -> stereo_to_mono ;
166
+
167
+ return 0 ;
168
+ }
169
+
170
+ static int tegra186_dspk_put_stereo_to_mono (struct snd_kcontrol * kcontrol ,
171
+ struct snd_ctl_elem_value * ucontrol )
172
+ {
173
+ struct snd_soc_component * codec = snd_soc_kcontrol_component (kcontrol );
174
+ struct tegra186_dspk * dspk = snd_soc_component_get_drvdata (codec );
175
+ unsigned int value = ucontrol -> value .enumerated .item [0 ];
176
+
177
+ if (value == dspk -> stereo_to_mono )
178
+ return 0 ;
179
+
180
+ dspk -> stereo_to_mono = value ;
181
+
182
+ return 1 ;
183
+ }
184
+
74
185
static int __maybe_unused tegra186_dspk_runtime_suspend (struct device * dev )
75
186
{
76
187
struct tegra186_dspk * dspk = dev_get_drvdata (dev );
@@ -279,17 +390,19 @@ static const struct soc_enum tegra186_dspk_lrsel_enum =
279
390
static const struct snd_kcontrol_new tegrat186_dspk_controls [] = {
280
391
SOC_SINGLE_EXT ("FIFO Threshold" , SND_SOC_NOPM , 0 ,
281
392
TEGRA186_DSPK_RX_FIFO_DEPTH - 1 , 0 ,
282
- tegra186_dspk_get_control , tegra186_dspk_put_control ),
393
+ tegra186_dspk_get_fifo_th , tegra186_dspk_put_fifo_th ),
283
394
SOC_ENUM_EXT ("OSR Value" , tegra186_dspk_osr_enum ,
284
- tegra186_dspk_get_control , tegra186_dspk_put_control ),
395
+ tegra186_dspk_get_osr_val , tegra186_dspk_put_osr_val ),
285
396
SOC_ENUM_EXT ("LR Polarity Select" , tegra186_dspk_lrsel_enum ,
286
- tegra186_dspk_get_control , tegra186_dspk_put_control ),
397
+ tegra186_dspk_get_pol_sel , tegra186_dspk_put_pol_sel ),
287
398
SOC_ENUM_EXT ("Channel Select" , tegra186_dspk_ch_sel_enum ,
288
- tegra186_dspk_get_control , tegra186_dspk_put_control ),
399
+ tegra186_dspk_get_ch_sel , tegra186_dspk_put_ch_sel ),
289
400
SOC_ENUM_EXT ("Mono To Stereo" , tegra186_dspk_mono_conv_enum ,
290
- tegra186_dspk_get_control , tegra186_dspk_put_control ),
401
+ tegra186_dspk_get_mono_to_stereo ,
402
+ tegra186_dspk_put_mono_to_stereo ),
291
403
SOC_ENUM_EXT ("Stereo To Mono" , tegra186_dspk_stereo_conv_enum ,
292
- tegra186_dspk_get_control , tegra186_dspk_put_control ),
404
+ tegra186_dspk_get_stereo_to_mono ,
405
+ tegra186_dspk_put_stereo_to_mono ),
293
406
};
294
407
295
408
static const struct snd_soc_component_driver tegra186_dspk_cmpnt = {
0 commit comments