Skip to content

Commit 27fb824

Browse files
committed
audio: dai: move dai-zephyr to use SOF DMA wrapper
Use the sof/lib/dma.h wrapper interface to access DMA devices. This allows to run this code also from user-space. The commit has no impact to builds where userspace is not used. Also this will not impact builds where user-space is enabled for some functionality, but the dai/copier module is not run in user space. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 4221dd5 commit 27fb824

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ __cold void dai_common_free(struct dai_data *dd)
607607
dai_group_put(dd->group);
608608

609609
if (dd->chan) {
610-
dma_release_channel(dd->dma->z_dev, dd->chan->index);
610+
sof_dma_release_channel(dd->dma, dd->chan->index);
611611
dd->chan->dev_data = NULL;
612612
}
613613

@@ -798,7 +798,7 @@ static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev, uint32_t
798798

799799
comp_dbg(dev, "fifo 0x%x", fifo);
800800

801-
err = dma_get_attribute(dd->dma->z_dev, DMA_ATTR_MAX_BLOCK_COUNT, &max_block_count);
801+
err = sof_dma_get_attribute(dd->dma, DMA_ATTR_MAX_BLOCK_COUNT, &max_block_count);
802802
if (err < 0) {
803803
comp_err(dev, "can't get max block count, err = %d",
804804
err);
@@ -954,14 +954,14 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
954954
return -EINVAL;
955955
}
956956

957-
err = dma_get_attribute(dd->dma->z_dev, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT, &addr_align);
957+
err = sof_dma_get_attribute(dd->dma, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT, &addr_align);
958958
if (err < 0) {
959959
comp_err(dev, "can't get dma buffer addr align, err = %d",
960960
err);
961961
return err;
962962
}
963963

964-
err = dma_get_attribute(dd->dma->z_dev, DMA_ATTR_BUFFER_SIZE_ALIGNMENT, &align);
964+
err = sof_dma_get_attribute(dd->dma, DMA_ATTR_BUFFER_SIZE_ALIGNMENT, &align);
965965
if (err < 0 || !align) {
966966
comp_err(dev, "no valid dma align, err = %d, align = %u",
967967
err, align);
@@ -1155,7 +1155,7 @@ int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev)
11551155
}
11561156

11571157
/* get DMA channel */
1158-
channel = dma_request_channel(dd->dma->z_dev, &channel);
1158+
channel = sof_dma_request_channel(dd->dma, channel);
11591159
if (channel < 0) {
11601160
comp_err(dev, "dma_request_channel() failed");
11611161
dd->chan = NULL;
@@ -1199,7 +1199,7 @@ int dai_common_prepare(struct dai_data *dd, struct comp_dev *dev)
11991199
return 0;
12001200
}
12011201

1202-
ret = dma_config(dd->chan->dma->z_dev, dd->chan->index, dd->z_config);
1202+
ret = sof_dma_config(dd->chan->dma, dd->chan->index, dd->z_config);
12031203
if (ret < 0)
12041204
comp_set_state(dev, COMP_TRIGGER_RESET);
12051205

@@ -1286,7 +1286,7 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
12861286

