/*
* Copyright (c) 1999 Klaus J. Klein
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* PCI Configuration Registers
*/
#define ESO_PCI_BAR_IO 0x10 /* I/O space base address */
#define ESO_PCI_BAR_SB 0x14 /* SB I/O space base address */
#define ESO_PCI_BAR_VC 0x18 /* VC I/O space base address */
#define ESO_PCI_BAR_MPU 0x1c /* MPU-401 I/O space base address */
#define ESO_PCI_BAR_GAME 0x20 /* Game port I/O space base address */
#define ESO_PCI_S1C 0x50 /* Solo-1 Configuration */
#define ESO_PCI_S1C_IRQP_MASK 0x0006000 /* ISA IRQ emulation policy */
#define ESO_PCI_S1C_DMAP_MASK 0x0000700 /* DMA policy */
#define ESO_PCI_DDMAC 0x60 /* DDMA Control base address */
#define ESO_PCI_DDMAC_DE 0x01 /* Distributed DMA enable */
/* PCI Revision IDs of the Solo-1 PCI AudioDrive family */
#define ESO_PCI_REVISION_ES1938 0x00 /* ES1938 */
#define ESO_PCI_REVISION_ES1946 0x01 /* ES1946 */
#define ESO_PCI_REVISION_ES1946E 0x02 /* ES1946 Revision E */
/*
* Check the validity of a PCI I/O space base address for use in
* ESO_PCI_DDMAC; see the relevant comment in the attach function.
*/
#define ESO_VALID_DDMAC_BASE(addr) \
(((addr) & 0x03ff) != 0)
/*
* Sample rate related constants.
* Note: the use of these clock sources must be explicitly enabled for Audio 1.
*/
#define ESO_CLK0 793800L /* Clock source 0 frequency */
#define ESO_CLK1 768000L /* Clock source 1 frequency */
#define ESO_CLK1_SELECT 0x80 /* MSb of divider selects clock src */
/*
* Upper bounds on several polling loop iterations.
*/
#define ESO_RESET_TIMEOUT 5000
#define ESO_RDR_TIMEOUT 5000
#define ESO_WDR_TIMEOUT 5000
/*
* Mixer state data conversions.
*/
/* Truncate MI 8-bit precision gain values to the width of chip registers. */
#define ESO_GAIN_TO_3BIT(x) ((x) & 0xe0)
#define ESO_GAIN_TO_4BIT(x) ((x) & 0xf0)
#define ESO_GAIN_TO_6BIT(x) ((x) & 0xfc)
/* Convert two 4-bit gain values to standard mixer stereo register layout. */
#define ESO_4BIT_GAIN_TO_STEREO(l,r) ((l) | ((r) >> 4))