1d43f3010STakashi Iwai /* 2d43f3010STakashi Iwai * Support for Digigram Lola PCI-e boards 3d43f3010STakashi Iwai * 4d43f3010STakashi Iwai * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de> 5d43f3010STakashi Iwai * 6d43f3010STakashi Iwai * This program is free software; you can redistribute it and/or modify it 7d43f3010STakashi Iwai * under the terms of the GNU General Public License as published by the Free 8d43f3010STakashi Iwai * Software Foundation; either version 2 of the License, or (at your option) 9d43f3010STakashi Iwai * any later version. 10d43f3010STakashi Iwai * 11d43f3010STakashi Iwai * This program is distributed in the hope that it will be useful, but WITHOUT 12d43f3010STakashi Iwai * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13d43f3010STakashi Iwai * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14d43f3010STakashi Iwai * more details. 15d43f3010STakashi Iwai * 16d43f3010STakashi Iwai * You should have received a copy of the GNU General Public License along with 17d43f3010STakashi Iwai * this program; if not, write to the Free Software Foundation, Inc., 59 18d43f3010STakashi Iwai * Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19d43f3010STakashi Iwai */ 20d43f3010STakashi Iwai 21d43f3010STakashi Iwai #ifndef _LOLA_H 22d43f3010STakashi Iwai #define _LOLA_H 23d43f3010STakashi Iwai 24d43f3010STakashi Iwai #define DRVNAME "snd-lola" 25d43f3010STakashi Iwai #define SFX DRVNAME ": " 26d43f3010STakashi Iwai 27d43f3010STakashi Iwai /* 28d43f3010STakashi Iwai * Lola HD Audio Registers BAR0 29d43f3010STakashi Iwai */ 30d43f3010STakashi Iwai #define LOLA_BAR0_GCAP 0x00 31d43f3010STakashi Iwai #define LOLA_BAR0_VMIN 0x02 32d43f3010STakashi Iwai #define LOLA_BAR0_VMAJ 0x03 33d43f3010STakashi Iwai #define LOLA_BAR0_OUTPAY 0x04 34d43f3010STakashi Iwai #define LOLA_BAR0_INPAY 0x06 35d43f3010STakashi Iwai #define LOLA_BAR0_GCTL 0x08 36d43f3010STakashi Iwai #define LOLA_BAR0_WAKEEN 0x0c 37d43f3010STakashi Iwai #define LOLA_BAR0_STATESTS 0x0e 38d43f3010STakashi Iwai #define LOLA_BAR0_GSTS 0x10 39d43f3010STakashi Iwai #define LOLA_BAR0_OUTSTRMPAY 0x18 40d43f3010STakashi Iwai #define LOLA_BAR0_INSTRMPAY 0x1a 41d43f3010STakashi Iwai #define LOLA_BAR0_INTCTL 0x20 42d43f3010STakashi Iwai #define LOLA_BAR0_INTSTS 0x24 43d43f3010STakashi Iwai #define LOLA_BAR0_WALCLK 0x30 44d43f3010STakashi Iwai #define LOLA_BAR0_SSYNC 0x38 45d43f3010STakashi Iwai 46d43f3010STakashi Iwai #define LOLA_BAR0_CORBLBASE 0x40 47d43f3010STakashi Iwai #define LOLA_BAR0_CORBUBASE 0x44 48d43f3010STakashi Iwai #define LOLA_BAR0_CORBWP 0x48 /* no ULONG access */ 49d43f3010STakashi Iwai #define LOLA_BAR0_CORBRP 0x4a /* no ULONG access */ 50d43f3010STakashi Iwai #define LOLA_BAR0_CORBCTL 0x4c /* no ULONG access */ 51d43f3010STakashi Iwai #define LOLA_BAR0_CORBSTS 0x4d /* UCHAR access only */ 52d43f3010STakashi Iwai #define LOLA_BAR0_CORBSIZE 0x4e /* no ULONG access */ 53d43f3010STakashi Iwai 54d43f3010STakashi Iwai #define LOLA_BAR0_RIRBLBASE 0x50 55d43f3010STakashi Iwai #define LOLA_BAR0_RIRBUBASE 0x54 56d43f3010STakashi Iwai #define LOLA_BAR0_RIRBWP 0x58 57d43f3010STakashi Iwai #define LOLA_BAR0_RINTCNT 0x5a /* no ULONG access */ 58d43f3010STakashi Iwai #define LOLA_BAR0_RIRBCTL 0x5c 59d43f3010STakashi Iwai #define LOLA_BAR0_RIRBSTS 0x5d /* UCHAR access only */ 60d43f3010STakashi Iwai #define LOLA_BAR0_RIRBSIZE 0x5e /* no ULONG access */ 61d43f3010STakashi Iwai 62d43f3010STakashi Iwai #define LOLA_BAR0_ICW 0x60 63d43f3010STakashi Iwai #define LOLA_BAR0_IRR 0x64 64d43f3010STakashi Iwai #define LOLA_BAR0_ICS 0x68 65d43f3010STakashi Iwai #define LOLA_BAR0_DPLBASE 0x70 66d43f3010STakashi Iwai #define LOLA_BAR0_DPUBASE 0x74 67d43f3010STakashi Iwai 68d43f3010STakashi Iwai /* stream register offsets from stream base 0x80 */ 69d43f3010STakashi Iwai #define LOLA_BAR0_SD0_OFFSET 0x80 70d43f3010STakashi Iwai #define LOLA_REG0_SD_CTL 0x00 71d43f3010STakashi Iwai #define LOLA_REG0_SD_STS 0x03 72d43f3010STakashi Iwai #define LOLA_REG0_SD_LPIB 0x04 73d43f3010STakashi Iwai #define LOLA_REG0_SD_CBL 0x08 74d43f3010STakashi Iwai #define LOLA_REG0_SD_LVI 0x0c 75d43f3010STakashi Iwai #define LOLA_REG0_SD_FIFOW 0x0e 76d43f3010STakashi Iwai #define LOLA_REG0_SD_FIFOSIZE 0x10 77d43f3010STakashi Iwai #define LOLA_REG0_SD_FORMAT 0x12 78d43f3010STakashi Iwai #define LOLA_REG0_SD_BDLPL 0x18 79d43f3010STakashi Iwai #define LOLA_REG0_SD_BDLPU 0x1c 80d43f3010STakashi Iwai 81d43f3010STakashi Iwai /* 82d43f3010STakashi Iwai * Lola Digigram Registers BAR1 83d43f3010STakashi Iwai */ 84d43f3010STakashi Iwai #define LOLA_BAR1_FPGAVER 0x00 85d43f3010STakashi Iwai #define LOLA_BAR1_DEVER 0x04 86d43f3010STakashi Iwai #define LOLA_BAR1_UCBMV 0x08 87d43f3010STakashi Iwai #define LOLA_BAR1_JTAG 0x0c 88d43f3010STakashi Iwai #define LOLA_BAR1_UARTRX 0x10 89d43f3010STakashi Iwai #define LOLA_BAR1_UARTTX 0x14 90d43f3010STakashi Iwai #define LOLA_BAR1_UARTCR 0x18 91d43f3010STakashi Iwai #define LOLA_BAR1_NVRAMVER 0x1c 92d43f3010STakashi Iwai #define LOLA_BAR1_CTRLSPI 0x20 93d43f3010STakashi Iwai #define LOLA_BAR1_DSPI 0x24 94d43f3010STakashi Iwai #define LOLA_BAR1_AISPI 0x28 95d43f3010STakashi Iwai #define LOLA_BAR1_GRAN 0x2c 96d43f3010STakashi Iwai 97d43f3010STakashi Iwai #define LOLA_BAR1_DINTCTL 0x80 98d43f3010STakashi Iwai #define LOLA_BAR1_DIINTCTL 0x84 99d43f3010STakashi Iwai #define LOLA_BAR1_DOINTCTL 0x88 100d43f3010STakashi Iwai #define LOLA_BAR1_LRC 0x90 101d43f3010STakashi Iwai #define LOLA_BAR1_DINTSTS 0x94 102d43f3010STakashi Iwai #define LOLA_BAR1_DIINTSTS 0x98 103d43f3010STakashi Iwai #define LOLA_BAR1_DOINTSTS 0x9c 104d43f3010STakashi Iwai 105d43f3010STakashi Iwai #define LOLA_BAR1_DSD0_OFFSET 0xa0 106d43f3010STakashi Iwai #define LOLA_BAR1_DSD_SIZE 0x18 107d43f3010STakashi Iwai 108d43f3010STakashi Iwai #define LOLA_BAR1_DSDnSTS 0x00 109d43f3010STakashi Iwai #define LOLA_BAR1_DSDnLPIB 0x04 110d43f3010STakashi Iwai #define LOLA_BAR1_DSDnCTL 0x08 111d43f3010STakashi Iwai #define LOLA_BAR1_DSDnLVI 0x0c 112d43f3010STakashi Iwai #define LOLA_BAR1_DSDnBDPL 0x10 113d43f3010STakashi Iwai #define LOLA_BAR1_DSDnBDPU 0x14 114d43f3010STakashi Iwai 115d43f3010STakashi Iwai #define LOLA_BAR1_SSYNC 0x03e8 116d43f3010STakashi Iwai 117d43f3010STakashi Iwai #define LOLA_BAR1_BOARD_CTRL 0x0f00 118d43f3010STakashi Iwai #define LOLA_BAR1_BOARD_MODE 0x0f02 119d43f3010STakashi Iwai 120d43f3010STakashi Iwai #define LOLA_BAR1_SOURCE_GAIN_ENABLE 0x1000 121d43f3010STakashi Iwai #define LOLA_BAR1_DEST00_MIX_GAIN_ENABLE 0x1004 122d43f3010STakashi Iwai #define LOLA_BAR1_DEST31_MIX_GAIN_ENABLE 0x1080 123d43f3010STakashi Iwai #define LOLA_BAR1_SOURCE00_01_GAIN 0x1084 124d43f3010STakashi Iwai #define LOLA_BAR1_SOURCE30_31_GAIN 0x10c0 125d43f3010STakashi Iwai #define LOLA_BAR1_SOURCE_GAIN(src) \ 126d43f3010STakashi Iwai (LOLA_BAR1_SOURCE00_01_GAIN + (src) * 2) 127d43f3010STakashi Iwai #define LOLA_BAR1_DEST00_MIX00_01_GAIN 0x10c4 128d43f3010STakashi Iwai #define LOLA_BAR1_DEST00_MIX30_31_GAIN 0x1100 129d43f3010STakashi Iwai #define LOLA_BAR1_DEST01_MIX00_01_GAIN 0x1104 130d43f3010STakashi Iwai #define LOLA_BAR1_DEST01_MIX30_31_GAIN 0x1140 131d43f3010STakashi Iwai #define LOLA_BAR1_DEST31_MIX00_01_GAIN 0x1884 132d43f3010STakashi Iwai #define LOLA_BAR1_DEST31_MIX30_31_GAIN 0x18c0 133d43f3010STakashi Iwai #define LOLA_BAR1_MIX_GAIN(dest, mix) \ 134d43f3010STakashi Iwai (LOLA_BAR1_DEST00_MIX00_01_GAIN + (dest) * 0x40 + (mix) * 2) 135d43f3010STakashi Iwai #define LOLA_BAR1_ANALOG_CLIP_IN 0x18c4 136d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_SOURCE00_01 0x18c8 137d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_SOURCE30_31 0x1904 138d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_SOURCE(src) \ 139d43f3010STakashi Iwai (LOLA_BAR1_PEAKMETERS_SOURCE00_01 + (src) * 2) 140d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_DEST00_01 0x1908 141d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_DEST30_31 0x1944 142d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_DEST(dest) \ 143d43f3010STakashi Iwai (LOLA_BAR1_PEAKMETERS_DEST00_01 + (dest) * 2) 144d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_AGC00_01 0x1948 145d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_AGC14_15 0x1964 146d43f3010STakashi Iwai #define LOLA_BAR1_PEAKMETERS_AGC(x) \ 147d43f3010STakashi Iwai (LOLA_BAR1_PEAKMETERS_AGC00_01 + (x) * 2) 148d43f3010STakashi Iwai 149d43f3010STakashi Iwai /* GCTL reset bit */ 150d43f3010STakashi Iwai #define LOLA_GCTL_RESET (1 << 0) 151d43f3010STakashi Iwai /* GCTL unsolicited response enable bit */ 152d43f3010STakashi Iwai #define LOLA_GCTL_UREN (1 << 8) 153d43f3010STakashi Iwai 154d43f3010STakashi Iwai /* CORB/RIRB control, read/write pointer */ 155d43f3010STakashi Iwai #define LOLA_RBCTL_DMA_EN 0x02 /* enable DMA */ 156d43f3010STakashi Iwai #define LOLA_RBCTL_IRQ_EN 0x01 /* enable IRQ */ 157d43f3010STakashi Iwai #define LOLA_RBRWP_CLR 0x8000 /* read/write pointer clear */ 158d43f3010STakashi Iwai 159d43f3010STakashi Iwai #define LOLA_RIRB_EX_UNSOL_EV 0x40000000 160d43f3010STakashi Iwai #define LOLA_RIRB_EX_ERROR 0x80000000 161d43f3010STakashi Iwai 162d43f3010STakashi Iwai /* CORB int mask: CMEI[0] */ 163d43f3010STakashi Iwai #define LOLA_CORB_INT_CMEI 0x01 164d43f3010STakashi Iwai #define LOLA_CORB_INT_MASK LOLA_CORB_INT_CMEI 165d43f3010STakashi Iwai 166d43f3010STakashi Iwai /* RIRB int mask: overrun[2], response[0] */ 167d43f3010STakashi Iwai #define LOLA_RIRB_INT_RESPONSE 0x01 168d43f3010STakashi Iwai #define LOLA_RIRB_INT_OVERRUN 0x04 169d43f3010STakashi Iwai #define LOLA_RIRB_INT_MASK (LOLA_RIRB_INT_RESPONSE | LOLA_RIRB_INT_OVERRUN) 170d43f3010STakashi Iwai 171d43f3010STakashi Iwai /* DINTCTL and DINTSTS */ 172d43f3010STakashi Iwai #define LOLA_DINT_GLOBAL 0x80000000 /* global interrupt enable bit */ 173d43f3010STakashi Iwai #define LOLA_DINT_CTRL 0x40000000 /* controller interrupt enable bit */ 174d43f3010STakashi Iwai #define LOLA_DINT_FIFOERR 0x20000000 /* global fifo error enable bit */ 175d43f3010STakashi Iwai #define LOLA_DINT_MUERR 0x10000000 /* global microcontroller underrun error */ 176d43f3010STakashi Iwai 177d43f3010STakashi Iwai /* DSDnCTL bits */ 178d43f3010STakashi Iwai #define LOLA_DSD_CTL_SRST 0x01 /* stream reset bit */ 179d43f3010STakashi Iwai #define LOLA_DSD_CTL_SRUN 0x02 /* stream DMA start bit */ 180d43f3010STakashi Iwai #define LOLA_DSD_CTL_IOCE 0x04 /* interrupt on completion enable */ 181d43f3010STakashi Iwai #define LOLA_DSD_CTL_DEIE 0x10 /* descriptor error interrupt enable */ 182d43f3010STakashi Iwai #define LOLA_DSD_CTL_VLRCV 0x20 /* valid LRCountValue information in bits 8..31 */ 183d43f3010STakashi Iwai #define LOLA_LRC_MASK 0xffffff00 184d43f3010STakashi Iwai 185d43f3010STakashi Iwai /* DSDnSTS */ 186d43f3010STakashi Iwai #define LOLA_DSD_STS_BCIS 0x04 /* buffer completion interrupt status */ 187d43f3010STakashi Iwai #define LOLA_DSD_STS_DESE 0x10 /* descriptor error interrupt */ 188d43f3010STakashi Iwai #define LOLA_DSD_STS_FIFORDY 0x20 /* fifo ready */ 189d43f3010STakashi Iwai 190d43f3010STakashi Iwai #define LOLA_CORB_ENTRIES 256 191d43f3010STakashi Iwai 192d43f3010STakashi Iwai #define MAX_STREAM_IN_COUNT 16 193d43f3010STakashi Iwai #define MAX_STREAM_OUT_COUNT 16 194d43f3010STakashi Iwai #define MAX_STREAM_COUNT 16 195d43f3010STakashi Iwai #define MAX_PINS MAX_STREAM_COUNT 196d43f3010STakashi Iwai #define MAX_STREAM_BUFFER_COUNT 16 197d43f3010STakashi Iwai #define MAX_AUDIO_INOUT_COUNT 16 198d43f3010STakashi Iwai 199d43f3010STakashi Iwai #define LOLA_CLOCK_TYPE_INTERNAL 0 200d43f3010STakashi Iwai #define LOLA_CLOCK_TYPE_AES 1 201d43f3010STakashi Iwai #define LOLA_CLOCK_TYPE_AES_SYNC 2 202d43f3010STakashi Iwai #define LOLA_CLOCK_TYPE_WORDCLOCK 3 203d43f3010STakashi Iwai #define LOLA_CLOCK_TYPE_ETHERSOUND 4 204d43f3010STakashi Iwai #define LOLA_CLOCK_TYPE_VIDEO 5 205d43f3010STakashi Iwai 206d43f3010STakashi Iwai #define LOLA_CLOCK_FORMAT_NONE 0 207d43f3010STakashi Iwai #define LOLA_CLOCK_FORMAT_NTSC 1 208d43f3010STakashi Iwai #define LOLA_CLOCK_FORMAT_PAL 2 209d43f3010STakashi Iwai 210d43f3010STakashi Iwai #define MAX_SAMPLE_CLOCK_COUNT 48 211d43f3010STakashi Iwai 212d43f3010STakashi Iwai /* parameters used with mixer widget's mixer capabilities */ 213d43f3010STakashi Iwai #define LOLA_PEAK_METER_CAN_AGC_MASK 1 214d43f3010STakashi Iwai #define LOLA_PEAK_METER_CAN_ANALOG_CLIP_MASK 2 215d43f3010STakashi Iwai 216d43f3010STakashi Iwai struct lola_bar { 217d43f3010STakashi Iwai unsigned long addr; 218d43f3010STakashi Iwai void __iomem *remap_addr; 219d43f3010STakashi Iwai }; 220d43f3010STakashi Iwai 221d43f3010STakashi Iwai /* CORB/RIRB */ 222d43f3010STakashi Iwai struct lola_rb { 223d43f3010STakashi Iwai u32 *buf; /* CORB/RIRB buffer, 8 byte per each entry */ 224d43f3010STakashi Iwai dma_addr_t addr; /* physical address of CORB/RIRB buffer */ 225d43f3010STakashi Iwai unsigned short rp, wp; /* read/write pointers */ 226d43f3010STakashi Iwai int cmds; /* number of pending requests */ 227d43f3010STakashi Iwai }; 228d43f3010STakashi Iwai 229d43f3010STakashi Iwai /* Pin widget setup */ 230d43f3010STakashi Iwai struct lola_pin { 231d43f3010STakashi Iwai unsigned int nid; 232d43f3010STakashi Iwai bool is_analog; 233d43f3010STakashi Iwai unsigned int amp_mute; 234d43f3010STakashi Iwai unsigned int amp_step_size; 235d43f3010STakashi Iwai unsigned int amp_num_steps; 236d43f3010STakashi Iwai unsigned int amp_offset; 237d43f3010STakashi Iwai unsigned int max_level; 238d43f3010STakashi Iwai unsigned int config_default_reg; 239d43f3010STakashi Iwai unsigned int fixed_gain_list_len; 240d43f3010STakashi Iwai unsigned int cur_gain_step; 241d43f3010STakashi Iwai }; 242d43f3010STakashi Iwai 243d43f3010STakashi Iwai struct lola_pin_array { 244d43f3010STakashi Iwai unsigned int num_pins; 245d43f3010STakashi Iwai struct lola_pin pins[MAX_PINS]; 246d43f3010STakashi Iwai }; 247d43f3010STakashi Iwai 248d43f3010STakashi Iwai /* Clock widget setup */ 249d43f3010STakashi Iwai struct lola_sample_clock { 250d43f3010STakashi Iwai unsigned int type; 251d43f3010STakashi Iwai unsigned int format; 252d43f3010STakashi Iwai unsigned int freq; 253d43f3010STakashi Iwai }; 254d43f3010STakashi Iwai 255d43f3010STakashi Iwai struct lola_clock_widget { 256d43f3010STakashi Iwai unsigned int nid; 257d43f3010STakashi Iwai unsigned int items; 258d43f3010STakashi Iwai unsigned int cur_index; 259d43f3010STakashi Iwai unsigned int cur_freq; 260d43f3010STakashi Iwai bool cur_valid; 261d43f3010STakashi Iwai struct lola_sample_clock sample_clock[MAX_SAMPLE_CLOCK_COUNT]; 262d43f3010STakashi Iwai unsigned int idx_lookup[MAX_SAMPLE_CLOCK_COUNT]; 263d43f3010STakashi Iwai }; 264d43f3010STakashi Iwai 265d43f3010STakashi Iwai #define LOLA_MIXER_DIM 32 266d43f3010STakashi Iwai struct lola_mixer_array { 267d43f3010STakashi Iwai u32 src_gain_enable; 268d43f3010STakashi Iwai u32 dest_mix_gain_enable[LOLA_MIXER_DIM]; 269d43f3010STakashi Iwai u16 src_gain[LOLA_MIXER_DIM]; 270d43f3010STakashi Iwai u16 dest_mix_gain[LOLA_MIXER_DIM][LOLA_MIXER_DIM]; 271d43f3010STakashi Iwai }; 272d43f3010STakashi Iwai 273d43f3010STakashi Iwai /* Mixer widget setup */ 274d43f3010STakashi Iwai struct lola_mixer_widget { 275d43f3010STakashi Iwai unsigned int nid; 276d43f3010STakashi Iwai unsigned int caps; 277d43f3010STakashi Iwai struct lola_mixer_array __user *array; 278d43f3010STakashi Iwai struct lola_mixer_array *array_saved; 279d43f3010STakashi Iwai unsigned int src_stream_outs; 280d43f3010STakashi Iwai unsigned int src_phys_ins; 281d43f3010STakashi Iwai unsigned int dest_stream_ins; 282d43f3010STakashi Iwai unsigned int dest_phys_outs; 283d43f3010STakashi Iwai unsigned int src_stream_out_ofs; 284d43f3010STakashi Iwai unsigned int dest_phys_out_ofs; 285d43f3010STakashi Iwai unsigned int src_mask; 286d43f3010STakashi Iwai unsigned int dest_mask; 287d43f3010STakashi Iwai }; 288d43f3010STakashi Iwai 289d43f3010STakashi Iwai /* Audio stream */ 290d43f3010STakashi Iwai struct lola_stream { 291d43f3010STakashi Iwai unsigned int nid; /* audio widget NID */ 292d43f3010STakashi Iwai unsigned int index; /* array index */ 293d43f3010STakashi Iwai unsigned int dsd; /* DSD index */ 294d43f3010STakashi Iwai bool can_float; 295d43f3010STakashi Iwai struct snd_pcm_substream *substream; /* assigned PCM substream */ 296d43f3010STakashi Iwai struct lola_stream *master; /* master stream (for multi-channel) */ 297d43f3010STakashi Iwai 298d43f3010STakashi Iwai /* buffer setup */ 299d43f3010STakashi Iwai unsigned int bufsize; 300d43f3010STakashi Iwai unsigned int period_bytes; 301d43f3010STakashi Iwai unsigned int frags; 302d43f3010STakashi Iwai 303d43f3010STakashi Iwai /* format + channel setup */ 304d43f3010STakashi Iwai unsigned int format_verb; 305d43f3010STakashi Iwai 306d43f3010STakashi Iwai /* flags */ 307d43f3010STakashi Iwai unsigned int opened:1; 308d43f3010STakashi Iwai unsigned int running:1; 309d43f3010STakashi Iwai }; 310d43f3010STakashi Iwai 311d43f3010STakashi Iwai #define PLAY SNDRV_PCM_STREAM_PLAYBACK 312d43f3010STakashi Iwai #define CAPT SNDRV_PCM_STREAM_CAPTURE 313d43f3010STakashi Iwai 314d43f3010STakashi Iwai struct lola_pcm { 315d43f3010STakashi Iwai unsigned int num_streams; 316*333ff397STakashi Iwai struct snd_dma_buffer bdl; /* BDL buffer */ 317d43f3010STakashi Iwai struct lola_stream streams[MAX_STREAM_COUNT]; 318d43f3010STakashi Iwai }; 319d43f3010STakashi Iwai 320d43f3010STakashi Iwai /* card instance */ 321d43f3010STakashi Iwai struct lola { 322d43f3010STakashi Iwai struct snd_card *card; 323d43f3010STakashi Iwai struct pci_dev *pci; 324d43f3010STakashi Iwai 325d43f3010STakashi Iwai /* pci resources */ 326d43f3010STakashi Iwai struct lola_bar bar[2]; 327d43f3010STakashi Iwai int irq; 328d43f3010STakashi Iwai 329d43f3010STakashi Iwai /* locks */ 330d43f3010STakashi Iwai spinlock_t reg_lock; 331d43f3010STakashi Iwai struct mutex open_mutex; 332d43f3010STakashi Iwai 333d43f3010STakashi Iwai /* CORB/RIRB */ 334d43f3010STakashi Iwai struct lola_rb corb; 335d43f3010STakashi Iwai struct lola_rb rirb; 336d43f3010STakashi Iwai unsigned int res, res_ex; /* last read values */ 337d43f3010STakashi Iwai /* last command (for debugging) */ 338d43f3010STakashi Iwai unsigned int last_cmd_nid, last_verb, last_data, last_extdata; 339d43f3010STakashi Iwai 340d43f3010STakashi Iwai /* CORB/RIRB buffers */ 341d43f3010STakashi Iwai struct snd_dma_buffer rb; 342d43f3010STakashi Iwai 343d43f3010STakashi Iwai /* unsolicited events */ 344d43f3010STakashi Iwai unsigned int last_unsol_res; 345d43f3010STakashi Iwai 346d43f3010STakashi Iwai /* streams */ 347d43f3010STakashi Iwai struct lola_pcm pcm[2]; 348d43f3010STakashi Iwai 349d43f3010STakashi Iwai /* input src */ 350d43f3010STakashi Iwai unsigned int input_src_caps_mask; 351d43f3010STakashi Iwai unsigned int input_src_mask; 352d43f3010STakashi Iwai 353d43f3010STakashi Iwai /* pins */ 354d43f3010STakashi Iwai struct lola_pin_array pin[2]; 355d43f3010STakashi Iwai 356d43f3010STakashi Iwai /* clock */ 357d43f3010STakashi Iwai struct lola_clock_widget clock; 358d43f3010STakashi Iwai 359d43f3010STakashi Iwai /* mixer */ 360d43f3010STakashi Iwai struct lola_mixer_widget mixer; 361d43f3010STakashi Iwai 362d43f3010STakashi Iwai /* hw info */ 363d43f3010STakashi Iwai unsigned int version; 364d43f3010STakashi Iwai unsigned int lola_caps; 365d43f3010STakashi Iwai 366d43f3010STakashi Iwai /* parameters */ 367d43f3010STakashi Iwai unsigned int granularity; 368d43f3010STakashi Iwai unsigned int sample_rate_min; 369d43f3010STakashi Iwai 370d43f3010STakashi Iwai /* flags */ 371d43f3010STakashi Iwai unsigned int running :1; 372d43f3010STakashi Iwai unsigned int initialized :1; 373d43f3010STakashi Iwai unsigned int cold_reset :1; 374d43f3010STakashi Iwai 375d43f3010STakashi Iwai /* for debugging */ 376d43f3010STakashi Iwai unsigned int debug_res; 377d43f3010STakashi Iwai unsigned int debug_res_ex; 378d43f3010STakashi Iwai }; 379d43f3010STakashi Iwai 380d43f3010STakashi Iwai #define BAR0 0 381d43f3010STakashi Iwai #define BAR1 1 382d43f3010STakashi Iwai 383d43f3010STakashi Iwai /* Helper macros */ 384d43f3010STakashi Iwai #define lola_readl(chip, idx, name) \ 385d43f3010STakashi Iwai readl((chip)->bar[idx].remap_addr + LOLA_##idx##_##name) 386d43f3010STakashi Iwai #define lola_readw(chip, idx, name) \ 387d43f3010STakashi Iwai readw((chip)->bar[idx].remap_addr + LOLA_##idx##_##name) 388d43f3010STakashi Iwai #define lola_readb(chip, idx, name) \ 389d43f3010STakashi Iwai readb((chip)->bar[idx].remap_addr + LOLA_##idx##_##name) 390d43f3010STakashi Iwai #define lola_writel(chip, idx, name, val) \ 391d43f3010STakashi Iwai writel((val), (chip)->bar[idx].remap_addr + LOLA_##idx##_##name) 392d43f3010STakashi Iwai #define lola_writew(chip, idx, name, val) \ 393d43f3010STakashi Iwai writew((val), (chip)->bar[idx].remap_addr + LOLA_##idx##_##name) 394d43f3010STakashi Iwai #define lola_writeb(chip, idx, name, val) \ 395d43f3010STakashi Iwai writeb((val), (chip)->bar[idx].remap_addr + LOLA_##idx##_##name) 396d43f3010STakashi Iwai 397d43f3010STakashi Iwai #define lola_dsd_read(chip, dsd, name) \ 398d43f3010STakashi Iwai readl((chip)->bar[BAR1].remap_addr + LOLA_BAR1_DSD0_OFFSET + \ 399d43f3010STakashi Iwai (LOLA_BAR1_DSD_SIZE * (dsd)) + LOLA_BAR1_DSDn##name) 400d43f3010STakashi Iwai #define lola_dsd_write(chip, dsd, name, val) \ 401d43f3010STakashi Iwai writel((val), (chip)->bar[BAR1].remap_addr + LOLA_BAR1_DSD0_OFFSET + \ 402d43f3010STakashi Iwai (LOLA_BAR1_DSD_SIZE * (dsd)) + LOLA_BAR1_DSDn##name) 403d43f3010STakashi Iwai 404d43f3010STakashi Iwai /* GET verbs HDAudio */ 405d43f3010STakashi Iwai #define LOLA_VERB_GET_STREAM_FORMAT 0xa00 406d43f3010STakashi Iwai #define LOLA_VERB_GET_AMP_GAIN_MUTE 0xb00 407d43f3010STakashi Iwai #define LOLA_VERB_PARAMETERS 0xf00 408d43f3010STakashi Iwai #define LOLA_VERB_GET_POWER_STATE 0xf05 409d43f3010STakashi Iwai #define LOLA_VERB_GET_CONV 0xf06 410d43f3010STakashi Iwai #define LOLA_VERB_GET_UNSOLICITED_RESPONSE 0xf08 411d43f3010STakashi Iwai #define LOLA_VERB_GET_DIGI_CONVERT_1 0xf0d 412d43f3010STakashi Iwai #define LOLA_VERB_GET_CONFIG_DEFAULT 0xf1c 413d43f3010STakashi Iwai #define LOLA_VERB_GET_SUBSYSTEM_ID 0xf20 414d43f3010STakashi Iwai /* GET verbs Digigram */ 415d43f3010STakashi Iwai #define LOLA_VERB_GET_FIXED_GAIN 0xfc0 416d43f3010STakashi Iwai #define LOLA_VERB_GET_GAIN_SELECT 0xfc1 417d43f3010STakashi Iwai #define LOLA_VERB_GET_MAX_LEVEL 0xfc2 418d43f3010STakashi Iwai #define LOLA_VERB_GET_CLOCK_LIST 0xfc3 419d43f3010STakashi Iwai #define LOLA_VERB_GET_CLOCK_SELECT 0xfc4 420d43f3010STakashi Iwai #define LOLA_VERB_GET_CLOCK_STATUS 0xfc5 421d43f3010STakashi Iwai 422d43f3010STakashi Iwai /* SET verbs HDAudio */ 423d43f3010STakashi Iwai #define LOLA_VERB_SET_STREAM_FORMAT 0x200 424d43f3010STakashi Iwai #define LOLA_VERB_SET_AMP_GAIN_MUTE 0x300 425d43f3010STakashi Iwai #define LOLA_VERB_SET_POWER_STATE 0x705 426d43f3010STakashi Iwai #define LOLA_VERB_SET_CHANNEL_STREAMID 0x706 427d43f3010STakashi Iwai #define LOLA_VERB_SET_UNSOLICITED_ENABLE 0x708 428d43f3010STakashi Iwai #define LOLA_VERB_SET_DIGI_CONVERT_1 0x70d 429d43f3010STakashi Iwai /* SET verbs Digigram */ 430d43f3010STakashi Iwai #define LOLA_VERB_SET_GAIN_SELECT 0xf81 431d43f3010STakashi Iwai #define LOLA_VERB_SET_CLOCK_SELECT 0xf84 432d43f3010STakashi Iwai #define LOLA_VERB_SET_GRANULARITY_STEPS 0xf86 433d43f3010STakashi Iwai #define LOLA_VERB_SET_SOURCE_GAIN 0xf87 434d43f3010STakashi Iwai #define LOLA_VERB_SET_MIX_GAIN 0xf88 435d43f3010STakashi Iwai #define LOLA_VERB_SET_DESTINATION_GAIN 0xf89 436d43f3010STakashi Iwai #define LOLA_VERB_SET_SRC 0xf8a 437d43f3010STakashi Iwai 438d43f3010STakashi Iwai /* Parameter IDs used with LOLA_VERB_PARAMETERS */ 439d43f3010STakashi Iwai #define LOLA_PAR_VENDOR_ID 0x00 440d43f3010STakashi Iwai #define LOLA_PAR_FUNCTION_TYPE 0x05 441d43f3010STakashi Iwai #define LOLA_PAR_AUDIO_WIDGET_CAP 0x09 442d43f3010STakashi Iwai #define LOLA_PAR_PCM 0x0a 443d43f3010STakashi Iwai #define LOLA_PAR_STREAM_FORMATS 0x0b 444d43f3010STakashi Iwai #define LOLA_PAR_PIN_CAP 0x0c 445d43f3010STakashi Iwai #define LOLA_PAR_AMP_IN_CAP 0x0d 446d43f3010STakashi Iwai #define LOLA_PAR_CONNLIST_LEN 0x0e 447d43f3010STakashi Iwai #define LOLA_PAR_POWER_STATE 0x0f 448d43f3010STakashi Iwai #define LOLA_PAR_GPIO_CAP 0x11 449d43f3010STakashi Iwai #define LOLA_PAR_AMP_OUT_CAP 0x12 450d43f3010STakashi Iwai #define LOLA_PAR_SPECIFIC_CAPS 0x80 451d43f3010STakashi Iwai #define LOLA_PAR_FIXED_GAIN_LIST 0x81 452d43f3010STakashi Iwai 453d43f3010STakashi Iwai /* extract results of LOLA_PAR_SPECIFIC_CAPS */ 454d43f3010STakashi Iwai #define LOLA_AFG_MIXER_WIDGET_PRESENT(res) ((res & (1 << 21)) != 0) 455d43f3010STakashi Iwai #define LOLA_AFG_CLOCK_WIDGET_PRESENT(res) ((res & (1 << 20)) != 0) 456d43f3010STakashi Iwai #define LOLA_AFG_INPUT_PIN_COUNT(res) ((res >> 10) & 0x2ff) 457d43f3010STakashi Iwai #define LOLA_AFG_OUTPUT_PIN_COUNT(res) ((res) & 0x2ff) 458d43f3010STakashi Iwai 459d43f3010STakashi Iwai /* extract results of LOLA_PAR_AMP_IN_CAP / LOLA_PAR_AMP_OUT_CAP */ 460d43f3010STakashi Iwai #define LOLA_AMP_MUTE_CAPABLE(res) ((res & (1 << 31)) != 0) 461d43f3010STakashi Iwai #define LOLA_AMP_STEP_SIZE(res) ((res >> 24) & 0x7f) 462d43f3010STakashi Iwai #define LOLA_AMP_NUM_STEPS(res) ((res >> 12) & 0x3ff) 463d43f3010STakashi Iwai #define LOLA_AMP_OFFSET(res) ((res) & 0x3ff) 464d43f3010STakashi Iwai 465d43f3010STakashi Iwai #define LOLA_GRANULARITY_MIN 8 466d43f3010STakashi Iwai #define LOLA_GRANULARITY_MAX 32 467d43f3010STakashi Iwai #define LOLA_GRANULARITY_STEP 8 468d43f3010STakashi Iwai 469d43f3010STakashi Iwai /* parameters used with unsolicited command/response */ 470d43f3010STakashi Iwai #define LOLA_UNSOLICITED_TAG_MASK 0x3f 471d43f3010STakashi Iwai #define LOLA_UNSOLICITED_TAG 0x1a 472d43f3010STakashi Iwai #define LOLA_UNSOLICITED_ENABLE 0x80 473d43f3010STakashi Iwai #define LOLA_UNSOL_RESP_TAG_OFFSET 26 474d43f3010STakashi Iwai 475d43f3010STakashi Iwai /* count values in the Vendor Specific Mixer Widget's Audio Widget Capabilities */ 476d43f3010STakashi Iwai #define LOLA_MIXER_SRC_INPUT_PLAY_SEPARATION(res) ((res >> 2) & 0x1f) 477d43f3010STakashi Iwai #define LOLA_MIXER_DEST_REC_OUTPUT_SEPATATION(res) ((res >> 7) & 0x1f) 478d43f3010STakashi Iwai 479d43f3010STakashi Iwai int lola_codec_write(struct lola *chip, unsigned int nid, unsigned int verb, 480d43f3010STakashi Iwai unsigned int data, unsigned int extdata); 481d43f3010STakashi Iwai int lola_codec_read(struct lola *chip, unsigned int nid, unsigned int verb, 482d43f3010STakashi Iwai unsigned int data, unsigned int extdata, 483d43f3010STakashi Iwai unsigned int *val, unsigned int *extval); 484d43f3010STakashi Iwai int lola_codec_flush(struct lola *chip); 485d43f3010STakashi Iwai #define lola_read_param(chip, nid, param, val) \ 486d43f3010STakashi Iwai lola_codec_read(chip, nid, LOLA_VERB_PARAMETERS, param, 0, val, NULL) 487d43f3010STakashi Iwai 488d43f3010STakashi Iwai /* PCM */ 489d43f3010STakashi Iwai int lola_create_pcm(struct lola *chip); 490d43f3010STakashi Iwai void lola_free_pcm(struct lola *chip); 491d43f3010STakashi Iwai int lola_init_pcm(struct lola *chip, int dir, int *nidp); 492d43f3010STakashi Iwai void lola_pcm_update(struct lola *chip, struct lola_pcm *pcm, unsigned int bits); 493d43f3010STakashi Iwai 494d43f3010STakashi Iwai /* clock */ 495d43f3010STakashi Iwai int lola_init_clock_widget(struct lola *chip, int nid); 496d43f3010STakashi Iwai int lola_set_granularity(struct lola *chip, unsigned int val, bool force); 497d43f3010STakashi Iwai int lola_enable_clock_events(struct lola *chip); 498d43f3010STakashi Iwai int lola_set_clock_index(struct lola *chip, unsigned int idx); 499d43f3010STakashi Iwai int lola_set_clock(struct lola *chip, int idx); 500d43f3010STakashi Iwai int lola_set_sample_rate(struct lola *chip, int rate); 501d43f3010STakashi Iwai bool lola_update_ext_clock_freq(struct lola *chip, unsigned int val); 5021c5d7b31STakashi Iwai unsigned int lola_sample_rate_convert(unsigned int coded); 503d43f3010STakashi Iwai 504d43f3010STakashi Iwai /* mixer */ 505d43f3010STakashi Iwai int lola_init_pins(struct lola *chip, int dir, int *nidp); 506d43f3010STakashi Iwai int lola_init_mixer_widget(struct lola *chip, int nid); 507d43f3010STakashi Iwai void lola_free_mixer(struct lola *chip); 508d43f3010STakashi Iwai int lola_create_mixer(struct lola *chip); 509d43f3010STakashi Iwai int lola_setup_all_analog_gains(struct lola *chip, int dir, bool mute); 510d43f3010STakashi Iwai void lola_save_mixer(struct lola *chip); 511d43f3010STakashi Iwai void lola_restore_mixer(struct lola *chip); 512d43f3010STakashi Iwai int lola_set_src_config(struct lola *chip, unsigned int src_mask, bool update); 513d43f3010STakashi Iwai 514d43f3010STakashi Iwai /* proc */ 515d43f3010STakashi Iwai #ifdef CONFIG_SND_DEBUG 516d43f3010STakashi Iwai void lola_proc_debug_new(struct lola *chip); 517d43f3010STakashi Iwai #else 518d43f3010STakashi Iwai #define lola_proc_debug_new(chip) 519d43f3010STakashi Iwai #endif 520d43f3010STakashi Iwai 521d43f3010STakashi Iwai #endif /* _LOLA_H */ 522