Blame view
sound/pci/emu10k1/emu10k1.c
7.71 KB
1a59d1b8e treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4c Linux-2.6.12-rc2 |
2 3 |
/* * The driver for the EMU10K1 (SB Live!) based soundcards |
c1017a4cd [ALSA] Changed Ja... |
4 |
* Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
1da177e4c Linux-2.6.12-rc2 |
5 6 7 |
* * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> * Added support for Audigy 2 Value. |
1da177e4c Linux-2.6.12-rc2 |
8 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
9 10 11 |
#include <linux/init.h> #include <linux/pci.h> #include <linux/time.h> |
65a772172 sound: fix driver... |
12 |
#include <linux/module.h> |
1da177e4c Linux-2.6.12-rc2 |
13 14 15 |
#include <sound/core.h> #include <sound/emu10k1.h> #include <sound/initval.h> |
c1017a4cd [ALSA] Changed Ja... |
16 |
MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); |
1da177e4c Linux-2.6.12-rc2 |
17 18 19 20 |
MODULE_DESCRIPTION("EMU10K1"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS}," "{Creative Labs,SB Audigy}}"); |
111b0cdb9 ALSA: seq: Allow ... |
21 |
#if IS_ENABLED(CONFIG_SND_SEQUENCER) |
1da177e4c Linux-2.6.12-rc2 |
22 23 24 25 26 27 |
#define ENABLE_SYNTH #include <sound/emu10k1_synth.h> #endif static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
a67ff6a54 ALSA: module_para... |
28 |
static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ |
6581f4e74 [ALSA] Remove zer... |
29 30 |
static int extin[SNDRV_CARDS]; static int extout[SNDRV_CARDS]; |
1da177e4c Linux-2.6.12-rc2 |
31 32 33 |
static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4}; static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64}; static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128}; |
a67ff6a54 ALSA: module_para... |
34 |
static bool enable_ir[SNDRV_CARDS]; |
6581f4e74 [ALSA] Remove zer... |
35 |
static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */ |
56385a12d ALSA: emu10k1 - d... |
36 |
static uint delay_pcm_irq[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; |
1da177e4c Linux-2.6.12-rc2 |
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard."); module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for the EMU10K1 soundcard."); module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable the EMU10K1 soundcard."); module_param_array(extin, int, NULL, 0444); MODULE_PARM_DESC(extin, "Available external inputs for FX8010. Zero=default."); module_param_array(extout, int, NULL, 0444); MODULE_PARM_DESC(extout, "Available external outputs for FX8010. Zero=default."); module_param_array(seq_ports, int, NULL, 0444); MODULE_PARM_DESC(seq_ports, "Allocated sequencer ports for internal synthesizer."); module_param_array(max_synth_voices, int, NULL, 0444); MODULE_PARM_DESC(max_synth_voices, "Maximum number of voices for WaveTable."); module_param_array(max_buffer_size, int, NULL, 0444); MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB."); module_param_array(enable_ir, bool, NULL, 0444); MODULE_PARM_DESC(enable_ir, "Enable IR."); |
e66bc8b2a [ALSA] emu10k1: A... |
56 57 |
module_param_array(subsystem, uint, NULL, 0444); MODULE_PARM_DESC(subsystem, "Force card subsystem model."); |
56385a12d ALSA: emu10k1 - d... |
58 59 |
module_param_array(delay_pcm_irq, uint, NULL, 0444); MODULE_PARM_DESC(delay_pcm_irq, "Delay PCM interrupt by specified number of samples (default 0)."); |
1da177e4c Linux-2.6.12-rc2 |
60 61 62 |
/* * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 */ |
9baa3c34a PCI: Remove DEFIN... |
63 |
static const struct pci_device_id snd_emu10k1_ids[] = { |
0d7392e54 sound: Use PCI_VD... |
64 65 66 |
{ PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */ { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */ { PCI_VDEVICE(CREATIVE, 0x0008), 1 }, /* Audigy 2 Value SB0400 */ |
1da177e4c Linux-2.6.12-rc2 |
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
{ 0, } }; /* * Audigy 2 Value notes: * A_IOCFG Input (GPIO) * 0x400 = Front analog jack plugged in. (Green socket) * 0x1000 = Read analog jack plugged in. (Black socket) * 0x2000 = Center/LFE analog jack plugged in. (Orange socket) * A_IOCFG Output (GPIO) * 0x60 = Sound out of front Left. * Win sets it to 0xXX61 */ MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids); |
e23e7a143 ALSA: pci: remove... |
82 83 |
static int snd_card_emu10k1_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) |
1da177e4c Linux-2.6.12-rc2 |
84 85 |
{ static int dev; |
eb4698f34 [ALSA] Remove xxx... |
86 87 |
struct snd_card *card; struct snd_emu10k1 *emu; |
1da177e4c Linux-2.6.12-rc2 |
88 |
#ifdef ENABLE_SYNTH |
eb4698f34 [ALSA] Remove xxx... |
89 |
struct snd_seq_device *wave = NULL; |
1da177e4c Linux-2.6.12-rc2 |
90 91 92 93 94 95 96 97 98 |
#endif int err; if (dev >= SNDRV_CARDS) return -ENODEV; if (!enable[dev]) { dev++; return -ENOENT; } |
60c5772b5 ALSA: pci: Conver... |
99 100 |
err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 0, &card); |
e58de7baf ALSA: Convert to ... |
101 102 |
if (err < 0) return err; |
1da177e4c Linux-2.6.12-rc2 |
103 104 105 106 107 108 |
if (max_buffer_size[dev] < 32) max_buffer_size[dev] = 32; else if (max_buffer_size[dev] > 1024) max_buffer_size[dev] = 1024; if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev], (long)max_buffer_size[dev] * 1024 * 1024, |
e66bc8b2a [ALSA] emu10k1: A... |
109 |
enable_ir[dev], subsystem[dev], |
09668b441 [ALSA] emu10k1 - ... |
110 111 112 |
&emu)) < 0) goto error; card->private_data = emu; |
56385a12d ALSA: emu10k1 - d... |
113 |
emu->delay_pcm_irq = delay_pcm_irq[dev] & 0x1f; |
bb814c396 ALSA: emu10k1: Re... |
114 |
if ((err = snd_emu10k1_pcm(emu, 0)) < 0) |
09668b441 [ALSA] emu10k1 - ... |
115 |
goto error; |
bb814c396 ALSA: emu10k1: Re... |
116 |
if ((err = snd_emu10k1_pcm_mic(emu, 1)) < 0) |
09668b441 [ALSA] emu10k1 - ... |
117 |
goto error; |
bb814c396 ALSA: emu10k1: Re... |
118 |
if ((err = snd_emu10k1_pcm_efx(emu, 2)) < 0) |
09668b441 [ALSA] emu10k1 - ... |
119 |
goto error; |
1da177e4c Linux-2.6.12-rc2 |
120 |
/* This stores the periods table. */ |
e0474e539 [ALSA] snd-emu10k... |
121 |
if (emu->card_capabilities->ca0151_chip) { /* P16V */ |
6974f8ad4 ALSA: pci: Avoid ... |
122 123 124 |
err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 1024, &emu->p16v_buffer); if (err < 0) |
09668b441 [ALSA] emu10k1 - ... |
125 |
goto error; |
1da177e4c Linux-2.6.12-rc2 |
126 |
} |
09668b441 [ALSA] emu10k1 - ... |
127 128 |
if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) goto error; |
1da177e4c Linux-2.6.12-rc2 |
129 |
|
09668b441 [ALSA] emu10k1 - ... |
130 131 |
if ((err = snd_emu10k1_timer(emu, 0)) < 0) goto error; |
1da177e4c Linux-2.6.12-rc2 |
132 |
|
bb814c396 ALSA: emu10k1: Re... |
133 |
if ((err = snd_emu10k1_pcm_multi(emu, 3)) < 0) |
09668b441 [ALSA] emu10k1 - ... |
134 135 |
goto error; if (emu->card_capabilities->ca0151_chip) { /* P16V */ |
bb814c396 ALSA: emu10k1: Re... |
136 |
if ((err = snd_p16v_pcm(emu, 4)) < 0) |
09668b441 [ALSA] emu10k1 - ... |
137 |
goto error; |
1da177e4c Linux-2.6.12-rc2 |
138 139 |
} if (emu->audigy) { |
09668b441 [ALSA] emu10k1 - ... |
140 141 |
if ((err = snd_emu10k1_audigy_midi(emu)) < 0) goto error; |
1da177e4c Linux-2.6.12-rc2 |
142 |
} else { |
09668b441 [ALSA] emu10k1 - ... |
143 144 |
if ((err = snd_emu10k1_midi(emu)) < 0) goto error; |
1da177e4c Linux-2.6.12-rc2 |
145 |
} |
bb814c396 ALSA: emu10k1: Re... |
146 |
if ((err = snd_emu10k1_fx8010_new(emu, 0)) < 0) |
09668b441 [ALSA] emu10k1 - ... |
147 |
goto error; |
1da177e4c Linux-2.6.12-rc2 |
148 149 |
#ifdef ENABLE_SYNTH if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, |
eb4698f34 [ALSA] Remove xxx... |
150 |
sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 || |
1da177e4c Linux-2.6.12-rc2 |
151 |
wave == NULL) { |
6f002b021 ALSA: emu10k1: Us... |
152 153 154 |
dev_warn(emu->card->dev, "can't initialize Emu10k1 wavetable synth "); |
1da177e4c Linux-2.6.12-rc2 |
155 |
} else { |
eb4698f34 [ALSA] Remove xxx... |
156 |
struct snd_emu10k1_synth_arg *arg; |
1da177e4c Linux-2.6.12-rc2 |
157 158 159 160 161 162 163 164 165 |
arg = SNDRV_SEQ_DEVICE_ARGPTR(wave); strcpy(wave->name, "Emu-10k1 Synth"); arg->hwptr = emu; arg->index = 1; arg->seq_ports = seq_ports[dev]; arg->max_voices = max_synth_voices[dev]; } #endif |
d02260824 ALSA: emu10k1: Fi... |
166 167 168 169 |
strlcpy(card->driver, emu->card_capabilities->driver, sizeof(card->driver)); strlcpy(card->shortname, emu->card_capabilities->name, sizeof(card->shortname)); |
1da177e4c Linux-2.6.12-rc2 |
170 171 172 |
snprintf(card->longname, sizeof(card->longname), "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i", card->shortname, emu->revision, emu->serial, emu->port, emu->irq); |
09668b441 [ALSA] emu10k1 - ... |
173 174 |
if ((err = snd_card_register(card)) < 0) goto error; |
aeaa6203b ALSA: emu10k1: Us... |
175 176 |
if (emu->card_capabilities->emu_model) schedule_delayed_work(&emu->emu1010.firmware_work, 0); |
1da177e4c Linux-2.6.12-rc2 |
177 178 179 |
pci_set_drvdata(pci, card); dev++; return 0; |
09668b441 [ALSA] emu10k1 - ... |
180 181 182 183 |
error: snd_card_free(card); return err; |
1da177e4c Linux-2.6.12-rc2 |
184 |
} |
e23e7a143 ALSA: pci: remove... |
185 |
static void snd_card_emu10k1_remove(struct pci_dev *pci) |
1da177e4c Linux-2.6.12-rc2 |
186 187 |
{ snd_card_free(pci_get_drvdata(pci)); |
1da177e4c Linux-2.6.12-rc2 |
188 |
} |
09668b441 [ALSA] emu10k1 - ... |
189 |
|
c7561cd80 ALSA: PCI: Replac... |
190 |
#ifdef CONFIG_PM_SLEEP |
68cb2b559 ALSA: Convert to ... |
191 |
static int snd_emu10k1_suspend(struct device *dev) |
09668b441 [ALSA] emu10k1 - ... |
192 |
{ |
68cb2b559 ALSA: Convert to ... |
193 |
struct snd_card *card = dev_get_drvdata(dev); |
09668b441 [ALSA] emu10k1 - ... |
194 195 196 |
struct snd_emu10k1 *emu = card->private_data; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
4f86f120d ALSA: emu10k1: do... |
197 |
emu->suspend = 1; |
aeaa6203b ALSA: emu10k1: Us... |
198 |
cancel_delayed_work_sync(&emu->emu1010.firmware_work); |
09668b441 [ALSA] emu10k1 - ... |
199 200 201 202 203 204 205 206 |
snd_ac97_suspend(emu->ac97); snd_emu10k1_efx_suspend(emu); snd_emu10k1_suspend_regs(emu); if (emu->card_capabilities->ca0151_chip) snd_p16v_suspend(emu); snd_emu10k1_done(emu); |
09668b441 [ALSA] emu10k1 - ... |
207 208 |
return 0; } |
68cb2b559 ALSA: Convert to ... |
209 |
static int snd_emu10k1_resume(struct device *dev) |
09668b441 [ALSA] emu10k1 - ... |
210 |
{ |
68cb2b559 ALSA: Convert to ... |
211 |
struct snd_card *card = dev_get_drvdata(dev); |
09668b441 [ALSA] emu10k1 - ... |
212 |
struct snd_emu10k1 *emu = card->private_data; |
09668b441 [ALSA] emu10k1 - ... |
213 214 215 216 217 218 219 |
snd_emu10k1_resume_init(emu); snd_emu10k1_efx_resume(emu); snd_ac97_resume(emu->ac97); snd_emu10k1_resume_regs(emu); if (emu->card_capabilities->ca0151_chip) snd_p16v_resume(emu); |
4f86f120d ALSA: emu10k1: do... |
220 |
emu->suspend = 0; |
09668b441 [ALSA] emu10k1 - ... |
221 |
snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
aeaa6203b ALSA: emu10k1: Us... |
222 223 224 |
if (emu->card_capabilities->emu_model) schedule_delayed_work(&emu->emu1010.firmware_work, 0); |
09668b441 [ALSA] emu10k1 - ... |
225 226 |
return 0; } |
68cb2b559 ALSA: Convert to ... |
227 228 229 230 231 |
static SIMPLE_DEV_PM_OPS(snd_emu10k1_pm, snd_emu10k1_suspend, snd_emu10k1_resume); #define SND_EMU10K1_PM_OPS &snd_emu10k1_pm #else #define SND_EMU10K1_PM_OPS NULL |
c7561cd80 ALSA: PCI: Replac... |
232 |
#endif /* CONFIG_PM_SLEEP */ |
09668b441 [ALSA] emu10k1 - ... |
233 |
|
e9f66d9b9 ALSA: pci: clean ... |
234 |
static struct pci_driver emu10k1_driver = { |
3733e424c ALSA: Use KBUILD_... |
235 |
.name = KBUILD_MODNAME, |
1da177e4c Linux-2.6.12-rc2 |
236 237 |
.id_table = snd_emu10k1_ids, .probe = snd_card_emu10k1_probe, |
e23e7a143 ALSA: pci: remove... |
238 |
.remove = snd_card_emu10k1_remove, |
68cb2b559 ALSA: Convert to ... |
239 240 241 |
.driver = { .pm = SND_EMU10K1_PM_OPS, }, |
1da177e4c Linux-2.6.12-rc2 |
242 |
}; |
e9f66d9b9 ALSA: pci: clean ... |
243 |
module_pci_driver(emu10k1_driver); |