[Sound-open-firmware] [RFC PATCH v2 16/29] Change macro definition and trace calling for comp_dev.

yan.wang at linux.intel.com yan.wang at linux.intel.com
Fri May 11 08:35:58 CEST 2018


From: Yan Wang <yan.wang at linux.intel.com>

It will use COMP trace class and component DMA trace API.
For trace calling of comp_new(), NULL will be passed into trace
API because comp_dev hasn't been initialized.

Signed-off-by: Yan Wang <yan.wang at 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/component.c             | 30 +++++++++++++++---------------
 src/include/sof/audio/component.h | 31 +++++++++++++++++++------------
 2 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/src/audio/component.c b/src/audio/component.c
index 15760b2..8684d87 100644
--- a/src/audio/component.c
+++ b/src/audio/component.c
@@ -78,15 +78,15 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp)
 	/* find the driver for our new component */
 	drv = get_drv(comp->type);
 	if (drv == NULL) {
-		trace_comp_error("eCD");
-		trace_error_value(comp->type);
+		trace_comp_error(NULL, "eCD");
+		trace_comp_val(NULL, comp->type);
 		return NULL;
 	}
 
 	/* create the new component */
 	cdev = drv->ops.new(comp);
 	if (cdev == NULL) {
-		trace_comp_error("eCN");
+		trace_comp_error(NULL, "eCN");
 		return NULL;
 	}
 
@@ -127,8 +127,8 @@ int comp_set_state(struct comp_dev *dev, int cmd)
 			dev->state == COMP_STATE_PAUSED) {
 			dev->state = COMP_STATE_ACTIVE;
 		} else {
-			trace_comp_error("CES");
-			trace_error_value(dev->state);
+			trace_comp_error(dev, "CES");
+			trace_comp_val(dev, dev->state);
 			ret = -EINVAL;
 		}
 		break;
@@ -136,8 +136,8 @@ int comp_set_state(struct comp_dev *dev, int cmd)
 		if (dev->state == COMP_STATE_PAUSED) {
 			dev->state = COMP_STATE_ACTIVE;
 		} else {
-			trace_comp_error("CEr");
-			trace_error_value(dev->state);
+			trace_comp_error(dev, "CEr");
+			trace_comp_val(dev, dev->state);
 			ret = -EINVAL;
 		}
 		break;
@@ -146,8 +146,8 @@ int comp_set_state(struct comp_dev *dev, int cmd)
 		if (dev->state == COMP_STATE_ACTIVE) {
 			dev->state = COMP_STATE_PREPARE;
 		} else {
-			trace_comp_error("CEs");
-			trace_error_value(dev->state);
+			trace_comp_error(dev, "CEs");
+			trace_comp_val(dev, dev->state);
 			ret = -EINVAL;
 		}
 		break;
@@ -156,8 +156,8 @@ int comp_set_state(struct comp_dev *dev, int cmd)
 		if (dev->state == COMP_STATE_ACTIVE)
 			dev->state = COMP_STATE_PAUSED;
 		else {
-			trace_comp_error("CEp");
-			trace_error_value(dev->state);
+			trace_comp_error(dev, "CEp");
+			trace_comp_val(dev, dev->state);
 			ret = -EINVAL;
 		}
 		break;
@@ -166,8 +166,8 @@ int comp_set_state(struct comp_dev *dev, int cmd)
 		dev->state = COMP_STATE_READY;
 		if (dev->state == COMP_STATE_ACTIVE ||
 			dev->state == COMP_STATE_PAUSED) {
-			trace_comp_error("CER");
-			trace_error_value(dev->state);
+			trace_comp_error(dev, "CER");
+			trace_comp_val(dev, dev->state);
 			ret = 0;
 		}
 		break;
@@ -176,8 +176,8 @@ int comp_set_state(struct comp_dev *dev, int cmd)
 			dev->state == COMP_STATE_READY) {
 			dev->state = COMP_STATE_PREPARE;
 		} else {
-			trace_comp_error("CEP");
-			trace_error_value(dev->state);
+			trace_comp_error(dev, "CEP");
+			trace_comp_val(dev, dev->state);
 			ret = -EINVAL;
 		}
 		break;
diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h
index 80a72d9..daf0aa7 100644
--- a/src/include/sof/audio/component.h
+++ b/src/include/sof/audio/component.h
@@ -107,9 +107,16 @@
 #define COMP_OPS_BUFFER		4
 #define COMP_OPS_RESET		5
 
-#define trace_comp(__e)	trace_event(TRACE_CLASS_COMP, __e)
-#define trace_comp_error(__e)	trace_error(TRACE_CLASS_COMP, __e)
-#define tracev_comp(__e)	tracev_event(TRACE_CLASS_COMP, __e)
+#define trace_comp(cd, __e) \
+	trace_comp_event(cd, NORMAL_LEVEL, TRACE_CLASS_COMP, __e)
+#define tracev_comp(cd, __e) \
+	trace_comp_event(cd, VERBOSE_LEVEL, TRACE_CLASS_COMP, __e)
+#define trace_comp_error(cd, __e) \
+	trace_comp_event_atomic(cd, ERROR_LEVEL, TRACE_CLASS_COMP, __e)
+#define trace_comp_val(cd, x) \
+	trace_comp_value(cd, NORMAL_LEVEL, x)
+#define trace_comp_error_val(cd, x) \
+	trace_comp_value_atomic(cd, ERROR_LEVEL, x)
 
 struct comp_dev;
 struct comp_buffer;
@@ -256,9 +263,9 @@ static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data)
 	if ((cmd == COMP_CMD_SET_DATA)
 		&& ((cdata->data->magic != SOF_ABI_MAGIC)
 		|| (cdata->data->abi != SOF_ABI_VERSION))) {
-		trace_comp_error("abi");
-		trace_error_value(cdata->data->magic);
-		trace_error_value(cdata->data->abi);
+		trace_comp_error(dev, "abi");
+		trace_comp_error_val(dev, cdata->data->magic);
+		trace_comp_error_val(dev, cdata->data->abi);
 		return -EINVAL;
 	}
 
@@ -367,9 +374,9 @@ static inline uint32_t comp_sample_bytes(struct comp_dev *dev)
 static inline void comp_underrun(struct comp_dev *dev, struct comp_buffer *source,
 	uint32_t copy_bytes, uint32_t min_bytes)
 {
-	trace_comp("Xun");
-	trace_value((dev->comp.id << 16) | source->avail);
-	trace_value((min_bytes << 16) | copy_bytes);
+	trace_comp(dev, "Xun");
+	trace_comp_val(dev, (dev->comp.id << 16) | source->avail);
+	trace_comp_val(dev, (min_bytes << 16) | copy_bytes);
 
 	pipeline_xrun(dev->pipeline, dev, (int32_t)source->avail - copy_bytes);
 }
@@ -377,9 +384,9 @@ static inline void comp_underrun(struct comp_dev *dev, struct comp_buffer *sourc
 static inline void comp_overrun(struct comp_dev *dev, struct comp_buffer *sink,
 	uint32_t copy_bytes, uint32_t min_bytes)
 {
-	trace_comp("Xov");
-	trace_value((dev->comp.id << 16) | sink->free);
-	trace_value((min_bytes << 16) | copy_bytes);
+	trace_comp(dev, "Xov");
+	trace_comp_val(dev, (dev->comp.id << 16) | sink->free);
+	trace_comp_val(dev, (min_bytes << 16) | copy_bytes);
 
 	pipeline_xrun(dev->pipeline, dev, (int32_t)copy_bytes - sink->free);
 }
-- 
2.14.3



More information about the Sound-open-firmware mailing list