Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,18 @@ static int dai_comp_get_hw_params(struct comp_dev *dev,
int dir)
{
struct dai_data *dd = comp_get_drvdata(dev);
const struct dai_config *cfg = dai_config_get(dd->dai->dev, dir);
struct dai_config cfg;
int ret;

comp_dbg(dev, "dai_hw_params()");

if (!cfg)
return -EINVAL;
ret = dai_config_get(dd->dai->dev, &cfg, dir);
if (ret)
return ret;

params->rate = cfg->rate;
params->rate = cfg.rate;
params->buffer_fmt = 0;
params->channels = cfg->channels;
params->channels = cfg.channels;

/* dai_comp_get_hw_params() function fetches hardware dai parameters,
* which then are propagating back through the pipeline, so that any
Expand All @@ -397,7 +399,7 @@ static int dai_comp_get_hw_params(struct comp_dev *dev,
*/
params->frame_fmt = dev->ipc_config.frame_fmt;

return 0;
return ret;
}

static int dai_comp_hw_params(struct comp_dev *dev, struct sof_ipc_stream_params *params)
Expand Down Expand Up @@ -1059,11 +1061,9 @@ static int dai_comp_trigger_internal(struct comp_dev *dev, int cmd)
/* only start the DAI if we are not XRUN handling */
if (dd->xrun == 0) {
/* recover valid start position */
if (dev->state == COMP_STATE_ACTIVE) {
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
if (ret < 0)
return ret;
}
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
if (ret < 0)
return ret;

/* dma_config needed after stop */
ret = dma_config(dd->chan->dma->z_dev, dd->chan->index, dd->z_config);
Expand Down Expand Up @@ -1101,23 +1101,12 @@ static int dai_comp_trigger_internal(struct comp_dev *dev, int cmd)
dai_trigger_op(dd->dai, cmd, dev->direction);
#else
dai_trigger_op(dd->dai, cmd, dev->direction);
if (dev->state == COMP_STATE_ACTIVE) {
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
} else {
comp_warn(dev, "dma was stopped earlier");
ret = 0;
}
ret = dma_stop(dd->chan->dma->z_dev, dd->chan->index);
#endif
break;
case COMP_TRIGGER_PAUSE:
comp_dbg(dev, "dai_comp_trigger_internal(), PAUSE");
if (dev->state == COMP_STATE_ACTIVE) {
ret = dma_suspend(dd->chan->dma->z_dev, dd->chan->index);
} else {
comp_warn(dev, "dma was stopped earlier");
ret = 0;
}

ret = dma_suspend(dd->chan->dma->z_dev, dd->chan->index);
dai_trigger_op(dd->dai, cmd, dev->direction);
break;
case COMP_TRIGGER_PRE_START:
Expand Down
14 changes: 5 additions & 9 deletions src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,10 @@ static int host_trigger(struct comp_dev *dev, int cmd)
break;
case COMP_TRIGGER_STOP:
case COMP_TRIGGER_XRUN:
if (dev->state == COMP_STATE_ACTIVE) {
ret = dma_stop(hd->chan->dma->z_dev, hd->chan->index);
if (ret < 0)
comp_err(dev, "host_trigger(): dma stop failed: %d",
ret);
}

ret = dma_stop(hd->chan->dma->z_dev, hd->chan->index);
if (ret < 0)
comp_err(dev, "host_trigger(): dma stop failed: %d",
ret);
break;
default:
break;
Expand Down Expand Up @@ -1052,8 +1049,7 @@ static int host_reset(struct comp_dev *dev)
comp_dbg(dev, "host_reset()");

if (hd->chan) {
if (dev->state == COMP_STATE_ACTIVE)
dma_stop(hd->chan->dma->z_dev, hd->chan->index);
dma_stop(hd->chan->dma->z_dev, hd->chan->index);

/* remove callback */
notifier_unregister(dev, hd->chan, NOTIFIER_ID_DMA_COPY);
Expand Down
4 changes: 1 addition & 3 deletions src/ipc/ipc4/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ void dai_dma_release(struct comp_dev *dev)
* TODO: refine power management when stream is paused
*/
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
/* if reset is after pause dma has already been stopped */
if (dev->state != COMP_STATE_PAUSED)
dma_stop(dd->chan->dma->z_dev, dd->chan->index);
dma_stop(dd->chan->dma->z_dev, dd->chan->index);

/* remove callback */
notifier_unregister(dev, dd->chan, NOTIFIER_ID_DMA_COPY);
Expand Down
7 changes: 4 additions & 3 deletions src/lib/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ const struct device *zephyr_dev[] = {

static const struct device *dai_get_zephyr_device(uint32_t type, uint32_t index)
{
const struct dai_config *cfg;
struct dai_config cfg;
int dir;
int i;

dir = (type == SOF_DAI_INTEL_DMIC) ? DAI_DIR_RX : DAI_DIR_BOTH;

for (i = 0; i < ARRAY_SIZE(zephyr_dev); i++) {
cfg = dai_config_get(zephyr_dev[i], dir);
if (cfg && cfg->type == type && cfg->dai_index == index)
if (dai_config_get(zephyr_dev[i], &cfg, dir))
continue;
if (cfg.type == type && cfg.dai_index == index)
return zephyr_dev[i];
}

Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ manifest:

- name: zephyr
repo-path: zephyr
revision: d9c4ec31fc49e7eef3c8c3b0d07827cc04e6efee
revision: 9af2789cad17924298d705b99a1bca5f35ea88e2
remote: zephyrproject
# Import some projects listed in zephyr/west.yml@revision
#
Expand Down