vserver 1.9.3
[linux-2.6.git] / sound / core / seq / instr / ainstr_iw.c
1 /*
2  *   IWFFFF - AMD InterWave (tm) - Instrument routines
3  *   Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *   GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18  *
19  */
20  
21 #include <sound/driver.h>
22 #include <linux/init.h>
23 #include <linux/sched.h>
24 #include <linux/slab.h>
25 #include <sound/core.h>
26 #include <sound/ainstr_iw.h>
27 #include <sound/initval.h>
28 #include <asm/uaccess.h>
29
30 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
31 MODULE_DESCRIPTION("Advanced Linux Sound Architecture IWFFFF support.");
32 MODULE_LICENSE("GPL");
33
34 char *snd_seq_iwffff_id = SNDRV_SEQ_INSTR_ID_INTERWAVE;
35
36 static unsigned int snd_seq_iwffff_size(unsigned int size, unsigned int format)
37 {
38         unsigned int result = size;
39         
40         if (format & IWFFFF_WAVE_16BIT)
41                 result <<= 1;
42         if (format & IWFFFF_WAVE_STEREO)
43                 result <<= 1;
44         return result;
45 }
46
47 static void snd_seq_iwffff_copy_lfo_from_stream(iwffff_lfo_t *fp,
48                                                 iwffff_xlfo_t *fx)
49 {
50         fp->freq = le16_to_cpu(fx->freq);
51         fp->depth = le16_to_cpu(fx->depth);
52         fp->sweep = le16_to_cpu(fx->sweep);
53         fp->shape = fx->shape;
54         fp->delay = fx->delay;
55 }
56
57 static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype,
58                                                iwffff_layer_t *lp,
59                                                iwffff_env_t *ep,
60                                                iwffff_xenv_t *ex,
61                                                char __user **data,
62                                                long *len,
63                                                int gfp_mask)
64 {
65         __u32 stype;
66         iwffff_env_record_t *rp, *rp_last;
67         iwffff_xenv_record_t rx;
68         iwffff_env_point_t *pp;
69         iwffff_xenv_point_t px;
70         int points_size, idx;
71
72         ep->flags = ex->flags;
73         ep->mode = ex->mode;
74         ep->index = ex->index;
75         rp_last = NULL;
76         while (1) {
77                 if (*len < (long)sizeof(__u32))
78                         return -EINVAL;
79                 if (copy_from_user(&stype, *data, sizeof(stype)))
80                         return -EFAULT;
81                 if (stype == IWFFFF_STRU_WAVE)
82                         return 0;
83                 if (req_stype != stype) {
84                         if (stype == IWFFFF_STRU_ENV_RECP ||
85                             stype == IWFFFF_STRU_ENV_RECV)
86                                 return 0;
87                 }
88                 if (*len < (long)sizeof(rx))
89                         return -EINVAL;
90                 if (copy_from_user(&rx, *data, sizeof(rx)))
91                         return -EFAULT;
92                 *data += sizeof(rx);
93                 *len -= sizeof(rx);
94                 points_size = (le16_to_cpu(rx.nattack) + le16_to_cpu(rx.nrelease)) * 2 * sizeof(__u16);
95                 if (points_size > *len)
96                         return -EINVAL;
97                 rp = kcalloc(1, sizeof(*rp) + points_size, gfp_mask);
98                 if (rp == NULL)
99                         return -ENOMEM;
100                 rp->nattack = le16_to_cpu(rx.nattack);
101                 rp->nrelease = le16_to_cpu(rx.nrelease);
102                 rp->sustain_offset = le16_to_cpu(rx.sustain_offset);
103                 rp->sustain_rate = le16_to_cpu(rx.sustain_rate);
104                 rp->release_rate = le16_to_cpu(rx.release_rate);
105                 rp->hirange = rx.hirange;
106                 pp = (iwffff_env_point_t *)(rp + 1);
107                 for (idx = 0; idx < rp->nattack + rp->nrelease; idx++) {
108                         if (copy_from_user(&px, *data, sizeof(px)))
109                                 return -EFAULT;
110                         *data += sizeof(px);
111                         *len -= sizeof(px);
112                         pp->offset = le16_to_cpu(px.offset);
113                         pp->rate = le16_to_cpu(px.rate);
114                 }
115                 if (ep->record == NULL) {
116                         ep->record = rp;
117                 } else {
118                         rp_last = rp;
119                 }
120                 rp_last = rp;
121         }
122         return 0;
123 }
124
125 static int snd_seq_iwffff_copy_wave_from_stream(snd_iwffff_ops_t *ops,
126                                                 iwffff_layer_t *lp,
127                                                 char __user **data,
128                                                 long *len,
129                                                 int atomic)
130 {
131         iwffff_wave_t *wp, *prev;
132         iwffff_xwave_t xp;
133         int err, gfp_mask;
134         unsigned int real_size;
135         
136         gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
137         if (*len < (long)sizeof(xp))
138                 return -EINVAL;
139         if (copy_from_user(&xp, *data, sizeof(xp)))
140                 return -EFAULT;
141         *data += sizeof(xp);
142         *len -= sizeof(xp);
143         wp = kcalloc(1, sizeof(*wp), gfp_mask);
144         if (wp == NULL)
145                 return -ENOMEM;
146         wp->share_id[0] = le32_to_cpu(xp.share_id[0]);
147         wp->share_id[1] = le32_to_cpu(xp.share_id[1]);
148         wp->share_id[2] = le32_to_cpu(xp.share_id[2]);
149         wp->share_id[3] = le32_to_cpu(xp.share_id[3]);
150         wp->format = le32_to_cpu(xp.format);
151         wp->address.memory = le32_to_cpu(xp.offset);
152         wp->size = le32_to_cpu(xp.size);
153         wp->start = le32_to_cpu(xp.start);
154         wp->loop_start = le32_to_cpu(xp.loop_start);
155         wp->loop_end = le32_to_cpu(xp.loop_end);
156         wp->loop_repeat = le16_to_cpu(xp.loop_repeat);
157         wp->sample_ratio = le32_to_cpu(xp.sample_ratio);
158         wp->attenuation = xp.attenuation;
159         wp->low_note = xp.low_note;
160         wp->high_note = xp.high_note;
161         real_size = snd_seq_iwffff_size(wp->size, wp->format);
162         if (!(wp->format & IWFFFF_WAVE_ROM)) {
163                 if ((long)real_size > *len) {
164                         kfree(wp);
165                         return -ENOMEM;
166                 }
167         }
168         if (ops->put_sample) {
169                 err = ops->put_sample(ops->private_data, wp,
170                                       *data, real_size, atomic);
171                 if (err < 0) {
172                         kfree(wp);
173                         return err;
174                 }
175         }
176         if (!(wp->format & IWFFFF_WAVE_ROM)) {
177                 *data += real_size;
178                 *len -= real_size;
179         }
180         prev = lp->wave;
181         if (prev) {
182                 while (prev->next) prev = prev->next;
183                 prev->next = wp;
184         } else {
185                 lp->wave = wp;
186         }
187         return 0;
188 }
189
190 static void snd_seq_iwffff_env_free(snd_iwffff_ops_t *ops,
191                                     iwffff_env_t *env,
192                                     int atomic)
193 {
194         iwffff_env_record_t *rec;
195         
196         while ((rec = env->record) != NULL) {
197                 env->record = rec->next;
198                 kfree(rec);
199         }
200 }
201                                     
202 static void snd_seq_iwffff_wave_free(snd_iwffff_ops_t *ops,
203                                      iwffff_wave_t *wave,
204                                      int atomic)
205 {
206         if (ops->remove_sample)
207                 ops->remove_sample(ops->private_data, wave, atomic);
208         kfree(wave);
209 }
210
211 static void snd_seq_iwffff_instr_free(snd_iwffff_ops_t *ops,
212                                       iwffff_instrument_t *ip,
213                                       int atomic)
214 {
215         iwffff_layer_t *layer;
216         iwffff_wave_t *wave;
217         
218         while ((layer = ip->layer) != NULL) {
219                 ip->layer = layer->next;
220                 snd_seq_iwffff_env_free(ops, &layer->penv, atomic);
221                 snd_seq_iwffff_env_free(ops, &layer->venv, atomic);
222                 while ((wave = layer->wave) != NULL) {
223                         layer->wave = wave->next;
224                         snd_seq_iwffff_wave_free(ops, wave, atomic);
225                 }
226                 kfree(layer);
227         }
228 }
229
230 static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr,
231                               char __user *instr_data, long len, int atomic,
232                               int cmd)
233 {
234         snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data;
235         iwffff_instrument_t *ip;
236         iwffff_xinstrument_t ix;
237         iwffff_layer_t *lp, *prev_lp;
238         iwffff_xlayer_t lx;
239         int err, gfp_mask;
240
241         if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE)
242                 return -EINVAL;
243         gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
244         /* copy instrument data */
245         if (len < (long)sizeof(ix))
246                 return -EINVAL;
247         if (copy_from_user(&ix, instr_data, sizeof(ix)))
248                 return -EFAULT;
249         if (ix.stype != IWFFFF_STRU_INSTR)
250                 return -EINVAL;
251         instr_data += sizeof(ix);
252         len -= sizeof(ix);
253         ip = (iwffff_instrument_t *)KINSTR_DATA(instr);
254         ip->exclusion = le16_to_cpu(ix.exclusion);
255         ip->layer_type = le16_to_cpu(ix.layer_type);
256         ip->exclusion_group = le16_to_cpu(ix.exclusion_group);
257         ip->effect1 = ix.effect1;
258         ip->effect1_depth = ix.effect1_depth;
259         ip->effect2 = ix.effect2;
260         ip->effect2_depth = ix.effect2_depth;
261         /* copy layers */
262         prev_lp = NULL;
263         while (len > 0) {
264                 if (len < (long)sizeof(iwffff_xlayer_t)) {
265                         snd_seq_iwffff_instr_free(ops, ip, atomic);
266                         return -EINVAL;
267                 }
268                 if (copy_from_user(&lx, instr_data, sizeof(lx)))
269                         return -EFAULT;
270                 instr_data += sizeof(lx);
271                 len -= sizeof(lx);
272                 if (lx.stype != IWFFFF_STRU_LAYER) {
273                         snd_seq_iwffff_instr_free(ops, ip, atomic);
274                         return -EINVAL;
275                 }
276                 lp = kcalloc(1, sizeof(*lp), gfp_mask);
277                 if (lp == NULL) {
278                         snd_seq_iwffff_instr_free(ops, ip, atomic);
279                         return -ENOMEM;
280                 }
281                 if (prev_lp) {
282                         prev_lp->next = lp;
283                 } else {
284                         ip->layer = lp;
285                 }
286                 prev_lp = lp;
287                 lp->flags = lx.flags;
288                 lp->velocity_mode = lx.velocity_mode;
289                 lp->layer_event = lx.layer_event;
290                 lp->low_range = lx.low_range;
291                 lp->high_range = lx.high_range;
292                 lp->pan = lx.pan;
293                 lp->pan_freq_scale = lx.pan_freq_scale;
294                 lp->attenuation = lx.attenuation;
295                 snd_seq_iwffff_copy_lfo_from_stream(&lp->tremolo, &lx.tremolo);
296                 snd_seq_iwffff_copy_lfo_from_stream(&lp->vibrato, &lx.vibrato);
297                 lp->freq_scale = le16_to_cpu(lx.freq_scale);
298                 lp->freq_center = lx.freq_center;
299                 err = snd_seq_iwffff_copy_env_from_stream(IWFFFF_STRU_ENV_RECP,
300                                                           lp,
301                                                           &lp->penv, &lx.penv,
302                                                           &instr_data, &len,
303                                                           gfp_mask);
304                 if (err < 0) {
305                         snd_seq_iwffff_instr_free(ops, ip, atomic);
306                         return err;
307                 }
308                 err = snd_seq_iwffff_copy_env_from_stream(IWFFFF_STRU_ENV_RECV,
309                                                           lp,
310                                                           &lp->venv, &lx.venv,
311                                                           &instr_data, &len,
312                                                           gfp_mask);
313                 if (err < 0) {
314                         snd_seq_iwffff_instr_free(ops, ip, atomic);
315                         return err;
316                 }
317                 while (len > (long)sizeof(__u32)) {
318                         __u32 stype;
319
320                         if (copy_from_user(&stype, instr_data, sizeof(stype)))
321                                 return -EFAULT;
322                         if (stype != IWFFFF_STRU_WAVE)
323                                 break;
324                         err = snd_seq_iwffff_copy_wave_from_stream(ops,
325                                                                    lp,
326                                                                    &instr_data,
327                                                                    &len,
328                                                                    atomic);
329                         if (err < 0) {
330                                 snd_seq_iwffff_instr_free(ops, ip, atomic);
331                                 return err;
332                         }
333                 }
334         }
335         return 0;
336 }
337
338 static void snd_seq_iwffff_copy_lfo_to_stream(iwffff_xlfo_t *fx,
339                                               iwffff_lfo_t *fp)
340 {
341         fx->freq = cpu_to_le16(fp->freq);
342         fx->depth = cpu_to_le16(fp->depth);
343         fx->sweep = cpu_to_le16(fp->sweep);
344         fp->shape = fx->shape;
345         fp->delay = fx->delay;
346 }
347
348 static int snd_seq_iwffff_copy_env_to_stream(__u32 req_stype,
349                                              iwffff_layer_t *lp,
350                                              iwffff_xenv_t *ex,
351                                              iwffff_env_t *ep,
352                                              char __user **data,
353                                              long *len)
354 {
355         iwffff_env_record_t *rp;
356         iwffff_xenv_record_t rx;
357         iwffff_env_point_t *pp;
358         iwffff_xenv_point_t px;
359         int points_size, idx;
360
361         ex->flags = ep->flags;
362         ex->mode = ep->mode;
363         ex->index = ep->index;
364         for (rp = ep->record; rp; rp = rp->next) {
365                 if (*len < (long)sizeof(rx))
366                         return -ENOMEM;
367                 memset(&rx, 0, sizeof(rx));
368                 rx.stype = req_stype;
369                 rx.nattack = cpu_to_le16(rp->nattack);
370                 rx.nrelease = cpu_to_le16(rp->nrelease);
371                 rx.sustain_offset = cpu_to_le16(rp->sustain_offset);
372                 rx.sustain_rate = cpu_to_le16(rp->sustain_rate);
373                 rx.release_rate = cpu_to_le16(rp->release_rate);
374                 rx.hirange = cpu_to_le16(rp->hirange);
375                 if (copy_to_user(*data, &rx, sizeof(rx)))
376                         return -EFAULT;
377                 *data += sizeof(rx);
378                 *len -= sizeof(rx);
379                 points_size = (rp->nattack + rp->nrelease) * 2 * sizeof(__u16);
380                 if (*len < points_size)
381                         return -ENOMEM;
382                 pp = (iwffff_env_point_t *)(rp + 1);
383                 for (idx = 0; idx < rp->nattack + rp->nrelease; idx++) {
384                         px.offset = cpu_to_le16(pp->offset);
385                         px.rate = cpu_to_le16(pp->rate);
386                         if (copy_to_user(*data, &px, sizeof(px)))
387                                 return -EFAULT;
388                         *data += sizeof(px);
389                         *len -= sizeof(px);
390                 }
391         }
392         return 0;
393 }
394
395 static int snd_seq_iwffff_copy_wave_to_stream(snd_iwffff_ops_t *ops,
396                                               iwffff_layer_t *lp,
397                                               char __user **data,
398                                               long *len,
399                                               int atomic)
400 {
401         iwffff_wave_t *wp;
402         iwffff_xwave_t xp;
403         int err;
404         unsigned int real_size;
405         
406         for (wp = lp->wave; wp; wp = wp->next) {
407                 if (*len < (long)sizeof(xp))
408                         return -ENOMEM;
409                 memset(&xp, 0, sizeof(xp));
410                 xp.stype = IWFFFF_STRU_WAVE;
411                 xp.share_id[0] = cpu_to_le32(wp->share_id[0]);
412                 xp.share_id[1] = cpu_to_le32(wp->share_id[1]);
413                 xp.share_id[2] = cpu_to_le32(wp->share_id[2]);
414                 xp.share_id[3] = cpu_to_le32(wp->share_id[3]);
415                 xp.format = cpu_to_le32(wp->format);
416                 if (wp->format & IWFFFF_WAVE_ROM)
417                         xp.offset = cpu_to_le32(wp->address.memory);
418                 xp.size = cpu_to_le32(wp->size);
419                 xp.start = cpu_to_le32(wp->start);
420                 xp.loop_start = cpu_to_le32(wp->loop_start);
421                 xp.loop_end = cpu_to_le32(wp->loop_end);
422                 xp.loop_repeat = cpu_to_le32(wp->loop_repeat);
423                 xp.sample_ratio = cpu_to_le32(wp->sample_ratio);
424                 xp.attenuation = wp->attenuation;
425                 xp.low_note = wp->low_note;
426                 xp.high_note = wp->high_note;
427                 if (copy_to_user(*data, &xp, sizeof(xp)))
428                         return -EFAULT;
429                 *data += sizeof(xp);
430                 *len -= sizeof(xp);
431                 real_size = snd_seq_iwffff_size(wp->size, wp->format);
432                 if (!(wp->format & IWFFFF_WAVE_ROM)) {
433                         if (*len < (long)real_size)
434                                 return -ENOMEM;
435                 }
436                 if (ops->get_sample) {
437                         err = ops->get_sample(ops->private_data, wp,
438                                               *data, real_size, atomic);
439                         if (err < 0)
440                                 return err;
441                 }
442                 if (!(wp->format & IWFFFF_WAVE_ROM)) {
443                         *data += real_size;
444                         *len -= real_size;
445                 }
446         }
447         return 0;
448 }
449
450 static int snd_seq_iwffff_get(void *private_data, snd_seq_kinstr_t *instr,
451                               char __user *instr_data, long len, int atomic, int cmd)
452 {
453         snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data;
454         iwffff_instrument_t *ip;
455         iwffff_xinstrument_t ix;
456         iwffff_layer_t *lp;
457         iwffff_xlayer_t lx;
458         char __user *layer_instr_data;
459         int err;
460         
461         if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL)
462                 return -EINVAL;
463         if (len < (long)sizeof(ix))
464                 return -ENOMEM;
465         memset(&ix, 0, sizeof(ix));
466         ip = (iwffff_instrument_t *)KINSTR_DATA(instr);
467         ix.stype = IWFFFF_STRU_INSTR;
468         ix.exclusion = cpu_to_le16(ip->exclusion);
469         ix.layer_type = cpu_to_le16(ip->layer_type);
470         ix.exclusion_group = cpu_to_le16(ip->exclusion_group);
471         ix.effect1 = cpu_to_le16(ip->effect1);
472         ix.effect1_depth = cpu_to_le16(ip->effect1_depth);
473         ix.effect2 = ip->effect2;
474         ix.effect2_depth = ip->effect2_depth;
475         if (copy_to_user(instr_data, &ix, sizeof(ix)))
476                 return -EFAULT;
477         instr_data += sizeof(ix);
478         len -= sizeof(ix);
479         for (lp = ip->layer; lp; lp = lp->next) {
480                 if (len < (long)sizeof(lx))
481                         return -ENOMEM;
482                 memset(&lx, 0, sizeof(lx));
483                 lx.stype = IWFFFF_STRU_LAYER;
484                 lx.flags = lp->flags;
485                 lx.velocity_mode = lp->velocity_mode;
486                 lx.layer_event = lp->layer_event;
487                 lx.low_range = lp->low_range;
488                 lx.high_range = lp->high_range;
489                 lx.pan = lp->pan;
490                 lx.pan_freq_scale = lp->pan_freq_scale;
491                 lx.attenuation = lp->attenuation;
492                 snd_seq_iwffff_copy_lfo_to_stream(&lx.tremolo, &lp->tremolo);
493                 snd_seq_iwffff_copy_lfo_to_stream(&lx.vibrato, &lp->vibrato);
494                 layer_instr_data = instr_data;
495                 instr_data += sizeof(lx);
496                 len -= sizeof(lx);
497                 err = snd_seq_iwffff_copy_env_to_stream(IWFFFF_STRU_ENV_RECP,
498                                                         lp,
499                                                         &lx.penv, &lp->penv,
500                                                         &instr_data, &len);
501                 if (err < 0)
502                         return err;
503                 err = snd_seq_iwffff_copy_env_to_stream(IWFFFF_STRU_ENV_RECV,
504                                                         lp,
505                                                         &lx.venv, &lp->venv,
506                                                         &instr_data, &len);
507                 if (err < 0)
508                         return err;
509                 /* layer structure updating is now finished */
510                 if (copy_to_user(layer_instr_data, &lx, sizeof(lx)))
511                         return -EFAULT;
512                 err = snd_seq_iwffff_copy_wave_to_stream(ops,
513                                                          lp,
514                                                          &instr_data,
515                                                          &len,
516                                                          atomic);
517                 if (err < 0)
518                         return err;
519         }
520         return 0;
521 }
522
523 static long snd_seq_iwffff_env_size_in_stream(iwffff_env_t *ep)
524 {
525         long result = 0;
526         iwffff_env_record_t *rp;
527
528         for (rp = ep->record; rp; rp = rp->next) {
529                 result += sizeof(iwffff_xenv_record_t);
530                 result += (rp->nattack + rp->nrelease) * 2 * sizeof(__u16);
531         }
532         return 0;
533 }
534
535 static long snd_seq_iwffff_wave_size_in_stream(iwffff_layer_t *lp)
536 {
537         long result = 0;
538         iwffff_wave_t *wp;
539         
540         for (wp = lp->wave; wp; wp = wp->next) {
541                 result += sizeof(iwffff_xwave_t);
542                 if (!(wp->format & IWFFFF_WAVE_ROM))
543                         result += wp->size;
544         }
545         return result;
546 }
547
548 static int snd_seq_iwffff_get_size(void *private_data, snd_seq_kinstr_t *instr,
549                                    long *size)
550 {
551         long result;
552         iwffff_instrument_t *ip;
553         iwffff_layer_t *lp;
554
555         *size = 0;
556         ip = (iwffff_instrument_t *)KINSTR_DATA(instr);
557         result = sizeof(iwffff_xinstrument_t);
558         for (lp = ip->layer; lp; lp = lp->next) {
559                 result += sizeof(iwffff_xlayer_t);
560                 result += snd_seq_iwffff_env_size_in_stream(&lp->penv);
561                 result += snd_seq_iwffff_env_size_in_stream(&lp->venv);
562                 result += snd_seq_iwffff_wave_size_in_stream(lp);
563         }
564         *size = result;
565         return 0;
566 }
567
568 static int snd_seq_iwffff_remove(void *private_data,
569                                  snd_seq_kinstr_t *instr,
570                                  int atomic)
571 {
572         snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data;
573         iwffff_instrument_t *ip;
574
575         ip = (iwffff_instrument_t *)KINSTR_DATA(instr);
576         snd_seq_iwffff_instr_free(ops, ip, atomic);
577         return 0;
578 }
579
580 static void snd_seq_iwffff_notify(void *private_data,
581                                   snd_seq_kinstr_t *instr,
582                                   int what)
583 {
584         snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data;
585
586         if (ops->notify)
587                 ops->notify(ops->private_data, instr, what);
588 }
589
590 int snd_seq_iwffff_init(snd_iwffff_ops_t *ops,
591                         void *private_data,
592                         snd_seq_kinstr_ops_t *next)
593 {
594         memset(ops, 0, sizeof(*ops));
595         ops->private_data = private_data;
596         ops->kops.private_data = ops;
597         ops->kops.add_len = sizeof(iwffff_instrument_t);
598         ops->kops.instr_type = snd_seq_iwffff_id;
599         ops->kops.put = snd_seq_iwffff_put;
600         ops->kops.get = snd_seq_iwffff_get;
601         ops->kops.get_size = snd_seq_iwffff_get_size;
602         ops->kops.remove = snd_seq_iwffff_remove;
603         ops->kops.notify = snd_seq_iwffff_notify;
604         ops->kops.next = next;
605         return 0;
606 }
607
608 /*
609  *  Init part
610  */
611
612 static int __init alsa_ainstr_iw_init(void)
613 {
614         return 0;
615 }
616
617 static void __exit alsa_ainstr_iw_exit(void)
618 {
619 }
620
621 module_init(alsa_ainstr_iw_init)
622 module_exit(alsa_ainstr_iw_exit)
623
624 EXPORT_SYMBOL(snd_seq_iwffff_id);
625 EXPORT_SYMBOL(snd_seq_iwffff_init);