X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fdrivers%2Fopl3%2Fopl3_seq.c;h=96762c9d485578799c8a8fb6dbce6bad48f17953;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=3f774813480ec578b80e72ae52acbd76f5930a76;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 3f7748134..96762c9d4 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -24,18 +24,18 @@ #include "opl3_voice.h" #include +#include #include MODULE_AUTHOR("Uros Bizjak "); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("ALSA driver for OPL3 FM synth"); -MODULE_CLASSES("{sound}"); int use_internal_drums = 0; -MODULE_PARM(use_internal_drums, "i"); +module_param(use_internal_drums, bool, 0444); MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); -int snd_opl3_synth_use_inc(opl3_t * opl3) +int snd_opl3_synth_use_inc(struct snd_opl3 * opl3) { if (!try_module_get(opl3->card->module)) return -EFAULT; @@ -43,22 +43,22 @@ int snd_opl3_synth_use_inc(opl3_t * opl3) } -void snd_opl3_synth_use_dec(opl3_t * opl3) +void snd_opl3_synth_use_dec(struct snd_opl3 * opl3) { module_put(opl3->card->module); } -int snd_opl3_synth_setup(opl3_t * opl3) +int snd_opl3_synth_setup(struct snd_opl3 * opl3) { int idx; - down(&opl3->access_mutex); + mutex_lock(&opl3->access_mutex); if (opl3->used) { - up(&opl3->access_mutex); + mutex_unlock(&opl3->access_mutex); return -EBUSY; } opl3->used++; - up(&opl3->access_mutex); + mutex_unlock(&opl3->access_mutex); snd_opl3_reset(opl3); @@ -78,7 +78,7 @@ int snd_opl3_synth_setup(opl3_t * opl3) return 0; } -void snd_opl3_synth_cleanup(opl3_t * opl3) +void snd_opl3_synth_cleanup(struct snd_opl3 * opl3) { unsigned long flags; @@ -91,14 +91,14 @@ void snd_opl3_synth_cleanup(opl3_t * opl3) spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); snd_opl3_reset(opl3); - down(&opl3->access_mutex); + mutex_lock(&opl3->access_mutex); opl3->used--; - up(&opl3->access_mutex); + mutex_unlock(&opl3->access_mutex); } -int snd_opl3_synth_use(void *private_data, snd_seq_port_subscribe_t * info) +static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info) { - opl3_t *opl3 = snd_magic_cast(opl3_t, private_data, return -ENXIO); + struct snd_opl3 *opl3 = private_data; int err; if ((err = snd_opl3_synth_setup(opl3)) < 0) @@ -123,9 +123,9 @@ int snd_opl3_synth_use(void *private_data, snd_seq_port_subscribe_t * info) return 0; } -int snd_opl3_synth_unuse(void *private_data, snd_seq_port_subscribe_t * info) +static int snd_opl3_synth_unuse(void *private_data, struct snd_seq_port_subscribe * info) { - opl3_t *opl3 = snd_magic_cast(opl3_t, private_data, return -ENXIO); + struct snd_opl3 *opl3 = private_data; snd_opl3_synth_cleanup(opl3); @@ -137,7 +137,7 @@ int snd_opl3_synth_unuse(void *private_data, snd_seq_port_subscribe_t * info) /* * MIDI emulation operators */ -snd_midi_op_t opl3_ops = { +struct snd_midi_op opl3_ops = { .note_on = snd_opl3_note_on, .note_off = snd_opl3_note_off, .key_press = snd_opl3_key_press, @@ -147,10 +147,10 @@ snd_midi_op_t opl3_ops = { .sysex = snd_opl3_sysex, }; -static int snd_opl3_synth_event_input(snd_seq_event_t * ev, int direct, +static int snd_opl3_synth_event_input(struct snd_seq_event * ev, int direct, void *private_data, int atomic, int hop) { - opl3_t *opl3 = snd_magic_cast(opl3_t, private_data, return -EINVAL); + struct snd_opl3 *opl3 = private_data; if (ev->type >= SNDRV_SEQ_EVENT_INSTR_BEGIN && ev->type <= SNDRV_SEQ_EVENT_INSTR_CHANGE) { @@ -168,14 +168,14 @@ static int snd_opl3_synth_event_input(snd_seq_event_t * ev, int direct, static void snd_opl3_synth_free_port(void *private_data) { - opl3_t *opl3 = snd_magic_cast(opl3_t, private_data, return); + struct snd_opl3 *opl3 = private_data; snd_midi_channel_free_set(opl3->chset); } -static int snd_opl3_synth_create_port(opl3_t * opl3) +static int snd_opl3_synth_create_port(struct snd_opl3 * opl3) { - snd_seq_port_callback_t callbacks; + struct snd_seq_port_callback callbacks; char name[32]; int voices, opl_ver; @@ -203,27 +203,30 @@ static int snd_opl3_synth_create_port(opl3_t * opl3) SNDRV_SEQ_PORT_CAP_SUBS_WRITE, SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | SNDRV_SEQ_PORT_TYPE_MIDI_GM | - SNDRV_SEQ_PORT_TYPE_SYNTH, + SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE | + SNDRV_SEQ_PORT_TYPE_HARDWARE | + SNDRV_SEQ_PORT_TYPE_SYNTHESIZER, 16, voices, name); if (opl3->chset->port < 0) { + int port; + port = opl3->chset->port; snd_midi_channel_free_set(opl3->chset); - return opl3->chset->port; + return port; } return 0; } /* ------------------------------ */ -static int snd_opl3_seq_new_device(snd_seq_device_t *dev) +static int snd_opl3_seq_new_device(struct snd_seq_device *dev) { - opl3_t *opl3; - int client; - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t cinfo; + struct snd_opl3 *opl3; + int client, err; + char name[32]; int opl_ver; - opl3 = *(opl3_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (opl3 == NULL) return -EINVAL; @@ -232,23 +235,19 @@ static int snd_opl3_seq_new_device(snd_seq_device_t *dev) opl3->seq_client = -1; /* allocate new client */ - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = opl3; - callbacks.allow_output = callbacks.allow_input = 1; + opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; + sprintf(name, "OPL%i FM synth", opl_ver); client = opl3->seq_client = - snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num, &callbacks); + snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num, + name); if (client < 0) return client; - /* change name of client */ - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client; - cinfo.type = KERNEL_CLIENT; - opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; - sprintf(cinfo.name, "OPL%i FM synth", opl_ver); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); - - snd_opl3_synth_create_port(opl3); + if ((err = snd_opl3_synth_create_port(opl3)) < 0) { + snd_seq_delete_kernel_client(client); + opl3->seq_client = -1; + return err; + } /* initialize instrument list */ opl3->ilist = snd_seq_instr_list_new(); @@ -268,16 +267,16 @@ static int snd_opl3_seq_new_device(snd_seq_device_t *dev) opl3->sys_timer_status = 0; #ifdef CONFIG_SND_SEQUENCER_OSS - snd_opl3_init_seq_oss(opl3, cinfo.name); + snd_opl3_init_seq_oss(opl3, name); #endif return 0; } -static int snd_opl3_seq_delete_device(snd_seq_device_t *dev) +static int snd_opl3_seq_delete_device(struct snd_seq_device *dev) { - opl3_t *opl3; + struct snd_opl3 *opl3; - opl3 = *(opl3_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (opl3 == NULL) return -EINVAL; @@ -295,14 +294,14 @@ static int snd_opl3_seq_delete_device(snd_seq_device_t *dev) static int __init alsa_opl3_seq_init(void) { - static snd_seq_dev_ops_t ops = + static struct snd_seq_dev_ops ops = { snd_opl3_seq_new_device, snd_opl3_seq_delete_device }; return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OPL3, &ops, - sizeof(opl3_t*)); + sizeof(struct snd_opl3 *)); } static void __exit alsa_opl3_seq_exit(void)