hdac_controller.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * HD-audio controller helpers
  3. */
  4. #include <linux/kernel.h>
  5. #include <linux/delay.h>
  6. #include <linux/export.h>
  7. #include <sound/core.h>
  8. #include <sound/hdaudio.h>
  9. #include <sound/hda_register.h>
  10. /* clear CORB read pointer properly */
  11. static void azx_clear_corbrp(struct hdac_bus *bus)
  12. {
  13. int timeout;
  14. for (timeout = 1000; timeout > 0; timeout--) {
  15. if (snd_hdac_chip_readw(bus, CORBRP) & AZX_CORBRP_RST)
  16. break;
  17. udelay(1);
  18. }
  19. if (timeout <= 0)
  20. dev_err(bus->dev, "CORB reset timeout#1, CORBRP = %d\n",
  21. snd_hdac_chip_readw(bus, CORBRP));
  22. snd_hdac_chip_writew(bus, CORBRP, 0);
  23. for (timeout = 1000; timeout > 0; timeout--) {
  24. if (snd_hdac_chip_readw(bus, CORBRP) == 0)
  25. break;
  26. udelay(1);
  27. }
  28. if (timeout <= 0)
  29. dev_err(bus->dev, "CORB reset timeout#2, CORBRP = %d\n",
  30. snd_hdac_chip_readw(bus, CORBRP));
  31. }
  32. /**
  33. * snd_hdac_bus_init_cmd_io - set up CORB/RIRB buffers
  34. * @bus: HD-audio core bus
  35. */
  36. void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
  37. {
  38. spin_lock_irq(&bus->reg_lock);
  39. /* CORB set up */
  40. bus->corb.addr = bus->rb.addr;
  41. bus->corb.buf = (__le32 *)bus->rb.area;
  42. snd_hdac_chip_writel(bus, CORBLBASE, (u32)bus->corb.addr);
  43. snd_hdac_chip_writel(bus, CORBUBASE, upper_32_bits(bus->corb.addr));
  44. /* set the corb size to 256 entries (ULI requires explicitly) */
  45. snd_hdac_chip_writeb(bus, CORBSIZE, 0x02);
  46. /* set the corb write pointer to 0 */
  47. snd_hdac_chip_writew(bus, CORBWP, 0);
  48. /* reset the corb hw read pointer */
  49. snd_hdac_chip_writew(bus, CORBRP, AZX_CORBRP_RST);
  50. if (!bus->corbrp_self_clear)
  51. azx_clear_corbrp(bus);
  52. /* enable corb dma */
  53. snd_hdac_chip_writeb(bus, CORBCTL, AZX_CORBCTL_RUN);
  54. /* RIRB set up */
  55. bus->rirb.addr = bus->rb.addr + 2048;
  56. bus->rirb.buf = (__le32 *)(bus->rb.area + 2048);
  57. bus->rirb.wp = bus->rirb.rp = 0;
  58. memset(bus->rirb.cmds, 0, sizeof(bus->rirb.cmds));
  59. snd_hdac_chip_writel(bus, RIRBLBASE, (u32)bus->rirb.addr);
  60. snd_hdac_chip_writel(bus, RIRBUBASE, upper_32_bits(bus->rirb.addr));
  61. /* set the rirb size to 256 entries (ULI requires explicitly) */
  62. snd_hdac_chip_writeb(bus, RIRBSIZE, 0x02);
  63. /* reset the rirb hw write pointer */
  64. snd_hdac_chip_writew(bus, RIRBWP, AZX_RIRBWP_RST);
  65. /* set N=1, get RIRB response interrupt for new entry */
  66. snd_hdac_chip_writew(bus, RINTCNT, 1);
  67. /* enable rirb dma and response irq */
  68. snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN);
  69. spin_unlock_irq(&bus->reg_lock);
  70. }
  71. EXPORT_SYMBOL_GPL(snd_hdac_bus_init_cmd_io);
  72. /* wait for cmd dmas till they are stopped */
  73. static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus)
  74. {
  75. unsigned long timeout;
  76. timeout = jiffies + msecs_to_jiffies(100);
  77. while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN)
  78. && time_before(jiffies, timeout))
  79. udelay(10);
  80. timeout = jiffies + msecs_to_jiffies(100);
  81. while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN)
  82. && time_before(jiffies, timeout))
  83. udelay(10);
  84. }
  85. /**
  86. * snd_hdac_bus_stop_cmd_io - clean up CORB/RIRB buffers
  87. * @bus: HD-audio core bus
  88. */
  89. void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus)
  90. {
  91. spin_lock_irq(&bus->reg_lock);
  92. /* disable ringbuffer DMAs */
  93. snd_hdac_chip_writeb(bus, RIRBCTL, 0);
  94. snd_hdac_chip_writeb(bus, CORBCTL, 0);
  95. spin_unlock_irq(&bus->reg_lock);
  96. hdac_wait_for_cmd_dmas(bus);
  97. spin_lock_irq(&bus->reg_lock);
  98. /* disable unsolicited responses */
  99. snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0);
  100. spin_unlock_irq(&bus->reg_lock);
  101. }
  102. EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_cmd_io);
  103. static unsigned int azx_command_addr(u32 cmd)
  104. {
  105. unsigned int addr = cmd >> 28;
  106. if (snd_BUG_ON(addr >= HDA_MAX_CODECS))
  107. addr = 0;
  108. return addr;
  109. }
  110. /**
  111. * snd_hdac_bus_send_cmd - send a command verb via CORB
  112. * @bus: HD-audio core bus
  113. * @val: encoded verb value to send
  114. *
  115. * Returns zero for success or a negative error code.
  116. */
  117. int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val)
  118. {
  119. unsigned int addr = azx_command_addr(val);
  120. unsigned int wp, rp;
  121. spin_lock_irq(&bus->reg_lock);
  122. bus->last_cmd[azx_command_addr(val)] = val;
  123. /* add command to corb */
  124. wp = snd_hdac_chip_readw(bus, CORBWP);
  125. if (wp == 0xffff) {
  126. /* something wrong, controller likely turned to D3 */
  127. spin_unlock_irq(&bus->reg_lock);
  128. return -EIO;
  129. }
  130. wp++;
  131. wp %= AZX_MAX_CORB_ENTRIES;
  132. rp = snd_hdac_chip_readw(bus, CORBRP);
  133. if (wp == rp) {
  134. /* oops, it's full */
  135. spin_unlock_irq(&bus->reg_lock);
  136. return -EAGAIN;
  137. }
  138. bus->rirb.cmds[addr]++;
  139. bus->corb.buf[wp] = cpu_to_le32(val);
  140. snd_hdac_chip_writew(bus, CORBWP, wp);
  141. spin_unlock_irq(&bus->reg_lock);
  142. return 0;
  143. }
  144. EXPORT_SYMBOL_GPL(snd_hdac_bus_send_cmd);
  145. #define AZX_RIRB_EX_UNSOL_EV (1<<4)
  146. /**
  147. * snd_hdac_bus_update_rirb - retrieve RIRB entries
  148. * @bus: HD-audio core bus
  149. *
  150. * Usually called from interrupt handler.
  151. */
  152. void snd_hdac_bus_update_rirb(struct hdac_bus *bus)
  153. {
  154. unsigned int rp, wp;
  155. unsigned int addr;
  156. u32 res, res_ex;
  157. wp = snd_hdac_chip_readw(bus, RIRBWP);
  158. if (wp == 0xffff) {
  159. /* something wrong, controller likely turned to D3 */
  160. return;
  161. }
  162. if (wp == bus->rirb.wp)
  163. return;
  164. bus->rirb.wp = wp;
  165. while (bus->rirb.rp != wp) {
  166. bus->rirb.rp++;
  167. bus->rirb.rp %= AZX_MAX_RIRB_ENTRIES;
  168. rp = bus->rirb.rp << 1; /* an RIRB entry is 8-bytes */
  169. res_ex = le32_to_cpu(bus->rirb.buf[rp + 1]);
  170. res = le32_to_cpu(bus->rirb.buf[rp]);
  171. addr = res_ex & 0xf;
  172. if (addr >= HDA_MAX_CODECS) {
  173. dev_err(bus->dev,
  174. "spurious response %#x:%#x, rp = %d, wp = %d",
  175. res, res_ex, bus->rirb.rp, wp);
  176. snd_BUG();
  177. } else if (res_ex & AZX_RIRB_EX_UNSOL_EV)
  178. snd_hdac_bus_queue_event(bus, res, res_ex);
  179. else if (bus->rirb.cmds[addr]) {
  180. bus->rirb.res[addr] = res;
  181. bus->rirb.cmds[addr]--;
  182. } else {
  183. dev_err_ratelimited(bus->dev,
  184. "spurious response %#x:%#x, last cmd=%#08x\n",
  185. res, res_ex, bus->last_cmd[addr]);
  186. }
  187. }
  188. }
  189. EXPORT_SYMBOL_GPL(snd_hdac_bus_update_rirb);
  190. /**
  191. * snd_hdac_bus_get_response - receive a response via RIRB
  192. * @bus: HD-audio core bus
  193. * @addr: codec address
  194. * @res: pointer to store the value, NULL when not needed
  195. *
  196. * Returns zero if a value is read, or a negative error code.
  197. */
  198. int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
  199. unsigned int *res)
  200. {
  201. unsigned long timeout;
  202. unsigned long loopcounter;
  203. timeout = jiffies + msecs_to_jiffies(1000);
  204. for (loopcounter = 0;; loopcounter++) {
  205. spin_lock_irq(&bus->reg_lock);
  206. if (!bus->rirb.cmds[addr]) {
  207. if (res)
  208. *res = bus->rirb.res[addr]; /* the last value */
  209. spin_unlock_irq(&bus->reg_lock);
  210. return 0;
  211. }
  212. spin_unlock_irq(&bus->reg_lock);
  213. if (time_after(jiffies, timeout))
  214. break;
  215. if (loopcounter > 3000)
  216. msleep(2); /* temporary workaround */
  217. else {
  218. udelay(10);
  219. cond_resched();
  220. }
  221. }
  222. return -EIO;
  223. }
  224. EXPORT_SYMBOL_GPL(snd_hdac_bus_get_response);
  225. #define HDAC_MAX_CAPS 10
  226. /**
  227. * snd_hdac_bus_parse_capabilities - parse capability structure
  228. * @bus: the pointer to bus object
  229. *
  230. * Returns 0 if successful, or a negative error code.
  231. */
  232. int snd_hdac_bus_parse_capabilities(struct hdac_bus *bus)
  233. {
  234. unsigned int cur_cap;
  235. unsigned int offset;
  236. unsigned int counter = 0;
  237. offset = snd_hdac_chip_readl(bus, LLCH);
  238. /* Lets walk the linked capabilities list */
  239. do {
  240. cur_cap = _snd_hdac_chip_read(l, bus, offset);
  241. dev_dbg(bus->dev, "Capability version: 0x%x\n",
  242. (cur_cap & AZX_CAP_HDR_VER_MASK) >> AZX_CAP_HDR_VER_OFF);
  243. dev_dbg(bus->dev, "HDA capability ID: 0x%x\n",
  244. (cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF);
  245. if (cur_cap == -1) {
  246. dev_dbg(bus->dev, "Invalid capability reg read\n");
  247. break;
  248. }
  249. switch ((cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF) {
  250. case AZX_ML_CAP_ID:
  251. dev_dbg(bus->dev, "Found ML capability\n");
  252. bus->mlcap = bus->remap_addr + offset;
  253. break;
  254. case AZX_GTS_CAP_ID:
  255. dev_dbg(bus->dev, "Found GTS capability offset=%x\n", offset);
  256. bus->gtscap = bus->remap_addr + offset;
  257. break;
  258. case AZX_PP_CAP_ID:
  259. /* PP capability found, the Audio DSP is present */
  260. dev_dbg(bus->dev, "Found PP capability offset=%x\n", offset);
  261. bus->ppcap = bus->remap_addr + offset;
  262. break;
  263. case AZX_SPB_CAP_ID:
  264. /* SPIB capability found, handler function */
  265. dev_dbg(bus->dev, "Found SPB capability\n");
  266. bus->spbcap = bus->remap_addr + offset;
  267. break;
  268. case AZX_DRSM_CAP_ID:
  269. /* DMA resume capability found, handler function */
  270. dev_dbg(bus->dev, "Found DRSM capability\n");
  271. bus->drsmcap = bus->remap_addr + offset;
  272. break;
  273. default:
  274. dev_dbg(bus->dev, "Unknown capability %d\n", cur_cap);
  275. break;
  276. }
  277. counter++;
  278. if (counter > HDAC_MAX_CAPS) {
  279. dev_err(bus->dev, "We exceeded HDAC capabilities!!!\n");
  280. break;
  281. }
  282. /* read the offset of next capability */
  283. offset = cur_cap & AZX_CAP_HDR_NXT_PTR_MASK;
  284. } while (offset);
  285. return 0;
  286. }
  287. EXPORT_SYMBOL_GPL(snd_hdac_bus_parse_capabilities);
  288. /*
  289. * Lowlevel interface
  290. */
  291. /**
  292. * snd_hdac_bus_enter_link_reset - enter link reset
  293. * @bus: HD-audio core bus
  294. *
  295. * Enter to the link reset state.
  296. */
  297. void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus)
  298. {
  299. unsigned long timeout;
  300. /* reset controller */
  301. snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_RESET, 0);
  302. timeout = jiffies + msecs_to_jiffies(100);
  303. while ((snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET) &&
  304. time_before(jiffies, timeout))
  305. usleep_range(500, 1000);
  306. }
  307. EXPORT_SYMBOL_GPL(snd_hdac_bus_enter_link_reset);
  308. /**
  309. * snd_hdac_bus_exit_link_reset - exit link reset
  310. * @bus: HD-audio core bus
  311. *
  312. * Exit from the link reset state.
  313. */
  314. void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus)
  315. {
  316. unsigned long timeout;
  317. snd_hdac_chip_updateb(bus, GCTL, 0, AZX_GCTL_RESET);
  318. timeout = jiffies + msecs_to_jiffies(100);
  319. while (!snd_hdac_chip_readb(bus, GCTL) && time_before(jiffies, timeout))
  320. usleep_range(500, 1000);
  321. }
  322. EXPORT_SYMBOL_GPL(snd_hdac_bus_exit_link_reset);
  323. /* reset codec link */
  324. static int azx_reset(struct hdac_bus *bus, bool full_reset)
  325. {
  326. if (!full_reset)
  327. goto skip_reset;
  328. /* clear STATESTS */
  329. snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK);
  330. /* reset controller */
  331. snd_hdac_bus_enter_link_reset(bus);
  332. /* delay for >= 100us for codec PLL to settle per spec
  333. * Rev 0.9 section 5.5.1
  334. */
  335. usleep_range(500, 1000);
  336. /* Bring controller out of reset */
  337. snd_hdac_bus_exit_link_reset(bus);
  338. /* Brent Chartrand said to wait >= 540us for codecs to initialize */
  339. usleep_range(1000, 1200);
  340. skip_reset:
  341. /* check to see if controller is ready */
  342. if (!snd_hdac_chip_readb(bus, GCTL)) {
  343. dev_dbg(bus->dev, "azx_reset: controller not ready!\n");
  344. return -EBUSY;
  345. }
  346. /* Accept unsolicited responses */
  347. snd_hdac_chip_updatel(bus, GCTL, 0, AZX_GCTL_UNSOL);
  348. /* detect codecs */
  349. if (!bus->codec_mask) {
  350. bus->codec_mask = snd_hdac_chip_readw(bus, STATESTS);
  351. dev_dbg(bus->dev, "codec_mask = 0x%lx\n", bus->codec_mask);
  352. }
  353. return 0;
  354. }
  355. /* enable interrupts */
  356. static void azx_int_enable(struct hdac_bus *bus)
  357. {
  358. /* enable controller CIE and GIE */
  359. snd_hdac_chip_updatel(bus, INTCTL, 0, AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN);
  360. }
  361. /* disable interrupts */
  362. static void azx_int_disable(struct hdac_bus *bus)
  363. {
  364. struct hdac_stream *azx_dev;
  365. /* disable interrupts in stream descriptor */
  366. list_for_each_entry(azx_dev, &bus->stream_list, list)
  367. snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0);
  368. /* disable SIE for all streams */
  369. snd_hdac_chip_writeb(bus, INTCTL, 0);
  370. /* disable controller CIE and GIE */
  371. snd_hdac_chip_updatel(bus, INTCTL, AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN, 0);
  372. }
  373. /* clear interrupts */
  374. static void azx_int_clear(struct hdac_bus *bus)
  375. {
  376. struct hdac_stream *azx_dev;
  377. /* clear stream status */
  378. list_for_each_entry(azx_dev, &bus->stream_list, list)
  379. snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK);
  380. /* clear STATESTS */
  381. snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK);
  382. /* clear rirb status */
  383. snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK);
  384. /* clear int status */
  385. snd_hdac_chip_writel(bus, INTSTS, AZX_INT_CTRL_EN | AZX_INT_ALL_STREAM);
  386. }
  387. /**
  388. * snd_hdac_bus_init_chip - reset and start the controller registers
  389. * @bus: HD-audio core bus
  390. * @full_reset: Do full reset
  391. */
  392. bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
  393. {
  394. if (bus->chip_init)
  395. return false;
  396. /* reset controller */
  397. azx_reset(bus, full_reset);
  398. /* initialize interrupts */
  399. azx_int_clear(bus);
  400. azx_int_enable(bus);
  401. /* initialize the codec command I/O */
  402. snd_hdac_bus_init_cmd_io(bus);
  403. /* program the position buffer */
  404. if (bus->use_posbuf && bus->posbuf.addr) {
  405. snd_hdac_chip_writel(bus, DPLBASE, (u32)bus->posbuf.addr);
  406. snd_hdac_chip_writel(bus, DPUBASE, upper_32_bits(bus->posbuf.addr));
  407. }
  408. bus->chip_init = true;
  409. return true;
  410. }
  411. EXPORT_SYMBOL_GPL(snd_hdac_bus_init_chip);
  412. /**
  413. * snd_hdac_bus_stop_chip - disable the whole IRQ and I/Os
  414. * @bus: HD-audio core bus
  415. */
  416. void snd_hdac_bus_stop_chip(struct hdac_bus *bus)
  417. {
  418. if (!bus->chip_init)
  419. return;
  420. /* disable interrupts */
  421. azx_int_disable(bus);
  422. azx_int_clear(bus);
  423. /* disable CORB/RIRB */
  424. snd_hdac_bus_stop_cmd_io(bus);
  425. /* disable position buffer */
  426. if (bus->posbuf.addr) {
  427. snd_hdac_chip_writel(bus, DPLBASE, 0);
  428. snd_hdac_chip_writel(bus, DPUBASE, 0);
  429. }
  430. bus->chip_init = false;
  431. }
  432. EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);
  433. /**
  434. * snd_hdac_bus_handle_stream_irq - interrupt handler for streams
  435. * @bus: HD-audio core bus
  436. * @status: INTSTS register value
  437. * @ask: callback to be called for woken streams
  438. *
  439. * Returns the bits of handled streams, or zero if no stream is handled.
  440. */
  441. int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
  442. void (*ack)(struct hdac_bus *,
  443. struct hdac_stream *))
  444. {
  445. struct hdac_stream *azx_dev;
  446. u8 sd_status;
  447. int handled = 0;
  448. list_for_each_entry(azx_dev, &bus->stream_list, list) {
  449. if (status & azx_dev->sd_int_sta_mask) {
  450. sd_status = snd_hdac_stream_readb(azx_dev, SD_STS);
  451. snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK);
  452. handled |= 1 << azx_dev->index;
  453. if (!azx_dev->substream || !azx_dev->running ||
  454. !(sd_status & SD_INT_COMPLETE))
  455. continue;
  456. if (ack)
  457. ack(bus, azx_dev);
  458. }
  459. }
  460. return handled;
  461. }
  462. EXPORT_SYMBOL_GPL(snd_hdac_bus_handle_stream_irq);
  463. /**
  464. * snd_hdac_bus_alloc_stream_pages - allocate BDL and other buffers
  465. * @bus: HD-audio core bus
  466. *
  467. * Call this after assigning the all streams.
  468. * Returns zero for success, or a negative error code.
  469. */
  470. int snd_hdac_bus_alloc_stream_pages(struct hdac_bus *bus)
  471. {
  472. struct hdac_stream *s;
  473. int num_streams = 0;
  474. int err;
  475. list_for_each_entry(s, &bus->stream_list, list) {
  476. /* allocate memory for the BDL for each stream */
  477. err = bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV,
  478. BDL_SIZE, &s->bdl);
  479. num_streams++;
  480. if (err < 0)
  481. return -ENOMEM;
  482. }
  483. if (WARN_ON(!num_streams))
  484. return -EINVAL;
  485. /* allocate memory for the position buffer */
  486. err = bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV,
  487. num_streams * 8, &bus->posbuf);
  488. if (err < 0)
  489. return -ENOMEM;
  490. list_for_each_entry(s, &bus->stream_list, list)
  491. s->posbuf = (__le32 *)(bus->posbuf.area + s->index * 8);
  492. /* single page (at least 4096 bytes) must suffice for both ringbuffes */
  493. return bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV,
  494. PAGE_SIZE, &bus->rb);
  495. }
  496. EXPORT_SYMBOL_GPL(snd_hdac_bus_alloc_stream_pages);
  497. /**
  498. * snd_hdac_bus_free_stream_pages - release BDL and other buffers
  499. * @bus: HD-audio core bus
  500. */
  501. void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus)
  502. {
  503. struct hdac_stream *s;
  504. list_for_each_entry(s, &bus->stream_list, list) {
  505. if (s->bdl.area)
  506. bus->io_ops->dma_free_pages(bus, &s->bdl);
  507. }
  508. if (bus->rb.area)
  509. bus->io_ops->dma_free_pages(bus, &bus->rb);
  510. if (bus->posbuf.area)
  511. bus->io_ops->dma_free_pages(bus, &bus->posbuf);
  512. }
  513. EXPORT_SYMBOL_GPL(snd_hdac_bus_free_stream_pages);