Lines Matching refs:sflist
24 static int open_patch(struct snd_sf_list *sflist, const char __user *data,
26 static struct snd_soundfont *newsf(struct snd_sf_list *sflist, int type, char *name);
28 static int close_patch(struct snd_sf_list *sflist);
29 static int probe_data(struct snd_sf_list *sflist, int sample_id);
30 static void set_zone_counter(struct snd_sf_list *sflist,
32 static struct snd_sf_zone *sf_zone_new(struct snd_sf_list *sflist,
34 static void set_sample_counter(struct snd_sf_list *sflist,
36 static struct snd_sf_sample *sf_sample_new(struct snd_sf_list *sflist,
38 static void sf_sample_delete(struct snd_sf_list *sflist,
40 static int load_map(struct snd_sf_list *sflist, const void __user *data, int count);
41 static int load_info(struct snd_card *card, struct snd_sf_list *sflist,
43 static int remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,
50 static int load_data(struct snd_sf_list *sflist, const void __user *data, long count);
51 static void rebuild_presets(struct snd_sf_list *sflist);
52 static void add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur);
53 static void delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp);
54 static struct snd_sf_zone *search_first_zone(struct snd_sf_list *sflist,
56 static int search_zones(struct snd_sf_list *sflist, int *notep, int vel,
60 static void snd_sf_init(struct snd_sf_list *sflist);
61 static void snd_sf_clear(struct snd_sf_list *sflist);
67 lock_preset(struct snd_sf_list *sflist) in lock_preset() argument
70 mutex_lock(&sflist->presets_mutex); in lock_preset()
71 spin_lock_irqsave(&sflist->lock, flags); in lock_preset()
72 sflist->presets_locked = 1; in lock_preset()
73 spin_unlock_irqrestore(&sflist->lock, flags); in lock_preset()
81 unlock_preset(struct snd_sf_list *sflist) in unlock_preset() argument
84 spin_lock_irqsave(&sflist->lock, flags); in unlock_preset()
85 sflist->presets_locked = 0; in unlock_preset()
86 spin_unlock_irqrestore(&sflist->lock, flags); in unlock_preset()
87 mutex_unlock(&sflist->presets_mutex); in unlock_preset()
95 snd_soundfont_close_check(struct snd_sf_list *sflist, int client) in snd_soundfont_close_check() argument
98 spin_lock_irqsave(&sflist->lock, flags); in snd_soundfont_close_check()
99 if (sflist->open_client == client) { in snd_soundfont_close_check()
100 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_close_check()
101 return close_patch(sflist); in snd_soundfont_close_check()
103 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_close_check()
118 struct snd_sf_list *sflist, const void __user *data, in snd_soundfont_load() argument
151 lock_preset(sflist); in snd_soundfont_load()
152 rc = open_patch(sflist, data, count, client); in snd_soundfont_load()
153 unlock_preset(sflist); in snd_soundfont_load()
158 spin_lock_irqsave(&sflist->lock, flags); in snd_soundfont_load()
159 if (sflist->open_client != client) { in snd_soundfont_load()
160 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_load()
163 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_load()
165 lock_preset(sflist); in snd_soundfont_load()
169 rc = load_info(card, sflist, data, count); in snd_soundfont_load()
172 rc = load_data(sflist, data, count); in snd_soundfont_load()
175 rc = close_patch(sflist); in snd_soundfont_load()
181 rc = load_map(sflist, data, count); in snd_soundfont_load()
184 rc = probe_data(sflist, patch.optarg); in snd_soundfont_load()
188 if (!sflist->currsf) { in snd_soundfont_load()
196 if (! remove_info(sflist, sflist->currsf, bank, instr)) in snd_soundfont_load()
203 unlock_preset(sflist); in snd_soundfont_load()
221 open_patch(struct snd_sf_list *sflist, const char __user *data, in open_patch() argument
228 spin_lock_irqsave(&sflist->lock, flags); in open_patch()
229 if (sflist->open_client >= 0 || sflist->currsf) { in open_patch()
230 spin_unlock_irqrestore(&sflist->lock, flags); in open_patch()
233 spin_unlock_irqrestore(&sflist->lock, flags); in open_patch()
240 sf = newsf(sflist, parm.type, NULL); in open_patch()
242 sf = newsf(sflist, parm.type, parm.name); in open_patch()
247 spin_lock_irqsave(&sflist->lock, flags); in open_patch()
248 sflist->open_client = client; in open_patch()
249 sflist->currsf = sf; in open_patch()
250 spin_unlock_irqrestore(&sflist->lock, flags); in open_patch()
259 newsf(struct snd_sf_list *sflist, int type, char *name) in newsf() argument
265 for (sf = sflist->fonts; sf; sf = sf->next) { in newsf()
276 sf->id = sflist->fonts_size; in newsf()
277 sflist->fonts_size++; in newsf()
280 sf->next = sflist->fonts; in newsf()
281 sflist->fonts = sf; in newsf()
306 close_patch(struct snd_sf_list *sflist) in close_patch() argument
310 spin_lock_irqsave(&sflist->lock, flags); in close_patch()
311 sflist->currsf = NULL; in close_patch()
312 sflist->open_client = -1; in close_patch()
313 spin_unlock_irqrestore(&sflist->lock, flags); in close_patch()
315 rebuild_presets(sflist); in close_patch()
323 probe_data(struct snd_sf_list *sflist, int sample_id) in probe_data() argument
326 if (sflist->currsf) { in probe_data()
328 if (find_sample(sflist->currsf, sample_id)) in probe_data()
338 set_zone_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, in set_zone_counter() argument
341 zp->counter = sflist->zone_counter++; in set_zone_counter()
343 sflist->zone_locked = sflist->zone_counter; in set_zone_counter()
350 sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) in sf_zone_new() argument
362 set_zone_counter(sflist, sf, zp); in sf_zone_new()
371 set_sample_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, in set_sample_counter() argument
374 sp->counter = sflist->sample_counter++; in set_sample_counter()
376 sflist->sample_locked = sflist->sample_counter; in set_sample_counter()
383 sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) in sf_sample_new() argument
394 set_sample_counter(sflist, sf, sp); in sf_sample_new()
403 sf_sample_delete(struct snd_sf_list *sflist, struct snd_soundfont *sf, in sf_sample_delete() argument
416 load_map(struct snd_sf_list *sflist, const void __user *data, int count) in load_map() argument
431 sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_MAP|SNDRV_SFNT_PAT_SHARED, NULL); in load_map()
452 set_zone_counter(sflist, sf, zp); in load_map()
458 zp = sf_zone_new(sflist, sf); in load_map()
474 add_preset(sflist, zp); in load_map()
482 remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf, in remove_info() argument
504 rebuild_presets(sflist); in remove_info()
515 struct snd_sf_list *sflist, const void __user *data, long count) in load_info() argument
523 sf = sflist->currsf; in load_info()
566 remove_info(sflist, sf, hdr.bank, hdr.instr); in load_info()
589 zone = sf_zone_new(sflist, sf); in load_info()
717 load_data(struct snd_sf_list *sflist, const void __user *data, long count) in load_data() argument
724 sf = sflist->currsf; in load_data()
767 sp = sf_sample_new(sflist, sf); in load_data()
781 rc = sflist->callback.sample_new in load_data()
782 (sflist->callback.private_data, sp, sflist->memhdr, in load_data()
785 sf_sample_delete(sflist, sf, sp); in load_data()
788 sflist->mem_used += sp->v.truesize; in load_data()
981 struct snd_sf_list *sflist, const char __user *data, long count) in load_guspatch() argument
1002 sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_GUS|SNDRV_SFNT_PAT_SHARED, NULL); in load_guspatch()
1005 smp = sf_sample_new(sflist, sf); in load_guspatch()
1008 sample_id = sflist->sample_counter; in load_guspatch()
1017 sf_sample_delete(sflist, sf, smp); in load_guspatch()
1049 zone = sf_zone_new(sflist, sf); in load_guspatch()
1051 sf_sample_delete(sflist, sf, smp); in load_guspatch()
1059 rc = sflist->callback.sample_new in load_guspatch()
1060 (sflist->callback.private_data, smp, sflist->memhdr, in load_guspatch()
1063 sf_sample_delete(sflist, sf, smp); in load_guspatch()
1071 sflist->mem_used += smp->v.truesize; in load_guspatch()
1160 add_preset(sflist, zone); in load_guspatch()
1168 struct snd_sf_list *sflist, const char __user *data, in snd_soundfont_load_guspatch() argument
1172 lock_preset(sflist); in snd_soundfont_load_guspatch()
1173 rc = load_guspatch(card, sflist, data, count); in snd_soundfont_load_guspatch()
1174 unlock_preset(sflist); in snd_soundfont_load_guspatch()
1187 rebuild_presets(struct snd_sf_list *sflist) in rebuild_presets() argument
1193 memset(sflist->presets, 0, sizeof(sflist->presets)); in rebuild_presets()
1196 for (sf = sflist->fonts; sf; sf = sf->next) { in rebuild_presets()
1205 add_preset(sflist, cur); in rebuild_presets()
1215 add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur) in add_preset() argument
1220 zone = search_first_zone(sflist, cur->bank, cur->instr, cur->v.low); in add_preset()
1231 delete_preset(sflist, zone); in add_preset()
1240 cur->next_instr = sflist->presets[index]; /* preset table link */ in add_preset()
1241 sflist->presets[index] = cur; in add_preset()
1248 delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp) in delete_preset() argument
1256 for (p = sflist->presets[index]; p; p = p->next_instr) { in delete_preset()
1275 snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, in snd_soundfont_search_zone() argument
1287 spin_lock_irqsave(&sflist->lock, flags); in snd_soundfont_search_zone()
1288 if (sflist->presets_locked) { in snd_soundfont_search_zone()
1289 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_search_zone()
1292 nvoices = search_zones(sflist, notep, vel, preset, bank, in snd_soundfont_search_zone()
1296 nvoices = search_zones(sflist, notep, vel, in snd_soundfont_search_zone()
1300 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_search_zone()
1309 search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key) in search_first_zone() argument
1317 for (zp = sflist->presets[index]; zp; zp = zp->next_instr) { in search_first_zone()
1329 search_zones(struct snd_sf_list *sflist, int *notep, int vel, in search_zones() argument
1336 zp = search_first_zone(sflist, bank, preset, *notep); in search_zones()
1351 nvoices = search_zones(sflist, &key, vel, in search_zones()
1391 snd_sf_init(struct snd_sf_list *sflist) in snd_sf_init() argument
1393 memset(sflist->presets, 0, sizeof(sflist->presets)); in snd_sf_init()
1395 sflist->mem_used = 0; in snd_sf_init()
1396 sflist->currsf = NULL; in snd_sf_init()
1397 sflist->open_client = -1; in snd_sf_init()
1398 sflist->fonts = NULL; in snd_sf_init()
1399 sflist->fonts_size = 0; in snd_sf_init()
1400 sflist->zone_counter = 0; in snd_sf_init()
1401 sflist->sample_counter = 0; in snd_sf_init()
1402 sflist->zone_locked = 0; in snd_sf_init()
1403 sflist->sample_locked = 0; in snd_sf_init()
1410 snd_sf_clear(struct snd_sf_list *sflist) in snd_sf_clear() argument
1416 for (sf = sflist->fonts; sf; sf = nextsf) { in snd_sf_clear()
1424 sflist->callback.sample_free(sflist->callback.private_data, in snd_sf_clear()
1425 sp, sflist->memhdr); in snd_sf_clear()
1431 snd_sf_init(sflist); in snd_sf_clear()
1441 struct snd_sf_list *sflist; in snd_sf_new() local
1443 sflist = kzalloc(sizeof(*sflist), GFP_KERNEL); in snd_sf_new()
1444 if (!sflist) in snd_sf_new()
1447 mutex_init(&sflist->presets_mutex); in snd_sf_new()
1448 spin_lock_init(&sflist->lock); in snd_sf_new()
1449 sflist->memhdr = hdr; in snd_sf_new()
1452 sflist->callback = *callback; in snd_sf_new()
1454 snd_sf_init(sflist); in snd_sf_new()
1455 return sflist; in snd_sf_new()
1463 snd_sf_free(struct snd_sf_list *sflist) in snd_sf_free() argument
1465 if (sflist == NULL) in snd_sf_free()
1468 lock_preset(sflist); in snd_sf_free()
1469 if (sflist->callback.sample_reset) in snd_sf_free()
1470 sflist->callback.sample_reset(sflist->callback.private_data); in snd_sf_free()
1471 snd_sf_clear(sflist); in snd_sf_free()
1472 unlock_preset(sflist); in snd_sf_free()
1474 kfree(sflist); in snd_sf_free()
1482 snd_soundfont_remove_samples(struct snd_sf_list *sflist) in snd_soundfont_remove_samples() argument
1484 lock_preset(sflist); in snd_soundfont_remove_samples()
1485 if (sflist->callback.sample_reset) in snd_soundfont_remove_samples()
1486 sflist->callback.sample_reset(sflist->callback.private_data); in snd_soundfont_remove_samples()
1487 snd_sf_clear(sflist); in snd_soundfont_remove_samples()
1488 unlock_preset(sflist); in snd_soundfont_remove_samples()
1498 snd_soundfont_remove_unlocked(struct snd_sf_list *sflist) in snd_soundfont_remove_unlocked() argument
1504 lock_preset(sflist); in snd_soundfont_remove_unlocked()
1506 if (sflist->callback.sample_reset) in snd_soundfont_remove_unlocked()
1507 sflist->callback.sample_reset(sflist->callback.private_data); in snd_soundfont_remove_unlocked()
1510 memset(sflist->presets, 0, sizeof(sflist->presets)); in snd_soundfont_remove_unlocked()
1512 for (sf = sflist->fonts; sf; sf = sf->next) { in snd_soundfont_remove_unlocked()
1514 if (zp->counter < sflist->zone_locked) in snd_soundfont_remove_unlocked()
1522 if (sp->counter < sflist->sample_locked) in snd_soundfont_remove_unlocked()
1526 sflist->mem_used -= sp->v.truesize; in snd_soundfont_remove_unlocked()
1527 sflist->callback.sample_free(sflist->callback.private_data, in snd_soundfont_remove_unlocked()
1528 sp, sflist->memhdr); in snd_soundfont_remove_unlocked()
1533 sflist->zone_counter = sflist->zone_locked; in snd_soundfont_remove_unlocked()
1534 sflist->sample_counter = sflist->sample_locked; in snd_soundfont_remove_unlocked()
1536 rebuild_presets(sflist); in snd_soundfont_remove_unlocked()
1538 unlock_preset(sflist); in snd_soundfont_remove_unlocked()