@@ -238,7 +238,7 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
238
238
struct snd_card * snd_card_ptr = card -> snd_card ;
239
239
struct snd_kcontrol * kctl ;
240
240
struct soc_mixer_control * mc ;
241
- unsigned int left_val = 0 ;
241
+ unsigned int left_val = 0 , right_val = 0 ;
242
242
243
243
rtd = snd_soc_get_pcm_runtime (card , card -> dai_link [0 ].name );
244
244
@@ -260,6 +260,8 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
260
260
snd_soc_write (rtd -> codec_dais [1 ]-> codec , PCM512x_MUTE , 0x10 );
261
261
snd_soc_write (rtd -> codec_dais [0 ]-> codec ,
262
262
PCM512x_DIGITAL_VOLUME_3 , 0xff );
263
+ snd_soc_write (rtd -> codec_dais [1 ]-> codec ,
264
+ PCM512x_DIGITAL_VOLUME_2 , 0xff );
263
265
264
266
list_for_each_entry (kctl , & snd_card_ptr -> controls , list ) {
265
267
if (!strncmp (kctl -> id .name , "Digital Playback Volume" ,
@@ -273,6 +275,9 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
273
275
} else {
274
276
left_val = snd_soc_read (rtd -> codec_dais [0 ]-> codec ,
275
277
PCM512x_DIGITAL_VOLUME_2 );
278
+ right_val = snd_soc_read (rtd -> codec_dais [1 ]-> codec ,
279
+ PCM512x_DIGITAL_VOLUME_3 );
280
+
276
281
list_for_each_entry (kctl , & snd_card_ptr -> controls , list ) {
277
282
if (!strncmp (kctl -> id .name , "Digital Playback Volume" ,
278
283
sizeof (kctl -> id .name ))) {
@@ -285,6 +290,8 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
285
290
286
291
snd_soc_write (rtd -> codec_dais [0 ]-> codec ,
287
292
PCM512x_DIGITAL_VOLUME_3 , left_val );
293
+ snd_soc_write (rtd -> codec_dais [1 ]-> codec ,
294
+ PCM512x_DIGITAL_VOLUME_2 , right_val );
288
295
snd_soc_write (rtd -> codec_dais [0 ]-> codec , PCM512x_MUTE , 0x00 );
289
296
snd_soc_write (rtd -> codec_dais [1 ]-> codec , PCM512x_MUTE , 0x00 );
290
297
}
@@ -311,14 +318,17 @@ static int snd_allo_piano_mode_put(struct snd_kcontrol *kcontrol,
311
318
struct snd_card * snd_card_ptr = card -> snd_card ;
312
319
struct snd_kcontrol * kctl ;
313
320
struct soc_mixer_control * mc ;
314
- unsigned int left_val = 0 ;
321
+ unsigned int left_val = 0 , right_val = 0 ;
315
322
316
323
rtd = snd_soc_get_pcm_runtime (card , card -> dai_link [0 ].name );
317
324
318
325
if ((glb_ptr -> dual_mode == 1 ) &&
319
326
(ucontrol -> value .integer .value [0 ] > 0 )) {
320
327
left_val = snd_soc_read (rtd -> codec_dais [0 ]-> codec ,
321
328
PCM512x_DIGITAL_VOLUME_2 );
329
+ right_val = snd_soc_read (rtd -> codec_dais [1 ]-> codec ,
330
+ PCM512x_DIGITAL_VOLUME_2 );
331
+
322
332
list_for_each_entry (kctl , & snd_card_ptr -> controls , list ) {
323
333
if (!strncmp (kctl -> id .name , "Digital Playback Volume" ,
324
334
sizeof (kctl -> id .name ))) {
@@ -330,6 +340,8 @@ static int snd_allo_piano_mode_put(struct snd_kcontrol *kcontrol,
330
340
}
331
341
snd_soc_write (rtd -> codec_dais [0 ]-> codec ,
332
342
PCM512x_DIGITAL_VOLUME_3 , left_val );
343
+ snd_soc_write (rtd -> codec_dais [1 ]-> codec ,
344
+ PCM512x_DIGITAL_VOLUME_3 , right_val );
333
345
}
334
346
335
347
return (snd_allo_piano_dsp_program (rtd ,
@@ -366,21 +378,27 @@ static int pcm512x_get_reg_sub(struct snd_kcontrol *kcontrol,
366
378
struct soc_mixer_control * mc =
367
379
(struct soc_mixer_control * )kcontrol -> private_value ;
368
380
struct snd_soc_card * card = snd_kcontrol_chip (kcontrol );
381
+ struct glb_pool * glb_ptr = card -> drvdata ;
369
382
struct snd_soc_pcm_runtime * rtd ;
370
383
unsigned int left_val = 0 ;
371
384
unsigned int right_val = 0 ;
372
385
373
386
rtd = snd_soc_get_pcm_runtime (card , card -> dai_link [0 ].name );
374
- left_val = snd_soc_read (rtd -> codec_dais [1 ]-> codec ,
375
- PCM512x_DIGITAL_VOLUME_2 );
376
- if (left_val < 0 )
377
- return left_val ;
378
-
379
387
right_val = snd_soc_read (rtd -> codec_dais [1 ]-> codec ,
380
388
PCM512x_DIGITAL_VOLUME_3 );
381
389
if (right_val < 0 )
382
390
return right_val ;
383
391
392
+ if (glb_ptr -> dual_mode != 1 ) {
393
+ left_val = snd_soc_read (rtd -> codec_dais [1 ]-> codec ,
394
+ PCM512x_DIGITAL_VOLUME_2 );
395
+ if (left_val < 0 )
396
+ return left_val ;
397
+
398
+ } else {
399
+ left_val = right_val ;
400
+ }
401
+
384
402
ucontrol -> value .integer .value [0 ] =
385
403
(~(left_val >> mc -> shift )) & mc -> max ;
386
404
ucontrol -> value .integer .value [1 ] =
@@ -395,16 +413,19 @@ static int pcm512x_set_reg_sub(struct snd_kcontrol *kcontrol,
395
413
struct soc_mixer_control * mc =
396
414
(struct soc_mixer_control * )kcontrol -> private_value ;
397
415
struct snd_soc_card * card = snd_kcontrol_chip (kcontrol );
416
+ struct glb_pool * glb_ptr = card -> drvdata ;
398
417
struct snd_soc_pcm_runtime * rtd ;
399
418
unsigned int left_val = (ucontrol -> value .integer .value [0 ] & mc -> max );
400
419
unsigned int right_val = (ucontrol -> value .integer .value [1 ] & mc -> max );
401
420
int ret = 0 ;
402
421
403
422
rtd = snd_soc_get_pcm_runtime (card , card -> dai_link [0 ].name );
404
- ret = snd_soc_write (rtd -> codec_dais [1 ]-> codec ,
405
- PCM512x_DIGITAL_VOLUME_2 , (~left_val ));
406
- if (ret < 0 )
407
- return ret ;
423
+ if (glb_ptr -> dual_mode != 1 ) {
424
+ ret = snd_soc_write (rtd -> codec_dais [1 ]-> codec ,
425
+ PCM512x_DIGITAL_VOLUME_2 , (~left_val ));
426
+ if (ret < 0 )
427
+ return ret ;
428
+ }
408
429
409
430
ret = snd_soc_write (rtd -> codec_dais [1 ]-> codec ,
410
431
PCM512x_DIGITAL_VOLUME_3 , (~right_val ));
@@ -437,16 +458,18 @@ static int pcm512x_set_reg_sub_switch(struct snd_kcontrol *kcontrol,
437
458
{
438
459
struct snd_soc_card * card = snd_kcontrol_chip (kcontrol );
439
460
struct snd_soc_pcm_runtime * rtd ;
461
+ struct glb_pool * glb_ptr = card -> drvdata ;
440
462
unsigned int left_val = (ucontrol -> value .integer .value [0 ]);
441
463
unsigned int right_val = (ucontrol -> value .integer .value [1 ]);
442
464
int ret = 0 ;
443
465
444
466
rtd = snd_soc_get_pcm_runtime (card , card -> dai_link [0 ].name );
445
- ret = snd_soc_write (rtd -> codec_dais [1 ]-> codec , PCM512x_MUTE ,
446
- ~((left_val & 0x01 )<<4 | (right_val & 0x01 )));
447
- if (ret < 0 )
448
- return ret ;
449
-
467
+ if (glb_ptr -> set_mode != 1 ) {
468
+ ret = snd_soc_write (rtd -> codec_dais [1 ]-> codec , PCM512x_MUTE ,
469
+ ~((left_val & 0x01 )<<4 | (right_val & 0x01 )));
470
+ if (ret < 0 )
471
+ return ret ;
472
+ }
450
473
return 1 ;
451
474
452
475
}
@@ -506,7 +529,6 @@ static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
506
529
dev_warn (card -> dev , "Failed to set volume limit: %d\n" ,
507
530
ret );
508
531
}
509
-
510
532
return 0 ;
511
533
}
512
534
0 commit comments