/*
* sound/sb_common.c
*
* Common routines for Sound Blaster compatible cards.
*
*
* Copyright (C) by Hannu Savolainen 1993-1997
*
* OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
* Version 2 (June 1991). See the "COPYING" file distributed with this software
* for more info.
*
*
* Daniel J. Rodriksson: Modified sbintr to handle 8 and 16 bit interrupts
* for full duplex support ( only sb16 by now )
* Rolf Fokkens: Added (BETA?) support for ES1887 chips.
* (fokkensr@vertis.nl) Which means: You can adjust the recording levels.
*
* 2000/01/18 - separated sb_card and sb_common -
* Jeff Garzik <jgarzik@pobox.com>
*
* 2000/09/18 - got rid of attach_uart401
* Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* 2001/01/26 - replaced CLI/STI with spinlocks
* Chris Rankin <rankinc@zipworld.com.au>
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include "sound_config.h"
#include "sound_firmware.h"
#include "mpu401.h"
#include "sb_mixer.h"
#include "sb.h"
#include "sb_ess.h"
/*
* global module flag
*/
int sb_be_quiet;
static sb_devc *detected_devc; /* For communication from probe to init */
static sb_devc *last_devc; /* For MPU401 initialization */
static unsigned char jazz_irq_bits[] = {
0, 0, 2, 3, 0, 1, 0, 4, 0, 2, 5, 0, 0, 0, 0, 6
};
static unsigned char jazz_dma_bits[] = {
0, 1, 0, 2, 0, 3, 0, 4
};
void *smw_free;
/*
* Jazz16 chipset specific control variables
*/
static int jazz16_base; /* Not detected */
static unsigned char jazz16_bits; /* I/O relocation bits */
static DEFINE_SPINLOCK(jazz16_lock);
/*
* Logitech Soundman Wave specific initialization code
*/
#ifdef SMW_MIDI0001_INCLUDED
#include "smw-midi0001.h"
#else
static unsigned char *smw_ucode;
static int smw_ucodeLen;
#endif
static sb_devc *last_sb; /* Last sb loaded */
int sb_dsp_command(sb_devc * devc, unsigned char val)
{
int i;
unsigned long limit;
limit = jiffies + HZ / 10; /* Timeout */
/*
* Note! the i<500000 is an emergency exit. The sb_dsp_command() is sometimes
* called while interrupts are disabled. This means that the timer is
* disabled also. However the timeout situation is a abnormal condition.
* Normally the DSP should be ready to accept commands after just couple of
* loops.
*/
for (i = 0; i < 500000 && (limit-jiffies)>0; i++)
{
if ((inb(DSP_STATUS) & 0x80) == 0)
{
outb((val), DSP_COMMAND);
return 1;
}
}
printk(KERN_WARNING "Sound Blaster: DSP command(%x) timeout.\n", val);
return 0;
}
int sb_dsp_get_byte(sb_devc * devc)
{
int i;
for (i = 1000;