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