18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci Aureal Vortex Soundcard driver. 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci IO addr collected from asp4core.vxd: 68c2ecf20Sopenharmony_ci function address 78c2ecf20Sopenharmony_ci 0005D5A0 13004 88c2ecf20Sopenharmony_ci 00080674 14004 98c2ecf20Sopenharmony_ci 00080AFF 12818 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define CHIP_AU8820 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define CARD_NAME "Aureal Vortex" 168c2ecf20Sopenharmony_ci#define CARD_NAME_SHORT "au8820" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* Number of ADB and WT channels */ 198c2ecf20Sopenharmony_ci#define NR_ADB 0x10 208c2ecf20Sopenharmony_ci#define NR_WT 0x20 218c2ecf20Sopenharmony_ci#define NR_SRC 0x10 228c2ecf20Sopenharmony_ci#define NR_A3D 0x00 238c2ecf20Sopenharmony_ci#define NR_MIXIN 0x10 248c2ecf20Sopenharmony_ci#define NR_MIXOUT 0x10 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* ADBDMA */ 288c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_STAT 0x105c0 /* read only, subbuffer, DMA pos */ 298c2ecf20Sopenharmony_ci#define POS_MASK 0x00000fff 308c2ecf20Sopenharmony_ci#define POS_SHIFT 0x0 318c2ecf20Sopenharmony_ci#define ADB_SUBBUF_MASK 0x00003000 /* ADB only. */ 328c2ecf20Sopenharmony_ci#define ADB_SUBBUF_SHIFT 0xc /* ADB only. */ 338c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_CTRL 0x10580 /* write only, format, flags, DMA pos */ 348c2ecf20Sopenharmony_ci#define OFFSET_MASK 0x00000fff 358c2ecf20Sopenharmony_ci#define OFFSET_SHIFT 0x0 368c2ecf20Sopenharmony_ci#define IE_MASK 0x00001000 /* interrupt enable. */ 378c2ecf20Sopenharmony_ci#define IE_SHIFT 0xc 388c2ecf20Sopenharmony_ci#define DIR_MASK 0x00002000 /* Direction. */ 398c2ecf20Sopenharmony_ci#define DIR_SHIFT 0xd 408c2ecf20Sopenharmony_ci#define FMT_MASK 0x0003c000 418c2ecf20Sopenharmony_ci#define FMT_SHIFT 0xe 428c2ecf20Sopenharmony_ci// The masks and shift also work for the wtdma, if not specified otherwise. 438c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_BUFCFG0 0x10400 448c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_BUFCFG1 0x10404 458c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_BUFBASE 0x10200 468c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_START 0x106c0 /* Which subbuffer starts */ 478c2ecf20Sopenharmony_ci#define VORTEX_ADBDMA_STATUS 0x10600 /* stored at AdbDma->this_10 / 2 DWORD in size. */ 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* ADB */ 508c2ecf20Sopenharmony_ci#define VORTEX_ADB_SR 0x10a00 /* Samplerates enable/disable */ 518c2ecf20Sopenharmony_ci#define VORTEX_ADB_RTBASE 0x10800 528c2ecf20Sopenharmony_ci#define VORTEX_ADB_RTBASE_COUNT 103 538c2ecf20Sopenharmony_ci#define VORTEX_ADB_CHNBASE 0x1099c 548c2ecf20Sopenharmony_ci#define VORTEX_ADB_CHNBASE_COUNT 22 558c2ecf20Sopenharmony_ci#define ROUTE_MASK 0x3fff 568c2ecf20Sopenharmony_ci#define ADB_MASK 0x7f 578c2ecf20Sopenharmony_ci#define ADB_SHIFT 0x7 588c2ecf20Sopenharmony_ci//#define ADB_MIX_MASK 0xf 598c2ecf20Sopenharmony_ci/* ADB address */ 608c2ecf20Sopenharmony_ci#define OFFSET_ADBDMA 0x00 618c2ecf20Sopenharmony_ci#define OFFSET_SRCOUT 0x10 /* on channel 0x11 */ 628c2ecf20Sopenharmony_ci#define OFFSET_SRCIN 0x10 /* on channel < 0x11 */ 638c2ecf20Sopenharmony_ci#define OFFSET_MIXOUT 0x20 /* source */ 648c2ecf20Sopenharmony_ci#define OFFSET_MIXIN 0x30 /* sink */ 658c2ecf20Sopenharmony_ci#define OFFSET_CODECIN 0x48 /* ADB source */ 668c2ecf20Sopenharmony_ci#define OFFSET_CODECOUT 0x58 /* ADB sink/target */ 678c2ecf20Sopenharmony_ci#define OFFSET_SPORTOUT 0x60 /* sink */ 688c2ecf20Sopenharmony_ci#define OFFSET_SPORTIN 0x50 /* source */ 698c2ecf20Sopenharmony_ci#define OFFSET_EFXOUT 0x50 /* sink */ 708c2ecf20Sopenharmony_ci#define OFFSET_EFXIN 0x40 /* source */ 718c2ecf20Sopenharmony_ci#define OFFSET_A3DOUT 0x00 /* This card has no HRTF :( */ 728c2ecf20Sopenharmony_ci#define OFFSET_A3DIN 0x00 738c2ecf20Sopenharmony_ci#define OFFSET_WTOUT 0x58 /* */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* ADB route translate helper */ 768c2ecf20Sopenharmony_ci#define ADB_DMA(x) (x + OFFSET_ADBDMA) 778c2ecf20Sopenharmony_ci#define ADB_SRCOUT(x) (x + OFFSET_SRCOUT) 788c2ecf20Sopenharmony_ci#define ADB_SRCIN(x) (x + OFFSET_SRCIN) 798c2ecf20Sopenharmony_ci#define ADB_MIXOUT(x) (x + OFFSET_MIXOUT) 808c2ecf20Sopenharmony_ci#define ADB_MIXIN(x) (x + OFFSET_MIXIN) 818c2ecf20Sopenharmony_ci#define ADB_CODECIN(x) (x + OFFSET_CODECIN) 828c2ecf20Sopenharmony_ci#define ADB_CODECOUT(x) (x + OFFSET_CODECOUT) 838c2ecf20Sopenharmony_ci#define ADB_SPORTOUT(x) (x + OFFSET_SPORTOUT) 848c2ecf20Sopenharmony_ci#define ADB_SPORTIN(x) (x + OFFSET_SPORTIN) /* */ 858c2ecf20Sopenharmony_ci#define ADB_A3DOUT(x) (x + OFFSET_A3DOUT) /* 8 A3D blocks */ 868c2ecf20Sopenharmony_ci#define ADB_A3DIN(x) (x + OFFSET_A3DIN) 878c2ecf20Sopenharmony_ci#define ADB_WTOUT(x,y) (y + OFFSET_WTOUT) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* WTDMA */ 908c2ecf20Sopenharmony_ci#define VORTEX_WTDMA_CTRL 0x10500 /* format, DMA pos */ 918c2ecf20Sopenharmony_ci#define VORTEX_WTDMA_STAT 0x10500 /* DMA subbuf, DMA pos */ 928c2ecf20Sopenharmony_ci#define WT_SUBBUF_MASK (0x3 << WT_SUBBUF_SHIFT) 938c2ecf20Sopenharmony_ci#define WT_SUBBUF_SHIFT 0x15 948c2ecf20Sopenharmony_ci#define VORTEX_WTDMA_BUFBASE 0x10000 958c2ecf20Sopenharmony_ci#define VORTEX_WTDMA_BUFCFG0 0x10300 968c2ecf20Sopenharmony_ci#define VORTEX_WTDMA_BUFCFG1 0x10304 978c2ecf20Sopenharmony_ci#define VORTEX_WTDMA_START 0x10640 /* which subbuffer is first */ 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define VORTEX_WT_BASE 0x9000 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* MIXER */ 1028c2ecf20Sopenharmony_ci#define VORTEX_MIXER_SR 0x9f00 1038c2ecf20Sopenharmony_ci#define VORTEX_MIXER_CLIP 0x9f80 1048c2ecf20Sopenharmony_ci#define VORTEX_MIXER_CHNBASE 0x9e40 1058c2ecf20Sopenharmony_ci#define VORTEX_MIXER_RTBASE 0x9e00 1068c2ecf20Sopenharmony_ci#define MIXER_RTBASE_SIZE 0x26 1078c2ecf20Sopenharmony_ci#define VORTEX_MIX_ENIN 0x9a00 /* Input enable bits. 4 bits wide. */ 1088c2ecf20Sopenharmony_ci#define VORTEX_MIX_SMP 0x9c00 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* MIX */ 1118c2ecf20Sopenharmony_ci#define VORTEX_MIX_INVOL_A 0x9000 /* in? */ 1128c2ecf20Sopenharmony_ci#define VORTEX_MIX_INVOL_B 0x8000 /* out? */ 1138c2ecf20Sopenharmony_ci#define VORTEX_MIX_VOL_A 0x9800 1148c2ecf20Sopenharmony_ci#define VORTEX_MIX_VOL_B 0x8800 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define VOL_MIN 0x80 /* Input volume when muted. */ 1178c2ecf20Sopenharmony_ci#define VOL_MAX 0x7f /* FIXME: Not confirmed! Just guessed. */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci//#define MIX_OUTL 0xe 1208c2ecf20Sopenharmony_ci//#define MIX_OUTR 0xf 1218c2ecf20Sopenharmony_ci//#define MIX_INL 0xe 1228c2ecf20Sopenharmony_ci//#define MIX_INR 0xf 1238c2ecf20Sopenharmony_ci#define MIX_DEFIGAIN 0x08 /* 0x8 => 6dB */ 1248c2ecf20Sopenharmony_ci#define MIX_DEFOGAIN 0x08 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci/* SRC */ 1278c2ecf20Sopenharmony_ci#define VORTEX_SRCBLOCK_SR 0xccc0 1288c2ecf20Sopenharmony_ci#define VORTEX_SRC_CHNBASE 0xcc40 1298c2ecf20Sopenharmony_ci#define VORTEX_SRC_RTBASE 0xcc00 1308c2ecf20Sopenharmony_ci#define VORTEX_SRC_SOURCE 0xccc4 1318c2ecf20Sopenharmony_ci#define VORTEX_SRC_SOURCESIZE 0xccc8 1328c2ecf20Sopenharmony_ci#define VORTEX_SRC_U0 0xce00 1338c2ecf20Sopenharmony_ci#define VORTEX_SRC_DRIFT0 0xce80 1348c2ecf20Sopenharmony_ci#define VORTEX_SRC_DRIFT1 0xcec0 1358c2ecf20Sopenharmony_ci#define VORTEX_SRC_U1 0xcf00 1368c2ecf20Sopenharmony_ci#define VORTEX_SRC_DRIFT2 0xcf40 1378c2ecf20Sopenharmony_ci#define VORTEX_SRC_U2 0xcf80 1388c2ecf20Sopenharmony_ci#define VORTEX_SRC_DATA 0xc800 1398c2ecf20Sopenharmony_ci#define VORTEX_SRC_DATA0 0xc000 1408c2ecf20Sopenharmony_ci#define VORTEX_SRC_CONVRATIO 0xce40 1418c2ecf20Sopenharmony_ci//#define SRC_RATIO(x) ((((x<<15)/48000) + 1)/2) /* Playback */ 1428c2ecf20Sopenharmony_ci//#define SRC_RATIO2(x) ((((48000<<15)/x) + 1)/2) /* Recording */ 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci/* FIFO */ 1458c2ecf20Sopenharmony_ci#define VORTEX_FIFO_ADBCTRL 0xf800 /* Control bits. */ 1468c2ecf20Sopenharmony_ci#define VORTEX_FIFO_WTCTRL 0xf840 1478c2ecf20Sopenharmony_ci#define FIFO_RDONLY 0x00000001 1488c2ecf20Sopenharmony_ci#define FIFO_CTRL 0x00000002 /* Allow ctrl. ? */ 1498c2ecf20Sopenharmony_ci#define FIFO_VALID 0x00000010 1508c2ecf20Sopenharmony_ci#define FIFO_EMPTY 0x00000020 1518c2ecf20Sopenharmony_ci#define FIFO_U0 0x00001000 /* Unknown. */ 1528c2ecf20Sopenharmony_ci#define FIFO_U1 0x00010000 1538c2ecf20Sopenharmony_ci#define FIFO_SIZE_BITS 5 1548c2ecf20Sopenharmony_ci#define FIFO_SIZE (1<<FIFO_SIZE_BITS) // 0x20 1558c2ecf20Sopenharmony_ci#define FIFO_MASK (FIFO_SIZE-1) //0x1f /* at shift left 0xc */ 1568c2ecf20Sopenharmony_ci#define VORTEX_FIFO_ADBDATA 0xe000 1578c2ecf20Sopenharmony_ci#define VORTEX_FIFO_WTDATA 0xe800 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* CODEC */ 1608c2ecf20Sopenharmony_ci#define VORTEX_CODEC_CTRL 0x11984 1618c2ecf20Sopenharmony_ci#define VORTEX_CODEC_EN 0x11990 1628c2ecf20Sopenharmony_ci#define EN_CODEC 0x00000300 1638c2ecf20Sopenharmony_ci#define EN_SPORT 0x00030000 1648c2ecf20Sopenharmony_ci#define EN_SPDIF 0x000c0000 1658c2ecf20Sopenharmony_ci#define VORTEX_CODEC_CHN 0x11880 1668c2ecf20Sopenharmony_ci#define VORTEX_CODEC_IO 0x11988 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci#define VORTEX_SPDIF_FLAGS 0x1005c /* FIXME */ 1698c2ecf20Sopenharmony_ci#define VORTEX_SPDIF_CFG0 0x119D0 1708c2ecf20Sopenharmony_ci#define VORTEX_SPDIF_CFG1 0x119D4 1718c2ecf20Sopenharmony_ci#define VORTEX_SPDIF_SMPRATE 0x11994 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* Sample timer */ 1748c2ecf20Sopenharmony_ci#define VORTEX_SMP_TIME 0x11998 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* IRQ */ 1778c2ecf20Sopenharmony_ci#define VORTEX_IRQ_SOURCE 0x12800 /* Interrupt source flags. */ 1788c2ecf20Sopenharmony_ci#define VORTEX_IRQ_CTRL 0x12804 /* Interrupt source mask. */ 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#define VORTEX_STAT 0x12808 /* ?? */ 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#define VORTEX_CTRL 0x1280c 1838c2ecf20Sopenharmony_ci#define CTRL_MIDI_EN 0x00000001 1848c2ecf20Sopenharmony_ci#define CTRL_MIDI_PORT 0x00000060 1858c2ecf20Sopenharmony_ci#define CTRL_GAME_EN 0x00000008 1868c2ecf20Sopenharmony_ci#define CTRL_GAME_PORT 0x00000e00 1878c2ecf20Sopenharmony_ci#define CTRL_IRQ_ENABLE 0x4000 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/* write: Timer period config / read: TIMER IRQ ack. */ 1908c2ecf20Sopenharmony_ci#define VORTEX_IRQ_STAT 0x1199c 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci/* DMA */ 1938c2ecf20Sopenharmony_ci#define VORTEX_DMA_BUFFER 0x10200 1948c2ecf20Sopenharmony_ci#define VORTEX_ENGINE_CTRL 0x1060c 1958c2ecf20Sopenharmony_ci#define ENGINE_INIT 0x0L 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci /* MIDI *//* GAME. */ 1988c2ecf20Sopenharmony_ci#define VORTEX_MIDI_DATA 0x11000 1998c2ecf20Sopenharmony_ci#define VORTEX_MIDI_CMD 0x11004 /* Write command / Read status */ 2008c2ecf20Sopenharmony_ci#define VORTEX_GAME_LEGACY 0x11008 2018c2ecf20Sopenharmony_ci#define VORTEX_CTRL2 0x1100c 2028c2ecf20Sopenharmony_ci#define CTRL2_GAME_ADCMODE 0x40 2038c2ecf20Sopenharmony_ci#define VORTEX_GAME_AXIS 0x11010 2048c2ecf20Sopenharmony_ci#define AXIS_SIZE 4 2058c2ecf20Sopenharmony_ci#define AXIS_RANGE 0x1fff 206