blob: 687e6a13689e7cd912ac99ca79b9a14883931a56 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
3 *
4 * Proc interface for Emu8k/Emu10k1 WaveTable synth
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/wait.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/slab.h>
23#include <sound/core.h>
24#include <sound/emux_synth.h>
25#include <sound/info.h>
26#include "emux_voice.h"
27
28#ifdef CONFIG_PROC_FS
29
30static void
Takashi Iwai03da3122005-11-17 14:24:47 +010031snd_emux_proc_info_read(struct snd_info_entry *entry,
32 struct snd_info_buffer *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Takashi Iwai03da3122005-11-17 14:24:47 +010034 struct snd_emux *emu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 int i;
36
37 emu = entry->private_data;
Ingo Molnaref9f0a42006-01-16 16:31:42 +010038 mutex_lock(&emu->register_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 if (emu->name)
40 snd_iprintf(buf, "Device: %s\n", emu->name);
41 snd_iprintf(buf, "Ports: %d\n", emu->num_ports);
42 snd_iprintf(buf, "Addresses:");
43 for (i = 0; i < emu->num_ports; i++)
44 snd_iprintf(buf, " %d:%d", emu->client, emu->ports[i]);
45 snd_iprintf(buf, "\n");
46 snd_iprintf(buf, "Use Counter: %d\n", emu->used);
47 snd_iprintf(buf, "Max Voices: %d\n", emu->max_voices);
48 snd_iprintf(buf, "Allocated Voices: %d\n", emu->num_voices);
49 if (emu->memhdr) {
50 snd_iprintf(buf, "Memory Size: %d\n", emu->memhdr->size);
51 snd_iprintf(buf, "Memory Available: %d\n", snd_util_mem_avail(emu->memhdr));
52 snd_iprintf(buf, "Allocated Blocks: %d\n", emu->memhdr->nblocks);
53 } else {
54 snd_iprintf(buf, "Memory Size: 0\n");
55 }
56 if (emu->sflist) {
Ingo Molnaref9f0a42006-01-16 16:31:42 +010057 mutex_lock(&emu->sflist->presets_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 snd_iprintf(buf, "SoundFonts: %d\n", emu->sflist->fonts_size);
59 snd_iprintf(buf, "Instruments: %d\n", emu->sflist->zone_counter);
60 snd_iprintf(buf, "Samples: %d\n", emu->sflist->sample_counter);
61 snd_iprintf(buf, "Locked Instruments: %d\n", emu->sflist->zone_locked);
62 snd_iprintf(buf, "Locked Samples: %d\n", emu->sflist->sample_locked);
Ingo Molnaref9f0a42006-01-16 16:31:42 +010063 mutex_unlock(&emu->sflist->presets_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 }
65#if 0 /* debug */
66 if (emu->voices[0].state != SNDRV_EMUX_ST_OFF && emu->voices[0].ch >= 0) {
Takashi Iwai03da3122005-11-17 14:24:47 +010067 struct snd_emux_voice *vp = &emu->voices[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 snd_iprintf(buf, "voice 0: on\n");
69 snd_iprintf(buf, "mod delay=%x, atkhld=%x, dcysus=%x, rel=%x\n",
70 vp->reg.parm.moddelay,
71 vp->reg.parm.modatkhld,
72 vp->reg.parm.moddcysus,
73 vp->reg.parm.modrelease);
74 snd_iprintf(buf, "vol delay=%x, atkhld=%x, dcysus=%x, rel=%x\n",
75 vp->reg.parm.voldelay,
76 vp->reg.parm.volatkhld,
77 vp->reg.parm.voldcysus,
78 vp->reg.parm.volrelease);
79 snd_iprintf(buf, "lfo1 delay=%x, lfo2 delay=%x, pefe=%x\n",
80 vp->reg.parm.lfo1delay,
81 vp->reg.parm.lfo2delay,
82 vp->reg.parm.pefe);
83 snd_iprintf(buf, "fmmod=%x, tremfrq=%x, fm2frq2=%x\n",
84 vp->reg.parm.fmmod,
85 vp->reg.parm.tremfrq,
86 vp->reg.parm.fm2frq2);
87 snd_iprintf(buf, "cutoff=%x, filterQ=%x, chorus=%x, reverb=%x\n",
88 vp->reg.parm.cutoff,
89 vp->reg.parm.filterQ,
90 vp->reg.parm.chorus,
91 vp->reg.parm.reverb);
92 snd_iprintf(buf, "avol=%x, acutoff=%x, apitch=%x\n",
93 vp->avol, vp->acutoff, vp->apitch);
94 snd_iprintf(buf, "apan=%x, aaux=%x, ptarget=%x, vtarget=%x, ftarget=%x\n",
95 vp->apan, vp->aaux,
96 vp->ptarget,
97 vp->vtarget,
98 vp->ftarget);
99 snd_iprintf(buf, "start=%x, end=%x, loopstart=%x, loopend=%x\n",
100 vp->reg.start, vp->reg.end, vp->reg.loopstart, vp->reg.loopend);
101 snd_iprintf(buf, "sample_mode=%x, rate=%x\n", vp->reg.sample_mode, vp->reg.rate_offset);
102 }
103#endif
Ingo Molnaref9f0a42006-01-16 16:31:42 +0100104 mutex_unlock(&emu->register_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105}
106
107
Takashi Iwai03da3122005-11-17 14:24:47 +0100108void snd_emux_proc_init(struct snd_emux *emu, struct snd_card *card, int device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
Takashi Iwai03da3122005-11-17 14:24:47 +0100110 struct snd_info_entry *entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 char name[64];
112
113 sprintf(name, "wavetableD%d", device);
114 entry = snd_info_create_card_entry(card, name, card->proc_root);
115 if (entry == NULL)
116 return;
117
118 entry->content = SNDRV_INFO_CONTENT_TEXT;
119 entry->private_data = emu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 entry->c.text.read = snd_emux_proc_info_read;
121 if (snd_info_register(entry) < 0)
122 snd_info_free_entry(entry);
123 else
124 emu->proc = entry;
125}
126
Takashi Iwai03da3122005-11-17 14:24:47 +0100127void snd_emux_proc_free(struct snd_emux *emu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128{
Takashi Iwai746d4a02006-06-23 14:37:59 +0200129 snd_info_free_entry(emu->proc);
130 emu->proc = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131}
132
133#endif /* CONFIG_PROC_FS */