|
11 | 11 | #include <linux/io.h>
|
12 | 12 | #include <linux/mm.h>
|
13 | 13 | #include <linux/delay.h>
|
| 14 | +#include <sound/hda_register.h> |
14 | 15 | #include "../common/sst-dsp.h"
|
15 | 16 | #include "../common/sst-dsp-priv.h"
|
16 | 17 |
|
@@ -79,21 +80,25 @@ static void skl_cldma_setup_bdle(struct sst_dsp *ctx,
|
79 | 80 | __le32 **bdlp, int size, int with_ioc)
|
80 | 81 | {
|
81 | 82 | __le32 *bdl = *bdlp;
|
| 83 | + int remaining = ctx->cl_dev.bufsize; |
| 84 | + int offset = 0; |
82 | 85 |
|
83 | 86 | ctx->cl_dev.frags = 0;
|
84 |
| - while (size > 0) { |
85 |
| - phys_addr_t addr = virt_to_phys(dmab_data->area + |
86 |
| - (ctx->cl_dev.frags * ctx->cl_dev.bufsize)); |
| 87 | + while (remaining > 0) { |
| 88 | + phys_addr_t addr; |
| 89 | + int chunk; |
87 | 90 |
|
| 91 | + addr = snd_sgbuf_get_addr(dmab_data, offset); |
88 | 92 | bdl[0] = cpu_to_le32(lower_32_bits(addr));
|
89 | 93 | bdl[1] = cpu_to_le32(upper_32_bits(addr));
|
| 94 | + chunk = snd_sgbuf_get_chunk_size(dmab_data, offset, size); |
| 95 | + bdl[2] = cpu_to_le32(chunk); |
90 | 96 |
|
91 |
| - bdl[2] = cpu_to_le32(ctx->cl_dev.bufsize); |
92 |
| - |
93 |
| - size -= ctx->cl_dev.bufsize; |
94 |
| - bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01); |
| 97 | + remaining -= chunk; |
| 98 | + bdl[3] = (remaining > 0) ? 0 : cpu_to_le32(0x01); |
95 | 99 |
|
96 | 100 | bdl += 4;
|
| 101 | + offset += chunk; |
97 | 102 | ctx->cl_dev.frags++;
|
98 | 103 | }
|
99 | 104 | }
|
@@ -338,15 +343,15 @@ int skl_cldma_prepare(struct sst_dsp *ctx)
|
338 | 343 | ctx->cl_dev.ops.cl_stop_dma = skl_cldma_stop;
|
339 | 344 |
|
340 | 345 | /* Allocate buffer*/
|
341 |
| - ret = ctx->dsp_ops.alloc_dma_buf(ctx->dev, |
342 |
| - &ctx->cl_dev.dmab_data, ctx->cl_dev.bufsize); |
| 346 | + ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, ctx->dev, ctx->cl_dev.bufsize, |
| 347 | + &ctx->cl_dev.dmab_data); |
343 | 348 | if (ret < 0) {
|
344 | 349 | dev_err(ctx->dev, "Alloc buffer for base fw failed: %x\n", ret);
|
345 | 350 | return ret;
|
346 | 351 | }
|
| 352 | + |
347 | 353 | /* Setup Code loader BDL */
|
348 |
| - ret = ctx->dsp_ops.alloc_dma_buf(ctx->dev, |
349 |
| - &ctx->cl_dev.dmab_bdl, PAGE_SIZE); |
| 354 | + ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, ctx->dev, BDL_SIZE, &ctx->cl_dev.dmab_bdl); |
350 | 355 | if (ret < 0) {
|
351 | 356 | dev_err(ctx->dev, "Alloc buffer for blde failed: %x\n", ret);
|
352 | 357 | ctx->dsp_ops.free_dma_buf(ctx->dev, &ctx->cl_dev.dmab_data);
|
|
0 commit comments