18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Proc interface for Emu8k/Emu10k1 WaveTable synth
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/wait.h>
98c2ecf20Sopenharmony_ci#include <sound/core.h>
108c2ecf20Sopenharmony_ci#include <sound/emux_synth.h>
118c2ecf20Sopenharmony_ci#include <sound/info.h>
128c2ecf20Sopenharmony_ci#include "emux_voice.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistatic void
158c2ecf20Sopenharmony_cisnd_emux_proc_info_read(struct snd_info_entry *entry,
168c2ecf20Sopenharmony_ci			struct snd_info_buffer *buf)
178c2ecf20Sopenharmony_ci{
188c2ecf20Sopenharmony_ci	struct snd_emux *emu;
198c2ecf20Sopenharmony_ci	int i;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	emu = entry->private_data;
228c2ecf20Sopenharmony_ci	mutex_lock(&emu->register_mutex);
238c2ecf20Sopenharmony_ci	if (emu->name)
248c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Device: %s\n", emu->name);
258c2ecf20Sopenharmony_ci	snd_iprintf(buf, "Ports: %d\n", emu->num_ports);
268c2ecf20Sopenharmony_ci	snd_iprintf(buf, "Addresses:");
278c2ecf20Sopenharmony_ci	for (i = 0; i < emu->num_ports; i++)
288c2ecf20Sopenharmony_ci		snd_iprintf(buf, " %d:%d", emu->client, emu->ports[i]);
298c2ecf20Sopenharmony_ci	snd_iprintf(buf, "\n");
308c2ecf20Sopenharmony_ci	snd_iprintf(buf, "Use Counter: %d\n", emu->used);
318c2ecf20Sopenharmony_ci	snd_iprintf(buf, "Max Voices: %d\n", emu->max_voices);
328c2ecf20Sopenharmony_ci	snd_iprintf(buf, "Allocated Voices: %d\n", emu->num_voices);
338c2ecf20Sopenharmony_ci	if (emu->memhdr) {
348c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Memory Size: %d\n", emu->memhdr->size);
358c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Memory Available: %d\n", snd_util_mem_avail(emu->memhdr));
368c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Allocated Blocks: %d\n", emu->memhdr->nblocks);
378c2ecf20Sopenharmony_ci	} else {
388c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Memory Size: 0\n");
398c2ecf20Sopenharmony_ci	}
408c2ecf20Sopenharmony_ci	if (emu->sflist) {
418c2ecf20Sopenharmony_ci		mutex_lock(&emu->sflist->presets_mutex);
428c2ecf20Sopenharmony_ci		snd_iprintf(buf, "SoundFonts: %d\n", emu->sflist->fonts_size);
438c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Instruments: %d\n", emu->sflist->zone_counter);
448c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Samples: %d\n", emu->sflist->sample_counter);
458c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Locked Instruments: %d\n", emu->sflist->zone_locked);
468c2ecf20Sopenharmony_ci		snd_iprintf(buf, "Locked Samples: %d\n", emu->sflist->sample_locked);
478c2ecf20Sopenharmony_ci		mutex_unlock(&emu->sflist->presets_mutex);
488c2ecf20Sopenharmony_ci	}
498c2ecf20Sopenharmony_ci#if 0  /* debug */
508c2ecf20Sopenharmony_ci	if (emu->voices[0].state != SNDRV_EMUX_ST_OFF && emu->voices[0].ch >= 0) {
518c2ecf20Sopenharmony_ci		struct snd_emux_voice *vp = &emu->voices[0];
528c2ecf20Sopenharmony_ci		snd_iprintf(buf, "voice 0: on\n");
538c2ecf20Sopenharmony_ci		snd_iprintf(buf, "mod delay=%x, atkhld=%x, dcysus=%x, rel=%x\n",
548c2ecf20Sopenharmony_ci			    vp->reg.parm.moddelay,
558c2ecf20Sopenharmony_ci			    vp->reg.parm.modatkhld,
568c2ecf20Sopenharmony_ci			    vp->reg.parm.moddcysus,
578c2ecf20Sopenharmony_ci			    vp->reg.parm.modrelease);
588c2ecf20Sopenharmony_ci		snd_iprintf(buf, "vol delay=%x, atkhld=%x, dcysus=%x, rel=%x\n",
598c2ecf20Sopenharmony_ci			    vp->reg.parm.voldelay,
608c2ecf20Sopenharmony_ci			    vp->reg.parm.volatkhld,
618c2ecf20Sopenharmony_ci			    vp->reg.parm.voldcysus,
628c2ecf20Sopenharmony_ci			    vp->reg.parm.volrelease);
638c2ecf20Sopenharmony_ci		snd_iprintf(buf, "lfo1 delay=%x, lfo2 delay=%x, pefe=%x\n",
648c2ecf20Sopenharmony_ci			    vp->reg.parm.lfo1delay,
658c2ecf20Sopenharmony_ci			    vp->reg.parm.lfo2delay,
668c2ecf20Sopenharmony_ci			    vp->reg.parm.pefe);
678c2ecf20Sopenharmony_ci		snd_iprintf(buf, "fmmod=%x, tremfrq=%x, fm2frq2=%x\n",
688c2ecf20Sopenharmony_ci			    vp->reg.parm.fmmod,
698c2ecf20Sopenharmony_ci			    vp->reg.parm.tremfrq,
708c2ecf20Sopenharmony_ci			    vp->reg.parm.fm2frq2);
718c2ecf20Sopenharmony_ci		snd_iprintf(buf, "cutoff=%x, filterQ=%x, chorus=%x, reverb=%x\n",
728c2ecf20Sopenharmony_ci			    vp->reg.parm.cutoff,
738c2ecf20Sopenharmony_ci			    vp->reg.parm.filterQ,
748c2ecf20Sopenharmony_ci			    vp->reg.parm.chorus,
758c2ecf20Sopenharmony_ci			    vp->reg.parm.reverb);
768c2ecf20Sopenharmony_ci		snd_iprintf(buf, "avol=%x, acutoff=%x, apitch=%x\n",
778c2ecf20Sopenharmony_ci			    vp->avol, vp->acutoff, vp->apitch);
788c2ecf20Sopenharmony_ci		snd_iprintf(buf, "apan=%x, aaux=%x, ptarget=%x, vtarget=%x, ftarget=%x\n",
798c2ecf20Sopenharmony_ci			    vp->apan, vp->aaux,
808c2ecf20Sopenharmony_ci			    vp->ptarget,
818c2ecf20Sopenharmony_ci			    vp->vtarget,
828c2ecf20Sopenharmony_ci			    vp->ftarget);
838c2ecf20Sopenharmony_ci		snd_iprintf(buf, "start=%x, end=%x, loopstart=%x, loopend=%x\n",
848c2ecf20Sopenharmony_ci			    vp->reg.start, vp->reg.end, vp->reg.loopstart, vp->reg.loopend);
858c2ecf20Sopenharmony_ci		snd_iprintf(buf, "sample_mode=%x, rate=%x\n", vp->reg.sample_mode, vp->reg.rate_offset);
868c2ecf20Sopenharmony_ci	}
878c2ecf20Sopenharmony_ci#endif
888c2ecf20Sopenharmony_ci	mutex_unlock(&emu->register_mutex);
898c2ecf20Sopenharmony_ci}
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_civoid snd_emux_proc_init(struct snd_emux *emu, struct snd_card *card, int device)
938c2ecf20Sopenharmony_ci{
948c2ecf20Sopenharmony_ci	struct snd_info_entry *entry;
958c2ecf20Sopenharmony_ci	char name[64];
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	sprintf(name, "wavetableD%d", device);
988c2ecf20Sopenharmony_ci	entry = snd_info_create_card_entry(card, name, card->proc_root);
998c2ecf20Sopenharmony_ci	if (entry == NULL)
1008c2ecf20Sopenharmony_ci		return;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	entry->content = SNDRV_INFO_CONTENT_TEXT;
1038c2ecf20Sopenharmony_ci	entry->private_data = emu;
1048c2ecf20Sopenharmony_ci	entry->c.text.read = snd_emux_proc_info_read;
1058c2ecf20Sopenharmony_ci}
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_civoid snd_emux_proc_free(struct snd_emux *emu)
1088c2ecf20Sopenharmony_ci{
1098c2ecf20Sopenharmony_ci	snd_info_free_entry(emu->proc);
1108c2ecf20Sopenharmony_ci	emu->proc = NULL;
1118c2ecf20Sopenharmony_ci}
112