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_sf_list *sflist, const void __user *data, long count);
42 static int remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,
49 static int load_data(struct snd_sf_list *sflist, const void __user *data, long count);
50 static void rebuild_presets(struct snd_sf_list *sflist);
51 static void add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur);
52 static void delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp);
53 static struct snd_sf_zone *search_first_zone(struct snd_sf_list *sflist,
55 static int search_zones(struct snd_sf_list *sflist, int *notep, int vel,
59 static void snd_sf_init(struct snd_sf_list *sflist);
60 static void snd_sf_clear(struct snd_sf_list *sflist);
66 lock_preset(struct snd_sf_list *sflist) in lock_preset() argument
69 mutex_lock(&sflist->presets_mutex); in lock_preset()
70 spin_lock_irqsave(&sflist->lock, flags); in lock_preset()
71 sflist->presets_locked = 1; in lock_preset()
72 spin_unlock_irqrestore(&sflist->lock, flags); in lock_preset()
80 unlock_preset(struct snd_sf_list *sflist) in unlock_preset() argument
83 spin_lock_irqsave(&sflist->lock, flags); in unlock_preset()
84 sflist->presets_locked = 0; in unlock_preset()
85 spin_unlock_irqrestore(&sflist->lock, flags); in unlock_preset()
86 mutex_unlock(&sflist->presets_mutex); in unlock_preset()
94 snd_soundfont_close_check(struct snd_sf_list *sflist, int client) in snd_soundfont_close_check() argument
97 spin_lock_irqsave(&sflist->lock, flags); in snd_soundfont_close_check()
98 if (sflist->open_client == client) { in snd_soundfont_close_check()
99 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_close_check()
100 return close_patch(sflist); in snd_soundfont_close_check()
102 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_close_check()
116 snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data, in snd_soundfont_load() argument
149 lock_preset(sflist); in snd_soundfont_load()
150 rc = open_patch(sflist, data, count, client); in snd_soundfont_load()
151 unlock_preset(sflist); in snd_soundfont_load()
156 spin_lock_irqsave(&sflist->lock, flags); in snd_soundfont_load()
157 if (sflist->open_client != client) { in snd_soundfont_load()
158 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_load()
161 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_load()
163 lock_preset(sflist); in snd_soundfont_load()
167 rc = load_info(sflist, data, count); in snd_soundfont_load()
170 rc = load_data(sflist, data, count); in snd_soundfont_load()
173 rc = close_patch(sflist); in snd_soundfont_load()
179 rc = load_map(sflist, data, count); in snd_soundfont_load()
182 rc = probe_data(sflist, patch.optarg); in snd_soundfont_load()
186 if (!sflist->currsf) { in snd_soundfont_load()
194 if (! remove_info(sflist, sflist->currsf, bank, instr)) in snd_soundfont_load()
201 unlock_preset(sflist); in snd_soundfont_load()
219 open_patch(struct snd_sf_list *sflist, const char __user *data, in open_patch() argument
226 spin_lock_irqsave(&sflist->lock, flags); in open_patch()
227 if (sflist->open_client >= 0 || sflist->currsf) { in open_patch()
228 spin_unlock_irqrestore(&sflist->lock, flags); in open_patch()
231 spin_unlock_irqrestore(&sflist->lock, flags); in open_patch()
238 sf = newsf(sflist, parm.type, NULL); in open_patch()
240 sf = newsf(sflist, parm.type, parm.name); in open_patch()
245 spin_lock_irqsave(&sflist->lock, flags); in open_patch()
246 sflist->open_client = client; in open_patch()
247 sflist->currsf = sf; in open_patch()
248 spin_unlock_irqrestore(&sflist->lock, flags); in open_patch()
257 newsf(struct snd_sf_list *sflist, int type, char *name) in newsf() argument
263 for (sf = sflist->fonts; sf; sf = sf->next) { in newsf()
274 sf->id = sflist->fonts_size; in newsf()
275 sflist->fonts_size++; in newsf()
278 sf->next = sflist->fonts; in newsf()
279 sflist->fonts = sf; in newsf()
304 close_patch(struct snd_sf_list *sflist) in close_patch() argument
308 spin_lock_irqsave(&sflist->lock, flags); in close_patch()
309 sflist->currsf = NULL; in close_patch()
310 sflist->open_client = -1; in close_patch()
311 spin_unlock_irqrestore(&sflist->lock, flags); in close_patch()
313 rebuild_presets(sflist); in close_patch()
321 probe_data(struct snd_sf_list *sflist, int sample_id) in probe_data() argument
324 if (sflist->currsf) { in probe_data()
326 if (find_sample(sflist->currsf, sample_id)) in probe_data()
336 set_zone_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, in set_zone_counter() argument
339 zp->counter = sflist->zone_counter++; in set_zone_counter()
341 sflist->zone_locked = sflist->zone_counter; in set_zone_counter()
348 sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) in sf_zone_new() argument
360 set_zone_counter(sflist, sf, zp); in sf_zone_new()
369 set_sample_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, in set_sample_counter() argument
372 sp->counter = sflist->sample_counter++; in set_sample_counter()
374 sflist->sample_locked = sflist->sample_counter; in set_sample_counter()
381 sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) in sf_sample_new() argument
392 set_sample_counter(sflist, sf, sp); in sf_sample_new()
401 sf_sample_delete(struct snd_sf_list *sflist, struct snd_soundfont *sf, in sf_sample_delete() argument
414 load_map(struct snd_sf_list *sflist, const void __user *data, int count) in load_map() argument
429 sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_MAP|SNDRV_SFNT_PAT_SHARED, NULL); in load_map()
450 set_zone_counter(sflist, sf, zp); in load_map()
456 zp = sf_zone_new(sflist, sf); in load_map()
472 add_preset(sflist, zp); in load_map()
480 remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf, in remove_info() argument
502 rebuild_presets(sflist); in remove_info()
512 load_info(struct snd_sf_list *sflist, const void __user *data, long count) in load_info() argument
520 sf = sflist->currsf; in load_info()
563 remove_info(sflist, sf, hdr.bank, hdr.instr); in load_info()
586 zone = sf_zone_new(sflist, sf); in load_info()
699 load_data(struct snd_sf_list *sflist, const void __user *data, long count) in load_data() argument
707 sf = sflist->currsf; in load_data()
731 sp = sf_sample_new(sflist, sf); in load_data()
745 rc = sflist->callback.sample_new in load_data()
746 (sflist->callback.private_data, sp, sflist->memhdr, in load_data()
749 sf_sample_delete(sflist, sf, sp); in load_data()
752 sflist->mem_used += sp->v.truesize; in load_data()
944 load_guspatch(struct snd_sf_list *sflist, const char __user *data, in load_guspatch() argument
964 sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_GUS|SNDRV_SFNT_PAT_SHARED, NULL); in load_guspatch()
967 smp = sf_sample_new(sflist, sf); in load_guspatch()
970 sample_id = sflist->sample_counter; in load_guspatch()
1006 zone = sf_zone_new(sflist, sf); in load_guspatch()
1008 sf_sample_delete(sflist, sf, smp); in load_guspatch()
1015 if (sflist->callback.sample_new) { in load_guspatch()
1016 rc = sflist->callback.sample_new in load_guspatch()
1017 (sflist->callback.private_data, smp, sflist->memhdr, in load_guspatch()
1020 sf_sample_delete(sflist, sf, smp); in load_guspatch()
1028 sflist->mem_used += smp->v.truesize; in load_guspatch()
1117 add_preset(sflist, zone); in load_guspatch()
1124 snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data, in snd_soundfont_load_guspatch() argument
1128 lock_preset(sflist); in snd_soundfont_load_guspatch()
1129 rc = load_guspatch(sflist, data, count, client); in snd_soundfont_load_guspatch()
1130 unlock_preset(sflist); in snd_soundfont_load_guspatch()
1143 rebuild_presets(struct snd_sf_list *sflist) in rebuild_presets() argument
1149 memset(sflist->presets, 0, sizeof(sflist->presets)); in rebuild_presets()
1152 for (sf = sflist->fonts; sf; sf = sf->next) { in rebuild_presets()
1161 add_preset(sflist, cur); in rebuild_presets()
1171 add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur) in add_preset() argument
1176 zone = search_first_zone(sflist, cur->bank, cur->instr, cur->v.low); in add_preset()
1187 delete_preset(sflist, zone); in add_preset()
1196 cur->next_instr = sflist->presets[index]; /* preset table link */ in add_preset()
1197 sflist->presets[index] = cur; in add_preset()
1204 delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp) in delete_preset() argument
1212 for (p = sflist->presets[index]; p; p = p->next_instr) { in delete_preset()
1231 snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, in snd_soundfont_search_zone() argument
1243 spin_lock_irqsave(&sflist->lock, flags); in snd_soundfont_search_zone()
1244 if (sflist->presets_locked) { in snd_soundfont_search_zone()
1245 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_search_zone()
1248 nvoices = search_zones(sflist, notep, vel, preset, bank, in snd_soundfont_search_zone()
1252 nvoices = search_zones(sflist, notep, vel, in snd_soundfont_search_zone()
1256 spin_unlock_irqrestore(&sflist->lock, flags); in snd_soundfont_search_zone()
1265 search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key) in search_first_zone() argument
1273 for (zp = sflist->presets[index]; zp; zp = zp->next_instr) { in search_first_zone()
1285 search_zones(struct snd_sf_list *sflist, int *notep, int vel, in search_zones() argument
1292 zp = search_first_zone(sflist, bank, preset, *notep); in search_zones()
1307 nvoices = search_zones(sflist, &key, vel, in search_zones()
1347 snd_sf_init(struct snd_sf_list *sflist) in snd_sf_init() argument
1349 memset(sflist->presets, 0, sizeof(sflist->presets)); in snd_sf_init()
1351 sflist->mem_used = 0; in snd_sf_init()
1352 sflist->currsf = NULL; in snd_sf_init()
1353 sflist->open_client = -1; in snd_sf_init()
1354 sflist->fonts = NULL; in snd_sf_init()
1355 sflist->fonts_size = 0; in snd_sf_init()
1356 sflist->zone_counter = 0; in snd_sf_init()
1357 sflist->sample_counter = 0; in snd_sf_init()
1358 sflist->zone_locked = 0; in snd_sf_init()
1359 sflist->sample_locked = 0; in snd_sf_init()
1366 snd_sf_clear(struct snd_sf_list *sflist) in snd_sf_clear() argument
1372 for (sf = sflist->fonts; sf; sf = nextsf) { in snd_sf_clear()
1380 if (sflist->callback.sample_free) in snd_sf_clear()
1381 sflist->callback.sample_free(sflist->callback.private_data, in snd_sf_clear()
1382 sp, sflist->memhdr); in snd_sf_clear()
1388 snd_sf_init(sflist); in snd_sf_clear()
1398 struct snd_sf_list *sflist; in snd_sf_new() local
1400 sflist = kzalloc(sizeof(*sflist), GFP_KERNEL); in snd_sf_new()
1401 if (!sflist) in snd_sf_new()
1404 mutex_init(&sflist->presets_mutex); in snd_sf_new()
1405 spin_lock_init(&sflist->lock); in snd_sf_new()
1406 sflist->memhdr = hdr; in snd_sf_new()
1409 sflist->callback = *callback; in snd_sf_new()
1411 snd_sf_init(sflist); in snd_sf_new()
1412 return sflist; in snd_sf_new()
1420 snd_sf_free(struct snd_sf_list *sflist) in snd_sf_free() argument
1422 if (sflist == NULL) in snd_sf_free()
1425 lock_preset(sflist); in snd_sf_free()
1426 if (sflist->callback.sample_reset) in snd_sf_free()
1427 sflist->callback.sample_reset(sflist->callback.private_data); in snd_sf_free()
1428 snd_sf_clear(sflist); in snd_sf_free()
1429 unlock_preset(sflist); in snd_sf_free()
1431 kfree(sflist); in snd_sf_free()
1439 snd_soundfont_remove_samples(struct snd_sf_list *sflist) in snd_soundfont_remove_samples() argument
1441 lock_preset(sflist); in snd_soundfont_remove_samples()
1442 if (sflist->callback.sample_reset) in snd_soundfont_remove_samples()
1443 sflist->callback.sample_reset(sflist->callback.private_data); in snd_soundfont_remove_samples()
1444 snd_sf_clear(sflist); in snd_soundfont_remove_samples()
1445 unlock_preset(sflist); in snd_soundfont_remove_samples()
1455 snd_soundfont_remove_unlocked(struct snd_sf_list *sflist) in snd_soundfont_remove_unlocked() argument
1461 lock_preset(sflist); in snd_soundfont_remove_unlocked()
1463 if (sflist->callback.sample_reset) in snd_soundfont_remove_unlocked()
1464 sflist->callback.sample_reset(sflist->callback.private_data); in snd_soundfont_remove_unlocked()
1467 memset(sflist->presets, 0, sizeof(sflist->presets)); in snd_soundfont_remove_unlocked()
1469 for (sf = sflist->fonts; sf; sf = sf->next) { in snd_soundfont_remove_unlocked()
1471 if (zp->counter < sflist->zone_locked) in snd_soundfont_remove_unlocked()
1479 if (sp->counter < sflist->sample_locked) in snd_soundfont_remove_unlocked()
1483 sflist->mem_used -= sp->v.truesize; in snd_soundfont_remove_unlocked()
1484 if (sflist->callback.sample_free) in snd_soundfont_remove_unlocked()
1485 sflist->callback.sample_free(sflist->callback.private_data, in snd_soundfont_remove_unlocked()
1486 sp, sflist->memhdr); in snd_soundfont_remove_unlocked()
1491 sflist->zone_counter = sflist->zone_locked; in snd_soundfont_remove_unlocked()
1492 sflist->sample_counter = sflist->sample_locked; in snd_soundfont_remove_unlocked()
1494 rebuild_presets(sflist); in snd_soundfont_remove_unlocked()
1496 unlock_preset(sflist); in snd_soundfont_remove_unlocked()