Skip to content

Commit 56d1e6b

Browse files
committed
audio: host: move host-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 the host module is not run in user space. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent e3aea19 commit 56d1e6b

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/audio/host-zephyr.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int host_dma_set_config_and_copy(struct host_data *hd, struct comp_dev *d
8686
local_elem->size = bytes;
8787

8888
/* reconfigure transfer */
89-
ret = dma_config(hd->chan->dma->z_dev, hd->chan->index, &hd->z_config);
89+
ret = sof_dma_config(hd->chan->dma, hd->chan->index, &hd->z_config);
9090
if (ret < 0) {
9191
comp_err(dev, "dma_config() failed, ret = %d",
9292
ret);
@@ -95,7 +95,7 @@ static int host_dma_set_config_and_copy(struct host_data *hd, struct comp_dev *d
9595

9696
cb(dev, bytes);
9797

98-
ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0, bytes);
98+
ret = sof_dma_reload(hd->chan->dma, hd->chan->index, 0, 0, bytes);
9999
if (ret < 0) {
100100
comp_err(dev, "dma_copy() failed, ret = %d",
101101
ret);
@@ -225,15 +225,15 @@ static int host_copy_one_shot(struct host_data *hd, struct comp_dev *dev, copy_c
225225
hd->z_config.head_block->block_size = local_elem->size;
226226

227227
/* reconfigure transfer */
228-
ret = dma_config(hd->chan->dma->z_dev, hd->chan->index, &hd->z_config);
228+
ret = sof_dma_config(hd->chan->dma, hd->chan->index, &hd->z_config);
229229
if (ret < 0) {
230230
comp_err(dev, "dma_config() failed, ret = %u", ret);
231231
return ret;
232232
}
233233

234234
cb(dev, copy_bytes);
235235

236-
ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0, copy_bytes);
236+
ret = sof_dma_reload(hd->chan->dma, hd->chan->index, copy_bytes);
237237
if (ret < 0)
238238
comp_err(dev, "dma_copy() failed, ret = %u", ret);
239239

@@ -367,7 +367,7 @@ static void host_dma_cb(struct comp_dev *dev, size_t bytes)
367367
/* get status from dma and check for xrun */
368368
static int host_get_status(struct comp_dev *dev, struct host_data *hd, struct dma_status *stat)
369369
{
370-
int ret = dma_get_status(hd->chan->dma->z_dev, hd->chan->index, stat);
370+
int ret = sof_dma_get_status(hd->chan->dma, hd->chan->index, stat);
371371
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
372372
if (ret == -EPIPE && !hd->xrun_notification_sent) {
373373
struct ipc_msg *notify = ipc_notification_pool_get(IPC4_RESOURCE_EVENT_SIZE);
@@ -562,8 +562,8 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal
562562
if (!copy_bytes) {
563563
if (hd->partial_size != 0) {
564564
if (stream_sync(hd, dev)) {
565-
ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0,
566-
hd->partial_size);
565+
ret = sof_dma_reload(hd->chan->dma, hd->chan->index,
566+
hd->partial_size);
567567
if (ret < 0)
568568
comp_err(dev, "dma_reload() failed, ret = %u", ret);
569569

@@ -589,8 +589,8 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal
589589
hd->dma_buffer_size - hd->partial_size <=
590590
(2 + threshold) * hd->period_bytes) {
591591
if (stream_sync(hd, dev)) {
592-
ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0,
593-
hd->partial_size);
592+
ret = sof_dma_reload(hd->chan->dma, hd->chan->index,
593+
hd->partial_size);
594594
if (ret < 0)
595595
comp_err(dev, "dma_reload() failed, ret = %u", ret);
596596

@@ -665,14 +665,14 @@ int host_common_trigger(struct host_data *hd, struct comp_dev *dev, int cmd)
665665
switch (cmd) {
666666
case COMP_TRIGGER_START:
667667
hd->partial_size = 0;
668-
ret = dma_start(hd->chan->dma->z_dev, hd->chan->index);
668+
ret = sof_dma_start(hd->chan->dma, hd->chan->index);
669669
if (ret < 0)
670670
comp_err(dev, "dma_start() failed, ret = %u",
671671
ret);
672672
break;
673673
case COMP_TRIGGER_STOP:
674674
case COMP_TRIGGER_XRUN:
675-
ret = dma_stop(hd->chan->dma->z_dev, hd->chan->index);
675+
ret = sof_dma_stop(hd->chan->dma, hd->chan->index);
676676
if (ret < 0)
677677
comp_err(dev, "dma stop failed: %d",
678678
ret);
@@ -875,16 +875,16 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
875875
hd->cont_update_posn = params->cont_update_posn;
876876

877877
/* retrieve DMA buffer address alignment */
878-
err = dma_get_attribute(hd->dma->z_dev, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT,
879-
&addr_align);
878+
err = sof_dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT,
879+
&addr_align);
880880
if (err < 0) {
881881
comp_err(dev, "could not get dma buffer address alignment, err = %d",
882882
err);
883883
return err;
884884
}
885885

886886
/* retrieve DMA buffer size alignment */
887-
err = dma_get_attribute(hd->dma->z_dev, DMA_ATTR_BUFFER_SIZE_ALIGNMENT, &align);
887+
err = sof_dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_SIZE_ALIGNMENT, &align);
888888
if (err < 0 || !align) {
889889
comp_err(dev, "could not get valid dma buffer alignment, err = %d, align = %u",
890890
err, align);
@@ -999,7 +999,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
999999
/* get DMA channel from DMAC
10001000
* note: stream_tag is ignored by dw-dma
10011001
*/
1002-
channel = dma_request_channel(hd->dma->z_dev, &hda_chan);
1002+
channel = sof_dma_request_channel(hd->dma, hda_chan);
10031003
if (channel < 0) {
10041004
comp_err(dev, "requested channel %d is busy", hda_chan);
10051005
return -ENODEV;
@@ -1061,14 +1061,14 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
10611061
break;
10621062
}
10631063

1064-
err = dma_config(hd->chan->dma->z_dev, hd->chan->index, dma_cfg);
1064+
err = sof_dma_config(hd->chan->dma, hd->chan->index, dma_cfg);
10651065
if (err < 0) {
10661066
comp_err(dev, "dma_config() failed");
10671067
goto err_free_block_cfg;
10681068
}
10691069

1070-
err = dma_get_attribute(hd->dma->z_dev, DMA_ATTR_COPY_ALIGNMENT,
1071-
&hd->dma_copy_align);
1070+
err = sof_dma_get_attribute(hd->dma, DMA_ATTR_COPY_ALIGNMENT,
1071+
&hd->dma_copy_align);
10721072

10731073
if (err < 0) {
10741074
comp_err(dev, "dma_get_attribute() failed");
@@ -1091,7 +1091,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
10911091
dma_cfg->head_block = NULL;
10921092
rfree(dma_block_cfg);
10931093
err_release_channel:
1094-
dma_release_channel(hd->dma->z_dev, hd->chan->index);
1094+
sof_dma_release_channel(hd->dma, hd->chan->index);
10951095
hd->chan = NULL;
10961096

10971097
return err;
@@ -1151,8 +1151,8 @@ static int host_position(struct comp_dev *dev,
11511151
void host_common_reset(struct host_data *hd, uint16_t state)
11521152
{
11531153
if (hd->chan) {
1154-
dma_stop(hd->chan->dma->z_dev, hd->chan->index);
1155-
dma_release_channel(hd->dma->z_dev, hd->chan->index);
1154+
sof_dma_stop(hd->chan->dma, hd->chan->index);
1155+
sof_dma_release_channel(hd->dma, hd->chan->index);
11561156
hd->chan = NULL;
11571157
}
11581158

0 commit comments

Comments
 (0)