aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106
diff options
context:
space:
mode:
authorAndy Owen <andy-alsa@ultra-premium.com>2010-10-23 07:12:31 -0400
committerTakashi Iwai <tiwai@suse.de>2010-10-23 10:59:16 -0400
commit861391d3a037fab38020c741baffdb147e1c732a (patch)
tree4c036318d4ff911da8537f750e70020498d4759b /sound/pci/ca0106
parent9bfd94132dd97b76af41024eb7e980a5cb41afee (diff)
ALSA: ca0106: Create a nice spot for mapping channels to dacs.
This is to allow a future patch to have card specific mappings between dacs, which is required since the Sound Blaster 5.1vx seems to have a different mapping to what was previously used. Signed-off-by: Andy Owen <andy-alsa@ultra-premium.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ca0106')
-rw-r--r--sound/pci/ca0106/ca0106_main.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 46ae98d9cb49..da910031edfa 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -493,16 +493,18 @@ static void snd_ca0106_pcm_free_substream(struct snd_pcm_runtime *runtime)
493} 493}
494 494
495static const int spi_dacd_reg[] = { 495static const int spi_dacd_reg[] = {
496 [PCM_FRONT_CHANNEL] = SPI_DACD4_REG, 496 SPI_DACD0_REG,
497 [PCM_REAR_CHANNEL] = SPI_DACD0_REG, 497 SPI_DACD1_REG,
498 [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_REG, 498 SPI_DACD2_REG,
499 [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_REG, 499 0,
500 SPI_DACD4_REG,
500}; 501};
501static const int spi_dacd_bit[] = { 502static const int spi_dacd_bit[] = {
502 [PCM_FRONT_CHANNEL] = SPI_DACD4_BIT, 503 SPI_DACD0_BIT,
503 [PCM_REAR_CHANNEL] = SPI_DACD0_BIT, 504 SPI_DACD1_BIT,
504 [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_BIT, 505 SPI_DACD2_BIT,
505 [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT, 506 0,
507 SPI_DACD4_BIT,
506}; 508};
507 509
508static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) 510static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
@@ -514,18 +516,34 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
514 } 516 }
515} 517}
516 518
519static int snd_ca0106_channel_dac(struct snd_ca0106_details *details,
520 int channel_id)
521{
522 switch (channel_id) {
523 case PCM_FRONT_CHANNEL: return 4;
524 case PCM_REAR_CHANNEL: return 0;
525 case PCM_CENTER_LFE_CHANNEL: return 2;
526 case PCM_UNKNOWN_CHANNEL: return 1;
527 }
528 snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n", channel_id);
529 return 0;
530}
531
517static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id, 532static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
518 int power) 533 int power)
519{ 534{
520 if (chip->details->spi_dac) { 535 if (chip->details->spi_dac) {
521 const int reg = spi_dacd_reg[channel_id]; 536 const int dac = snd_ca0106_channel_dac(chip->details,
537 channel_id);
538 const int reg = spi_dacd_reg[dac];
539 const int bit = spi_dacd_bit[dac];
522 540
523 if (power) 541 if (power)
524 /* Power up */ 542 /* Power up */
525 chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id]; 543 chip->spi_dac_reg[reg] &= ~bit;
526 else 544 else
527 /* Power down */ 545 /* Power down */
528 chip->spi_dac_reg[reg] |= spi_dacd_bit[channel_id]; 546 chip->spi_dac_reg[reg] |= bit;
529 return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); 547 return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
530 } 548 }
531 return 0; 549 return 0;