aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@suse.cz>2006-01-18 02:02:24 -0500
committerJaroslav Kysela <perex@suse.cz>2006-03-22 04:26:21 -0500
commit5a25c5cfd4f61f514decca3c4106210fb168ce19 (patch)
treeb79f15c8dd90d682233c231b43ce0ed932a5b126
parent12aa757905d09b1dc2c1c3d0de3fa8f4c9726f2b (diff)
[ALSA] ymfpci - make rear channel swap optional
Modules: YMFPCI driver Added rear_swap module option / kernel parameter to configure the rear channel swapping. Default value is enable to make the AC3 passthrough working, but analog only users might revert the previous behaviour. Signed-off-by: Jaroslav Kysela <perex@suse.cz>
-rw-r--r--include/sound/ymfpci.h10
-rw-r--r--sound/pci/ymfpci/ymfpci.c5
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c42
3 files changed, 38 insertions, 19 deletions
diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h
index d567bfdbf513..d41cda97e952 100644
--- a/include/sound/ymfpci.h
+++ b/include/sound/ymfpci.h
@@ -269,9 +269,10 @@ struct snd_ymfpci_pcm {
269 enum snd_ymfpci_pcm_type type; 269 enum snd_ymfpci_pcm_type type;
270 struct snd_pcm_substream *substream; 270 struct snd_pcm_substream *substream;
271 struct snd_ymfpci_voice *voices[2]; /* playback only */ 271 struct snd_ymfpci_voice *voices[2]; /* playback only */
272 unsigned int running: 1; 272 unsigned int running: 1,
273 unsigned int output_front: 1; 273 output_front: 1,
274 unsigned int output_rear: 1; 274 output_rear: 1,
275 swap_rear: 1;
275 unsigned int update_pcm_vol; 276 unsigned int update_pcm_vol;
276 u32 period_size; /* cached from runtime->period_size */ 277 u32 period_size; /* cached from runtime->period_size */
277 u32 buffer_size; /* cached from runtime->buffer_size */ 278 u32 buffer_size; /* cached from runtime->buffer_size */
@@ -344,6 +345,7 @@ struct snd_ymfpci {
344 struct snd_kcontrol *spdif_pcm_ctl; 345 struct snd_kcontrol *spdif_pcm_ctl;
345 int mode_dup4ch; 346 int mode_dup4ch;
346 int rear_opened; 347 int rear_opened;
348 int rear_swap;
347 int spdif_opened; 349 int spdif_opened;
348 struct { 350 struct {
349 u16 left; 351 u16 left;
@@ -376,7 +378,7 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm);
376int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); 378int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm);
377int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); 379int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm);
378int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); 380int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm);
379int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch); 381int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch, int rear_swap);
380int snd_ymfpci_timer(struct snd_ymfpci *chip, int device); 382int snd_ymfpci_timer(struct snd_ymfpci *chip, int device);
381 383
382#endif /* __SOUND_YMFPCI_H */ 384#endif /* __SOUND_YMFPCI_H */
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index dab9b8310341..db57ce939fa8 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -49,6 +49,7 @@ static long mpu_port[SNDRV_CARDS];
49static long joystick_port[SNDRV_CARDS]; 49static long joystick_port[SNDRV_CARDS];
50#endif 50#endif
51static int rear_switch[SNDRV_CARDS]; 51static int rear_switch[SNDRV_CARDS];
52static int rear_swap[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 1 };
52 53
53module_param_array(index, int, NULL, 0444); 54module_param_array(index, int, NULL, 0444);
54MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard."); 55MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard.");
@@ -66,6 +67,8 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address");
66#endif 67#endif
67module_param_array(rear_switch, bool, NULL, 0444); 68module_param_array(rear_switch, bool, NULL, 0444);
68MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); 69MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch");
70module_param_array(rear_swap, bool, NULL, 0444);
71MODULE_PARM_DESC(rear_swap, "Swap rear channels (must be enabled for correct IEC958 (S/PDIF)) output");
69 72
70static struct pci_device_id snd_ymfpci_ids[] = { 73static struct pci_device_id snd_ymfpci_ids[] = {
71 { 0x1073, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF724 */ 74 { 0x1073, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF724 */
@@ -295,7 +298,7 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci,
295 snd_card_free(card); 298 snd_card_free(card);
296 return err; 299 return err;
297 } 300 }
298 if ((err = snd_ymfpci_mixer(chip, rear_switch[dev])) < 0) { 301 if ((err = snd_ymfpci_mixer(chip, rear_switch[dev], rear_swap[dev])) < 0) {
299 snd_card_free(card); 302 snd_card_free(card);
300 return err; 303 return err;
301 } 304 }
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 30ee53adb494..8ac5ab50b5c7 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -536,19 +536,30 @@ static void snd_ymfpci_pcm_init_voice(struct snd_ymfpci_pcm *ypcm, unsigned int
536 } 536 }
537 } 537 }
538 if (ypcm->output_rear) { 538 if (ypcm->output_rear) {
539 /* The SPDIF out channels seem to be swapped, so we have 539 if (!ypcm->swap_rear) {
540 * to swap them here, too. The rear analog out channels 540 if (use_left) {
541 * will be wrong, but otherwise AC3 would not work. 541 bank->eff2_gain =
542 */ 542 bank->eff2_gain_end = vol_left;
543 if (use_left) { 543 }
544 bank->eff3_gain = 544 if (use_right) {
545 bank->eff3_gain_end = vol_left; 545 bank->eff3_gain =
546 } 546 bank->eff3_gain_end = vol_right;
547 if (use_right) { 547 }
548 bank->eff2_gain = 548 } else {
549 bank->eff2_gain_end = vol_right; 549 /* The SPDIF out channels seem to be swapped, so we have
550 } 550 * to swap them here, too. The rear analog out channels
551 } 551 * will be wrong, but otherwise AC3 would not work.
552 */
553 if (use_left) {
554 bank->eff3_gain =
555 bank->eff3_gain_end = vol_left;
556 }
557 if (use_right) {
558 bank->eff2_gain =
559 bank->eff2_gain_end = vol_right;
560 }
561 }
562 }
552 } 563 }
553} 564}
554 565
@@ -898,6 +909,7 @@ static int snd_ymfpci_playback_open(struct snd_pcm_substream *substream)
898 ypcm = runtime->private_data; 909 ypcm = runtime->private_data;
899 ypcm->output_front = 1; 910 ypcm->output_front = 1;
900 ypcm->output_rear = chip->mode_dup4ch ? 1 : 0; 911 ypcm->output_rear = chip->mode_dup4ch ? 1 : 0;
912 ypcm->swap_rear = chip->rear_swap;
901 spin_lock_irq(&chip->reg_lock); 913 spin_lock_irq(&chip->reg_lock);
902 if (ypcm->output_rear) { 914 if (ypcm->output_rear) {
903 ymfpci_open_extension(chip); 915 ymfpci_open_extension(chip);
@@ -1738,7 +1750,7 @@ static void snd_ymfpci_mixer_free_ac97(struct snd_ac97 *ac97)
1738 chip->ac97 = NULL; 1750 chip->ac97 = NULL;
1739} 1751}
1740 1752
1741int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) 1753int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch, int rear_swap)
1742{ 1754{
1743 struct snd_ac97_template ac97; 1755 struct snd_ac97_template ac97;
1744 struct snd_kcontrol *kctl; 1756 struct snd_kcontrol *kctl;
@@ -1750,6 +1762,7 @@ int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch)
1750 .read = snd_ymfpci_codec_read, 1762 .read = snd_ymfpci_codec_read,
1751 }; 1763 };
1752 1764
1765 chip->rear_swap = rear_swap;
1753 if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) 1766 if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0)
1754 return err; 1767 return err;
1755 chip->ac97_bus->private_free = snd_ymfpci_mixer_free_ac97_bus; 1768 chip->ac97_bus->private_free = snd_ymfpci_mixer_free_ac97_bus;
@@ -2297,6 +2310,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
2297 return -EIO; 2310 return -EIO;
2298 } 2311 }
2299 2312
2313 chip->rear_swap = 1;
2300 if ((err = snd_ymfpci_ac3_init(chip)) < 0) { 2314 if ((err = snd_ymfpci_ac3_init(chip)) < 0) {
2301 snd_ymfpci_free(chip); 2315 snd_ymfpci_free(chip);
2302 return err; 2316 return err;