Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  3 *     and (c) 1999 Steve Ratcliffe <steve@parabola.demon.co.uk>
  4 *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
  5 *
  6 *  Emu8000 synth plug-in routine
  7 *
  8 *   This program is free software; you can redistribute it and/or modify
  9 *   it under the terms of the GNU General Public License as published by
 10 *   the Free Software Foundation; either version 2 of the License, or
 11 *   (at your option) any later version.
 12 *
 13 *   This program is distributed in the hope that it will be useful,
 14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 *   GNU General Public License for more details.
 17 *
 18 *   You should have received a copy of the GNU General Public License
 19 *   along with this program; if not, write to the Free Software
 20 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 21 */
 22
 23#include "emu8000_local.h"
 24#include <linux/init.h>
 25#include <linux/module.h>
 26#include <sound/initval.h>
 27
 28MODULE_AUTHOR("Takashi Iwai, Steve Ratcliffe");
 29MODULE_DESCRIPTION("Emu8000 synth plug-in routine");
 30MODULE_LICENSE("GPL");
 31
 32/*----------------------------------------------------------------*/
 33
 34/*
 35 * create a new hardware dependent device for Emu8000
 36 */
 37static int snd_emu8000_probe(struct device *_dev)
 38{
 39	struct snd_seq_device *dev = to_seq_dev(_dev);
 40	struct snd_emu8000 *hw;
 41	struct snd_emux *emu;
 42
 43	hw = *(struct snd_emu8000**)SNDRV_SEQ_DEVICE_ARGPTR(dev);
 44	if (hw == NULL)
 45		return -EINVAL;
 46
 47	if (hw->emu)
 48		return -EBUSY; /* already exists..? */
 49
 50	if (snd_emux_new(&emu) < 0)
 51		return -ENOMEM;
 52
 53	hw->emu = emu;
 54	snd_emu8000_ops_setup(hw);
 55
 56	emu->hw = hw;
 57	emu->max_voices = EMU8000_DRAM_VOICES;
 58	emu->num_ports = hw->seq_ports;
 59
 60	if (hw->memhdr) {
 61		snd_printk(KERN_ERR "memhdr is already initialized!?\n");
 62		snd_util_memhdr_free(hw->memhdr);
 63	}
 64	hw->memhdr = snd_util_memhdr_new(hw->mem_size);
 65	if (hw->memhdr == NULL) {
 66		snd_emux_free(emu);
 67		hw->emu = NULL;
 68		return -ENOMEM;
 69	}
 70
 71	emu->memhdr = hw->memhdr;
 72	emu->midi_ports = hw->seq_ports < 2 ? hw->seq_ports : 2; /* number of virmidi ports */
 73	emu->midi_devidx = 1;
 74	emu->linear_panning = 1;
 75	emu->hwdep_idx = 2; /* FIXED */
 76
 77	if (snd_emux_register(emu, dev->card, hw->index, "Emu8000") < 0) {
 78		snd_emux_free(emu);
 79		snd_util_memhdr_free(hw->memhdr);
 80		hw->emu = NULL;
 81		hw->memhdr = NULL;
 82		return -ENOMEM;
 83	}
 84
 85	if (hw->mem_size > 0)
 86		snd_emu8000_pcm_new(dev->card, hw, 1);
 87
 88	dev->driver_data = hw;
 89
 90	return 0;
 91}
 92
 93
 94/*
 95 * free all resources
 96 */
 97static int snd_emu8000_remove(struct device *_dev)
 98{
 99	struct snd_seq_device *dev = to_seq_dev(_dev);
100	struct snd_emu8000 *hw;
101
102	if (dev->driver_data == NULL)
103		return 0; /* no synth was allocated actually */
104
105	hw = dev->driver_data;
106	if (hw->pcm)
107		snd_device_free(dev->card, hw->pcm);
108	snd_emux_free(hw->emu);
109	snd_util_memhdr_free(hw->memhdr);
110	hw->emu = NULL;
111	hw->memhdr = NULL;
112	return 0;
113}
114
115/*
116 *  INIT part
117 */
118
119static struct snd_seq_driver emu8000_driver = {
120	.driver = {
121		.name = KBUILD_MODNAME,
122		.probe = snd_emu8000_probe,
123		.remove = snd_emu8000_remove,
124	},
125	.id = SNDRV_SEQ_DEV_ID_EMU8000,
126	.argsize = sizeof(struct snd_emu8000 *),
127};
128
129module_snd_seq_driver(emu8000_driver);
v6.2
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4 *     and (c) 1999 Steve Ratcliffe <steve@parabola.demon.co.uk>
  5 *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
  6 *
  7 *  Emu8000 synth plug-in routine
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  8 */
  9
 10#include "emu8000_local.h"
 11#include <linux/init.h>
 12#include <linux/module.h>
 13#include <sound/initval.h>
 14
 15MODULE_AUTHOR("Takashi Iwai, Steve Ratcliffe");
 16MODULE_DESCRIPTION("Emu8000 synth plug-in routine");
 17MODULE_LICENSE("GPL");
 18
 19/*----------------------------------------------------------------*/
 20
 21/*
 22 * create a new hardware dependent device for Emu8000
 23 */
 24static int snd_emu8000_probe(struct device *_dev)
 25{
 26	struct snd_seq_device *dev = to_seq_dev(_dev);
 27	struct snd_emu8000 *hw;
 28	struct snd_emux *emu;
 29
 30	hw = *(struct snd_emu8000**)SNDRV_SEQ_DEVICE_ARGPTR(dev);
 31	if (hw == NULL)
 32		return -EINVAL;
 33
 34	if (hw->emu)
 35		return -EBUSY; /* already exists..? */
 36
 37	if (snd_emux_new(&emu) < 0)
 38		return -ENOMEM;
 39
 40	hw->emu = emu;
 41	snd_emu8000_ops_setup(hw);
 42
 43	emu->hw = hw;
 44	emu->max_voices = EMU8000_DRAM_VOICES;
 45	emu->num_ports = hw->seq_ports;
 46
 47	if (hw->memhdr) {
 48		snd_printk(KERN_ERR "memhdr is already initialized!?\n");
 49		snd_util_memhdr_free(hw->memhdr);
 50	}
 51	hw->memhdr = snd_util_memhdr_new(hw->mem_size);
 52	if (hw->memhdr == NULL) {
 53		snd_emux_free(emu);
 54		hw->emu = NULL;
 55		return -ENOMEM;
 56	}
 57
 58	emu->memhdr = hw->memhdr;
 59	emu->midi_ports = hw->seq_ports < 2 ? hw->seq_ports : 2; /* number of virmidi ports */
 60	emu->midi_devidx = 1;
 61	emu->linear_panning = 1;
 62	emu->hwdep_idx = 2; /* FIXED */
 63
 64	if (snd_emux_register(emu, dev->card, hw->index, "Emu8000") < 0) {
 65		snd_emux_free(emu);
 66		snd_util_memhdr_free(hw->memhdr);
 67		hw->emu = NULL;
 68		hw->memhdr = NULL;
 69		return -ENOMEM;
 70	}
 71
 72	if (hw->mem_size > 0)
 73		snd_emu8000_pcm_new(dev->card, hw, 1);
 74
 75	dev->driver_data = hw;
 76
 77	return 0;
 78}
 79
 80
 81/*
 82 * free all resources
 83 */
 84static int snd_emu8000_remove(struct device *_dev)
 85{
 86	struct snd_seq_device *dev = to_seq_dev(_dev);
 87	struct snd_emu8000 *hw;
 88
 89	if (dev->driver_data == NULL)
 90		return 0; /* no synth was allocated actually */
 91
 92	hw = dev->driver_data;
 93	if (hw->pcm)
 94		snd_device_free(dev->card, hw->pcm);
 95	snd_emux_free(hw->emu);
 96	snd_util_memhdr_free(hw->memhdr);
 97	hw->emu = NULL;
 98	hw->memhdr = NULL;
 99	return 0;
100}
101
102/*
103 *  INIT part
104 */
105
106static struct snd_seq_driver emu8000_driver = {
107	.driver = {
108		.name = KBUILD_MODNAME,
109		.probe = snd_emu8000_probe,
110		.remove = snd_emu8000_remove,
111	},
112	.id = SNDRV_SEQ_DEV_ID_EMU8000,
113	.argsize = sizeof(struct snd_emu8000 *),
114};
115
116module_snd_seq_driver(emu8000_driver);