2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2006-03-27 18:41:01 +08:00
|
|
|
/*
|
|
|
|
* ALSA soundcard driver for Miro miroSOUND PCM1 pro
|
|
|
|
* miroSOUND PCM12
|
|
|
|
* miroSOUND PCM20 Radio
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2005 Martin Langer <martin-langer@gmx.de>
|
|
|
|
*
|
|
|
|
* Based on OSS ACI and ALSA OPTi9xx drivers
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/err.h>
|
2007-02-22 19:50:54 +08:00
|
|
|
#include <linux/isa.h>
|
2009-11-30 14:46:56 +08:00
|
|
|
#include <linux/pnp.h>
|
2006-03-27 18:41:01 +08:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/ioport.h>
|
2011-07-16 01:13:37 +08:00
|
|
|
#include <linux/module.h>
|
2015-01-28 23:49:33 +08:00
|
|
|
#include <linux/io.h>
|
2006-03-27 18:41:01 +08:00
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <sound/core.h>
|
2008-08-01 03:02:42 +08:00
|
|
|
#include <sound/wss.h>
|
2006-03-27 18:41:01 +08:00
|
|
|
#include <sound/mpu401.h>
|
|
|
|
#include <sound/opl4.h>
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/info.h>
|
2012-08-01 22:05:39 +08:00
|
|
|
#define SNDRV_LEGACY_FIND_FREE_IOPORT
|
2006-03-27 18:41:01 +08:00
|
|
|
#define SNDRV_LEGACY_FIND_FREE_IRQ
|
|
|
|
#define SNDRV_LEGACY_FIND_FREE_DMA
|
|
|
|
#include <sound/initval.h>
|
2009-11-23 00:23:45 +08:00
|
|
|
#include <sound/aci.h>
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("Miro miroSOUND PCM1 pro, PCM12, PCM20 Radio");
|
|
|
|
MODULE_SUPPORTED_DEVICE("{{Miro,miroSOUND PCM1 pro}, "
|
|
|
|
"{Miro,miroSOUND PCM12}, "
|
|
|
|
"{Miro,miroSOUND PCM20 Radio}}");
|
|
|
|
|
|
|
|
static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
|
|
|
|
static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
|
|
|
|
static long port = SNDRV_DEFAULT_PORT1; /* 0x530,0xe80,0xf40,0x604 */
|
|
|
|
static long mpu_port = SNDRV_DEFAULT_PORT1; /* 0x300,0x310,0x320,0x330 */
|
|
|
|
static long fm_port = SNDRV_DEFAULT_PORT1; /* 0x388 */
|
|
|
|
static int irq = SNDRV_DEFAULT_IRQ1; /* 5,7,9,10,11 */
|
|
|
|
static int mpu_irq = SNDRV_DEFAULT_IRQ1; /* 5,7,9,10 */
|
|
|
|
static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */
|
|
|
|
static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */
|
|
|
|
static int wss;
|
|
|
|
static int ide;
|
2009-11-30 14:46:56 +08:00
|
|
|
#ifdef CONFIG_PNP
|
2011-12-15 11:19:36 +08:00
|
|
|
static bool isapnp = 1; /* Enable ISA PnP detection */
|
2009-11-30 14:46:56 +08:00
|
|
|
#endif
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
module_param(index, int, 0444);
|
|
|
|
MODULE_PARM_DESC(index, "Index value for miro soundcard.");
|
|
|
|
module_param(id, charp, 0444);
|
|
|
|
MODULE_PARM_DESC(id, "ID string for miro soundcard.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(port, long, ioport, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(port, "WSS port # for miro driver.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(mpu_port, long, ioport, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(mpu_port, "MPU-401 port # for miro driver.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(fm_port, long, ioport, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(fm_port, "FM Port # for miro driver.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(irq, int, irq, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(irq, "WSS irq # for miro driver.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(mpu_irq, int, irq, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(mpu_irq, "MPU-401 irq # for miro driver.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(dma1, int, dma, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(dma1, "1st dma # for miro driver.");
|
2017-04-04 23:54:30 +08:00
|
|
|
module_param_hw(dma2, int, dma, 0444);
|
2006-03-27 18:41:01 +08:00
|
|
|
MODULE_PARM_DESC(dma2, "2nd dma # for miro driver.");
|
|
|
|
module_param(wss, int, 0444);
|
|
|
|
MODULE_PARM_DESC(wss, "wss mode");
|
|
|
|
module_param(ide, int, 0444);
|
|
|
|
MODULE_PARM_DESC(ide, "enable ide port");
|
2009-11-30 14:46:56 +08:00
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
module_param(isapnp, bool, 0444);
|
|
|
|
MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard.");
|
|
|
|
#endif
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
#define OPTi9XX_HW_DETECT 0
|
|
|
|
#define OPTi9XX_HW_82C928 1
|
|
|
|
#define OPTi9XX_HW_82C929 2
|
|
|
|
#define OPTi9XX_HW_82C924 3
|
|
|
|
#define OPTi9XX_HW_82C925 4
|
|
|
|
#define OPTi9XX_HW_82C930 5
|
|
|
|
#define OPTi9XX_HW_82C931 6
|
|
|
|
#define OPTi9XX_HW_82C933 7
|
|
|
|
#define OPTi9XX_HW_LAST OPTi9XX_HW_82C933
|
|
|
|
|
|
|
|
#define OPTi9XX_MC_REG(n) n
|
|
|
|
|
|
|
|
struct snd_miro {
|
|
|
|
unsigned short hardware;
|
|
|
|
unsigned char password;
|
|
|
|
char name[7];
|
|
|
|
|
|
|
|
struct resource *res_mc_base;
|
|
|
|
struct resource *res_aci_port;
|
|
|
|
|
|
|
|
unsigned long mc_base;
|
|
|
|
unsigned long mc_base_size;
|
|
|
|
unsigned long pwd_reg;
|
|
|
|
|
|
|
|
spinlock_t lock;
|
|
|
|
struct snd_pcm *pcm;
|
|
|
|
|
|
|
|
long wss_base;
|
|
|
|
int irq;
|
|
|
|
int dma1;
|
|
|
|
int dma2;
|
|
|
|
|
|
|
|
long mpu_port;
|
|
|
|
int mpu_irq;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
struct snd_miro_aci *aci;
|
2006-03-27 18:41:01 +08:00
|
|
|
};
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
static struct snd_miro_aci aci_device;
|
|
|
|
|
2020-01-05 22:48:05 +08:00
|
|
|
static const char * const snd_opti9xx_names[] = {
|
tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-11-14 23:09:05 +08:00
|
|
|
"unknown",
|
2006-03-27 18:41:01 +08:00
|
|
|
"82C928", "82C929",
|
|
|
|
"82C924", "82C925",
|
|
|
|
"82C930", "82C931", "82C933"
|
|
|
|
};
|
|
|
|
|
2009-11-30 14:46:56 +08:00
|
|
|
static int snd_miro_pnp_is_probed;
|
|
|
|
|
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
|
2017-08-17 18:06:27 +08:00
|
|
|
static const struct pnp_card_device_id snd_miro_pnpids[] = {
|
2009-11-30 14:46:56 +08:00
|
|
|
/* PCM20 and PCM12 in PnP mode */
|
|
|
|
{ .id = "MIR0924",
|
|
|
|
.devs = { { "MIR0000" }, { "MIR0002" }, { "MIR0005" } }, },
|
|
|
|
{ .id = "" }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pnp_card, snd_miro_pnpids);
|
|
|
|
|
|
|
|
#endif /* CONFIG_PNP */
|
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
/*
|
|
|
|
* ACI control
|
|
|
|
*/
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
static int aci_busy_wait(struct snd_miro_aci *aci)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
long timeout;
|
|
|
|
unsigned char byte;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
for (timeout = 1; timeout <= ACI_MINTIME + 30; timeout++) {
|
|
|
|
byte = inb(aci->aci_port + ACI_REG_BUSY);
|
|
|
|
if ((byte & 1) == 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
if (timeout >= ACI_MINTIME)
|
|
|
|
snd_printd("aci ready in round %ld.\n",
|
|
|
|
timeout-ACI_MINTIME);
|
|
|
|
return byte;
|
|
|
|
}
|
|
|
|
if (timeout >= ACI_MINTIME) {
|
|
|
|
long out=10*HZ;
|
|
|
|
switch (timeout-ACI_MINTIME) {
|
|
|
|
case 0 ... 9:
|
|
|
|
out /= 10;
|
2018-08-03 04:41:55 +08:00
|
|
|
/* fall through */
|
2006-03-27 18:41:01 +08:00
|
|
|
case 10 ... 19:
|
|
|
|
out /= 10;
|
2018-08-03 04:41:55 +08:00
|
|
|
/* fall through */
|
2006-03-27 18:41:01 +08:00
|
|
|
case 20 ... 30:
|
|
|
|
out /= 10;
|
2018-08-03 04:41:55 +08:00
|
|
|
/* fall through */
|
2006-03-27 18:41:01 +08:00
|
|
|
default:
|
|
|
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
|
|
|
schedule_timeout(out);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snd_printk(KERN_ERR "aci_busy_wait() time out\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
static inline int aci_write(struct snd_miro_aci *aci, unsigned char byte)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
2009-11-23 00:26:34 +08:00
|
|
|
if (aci_busy_wait(aci) >= 0) {
|
|
|
|
outb(byte, aci->aci_port + ACI_REG_COMMAND);
|
2006-03-27 18:41:01 +08:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
static inline int aci_read(struct snd_miro_aci *aci)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
unsigned char byte;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if (aci_busy_wait(aci) >= 0) {
|
|
|
|
byte = inb(aci->aci_port + ACI_REG_STATUS);
|
2006-03-27 18:41:01 +08:00
|
|
|
return byte;
|
|
|
|
} else {
|
|
|
|
snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
int snd_aci_cmd(struct snd_miro_aci *aci, int write1, int write2, int write3)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
int write[] = {write1, write2, write3};
|
|
|
|
int value, i;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if (mutex_lock_interruptible(&aci->aci_mutex))
|
2006-03-27 18:41:01 +08:00
|
|
|
return -EINTR;
|
|
|
|
|
|
|
|
for (i=0; i<3; i++) {
|
|
|
|
if (write[i]< 0 || write[i] > 255)
|
|
|
|
break;
|
|
|
|
else {
|
2009-11-23 00:26:34 +08:00
|
|
|
value = aci_write(aci, write[i]);
|
2006-03-27 18:41:01 +08:00
|
|
|
if (value < 0)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
value = aci_read(aci);
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
out: mutex_unlock(&aci->aci_mutex);
|
2006-03-27 18:41:01 +08:00
|
|
|
return value;
|
|
|
|
}
|
2009-11-23 00:26:34 +08:00
|
|
|
EXPORT_SYMBOL(snd_aci_cmd);
|
|
|
|
|
|
|
|
static int aci_getvalue(struct snd_miro_aci *aci, unsigned char index)
|
|
|
|
{
|
|
|
|
return snd_aci_cmd(aci, ACI_STATUS, index, -1);
|
|
|
|
}
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
static int aci_setvalue(struct snd_miro_aci *aci, unsigned char index,
|
|
|
|
int value)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
2009-11-23 00:26:34 +08:00
|
|
|
return snd_aci_cmd(aci, index, value, -1);
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
struct snd_miro_aci *snd_aci_get_aci(void)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
2009-11-23 00:26:34 +08:00
|
|
|
if (aci_device.aci_port == 0)
|
|
|
|
return NULL;
|
|
|
|
return &aci_device;
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
2009-11-23 00:26:34 +08:00
|
|
|
EXPORT_SYMBOL(snd_aci_get_aci);
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MIXER part
|
|
|
|
*/
|
|
|
|
|
2007-07-23 21:42:26 +08:00
|
|
|
#define snd_miro_info_capture snd_ctl_boolean_mono_info
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
static int snd_miro_get_capture(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
|
|
|
int value;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
value = aci_getvalue(miro->aci, ACI_S_GENERAL);
|
|
|
|
if (value < 0) {
|
|
|
|
snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n",
|
|
|
|
value);
|
2006-03-27 18:41:01 +08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
ucontrol->value.integer.value[0] = value & 0x20;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_put_capture(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
|
|
|
int change, value, error;
|
|
|
|
|
|
|
|
value = !(ucontrol->value.integer.value[0]);
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(miro->aci, ACI_SET_SOLOMODE, value);
|
|
|
|
if (error < 0) {
|
|
|
|
snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n",
|
|
|
|
error);
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
change = (value != miro->aci->aci_solomode);
|
|
|
|
miro->aci->aci_solomode = value;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_info_preamp(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 1;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 3;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
|
|
|
int value;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if (miro->aci->aci_version <= 176) {
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
OSS says it's not readable with versions < 176.
|
|
|
|
But it doesn't work on my card,
|
|
|
|
which is a PCM12 with aci_version = 176.
|
|
|
|
*/
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
ucontrol->value.integer.value[0] = miro->aci->aci_preamp;
|
2006-03-27 18:41:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
value = aci_getvalue(miro->aci, ACI_GET_PREAMP);
|
|
|
|
if (value < 0) {
|
|
|
|
snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n",
|
|
|
|
value);
|
2006-03-27 18:41:01 +08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
ucontrol->value.integer.value[0] = value;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_put_preamp(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
|
|
|
int error, value, change;
|
|
|
|
|
|
|
|
value = ucontrol->value.integer.value[0];
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(miro->aci, ACI_SET_PREAMP, value);
|
|
|
|
if (error < 0) {
|
|
|
|
snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n",
|
|
|
|
error);
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
change = (value != miro->aci->aci_preamp);
|
|
|
|
miro->aci->aci_preamp = value;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2007-07-23 21:42:26 +08:00
|
|
|
#define snd_miro_info_amp snd_ctl_boolean_mono_info
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
static int snd_miro_get_amp(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
2009-11-23 00:26:34 +08:00
|
|
|
ucontrol->value.integer.value[0] = miro->aci->aci_amp;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_put_amp(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
|
|
|
int error, value, change;
|
|
|
|
|
|
|
|
value = ucontrol->value.integer.value[0];
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(miro->aci, ACI_SET_POWERAMP, value);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
change = (value != miro->aci->aci_amp);
|
|
|
|
miro->aci->aci_amp = value;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MIRO_DOUBLE(ctl_name, ctl_index, get_right_reg, set_right_reg) \
|
|
|
|
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
|
|
|
|
.name = ctl_name, \
|
|
|
|
.index = ctl_index, \
|
|
|
|
.info = snd_miro_info_double, \
|
|
|
|
.get = snd_miro_get_double, \
|
|
|
|
.put = snd_miro_put_double, \
|
|
|
|
.private_value = get_right_reg | (set_right_reg << 8) \
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_info_double(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
int reg = kcontrol->private_value & 0xff;
|
|
|
|
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 2;
|
|
|
|
|
|
|
|
if ((reg >= ACI_GET_EQ1) && (reg <= ACI_GET_EQ7)) {
|
|
|
|
|
|
|
|
/* equalizer elements */
|
|
|
|
|
|
|
|
uinfo->value.integer.min = - 0x7f;
|
|
|
|
uinfo->value.integer.max = 0x7f;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* non-equalizer elements */
|
|
|
|
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 0x20;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_get_double(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *uinfo)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
|
|
|
int left_val, right_val;
|
|
|
|
|
|
|
|
int right_reg = kcontrol->private_value & 0xff;
|
|
|
|
int left_reg = right_reg + 1;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
right_val = aci_getvalue(miro->aci, right_reg);
|
|
|
|
if (right_val < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val);
|
|
|
|
return right_val;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
left_val = aci_getvalue(miro->aci, left_reg);
|
|
|
|
if (left_val < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val);
|
|
|
|
return left_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((right_reg >= ACI_GET_EQ1) && (right_reg <= ACI_GET_EQ7)) {
|
|
|
|
|
|
|
|
/* equalizer elements */
|
|
|
|
|
|
|
|
if (left_val < 0x80) {
|
|
|
|
uinfo->value.integer.value[0] = left_val;
|
|
|
|
} else {
|
|
|
|
uinfo->value.integer.value[0] = 0x80 - left_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (right_val < 0x80) {
|
|
|
|
uinfo->value.integer.value[1] = right_val;
|
|
|
|
} else {
|
|
|
|
uinfo->value.integer.value[1] = 0x80 - right_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* non-equalizer elements */
|
|
|
|
|
|
|
|
uinfo->value.integer.value[0] = 0x20 - left_val;
|
|
|
|
uinfo->value.integer.value[1] = 0x20 - right_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_miro_put_double(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = snd_kcontrol_chip(kcontrol);
|
2009-11-23 00:26:34 +08:00
|
|
|
struct snd_miro_aci *aci = miro->aci;
|
2006-03-27 18:41:01 +08:00
|
|
|
int left, right, left_old, right_old;
|
|
|
|
int setreg_left, setreg_right, getreg_left, getreg_right;
|
|
|
|
int change, error;
|
|
|
|
|
|
|
|
left = ucontrol->value.integer.value[0];
|
|
|
|
right = ucontrol->value.integer.value[1];
|
|
|
|
|
|
|
|
setreg_right = (kcontrol->private_value >> 8) & 0xff;
|
2009-11-21 08:01:18 +08:00
|
|
|
setreg_left = setreg_right + 8;
|
|
|
|
if (setreg_right == ACI_SET_MASTER)
|
|
|
|
setreg_left -= 7;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
getreg_right = kcontrol->private_value & 0xff;
|
|
|
|
getreg_left = getreg_right + 1;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
left_old = aci_getvalue(aci, getreg_left);
|
|
|
|
if (left_old < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old);
|
|
|
|
return left_old;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
right_old = aci_getvalue(aci, getreg_right);
|
|
|
|
if (right_old < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old);
|
|
|
|
return right_old;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((getreg_right >= ACI_GET_EQ1) && (getreg_right <= ACI_GET_EQ7)) {
|
|
|
|
|
|
|
|
/* equalizer elements */
|
|
|
|
|
2007-11-15 23:17:24 +08:00
|
|
|
if (left < -0x7f || left > 0x7f ||
|
|
|
|
right < -0x7f || right > 0x7f)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
if (left_old > 0x80)
|
|
|
|
left_old = 0x80 - left_old;
|
|
|
|
if (right_old > 0x80)
|
|
|
|
right_old = 0x80 - right_old;
|
|
|
|
|
|
|
|
if (left >= 0) {
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, setreg_left, left);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
left, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
} else {
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, setreg_left, 0x80 - left);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
0x80 - left, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (right >= 0) {
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, setreg_right, right);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
right, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
} else {
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, setreg_right, 0x80 - right);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
0x80 - right, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* non-equalizer elements */
|
|
|
|
|
2007-11-15 23:17:24 +08:00
|
|
|
if (left < 0 || left > 0x20 ||
|
|
|
|
right < 0 || right > 0x20)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
left_old = 0x20 - left_old;
|
|
|
|
right_old = 0x20 - right_old;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, setreg_left, 0x20 - left);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
0x20 - left, error);
|
|
|
|
return error;
|
|
|
|
}
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, setreg_right, 0x20 - right);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
0x20 - right, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
change = (left != left_old) || (right != right_old);
|
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_controls[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER),
|
|
|
|
MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC),
|
|
|
|
MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE),
|
|
|
|
MIRO_DOUBLE("CD Playback Volume", 0, ACI_GET_CD, ACI_SET_CD),
|
|
|
|
MIRO_DOUBLE("Synth Playback Volume", 0, ACI_GET_SYNTH, ACI_SET_SYNTH),
|
|
|
|
MIRO_DOUBLE("PCM Playback Volume", 1, ACI_GET_PCM, ACI_SET_PCM),
|
|
|
|
MIRO_DOUBLE("Aux Playback Volume", 2, ACI_GET_LINE2, ACI_SET_LINE2),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Equalizer with seven bands (only PCM20)
|
|
|
|
from -12dB up to +12dB on each band */
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_eq_controls[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1),
|
|
|
|
MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2),
|
|
|
|
MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3),
|
|
|
|
MIRO_DOUBLE("Tone Control - 1 kHz", 0, ACI_GET_EQ4, ACI_SET_EQ4),
|
|
|
|
MIRO_DOUBLE("Tone Control - 2.5 kHz", 0, ACI_GET_EQ5, ACI_SET_EQ5),
|
|
|
|
MIRO_DOUBLE("Tone Control - 6.3 kHz", 0, ACI_GET_EQ6, ACI_SET_EQ6),
|
|
|
|
MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7),
|
|
|
|
};
|
|
|
|
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_radio_control[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1),
|
|
|
|
};
|
|
|
|
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_line_control[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1),
|
|
|
|
};
|
|
|
|
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_preamp_control[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Mic Boost",
|
|
|
|
.index = 1,
|
|
|
|
.info = snd_miro_info_preamp,
|
|
|
|
.get = snd_miro_get_preamp,
|
|
|
|
.put = snd_miro_put_preamp,
|
|
|
|
}};
|
|
|
|
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_amp_control[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Line Boost",
|
|
|
|
.index = 0,
|
|
|
|
.info = snd_miro_info_amp,
|
|
|
|
.get = snd_miro_get_amp,
|
|
|
|
.put = snd_miro_put_amp,
|
|
|
|
}};
|
|
|
|
|
2020-01-03 16:16:51 +08:00
|
|
|
static const struct snd_kcontrol_new snd_miro_capture_control[] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "PCM Capture Switch",
|
|
|
|
.index = 0,
|
|
|
|
.info = snd_miro_info_capture,
|
|
|
|
.get = snd_miro_get_capture,
|
|
|
|
.put = snd_miro_put_capture,
|
|
|
|
}};
|
|
|
|
|
2020-01-05 22:48:05 +08:00
|
|
|
static const unsigned char aci_init_values[][2] = {
|
2006-03-27 18:41:01 +08:00
|
|
|
{ ACI_SET_MUTE, 0x00 },
|
|
|
|
{ ACI_SET_POWERAMP, 0x00 },
|
|
|
|
{ ACI_SET_PREAMP, 0x00 },
|
|
|
|
{ ACI_SET_SOLOMODE, 0x00 },
|
|
|
|
{ ACI_SET_MIC + 0, 0x20 },
|
|
|
|
{ ACI_SET_MIC + 8, 0x20 },
|
|
|
|
{ ACI_SET_LINE + 0, 0x20 },
|
|
|
|
{ ACI_SET_LINE + 8, 0x20 },
|
|
|
|
{ ACI_SET_CD + 0, 0x20 },
|
|
|
|
{ ACI_SET_CD + 8, 0x20 },
|
|
|
|
{ ACI_SET_PCM + 0, 0x20 },
|
|
|
|
{ ACI_SET_PCM + 8, 0x20 },
|
|
|
|
{ ACI_SET_LINE1 + 0, 0x20 },
|
|
|
|
{ ACI_SET_LINE1 + 8, 0x20 },
|
|
|
|
{ ACI_SET_LINE2 + 0, 0x20 },
|
|
|
|
{ ACI_SET_LINE2 + 8, 0x20 },
|
|
|
|
{ ACI_SET_SYNTH + 0, 0x20 },
|
|
|
|
{ ACI_SET_SYNTH + 8, 0x20 },
|
|
|
|
{ ACI_SET_MASTER + 0, 0x20 },
|
|
|
|
{ ACI_SET_MASTER + 1, 0x20 },
|
|
|
|
};
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_set_aci_init_values(struct snd_miro *miro)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
int idx, error;
|
2009-11-23 00:26:34 +08:00
|
|
|
struct snd_miro_aci *aci = miro->aci;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
/* enable WSS on PCM1 */
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if ((aci->aci_product == 'A') && wss) {
|
|
|
|
error = aci_setvalue(aci, ACI_SET_WSS, wss);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "enabling WSS mode failed\n");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable IDE port */
|
|
|
|
|
|
|
|
if (ide) {
|
2009-11-23 00:26:34 +08:00
|
|
|
error = aci_setvalue(aci, ACI_SET_IDE, ide);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "enabling IDE port failed\n");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set common aci values */
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) {
|
|
|
|
error = aci_setvalue(aci, aci_init_values[idx][0],
|
|
|
|
aci_init_values[idx][1]);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n",
|
|
|
|
aci_init_values[idx][0], error);
|
|
|
|
return error;
|
|
|
|
}
|
2009-11-23 00:26:34 +08:00
|
|
|
}
|
|
|
|
aci->aci_amp = 0;
|
|
|
|
aci->aci_preamp = 0;
|
|
|
|
aci->aci_solomode = 1;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_mixer(struct snd_card *card,
|
|
|
|
struct snd_miro *miro)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
unsigned int idx;
|
|
|
|
int err;
|
|
|
|
|
2009-11-21 08:01:18 +08:00
|
|
|
if (snd_BUG_ON(!miro || !card))
|
2008-08-08 23:11:45 +08:00
|
|
|
return -EINVAL;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
switch (miro->hardware) {
|
|
|
|
case OPTi9XX_HW_82C924:
|
|
|
|
strcpy(card->mixername, "ACI & OPTi924");
|
|
|
|
break;
|
|
|
|
case OPTi9XX_HW_82C929:
|
|
|
|
strcpy(card->mixername, "ACI & OPTi929");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_BUG();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_miro_controls); idx++) {
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_controls[idx], miro))) < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if ((miro->aci->aci_product == 'A') ||
|
|
|
|
(miro->aci->aci_product == 'B')) {
|
2006-03-27 18:41:01 +08:00
|
|
|
/* PCM1/PCM12 with power-amp and Line 2 */
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0)
|
|
|
|
return err;
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_amp_control[0], miro))) < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if ((miro->aci->aci_product == 'B') ||
|
|
|
|
(miro->aci->aci_product == 'C')) {
|
2006-03-27 18:41:01 +08:00
|
|
|
/* PCM12/PCM20 with mic-preamp */
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0)
|
|
|
|
return err;
|
2009-11-23 00:26:34 +08:00
|
|
|
if (miro->aci->aci_version >= 176)
|
2006-03-27 18:41:01 +08:00
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if (miro->aci->aci_product == 'C') {
|
2006-03-27 18:41:01 +08:00
|
|
|
/* PCM20 with radio and 7 band equalizer */
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0)
|
|
|
|
return err;
|
|
|
|
for (idx = 0; idx < ARRAY_SIZE(snd_miro_eq_controls); idx++) {
|
|
|
|
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_eq_controls[idx], miro))) < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_init(struct snd_miro *chip,
|
|
|
|
unsigned short hardware)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
2020-01-05 22:48:05 +08:00
|
|
|
static const int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
chip->hardware = hardware;
|
|
|
|
strcpy(chip->name, snd_opti9xx_names[hardware]);
|
|
|
|
|
|
|
|
chip->mc_base_size = opti9xx_mc_size[hardware];
|
|
|
|
|
|
|
|
spin_lock_init(&chip->lock);
|
|
|
|
|
|
|
|
chip->wss_base = -1;
|
|
|
|
chip->irq = -1;
|
|
|
|
chip->dma1 = -1;
|
|
|
|
chip->dma2 = -1;
|
|
|
|
chip->mpu_port = -1;
|
|
|
|
chip->mpu_irq = -1;
|
|
|
|
|
2009-11-30 14:46:56 +08:00
|
|
|
chip->pwd_reg = 3;
|
|
|
|
|
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
if (isapnp && chip->mc_base)
|
|
|
|
/* PnP resource gives the least 10 bits */
|
|
|
|
chip->mc_base |= 0xc00;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
chip->mc_base = 0xf8c;
|
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
switch (hardware) {
|
|
|
|
case OPTi9XX_HW_82C929:
|
|
|
|
chip->password = 0xe3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTi9XX_HW_82C924:
|
|
|
|
chip->password = 0xe5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "sorry, no support for %d\n", hardware);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char snd_miro_read(struct snd_miro *chip,
|
|
|
|
unsigned char reg)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned char retval = 0xff;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->lock, flags);
|
|
|
|
outb(chip->password, chip->mc_base + chip->pwd_reg);
|
|
|
|
|
|
|
|
switch (chip->hardware) {
|
|
|
|
case OPTi9XX_HW_82C924:
|
|
|
|
if (reg > 7) {
|
|
|
|
outb(reg, chip->mc_base + 8);
|
|
|
|
outb(chip->password, chip->mc_base + chip->pwd_reg);
|
|
|
|
retval = inb(chip->mc_base + 9);
|
|
|
|
break;
|
|
|
|
}
|
2018-08-03 04:41:55 +08:00
|
|
|
/* fall through */
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
case OPTi9XX_HW_82C929:
|
|
|
|
retval = inb(chip->mc_base + reg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "sorry, no support for %d\n", chip->hardware);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&chip->lock, flags);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void snd_miro_write(struct snd_miro *chip, unsigned char reg,
|
|
|
|
unsigned char value)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->lock, flags);
|
|
|
|
outb(chip->password, chip->mc_base + chip->pwd_reg);
|
|
|
|
|
|
|
|
switch (chip->hardware) {
|
|
|
|
case OPTi9XX_HW_82C924:
|
|
|
|
if (reg > 7) {
|
|
|
|
outb(reg, chip->mc_base + 8);
|
|
|
|
outb(chip->password, chip->mc_base + chip->pwd_reg);
|
|
|
|
outb(value, chip->mc_base + 9);
|
|
|
|
break;
|
|
|
|
}
|
2018-08-03 04:41:55 +08:00
|
|
|
/* fall through */
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
case OPTi9XX_HW_82C929:
|
|
|
|
outb(value, chip->mc_base + reg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "sorry, no support for %d\n", chip->hardware);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&chip->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define snd_miro_write_mask(chip, reg, value, mask) \
|
|
|
|
snd_miro_write(chip, reg, \
|
|
|
|
(snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask)))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Proc Interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void snd_miro_proc_read(struct snd_info_entry * entry,
|
|
|
|
struct snd_info_buffer *buffer)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = (struct snd_miro *) entry->private_data;
|
2009-11-23 00:26:34 +08:00
|
|
|
struct snd_miro_aci *aci = miro->aci;
|
2006-03-27 18:41:01 +08:00
|
|
|
char* model = "unknown";
|
|
|
|
|
|
|
|
/* miroSOUND PCM1 pro, early PCM12 */
|
|
|
|
|
|
|
|
if ((miro->hardware == OPTi9XX_HW_82C929) &&
|
2009-11-23 00:26:34 +08:00
|
|
|
(aci->aci_vendor == 'm') &&
|
|
|
|
(aci->aci_product == 'A')) {
|
|
|
|
switch (aci->aci_version) {
|
2006-03-27 18:41:01 +08:00
|
|
|
case 3:
|
|
|
|
model = "miroSOUND PCM1 pro";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
model = "miroSOUND PCM1 pro / (early) PCM12";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */
|
|
|
|
|
|
|
|
if ((miro->hardware == OPTi9XX_HW_82C924) &&
|
2009-11-23 00:26:34 +08:00
|
|
|
(aci->aci_vendor == 'm') &&
|
|
|
|
(aci->aci_product == 'B')) {
|
|
|
|
switch (aci->aci_version) {
|
2006-03-27 18:41:01 +08:00
|
|
|
case 4:
|
|
|
|
model = "miroSOUND PCM12";
|
|
|
|
break;
|
|
|
|
case 176:
|
|
|
|
model = "miroSOUND PCM12 (Rev. E)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
model = "miroSOUND PCM12 / PCM12 pnp";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* miroSOUND PCM20 radio */
|
|
|
|
|
|
|
|
if ((miro->hardware == OPTi9XX_HW_82C924) &&
|
2009-11-23 00:26:34 +08:00
|
|
|
(aci->aci_vendor == 'm') &&
|
|
|
|
(aci->aci_product == 'C')) {
|
|
|
|
switch (aci->aci_version) {
|
2006-03-27 18:41:01 +08:00
|
|
|
case 7:
|
|
|
|
model = "miroSOUND PCM20 radio (Rev. E)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
model = "miroSOUND PCM20 radio";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_iprintf(buffer, "\nGeneral information:\n");
|
|
|
|
snd_iprintf(buffer, " model : %s\n", model);
|
|
|
|
snd_iprintf(buffer, " opti : %s\n", miro->name);
|
|
|
|
snd_iprintf(buffer, " codec : %s\n", miro->pcm->name);
|
|
|
|
snd_iprintf(buffer, " port : 0x%lx\n", miro->wss_base);
|
|
|
|
snd_iprintf(buffer, " irq : %d\n", miro->irq);
|
|
|
|
snd_iprintf(buffer, " dma : %d,%d\n\n", miro->dma1, miro->dma2);
|
|
|
|
|
|
|
|
snd_iprintf(buffer, "MPU-401:\n");
|
|
|
|
snd_iprintf(buffer, " port : 0x%lx\n", miro->mpu_port);
|
|
|
|
snd_iprintf(buffer, " irq : %d\n\n", miro->mpu_irq);
|
|
|
|
|
|
|
|
snd_iprintf(buffer, "ACI information:\n");
|
|
|
|
snd_iprintf(buffer, " vendor : ");
|
2009-11-23 00:26:34 +08:00
|
|
|
switch (aci->aci_vendor) {
|
2006-03-27 18:41:01 +08:00
|
|
|
case 'm':
|
|
|
|
snd_iprintf(buffer, "Miro\n");
|
|
|
|
break;
|
|
|
|
default:
|
2009-11-23 00:26:34 +08:00
|
|
|
snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_vendor);
|
2006-03-27 18:41:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_iprintf(buffer, " product : ");
|
2009-11-23 00:26:34 +08:00
|
|
|
switch (aci->aci_product) {
|
2006-03-27 18:41:01 +08:00
|
|
|
case 'A':
|
|
|
|
snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n");
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
snd_iprintf(buffer, "miroSOUND PCM12\n");
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
snd_iprintf(buffer, "miroSOUND PCM20 radio\n");
|
|
|
|
break;
|
|
|
|
default:
|
2009-11-23 00:26:34 +08:00
|
|
|
snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_product);
|
2006-03-27 18:41:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_iprintf(buffer, " firmware: %d (0x%x)\n",
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_version, aci->aci_version);
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_iprintf(buffer, " port : 0x%lx-0x%lx\n",
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_port, aci->aci_port+2);
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_iprintf(buffer, " wss : 0x%x\n", wss);
|
|
|
|
snd_iprintf(buffer, " ide : 0x%x\n", ide);
|
2009-11-23 00:26:34 +08:00
|
|
|
snd_iprintf(buffer, " solomode: 0x%x\n", aci->aci_solomode);
|
|
|
|
snd_iprintf(buffer, " amp : 0x%x\n", aci->aci_amp);
|
|
|
|
snd_iprintf(buffer, " preamp : 0x%x\n", aci->aci_preamp);
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static void snd_miro_proc_init(struct snd_card *card,
|
|
|
|
struct snd_miro *miro)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
2019-02-04 23:00:13 +08:00
|
|
|
snd_card_ro_proc_new(card, "miro", miro, snd_miro_proc_read);
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Init
|
|
|
|
*/
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_configure(struct snd_miro *chip)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
unsigned char wss_base_bits;
|
|
|
|
unsigned char irq_bits;
|
|
|
|
unsigned char dma_bits;
|
|
|
|
unsigned char mpu_port_bits = 0;
|
|
|
|
unsigned char mpu_irq_bits;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-11-21 08:01:18 +08:00
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80);
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02);
|
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
switch (chip->hardware) {
|
|
|
|
case OPTi9XX_HW_82C924:
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02);
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
|
|
|
|
break;
|
|
|
|
case OPTi9XX_HW_82C929:
|
|
|
|
/* untested init commands for OPTi929 */
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-11-30 14:46:56 +08:00
|
|
|
/* PnP resource says it decodes only 10 bits of address */
|
|
|
|
switch (chip->wss_base & 0x3ff) {
|
|
|
|
case 0x130:
|
|
|
|
chip->wss_base = 0x530;
|
2006-03-27 18:41:01 +08:00
|
|
|
wss_base_bits = 0x00;
|
|
|
|
break;
|
2009-11-30 14:46:56 +08:00
|
|
|
case 0x204:
|
|
|
|
chip->wss_base = 0x604;
|
2006-03-27 18:41:01 +08:00
|
|
|
wss_base_bits = 0x03;
|
|
|
|
break;
|
2009-11-30 14:46:56 +08:00
|
|
|
case 0x280:
|
|
|
|
chip->wss_base = 0xe80;
|
2006-03-27 18:41:01 +08:00
|
|
|
wss_base_bits = 0x01;
|
|
|
|
break;
|
2009-11-30 14:46:56 +08:00
|
|
|
case 0x340:
|
|
|
|
chip->wss_base = 0xf40;
|
2006-03-27 18:41:01 +08:00
|
|
|
wss_base_bits = 0x02;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "WSS port 0x%lx not valid\n", chip->wss_base);
|
|
|
|
goto __skip_base;
|
|
|
|
}
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30);
|
|
|
|
|
|
|
|
__skip_base:
|
|
|
|
switch (chip->irq) {
|
|
|
|
case 5:
|
|
|
|
irq_bits = 0x05;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
irq_bits = 0x01;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
irq_bits = 0x02;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
irq_bits = 0x03;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
irq_bits = 0x04;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "WSS irq # %d not valid\n", chip->irq);
|
|
|
|
goto __skip_resources;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (chip->dma1) {
|
|
|
|
case 0:
|
|
|
|
dma_bits = 0x01;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
dma_bits = 0x02;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
dma_bits = 0x03;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "WSS dma1 # %d not valid\n", chip->dma1);
|
|
|
|
goto __skip_resources;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chip->dma1 == chip->dma2) {
|
|
|
|
snd_printk(KERN_ERR "don't want to share dmas\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (chip->dma2) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "WSS dma2 # %d not valid\n", chip->dma2);
|
|
|
|
goto __skip_resources;
|
|
|
|
}
|
|
|
|
dma_bits |= 0x04;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->lock, flags);
|
|
|
|
outb(irq_bits << 3 | dma_bits, chip->wss_base);
|
|
|
|
spin_unlock_irqrestore(&chip->lock, flags);
|
|
|
|
|
|
|
|
__skip_resources:
|
|
|
|
if (chip->hardware > OPTi9XX_HW_82C928) {
|
|
|
|
switch (chip->mpu_port) {
|
|
|
|
case 0:
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
case 0x300:
|
|
|
|
mpu_port_bits = 0x03;
|
|
|
|
break;
|
|
|
|
case 0x310:
|
|
|
|
mpu_port_bits = 0x02;
|
|
|
|
break;
|
|
|
|
case 0x320:
|
|
|
|
mpu_port_bits = 0x01;
|
|
|
|
break;
|
|
|
|
case 0x330:
|
|
|
|
mpu_port_bits = 0x00;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "MPU-401 port 0x%lx not valid\n",
|
|
|
|
chip->mpu_port);
|
|
|
|
goto __skip_mpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (chip->mpu_irq) {
|
|
|
|
case 5:
|
|
|
|
mpu_irq_bits = 0x02;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
mpu_irq_bits = 0x03;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
mpu_irq_bits = 0x00;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
mpu_irq_bits = 0x01;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snd_printk(KERN_ERR "MPU-401 irq # %d not valid\n",
|
|
|
|
chip->mpu_irq);
|
|
|
|
goto __skip_mpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_miro_write_mask(chip, OPTi9XX_MC_REG(6),
|
|
|
|
(chip->mpu_port <= 0) ? 0x00 :
|
|
|
|
0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3,
|
|
|
|
0xf8);
|
|
|
|
}
|
|
|
|
__skip_mpu:
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_opti_check(struct snd_miro *chip)
|
2009-11-30 14:45:47 +08:00
|
|
|
{
|
|
|
|
unsigned char value;
|
|
|
|
|
|
|
|
chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
|
|
|
|
"OPTi9xx MC");
|
|
|
|
if (chip->res_mc_base == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
value = snd_miro_read(chip, OPTi9XX_MC_REG(1));
|
|
|
|
if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1)))
|
|
|
|
if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
release_and_free_resource(chip->res_mc_base);
|
|
|
|
chip->res_mc_base = NULL;
|
|
|
|
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_card_miro_detect(struct snd_card *card,
|
|
|
|
struct snd_miro *chip)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
|
|
|
|
for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) {
|
|
|
|
|
|
|
|
if ((err = snd_miro_init(chip, i)) < 0)
|
|
|
|
return err;
|
|
|
|
|
2009-11-30 14:45:47 +08:00
|
|
|
err = snd_miro_opti_check(chip);
|
|
|
|
if (err == 0)
|
|
|
|
return 1;
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_card_miro_aci_detect(struct snd_card *card,
|
|
|
|
struct snd_miro *miro)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
unsigned char regval;
|
|
|
|
int i;
|
2009-11-23 00:26:34 +08:00
|
|
|
struct snd_miro_aci *aci = &aci_device;
|
|
|
|
|
|
|
|
miro->aci = aci;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
mutex_init(&aci->aci_mutex);
|
2006-03-27 18:41:01 +08:00
|
|
|
|
|
|
|
/* get ACI port from OPTi9xx MC 4 */
|
|
|
|
|
|
|
|
regval=inb(miro->mc_base + 4);
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_port = (regval & 0x10) ? 0x344 : 0x354;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
miro->res_aci_port = request_region(aci->aci_port, 3, "miro aci");
|
|
|
|
if (miro->res_aci_port == NULL) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n",
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_port, aci->aci_port+2);
|
2006-03-27 18:41:01 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* force ACI into a known state */
|
|
|
|
for (i = 0; i < 3; i++)
|
2009-11-23 00:26:34 +08:00
|
|
|
if (snd_aci_cmd(aci, ACI_ERROR_OP, -1, -1) < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "can't force aci into known state.\n");
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_vendor = snd_aci_cmd(aci, ACI_READ_IDCODE, -1, -1);
|
|
|
|
aci->aci_product = snd_aci_cmd(aci, ACI_READ_IDCODE, -1, -1);
|
|
|
|
if (aci->aci_vendor < 0 || aci->aci_product < 0) {
|
|
|
|
snd_printk(KERN_ERR "can't read aci id on 0x%lx.\n",
|
|
|
|
aci->aci_port);
|
2006-03-27 18:41:01 +08:00
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_version = snd_aci_cmd(aci, ACI_READ_VERSION, -1, -1);
|
|
|
|
if (aci->aci_version < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n",
|
2009-11-23 00:26:34 +08:00
|
|
|
aci->aci_port);
|
2006-03-27 18:41:01 +08:00
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if (snd_aci_cmd(aci, ACI_INIT, -1, -1) < 0 ||
|
|
|
|
snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0 ||
|
|
|
|
snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "can't initialize aci.\n");
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void snd_card_miro_free(struct snd_card *card)
|
|
|
|
{
|
|
|
|
struct snd_miro *miro = card->private_data;
|
2009-11-30 14:46:56 +08:00
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
release_and_free_resource(miro->res_aci_port);
|
2009-11-27 18:20:56 +08:00
|
|
|
if (miro->aci)
|
|
|
|
miro->aci->aci_port = 0;
|
2006-03-27 18:41:01 +08:00
|
|
|
release_and_free_resource(miro->res_mc_base);
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_probe(struct snd_card *card)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
|
|
|
int error;
|
2009-11-30 14:45:47 +08:00
|
|
|
struct snd_miro *miro = card->private_data;
|
2008-08-01 03:03:41 +08:00
|
|
|
struct snd_wss *codec;
|
2006-03-27 18:41:01 +08:00
|
|
|
struct snd_rawmidi *rmidi;
|
|
|
|
|
2009-11-30 14:45:47 +08:00
|
|
|
if (!miro->res_mc_base) {
|
|
|
|
miro->res_mc_base = request_region(miro->mc_base,
|
|
|
|
miro->mc_base_size,
|
|
|
|
"miro (OPTi9xx MC)");
|
|
|
|
if (miro->res_mc_base == NULL) {
|
|
|
|
snd_printk(KERN_ERR "request for OPTI9xx MC failed\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2009-11-21 08:01:18 +08:00
|
|
|
}
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-30 14:45:47 +08:00
|
|
|
error = snd_card_miro_aci_detect(card, miro);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_printk(KERN_ERR "unable to detect aci chip\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
miro->wss_base = port;
|
2009-11-30 14:45:47 +08:00
|
|
|
miro->mpu_port = mpu_port;
|
2006-03-27 18:41:01 +08:00
|
|
|
miro->irq = irq;
|
|
|
|
miro->mpu_irq = mpu_irq;
|
|
|
|
miro->dma1 = dma1;
|
|
|
|
miro->dma2 = dma2;
|
|
|
|
|
2009-11-30 14:45:47 +08:00
|
|
|
/* init proc interface */
|
|
|
|
snd_miro_proc_init(card, miro);
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2008-08-01 03:03:41 +08:00
|
|
|
error = snd_miro_configure(miro);
|
2009-11-30 14:45:47 +08:00
|
|
|
if (error)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
|
|
|
|
2008-08-01 03:03:41 +08:00
|
|
|
error = snd_wss_create(card, miro->wss_base + 4, -1,
|
2009-11-30 14:45:47 +08:00
|
|
|
miro->irq, miro->dma1, miro->dma2,
|
|
|
|
WSS_HW_DETECT, 0, &codec);
|
|
|
|
if (error < 0)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
|
|
|
|
2015-01-02 19:24:43 +08:00
|
|
|
error = snd_wss_pcm(codec, 0);
|
2009-11-30 14:45:47 +08:00
|
|
|
if (error < 0)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
2009-11-30 14:45:47 +08:00
|
|
|
|
2008-08-01 03:03:41 +08:00
|
|
|
error = snd_wss_mixer(codec);
|
2009-11-30 14:45:47 +08:00
|
|
|
if (error < 0)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
2009-11-30 14:45:47 +08:00
|
|
|
|
2015-01-02 19:24:43 +08:00
|
|
|
error = snd_wss_timer(codec, 0);
|
2009-11-30 14:45:47 +08:00
|
|
|
if (error < 0)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
|
|
|
|
2015-01-02 19:24:43 +08:00
|
|
|
miro->pcm = codec->pcm;
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-21 08:01:18 +08:00
|
|
|
error = snd_miro_mixer(card, miro);
|
2009-11-30 14:45:47 +08:00
|
|
|
if (error < 0)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
|
|
|
|
2009-11-23 00:26:34 +08:00
|
|
|
if (miro->aci->aci_vendor == 'm') {
|
2006-03-27 18:41:01 +08:00
|
|
|
/* It looks like a miro sound card. */
|
2009-11-23 00:26:34 +08:00
|
|
|
switch (miro->aci->aci_product) {
|
2006-03-27 18:41:01 +08:00
|
|
|
case 'A':
|
|
|
|
sprintf(card->shortname,
|
|
|
|
"miroSOUND PCM1 pro / PCM12");
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
sprintf(card->shortname,
|
|
|
|
"miroSOUND PCM12");
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
sprintf(card->shortname,
|
|
|
|
"miroSOUND PCM20 radio");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(card->shortname,
|
|
|
|
"unknown miro");
|
|
|
|
snd_printk(KERN_INFO "unknown miro aci id\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
snd_printk(KERN_INFO "found unsupported aci card\n");
|
|
|
|
sprintf(card->shortname, "unknown Cardinal Technologies");
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(card->driver, "miro");
|
ALSA: opti9xx: fix format string overflow warning
We pass a long name from "codec->pcm->name" into the longname
string of the same length:
sound/isa/opti9xx/miro.c: In function 'snd_miro_probe':
sound/isa/opti9xx/miro.c:1356:39: error: '%s' directive writing up to 79 bytes into a region of size between 35 and 72 [-Werror=format-overflow=]
sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
^~
sound/isa/opti9xx/miro.c:1356:26: note: using the range [0, 4294967295] for directive argument
sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/isa/opti9xx/miro.c:1356:2: note: 'sprintf' output between 32 and 185 bytes into a destination of size 80
sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
There is no easy way to avoid the theoretical overflow in this case,
but using snprintf() will turn it into a harmless truncation.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-07-18 19:48:07 +08:00
|
|
|
snprintf(card->longname, sizeof(card->longname),
|
|
|
|
"%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
|
|
|
|
card->shortname, miro->name, codec->pcm->name,
|
|
|
|
miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2);
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-18 01:35:41 +08:00
|
|
|
if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)
|
2006-03-27 18:41:01 +08:00
|
|
|
rmidi = NULL;
|
2009-11-18 01:35:41 +08:00
|
|
|
else {
|
|
|
|
error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
|
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 17:24:41 +08:00
|
|
|
mpu_port, 0, miro->mpu_irq, &rmidi);
|
2009-11-18 01:35:41 +08:00
|
|
|
if (error < 0)
|
|
|
|
snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
|
|
|
|
mpu_port);
|
|
|
|
}
|
2006-03-27 18:41:01 +08:00
|
|
|
|
2009-11-18 01:35:41 +08:00
|
|
|
if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) {
|
2006-03-27 18:41:01 +08:00
|
|
|
struct snd_opl3 *opl3 = NULL;
|
|
|
|
struct snd_opl4 *opl4;
|
2009-11-30 14:45:47 +08:00
|
|
|
|
2009-11-18 01:35:41 +08:00
|
|
|
if (snd_opl4_create(card, fm_port, fm_port - 8,
|
2006-03-27 18:41:01 +08:00
|
|
|
2, &opl3, &opl4) < 0)
|
2009-11-18 01:35:41 +08:00
|
|
|
snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n",
|
|
|
|
fm_port);
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
2009-11-30 14:45:47 +08:00
|
|
|
error = snd_set_aci_init_values(miro);
|
|
|
|
if (error < 0)
|
2006-03-27 18:41:01 +08:00
|
|
|
return error;
|
2009-11-30 14:45:47 +08:00
|
|
|
|
|
|
|
return snd_card_register(card);
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_isa_match(struct device *devptr, unsigned int n)
|
2009-11-30 14:45:47 +08:00
|
|
|
{
|
2009-11-30 14:46:56 +08:00
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
if (snd_miro_pnp_is_probed)
|
|
|
|
return 0;
|
|
|
|
if (isapnp)
|
|
|
|
return 0;
|
|
|
|
#endif
|
2009-11-30 14:45:47 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_isa_probe(struct device *devptr, unsigned int n)
|
2009-11-30 14:45:47 +08:00
|
|
|
{
|
2020-01-05 22:48:05 +08:00
|
|
|
static const long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
|
|
|
|
static const long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1};
|
|
|
|
static const int possible_irqs[] = {11, 9, 10, 7, -1};
|
|
|
|
static const int possible_mpu_irqs[] = {10, 5, 9, 7, -1};
|
|
|
|
static const int possible_dma1s[] = {3, 1, 0, -1};
|
|
|
|
static const int possible_dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1},
|
2009-11-30 14:45:47 +08:00
|
|
|
{0, -1} };
|
|
|
|
|
|
|
|
int error;
|
|
|
|
struct snd_miro *miro;
|
|
|
|
struct snd_card *card;
|
|
|
|
|
2014-01-29 20:03:56 +08:00
|
|
|
error = snd_card_new(devptr, index, id, THIS_MODULE,
|
|
|
|
sizeof(struct snd_miro), &card);
|
2009-11-30 14:45:47 +08:00
|
|
|
if (error < 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
card->private_free = snd_card_miro_free;
|
|
|
|
miro = card->private_data;
|
|
|
|
|
|
|
|
error = snd_card_miro_detect(card, miro);
|
|
|
|
if (error < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port == SNDRV_AUTO_PORT) {
|
|
|
|
port = snd_legacy_find_free_ioport(possible_ports, 4);
|
|
|
|
if (port < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR "unable to find a free WSS port\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mpu_port == SNDRV_AUTO_PORT) {
|
|
|
|
mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2);
|
|
|
|
if (mpu_port < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR
|
|
|
|
"unable to find a free MPU401 port\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (irq == SNDRV_AUTO_IRQ) {
|
|
|
|
irq = snd_legacy_find_free_irq(possible_irqs);
|
|
|
|
if (irq < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR "unable to find a free IRQ\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mpu_irq == SNDRV_AUTO_IRQ) {
|
|
|
|
mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs);
|
|
|
|
if (mpu_irq < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR
|
|
|
|
"unable to find a free MPU401 IRQ\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dma1 == SNDRV_AUTO_DMA) {
|
|
|
|
dma1 = snd_legacy_find_free_dma(possible_dma1s);
|
|
|
|
if (dma1 < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR "unable to find a free DMA1\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dma2 == SNDRV_AUTO_DMA) {
|
|
|
|
dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4]);
|
|
|
|
if (dma2 < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
snd_printk(KERN_ERR "unable to find a free DMA2\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
2009-11-30 14:45:47 +08:00
|
|
|
error = snd_miro_probe(card);
|
|
|
|
if (error < 0) {
|
2006-03-27 18:41:01 +08:00
|
|
|
snd_card_free(card);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-02-22 19:50:54 +08:00
|
|
|
dev_set_drvdata(devptr, card);
|
2006-03-27 18:41:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_isa_remove(struct device *devptr,
|
|
|
|
unsigned int dev)
|
2006-03-27 18:41:01 +08:00
|
|
|
{
|
2007-02-22 19:50:54 +08:00
|
|
|
snd_card_free(dev_get_drvdata(devptr));
|
2006-03-27 18:41:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-20 18:33:46 +08:00
|
|
|
#define DEV_NAME "miro"
|
|
|
|
|
2007-02-22 19:50:54 +08:00
|
|
|
static struct isa_driver snd_miro_driver = {
|
2009-11-30 14:45:47 +08:00
|
|
|
.match = snd_miro_isa_match,
|
|
|
|
.probe = snd_miro_isa_probe,
|
2012-12-07 01:35:21 +08:00
|
|
|
.remove = snd_miro_isa_remove,
|
2006-03-27 18:41:01 +08:00
|
|
|
/* FIXME: suspend/resume */
|
|
|
|
.driver = {
|
2007-03-20 18:33:46 +08:00
|
|
|
.name = DEV_NAME
|
2006-03-27 18:41:01 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-11-30 14:46:56 +08:00
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_card_miro_pnp(struct snd_miro *chip,
|
|
|
|
struct pnp_card_link *card,
|
|
|
|
const struct pnp_card_device_id *pid)
|
2009-11-30 14:46:56 +08:00
|
|
|
{
|
|
|
|
struct pnp_dev *pdev;
|
|
|
|
int err;
|
|
|
|
struct pnp_dev *devmpu;
|
|
|
|
struct pnp_dev *devmc;
|
|
|
|
|
|
|
|
pdev = pnp_request_card_device(card, pid->devs[0].id, NULL);
|
|
|
|
if (pdev == NULL)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL);
|
|
|
|
if (devmpu == NULL)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
devmc = pnp_request_card_device(card, pid->devs[2].id, NULL);
|
|
|
|
if (devmc == NULL)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
err = pnp_activate_dev(pdev);
|
|
|
|
if (err < 0) {
|
|
|
|
snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = pnp_activate_dev(devmc);
|
|
|
|
if (err < 0) {
|
2010-03-04 02:41:44 +08:00
|
|
|
snd_printk(KERN_ERR "MC pnp configure failure: %d\n",
|
2009-11-30 14:46:56 +08:00
|
|
|
err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
port = pnp_port_start(pdev, 1);
|
|
|
|
fm_port = pnp_port_start(pdev, 2) + 8;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The MC(0) is never accessed and the miroSOUND PCM20 card does not
|
|
|
|
* include it in the PnP resource range. OPTI93x include it.
|
|
|
|
*/
|
|
|
|
chip->mc_base = pnp_port_start(devmc, 0) - 1;
|
|
|
|
chip->mc_base_size = pnp_port_len(devmc, 0) + 1;
|
|
|
|
|
|
|
|
irq = pnp_irq(pdev, 0);
|
|
|
|
dma1 = pnp_dma(pdev, 0);
|
|
|
|
dma2 = pnp_dma(pdev, 1);
|
|
|
|
|
|
|
|
if (mpu_port > 0) {
|
|
|
|
err = pnp_activate_dev(devmpu);
|
|
|
|
if (err < 0) {
|
|
|
|
snd_printk(KERN_ERR "MPU401 pnp configure failure\n");
|
|
|
|
mpu_port = -1;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
mpu_port = pnp_port_start(devmpu, 0);
|
|
|
|
mpu_irq = pnp_irq(devmpu, 0);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static int snd_miro_pnp_probe(struct pnp_card_link *pcard,
|
|
|
|
const struct pnp_card_device_id *pid)
|
2009-11-30 14:46:56 +08:00
|
|
|
{
|
|
|
|
struct snd_card *card;
|
|
|
|
int err;
|
|
|
|
struct snd_miro *miro;
|
|
|
|
|
|
|
|
if (snd_miro_pnp_is_probed)
|
|
|
|
return -EBUSY;
|
|
|
|
if (!isapnp)
|
|
|
|
return -ENODEV;
|
2014-01-29 20:03:56 +08:00
|
|
|
err = snd_card_new(&pcard->card->dev, index, id, THIS_MODULE,
|
|
|
|
sizeof(struct snd_miro), &card);
|
2009-11-30 14:46:56 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
card->private_free = snd_card_miro_free;
|
|
|
|
miro = card->private_data;
|
|
|
|
|
|
|
|
err = snd_card_miro_pnp(miro, pcard, pid);
|
|
|
|
if (err) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only miroSOUND PCM20 and PCM12 == OPTi924 */
|
|
|
|
err = snd_miro_init(miro, OPTi9XX_HW_82C924);
|
|
|
|
if (err) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = snd_miro_opti_check(miro);
|
|
|
|
if (err) {
|
|
|
|
snd_printk(KERN_ERR "OPTI chip not found\n");
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = snd_miro_probe(card);
|
|
|
|
if (err < 0) {
|
|
|
|
snd_card_free(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
pnp_set_card_drvdata(pcard, card);
|
|
|
|
snd_miro_pnp_is_probed = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:35:21 +08:00
|
|
|
static void snd_miro_pnp_remove(struct pnp_card_link *pcard)
|
2009-11-30 14:46:56 +08:00
|
|
|
{
|
|
|
|
snd_card_free(pnp_get_card_drvdata(pcard));
|
|
|
|
pnp_set_card_drvdata(pcard, NULL);
|
|
|
|
snd_miro_pnp_is_probed = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pnp_card_driver miro_pnpc_driver = {
|
|
|
|
.flags = PNP_DRIVER_RES_DISABLE,
|
|
|
|
.name = "miro",
|
|
|
|
.id_table = snd_miro_pnpids,
|
|
|
|
.probe = snd_miro_pnp_probe,
|
2012-12-07 01:35:21 +08:00
|
|
|
.remove = snd_miro_pnp_remove,
|
2009-11-30 14:46:56 +08:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2006-03-27 18:41:01 +08:00
|
|
|
static int __init alsa_card_miro_init(void)
|
|
|
|
{
|
2009-11-30 14:46:56 +08:00
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
pnp_register_card_driver(&miro_pnpc_driver);
|
|
|
|
if (snd_miro_pnp_is_probed)
|
|
|
|
return 0;
|
|
|
|
pnp_unregister_card_driver(&miro_pnpc_driver);
|
|
|
|
#endif
|
2007-02-22 19:50:54 +08:00
|
|
|
return isa_register_driver(&snd_miro_driver, 1);
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit alsa_card_miro_exit(void)
|
|
|
|
{
|
2009-11-30 14:46:56 +08:00
|
|
|
if (!snd_miro_pnp_is_probed) {
|
|
|
|
isa_unregister_driver(&snd_miro_driver);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_PNP
|
|
|
|
pnp_unregister_card_driver(&miro_pnpc_driver);
|
|
|
|
#endif
|
2006-03-27 18:41:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(alsa_card_miro_init)
|
|
|
|
module_exit(alsa_card_miro_exit)
|