Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Owen <andy-alsa@ultra-premium.com>
To: patch@alsa-project.org
Cc: alsa-devel@alsa-project.org, Andy Owen <andy-alsa@ultra-premium.com>
Subject: [PATCH - ca0106 4/6] ALSA: ca0106: Create a nice spot for mapping channels to dacs.
Date: Thu, 21 Oct 2010 23:39:22 +1100	[thread overview]
Message-ID: <1287664764-4996-4-git-send-email-andy-alsa@ultra-premium.com> (raw)
In-Reply-To: <1287664764-4996-1-git-send-email-andy-alsa@ultra-premium.com>


Signed-off-by: Andy Owen <andy-alsa@ultra-premium.com>

diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 46ae98d..da91003 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)
 }
 
 static const int spi_dacd_reg[] = {
-	[PCM_FRONT_CHANNEL]	= SPI_DACD4_REG,
-	[PCM_REAR_CHANNEL]	= SPI_DACD0_REG,
-	[PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_REG,
-	[PCM_UNKNOWN_CHANNEL]	= SPI_DACD1_REG,
+	SPI_DACD0_REG,
+	SPI_DACD1_REG,
+	SPI_DACD2_REG,
+	0,
+	SPI_DACD4_REG,
 };
 static const int spi_dacd_bit[] = {
-	[PCM_FRONT_CHANNEL]	= SPI_DACD4_BIT,
-	[PCM_REAR_CHANNEL]	= SPI_DACD0_BIT,
-	[PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_BIT,
-	[PCM_UNKNOWN_CHANNEL]	= SPI_DACD1_BIT,
+	SPI_DACD0_BIT,
+	SPI_DACD1_BIT,
+	SPI_DACD2_BIT,
+	0,
+	SPI_DACD4_BIT,
 };
 
 static 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)
 	}
 }
 
+static int snd_ca0106_channel_dac(struct snd_ca0106_details *details,
+				  int channel_id)
+{
+	switch (channel_id) {
+	case PCM_FRONT_CHANNEL:		return 4;
+	case PCM_REAR_CHANNEL:		return 0;
+	case PCM_CENTER_LFE_CHANNEL:	return 2;
+	case PCM_UNKNOWN_CHANNEL:	return 1;
+	}
+	snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n", channel_id);
+	return 0;
+}
+
 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];
+		const int dac = snd_ca0106_channel_dac(chip->details,
+						       channel_id);
+		const int reg = spi_dacd_reg[dac];
+		const int bit = spi_dacd_bit[dac];
 
 		if (power)
 			/* Power up */
-			chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id];
+			chip->spi_dac_reg[reg] &= ~bit;
 		else
 			/* Power down */
-			chip->spi_dac_reg[reg] |= spi_dacd_bit[channel_id];
+			chip->spi_dac_reg[reg] |= bit;
 		return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
 	}
 	return 0;
-- 
1.7.3.1.127.g1bb28

  parent reply	other threads:[~2010-10-21 12:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 12:39 [PATCH - ca0106 1/6] ALSA: ca0106 - add Sound Blaster 5.1vx info Andy Owen
2010-10-21 12:39 ` [PATCH - ca0106 2/6] ALSA: ca0106: Pull out dac powering routine into separate function Andy Owen
2010-10-21 12:39 ` [PATCH - ca0106 3/6] ALSA: ca0106: Move enabling of front dac out of hardcoded setup sequence Andy Owen
2010-10-21 12:39 ` Andy Owen [this message]
2010-10-21 12:39 ` [PATCH - ca0106 5/6] ALSA: ca0106: Allow different sound cards to use different SPI channel mappings Andy Owen
2010-10-21 12:39 ` [PATCH - ca0106 6/6] ALSA: ca0106: Use card specific dac id for mute controls Andy Owen
2010-10-21 21:16 ` [PATCH - ca0106 1/6] ALSA: ca0106 - add Sound Blaster 5.1vx info Takashi Iwai
2010-10-23  6:28   ` Andy Owen
     [not found]   ` <1287814690.1940.4.camel@marvin>
2010-10-23  9:22     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287664764-4996-4-git-send-email-andy-alsa@ultra-premium.com \
    --to=andy-alsa@ultra-premium.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=patch@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox