18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Vortex Mixer support.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * There is much more than just the AC97 mixer...
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/time.h>
108c2ecf20Sopenharmony_ci#include <linux/init.h>
118c2ecf20Sopenharmony_ci#include <sound/core.h>
128c2ecf20Sopenharmony_ci#include "au88x0.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistatic int remove_ctl(struct snd_card *card, const char *name)
158c2ecf20Sopenharmony_ci{
168c2ecf20Sopenharmony_ci	struct snd_ctl_elem_id id;
178c2ecf20Sopenharmony_ci	memset(&id, 0, sizeof(id));
188c2ecf20Sopenharmony_ci	strcpy(id.name, name);
198c2ecf20Sopenharmony_ci	id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
208c2ecf20Sopenharmony_ci	return snd_ctl_remove_id(card, &id);
218c2ecf20Sopenharmony_ci}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic int snd_vortex_mixer(vortex_t *vortex)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	struct snd_ac97_bus *pbus;
268c2ecf20Sopenharmony_ci	struct snd_ac97_template ac97;
278c2ecf20Sopenharmony_ci	int err;
288c2ecf20Sopenharmony_ci	static const struct snd_ac97_bus_ops ops = {
298c2ecf20Sopenharmony_ci		.write = vortex_codec_write,
308c2ecf20Sopenharmony_ci		.read = vortex_codec_read,
318c2ecf20Sopenharmony_ci	};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	if ((err = snd_ac97_bus(vortex->card, 0, &ops, NULL, &pbus)) < 0)
348c2ecf20Sopenharmony_ci		return err;
358c2ecf20Sopenharmony_ci	memset(&ac97, 0, sizeof(ac97));
368c2ecf20Sopenharmony_ci	// Initialize AC97 codec stuff.
378c2ecf20Sopenharmony_ci	ac97.private_data = vortex;
388c2ecf20Sopenharmony_ci	ac97.scaps = AC97_SCAP_NO_SPDIF;
398c2ecf20Sopenharmony_ci	err = snd_ac97_mixer(pbus, &ac97, &vortex->codec);
408c2ecf20Sopenharmony_ci	vortex->isquad = ((vortex->codec == NULL) ?  0 : (vortex->codec->ext_id&0x80));
418c2ecf20Sopenharmony_ci	remove_ctl(vortex->card, "Master Mono Playback Volume");
428c2ecf20Sopenharmony_ci	remove_ctl(vortex->card, "Master Mono Playback Switch");
438c2ecf20Sopenharmony_ci	return err;
448c2ecf20Sopenharmony_ci}
45