提交 51630142 编写于 作者: A Andy Owen 提交者: Takashi Iwai

ALSA: ca0106: Pull out dac powering routine into separate function.

This is ground work for a future commit where cards (such as the Sound
Blaster 5.1vx) have different mappings between dacs and channels.
Signed-off-by: NAndy Owen <andy-alsa@ultra-premium.com>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 23156e8f
...@@ -514,6 +514,23 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) ...@@ -514,6 +514,23 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
} }
} }
static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
int power)
{
if (chip->details->spi_dac) {
const int reg = spi_dacd_reg[channel_id];
if (power)
/* Power up */
chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id];
else
/* Power down */
chip->spi_dac_reg[reg] |= spi_dacd_bit[channel_id];
return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
}
return 0;
}
/* open_playback callback */ /* open_playback callback */
static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream,
int channel_id) int channel_id)
...@@ -553,12 +570,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr ...@@ -553,12 +570,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
return err; return err;
snd_pcm_set_sync(substream); snd_pcm_set_sync(substream);
if (chip->details->spi_dac && channel_id != PCM_FRONT_CHANNEL) { /* Front channel dac should already be on */
const int reg = spi_dacd_reg[channel_id]; if (channel_id != PCM_FRONT_CHANNEL) {
err = snd_ca0106_pcm_power_dac(chip, channel_id, 1);
/* Power up dac */
chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id];
err = snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -578,13 +592,14 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream) ...@@ -578,13 +592,14 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream)
restore_spdif_bits(chip, epcm->channel_id); restore_spdif_bits(chip, epcm->channel_id);
if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) { /* Front channel dac should stay on */
const int reg = spi_dacd_reg[epcm->channel_id]; if (epcm->channel_id != PCM_FRONT_CHANNEL) {
int err;
/* Power down DAC */ err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0);
chip->spi_dac_reg[reg] |= spi_dacd_bit[epcm->channel_id]; if (err < 0)
snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); return err;
} }
/* FIXME: maybe zero others */ /* FIXME: maybe zero others */
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册