Skip to content

Commit f8e5569

Browse files
allocompopcornmix
allocom
authored andcommitted
Bug fix: unmuted
1 parent 2e6aa17 commit f8e5569

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

sound/soc/bcm/allo-piano-dac-plus.c

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
238238
struct snd_card *snd_card_ptr = card->snd_card;
239239
struct snd_kcontrol *kctl;
240240
struct soc_mixer_control *mc;
241-
unsigned int left_val = 0;
241+
unsigned int left_val = 0, right_val = 0;
242242

243243
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
244244

@@ -260,6 +260,8 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
260260
snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x10);
261261
snd_soc_write(rtd->codec_dais[0]->codec,
262262
PCM512x_DIGITAL_VOLUME_3, 0xff);
263+
snd_soc_write(rtd->codec_dais[1]->codec,
264+
PCM512x_DIGITAL_VOLUME_2, 0xff);
263265

264266
list_for_each_entry(kctl, &snd_card_ptr->controls, list) {
265267
if (!strncmp(kctl->id.name, "Digital Playback Volume",
@@ -273,6 +275,9 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
273275
} else {
274276
left_val = snd_soc_read(rtd->codec_dais[0]->codec,
275277
PCM512x_DIGITAL_VOLUME_2);
278+
right_val = snd_soc_read(rtd->codec_dais[1]->codec,
279+
PCM512x_DIGITAL_VOLUME_3);
280+
276281
list_for_each_entry(kctl, &snd_card_ptr->controls, list) {
277282
if (!strncmp(kctl->id.name, "Digital Playback Volume",
278283
sizeof(kctl->id.name))) {
@@ -285,6 +290,8 @@ static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol,
285290

286291
snd_soc_write(rtd->codec_dais[0]->codec,
287292
PCM512x_DIGITAL_VOLUME_3, left_val);
293+
snd_soc_write(rtd->codec_dais[1]->codec,
294+
PCM512x_DIGITAL_VOLUME_2, right_val);
288295
snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00);
289296
snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x00);
290297
}
@@ -311,14 +318,17 @@ static int snd_allo_piano_mode_put(struct snd_kcontrol *kcontrol,
311318
struct snd_card *snd_card_ptr = card->snd_card;
312319
struct snd_kcontrol *kctl;
313320
struct soc_mixer_control *mc;
314-
unsigned int left_val = 0;
321+
unsigned int left_val = 0, right_val = 0;
315322

316323
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
317324

318325
if ((glb_ptr->dual_mode == 1) &&
319326
(ucontrol->value.integer.value[0] > 0)) {
320327
left_val = snd_soc_read(rtd->codec_dais[0]->codec,
321328
PCM512x_DIGITAL_VOLUME_2);
329+
right_val = snd_soc_read(rtd->codec_dais[1]->codec,
330+
PCM512x_DIGITAL_VOLUME_2);
331+
322332
list_for_each_entry(kctl, &snd_card_ptr->controls, list) {
323333
if (!strncmp(kctl->id.name, "Digital Playback Volume",
324334
sizeof(kctl->id.name))) {
@@ -330,6 +340,8 @@ static int snd_allo_piano_mode_put(struct snd_kcontrol *kcontrol,
330340
}
331341
snd_soc_write(rtd->codec_dais[0]->codec,
332342
PCM512x_DIGITAL_VOLUME_3, left_val);
343+
snd_soc_write(rtd->codec_dais[1]->codec,
344+
PCM512x_DIGITAL_VOLUME_3, right_val);
333345
}
334346

335347
return(snd_allo_piano_dsp_program(rtd,
@@ -366,21 +378,27 @@ static int pcm512x_get_reg_sub(struct snd_kcontrol *kcontrol,
366378
struct soc_mixer_control *mc =
367379
(struct soc_mixer_control *)kcontrol->private_value;
368380
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
381+
struct glb_pool *glb_ptr = card->drvdata;
369382
struct snd_soc_pcm_runtime *rtd;
370383
unsigned int left_val = 0;
371384
unsigned int right_val = 0;
372385

373386
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-
379387
right_val = snd_soc_read(rtd->codec_dais[1]->codec,
380388
PCM512x_DIGITAL_VOLUME_3);
381389
if (right_val < 0)
382390
return right_val;
383391

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+
384402
ucontrol->value.integer.value[0] =
385403
(~(left_val >> mc->shift)) & mc->max;
386404
ucontrol->value.integer.value[1] =
@@ -395,16 +413,19 @@ static int pcm512x_set_reg_sub(struct snd_kcontrol *kcontrol,
395413
struct soc_mixer_control *mc =
396414
(struct soc_mixer_control *)kcontrol->private_value;
397415
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
416+
struct glb_pool *glb_ptr = card->drvdata;
398417
struct snd_soc_pcm_runtime *rtd;
399418
unsigned int left_val = (ucontrol->value.integer.value[0] & mc->max);
400419
unsigned int right_val = (ucontrol->value.integer.value[1] & mc->max);
401420
int ret = 0;
402421

403422
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+
}
408429

409430
ret = snd_soc_write(rtd->codec_dais[1]->codec,
410431
PCM512x_DIGITAL_VOLUME_3, (~right_val));
@@ -437,16 +458,18 @@ static int pcm512x_set_reg_sub_switch(struct snd_kcontrol *kcontrol,
437458
{
438459
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
439460
struct snd_soc_pcm_runtime *rtd;
461+
struct glb_pool *glb_ptr = card->drvdata;
440462
unsigned int left_val = (ucontrol->value.integer.value[0]);
441463
unsigned int right_val = (ucontrol->value.integer.value[1]);
442464
int ret = 0;
443465

444466
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+
}
450473
return 1;
451474

452475
}
@@ -506,7 +529,6 @@ static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
506529
dev_warn(card->dev, "Failed to set volume limit: %d\n",
507530
ret);
508531
}
509-
510532
return 0;
511533
}
512534

0 commit comments

Comments
 (0)