From: Yan Wang yan.wang@linux.intel.com
It will use TONE trace class and component DMA trace API. For trace calling of tone_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/tone.c | 79 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 35 deletions(-)
diff --git a/src/audio/tone.c b/src/audio/tone.c index eee6091..33c827e 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -52,9 +52,18 @@ #include <stdio.h> #endif
-#define trace_tone(__e) trace_event(TRACE_CLASS_TONE, __e) -#define tracev_tone(__e) tracev_event(TRACE_CLASS_TONE, __e) -#define trace_tone_error(__e) trace_error(TRACE_CLASS_TONE, __e) +#define trace_tone(cd, __e) \ + trace_comp_event(cd, NORMAL_LEVEL, TRACE_CLASS_TONE, __e) +#define tracev_tone(cd, __e) \ + trace_comp_event(cd, VERBOSE_LEVEL, TRACE_CLASS_TONE, __e) +#define trace_tone_error(cd, __e) \ + trace_comp_event_atomic(cd, ERROR_LEVEL, TRACE_CLASS_TONE, __e) +#define trace_tone_value(cd, x) \ + trace_comp_value(cd, NORMAL_LEVEL, x) +#define tracev_tone_value(cd, x) \ + trace_comp_value(cd, VERBOSE_LEVEL, x) +#define trace_tone_error_value(cd, x) \ + trace_comp_value_atomic(cd, ERROR_LEVEL, x)
/* Convert float frequency in Hz to Q16.16 fractional format */ #define TONE_FREQ(f) Q_CONVERT_FLOAT(f, 16) @@ -403,7 +412,7 @@ static struct comp_dev *tone_new(struct sof_ipc_comp *comp) struct comp_data *cd; int i;
- trace_tone("new"); + trace_tone(NULL, "new");
dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, COMP_SIZE(struct sof_ipc_comp_tone)); @@ -434,7 +443,7 @@ static void tone_free(struct comp_dev *dev) { struct tone_data *td = comp_get_drvdata(dev);
- trace_tone("fre"); + trace_tone(dev, "fre");
rfree(td); rfree(dev); @@ -446,7 +455,7 @@ static int tone_params(struct comp_dev *dev) struct comp_data *cd = comp_get_drvdata(dev); struct sof_ipc_comp_config *config = COMP_GET_CONFIG(dev);
- trace_tone("par"); + trace_tone(dev, "par");
/* Need to compute this in non-host endpoint */ dev->frame_bytes = @@ -470,14 +479,14 @@ static int tone_cmd_set_value(struct comp_dev *dev, struct sof_ipc_ctrl_data *cd bool val;
if (cdata->cmd == SOF_CTRL_CMD_SWITCH) { - trace_tone("mst"); + trace_tone(dev, "mst"); for (j = 0; j < cdata->num_elems; j++) { ch = cdata->chanv[j].channel; val = cdata->chanv[j].value; - tracev_value(ch); - tracev_value(val); + tracev_tone_value(dev, ch); + tracev_tone_value(dev, val); if (ch >= PLATFORM_MAX_CHANNELS) { - trace_tone_error("che"); + trace_tone_error(dev, "che"); return -EINVAL; } if (val) @@ -487,7 +496,7 @@ static int tone_cmd_set_value(struct comp_dev *dev, struct sof_ipc_ctrl_data *cd
} } else { - trace_tone_error("ste"); + trace_tone_error(dev, "ste"); return -EINVAL; }
@@ -503,65 +512,65 @@ static int tone_cmd_set_data(struct comp_dev *dev, uint32_t ch; uint32_t val;
- trace_tone("tri"); + trace_tone(dev, "tri");
/* Check version from ABI header */ if (cdata->data->comp_abi != SOF_TONE_ABI_VERSION) { - trace_tone_error("abi"); + trace_tone_error(dev, "abi"); return -EINVAL; }
switch (cdata->cmd) { case SOF_CTRL_CMD_ENUM: - trace_tone("ten"); - trace_value(cdata->index); + trace_tone(dev, "ten"); + trace_tone_value(dev, cdata->index); compv = (struct sof_ipc_ctrl_value_comp *) cdata->data->data; for (i = 0; i < (int) cdata->num_elems; i++) { ch = compv[i].index; val = compv[i].svalue; - tracev_value(ch); - tracev_value(val); + tracev_tone_value(dev, ch); + tracev_tone_value(dev, val); switch (cdata->index) { case SOF_TONE_IDX_FREQUENCY: - trace_tone("tfr"); + trace_tone(dev, "tfr"); tonegen_update_f(&cd->sg[ch], val); break; case SOF_TONE_IDX_AMPLITUDE: - trace_tone("tam"); + trace_tone(dev, "tam"); tonegen_set_a(&cd->sg[ch], val); break; case SOF_TONE_IDX_FREQ_MULT: - trace_tone("tfx"); + trace_tone(dev, "tfx"); tonegen_set_freq_mult(&cd->sg[ch], val); break; case SOF_TONE_IDX_AMPL_MULT: - trace_tone("tax"); + trace_tone(dev, "tax"); tonegen_set_ampl_mult(&cd->sg[ch], val); break; case SOF_TONE_IDX_LENGTH: - trace_tone("tle"); + trace_tone(dev, "tle"); tonegen_set_length(&cd->sg[ch], val); break; case SOF_TONE_IDX_PERIOD: - trace_tone("tpe"); + trace_tone(dev, "tpe"); tonegen_set_period(&cd->sg[ch], val); break; case SOF_TONE_IDX_REPEATS: - trace_tone("trp"); + trace_tone(dev, "trp"); tonegen_set_repeats(&cd->sg[ch], val); break; case SOF_TONE_IDX_LIN_RAMP_STEP: - trace_tone("trs"); + trace_tone(dev, "trs"); tonegen_set_linramp(&cd->sg[ch], val); break; default: - trace_tone_error("ier"); + trace_tone_error(dev, "ier"); return -EINVAL; } } break; default: - trace_tone_error("ec1"); + trace_tone_error(dev, "ec1"); return -EINVAL; }
@@ -574,7 +583,7 @@ static int tone_cmd(struct comp_dev *dev, int cmd, void *data) struct sof_ipc_ctrl_data *cdata = data; int ret = 0;
- trace_tone("cmd"); + trace_tone(dev, "cmd");
switch (cmd) { case COMP_CMD_SET_DATA: @@ -590,7 +599,7 @@ static int tone_cmd(struct comp_dev *dev, int cmd, void *data)
static int tone_trigger(struct comp_dev *dev, int cmd) { - trace_tone("trg"); + trace_tone(dev, "trg");
return comp_set_state(dev, cmd); } @@ -601,7 +610,7 @@ static int tone_copy(struct comp_dev * dev) struct comp_buffer *sink; struct comp_data *cd = comp_get_drvdata(dev);
- tracev_comp("cpy"); + tracev_tone(dev, "cpy");
/* tone component sink buffer */ sink = list_first_item(&dev->bsink_list, struct comp_buffer, @@ -620,7 +629,7 @@ static int tone_copy(struct comp_dev * dev) return dev->frames; } else { /* XRUN */ - trace_tone_error("xrn"); + trace_tone_error(dev, "xrn"); comp_overrun(dev, sink, cd->period_bytes, sink->free); return -EIO; } @@ -634,7 +643,7 @@ static int tone_prepare(struct comp_dev * dev) int ret; int i;
- trace_tone("TPp"); + trace_tone(dev, "TPp");
ret = comp_set_state(dev, COMP_TRIGGER_PREPARE); if (ret < 0) @@ -642,8 +651,8 @@ static int tone_prepare(struct comp_dev * dev)
cd->channels = dev->params.channels; cd->rate = dev->params.rate; - tracev_value(cd->channels); - tracev_value(cd->rate); + tracev_tone_value(dev, cd->channels); + tracev_tone_value(dev, cd->rate);
for (i = 0; i < cd->channels; i++) { f = tonegen_get_f(&cd->sg[i]); @@ -663,7 +672,7 @@ static int tone_reset(struct comp_dev * dev) struct comp_data *cd = comp_get_drvdata(dev); int i;
- trace_tone("TRe"); + trace_tone(dev, "TRe");
/* Initialize with the defaults */ for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)