mirror of https://github.com/thesofproject/sof.git
dai-zephyr/dai-legacy: Expose dai_zephyr_prepare() and dai_zephyr_config_prepare()
Rename dai_config_prepare() to add the zephyr prefix and expose both functions and use them in the copier device in the single endpoint DAI case. Signed-off-by: Baofeng Tian <baofeng.tian@intel.com> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
parent
9da71a8708
commit
79c4339489
|
@ -931,19 +931,48 @@ static int copier_prepare(struct comp_dev *dev)
|
|||
if (ret == COMP_STATUS_STATE_ALREADY_SET)
|
||||
return PPL_STATUS_PATH_STOP;
|
||||
|
||||
if (dev->ipc_config.type == SOF_COMP_HOST && !cd->ipc_gtw) {
|
||||
switch (dev->ipc_config.type) {
|
||||
case SOF_COMP_HOST:
|
||||
if (!cd->ipc_gtw) {
|
||||
ret = host_zephyr_prepare(cd->hd);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* handle gtw case */
|
||||
for (i = 0; i < cd->endpoint_num; i++) {
|
||||
if (dev->ipc_config.type != SOF_COMP_HOST || cd->ipc_gtw) {
|
||||
ret = cd->endpoint[i]->drv->ops.prepare(cd->endpoint[i]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOF_COMP_DAI:
|
||||
if (cd->endpoint_num == 1) {
|
||||
ret = dai_zephyr_config_prepare(cd->dd[0], cd->endpoint[0]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = comp_set_state(cd->endpoint[0], COMP_TRIGGER_PREPARE);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (ret == COMP_STATUS_STATE_ALREADY_SET)
|
||||
return PPL_STATUS_PATH_STOP;
|
||||
|
||||
ret = dai_zephyr_prepare(cd->dd[0], cd->endpoint[0]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
for (i = 0; i < cd->endpoint_num; i++) {
|
||||
ret = cd->endpoint[i]->drv->ops.prepare(cd->endpoint[i]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!cd->endpoint_num) {
|
||||
/* set up format conversion function for pin 0, for other pins (if any)
|
||||
|
|
|
@ -618,13 +618,13 @@ static int dai_params(struct comp_dev *dev,
|
|||
dai_capture_params(dev, period_bytes, period_count);
|
||||
}
|
||||
|
||||
static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
int dai_zephyr_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
{
|
||||
int channel = 0;
|
||||
|
||||
/* cannot configure DAI while active */
|
||||
if (dev->state == COMP_STATE_ACTIVE) {
|
||||
comp_info(dev, "dai_config_prepare(): Component is in active state.");
|
||||
comp_info(dev, "dai_zephyr_config_prepare(): Component is in active state.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -634,13 +634,13 @@ static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
|||
}
|
||||
|
||||
if (dd->chan) {
|
||||
comp_info(dev, "dai_config_prepare(): dma channel index %d already configured",
|
||||
comp_info(dev, "dai_zephyr_config_prepare(): dma channel index %d already configured",
|
||||
dd->chan->index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
channel = dai_config_dma_channel(dd, dev, dd->dai_spec_config);
|
||||
comp_info(dev, "dai_config_prepare(), channel = %d", channel);
|
||||
comp_info(dev, "dai_zephyr_config_prepare(), channel = %d", channel);
|
||||
|
||||
/* do nothing for asking for channel free, for compatibility. */
|
||||
if (channel == DMA_CHAN_INVALID) {
|
||||
|
@ -651,14 +651,14 @@ static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
|||
/* allocate DMA channel */
|
||||
dd->chan = dma_channel_get_legacy(dd->dma, channel);
|
||||
if (!dd->chan) {
|
||||
comp_err(dev, "dai_config_prepare(): dma_channel_get() failed");
|
||||
comp_err(dev, "dai_zephyr_config_prepare(): dma_channel_get() failed");
|
||||
dd->chan = NULL;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
dd->chan->dev_data = dd;
|
||||
|
||||
comp_info(dev, "dai_config_prepare(): new configured dma channel index %d",
|
||||
comp_info(dev, "dai_zephyr_config_prepare(): new configured dma channel index %d",
|
||||
dd->chan->index);
|
||||
|
||||
/* setup callback */
|
||||
|
@ -668,7 +668,7 @@ static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dai_zephyr_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
int dai_zephyr_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
{
|
||||
struct comp_buffer __sparse_cache *buffer_c;
|
||||
int ret;
|
||||
|
@ -713,7 +713,7 @@ static int dai_prepare(struct comp_dev *dev)
|
|||
|
||||
comp_info(dev, "dai_prepare()");
|
||||
|
||||
ret = dai_config_prepare(dd, dev);
|
||||
ret = dai_zephyr_config_prepare(dd, dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -874,13 +874,13 @@ static int dai_params(struct comp_dev *dev, struct sof_ipc_stream_params *params
|
|||
dai_capture_params(dev, period_bytes, period_count);
|
||||
}
|
||||
|
||||
static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
int dai_zephyr_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
{
|
||||
int channel;
|
||||
|
||||
/* cannot configure DAI while active */
|
||||
if (dev->state == COMP_STATE_ACTIVE) {
|
||||
comp_info(dev, "dai_config_prepare(): Component is in active state.");
|
||||
comp_info(dev, "dai_zephyr_config_prepare(): Component is in active state.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -890,13 +890,13 @@ static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
|||
}
|
||||
|
||||
if (dd->chan) {
|
||||
comp_info(dev, "dai_config_prepare(): dma channel index %d already configured",
|
||||
comp_info(dev, "dai_zephyr_config_prepare(): dma channel index %d already configured",
|
||||
dd->chan->index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
channel = dai_config_dma_channel(dd, dev, dd->dai_spec_config);
|
||||
comp_dbg(dev, "dai_config_prepare(), channel = %d", channel);
|
||||
comp_dbg(dev, "dai_zephyr_config_prepare(), channel = %d", channel);
|
||||
|
||||
/* do nothing for asking for channel free, for compatibility. */
|
||||
if (channel == DMA_CHAN_INVALID) {
|
||||
|
@ -907,7 +907,7 @@ static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
|||
/* get DMA channel */
|
||||
channel = dma_request_channel(dd->dma->z_dev, &channel);
|
||||
if (channel < 0) {
|
||||
comp_err(dev, "dai_config_prepare(): dma_request_channel() failed");
|
||||
comp_err(dev, "dai_zephyr_config_prepare(): dma_request_channel() failed");
|
||||
dd->chan = NULL;
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -915,13 +915,13 @@ static int dai_config_prepare(struct dai_data *dd, struct comp_dev *dev)
|
|||
dd->chan = &dd->dma->chan[channel];
|
||||
dd->chan->dev_data = dd;
|
||||
|
||||
comp_dbg(dev, "dai_config_prepare(): new configured dma channel index %d",
|
||||
comp_dbg(dev, "dai_zephyr_config_prepare(): new configured dma channel index %d",
|
||||
dd->chan->index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dai_zephyr_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
int dai_zephyr_prepare(struct dai_data *dd, struct comp_dev *dev)
|
||||
{
|
||||
struct comp_buffer __sparse_cache *buffer_c;
|
||||
int ret;
|
||||
|
@ -966,7 +966,7 @@ static int dai_prepare(struct comp_dev *dev)
|
|||
|
||||
comp_dbg(dev, "dai_prepare()");
|
||||
|
||||
ret = dai_config_prepare(dd, dev);
|
||||
ret = dai_zephyr_config_prepare(dd, dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -22,4 +22,7 @@ int dai_zephyr_new(struct dai_data *dd, struct comp_dev *dev,
|
|||
|
||||
void dai_zephyr_free(struct dai_data *dd);
|
||||
|
||||
int dai_zephyr_config_prepare(struct dai_data *dd, struct comp_dev *dev);
|
||||
|
||||
int dai_zephyr_prepare(struct dai_data *dd, struct comp_dev *dev);
|
||||
#endif /* __SOF_LIB_DAI_COPIER_H__ */
|
||||
|
|
Loading…
Reference in New Issue