@@ -243,6 +243,33 @@ static int soc_put_volsw(struct snd_kcontrol *kcontrol,
243
243
return ret ;
244
244
}
245
245
246
+ static int soc_get_volsw (struct snd_kcontrol * kcontrol ,
247
+ struct snd_ctl_elem_value * ucontrol ,
248
+ struct soc_mixer_control * mc , int mask , int max )
249
+ {
250
+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
251
+ unsigned int reg_val ;
252
+ int val ;
253
+
254
+ reg_val = snd_soc_component_read (component , mc -> reg );
255
+ val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> shift , max );
256
+
257
+ ucontrol -> value .integer .value [0 ] = val ;
258
+
259
+ if (snd_soc_volsw_is_stereo (mc )) {
260
+ if (mc -> reg == mc -> rreg ) {
261
+ val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> rshift , max );
262
+ } else {
263
+ reg_val = snd_soc_component_read (component , mc -> rreg );
264
+ val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> shift , max );
265
+ }
266
+
267
+ ucontrol -> value .integer .value [1 ] = val ;
268
+ }
269
+
270
+ return 0 ;
271
+ }
272
+
246
273
/**
247
274
* snd_soc_info_volsw - single mixer info callback with range.
248
275
* @kcontrol: mixer control
@@ -299,31 +326,11 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_sx);
299
326
int snd_soc_get_volsw (struct snd_kcontrol * kcontrol ,
300
327
struct snd_ctl_elem_value * ucontrol )
301
328
{
302
- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
303
329
struct soc_mixer_control * mc =
304
330
(struct soc_mixer_control * )kcontrol -> private_value ;
305
- int max = mc -> max - mc -> min ;
306
331
unsigned int mask = soc_mixer_mask (mc );
307
- unsigned int reg_val ;
308
- int val ;
309
332
310
- reg_val = snd_soc_component_read (component , mc -> reg );
311
- val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> shift , max );
312
-
313
- ucontrol -> value .integer .value [0 ] = val ;
314
-
315
- if (snd_soc_volsw_is_stereo (mc )) {
316
- if (mc -> reg == mc -> rreg ) {
317
- val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> rshift , max );
318
- } else {
319
- reg_val = snd_soc_component_read (component , mc -> rreg );
320
- val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> shift , max );
321
- }
322
-
323
- ucontrol -> value .integer .value [1 ] = val ;
324
- }
325
-
326
- return 0 ;
333
+ return soc_get_volsw (kcontrol , ucontrol , mc , mask , mc -> max - mc -> min );
327
334
}
328
335
EXPORT_SYMBOL_GPL (snd_soc_get_volsw );
329
336
@@ -361,28 +368,11 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
361
368
int snd_soc_get_volsw_sx (struct snd_kcontrol * kcontrol ,
362
369
struct snd_ctl_elem_value * ucontrol )
363
370
{
364
- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
365
371
struct soc_mixer_control * mc =
366
372
(struct soc_mixer_control * )kcontrol -> private_value ;
367
- unsigned int reg = mc -> reg ;
368
- unsigned int reg2 = mc -> rreg ;
369
373
unsigned int mask = soc_mixer_sx_mask (mc );
370
- unsigned int reg_val ;
371
- int val ;
372
-
373
- reg_val = snd_soc_component_read (component , reg );
374
- val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> shift , mc -> max );
375
-
376
- ucontrol -> value .integer .value [0 ] = val ;
377
-
378
- if (snd_soc_volsw_is_stereo (mc )) {
379
- reg_val = snd_soc_component_read (component , reg2 );
380
- val = soc_mixer_reg_to_ctl (mc , reg_val , mask , mc -> rshift , mc -> max );
381
374
382
- ucontrol -> value .integer .value [1 ] = val ;
383
- }
384
-
385
- return 0 ;
375
+ return soc_get_volsw (kcontrol , ucontrol , mc , mask , mc -> max );
386
376
}
387
377
EXPORT_SYMBOL_GPL (snd_soc_get_volsw_sx );
388
378
0 commit comments