X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fsynth%2Femux%2Fsoundfont.c;h=455e535933ecf0b3ac1a182588677a3ae31b95eb;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=8db2e2db5ff1bdb6c230b52dc5c80174c85f9713;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 8db2e2db5..455e53593 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -34,45 +34,55 @@ /* Prototypes for static functions */ -static int open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client); -static snd_soundfont_t *newsf(snd_sf_list_t *sflist, int type, char *name); -static int is_identical_font(snd_soundfont_t *sf, int type, unsigned char *name); -static int close_patch(snd_sf_list_t *sflist); -static int probe_data(snd_sf_list_t *sflist, int sample_id); -static void set_zone_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_zone_t *zp); -static snd_sf_zone_t *sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf); -static void set_sample_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp); -static snd_sf_sample_t *sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf); -static void sf_sample_delete(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp); -static int load_map(snd_sf_list_t *sflist, const void __user *data, int count); -static int load_info(snd_sf_list_t *sflist, const void __user *data, long count); -static int remove_info(snd_sf_list_t *sflist, snd_soundfont_t *sf, int bank, int instr); -static void init_voice_info(soundfont_voice_info_t *avp); -static void init_voice_parm(soundfont_voice_parm_t *pp); -static snd_sf_sample_t *set_sample(snd_soundfont_t *sf, soundfont_voice_info_t *avp); -static snd_sf_sample_t *find_sample(snd_soundfont_t *sf, int sample_id); -static int load_data(snd_sf_list_t *sflist, const void __user *data, long count); -static void rebuild_presets(snd_sf_list_t *sflist); -static void add_preset(snd_sf_list_t *sflist, snd_sf_zone_t *cur); -static void delete_preset(snd_sf_list_t *sflist, snd_sf_zone_t *zp); -static snd_sf_zone_t *search_first_zone(snd_sf_list_t *sflist, int bank, int preset, int key); -static int search_zones(snd_sf_list_t *sflist, int *notep, int vel, int preset, int bank, snd_sf_zone_t **table, int max_layers, int level); +static int open_patch(struct snd_sf_list *sflist, const char __user *data, + int count, int client); +static struct snd_soundfont *newsf(struct snd_sf_list *sflist, int type, char *name); +static int is_identical_font(struct snd_soundfont *sf, int type, unsigned char *name); +static int close_patch(struct snd_sf_list *sflist); +static int probe_data(struct snd_sf_list *sflist, int sample_id); +static void set_zone_counter(struct snd_sf_list *sflist, + struct snd_soundfont *sf, struct snd_sf_zone *zp); +static struct snd_sf_zone *sf_zone_new(struct snd_sf_list *sflist, + struct snd_soundfont *sf); +static void set_sample_counter(struct snd_sf_list *sflist, + struct snd_soundfont *sf, struct snd_sf_sample *sp); +static struct snd_sf_sample *sf_sample_new(struct snd_sf_list *sflist, + struct snd_soundfont *sf); +static void sf_sample_delete(struct snd_sf_list *sflist, + struct snd_soundfont *sf, struct snd_sf_sample *sp); +static int load_map(struct snd_sf_list *sflist, const void __user *data, int count); +static int load_info(struct snd_sf_list *sflist, const void __user *data, long count); +static int remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf, + int bank, int instr); +static void init_voice_info(struct soundfont_voice_info *avp); +static void init_voice_parm(struct soundfont_voice_parm *pp); +static struct snd_sf_sample *set_sample(struct snd_soundfont *sf, + struct soundfont_voice_info *avp); +static struct snd_sf_sample *find_sample(struct snd_soundfont *sf, int sample_id); +static int load_data(struct snd_sf_list *sflist, const void __user *data, long count); +static void rebuild_presets(struct snd_sf_list *sflist); +static void add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur); +static void delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp); +static struct snd_sf_zone *search_first_zone(struct snd_sf_list *sflist, + int bank, int preset, int key); +static int search_zones(struct snd_sf_list *sflist, int *notep, int vel, + int preset, int bank, struct snd_sf_zone **table, + int max_layers, int level); static int get_index(int bank, int instr, int key); -static void snd_sf_init(snd_sf_list_t *sflist); -static void snd_sf_clear(snd_sf_list_t *sflist); +static void snd_sf_init(struct snd_sf_list *sflist); +static void snd_sf_clear(struct snd_sf_list *sflist); /* * lock access to sflist */ -static int -lock_preset(snd_sf_list_t *sflist, int nonblock) +static void +lock_preset(struct snd_sf_list *sflist) { - if (nonblock) { - if (down_trylock(&sflist->presets_mutex)) - return -EBUSY; - } else - down(&sflist->presets_mutex); - return 0; + unsigned long flags; + mutex_lock(&sflist->presets_mutex); + spin_lock_irqsave(&sflist->lock, flags); + sflist->presets_locked = 1; + spin_unlock_irqrestore(&sflist->lock, flags); } @@ -80,9 +90,13 @@ lock_preset(snd_sf_list_t *sflist, int nonblock) * remove lock */ static void -unlock_preset(snd_sf_list_t *sflist) +unlock_preset(struct snd_sf_list *sflist) { - up(&sflist->presets_mutex); + unsigned long flags; + spin_lock_irqsave(&sflist->lock, flags); + sflist->presets_locked = 0; + spin_unlock_irqrestore(&sflist->lock, flags); + mutex_unlock(&sflist->presets_mutex); } @@ -90,7 +104,7 @@ unlock_preset(snd_sf_list_t *sflist) * close the patch if the patch was opened by this client. */ int -snd_soundfont_close_check(snd_sf_list_t *sflist, int client) +snd_soundfont_close_check(struct snd_sf_list *sflist, int client) { unsigned long flags; spin_lock_irqsave(&sflist->lock, flags); @@ -112,9 +126,10 @@ snd_soundfont_close_check(snd_sf_list_t *sflist, int client) * it wants to do with it. */ int -snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, int client) +snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data, + long count, int client) { - soundfont_patch_info_t patch; + struct soundfont_patch_info patch; unsigned long flags; int rc; @@ -143,7 +158,7 @@ snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, i if (patch.type == SNDRV_SFNT_OPEN_PATCH) { /* grab sflist to open */ - lock_preset(sflist, 0); + lock_preset(sflist); rc = open_patch(sflist, data, count, client); unlock_preset(sflist); return rc; @@ -157,7 +172,7 @@ snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, i } spin_unlock_irqrestore(&sflist->lock, flags); - lock_preset(sflist, 0); + lock_preset(sflist); rc = -EINVAL; switch (patch.type) { case SNDRV_SFNT_LOAD_INFO: @@ -180,7 +195,7 @@ snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, i break; case SNDRV_SFNT_REMOVE_INFO: /* patch must be opened */ - if (sflist->currsf) { + if (!sflist->currsf) { snd_printk("soundfont: remove_info: patch not opened\n"); rc = -EINVAL; } else { @@ -212,10 +227,11 @@ is_special_type(int type) /* open patch; create sf list */ static int -open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client) +open_patch(struct snd_sf_list *sflist, const char __user *data, + int count, int client) { - soundfont_open_parm_t parm; - snd_soundfont_t *sf; + struct soundfont_open_parm parm; + struct snd_soundfont *sf; unsigned long flags; spin_lock_irqsave(&sflist->lock, flags); @@ -237,8 +253,10 @@ open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client return -ENOMEM; } + spin_lock_irqsave(&sflist->lock, flags); sflist->open_client = client; sflist->currsf = sf; + spin_unlock_irqrestore(&sflist->lock, flags); return 0; } @@ -246,10 +264,10 @@ open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client /* * Allocate a new soundfont structure. */ -static snd_soundfont_t * -newsf(snd_sf_list_t *sflist, int type, char *name) +static struct snd_soundfont * +newsf(struct snd_sf_list *sflist, int type, char *name) { - snd_soundfont_t *sf; + struct snd_soundfont *sf; /* check the shared fonts */ if (type & SNDRV_SFNT_PAT_SHARED) { @@ -261,7 +279,7 @@ newsf(snd_sf_list_t *sflist, int type, char *name) } /* not found -- create a new one */ - sf = (snd_soundfont_t*)snd_kcalloc(sizeof(*sf), GFP_KERNEL); + sf = kzalloc(sizeof(*sf), GFP_KERNEL); if (sf == NULL) return NULL; sf->id = sflist->fonts_size; @@ -282,7 +300,7 @@ newsf(snd_sf_list_t *sflist, int type, char *name) /* check if the given name matches to the existing list */ static int -is_identical_font(snd_soundfont_t *sf, int type, unsigned char *name) +is_identical_font(struct snd_soundfont *sf, int type, unsigned char *name) { return ((sf->type & SNDRV_SFNT_PAT_SHARED) && (sf->type & 0x0f) == (type & 0x0f) && @@ -294,10 +312,14 @@ is_identical_font(snd_soundfont_t *sf, int type, unsigned char *name) * Close the current patch. */ static int -close_patch(snd_sf_list_t *sflist) +close_patch(struct snd_sf_list *sflist) { + unsigned long flags; + + spin_lock_irqsave(&sflist->lock, flags); sflist->currsf = NULL; sflist->open_client = -1; + spin_unlock_irqrestore(&sflist->lock, flags); rebuild_presets(sflist); @@ -307,7 +329,7 @@ close_patch(snd_sf_list_t *sflist) /* probe sample in the current list -- nothing to be loaded */ static int -probe_data(snd_sf_list_t *sflist, int sample_id) +probe_data(struct snd_sf_list *sflist, int sample_id) { /* patch must be opened */ if (sflist->currsf) { @@ -322,7 +344,8 @@ probe_data(snd_sf_list_t *sflist, int sample_id) * increment zone counter */ static void -set_zone_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_zone_t *zp) +set_zone_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, + struct snd_sf_zone *zp) { zp->counter = sflist->zone_counter++; if (sf->type & SNDRV_SFNT_PAT_LOCKED) @@ -332,12 +355,12 @@ set_zone_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_zone_t *zp) /* * allocate a new zone record */ -static snd_sf_zone_t * -sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) +static struct snd_sf_zone * +sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) { - snd_sf_zone_t *zp; + struct snd_sf_zone *zp; - if ((zp = snd_kcalloc(sizeof(*zp), GFP_KERNEL)) == NULL) + if ((zp = kzalloc(sizeof(*zp), GFP_KERNEL)) == NULL) return NULL; zp->next = sf->zones; sf->zones = zp; @@ -353,7 +376,8 @@ sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) * increment sample couter */ static void -set_sample_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp) +set_sample_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, + struct snd_sf_sample *sp) { sp->counter = sflist->sample_counter++; if (sf->type & SNDRV_SFNT_PAT_LOCKED) @@ -363,12 +387,12 @@ set_sample_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t * /* * allocate a new sample list record */ -static snd_sf_sample_t * -sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) +static struct snd_sf_sample * +sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) { - snd_sf_sample_t *sp; + struct snd_sf_sample *sp; - if ((sp = snd_kcalloc(sizeof(*sp), GFP_KERNEL)) == NULL) + if ((sp = kzalloc(sizeof(*sp), GFP_KERNEL)) == NULL) return NULL; sp->next = sf->samples; @@ -383,7 +407,8 @@ sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) * only the last allocated sample can be deleted. */ static void -sf_sample_delete(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp) +sf_sample_delete(struct snd_sf_list *sflist, struct snd_soundfont *sf, + struct snd_sf_sample *sp) { /* only last sample is accepted */ if (sp == sf->samples) { @@ -395,11 +420,11 @@ sf_sample_delete(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp /* load voice map */ static int -load_map(snd_sf_list_t *sflist, const void __user *data, int count) +load_map(struct snd_sf_list *sflist, const void __user *data, int count) { - snd_sf_zone_t *zp, *prevp; - snd_soundfont_t *sf; - soundfont_voice_map_t map; + struct snd_sf_zone *zp, *prevp; + struct snd_soundfont *sf; + struct soundfont_voice_map map; /* get the link info */ if (count < (int)sizeof(map)) @@ -460,9 +485,10 @@ load_map(snd_sf_list_t *sflist, const void __user *data, int count) /* remove the present instrument layers */ static int -remove_info(snd_sf_list_t *sflist, snd_soundfont_t *sf, int bank, int instr) +remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf, + int bank, int instr) { - snd_sf_zone_t *prev, *next, *p; + struct snd_sf_zone *prev, *next, *p; int removed = 0; prev = NULL; @@ -491,11 +517,11 @@ remove_info(snd_sf_list_t *sflist, snd_soundfont_t *sf, int bank, int instr) * open soundfont. */ static int -load_info(snd_sf_list_t *sflist, const void __user *data, long count) +load_info(struct snd_sf_list *sflist, const void __user *data, long count) { - snd_soundfont_t *sf; - snd_sf_zone_t *zone; - soundfont_voice_rec_hdr_t hdr; + struct snd_soundfont *sf; + struct snd_sf_zone *zone; + struct soundfont_voice_rec_hdr hdr; int i; /* patch must be opened */ @@ -520,7 +546,7 @@ load_info(snd_sf_list_t *sflist, const void __user *data, long count) return -EINVAL; } - if (count < (long)sizeof(soundfont_voice_info_t)*hdr.nvoices) { + if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) { printk("Soundfont Error: patch length(%ld) is smaller than nvoices(%d)\n", count, hdr.nvoices); return -EINVAL; @@ -544,7 +570,7 @@ load_info(snd_sf_list_t *sflist, const void __user *data, long count) } for (i = 0; i < hdr.nvoices; i++) { - snd_sf_zone_t tmpzone; + struct snd_sf_zone tmpzone; /* copy awe_voice_info parameters */ if (copy_from_user(&tmpzone.v, data, sizeof(tmpzone.v))) { @@ -581,7 +607,7 @@ load_info(snd_sf_list_t *sflist, const void __user *data, long count) /* initialize voice_info record */ static void -init_voice_info(soundfont_voice_info_t *avp) +init_voice_info(struct soundfont_voice_info *avp) { memset(avp, 0, sizeof(*avp)); @@ -605,7 +631,7 @@ init_voice_info(soundfont_voice_info_t *avp) * Chorus and Reverb effects are zero. */ static void -init_voice_parm(soundfont_voice_parm_t *pp) +init_voice_parm(struct soundfont_voice_parm *pp) { memset(pp, 0, sizeof(*pp)); @@ -626,10 +652,10 @@ init_voice_parm(soundfont_voice_parm_t *pp) } /* search the specified sample */ -static snd_sf_sample_t * -set_sample(snd_soundfont_t *sf, soundfont_voice_info_t *avp) +static struct snd_sf_sample * +set_sample(struct snd_soundfont *sf, struct soundfont_voice_info *avp) { - snd_sf_sample_t *sample; + struct snd_sf_sample *sample; sample = find_sample(sf, avp->sample); if (sample == NULL) @@ -652,10 +678,10 @@ set_sample(snd_soundfont_t *sf, soundfont_voice_info_t *avp) } /* find the sample pointer with the given id in the soundfont */ -static snd_sf_sample_t * -find_sample(snd_soundfont_t *sf, int sample_id) +static struct snd_sf_sample * +find_sample(struct snd_soundfont *sf, int sample_id) { - snd_sf_sample_t *p; + struct snd_sf_sample *p; if (sf == NULL) return NULL; @@ -675,11 +701,11 @@ find_sample(snd_soundfont_t *sf, int sample_id) * routine. */ static int -load_data(snd_sf_list_t *sflist, const void __user *data, long count) +load_data(struct snd_sf_list *sflist, const void __user *data, long count) { - snd_soundfont_t *sf; - soundfont_sample_info_t sample_info; - snd_sf_sample_t *sp; + struct snd_soundfont *sf; + struct soundfont_sample_info sample_info; + struct snd_sf_sample *sp; long off; /* patch must be opened */ @@ -784,6 +810,9 @@ snd_sf_linear_to_log(unsigned int amount, int offset, int ratio) return v; } +EXPORT_SYMBOL(snd_sf_linear_to_log); + + #define OFFSET_MSEC 653117 /* base = 1000 */ #define OFFSET_ABSCENT 851781 /* base = 8176 */ #define OFFSET_SAMPLERATE 1011119 /* base = 44100 */ @@ -913,12 +942,13 @@ int snd_sf_vol_table[128] = { /* load GUS patch */ static int -load_guspatch(snd_sf_list_t *sflist, const char __user *data, long count, int client) +load_guspatch(struct snd_sf_list *sflist, const char __user *data, + long count, int client) { struct patch_info patch; - snd_soundfont_t *sf; - snd_sf_zone_t *zone; - snd_sf_sample_t *smp; + struct snd_soundfont *sf; + struct snd_sf_zone *zone; + struct snd_sf_sample *smp; int note, sample_id; int rc; @@ -983,7 +1013,8 @@ load_guspatch(snd_sf_list_t *sflist, const char __user *data, long count, int cl */ if (sflist->callback.sample_new) { rc = sflist->callback.sample_new - (sflist->callback.private_data, smp, sflist->memhdr, data, count); + (sflist->callback.private_data, smp, sflist->memhdr, + data, count); if (rc < 0) { sf_sample_delete(sflist, sf, smp); return rc; @@ -1086,11 +1117,11 @@ load_guspatch(snd_sf_list_t *sflist, const char __user *data, long count, int cl /* load GUS patch */ int -snd_soundfont_load_guspatch(snd_sf_list_t *sflist, const char __user *data, +snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count, int client) { int rc; - lock_preset(sflist, 0); + lock_preset(sflist); rc = load_guspatch(sflist, data, count, client); unlock_preset(sflist); return rc; @@ -1105,10 +1136,10 @@ snd_soundfont_load_guspatch(snd_sf_list_t *sflist, const char __user *data, * bank/key combination). */ static void -rebuild_presets(snd_sf_list_t *sflist) +rebuild_presets(struct snd_sf_list *sflist) { - snd_soundfont_t *sf; - snd_sf_zone_t *cur; + struct snd_soundfont *sf; + struct snd_sf_zone *cur; /* clear preset table */ memset(sflist->presets, 0, sizeof(sflist->presets)); @@ -1133,15 +1164,15 @@ rebuild_presets(snd_sf_list_t *sflist) * add the given zone to preset table */ static void -add_preset(snd_sf_list_t *sflist, snd_sf_zone_t *cur) +add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur) { - snd_sf_zone_t *zone; + struct snd_sf_zone *zone; int index; zone = search_first_zone(sflist, cur->bank, cur->instr, cur->v.low); if (zone && zone->v.sf_id != cur->v.sf_id) { /* different instrument was already defined */ - snd_sf_zone_t *p; + struct snd_sf_zone *p; /* compare the allocated time */ for (p = zone; p; p = p->next_zone) { if (p->counter > cur->counter) @@ -1165,10 +1196,10 @@ add_preset(snd_sf_list_t *sflist, snd_sf_zone_t *cur) * delete the given zones from preset_table */ static void -delete_preset(snd_sf_list_t *sflist, snd_sf_zone_t *zp) +delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp) { int index; - snd_sf_zone_t *p; + struct snd_sf_zone *p; if ((index = get_index(zp->bank, zp->instr, zp->v.low)) < 0) return; @@ -1191,23 +1222,32 @@ delete_preset(snd_sf_list_t *sflist, snd_sf_zone_t *zp) * This function returns the number of found zones. 0 if not found. */ int -snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel, +snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, int preset, int bank, int def_preset, int def_bank, - snd_sf_zone_t **table, int max_layers) + struct snd_sf_zone **table, int max_layers) { int nvoices; + unsigned long flags; - if (lock_preset(sflist, 1)) + /* this function is supposed to be called atomically, + * so we check the lock. if it's busy, just returns 0 to + * tell the caller the busy state + */ + spin_lock_irqsave(&sflist->lock, flags); + if (sflist->presets_locked) { + spin_unlock_irqrestore(&sflist->lock, flags); return 0; - - nvoices = search_zones(sflist, notep, vel, preset, bank, table, max_layers, 0); + } + nvoices = search_zones(sflist, notep, vel, preset, bank, + table, max_layers, 0); if (! nvoices) { if (preset != def_preset || bank != def_bank) - nvoices = search_zones(sflist, notep, vel, def_preset, def_bank, table, max_layers, 0); + nvoices = search_zones(sflist, notep, vel, + def_preset, def_bank, + table, max_layers, 0); } - unlock_preset(sflist); - + spin_unlock_irqrestore(&sflist->lock, flags); return nvoices; } @@ -1215,11 +1255,11 @@ snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel, /* * search the first matching zone */ -static snd_sf_zone_t * -search_first_zone(snd_sf_list_t *sflist, int bank, int preset, int key) +static struct snd_sf_zone * +search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key) { int index; - snd_sf_zone_t *zp; + struct snd_sf_zone *zp; if ((index = get_index(bank, preset, key)) < 0) return NULL; @@ -1235,9 +1275,11 @@ search_first_zone(snd_sf_list_t *sflist, int bank, int preset, int key) * search matching zones from sflist. can be called recursively. */ static int -search_zones(snd_sf_list_t *sflist, int *notep, int vel, int preset, int bank, snd_sf_zone_t **table, int max_layers, int level) +search_zones(struct snd_sf_list *sflist, int *notep, int vel, + int preset, int bank, struct snd_sf_zone **table, + int max_layers, int level) { - snd_sf_zone_t *zp; + struct snd_sf_zone *zp; int nvoices; zp = search_first_zone(sflist, bank, preset, *notep); @@ -1295,7 +1337,7 @@ get_index(int bank, int instr, int key) * Initialise the sflist structure. */ static void -snd_sf_init(snd_sf_list_t *sflist) +snd_sf_init(struct snd_sf_list *sflist) { memset(sflist->presets, 0, sizeof(sflist->presets)); @@ -1314,11 +1356,11 @@ snd_sf_init(snd_sf_list_t *sflist) * Release all list records */ static void -snd_sf_clear(snd_sf_list_t *sflist) +snd_sf_clear(struct snd_sf_list *sflist) { - snd_soundfont_t *sf, *nextsf; - snd_sf_zone_t *zp, *nextzp; - snd_sf_sample_t *sp, *nextsp; + struct snd_soundfont *sf, *nextsf; + struct snd_sf_zone *zp, *nextzp; + struct snd_sf_sample *sp, *nextsp; for (sf = sflist->fonts; sf; sf = nextsf) { nextsf = sf->next; @@ -1329,7 +1371,8 @@ snd_sf_clear(snd_sf_list_t *sflist) for (sp = sf->samples; sp; sp = nextsp) { nextsp = sp->next; if (sflist->callback.sample_free) - sflist->callback.sample_free(sflist->callback.private_data, sp, sflist->memhdr); + sflist->callback.sample_free(sflist->callback.private_data, + sp, sflist->memhdr); kfree(sp); } kfree(sf); @@ -1342,15 +1385,15 @@ snd_sf_clear(snd_sf_list_t *sflist) /* * Create a new sflist structure */ -snd_sf_list_t * -snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr) +struct snd_sf_list * +snd_sf_new(struct snd_sf_callback *callback, struct snd_util_memhdr *hdr) { - snd_sf_list_t *sflist; + struct snd_sf_list *sflist; - if ((sflist = snd_kcalloc(sizeof(snd_sf_list_t), GFP_KERNEL)) == NULL) + if ((sflist = kzalloc(sizeof(*sflist), GFP_KERNEL)) == NULL) return NULL; - init_MUTEX(&sflist->presets_mutex); + mutex_init(&sflist->presets_mutex); spin_lock_init(&sflist->lock); sflist->memhdr = hdr; @@ -1366,12 +1409,12 @@ snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr) * Free everything allocated off the sflist structure. */ void -snd_sf_free(snd_sf_list_t *sflist) +snd_sf_free(struct snd_sf_list *sflist) { if (sflist == NULL) return; - lock_preset(sflist, 0); + lock_preset(sflist); if (sflist->callback.sample_reset) sflist->callback.sample_reset(sflist->callback.private_data); snd_sf_clear(sflist); @@ -1385,9 +1428,9 @@ snd_sf_free(snd_sf_list_t *sflist) * The soundcard should be silet before calling this function. */ int -snd_soundfont_remove_samples(snd_sf_list_t *sflist) +snd_soundfont_remove_samples(struct snd_sf_list *sflist) { - lock_preset(sflist, 0); + lock_preset(sflist); if (sflist->callback.sample_reset) sflist->callback.sample_reset(sflist->callback.private_data); snd_sf_clear(sflist); @@ -1401,14 +1444,13 @@ snd_soundfont_remove_samples(snd_sf_list_t *sflist) * The soundcard should be silent before calling this function. */ int -snd_soundfont_remove_unlocked(snd_sf_list_t *sflist) +snd_soundfont_remove_unlocked(struct snd_sf_list *sflist) { - snd_soundfont_t *sf; - snd_sf_zone_t *zp, *nextzp; - snd_sf_sample_t *sp, *nextsp; + struct snd_soundfont *sf; + struct snd_sf_zone *zp, *nextzp; + struct snd_sf_sample *sp, *nextsp; - if (lock_preset(sflist, 1)) - return -EBUSY; + lock_preset(sflist); if (sflist->callback.sample_reset) sflist->callback.sample_reset(sflist->callback.private_data); @@ -1432,7 +1474,8 @@ snd_soundfont_remove_unlocked(snd_sf_list_t *sflist) sf->samples = nextsp; sflist->mem_used -= sp->v.truesize; if (sflist->callback.sample_free) - sflist->callback.sample_free(sflist->callback.private_data, sp, sflist->memhdr); + sflist->callback.sample_free(sflist->callback.private_data, + sp, sflist->memhdr); kfree(sp); } } @@ -1445,12 +1488,3 @@ snd_soundfont_remove_unlocked(snd_sf_list_t *sflist) unlock_preset(sflist); return 0; } - -/* - * Return the used memory size (in words) - */ -int -snd_soundfont_mem_used(snd_sf_list_t *sflist) -{ - return sflist->mem_used; -}