aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/ca0106/ca0106_main.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 6dc9a5d01af5..22d2f6b6a05f 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -514,6 +514,23 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
514 } 514 }
515} 515}
516 516
517static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
518 int power)
519{
520 if (chip->details->spi_dac) {
521 const int reg = spi_dacd_reg[channel_id];
522
523 if (power)
524 /* Power up */
525 chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id];
526 else
527 /* Power down */
528 chip->spi_dac_reg[reg] |= spi_dacd_bit[channel_id];
529 return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
530 }
531 return 0;
532}
533
517/* open_playback callback */ 534/* open_playback callback */
518static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, 535static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream,
519 int channel_id) 536 int channel_id)
@@ -553,12 +570,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
553 return err; 570 return err;
554 snd_pcm_set_sync(substream); 571 snd_pcm_set_sync(substream);
555 572
556 if (chip->details->spi_dac && channel_id != PCM_FRONT_CHANNEL) { 573 /* Front channel dac should already be on */
557 const int reg = spi_dacd_reg[channel_id]; 574 if (channel_id != PCM_FRONT_CHANNEL) {
558 575 err = snd_ca0106_pcm_power_dac(chip, channel_id, 1);
559 /* Power up dac */
560 chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id];
561 err = snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
562 if (err < 0) 576 if (err < 0)
563 return err; 577 return err;
564 } 578 }
@@ -578,13 +592,14 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream)
578 592
579 restore_spdif_bits(chip, epcm->channel_id); 593 restore_spdif_bits(chip, epcm->channel_id);
580 594
581 if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) { 595 /* Front channel dac should stay on */
582 const int reg = spi_dacd_reg[epcm->channel_id]; 596 if (epcm->channel_id != PCM_FRONT_CHANNEL) {
583 597 int err;
584 /* Power down DAC */ 598 err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0);
585 chip->spi_dac_reg[reg] |= spi_dacd_bit[epcm->channel_id]; 599 if (err < 0)
586 snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); 600 return err;
587 } 601 }
602
588 /* FIXME: maybe zero others */ 603 /* FIXME: maybe zero others */
589 return 0; 604 return 0;
590} 605}