Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/sound/pci/emu10k1/emu10k1_synth.c
29266 views
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/*
3
* Copyright (C) 2000 Takashi Iwai <[email protected]>
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
/*
17
* create a new hardware dependent device for Emu10k1
18
*/
19
static int snd_emu10k1_synth_probe(struct device *_dev)
20
{
21
struct snd_seq_device *dev = to_seq_dev(_dev);
22
struct snd_emux *emux;
23
struct snd_emu10k1 *hw;
24
struct snd_emu10k1_synth_arg *arg;
25
26
arg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
27
if (arg == NULL)
28
return -EINVAL;
29
30
if (arg->seq_ports <= 0)
31
return 0; /* nothing */
32
if (arg->max_voices < 1)
33
arg->max_voices = 1;
34
else if (arg->max_voices > 64)
35
arg->max_voices = 64;
36
37
if (snd_emux_new(&emux) < 0)
38
return -ENOMEM;
39
40
snd_emu10k1_ops_setup(emux);
41
hw = arg->hwptr;
42
emux->hw = hw;
43
emux->max_voices = arg->max_voices;
44
emux->num_ports = arg->seq_ports;
45
emux->memhdr = hw->memhdr;
46
/* maximum two ports */
47
emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;
48
/* audigy has two external midis */
49
emux->midi_devidx = hw->audigy ? 2 : 1;
50
emux->linear_panning = 0;
51
emux->hwdep_idx = 2; /* FIXED */
52
53
if (snd_emux_register(emux, dev->card, arg->index, "Emu10k1") < 0) {
54
snd_emux_free(emux);
55
return -ENOMEM;
56
}
57
58
guard(spinlock_irq)(&hw->voice_lock);
59
hw->synth = emux;
60
hw->get_synth_voice = snd_emu10k1_synth_get_voice;
61
62
dev->driver_data = emux;
63
64
return 0;
65
}
66
67
static int snd_emu10k1_synth_remove(struct device *_dev)
68
{
69
struct snd_seq_device *dev = to_seq_dev(_dev);
70
struct snd_emux *emux;
71
struct snd_emu10k1 *hw;
72
73
if (dev->driver_data == NULL)
74
return 0; /* not registered actually */
75
76
emux = dev->driver_data;
77
78
hw = emux->hw;
79
scoped_guard(spinlock_irq, &hw->voice_lock) {
80
hw->synth = NULL;
81
hw->get_synth_voice = NULL;
82
}
83
84
snd_emux_free(emux);
85
return 0;
86
}
87
88
/*
89
* INIT part
90
*/
91
92
static struct snd_seq_driver emu10k1_synth_driver = {
93
.driver = {
94
.name = KBUILD_MODNAME,
95
.probe = snd_emu10k1_synth_probe,
96
.remove = snd_emu10k1_synth_remove,
97
},
98
.id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
99
.argsize = sizeof(struct snd_emu10k1_synth_arg),
100
};
101
102
module_snd_seq_driver(emu10k1_synth_driver);
103
104