copier: align dai reset and trigger with host and gateway

Host and gateway case already have common function to handle
trigger and reset, add this wrap to align dai with host.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
This commit is contained in:
Baofeng Tian 2023-05-25 17:37:20 +08:00 committed by Kai Vehmanen
parent cbba56a121
commit 7ea9155ea8
3 changed files with 26 additions and 10 deletions

View File

@ -240,7 +240,6 @@ static int copier_reset(struct comp_dev *dev)
{ {
struct copier_data *cd = comp_get_drvdata(dev); struct copier_data *cd = comp_get_drvdata(dev);
struct ipc4_pipeline_registers pipe_reg; struct ipc4_pipeline_registers pipe_reg;
int i, ret = 0;
comp_dbg(dev, "copier_reset()"); comp_dbg(dev, "copier_reset()");
@ -255,8 +254,7 @@ static int copier_reset(struct comp_dev *dev)
copier_ipcgtw_reset(dev); copier_ipcgtw_reset(dev);
break; break;
case SOF_COMP_DAI: case SOF_COMP_DAI:
for (i = 0; i < cd->endpoint_num; i++) copier_dai_reset(cd, dev);
dai_zephyr_reset(cd->dd[i], dev);
break; break;
default: default:
break; break;
@ -270,7 +268,7 @@ static int copier_reset(struct comp_dev *dev)
comp_set_state(dev, COMP_TRIGGER_RESET); comp_set_state(dev, COMP_TRIGGER_RESET);
return ret; return 0;
} }
static int copier_comp_trigger(struct comp_dev *dev, int cmd) static int copier_comp_trigger(struct comp_dev *dev, int cmd)
@ -281,7 +279,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
struct comp_buffer *buffer; struct comp_buffer *buffer;
struct comp_buffer __sparse_cache *buffer_c; struct comp_buffer __sparse_cache *buffer_c;
uint32_t latency; uint32_t latency;
int ret, i; int ret;
comp_dbg(dev, "copier_comp_trigger()"); comp_dbg(dev, "copier_comp_trigger()");
@ -301,11 +299,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
} }
break; break;
case SOF_COMP_DAI: case SOF_COMP_DAI:
for (i = 0; i < cd->endpoint_num; i++) { ret = copier_dai_trigger(cd, dev, cmd);
ret = dai_zephyr_trigger(cd->dd[i], dev, cmd);
if (ret < 0)
return ret;
}
break; break;
default: default:
break; break;

View File

@ -464,3 +464,21 @@ int copier_dai_params(struct copier_data *cd, struct comp_dev *dev,
return ret; return ret;
} }
void copier_dai_reset(struct copier_data *cd, struct comp_dev *dev)
{
for (int i = 0; i < cd->endpoint_num; i++)
dai_zephyr_reset(cd->dd[i], dev);
}
int copier_dai_trigger(struct copier_data *cd, struct comp_dev *dev, int cmd)
{
int ret;
for (int i = 0; i < cd->endpoint_num; i++) {
ret = dai_zephyr_trigger(cd->dd[i], dev, cmd);
if (ret < 0)
return ret;
}
return 0;
}

View File

@ -68,4 +68,8 @@ int copier_dai_prepare(struct comp_dev *dev, struct copier_data *cd);
int copier_dai_params(struct copier_data *cd, struct comp_dev *dev, int copier_dai_params(struct copier_data *cd, struct comp_dev *dev,
struct sof_ipc_stream_params *params, int dai_index); struct sof_ipc_stream_params *params, int dai_index);
void copier_dai_reset(struct copier_data *cd, struct comp_dev *dev);
int copier_dai_trigger(struct copier_data *cd, struct comp_dev *dev, int cmd);
#endif /* __SOF_LIB_DAI_COPIER_H__ */ #endif /* __SOF_LIB_DAI_COPIER_H__ */