26 #include <linux/slab.h>
28 #ifdef SNDRV_EMUX_USE_RAW_EFFECT
33 #define xoffsetof(type,tag) ((long)(&((type)NULL)->tag) - (long)(NULL))
35 #define parm_offset(tag) xoffsetof(struct soundfont_voice_parm *, tag)
37 #define PARM_IS_BYTE (1 << 0)
38 #define PARM_IS_WORD (1 << 1)
39 #define PARM_IS_ALIGNED (3 << 2)
40 #define PARM_IS_ALIGN_HI (1 << 2)
41 #define PARM_IS_ALIGN_LO (2 << 2)
42 #define PARM_IS_SIGNED (1 << 4)
44 #define PARM_WORD (PARM_IS_WORD)
45 #define PARM_BYTE_LO (PARM_IS_BYTE|PARM_IS_ALIGN_LO)
46 #define PARM_BYTE_HI (PARM_IS_BYTE|PARM_IS_ALIGN_HI)
47 #define PARM_BYTE (PARM_IS_BYTE)
48 #define PARM_SIGN_LO (PARM_IS_BYTE|PARM_IS_ALIGN_LO|PARM_IS_SIGNED)
49 #define PARM_SIGN_HI (PARM_IS_BYTE|PARM_IS_ALIGN_HI|PARM_IS_SIGNED)
51 static struct emux_parm_defs {
57 {PARM_WORD, 0, 0x8000, parm_offset(moddelay), 0},
58 {PARM_BYTE_LO, 1, 0x80, parm_offset(modatkhld), 0},
59 {PARM_BYTE_HI, 0, 0x7e, parm_offset(modatkhld), 0},
60 {PARM_BYTE_LO, 1, 0x7f, parm_offset(moddcysus), 0},
61 {PARM_BYTE_LO, 1, 0x7f, parm_offset(modrelease), 0},
62 {PARM_BYTE_HI, 0, 0x7f, parm_offset(moddcysus), 0},
63 {PARM_BYTE_HI, 0, 0xff, parm_offset(pefe), 0},
64 {PARM_BYTE_LO, 0, 0xff, parm_offset(pefe), 0},
66 {PARM_WORD, 0, 0x8000, parm_offset(voldelay), 0},
67 {PARM_BYTE_LO, 1, 0x80, parm_offset(volatkhld), 0},
68 {PARM_BYTE_HI, 0, 0x7e, parm_offset(volatkhld), 0},
69 {PARM_BYTE_LO, 1, 0x7f, parm_offset(voldcysus), 0},
70 {PARM_BYTE_LO, 1, 0x7f, parm_offset(volrelease), 0},
71 {PARM_BYTE_HI, 0, 0x7f, parm_offset(voldcysus), 0},
73 {PARM_WORD, 0, 0x8000, parm_offset(lfo1delay), 0},
79 {PARM_WORD, 0, 0x8000, parm_offset(lfo2delay), 0},
84 {PARM_BYTE, 0, 0xff, parm_offset(chorus), 0},
85 {PARM_BYTE, 0, 0xff, parm_offset(reverb), 0},
89 {PARM_WORD, 0, 0xffff, -1, 0},
90 {PARM_WORD, 0, 0xffff, -1, 0},
91 {PARM_WORD, 0, 0xffff, -1, 0},
92 {PARM_WORD, 0, 0xffff, -1, 0},
93 {PARM_WORD, 0, 0xffff, -1, 0},
94 {PARM_WORD, 0, 0xffff, -1, 0},
107 if (parm_defs[type].type & PARM_IS_SIGNED)
108 effect += *(
char*)valp;
112 if (effect < parm_defs[type].
low)
113 effect = parm_defs[
type].low;
114 else if (effect > parm_defs[type].
high)
115 effect = parm_defs[
type].high;
116 *valp = (
unsigned char)effect;
121 effect_set_word(
unsigned short *valp,
struct snd_midi_channel *chan,
int type)
126 effect = *(
unsigned short*)&fx->
val[type];
129 if (effect < parm_defs[type].low)
130 effect = parm_defs[
type].low;
131 else if (effect > parm_defs[type].
high)
132 effect = parm_defs[
type].high;
133 *valp = (
unsigned short)effect;
153 #ifdef CONFIG_SND_SEQUENCER_OSS
163 else if (type & 0x80)
169 snd_emux_send_effect(port, chan, type, val, mode);
178 int type,
int val,
int mode)
182 unsigned char *srcp, *origp;
198 if (! parm_defs[type].
update || (offset = parm_defs[type].offset) < 0)
201 #ifdef SNDRV_LITTLE_ENDIAN
202 if (parm_defs[type].type & PARM_IS_ALIGN_HI)
205 if (parm_defs[type].type & PARM_IS_ALIGN_LO)
214 srcp = (
unsigned char*)&vp->
reg.parm + offset;
215 origp = (
unsigned char*)&vp->
zone->v.parm +
offset;
216 if (parm_defs[i].type & PARM_IS_BYTE) {
218 effect_set_byte(srcp, chan, type);
220 *(
unsigned short*)srcp = *(
unsigned short*)origp;
221 effect_set_word((
unsigned short*)srcp, chan, type);
224 spin_unlock_irqrestore(&emu->
voice_lock, flags);
246 if (! fx->
flag[i] || (offset = parm_defs[i].offset) < 0)
248 #ifdef SNDRV_LITTLE_ENDIAN
249 if (parm_defs[i].type & PARM_IS_ALIGN_HI)
252 if (parm_defs[i].type & PARM_IS_ALIGN_LO)
255 srcp = (
unsigned char*)&vp->
reg.parm + offset;
256 if (parm_defs[i].type & PARM_IS_BYTE)
257 effect_set_byte(srcp, chan, i);
259 effect_set_word((
unsigned short*)srcp, chan, i);
265 vp->
reg.sample_mode);
269 vp->
reg.sample_mode);
273 vp->
reg.sample_mode);
286 for (i = 0; i < p->
chset.max_channels; i++)
289 for (i = 0; i < p->
chset.max_channels; i++)
306 p->
chset.max_channels);