2019-05-27 13:55:05 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Driver for Trident 4DWave DX/NX & SiS SI7018 Audio PCI soundcard
|
|
|
|
*
|
|
|
|
* Driver was originated by Trident <audio@tridentmicro.com>
|
|
|
|
* Fri Feb 19 15:55:28 MST 1999
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/time.h>
|
2011-07-16 00:13:37 +07:00
|
|
|
#include <linux/module.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <sound/core.h>
|
2012-07-02 21:37:05 +07:00
|
|
|
#include "trident.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <sound/initval.h>
|
|
|
|
|
2007-10-15 14:50:19 +07:00
|
|
|
MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>");
|
2005-04-17 05:20:36 +07:00
|
|
|
MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
|
|
|
|
"{Trident,4DWave NX},"
|
|
|
|
"{SiS,SI7018 PCI Audio},"
|
|
|
|
"{Best Union,Miss Melody 4DWave PCI},"
|
|
|
|
"{HIS,4DWave PCI},"
|
|
|
|
"{Warpspeed,ONSpeed 4DWave PCI},"
|
|
|
|
"{Aztech Systems,PCI 64-Q3D},"
|
|
|
|
"{Addonics,SV 750},"
|
|
|
|
"{CHIC,True Sound 4Dwave},"
|
|
|
|
"{Shark,Predator4D-PCI},"
|
|
|
|
"{Jaton,SonicWave 4D},"
|
|
|
|
"{Hoontech,SoundTrack Digital 4DWave NX}}");
|
|
|
|
|
|
|
|
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
|
|
|
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
2011-12-15 10:19:36 +07:00
|
|
|
static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
|
2005-04-17 05:20:36 +07:00
|
|
|
static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
|
|
|
|
static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192};
|
|
|
|
|
|
|
|
module_param_array(index, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard.");
|
|
|
|
module_param_array(id, charp, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard.");
|
|
|
|
module_param_array(enable, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard.");
|
|
|
|
module_param_array(pcm_channels, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM.");
|
|
|
|
module_param_array(wavetable_size, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
|
|
|
|
|
2014-08-08 20:56:03 +07:00
|
|
|
static const struct pci_device_id snd_trident_ids[] = {
|
2006-01-13 19:14:53 +07:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX),
|
|
|
|
PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0},
|
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX),
|
|
|
|
0, 0, 0},
|
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7018), 0, 0, 0},
|
2005-04-17 05:20:36 +07:00
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, snd_trident_ids);
|
|
|
|
|
2012-12-07 00:35:10 +07:00
|
|
|
static int snd_trident_probe(struct pci_dev *pci,
|
|
|
|
const struct pci_device_id *pci_id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
static int dev;
|
2005-11-17 20:53:15 +07:00
|
|
|
struct snd_card *card;
|
|
|
|
struct snd_trident *trident;
|
2005-04-17 05:20:36 +07:00
|
|
|
const char *str;
|
|
|
|
int err, pcm_dev = 0;
|
|
|
|
|
|
|
|
if (dev >= SNDRV_CARDS)
|
|
|
|
return -ENODEV;
|
|
|
|
if (!enable[dev]) {
|
|
|
|
dev++;
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2014-01-29 20:20:19 +07:00
|
|
|
err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
|
|
|
|
0, &card);
|
2008-12-28 22:44:30 +07:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if ((err = snd_trident_create(card, pci,
|
|
|
|
pcm_channels[dev],
|
|
|
|
((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2,
|
|
|
|
wavetable_size[dev],
|
|
|
|
&trident)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
2005-11-17 22:09:25 +07:00
|
|
|
card->private_data = trident;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
switch (trident->device) {
|
|
|
|
case TRIDENT_DEVICE_ID_DX:
|
|
|
|
str = "TRID4DWAVEDX";
|
|
|
|
break;
|
|
|
|
case TRIDENT_DEVICE_ID_NX:
|
|
|
|
str = "TRID4DWAVENX";
|
|
|
|
break;
|
|
|
|
case TRIDENT_DEVICE_ID_SI7018:
|
|
|
|
str = "SI7018";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "Unknown";
|
|
|
|
}
|
|
|
|
strcpy(card->driver, str);
|
|
|
|
if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
|
|
|
|
strcpy(card->shortname, "SiS ");
|
|
|
|
} else {
|
|
|
|
strcpy(card->shortname, "Trident ");
|
|
|
|
}
|
2018-07-26 19:58:03 +07:00
|
|
|
strcat(card->shortname, str);
|
2005-04-17 05:20:36 +07:00
|
|
|
sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
|
|
|
|
card->shortname, trident->port, trident->irq);
|
|
|
|
|
2015-01-02 18:24:54 +07:00
|
|
|
if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) {
|
2005-04-17 05:20:36 +07:00
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
switch (trident->device) {
|
|
|
|
case TRIDENT_DEVICE_ID_DX:
|
|
|
|
case TRIDENT_DEVICE_ID_NX:
|
2015-01-02 18:24:54 +07:00
|
|
|
if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) {
|
2005-04-17 05:20:36 +07:00
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
|
2015-01-02 18:24:54 +07:00
|
|
|
if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) {
|
2005-04-17 05:20:36 +07:00
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
2005-06-08 19:49:31 +07:00
|
|
|
if (trident->device != TRIDENT_DEVICE_ID_SI7018 &&
|
|
|
|
(err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
|
2006-05-23 18:24:30 +07:00
|
|
|
trident->midi_port,
|
ALSA: mpu401: clean up interrupt specification
The semantics of snd_mpu401_uart_new()'s interrupt parameters are
somewhat counterintuitive: To prevent the function from allocating its
own interrupt, either the irq number must be invalid, or the irq_flags
parameter must be zero. At the same time, the irq parameter being
invalid specifies that the mpu401 code has to work without an interrupt
allocated by the caller. This implies that, if there is an interrupt
and it is allocated by the caller, the irq parameter must be set to
a valid-looking number which then isn't actually used.
With the removal of IRQF_DISABLED, zero becomes a valid irq_flags value,
which forces us to handle the parameters differently.
This patch introduces a new flag MPU401_INFO_IRQ_HOOK for when the
device interrupt is handled by the caller, and makes the allocation of
the interrupt to depend only on the irq parameter. As suggested by
Takashi, the irq_flags parameter was dropped because, when used, it had
the constant value IRQF_DISABLED.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-09-13 16:24:41 +07:00
|
|
|
MPU401_INFO_INTEGRATED |
|
|
|
|
MPU401_INFO_IRQ_HOOK,
|
|
|
|
-1, &trident->rmidi)) < 0) {
|
2005-04-17 05:20:36 +07:00
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_trident_create_gameport(trident);
|
|
|
|
|
|
|
|
if ((err = snd_card_register(card)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
pci_set_drvdata(pci, card);
|
|
|
|
dev++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 00:35:10 +07:00
|
|
|
static void snd_trident_remove(struct pci_dev *pci)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
snd_card_free(pci_get_drvdata(pci));
|
|
|
|
}
|
|
|
|
|
2012-04-24 17:25:00 +07:00
|
|
|
static struct pci_driver trident_driver = {
|
2011-06-10 21:20:20 +07:00
|
|
|
.name = KBUILD_MODNAME,
|
2005-04-17 05:20:36 +07:00
|
|
|
.id_table = snd_trident_ids,
|
|
|
|
.probe = snd_trident_probe,
|
2012-12-07 00:35:10 +07:00
|
|
|
.remove = snd_trident_remove,
|
2012-08-14 23:12:04 +07:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2012-07-02 20:20:37 +07:00
|
|
|
.driver = {
|
|
|
|
.pm = &snd_trident_pm,
|
|
|
|
},
|
2005-11-17 22:09:25 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2012-04-24 17:25:00 +07:00
|
|
|
module_pci_driver(trident_driver);
|