lola.h 16 KB

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