From: Yan Wang yan.wang@linux.intel.com
It will use DAI trace class and component DMA trace API. For trace calling of dai_new(), NULL will be passed into trace API because comp_dev hasn't been initialized.
Signed-off-by: Yan Wang yan.wang@linux.intel.com --- Test with: CNL nocodec SOF master: c1f2682c210201bbbc96fce7b382b25b90d19775 SOF-Tool master: 86fe688a2b4f68a1ce87e0951686be12a00f1a3c https://github.com/plbossart/sound/tree/topic/sof-v4.14: d09db67c5a9d6dfc85f700669fa2e43c678c8d51 --- src/audio/dai.c | 80 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 36 deletions(-)
diff --git a/src/audio/dai.c b/src/audio/dai.c index 1eeecd2..2ebff6a 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -49,10 +49,18 @@ #define DAI_CAPTURE_STREAM 1
/* tracing */ -#define trace_dai(__e) trace_event(TRACE_CLASS_DAI, __e) -#define trace_dai_error(__e) trace_error(TRACE_CLASS_DAI, __e) -#define tracev_dai(__e) tracev_event(TRACE_CLASS_DAI, __e) - +#define trace_dai(cd, __e) \ + trace_comp_event(cd, NORMAL_LEVEL, TRACE_CLASS_DAI, __e) +#define tracev_dai(cd, __e) \ + trace_comp_event(cd, VERBOSE_LEVEL, TRACE_CLASS_DAI, __e) +#define trace_dai_error(cd, __e) \ + trace_comp_event_atomic(cd, ERROR_LEVEL, TRACE_CLASS_DAI, __e) +#define trace_dai_value(cd, x) \ + trace_comp_value(cd, NORMAL_LEVEL, x) +#define tracev_dai_value(cd, x) \ + trace_comp_value(cd, VERBOSE_LEVEL, x) +#define trace_dai_error_value(cd, x) \ + trace_comp_value_atomic(cd, ERROR_LEVEL, x)
struct dai_data { /* local DMA config */ @@ -80,7 +88,7 @@ static void dai_dma_cb(void *data, uint32_t type, struct dma_sg_elem *next) struct comp_buffer *dma_buffer; uint32_t copied_size;
- tracev_dai("irq"); + tracev_dai(dev, "irq");
/* stop dma copy for pause/stop/xrun */ if (dev->state != COMP_STATE_ACTIVE || dd->xrun) { @@ -136,7 +144,7 @@ static void dai_dma_cb(void *data, uint32_t type, struct dma_sg_elem *next)
/* make sure there is availble bytes for next period */ if (dma_buffer->avail < dd->period_bytes) { - trace_dai_error("xru"); + trace_dai_error(dev, "xru"); comp_underrun(dev, dma_buffer, copied_size, 0); }
@@ -160,7 +168,7 @@ static void dai_dma_cb(void *data, uint32_t type, struct dma_sg_elem *next)
/* make sure there is free bytes for next period */ if (dma_buffer->free < dd->period_bytes) { - trace_dai_error("xro"); + trace_dai_error(dev, "xro"); comp_overrun(dev, dma_buffer, dd->period_bytes, 0); } } @@ -177,7 +185,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp) struct sof_ipc_comp_dai *ipc_dai = (struct sof_ipc_comp_dai *)comp; struct dai_data *dd;
- trace_dai("new"); + trace_dai(NULL, "new");
dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, COMP_SIZE(struct sof_ipc_comp_dai)); @@ -197,13 +205,13 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
dd->dai = dai_get(dai->type, dai->index); if (dd->dai == NULL) { - trace_dai_error("eDg"); + trace_dai_error(NULL, "eDg"); goto error; }
dd->dma = dma_get(ipc_dai->dmac_id); if (dd->dma == NULL) { - trace_dai_error("eDd"); + trace_dai_error(NULL, "eDd"); goto error; }
@@ -216,7 +224,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp) /* get DMA channel from DMAC1 */ dd->chan = dma_channel_get(dd->dma, 0); if (dd->chan < 0){ - trace_dai_error("eDc"); + trace_dai_error(dev, "eDc"); goto error; }
@@ -272,11 +280,11 @@ static int dai_playback_params(struct comp_dev *dev) /* resize the buffer if space is available to align with period size */ err = buffer_set_size(dma_buffer, buffer_size); if (err < 0) { - trace_dai_error("ep1"); - trace_error_value(source_config->periods_sink); - trace_error_value(dd->period_bytes); - trace_error_value(buffer_size); - trace_error_value(dma_buffer->alloc_size); + trace_dai_error(dev, "ep1"); + trace_dai_error_value(dev, source_config->periods_sink); + trace_dai_error_value(dev, dd->period_bytes); + trace_dai_error_value(dev, buffer_size); + trace_dai_error_value(dev, dma_buffer->alloc_size); return err; }
@@ -302,7 +310,7 @@ static int dai_playback_params(struct comp_dev *dev) return 0;
err_unwind: - trace_dai_error("ep3"); + trace_dai_error(dev, "ep3"); list_for_item_safe(elist, tlist, &config->elem_list) { elem = container_of(elist, struct dma_sg_elem, list); list_item_del(&elem->list); @@ -340,11 +348,11 @@ static int dai_capture_params(struct comp_dev *dev) /* resize the buffer if space is available to align with period size */ err = buffer_set_size(dma_buffer, buffer_size); if (err < 0) { - trace_dai_error("ec1"); - trace_error_value(sink_config->periods_sink); - trace_error_value(dd->period_bytes); - trace_error_value(buffer_size); - trace_error_value(dma_buffer->alloc_size); + trace_dai_error(dev, "ec1"); + trace_dai_error_value(dev, sink_config->periods_sink); + trace_dai_error_value(dev, dd->period_bytes); + trace_dai_error_value(dev, buffer_size); + trace_dai_error_value(dev, dma_buffer->alloc_size); return err; }
@@ -368,7 +376,7 @@ static int dai_capture_params(struct comp_dev *dev) return 0;
err_unwind: - trace_dai_error("ec3"); + trace_dai_error(dev, "ec3"); list_for_item_safe(elist, tlist, &config->elem_list) { elem = container_of(elist, struct dma_sg_elem, list); list_item_del(&elem->list); @@ -383,11 +391,11 @@ static int dai_params(struct comp_dev *dev) struct comp_buffer *dma_buffer; struct sof_ipc_comp_config *dconfig = COMP_GET_CONFIG(dev);
- trace_dai("par"); + trace_dai(dev, "par");
/* can set params on only init state */ if (dev->state != COMP_STATE_READY) { - trace_dai_error("wdp"); + trace_dai_error(dev, "wdp"); return -EINVAL; }
@@ -397,13 +405,13 @@ static int dai_params(struct comp_dev *dev) /* calculate period size based on config */ dev->frame_bytes = comp_frame_bytes(dev); if (dev->frame_bytes == 0) { - trace_dai_error("ed1"); + trace_dai_error(dev, "ed1"); return -EINVAL; }
dd->period_bytes = dev->frames * dev->frame_bytes; if (dd->period_bytes == 0) { - trace_dai_error("ed2"); + trace_dai_error(dev, "ed2"); return -EINVAL; }
@@ -428,7 +436,7 @@ static int dai_prepare(struct comp_dev *dev) struct comp_buffer *dma_buffer; int ret = 0;
- trace_dai("pre"); + trace_dai(dev, "pre");
ret = comp_set_state(dev, COMP_TRIGGER_PREPARE); if (ret < 0) @@ -437,7 +445,7 @@ static int dai_prepare(struct comp_dev *dev) dev->position = 0;
if (list_is_empty(&dd->config.elem_list)) { - trace_dai_error("wdm"); + trace_dai_error(dev, "wdm"); comp_set_state(dev, COMP_TRIGGER_RESET); return -EINVAL; } @@ -474,7 +482,7 @@ static int dai_reset(struct comp_dev *dev) struct list_item *tlist; struct dma_sg_elem *elem;
- trace_dai("res"); + trace_dai(dev, "res");
list_for_item_safe(elist, tlist, &config->elem_list) { elem = container_of(elist, struct dma_sg_elem, list); @@ -532,8 +540,8 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd) struct dai_data *dd = comp_get_drvdata(dev); int ret;
- trace_dai("trg"); - tracev_value(cmd); + trace_dai(dev, "trg"); + tracev_dai_value(dev, cmd);
wait_init(&dd->complete);
@@ -588,8 +596,8 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd) dd->complete.timeout = dev->pipeline->ipc_pipe.deadline; ret = wait_for_completion_timeout(&dd->complete); if (ret < 0) { - trace_dai_error("ed0"); - trace_error_value(cmd); + trace_dai_error(dev, "ed0"); + trace_dai_error_value(dev, cmd); } break; default: @@ -646,12 +654,12 @@ static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config) break; default: /* other types of DAIs not handled for now */ - trace_dai_error("de2"); + trace_dai_error(dev, "de2"); break; }
if (dev->frame_bytes == 0) { - trace_dai_error("de1"); + trace_dai_error(dev, "de1"); return -EINVAL; }