1 // SPDX-License-Identifier: GPL-2.0-or-later << 2 /* 1 /* 3 * Copyright (C) 2000 Takashi Iwai <tiwai@sus 2 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de> 4 * 3 * 5 * Routines for control of EMU10K1 WaveTable 4 * Routines for control of EMU10K1 WaveTable synth >> 5 * >> 6 * This program is free software; you can redistribute it and/or modify >> 7 * it under the terms of the GNU General Public License as published by >> 8 * the Free Software Foundation; either version 2 of the License, or >> 9 * (at your option) any later version. >> 10 * >> 11 * This program is distributed in the hope that it will be useful, >> 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 14 * GNU General Public License for more details. >> 15 * >> 16 * You should have received a copy of the GNU General Public License >> 17 * along with this program; if not, write to the Free Software >> 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 */ 19 */ 7 20 8 #include "emu10k1_synth_local.h" 21 #include "emu10k1_synth_local.h" 9 #include <linux/init.h> 22 #include <linux/init.h> 10 #include <linux/module.h> 23 #include <linux/module.h> 11 24 12 MODULE_AUTHOR("Takashi Iwai"); 25 MODULE_AUTHOR("Takashi Iwai"); 13 MODULE_DESCRIPTION("Routines for control of EM 26 MODULE_DESCRIPTION("Routines for control of EMU10K1 WaveTable synth"); 14 MODULE_LICENSE("GPL"); 27 MODULE_LICENSE("GPL"); 15 28 16 /* 29 /* 17 * create a new hardware dependent device for 30 * create a new hardware dependent device for Emu10k1 18 */ 31 */ 19 static int snd_emu10k1_synth_probe(struct devi 32 static int snd_emu10k1_synth_probe(struct device *_dev) 20 { 33 { 21 struct snd_seq_device *dev = to_seq_de 34 struct snd_seq_device *dev = to_seq_dev(_dev); 22 struct snd_emux *emux; 35 struct snd_emux *emux; 23 struct snd_emu10k1 *hw; 36 struct snd_emu10k1 *hw; 24 struct snd_emu10k1_synth_arg *arg; 37 struct snd_emu10k1_synth_arg *arg; 25 unsigned long flags; 38 unsigned long flags; 26 39 27 arg = SNDRV_SEQ_DEVICE_ARGPTR(dev); 40 arg = SNDRV_SEQ_DEVICE_ARGPTR(dev); 28 if (arg == NULL) 41 if (arg == NULL) 29 return -EINVAL; 42 return -EINVAL; 30 43 31 if (arg->seq_ports <= 0) 44 if (arg->seq_ports <= 0) 32 return 0; /* nothing */ 45 return 0; /* nothing */ 33 if (arg->max_voices < 1) 46 if (arg->max_voices < 1) 34 arg->max_voices = 1; 47 arg->max_voices = 1; 35 else if (arg->max_voices > 64) 48 else if (arg->max_voices > 64) 36 arg->max_voices = 64; 49 arg->max_voices = 64; 37 50 38 if (snd_emux_new(&emux) < 0) 51 if (snd_emux_new(&emux) < 0) 39 return -ENOMEM; 52 return -ENOMEM; 40 53 41 snd_emu10k1_ops_setup(emux); 54 snd_emu10k1_ops_setup(emux); 42 hw = arg->hwptr; 55 hw = arg->hwptr; 43 emux->hw = hw; 56 emux->hw = hw; 44 emux->max_voices = arg->max_voices; 57 emux->max_voices = arg->max_voices; 45 emux->num_ports = arg->seq_ports; 58 emux->num_ports = arg->seq_ports; 46 emux->pitch_shift = -501; 59 emux->pitch_shift = -501; 47 emux->memhdr = hw->memhdr; 60 emux->memhdr = hw->memhdr; 48 /* maximum two ports */ 61 /* maximum two ports */ 49 emux->midi_ports = arg->seq_ports < 2 62 emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2; 50 /* audigy has two external midis */ 63 /* audigy has two external midis */ 51 emux->midi_devidx = hw->audigy ? 2 : 1 64 emux->midi_devidx = hw->audigy ? 2 : 1; 52 emux->linear_panning = 0; 65 emux->linear_panning = 0; 53 emux->hwdep_idx = 2; /* FIXED */ 66 emux->hwdep_idx = 2; /* FIXED */ 54 67 55 if (snd_emux_register(emux, dev->card, 68 if (snd_emux_register(emux, dev->card, arg->index, "Emu10k1") < 0) { 56 snd_emux_free(emux); 69 snd_emux_free(emux); 57 return -ENOMEM; 70 return -ENOMEM; 58 } 71 } 59 72 60 spin_lock_irqsave(&hw->voice_lock, fla 73 spin_lock_irqsave(&hw->voice_lock, flags); 61 hw->synth = emux; 74 hw->synth = emux; 62 hw->get_synth_voice = snd_emu10k1_synt 75 hw->get_synth_voice = snd_emu10k1_synth_get_voice; 63 spin_unlock_irqrestore(&hw->voice_lock 76 spin_unlock_irqrestore(&hw->voice_lock, flags); 64 77 65 dev->driver_data = emux; 78 dev->driver_data = emux; 66 79 67 return 0; 80 return 0; 68 } 81 } 69 82 70 static int snd_emu10k1_synth_remove(struct dev 83 static int snd_emu10k1_synth_remove(struct device *_dev) 71 { 84 { 72 struct snd_seq_device *dev = to_seq_de 85 struct snd_seq_device *dev = to_seq_dev(_dev); 73 struct snd_emux *emux; 86 struct snd_emux *emux; 74 struct snd_emu10k1 *hw; 87 struct snd_emu10k1 *hw; 75 unsigned long flags; 88 unsigned long flags; 76 89 77 if (dev->driver_data == NULL) 90 if (dev->driver_data == NULL) 78 return 0; /* not registered ac 91 return 0; /* not registered actually */ 79 92 80 emux = dev->driver_data; 93 emux = dev->driver_data; 81 94 82 hw = emux->hw; 95 hw = emux->hw; 83 spin_lock_irqsave(&hw->voice_lock, fla 96 spin_lock_irqsave(&hw->voice_lock, flags); 84 hw->synth = NULL; 97 hw->synth = NULL; 85 hw->get_synth_voice = NULL; 98 hw->get_synth_voice = NULL; 86 spin_unlock_irqrestore(&hw->voice_lock 99 spin_unlock_irqrestore(&hw->voice_lock, flags); 87 100 88 snd_emux_free(emux); 101 snd_emux_free(emux); 89 return 0; 102 return 0; 90 } 103 } 91 104 92 /* 105 /* 93 * INIT part 106 * INIT part 94 */ 107 */ 95 108 96 static struct snd_seq_driver emu10k1_synth_dri 109 static struct snd_seq_driver emu10k1_synth_driver = { 97 .driver = { 110 .driver = { 98 .name = KBUILD_MODNAME, 111 .name = KBUILD_MODNAME, 99 .probe = snd_emu10k1_synth_pro 112 .probe = snd_emu10k1_synth_probe, 100 .remove = snd_emu10k1_synth_re 113 .remove = snd_emu10k1_synth_remove, 101 }, 114 }, 102 .id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, 115 .id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, 103 .argsize = sizeof(struct snd_emu10k1_s 116 .argsize = sizeof(struct snd_emu10k1_synth_arg), 104 }; 117 }; 105 118 106 module_snd_seq_driver(emu10k1_synth_driver); 119 module_snd_seq_driver(emu10k1_synth_driver); 107 120
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.