12871287
/* only start the DAI if we are not XRUN handling */
12881288
if (dd->xrun == 0) {
1289-
ret = dma_start(dd->chan->dma->z_dev, dd->chan->index);
1289+
ret = sof_dma_start(dd->chan->dma, dd->chan->index);
12901290
if (ret < 0)
12911291
return ret;
12921292

@@ -1324,16 +1324,16 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
13241324
/* only start the DAI if we are not XRUN handling */
13251325
if (dd->xrun == 0) {
13261326
/* recover valid start position */
1327-
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
1327+
ret = sof_dma_stop(dd->chan->dma, dd->chan->index);
13281328
if (ret < 0)
13291329
return ret;
13301330

13311331
/* dma_config needed after stop */
1332-
ret = dma_config(dd->chan->dma->z_dev, dd->chan->index, dd->z_config);
1332+
ret = sof_dma_config(dd->chan->dma, dd->chan->index, dd->z_config);
13331333
if (ret < 0)
13341334
return ret;
13351335

1336-
ret = dma_start(dd->chan->dma->z_dev, dd->chan->index);
1336+
ret = sof_dma_start(dd->chan->dma, dd->chan->index);
13371337
if (ret < 0)
13381338
return ret;
13391339

@@ -1361,11 +1361,11 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
13611361
* as soon as possible.
13621362
*/
13631363
#if CONFIG_COMP_DAI_STOP_TRIGGER_ORDER_REVERSE
1364-
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
1364+
ret = sof_dma_stop(dd->chan->dma, dd->chan->index);
13651365
dai_trigger_op(dd->dai, cmd, dev->direction);
13661366
#else
13671367
dai_trigger_op(dd->dai, cmd, dev->direction);
1368-
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
1368+
ret = sof_dma_stop(dd->chan->dma, dd->chan->index);
13691369
if (ret) {
13701370
comp_warn(dev, "dma was stopped earlier");
13711371
ret = 0;
@@ -1375,11 +1375,11 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
13751375
case COMP_TRIGGER_PAUSE:
13761376
comp_dbg(dev, "PAUSE");
13771377
#if CONFIG_COMP_DAI_STOP_TRIGGER_ORDER_REVERSE
1378-
ret = dma_suspend(dd->chan->dma->z_dev, dd->chan->index);
1378+
ret = sof_dma_suspend(dd->chan->dma, dd->chan->index);
13791379
dai_trigger_op(dd->dai, cmd, dev->direction);
13801380
#else
13811381
dai_trigger_op(dd->dai, cmd, dev->direction);
1382-
ret = dma_suspend(dd->chan->dma->z_dev, dd->chan->index);
1382+
ret = sof_dma_suspend(dd->chan->dma, dd->chan->index);
13831383
#endif
13841384
break;
13851385
case COMP_TRIGGER_PRE_START:
@@ -1471,7 +1471,7 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd)
14711471
/* get status from dma and check for xrun */
14721472
static int dai_get_status(struct comp_dev *dev, struct dai_data *dd, struct dma_status *stat)
14731473
{
1474-
int ret = dma_get_status(dd->chan->dma->z_dev, dd->chan->index, stat);
1474+
int ret = sof_dma_get_status(dd->chan->dma, dd->chan->index, stat);
14751475
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
14761476
if (ret == -EPIPE && !dd->xrun_notification_sent) {
14771477
struct ipc_msg *notify = ipc_notification_pool_get(IPC4_RESOURCE_EVENT_SIZE);
@@ -1582,7 +1582,7 @@ int dai_zephyr_multi_endpoint_copy(struct dai_data **dd, struct comp_dev *dev,
15821582
#endif
15831583

15841584
for (i = 0; i < num_endpoints; i++) {
1585-
ret = dma_reload(dd[i]->chan->dma->z_dev, dd[i]->chan->index, 0, 0, 0);
1585+
ret = sof_dma_reload(dd[i]->chan->dma, dd[i]->chan->index, 0);
15861586
if (ret < 0) {
15871587
dai_report_xrun(dd[i], dev, 0);
15881588
return ret;
@@ -1608,10 +1608,10 @@ int dai_zephyr_multi_endpoint_copy(struct dai_data **dd, struct comp_dev *dev,
16081608

16091609
status = dai_dma_multi_endpoint_cb(dd[i], dev, frames, multi_endpoint_buffer);
16101610
if (status == SOF_DMA_CB_STATUS_END)
1611-
dma_stop(dd[i]->chan->dma->z_dev, dd[i]->chan->index);
1611+
sof_dma_stop(dd[i]->chan->dma, dd[i]->chan->index);
16121612

16131613
copy_bytes = frames * audio_stream_frame_bytes(&dd[i]->dma_buffer->stream);
1614-
ret = dma_reload(dd[i]->chan->dma->z_dev, dd[i]->chan->index, 0, 0, copy_bytes);
1614+
ret = sof_dma_reload(dd[i]->chan->dma, dd[i]->chan->index, copy_bytes);
16151615
if (ret < 0) {
16161616
dai_report_xrun(dd[i], dev, copy_bytes);
16171617
return ret;
@@ -1800,7 +1800,7 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
18001800
comp_warn(dev, "nothing to copy, src_frames: %u, sink_frames: %u",
18011801
src_frames, sink_frames);
18021802
#endif
1803-
dma_reload(dd->chan->dma->z_dev, dd->chan->index, 0, 0, 0);
1803+
sof_dma_reload(dd->chan->dma, dd->chan->index, 0);
18041804
return 0;
18051805
}
18061806

@@ -1810,9 +1810,9 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
18101810
comp_warn(dev, "dai trigger copy failed");
18111811

18121812
if (dai_dma_cb(dd, dev, copy_bytes, converter) == SOF_DMA_CB_STATUS_END)
1813-
dma_stop(dd->chan->dma->z_dev, dd->chan->index);
1813+
sof_dma_stop(dd->chan->dma, dd->chan->index);
18141814

1815-
ret = dma_reload(dd->chan->dma->z_dev, dd->chan->index, 0, 0, copy_bytes);
1815+
ret = sof_dma_reload(dd->chan->dma, dd->chan->index, copy_bytes);
18161816
if (ret < 0) {
18171817
dai_report_xrun(dd, dev, copy_bytes);
18181818
return ret;

0 commit comments

Comments
 (0)