blob: 60dd8a091bc39fdd7d4090344f0205f609612ab6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Vortex Mixer support.
4 *
5 * There is much more than just the AC97 mixer...
6 *
7 */
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/time.h>
10#include <linux/init.h>
11#include <sound/core.h>
12#include "au88x0.h"
13
Raymond Yau223f18e2012-06-04 14:59:55 +080014static int remove_ctl(struct snd_card *card, const char *name)
15{
16 struct snd_ctl_elem_id id;
17 memset(&id, 0, sizeof(id));
18 strcpy(id.name, name);
19 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
20 return snd_ctl_remove_id(card, &id);
21}
22
Bill Pembertone23e7a12012-12-06 12:35:10 -050023static int snd_vortex_mixer(vortex_t *vortex)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
Takashi Iwai2fd16872005-11-17 14:55:19 +010025 struct snd_ac97_bus *pbus;
26 struct snd_ac97_template ac97;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 int err;
Takashi Iwai2fd16872005-11-17 14:55:19 +010028 static struct snd_ac97_bus_ops ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 .write = vortex_codec_write,
30 .read = vortex_codec_read,
31 };
32
33 if ((err = snd_ac97_bus(vortex->card, 0, &ops, NULL, &pbus)) < 0)
34 return err;
35 memset(&ac97, 0, sizeof(ac97));
Andrea Gelminifa2eb002010-10-16 15:19:20 +020036 // Initialize AC97 codec stuff.
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 ac97.private_data = vortex;
38 ac97.scaps = AC97_SCAP_NO_SPDIF;
39 err = snd_ac97_mixer(pbus, &ac97, &vortex->codec);
40 vortex->isquad = ((vortex->codec == NULL) ? 0 : (vortex->codec->ext_id&0x80));
Raymond Yau223f18e2012-06-04 14:59:55 +080041 remove_ctl(vortex->card, "Master Mono Playback Volume");
42 remove_ctl(vortex->card, "Master Mono Playback Switch");
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 return err;
44}