| 1 | // SPDX-License-Identifier: GPL-2.0-or-later
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
|
|---|
| 4 | *
|
|---|
| 5 | * Routines for control of EMU10K1 WaveTable synth
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include "emu10k1_synth_local.h"
|
|---|
| 9 | #include <linux/init.h>
|
|---|
| 10 | #include <linux/module.h>
|
|---|
| 11 |
|
|---|
| 12 | MODULE_AUTHOR("Takashi Iwai");
|
|---|
| 13 | MODULE_DESCRIPTION("Routines for control of EMU10K1 WaveTable synth");
|
|---|
| 14 | MODULE_LICENSE("GPL");
|
|---|
| 15 |
|
|---|
| 16 | #ifdef TARGET_OS2
|
|---|
| 17 | #define KBUILD_MODNAME "emu10k1_synth"
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | * create a new hardware dependent device for Emu10k1
|
|---|
| 22 | */
|
|---|
| 23 | static int snd_emu10k1_synth_probe(struct device *_dev)
|
|---|
| 24 | {
|
|---|
| 25 | struct snd_seq_device *dev = to_seq_dev(_dev);
|
|---|
| 26 | struct snd_emux *emux;
|
|---|
| 27 | struct snd_emu10k1 *hw;
|
|---|
| 28 | struct snd_emu10k1_synth_arg *arg;
|
|---|
| 29 |
|
|---|
| 30 | arg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
|
|---|
| 31 | if (arg == NULL)
|
|---|
| 32 | return -EINVAL;
|
|---|
| 33 |
|
|---|
| 34 | if (arg->seq_ports <= 0)
|
|---|
| 35 | return 0; /* nothing */
|
|---|
| 36 | if (arg->max_voices < 1)
|
|---|
| 37 | arg->max_voices = 1;
|
|---|
| 38 | else if (arg->max_voices > 64)
|
|---|
| 39 | arg->max_voices = 64;
|
|---|
| 40 |
|
|---|
| 41 | if (snd_emux_new(&emux) < 0)
|
|---|
| 42 | return -ENOMEM;
|
|---|
| 43 |
|
|---|
| 44 | snd_emu10k1_ops_setup(emux);
|
|---|
| 45 | hw = arg->hwptr;
|
|---|
| 46 | emux->hw = hw;
|
|---|
| 47 | emux->max_voices = arg->max_voices;
|
|---|
| 48 | emux->num_ports = arg->seq_ports;
|
|---|
| 49 | emux->memhdr = hw->memhdr;
|
|---|
| 50 | /* maximum two ports */
|
|---|
| 51 | emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;
|
|---|
| 52 | /* audigy has two external midis */
|
|---|
| 53 | emux->midi_devidx = hw->audigy ? 2 : 1;
|
|---|
| 54 | emux->linear_panning = 0;
|
|---|
| 55 | emux->hwdep_idx = 2; /* FIXED */
|
|---|
| 56 |
|
|---|
| 57 | if (snd_emux_register(emux, dev->card, arg->index, "Emu10k1") < 0) {
|
|---|
| 58 | snd_emux_free(emux);
|
|---|
| 59 | return -ENOMEM;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | spin_lock_irq(&hw->voice_lock);
|
|---|
| 63 | hw->synth = emux;
|
|---|
| 64 | hw->get_synth_voice = snd_emu10k1_synth_get_voice;
|
|---|
| 65 | spin_unlock_irq(&hw->voice_lock);
|
|---|
| 66 |
|
|---|
| 67 | dev->driver_data = emux;
|
|---|
| 68 |
|
|---|
| 69 | return 0;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | static int snd_emu10k1_synth_remove(struct device *_dev)
|
|---|
| 73 | {
|
|---|
| 74 | struct snd_seq_device *dev = to_seq_dev(_dev);
|
|---|
| 75 | struct snd_emux *emux;
|
|---|
| 76 | struct snd_emu10k1 *hw;
|
|---|
| 77 |
|
|---|
| 78 | if (dev->driver_data == NULL)
|
|---|
| 79 | return 0; /* not registered actually */
|
|---|
| 80 |
|
|---|
| 81 | emux = dev->driver_data;
|
|---|
| 82 |
|
|---|
| 83 | hw = emux->hw;
|
|---|
| 84 | spin_lock_irq(&hw->voice_lock);
|
|---|
| 85 | hw->synth = NULL;
|
|---|
| 86 | hw->get_synth_voice = NULL;
|
|---|
| 87 | spin_unlock_irq(&hw->voice_lock);
|
|---|
| 88 |
|
|---|
| 89 | snd_emux_free(emux);
|
|---|
| 90 | return 0;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /*
|
|---|
| 94 | * INIT part
|
|---|
| 95 | */
|
|---|
| 96 |
|
|---|
| 97 | static struct snd_seq_driver emu10k1_synth_driver = {
|
|---|
| 98 | .driver = {
|
|---|
| 99 | .name = KBUILD_MODNAME,
|
|---|
| 100 | .probe = snd_emu10k1_synth_probe,
|
|---|
| 101 | .remove = snd_emu10k1_synth_remove,
|
|---|
| 102 | },
|
|---|
| 103 | .id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
|
|---|
| 104 | .argsize = sizeof(struct snd_emu10k1_synth_arg),
|
|---|
| 105 | };
|
|---|
| 106 |
|
|---|
| 107 | module_snd_seq_driver(emu10k1_synth_driver);
|
|---|