Commit a49e82a5 authored by Vojtech Pavlik's avatar Vojtech Pavlik

Updates and fixes for sound drivers to handle gameports better.

Make gameport support unconditional for es1370 and es1371.
Fix amplifier command line option handling for es1371.
Make gameport support default for mad16.
Add ADC gameport support to trident.c
Add proper dependencies to Config.in
parent 71339646
......@@ -48,7 +48,7 @@ fi
if [ "$CONFIG_DDB5477" = "y" ]; then
dep_tristate ' NEC Vrc5477 AC97 sound' CONFIG_SOUND_VRC5477 $CONFIG_SOUND
fi
dep_tristate ' Trident 4DWave DX/NX, SiS 7018 or ALi 5451 PCI Audio Core' CONFIG_SOUND_TRIDENT $CONFIG_SOUND
dep_tristate ' Trident 4DWave DX/NX, SiS 7018 or ALi 5451 PCI Audio Core' CONFIG_SOUND_TRIDENT $CONFIG_SOUND $CONFIG_SOUND_GAMEPORT
dep_tristate ' Support for Turtle Beach MultiSound Classic, Tahiti, Monterey' CONFIG_SOUND_MSNDCLAS $CONFIG_SOUND
if [ "$CONFIG_SOUND_MSNDCLAS" = "y" -o "$CONFIG_SOUND_MSNDCLAS" = "m" ]; then
......@@ -134,7 +134,7 @@ if [ "$CONFIG_SOUND_OSS" = "y" -o "$CONFIG_SOUND_OSS" = "m" ]; then
dep_tristate ' Microsoft Sound System support' CONFIG_SOUND_MSS $CONFIG_SOUND_OSS
dep_tristate ' MPU-401 support (NOT for SB16)' CONFIG_SOUND_MPU401 $CONFIG_SOUND_OSS
dep_tristate ' NM256AV/NM256ZX audio support' CONFIG_SOUND_NM256 $CONFIG_SOUND_OSS
dep_tristate ' OPTi MAD16 and/or Mozart based cards' CONFIG_SOUND_MAD16 $CONFIG_SOUND_OSS
dep_tristate ' OPTi MAD16 and/or Mozart based cards' CONFIG_SOUND_MAD16 $CONFIG_SOUND_OSS $CONFIG_SOUND_GAMEPORT
if [ "$CONFIG_SOUND_MAD16" = "y" -o "$CONFIG_SOUND_MAD16" = "m" ]; then
bool ' Support MIDI in older MAD16 based cards (requires SB)' CONFIG_MAD16_OLDCARD
fi
......
......@@ -23,11 +23,6 @@
*
*
* Module command line parameters:
* joystick if 1 enables the joystick interface on the card; but it still
* needs a driver for joysticks connected to a standard IBM-PC
* joyport. It is tested with the joy-analog driver. This
* module must be loaded before the joystick driver. Kmod will
* not ensure that.
* lineout if 1 the LINE jack is used as an output instead of an input.
* LINE then contains the unmixed dsp output. This can be used
* to make the card a four channel one: use dsp to output two
......@@ -2529,14 +2524,11 @@ static /*const*/ struct file_operations es1370_midi_fops = {
/* maximum number of devices; only used for command line params */
#define NR_DEVICE 5
static int joystick[NR_DEVICE] = { 0, };
static int lineout[NR_DEVICE] = { 0, };
static int micbias[NR_DEVICE] = { 0, };
static unsigned int devindex = 0;
MODULE_PARM(joystick, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(joystick, "if 1 enables joystick interface (still need separate driver)");
MODULE_PARM(lineout, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(lineout, "if 1 the LINE input is converted to LINE out");
MODULE_PARM(micbias, "1-" __MODULE_STRING(NR_DEVICE) "i");
......@@ -2617,14 +2609,12 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
* mic bias setting (by Kim.Berts@fisub.mail.abb.com) */
s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL);
s->gameport.io = 0;
if (joystick[devindex]) {
if (!request_region(0x200, JOY_EXTENT, "es1370"))
printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
else {
s->ctrl |= CTRL_JYSTK_EN;
s->gameport.io = 0x200;
}
}
if (lineout[devindex])
s->ctrl |= CTRL_XCTL0;
if (micbias[devindex])
......@@ -2765,7 +2755,7 @@ module_exit(cleanup_es1370);
#ifndef MODULE
/* format is: es1370=[joystick[,lineout[,micbias]]] */
/* format is: es1370=lineout[,micbias]] */
static int __init es1370_setup(char *str)
{
......@@ -2775,8 +2765,7 @@ static int __init es1370_setup(char *str)
return 0;
(void)
( (get_option(&str,&joystick[nr_dev]) == 2)
&& (get_option(&str,&lineout [nr_dev]) == 2)
((get_option(&str,&lineout [nr_dev]) == 2)
&& get_option(&str,&micbias [nr_dev])
);
......
......@@ -21,12 +21,6 @@
*
* Special thanks to Ensoniq
*
*
* Module command line parameters:
* joystick must be set to the base I/O-Port to be used for
* the gameport. Legal values are 0x200, 0x208, 0x210 and 0x218.
* The gameport is mirrored eight times.
*
* Supported devices:
* /dev/dsp standard /dev/dsp device, (mostly) OSS compatible
* /dev/mixer standard /dev/mixer device, (mostly) OSS compatible
......@@ -2744,20 +2738,17 @@ static int proc_es1371_dump (char *buf, char **start, off_t fpos, int length, in
/* maximum number of devices; only used for command line params */
#define NR_DEVICE 5
static int joystick[NR_DEVICE] = { 0, };
static int spdif[NR_DEVICE] = { 0, };
static int nomix[NR_DEVICE] = { 0, };
static int amplifier[NR_DEVICE] = { 0, };
static unsigned int devindex = 0;
static int amplifier = 0;
MODULE_PARM(joystick, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(joystick, "sets address and enables joystick interface (still need separate driver)");
MODULE_PARM(spdif, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(spdif, "if 1 the output is in S/PDIF digital mode");
MODULE_PARM(nomix, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(nomix, "if 1 no analog audio is mixed to the digital output");
MODULE_PARM(amplifier, "i");
MODULE_PARM(amplifier, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(amplifier, "Set to 1 if the machine needs the amp control enabling (many laptops)");
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
......@@ -2856,8 +2847,8 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
printk(KERN_ERR PFX "irq %u in use\n", s->irq);
goto err_irq;
}
printk(KERN_INFO PFX "found es1371 rev %d at io %#lx irq %u\n"
KERN_INFO PFX "features: joystick 0x%x\n", s->rev, s->io, s->irq, joystick[devindex]);
printk(KERN_INFO PFX "found es1371 rev %d at io %#lx irq %u joystick %#x\n",
s->rev, s->io, s->irq, s->gameport.io);
/* register devices */
if ((res=(s->dev_audio = register_sound_dsp(&es1371_audio_fops,-1))<0))
goto err_dev1;
......@@ -2877,7 +2868,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
/* Check amplifier requirements */
if(amplifier)
if (amplifier[devindex])
s->ctrl |= CTRL_GPIO_OUT0;
else for(idx = 0; amplifier_needed[idx].svid != PCI_ANY_ID; idx++)
{
......@@ -2889,14 +2880,6 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
}
}
s->gameport.io = 0;
if ((joystick[devindex] & ~0x18) == 0x200) {
if (!request_region(joystick[devindex], JOY_EXTENT, "es1371"))
printk(KERN_ERR PFX "joystick address 0x%x already in use\n", joystick[devindex]);
else {
s->ctrl |= CTRL_JYSTK_EN | (((joystick[devindex] >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT);
s->gameport.io = joystick[devindex];
}
} else if (joystick[devindex] == 1) {
for (i = 0x218; i >= 0x200; i -= 0x08) {
if (request_region(i, JOY_EXTENT, "es1371")) {
s->ctrl |= CTRL_JYSTK_EN | (((i >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT);
......@@ -2906,7 +2889,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
}
if (!s->gameport.io)
printk(KERN_ERR PFX "no free joystick address found\n");
}
s->sctrl = 0;
cssr = 0;
s->spdif_volume = -1;
......@@ -2926,7 +2909,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
/* initialize the chips */
outl(s->ctrl, s->io+ES1371_REG_CONTROL);
outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
outl(0, s->io+ES1371_REG_LEGACY);
outl(LEGACY_JFAST, s->io+ES1371_REG_LEGACY);
pci_set_master(pcidev); /* enable bus mastering */
/* if we are a 5880 turn on the AC97 */
if (s->vendor == PCI_VENDOR_ID_ENSONIQ &&
......@@ -3070,7 +3053,7 @@ module_exit(cleanup_es1371);
#ifndef MODULE
/* format is: es1371=[joystick] */
/* format is: es1371=[spdif,[nomix,[amplifier]]] */
static int __init es1371_setup(char *str)
{
......@@ -3078,8 +3061,12 @@ static int __init es1371_setup(char *str)
if (nr_dev >= NR_DEVICE)
return 0;
if (get_option(&str, &joystick[nr_dev]) == 2)
(void)get_option(&str, &spdif[nr_dev]);
(void)
((get_option(&str, &spdif[nr_dev]) == 2)
&& (get_option(&str, &nomix[nr_dev]) == 2)
&& (get_option(&str, &amplifier[nr_dev])));
nr_dev++;
return 1;
}
......
......@@ -881,7 +881,7 @@ static int __initdata cdirq = 0;
static int __initdata cdport = 0x340;
static int __initdata cddma = -1;
static int __initdata opl4 = 0;
static int __initdata joystick = 0;
static int __initdata joystick = 1;
MODULE_PARM(mpu_io, "i");
MODULE_PARM(mpu_irq, "i");
......
......@@ -36,6 +36,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* History
* v0.14.9e
* January 2 2002 Vojtech Pavlik <vojtech@ucw.cz> added gameport
* support to avoid resource conflict with pcigame.c
* v0.14.9d
* October 8 2001 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* use set_current_state, properly release resources on failure in
......@@ -171,6 +174,7 @@
#include <linux/bitops.h>
#include <linux/proc_fs.h>
#include <linux/interrupt.h>
#include <linux/gameport.h>
#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
#include <asm/hwrpb.h>
......@@ -180,7 +184,7 @@
#include <linux/pm.h>
#define DRIVER_VERSION "0.14.9d"
#define DRIVER_VERSION "0.14.9e"
/* magic numbers to protect our data structures */
#define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */
......@@ -382,6 +386,9 @@ struct trident_card {
/* Added for hardware volume control */
int hwvolctl;
struct timer_list timer;
/* Game port support */
struct gameport gameport;
};
/* table to map from CHANNELMASK to channel attribute for SiS 7018 */
......@@ -3938,6 +3945,55 @@ static int __init trident_ac97_init(struct trident_card *card)
return num_ac97+1;
}
/* Gameport functions for the cards ADC gameport */
static unsigned char trident_game_read(struct gameport *gameport)
{
struct trident_card *card = gameport->driver;
return inb(TRID_REG(card, T4D_GAME_LEG));
}
static void trident_game_trigger(struct gameport *gameport)
{
struct trident_card *card = gameport->driver;
outb(0xff, TRID_REG(card, T4D_GAME_LEG));
}
static int trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
struct trident_card *card = gameport->driver;
int i;
*buttons = (~inb(TRID_REG(card, T4D_GAME_LEG)) >> 4) & 0xf;
for (i = 0; i < 4; i++) {
axes[i] = inw(TRID_REG(card, T4D_GAME_AXD) + i * sizeof(u16));
if (axes[i] == 0xffff) axes[i] = -1;
}
return 0;
}
static int trident_game_open(struct gameport *gameport, int mode)
{
struct trident_card *card = gameport->driver;
switch (mode) {
case GAMEPORT_MODE_COOKED:
outb(0x80, TRID_REG(card, T4D_GAME_CR));
wait_ms(20);
return 0;
case GAMEPORT_MODE_RAW:
outb(0x00, TRID_REG(card, T4D_GAME_CR));
return 0;
default:
return -1;
}
return 0;
}
/* install the driver, we do not allocate hardware channel nor DMA buffer now, they are defered
until "ACCESS" time (in prog_dmabuf called by open/read/write/ioctl/mmap) */
static int __init trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
......@@ -3998,6 +4054,13 @@ static int __init trident_probe(struct pci_dev *pci_dev, const struct pci_device
card->banks[BANK_B].addresses = &bank_b_addrs;
card->banks[BANK_B].bitmap = 0UL;
card->gameport.driver = card;
card->gameport.fuzz = 64;
card->gameport.read = trident_game_read;
card->gameport.trigger = trident_game_trigger;
card->gameport.cooked_read = trident_game_cooked_read;
card->gameport.open = trident_game_open;
init_MUTEX(&card->open_sem);
spin_lock_init(&card->lock);
init_timer(&card->timer);
......@@ -4131,6 +4194,10 @@ static int __init trident_probe(struct pci_dev *pci_dev, const struct pci_device
/* Enable Address Engine Interrupts */
trident_enable_loop_interrupts(card);
/* Register gameport */
gameport_register_port(&card->gameport);
out: return rc;
out_unregister_sound_dsp:
unregister_sound_dsp(card->dev_audio);
......@@ -4172,6 +4239,9 @@ static void __devexit trident_remove(struct pci_dev *pci_dev)
#endif
}
/* Unregister gameport */
gameport_unregister_port(&card->gameport);
/* Kill interrupts, and SP/DIF */
trident_disable_loop_interrupts(card);
......
......@@ -79,6 +79,8 @@
/* operational registers common to DX, NX, 7018 */
enum trident_op_registers {
T4D_GAME_CR = 0x30, T4D_GAME_LEG = 0x31,
T4D_GAME_AXD = 0x34,
T4D_REC_CH = 0x70,
T4D_START_A = 0x80, T4D_STOP_A = 0x84,
T4D_DLY_A = 0x88, T4D_SIGN_CSO_A = 0x8c,
......@@ -333,7 +335,7 @@ enum miscint_bits {
#define VALIDATE_STATE(a) VALIDATE_MAGIC(a,TRIDENT_STATE_MAGIC)
#define VALIDATE_CARD(a) VALIDATE_MAGIC(a,TRIDENT_CARD_MAGIC)
extern __inline__ unsigned ld2(unsigned int x)
static inline unsigned ld2(unsigned int x)
{
unsigned r = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment