From: Yan Wang yan.wang@linux.intel.com
It will use SRC trace class and component DMA trace API. For trace calling of src_new(), NULL will be passed into trace API because comp_dev hasn't been initialized. Some sub-functions must be added comp_dev input parameter for trace.
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/src.c | 97 ++++++++++++++++++++++++++++++++------------------------- src/audio/src.h | 5 +-- 2 files changed, 57 insertions(+), 45 deletions(-)
diff --git a/src/audio/src.c b/src/audio/src.c index c19828a..2fc01d6 100644 --- a/src/audio/src.c +++ b/src/audio/src.c @@ -60,9 +60,18 @@ #include <stdio.h> #endif
-#define trace_src(__e) trace_event(TRACE_CLASS_SRC, __e) -#define tracev_src(__e) tracev_event(TRACE_CLASS_SRC, __e) -#define trace_src_error(__e) trace_error(TRACE_CLASS_SRC, __e) +#define trace_src(cd, __e) \ + trace_comp_event(cd, NORMAL_LEVEL, TRACE_CLASS_SRC, __e) +#define tracev_src(cd, __e) \ + trace_comp_event(cd, VERBOSE_LEVEL, TRACE_CLASS_SRC, __e) +#define trace_src_error(cd, __e) \ + trace_comp_event_atomic(cd, ERROR_LEVEL, TRACE_CLASS_SRC, __e) +#define trace_src_value(cd, x) \ + trace_comp_value(cd, NORMAL_LEVEL, x) +#define tracev_src_value(cd, x) \ + trace_comp_value(cd, VERBOSE_LEVEL, x) +#define trace_src_error_value(cd, x) \ + trace_comp_value_atomic(cd, ERROR_LEVEL, x)
/* The FIR maximum lengths are per channel so need to multiply them */ #define MAX_FIR_DELAY_SIZE_XNCH (PLATFORM_MAX_CHANNELS * MAX_FIR_DELAY_SIZE) @@ -124,8 +133,9 @@ static int src_find_fs(int fs_list[], int list_length, int fs) }
/* Calculates buffers to allocate for a SRC mode */ -int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch, - int frames, int frames_is_for_source) +int src_buffer_lengths(struct comp_dev *dev, struct src_param *a, int fs_in, + int fs_out, int nch, int frames, + int frames_is_for_source) { struct src_stage *stage1; struct src_stage *stage2; @@ -135,8 +145,8 @@ int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch, int frames2;
if (nch > PLATFORM_MAX_CHANNELS) { - trace_src_error("che"); - tracev_value(nch); + trace_src_error(dev, "che"); + tracev_src_value(dev, nch); return -EINVAL; }
@@ -146,9 +156,9 @@ int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch,
/* Check that both in and out rates are supported */ if (a->idx_in < 0 || a->idx_out < 0) { - trace_src_error("us1"); - tracev_value(fs_in); - tracev_value(fs_out); + trace_src_error(dev, "us1"); + tracev_src_value(dev, fs_in); + tracev_src_value(dev, fs_out); return -EINVAL; }
@@ -157,9 +167,9 @@ int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch,
/* Check from stage1 parameter for a deleted in/out rate combination.*/ if (stage1->filter_length < 1) { - trace_src_error("us2"); - tracev_value(fs_in); - tracev_value(fs_out); + trace_src_error(dev, "us2"); + tracev_src_value(dev, fs_in); + tracev_src_value(dev, fs_out); return -EINVAL; }
@@ -542,11 +552,11 @@ static struct comp_dev *src_new(struct sof_ipc_comp *comp) struct sof_ipc_comp_src *ipc_src = (struct sof_ipc_comp_src *)comp; struct comp_data *cd;
- trace_src("new"); + trace_src(NULL, "new");
/* validate init data - either SRC sink or source rate must be set */ if (ipc_src->source_rate == 0 && ipc_src->sink_rate == 0) { - trace_src_error("sn1"); + trace_src_error(NULL, "sn1"); return NULL; }
@@ -579,7 +589,7 @@ static void src_free(struct comp_dev *dev) { struct comp_data *cd = comp_get_drvdata(dev);
- trace_src("fre"); + trace_src(dev, "fre");
/* Free dynamically reserved buffers for SRC algorithm */ if (!cd->delay_lines) @@ -607,7 +617,7 @@ static int src_params(struct comp_dev *dev) int frames_is_for_source; int q;
- trace_src("par"); + trace_src(dev, "par");
/* SRC supports S24_4LE and S32_LE formats */ switch (config->frame_fmt) { @@ -618,7 +628,7 @@ static int src_params(struct comp_dev *dev) cd->polyphase_func = src_polyphase_stage_cir; break; default: - trace_src_error("sr0"); + trace_src_error(dev, "sr0"); return -EINVAL; }
@@ -642,20 +652,21 @@ static int src_params(struct comp_dev *dev) }
/* Allocate needed memory for delay lines */ - err = src_buffer_lengths(&cd->param, source_rate, sink_rate, - params->channels, dev->frames, frames_is_for_source); + err = src_buffer_lengths(dev, &cd->param, source_rate, sink_rate, + params->channels, dev->frames, + frames_is_for_source); if (err < 0) { - trace_src_error("sr1"); - trace_error_value(source_rate); - trace_error_value(sink_rate); - trace_error_value(params->channels); - trace_error_value(dev->frames); + trace_src_error(dev, "sr1"); + trace_src_error_value(dev, source_rate); + trace_src_error_value(dev, sink_rate); + trace_src_error_value(dev, params->channels); + trace_src_error_value(dev, dev->frames); return err; }
delay_lines_size = sizeof(int32_t) * cd->param.total; if (delay_lines_size == 0) { - trace_src_error("sr2"); + trace_src_error(dev, "sr2"); return -EINVAL; }
@@ -666,8 +677,8 @@ static int src_params(struct comp_dev *dev) cd->delay_lines = rballoc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, delay_lines_size); if (!cd->delay_lines) { - trace_src_error("sr3"); - trace_error_value(delay_lines_size); + trace_src_error(dev, "sr3"); + trace_src_error_value(dev, delay_lines_size); return -EINVAL; }
@@ -698,7 +709,7 @@ static int src_params(struct comp_dev *dev) * requested rates combination. Sink audio will be * muted if copy() is run. */ - trace_src("SFa"); + trace_src(dev, "SFa"); cd->src_func = src_fallback; return -EINVAL; } @@ -721,9 +732,9 @@ static int src_params(struct comp_dev *dev) source_list); err = buffer_set_size(sink, q * dev->frames * dev->frame_bytes); if (err < 0) { - trace_src_error("eSz"); - trace_error_value(sink->alloc_size); - trace_error_value(q * dev->frames * dev->frame_bytes); + trace_src_error(dev, "eSz"); + trace_src_error_value(dev, sink->alloc_size); + trace_src_error_value(dev, q * dev->frames * dev->frame_bytes); return err; }
@@ -731,7 +742,7 @@ static int src_params(struct comp_dev *dev) source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); if (source->size < cd->param.blk_in * dev->frame_bytes) { - trace_src_error("eSy"); + trace_src_error(dev, "eSy"); return -EINVAL; }
@@ -740,7 +751,7 @@ static int src_params(struct comp_dev *dev)
static int src_ctrl_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata) { - trace_src_error("ec1"); + trace_src_error(dev, "ec1"); return -EINVAL; }
@@ -750,7 +761,7 @@ static int src_cmd(struct comp_dev *dev, int cmd, void *data) struct sof_ipc_ctrl_data *cdata = data; int ret = 0;
- trace_src("cmd"); + trace_src(dev, "cmd");
if (cmd == COMP_CMD_SET_VALUE) ret = src_ctrl_cmd(dev, cdata); @@ -760,7 +771,7 @@ static int src_cmd(struct comp_dev *dev, int cmd, void *data)
static int src_trigger(struct comp_dev *dev, int cmd) { - trace_src("trg"); + trace_src(dev, "trg");
return comp_set_state(dev, cmd); } @@ -776,7 +787,7 @@ static int src_copy(struct comp_dev *dev) size_t consumed = 0; size_t produced = 0;
- trace_src("SRC"); + trace_src(dev, "SRC");
/* src component needs 1 source and 1 sink buffer */ source = list_first_item(&dev->bsource_list, struct comp_buffer, @@ -799,18 +810,18 @@ static int src_copy(struct comp_dev *dev) * check for XRUNs. */ if (source->avail < need_source) { - trace_src_error("xru"); + trace_src_error(dev, "xru"); return -EIO; /* xrun */ } if (sink->free < need_sink) { - trace_src_error("xro"); + trace_src_error(dev, "xro"); return -EIO; /* xrun */ }
cd->src_func(dev, source, sink, &consumed, &produced);
- tracev_value(consumed >> 3); - tracev_value(produced >> 3); + tracev_src_value(dev, consumed >> 3); + tracev_src_value(dev, produced >> 3);
/* Calc new free and available if data was processed. These * functions must not be called with 0 consumed/produced. @@ -829,7 +840,7 @@ static int src_copy(struct comp_dev *dev)
static int src_prepare(struct comp_dev *dev) { - trace_src("pre"); + trace_src(dev, "pre");
return comp_set_state(dev, COMP_TRIGGER_PREPARE); } @@ -838,7 +849,7 @@ static int src_reset(struct comp_dev *dev) { struct comp_data *cd = comp_get_drvdata(dev);
- trace_src("SRe"); + trace_src(dev, "SRe");
cd->src_func = src_2s_s32_default; src_polyphase_reset(&cd->src); diff --git a/src/audio/src.h b/src/audio/src.h index 5268a66..a78bcc5 100644 --- a/src/audio/src.h +++ b/src/audio/src.h @@ -119,8 +119,9 @@ void src_polyphase_stage_cir(struct src_stage_prm *s);
void src_polyphase_stage_cir_s24(struct src_stage_prm *s);
-int src_buffer_lengths(struct src_param *p, int fs_in, int fs_out, int nch, - int frames, int frames_is_for_source); +int src_buffer_lengths(struct comp_dev *dev, struct src_param *p, int fs_in, + int fs_out, int nch, int frames, + int frames_is_for_source);
int32_t src_input_rates(void);