]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/drivers/opl3/opl3_seq.c
hwmon-vid: Add support for AMD family 10h CPUs
[linux-2.6-omap-h63xx.git] / sound / drivers / opl3 / opl3_seq.c
index c4ead790008a32ac66c3b35eff538f6dabae1fa8..2d33f53d36b8227a0ed520a7ec236f02b2df944c 100644 (file)
@@ -51,14 +51,15 @@ void snd_opl3_synth_use_dec(struct snd_opl3 * opl3)
 int snd_opl3_synth_setup(struct snd_opl3 * opl3)
 {
        int idx;
+       struct snd_hwdep *hwdep = opl3->hwdep;
 
-       down(&opl3->access_mutex);
-       if (opl3->used) {
-               up(&opl3->access_mutex);
+       mutex_lock(&hwdep->open_mutex);
+       if (hwdep->used) {
+               mutex_unlock(&hwdep->open_mutex);
                return -EBUSY;
        }
-       opl3->used++;
-       up(&opl3->access_mutex);
+       hwdep->used++;
+       mutex_unlock(&hwdep->open_mutex);
 
        snd_opl3_reset(opl3);
 
@@ -81,6 +82,7 @@ int snd_opl3_synth_setup(struct snd_opl3 * opl3)
 void snd_opl3_synth_cleanup(struct snd_opl3 * opl3)
 {
        unsigned long flags;
+       struct snd_hwdep *hwdep;
 
        /* Stop system timer */
        spin_lock_irqsave(&opl3->sys_timer_lock, flags);
@@ -91,9 +93,11 @@ void snd_opl3_synth_cleanup(struct snd_opl3 * opl3)
        spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
 
        snd_opl3_reset(opl3);
-       down(&opl3->access_mutex);
-       opl3->used--;
-       up(&opl3->access_mutex);
+       hwdep = opl3->hwdep;
+       mutex_lock(&hwdep->open_mutex);
+       hwdep->used--;
+       mutex_unlock(&hwdep->open_mutex);
+       wake_up(&hwdep->open_wait);
 }
 
 static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info)
@@ -152,15 +156,7 @@ static int snd_opl3_synth_event_input(struct snd_seq_event * ev, int direct,
 {
        struct snd_opl3 *opl3 = private_data;
 
-       if (ev->type >= SNDRV_SEQ_EVENT_INSTR_BEGIN &&
-           ev->type <= SNDRV_SEQ_EVENT_INSTR_CHANGE) {
-               if (direct) {
-                       snd_seq_instr_event(&opl3->fm_ops, opl3->ilist, ev,
-                                           opl3->seq_client, atomic, hop);
-               }
-       } else {
-               snd_midi_process_event(&opl3_ops, ev, opl3->chset);
-       }
+       snd_midi_process_event(&opl3_ops, ev, opl3->chset);
        return 0;
 }
 
@@ -203,12 +199,16 @@ static int snd_opl3_synth_create_port(struct snd_opl3 * 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;
 }
@@ -218,7 +218,7 @@ static int snd_opl3_synth_create_port(struct snd_opl3 * opl3)
 static int snd_opl3_seq_new_device(struct snd_seq_device *dev)
 {
        struct snd_opl3 *opl3;
-       int client;
+       int client, err;
        char name[32];
        int opl_ver;
 
@@ -239,17 +239,11 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev)
        if (client < 0)
                return client;
 
-       snd_opl3_synth_create_port(opl3);
-
-       /* initialize instrument list */
-       opl3->ilist = snd_seq_instr_list_new();
-       if (opl3->ilist == NULL) {
+       if ((err = snd_opl3_synth_create_port(opl3)) < 0) {
                snd_seq_delete_kernel_client(client);
                opl3->seq_client = -1;
-               return -ENOMEM;
+               return err;
        }
-       opl3->ilist->flags = SNDRV_SEQ_INSTR_FLG_DIRECT;
-       snd_seq_fm_init(&opl3->fm_ops, NULL);
 
        /* setup system timer */
        init_timer(&opl3->tlist);
@@ -279,8 +273,6 @@ static int snd_opl3_seq_delete_device(struct snd_seq_device *dev)
                snd_seq_delete_kernel_client(opl3->seq_client);
                opl3->seq_client = -1;
        }
-       if (opl3->ilist)
-               snd_seq_instr_list_free(&opl3->ilist);
        return 0;
 }