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