Skip to content

Commit

Permalink
ALSA: ymfpci - Don't create invalid PCM & mixers when AC97 doesn't su…
Browse files Browse the repository at this point in the history
…pport

- check SDAC bit of AC97 primary codec when create "rear" device 3,
  "4ch" device 2 and "4ch Duplication" switch as the card need a four channels
  AC97 codec to support surround40.

Signed-off-by: Raymond Yau <superquad.vortex2@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Raymond Yau authored and Takashi Iwai committed Jan 24, 2012
1 parent b4ead01 commit 4d20bb1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
21 changes: 13 additions & 8 deletions sound/pci/ymfpci/ymfpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,22 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci,
snd_card_free(card);
return err;
}
if ((err = snd_ymfpci_pcm_4ch(chip, 2, NULL)) < 0) {
err = snd_ymfpci_mixer(chip, rear_switch[dev]);
if (err < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_ymfpci_pcm2(chip, 3, NULL)) < 0) {
snd_card_free(card);
return err;
}
if ((err = snd_ymfpci_mixer(chip, rear_switch[dev])) < 0) {
snd_card_free(card);
return err;
if (chip->ac97->ext_id & AC97_EI_SDAC) {
err = snd_ymfpci_pcm_4ch(chip, 2, NULL);
if (err < 0) {
snd_card_free(card);
return err;
}
err = snd_ymfpci_pcm2(chip, 3, NULL);
if (err < 0) {
snd_card_free(card);
return err;
}
}
if ((err = snd_ymfpci_timer(chip, 0)) < 0) {
snd_card_free(card);
Expand Down
21 changes: 14 additions & 7 deletions sound/pci/ymfpci/ymfpci_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,14 @@ static int snd_ymfpci_put_dup4ch(struct snd_kcontrol *kcontrol, struct snd_ctl_e
return change;
}

static struct snd_kcontrol_new snd_ymfpci_dup4ch __devinitdata = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "4ch Duplication",
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
.info = snd_ymfpci_info_dup4ch,
.get = snd_ymfpci_get_dup4ch,
.put = snd_ymfpci_put_dup4ch,
};

static struct snd_kcontrol_new snd_ymfpci_controls[] __devinitdata = {
{
Expand Down Expand Up @@ -1642,13 +1650,6 @@ YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,VOLUME), 1, YDSXGR_SPDIFLOOPVOL),
YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 0, YDSXGR_SPDIFOUTCTRL, 0),
YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, YDSXGR_SPDIFINCTRL, 0),
YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("Loop",NONE,NONE), 0, YDSXGR_SPDIFINCTRL, 4),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "4ch Duplication",
.info = snd_ymfpci_info_dup4ch,
.get = snd_ymfpci_get_dup4ch,
.put = snd_ymfpci_put_dup4ch,
},
};


Expand Down Expand Up @@ -1838,6 +1839,12 @@ int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch)
if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip))) < 0)
return err;
}
if (chip->ac97->ext_id & AC97_EI_SDAC) {
kctl = snd_ctl_new1(&snd_ymfpci_dup4ch, chip);
err = snd_ctl_add(chip->card, kctl);
if (err < 0)
return err;
}

/* add S/PDIF control */
if (snd_BUG_ON(!chip->pcm_spdif))
Expand Down

0 comments on commit 4d20bb1

Please sign in to comment.