2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Driver for Yamaha OPL3-SA[2,3] soundcards
|
2007-10-15 09:50:19 +02:00
|
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
2005-11-17 17:11:53 +01:00
|
|
|
#include <linux/err.h>
|
2007-02-22 12:50:54 +01:00
|
|
|
#include <linux/isa.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/pnp.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <sound/core.h>
|
2008-07-31 21:02:42 +02:00
|
|
|
#include <sound/wss.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <sound/mpu401.h>
|
|
|
|
#include <sound/opl3.h>
|
|
|
|
#include <sound/initval.h>
|
2006-08-22 13:16:39 +02:00
|
|
|
#include <sound/tlv.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
2007-10-15 09:50:19 +02:00
|
|
|
MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
|
2005-04-17 00:20:36 +02:00
|
|
|
MODULE_DESCRIPTION("Yamaha OPL3SA2+");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF719E-S},"
|
|
|
|
"{Genius,Sound Maker 3DX},"
|
|
|
|
"{Yamaha,OPL3SA3},"
|
|
|
|
"{Intel,AL440LX sound},"
|
|
|
|
"{NeoMagic,MagicWave 3DX}}");
|
|
|
|
|
|
|
|
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
|
|
|
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
|
|
|
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
|
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
|
|
|
|
#endif
|
|
|
|
static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0xf86,0x370,0x100 */
|
|
|
|
static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
|
|
|
|
static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* 0x530,0xe80,0xf40,0x604 */
|
|
|
|
static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x388 */
|
|
|
|
static long midi_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* 0x330,0x300 */
|
|
|
|
static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 0,1,3,5,9,11,12,15 */
|
|
|
|
static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */
|
|
|
|
static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */
|
2006-05-17 17:14:51 +02:00
|
|
|
static int opl3sa3_ymode[SNDRV_CARDS]; /* 0,1,2,3 */ /*SL Added*/
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
module_param_array(index, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(index, "Index value for OPL3-SA soundcard.");
|
|
|
|
module_param_array(id, charp, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(id, "ID string for OPL3-SA soundcard.");
|
|
|
|
module_param_array(enable, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(enable, "Enable OPL3-SA soundcard.");
|
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
module_param_array(isapnp, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
|
|
|
|
#endif
|
|
|
|
module_param_array(port, long, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(port, "Port # for OPL3-SA driver.");
|
|
|
|
module_param_array(sb_port, long, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(sb_port, "SB port # for OPL3-SA driver.");
|
|
|
|
module_param_array(wss_port, long, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(wss_port, "WSS port # for OPL3-SA driver.");
|
|
|
|
module_param_array(fm_port, long, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(fm_port, "FM port # for OPL3-SA driver.");
|
|
|
|
module_param_array(midi_port, long, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(midi_port, "MIDI port # for OPL3-SA driver.");
|
|
|
|
module_param_array(irq, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(irq, "IRQ # for OPL3-SA driver.");
|
|
|
|
module_param_array(dma1, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(dma1, "DMA1 # for OPL3-SA driver.");
|
|
|
|
module_param_array(dma2, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
|
|
|
|
module_param_array(opl3sa3_ymode, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
|
|
|
|
|
2006-01-04 15:06:44 +01:00
|
|
|
#ifdef CONFIG_PNP
|
2007-05-15 11:42:56 +02:00
|
|
|
static int isa_registered;
|
2005-12-07 09:13:42 +01:00
|
|
|
static int pnp_registered;
|
|
|
|
static int pnpc_registered;
|
2006-01-04 15:06:44 +01:00
|
|
|
#endif
|
2005-12-07 09:13:42 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* control ports */
|
|
|
|
#define OPL3SA2_PM_CTRL 0x01
|
|
|
|
#define OPL3SA2_SYS_CTRL 0x02
|
|
|
|
#define OPL3SA2_IRQ_CONFIG 0x03
|
|
|
|
#define OPL3SA2_IRQ_STATUS 0x04
|
|
|
|
#define OPL3SA2_DMA_CONFIG 0x06
|
|
|
|
#define OPL3SA2_MASTER_LEFT 0x07
|
|
|
|
#define OPL3SA2_MASTER_RIGHT 0x08
|
|
|
|
#define OPL3SA2_MIC 0x09
|
|
|
|
#define OPL3SA2_MISC 0x0A
|
|
|
|
|
|
|
|
/* opl3sa3 only */
|
|
|
|
#define OPL3SA3_DGTL_DOWN 0x12
|
|
|
|
#define OPL3SA3_ANLG_DOWN 0x13
|
|
|
|
#define OPL3SA3_WIDE 0x14
|
|
|
|
#define OPL3SA3_BASS 0x15
|
|
|
|
#define OPL3SA3_TREBLE 0x16
|
|
|
|
|
|
|
|
/* power management bits */
|
|
|
|
#define OPL3SA2_PM_ADOWN 0x20
|
|
|
|
#define OPL3SA2_PM_PSV 0x04
|
|
|
|
#define OPL3SA2_PM_PDN 0x02
|
|
|
|
#define OPL3SA2_PM_PDX 0x01
|
|
|
|
|
|
|
|
#define OPL3SA2_PM_D0 0x00
|
|
|
|
#define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX)
|
|
|
|
|
|
|
|
struct snd_opl3sa2 {
|
|
|
|
int version; /* 2 or 3 */
|
|
|
|
unsigned long port; /* control port */
|
|
|
|
struct resource *res_port; /* control port resource */
|
|
|
|
int irq;
|
|
|
|
int single_dma;
|
|
|
|
spinlock_t reg_lock;
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_hwdep *synth;
|
|
|
|
struct snd_rawmidi *rmidi;
|
2008-07-31 21:03:41 +02:00
|
|
|
struct snd_wss *wss;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned char ctlregs[0x20];
|
|
|
|
int ymode; /* SL added */
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_kcontrol *master_switch;
|
|
|
|
struct snd_kcontrol *master_volume;
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
[ALSA] Add snd_card_set_generic_dev() call to ISA drivers
ISA,CMI8330 driver,ES18xx driver,OPL3SA2 driver,Sound Galaxy driver
Sound Scape driver,AD1848 driver,CS4231 driver,CS4236+ driver
ES1688 driver,GUS Classic driver,GUS Extreme driver,GUS MAX driver
AMD InterWave driver,Opti9xx drivers,SB16/AWE driver,SB8 driver
Wavefront drivers
- Added snd_card_set_generic_dev() call.
- Added SND_GENERIC_DRIVER to Kconfig.
- Clean up the error path in probe if necessary.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-05 17:19:20 +02:00
|
|
|
#define PFX "opl3sa2: "
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
|
2005-08-12 17:24:24 +02:00
|
|
|
static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = {
|
2005-08-12 17:35:09 +02:00
|
|
|
{ .id = "YMH0021" },
|
2005-08-12 17:24:24 +02:00
|
|
|
{ .id = "NMX2210" }, /* Gateway Solo 2500 */
|
|
|
|
{ .id = "" } /* end */
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pnp, snd_opl3sa2_pnpbiosids);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static struct pnp_card_device_id snd_opl3sa2_pnpids[] = {
|
|
|
|
/* Yamaha YMF719E-S (Genius Sound Maker 3DX) */
|
|
|
|
{ .id = "YMH0020", .devs = { { "YMH0021" } } },
|
|
|
|
/* Yamaha OPL3-SA3 (integrated on Intel's Pentium II AL440LX motherboard) */
|
|
|
|
{ .id = "YMH0030", .devs = { { "YMH0021" } } },
|
|
|
|
/* Yamaha OPL3-SA2 */
|
|
|
|
{ .id = "YMH0800", .devs = { { "YMH0021" } } },
|
|
|
|
/* Yamaha OPL3-SA2 */
|
|
|
|
{ .id = "YMH0801", .devs = { { "YMH0021" } } },
|
|
|
|
/* NeoMagic MagicWave 3DX */
|
|
|
|
{ .id = "NMX2200", .devs = { { "YMH2210" } } },
|
2007-07-04 10:34:22 +02:00
|
|
|
/* NeoMagic MagicWave 3D */
|
|
|
|
{ .id = "NMX2200", .devs = { { "NMX2210" } } },
|
2005-04-17 00:20:36 +02:00
|
|
|
/* --- */
|
|
|
|
{ .id = "" } /* end */
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpids);
|
|
|
|
|
|
|
|
#endif /* CONFIG_PNP */
|
|
|
|
|
|
|
|
|
|
|
|
/* read control port (w/o spinlock) */
|
2005-11-17 14:41:45 +01:00
|
|
|
static unsigned char __snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned char result;
|
|
|
|
#if 0
|
|
|
|
outb(0x1d, port); /* password */
|
2009-02-05 15:47:51 +01:00
|
|
|
printk(KERN_DEBUG "read [0x%lx] = 0x%x\n", port, inb(port));
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
outb(reg, chip->port); /* register */
|
|
|
|
result = inb(chip->port + 1);
|
|
|
|
#if 0
|
2009-02-05 15:47:51 +01:00
|
|
|
printk(KERN_DEBUG "read [0x%lx] = 0x%x [0x%x]\n",
|
|
|
|
port, result, inb(port));
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read control port (with spinlock) */
|
2005-11-17 14:41:45 +01:00
|
|
|
static unsigned char snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned char result;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->reg_lock, flags);
|
|
|
|
result = __snd_opl3sa2_read(chip, reg);
|
|
|
|
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write control port (w/o spinlock) */
|
2005-11-17 14:41:45 +01:00
|
|
|
static void __snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
outb(0x1d, port); /* password */
|
|
|
|
#endif
|
|
|
|
outb(reg, chip->port); /* register */
|
|
|
|
outb(value, chip->port + 1);
|
|
|
|
chip->ctlregs[reg] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write control port (with spinlock) */
|
2005-11-17 14:41:45 +01:00
|
|
|
static void snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&chip->reg_lock, flags);
|
|
|
|
__snd_opl3sa2_write(chip, reg, value);
|
|
|
|
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
|
|
|
}
|
|
|
|
|
2008-08-17 20:01:14 +02:00
|
|
|
static int __devinit snd_opl3sa2_detect(struct snd_card *card)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-08-17 20:01:14 +02:00
|
|
|
struct snd_opl3sa2 *chip = card->private_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long port;
|
|
|
|
unsigned char tmp, tmp1;
|
|
|
|
char str[2];
|
|
|
|
|
|
|
|
port = chip->port;
|
|
|
|
if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL) {
|
[ALSA] Add snd_card_set_generic_dev() call to ISA drivers
ISA,CMI8330 driver,ES18xx driver,OPL3SA2 driver,Sound Galaxy driver
Sound Scape driver,AD1848 driver,CS4231 driver,CS4236+ driver
ES1688 driver,GUS Classic driver,GUS Extreme driver,GUS MAX driver
AMD InterWave driver,Opti9xx drivers,SB16/AWE driver,SB8 driver
Wavefront drivers
- Added snd_card_set_generic_dev() call.
- Added SND_GENERIC_DRIVER to Kconfig.
- Clean up the error path in probe if necessary.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-05 17:19:20 +02:00
|
|
|
snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
2009-02-05 15:47:51 +01:00
|
|
|
/*
|
|
|
|
snd_printk(KERN_DEBUG "REG 0A = 0x%x\n",
|
|
|
|
snd_opl3sa2_read(chip, 0x0a));
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
chip->version = 0;
|
|
|
|
tmp = snd_opl3sa2_read(chip, OPL3SA2_MISC);
|
|
|
|
if (tmp == 0xff) {
|
|
|
|
snd_printd("OPL3-SA [0x%lx] detect = 0x%x\n", port, tmp);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
switch (tmp & 0x07) {
|
|
|
|
case 0x01:
|
|
|
|
chip->version = 2; /* YMF711 */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
chip->version = 3;
|
|
|
|
/* 0x02 - standard */
|
|
|
|
/* 0x03 - YM715B */
|
|
|
|
/* 0x04 - YM719 - OPL-SA4? */
|
|
|
|
/* 0x05 - OPL3-SA3 - Libretto 100 */
|
2007-07-27 12:20:38 +02:00
|
|
|
/* 0x07 - unknown - Neomagic MagicWave 3D */
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
str[0] = chip->version + '0';
|
|
|
|
str[1] = 0;
|
|
|
|
strcat(card->shortname, str);
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_MISC, tmp ^ 7);
|
|
|
|
if ((tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MISC)) != tmp) {
|
|
|
|
snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
/* try if the MIC register is accesible */
|
|
|
|
tmp = snd_opl3sa2_read(chip, OPL3SA2_MIC);
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x8a);
|
|
|
|
if (((tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MIC)) & 0x9f) != 0x8a) {
|
|
|
|
snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x9f);
|
|
|
|
/* initialization */
|
|
|
|
/* Power Management - full on */
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0);
|
|
|
|
if (chip->version > 2) {
|
|
|
|
/* ymode is bits 4&5 (of 0 to 7) on all but opl3sa2 versions */
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, (chip->ymode << 4));
|
|
|
|
} else {
|
|
|
|
/* default for opl3sa2 versions */
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, 0x00);
|
|
|
|
}
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_IRQ_CONFIG, 0x0d); /* Interrupt Channel Configuration - IRQ A = OPL3 + MPU + WSS */
|
|
|
|
if (chip->single_dma) {
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x03); /* DMA Configuration - DMA A = WSS-R + WSS-P */
|
|
|
|
} else {
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x21); /* DMA Configuration - DMA B = WSS-R, DMA A = WSS-P */
|
|
|
|
}
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_MISC, 0x80 | (tmp & 7)); /* Miscellaneous - default */
|
|
|
|
if (chip->version > 2) {
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA3_DGTL_DOWN, 0x00); /* Digital Block Partial Power Down - default */
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA3_ANLG_DOWN, 0x00); /* Analog Block Partial Power Down - default */
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 15:55:46 +02:00
|
|
|
static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned short status;
|
2008-08-17 20:01:14 +02:00
|
|
|
struct snd_card *card = dev_id;
|
|
|
|
struct snd_opl3sa2 *chip;
|
2005-04-17 00:20:36 +02:00
|
|
|
int handled = 0;
|
|
|
|
|
2008-08-19 21:51:49 +02:00
|
|
|
if (card == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return IRQ_NONE;
|
|
|
|
|
2008-08-17 20:01:14 +02:00
|
|
|
chip = card->private_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
status = snd_opl3sa2_read(chip, OPL3SA2_IRQ_STATUS);
|
|
|
|
|
|
|
|
if (status & 0x20) {
|
|
|
|
handled = 1;
|
|
|
|
snd_opl3_interrupt(chip->synth);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((status & 0x10) && chip->rmidi != NULL) {
|
|
|
|
handled = 1;
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 15:55:46 +02:00
|
|
|
snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status & 0x07) { /* TI,CI,PI */
|
|
|
|
handled = 1;
|
2008-07-31 21:03:41 +02:00
|
|
|
snd_wss_interrupt(irq, chip->wss);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status & 0x40) { /* hardware volume change */
|
|
|
|
handled = 1;
|
|
|
|
/* reading from Master Lch register at 0x07 clears this bit */
|
|
|
|
snd_opl3sa2_read(chip, OPL3SA2_MASTER_RIGHT);
|
|
|
|
snd_opl3sa2_read(chip, OPL3SA2_MASTER_LEFT);
|
|
|
|
if (chip->master_switch && chip->master_volume) {
|
2008-08-17 20:01:14 +02:00
|
|
|
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
|
|
|
|
&chip->master_switch->id);
|
|
|
|
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
|
|
|
|
&chip->master_volume->id);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OPL3SA2_SINGLE(xname, xindex, reg, shift, mask, invert) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
|
2008-08-19 21:51:49 +02:00
|
|
|
.info = snd_wss_info_single, \
|
2005-04-17 00:20:36 +02:00
|
|
|
.get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \
|
|
|
|
.private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
|
2006-08-22 13:16:39 +02:00
|
|
|
#define OPL3SA2_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
|
|
|
|
.name = xname, .index = xindex, \
|
2008-08-19 21:51:49 +02:00
|
|
|
.info = snd_wss_info_single, \
|
2006-08-22 13:16:39 +02:00
|
|
|
.get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \
|
|
|
|
.private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \
|
|
|
|
.tlv = { .p = (xtlv) } }
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static int snd_opl3sa2_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
int reg = kcontrol->private_value & 0xff;
|
|
|
|
int shift = (kcontrol->private_value >> 8) & 0xff;
|
|
|
|
int mask = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
int invert = (kcontrol->private_value >> 24) & 0xff;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->reg_lock, flags);
|
|
|
|
ucontrol->value.integer.value[0] = (chip->ctlregs[reg] >> shift) & mask;
|
|
|
|
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
|
|
|
if (invert)
|
|
|
|
ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static int snd_opl3sa2_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
int reg = kcontrol->private_value & 0xff;
|
|
|
|
int shift = (kcontrol->private_value >> 8) & 0xff;
|
|
|
|
int mask = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
int invert = (kcontrol->private_value >> 24) & 0xff;
|
|
|
|
int change;
|
|
|
|
unsigned short val, oval;
|
|
|
|
|
|
|
|
val = (ucontrol->value.integer.value[0] & mask);
|
|
|
|
if (invert)
|
|
|
|
val = mask - val;
|
|
|
|
val <<= shift;
|
|
|
|
spin_lock_irqsave(&chip->reg_lock, flags);
|
|
|
|
oval = chip->ctlregs[reg];
|
|
|
|
val = (oval & ~(mask << shift)) | val;
|
|
|
|
change = val != oval;
|
|
|
|
__snd_opl3sa2_write(chip, reg, val);
|
|
|
|
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OPL3SA2_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
|
2008-08-19 21:51:49 +02:00
|
|
|
.info = snd_wss_info_double, \
|
2005-04-17 00:20:36 +02:00
|
|
|
.get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \
|
|
|
|
.private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
|
2006-08-22 13:16:39 +02:00
|
|
|
#define OPL3SA2_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
|
|
|
|
.name = xname, .index = xindex, \
|
2008-08-19 21:51:49 +02:00
|
|
|
.info = snd_wss_info_double, \
|
2006-08-22 13:16:39 +02:00
|
|
|
.get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \
|
|
|
|
.private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22), \
|
|
|
|
.tlv = { .p = (xtlv) } }
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static int snd_opl3sa2_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
int left_reg = kcontrol->private_value & 0xff;
|
|
|
|
int right_reg = (kcontrol->private_value >> 8) & 0xff;
|
|
|
|
int shift_left = (kcontrol->private_value >> 16) & 0x07;
|
|
|
|
int shift_right = (kcontrol->private_value >> 19) & 0x07;
|
|
|
|
int mask = (kcontrol->private_value >> 24) & 0xff;
|
|
|
|
int invert = (kcontrol->private_value >> 22) & 1;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->reg_lock, flags);
|
|
|
|
ucontrol->value.integer.value[0] = (chip->ctlregs[left_reg] >> shift_left) & mask;
|
|
|
|
ucontrol->value.integer.value[1] = (chip->ctlregs[right_reg] >> shift_right) & mask;
|
|
|
|
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
|
|
|
if (invert) {
|
|
|
|
ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
|
|
|
|
ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
int left_reg = kcontrol->private_value & 0xff;
|
|
|
|
int right_reg = (kcontrol->private_value >> 8) & 0xff;
|
|
|
|
int shift_left = (kcontrol->private_value >> 16) & 0x07;
|
|
|
|
int shift_right = (kcontrol->private_value >> 19) & 0x07;
|
|
|
|
int mask = (kcontrol->private_value >> 24) & 0xff;
|
|
|
|
int invert = (kcontrol->private_value >> 22) & 1;
|
|
|
|
int change;
|
|
|
|
unsigned short val1, val2, oval1, oval2;
|
|
|
|
|
|
|
|
val1 = ucontrol->value.integer.value[0] & mask;
|
|
|
|
val2 = ucontrol->value.integer.value[1] & mask;
|
|
|
|
if (invert) {
|
|
|
|
val1 = mask - val1;
|
|
|
|
val2 = mask - val2;
|
|
|
|
}
|
|
|
|
val1 <<= shift_left;
|
|
|
|
val2 <<= shift_right;
|
|
|
|
spin_lock_irqsave(&chip->reg_lock, flags);
|
|
|
|
if (left_reg != right_reg) {
|
|
|
|
oval1 = chip->ctlregs[left_reg];
|
|
|
|
oval2 = chip->ctlregs[right_reg];
|
|
|
|
val1 = (oval1 & ~(mask << shift_left)) | val1;
|
|
|
|
val2 = (oval2 & ~(mask << shift_right)) | val2;
|
|
|
|
change = val1 != oval1 || val2 != oval2;
|
|
|
|
__snd_opl3sa2_write(chip, left_reg, val1);
|
|
|
|
__snd_opl3sa2_write(chip, right_reg, val2);
|
|
|
|
} else {
|
|
|
|
oval1 = chip->ctlregs[left_reg];
|
|
|
|
val1 = (oval1 & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2;
|
|
|
|
change = val1 != oval1;
|
|
|
|
__snd_opl3sa2_write(chip, left_reg, val1);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2007-01-29 15:33:49 +01:00
|
|
|
static const DECLARE_TLV_DB_SCALE(db_scale_master, -3000, 200, 0);
|
|
|
|
static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
|
2006-08-22 13:16:39 +02:00
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static struct snd_kcontrol_new snd_opl3sa2_controls[] = {
|
2005-04-17 00:20:36 +02:00
|
|
|
OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
|
2006-08-22 13:16:39 +02:00
|
|
|
OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1,
|
|
|
|
db_scale_master),
|
2005-04-17 00:20:36 +02:00
|
|
|
OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
|
2006-08-22 13:16:39 +02:00
|
|
|
OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1,
|
|
|
|
db_scale_5bit_12db_max),
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = {
|
2005-04-17 00:20:36 +02:00
|
|
|
OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
|
|
|
|
OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
|
|
|
|
OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0)
|
|
|
|
};
|
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static void snd_opl3sa2_master_free(struct snd_kcontrol *kcontrol)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
|
2005-04-17 00:20:36 +02:00
|
|
|
chip->master_switch = NULL;
|
|
|
|
chip->master_volume = NULL;
|
|
|
|
}
|
|
|
|
|
2008-08-17 20:01:14 +02:00
|
|
|
static int __devinit snd_opl3sa2_mixer(struct snd_card *card)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-08-17 20:01:14 +02:00
|
|
|
struct snd_opl3sa2 *chip = card->private_data;
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_ctl_elem_id id1, id2;
|
|
|
|
struct snd_kcontrol *kctl;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned int idx;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
memset(&id1, 0, sizeof(id1));
|
|
|
|
memset(&id2, 0, sizeof(id2));
|
|
|
|
id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
|
|
|
|
/* reassign AUX0 to CD */
|
|
|
|
strcpy(id1.name, "Aux Playback Switch");
|
|
|
|
strcpy(id2.name, "CD Playback Switch");
|
2005-11-17 17:44:01 +01:00
|
|
|
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
|
|
|
|
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return err;
|
2005-11-17 17:44:01 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
strcpy(id1.name, "Aux Playback Volume");
|
|
|
|
strcpy(id2.name, "CD Playback Volume");
|
2005-11-17 17:44:01 +01:00
|
|
|
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
|
|
|
|
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return err;
|
2005-11-17 17:44:01 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
/* reassign AUX1 to FM */
|
|
|
|
strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
|
|
|
|
strcpy(id2.name, "FM Playback Switch");
|
2005-11-17 17:44:01 +01:00
|
|
|
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
|
|
|
|
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return err;
|
2005-11-17 17:44:01 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
strcpy(id1.name, "Aux Playback Volume");
|
|
|
|
strcpy(id2.name, "FM Playback Volume");
|
2005-11-17 17:44:01 +01:00
|
|
|
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
|
|
|
|
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return err;
|
2005-11-17 17:44:01 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
/* add OPL3SA2 controls */
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) {
|
|
|
|
if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0)
|
|
|
|
return err;
|
|
|
|
switch (idx) {
|
|
|
|
case 0: chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free; break;
|
|
|
|
case 1: chip->master_volume = kctl; kctl->private_free = snd_opl3sa2_master_free; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chip->version > 2) {
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_tone_controls); idx++)
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa2_tone_controls[idx], chip))) < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power Management support functions */
|
|
|
|
#ifdef CONFIG_PM
|
2005-11-17 14:41:45 +01:00
|
|
|
static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
struct snd_opl3sa2 *chip = card->private_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
|
2008-07-31 21:03:41 +02:00
|
|
|
chip->wss->suspend(chip->wss);
|
2005-04-17 00:20:36 +02:00
|
|
|
/* power down */
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 14:41:45 +01:00
|
|
|
static int snd_opl3sa2_resume(struct snd_card *card)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
struct snd_opl3sa2 *chip = card->private_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* power up */
|
|
|
|
snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0);
|
|
|
|
|
|
|
|
/* restore registers */
|
|
|
|
for (i = 2; i <= 0x0a; i++) {
|
|
|
|
if (i != OPL3SA2_IRQ_STATUS)
|
|
|
|
snd_opl3sa2_write(chip, i, chip->ctlregs[i]);
|
|
|
|
}
|
|
|
|
if (chip->version > 2) {
|
|
|
|
for (i = 0x12; i <= 0x16; i++)
|
|
|
|
snd_opl3sa2_write(chip, i, chip->ctlregs[i]);
|
|
|
|
}
|
2008-07-31 21:03:41 +02:00
|
|
|
/* restore wss */
|
|
|
|
chip->wss->resume(chip->wss);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PNP
|
2006-06-09 15:28:07 +02:00
|
|
|
static int __devinit snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip,
|
|
|
|
struct pnp_dev *pdev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2007-11-30 17:59:25 +01:00
|
|
|
if (pnp_activate_dev(pdev) < 0) {
|
|
|
|
snd_printk(KERN_ERR "PnP configure failure (out of resources?)\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
sb_port[dev] = pnp_port_start(pdev, 0);
|
|
|
|
wss_port[dev] = pnp_port_start(pdev, 1);
|
|
|
|
fm_port[dev] = pnp_port_start(pdev, 2);
|
|
|
|
midi_port[dev] = pnp_port_start(pdev, 3);
|
|
|
|
port[dev] = pnp_port_start(pdev, 4);
|
|
|
|
dma1[dev] = pnp_dma(pdev, 0);
|
|
|
|
dma2[dev] = pnp_dma(pdev, 1);
|
|
|
|
irq[dev] = pnp_irq(pdev, 0);
|
2005-08-12 17:24:24 +02:00
|
|
|
snd_printdd("%sPnP OPL3-SA: sb port=0x%lx, wss port=0x%lx, fm port=0x%lx, midi port=0x%lx\n",
|
|
|
|
pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", sb_port[dev], wss_port[dev], fm_port[dev], midi_port[dev]);
|
|
|
|
snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n",
|
|
|
|
pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", port[dev], dma1[dev], dma2[dev], irq[dev]);
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PNP */
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
static void snd_opl3sa2_free(struct snd_card *card)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
struct snd_opl3sa2 *chip = card->private_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (chip->irq >= 0)
|
|
|
|
free_irq(chip->irq, (void *)chip);
|
2005-10-10 11:56:31 +02:00
|
|
|
release_and_free_resource(chip->res_port);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
static struct snd_card *snd_opl3sa2_card_new(int dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 14:41:45 +01:00
|
|
|
struct snd_card *card;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct snd_opl3sa2 *chip;
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_opl3sa2));
|
2005-04-17 00:20:36 +02:00
|
|
|
if (card == NULL)
|
2005-11-17 17:11:53 +01:00
|
|
|
return NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
strcpy(card->driver, "OPL3SA2");
|
|
|
|
strcpy(card->shortname, "Yamaha OPL3-SA2");
|
2005-11-17 17:11:53 +01:00
|
|
|
chip = card->private_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_init(&chip->reg_lock);
|
|
|
|
chip->irq = -1;
|
2005-11-17 17:11:53 +01:00
|
|
|
card->private_free = snd_opl3sa2_free;
|
|
|
|
return card;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev)
|
|
|
|
{
|
|
|
|
int xirq, xdma1, xdma2;
|
|
|
|
struct snd_opl3sa2 *chip;
|
2008-07-31 21:03:41 +02:00
|
|
|
struct snd_wss *wss;
|
2005-11-17 17:11:53 +01:00
|
|
|
struct snd_opl3 *opl3;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* initialise this card from supplied (or default) parameter*/
|
|
|
|
chip = card->private_data;
|
|
|
|
chip->ymode = opl3sa3_ymode[dev] & 0x03 ;
|
2005-04-17 00:20:36 +02:00
|
|
|
chip->port = port[dev];
|
|
|
|
xirq = irq[dev];
|
|
|
|
xdma1 = dma1[dev];
|
|
|
|
xdma2 = dma2[dev];
|
|
|
|
if (xdma2 < 0)
|
|
|
|
chip->single_dma = 1;
|
2008-08-17 20:01:14 +02:00
|
|
|
err = snd_opl3sa2_detect(card);
|
|
|
|
if (err < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2008-08-17 20:01:14 +02:00
|
|
|
err = request_irq(xirq, snd_opl3sa2_interrupt, IRQF_DISABLED,
|
|
|
|
"OPL3-SA2", card);
|
|
|
|
if (err) {
|
[ALSA] Add snd_card_set_generic_dev() call to ISA drivers
ISA,CMI8330 driver,ES18xx driver,OPL3SA2 driver,Sound Galaxy driver
Sound Scape driver,AD1848 driver,CS4231 driver,CS4236+ driver
ES1688 driver,GUS Classic driver,GUS Extreme driver,GUS MAX driver
AMD InterWave driver,Opti9xx drivers,SB16/AWE driver,SB8 driver
Wavefront drivers
- Added snd_card_set_generic_dev() call.
- Added SND_GENERIC_DRIVER to Kconfig.
- Clean up the error path in probe if necessary.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-05 17:19:20 +02:00
|
|
|
snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq);
|
2005-11-17 17:11:53 +01:00
|
|
|
return -ENODEV;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
chip->irq = xirq;
|
2008-07-31 21:03:41 +02:00
|
|
|
err = snd_wss_create(card,
|
|
|
|
wss_port[dev] + 4, -1,
|
|
|
|
xirq, xdma1, xdma2,
|
|
|
|
WSS_HW_OPL3SA2, WSS_HWSHARE_IRQ, &wss);
|
|
|
|
if (err < 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
snd_printd("Oops, WSS not detected at 0x%lx\n", wss_port[dev] + 4);
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-07-31 21:03:41 +02:00
|
|
|
chip->wss = wss;
|
|
|
|
err = snd_wss_pcm(wss, 0, NULL);
|
|
|
|
if (err < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2008-07-31 21:03:41 +02:00
|
|
|
err = snd_wss_mixer(wss);
|
|
|
|
if (err < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2008-08-17 20:01:14 +02:00
|
|
|
err = snd_opl3sa2_mixer(card);
|
|
|
|
if (err < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2008-07-31 21:03:41 +02:00
|
|
|
err = snd_wss_timer(wss, 0, NULL);
|
|
|
|
if (err < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) {
|
|
|
|
if ((err = snd_opl3_create(card, fm_port[dev],
|
|
|
|
fm_port[dev] + 2,
|
|
|
|
OPL3_HW_OPL3, 0, &opl3)) < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) {
|
|
|
|
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
|
|
|
|
midi_port[dev], 0,
|
|
|
|
xirq, 0, &chip->rmidi)) < 0)
|
2005-11-17 17:11:53 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
|
|
|
|
card->shortname, chip->port, xirq, xdma1);
|
2006-01-25 14:30:44 +01:00
|
|
|
if (xdma2 >= 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
return snd_card_register(card);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PNP
|
2005-08-12 17:24:24 +02:00
|
|
|
static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
|
|
|
|
const struct pnp_device_id *id)
|
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
static int dev;
|
|
|
|
int err;
|
|
|
|
struct snd_card *card;
|
|
|
|
|
|
|
|
if (pnp_device_is_isapnp(pdev))
|
|
|
|
return -ENOENT; /* we have another procedure - card */
|
|
|
|
for (; dev < SNDRV_CARDS; dev++) {
|
|
|
|
if (enable[dev] && isapnp[dev])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dev >= SNDRV_CARDS)
|
|
|
|
return -ENODEV;
|
2005-08-12 17:24:24 +02:00
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
card = snd_opl3sa2_card_new(dev);
|
|
|
|
if (! card)
|
|
|
|
return -ENOMEM;
|
|
|
|
if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
snd_card_set_dev(card, &pdev->dev);
|
|
|
|
if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
pnp_set_drvdata(pdev, card);
|
|
|
|
dev++;
|
|
|
|
return 0;
|
2005-08-12 17:24:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev)
|
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
snd_card_free(pnp_get_drvdata(pdev));
|
|
|
|
pnp_set_drvdata(pdev, NULL);
|
2005-08-12 17:24:24 +02:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
static int snd_opl3sa2_pnp_suspend(struct pnp_dev *pdev, pm_message_t state)
|
|
|
|
{
|
|
|
|
return snd_opl3sa2_suspend(pnp_get_drvdata(pdev), state);
|
|
|
|
}
|
|
|
|
static int snd_opl3sa2_pnp_resume(struct pnp_dev *pdev)
|
|
|
|
{
|
|
|
|
return snd_opl3sa2_resume(pnp_get_drvdata(pdev));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-08-12 17:24:24 +02:00
|
|
|
static struct pnp_driver opl3sa2_pnp_driver = {
|
2006-01-20 14:03:06 +01:00
|
|
|
.name = "snd-opl3sa2-pnpbios",
|
2005-08-12 17:24:24 +02:00
|
|
|
.id_table = snd_opl3sa2_pnpbiosids,
|
|
|
|
.probe = snd_opl3sa2_pnp_detect,
|
|
|
|
.remove = __devexit_p(snd_opl3sa2_pnp_remove),
|
2005-11-17 17:11:53 +01:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = snd_opl3sa2_pnp_suspend,
|
|
|
|
.resume = snd_opl3sa2_pnp_resume,
|
|
|
|
#endif
|
2005-08-12 17:24:24 +02:00
|
|
|
};
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
|
2005-08-12 17:24:24 +02:00
|
|
|
const struct pnp_card_device_id *id)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
static int dev;
|
|
|
|
struct pnp_dev *pdev;
|
|
|
|
int err;
|
|
|
|
struct snd_card *card;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL);
|
2005-11-17 17:44:01 +01:00
|
|
|
if (pdev == NULL) {
|
|
|
|
snd_printk(KERN_ERR PFX "can't get pnp device from id '%s'\n",
|
|
|
|
id->devs[0].id);
|
2005-11-17 17:11:53 +01:00
|
|
|
return -EBUSY;
|
2005-11-17 17:44:01 +01:00
|
|
|
}
|
2005-11-17 17:11:53 +01:00
|
|
|
for (; dev < SNDRV_CARDS; dev++) {
|
|
|
|
if (enable[dev] && isapnp[dev])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dev >= SNDRV_CARDS)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
card = snd_opl3sa2_card_new(dev);
|
|
|
|
if (! card)
|
|
|
|
return -ENOMEM;
|
|
|
|
if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
snd_card_set_dev(card, &pdev->dev);
|
|
|
|
if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
pnp_set_card_drvdata(pcard, card);
|
|
|
|
dev++;
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-08-12 17:24:24 +02:00
|
|
|
static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-11-17 17:11:53 +01:00
|
|
|
snd_card_free(pnp_get_card_drvdata(pcard));
|
|
|
|
pnp_set_card_drvdata(pcard, NULL);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
static int snd_opl3sa2_pnp_csuspend(struct pnp_card_link *pcard, pm_message_t state)
|
|
|
|
{
|
|
|
|
return snd_opl3sa2_suspend(pnp_get_card_drvdata(pcard), state);
|
|
|
|
}
|
|
|
|
static int snd_opl3sa2_pnp_cresume(struct pnp_card_link *pcard)
|
|
|
|
{
|
|
|
|
return snd_opl3sa2_resume(pnp_get_card_drvdata(pcard));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static struct pnp_card_driver opl3sa2_pnpc_driver = {
|
|
|
|
.flags = PNP_DRIVER_RES_DISABLE,
|
2006-01-20 14:03:06 +01:00
|
|
|
.name = "snd-opl3sa2-cpnp",
|
2005-04-17 00:20:36 +02:00
|
|
|
.id_table = snd_opl3sa2_pnpids,
|
2005-08-12 17:24:24 +02:00
|
|
|
.probe = snd_opl3sa2_pnp_cdetect,
|
|
|
|
.remove = __devexit_p(snd_opl3sa2_pnp_cremove),
|
2005-11-17 17:11:53 +01:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = snd_opl3sa2_pnp_csuspend,
|
|
|
|
.resume = snd_opl3sa2_pnp_cresume,
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
#endif /* CONFIG_PNP */
|
|
|
|
|
2007-02-22 12:50:54 +01:00
|
|
|
static int __devinit snd_opl3sa2_isa_match(struct device *pdev,
|
|
|
|
unsigned int dev)
|
2005-11-17 17:11:53 +01:00
|
|
|
{
|
2007-02-22 12:50:54 +01:00
|
|
|
if (!enable[dev])
|
|
|
|
return 0;
|
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
if (isapnp[dev])
|
|
|
|
return 0;
|
|
|
|
#endif
|
2005-11-17 17:11:53 +01:00
|
|
|
if (port[dev] == SNDRV_AUTO_PORT) {
|
|
|
|
snd_printk(KERN_ERR PFX "specify port\n");
|
2007-02-22 12:50:54 +01:00
|
|
|
return 0;
|
2005-11-17 17:11:53 +01:00
|
|
|
}
|
|
|
|
if (wss_port[dev] == SNDRV_AUTO_PORT) {
|
|
|
|
snd_printk(KERN_ERR PFX "specify wss_port\n");
|
2007-02-22 12:50:54 +01:00
|
|
|
return 0;
|
2005-11-17 17:11:53 +01:00
|
|
|
}
|
|
|
|
if (fm_port[dev] == SNDRV_AUTO_PORT) {
|
|
|
|
snd_printk(KERN_ERR PFX "specify fm_port\n");
|
2007-02-22 12:50:54 +01:00
|
|
|
return 0;
|
2005-11-17 17:11:53 +01:00
|
|
|
}
|
|
|
|
if (midi_port[dev] == SNDRV_AUTO_PORT) {
|
|
|
|
snd_printk(KERN_ERR PFX "specify midi_port\n");
|
2007-02-22 12:50:54 +01:00
|
|
|
return 0;
|
2005-11-17 17:11:53 +01:00
|
|
|
}
|
2007-02-22 12:50:54 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit snd_opl3sa2_isa_probe(struct device *pdev,
|
|
|
|
unsigned int dev)
|
|
|
|
{
|
|
|
|
struct snd_card *card;
|
|
|
|
int err;
|
2005-11-17 17:11:53 +01:00
|
|
|
|
|
|
|
card = snd_opl3sa2_card_new(dev);
|
|
|
|
if (! card)
|
|
|
|
return -ENOMEM;
|
2007-02-22 12:50:54 +01:00
|
|
|
snd_card_set_dev(card, pdev);
|
2005-11-17 17:11:53 +01:00
|
|
|
if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
2007-02-22 12:50:54 +01:00
|
|
|
dev_set_drvdata(pdev, card);
|
2005-11-17 17:11:53 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-22 12:50:54 +01:00
|
|
|
static int __devexit snd_opl3sa2_isa_remove(struct device *devptr,
|
|
|
|
unsigned int dev)
|
2005-11-17 17:11:53 +01:00
|
|
|
{
|
2007-02-22 12:50:54 +01:00
|
|
|
snd_card_free(dev_get_drvdata(devptr));
|
|
|
|
dev_set_drvdata(devptr, NULL);
|
2005-11-17 17:11:53 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
2007-02-22 12:50:54 +01:00
|
|
|
static int snd_opl3sa2_isa_suspend(struct device *dev, unsigned int n,
|
|
|
|
pm_message_t state)
|
2005-11-17 17:11:53 +01:00
|
|
|
{
|
2007-02-22 12:50:54 +01:00
|
|
|
return snd_opl3sa2_suspend(dev_get_drvdata(dev), state);
|
2005-11-17 17:11:53 +01:00
|
|
|
}
|
|
|
|
|
2007-02-22 12:50:54 +01:00
|
|
|
static int snd_opl3sa2_isa_resume(struct device *dev, unsigned int n)
|
2005-11-17 17:11:53 +01:00
|
|
|
{
|
2007-02-22 12:50:54 +01:00
|
|
|
return snd_opl3sa2_resume(dev_get_drvdata(dev));
|
2005-11-17 17:11:53 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-03-20 11:33:46 +01:00
|
|
|
#define DEV_NAME "opl3sa2"
|
2005-11-17 17:11:53 +01:00
|
|
|
|
2007-02-22 12:50:54 +01:00
|
|
|
static struct isa_driver snd_opl3sa2_isa_driver = {
|
|
|
|
.match = snd_opl3sa2_isa_match,
|
|
|
|
.probe = snd_opl3sa2_isa_probe,
|
2007-06-27 23:10:02 +02:00
|
|
|
.remove = __devexit_p(snd_opl3sa2_isa_remove),
|
2005-11-17 17:11:53 +01:00
|
|
|
#ifdef CONFIG_PM
|
2007-02-22 12:50:54 +01:00
|
|
|
.suspend = snd_opl3sa2_isa_suspend,
|
|
|
|
.resume = snd_opl3sa2_isa_resume,
|
2005-11-17 17:11:53 +01:00
|
|
|
#endif
|
|
|
|
.driver = {
|
2007-03-20 11:33:46 +01:00
|
|
|
.name = DEV_NAME
|
2005-11-17 17:11:53 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static int __init alsa_card_opl3sa2_init(void)
|
|
|
|
{
|
2007-02-22 12:50:54 +01:00
|
|
|
int err;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-02-22 12:50:54 +01:00
|
|
|
err = isa_register_driver(&snd_opl3sa2_isa_driver, SNDRV_CARDS);
|
2006-01-04 15:06:44 +01:00
|
|
|
#ifdef CONFIG_PNP
|
2007-05-15 11:42:56 +02:00
|
|
|
if (!err)
|
|
|
|
isa_registered = 1;
|
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
err = pnp_register_driver(&opl3sa2_pnp_driver);
|
2006-03-27 11:17:05 +02:00
|
|
|
if (!err)
|
2005-12-07 09:13:42 +01:00
|
|
|
pnp_registered = 1;
|
2007-05-15 11:42:56 +02:00
|
|
|
|
2005-11-17 17:11:53 +01:00
|
|
|
err = pnp_register_card_driver(&opl3sa2_pnpc_driver);
|
2006-03-27 11:17:05 +02:00
|
|
|
if (!err)
|
2005-12-07 09:13:42 +01:00
|
|
|
pnpc_registered = 1;
|
2007-05-15 11:42:56 +02:00
|
|
|
|
|
|
|
if (isa_registered || pnp_registered)
|
|
|
|
err = 0;
|
2006-01-04 15:06:44 +01:00
|
|
|
#endif
|
2007-05-15 11:42:56 +02:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit alsa_card_opl3sa2_exit(void)
|
|
|
|
{
|
2007-02-22 12:50:54 +01:00
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
if (pnpc_registered)
|
|
|
|
pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
|
|
|
|
if (pnp_registered)
|
|
|
|
pnp_unregister_driver(&opl3sa2_pnp_driver);
|
2007-05-15 11:42:56 +02:00
|
|
|
if (isa_registered)
|
2007-02-22 12:50:54 +01:00
|
|
|
#endif
|
2007-05-15 11:42:56 +02:00
|
|
|
isa_unregister_driver(&snd_opl3sa2_isa_driver);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(alsa_card_opl3sa2_init)
|
|
|
|
module_exit(alsa_card_opl3sa2_exit)
|