[Sound-open-firmware] [PATCH v3 6/7] host: remove 'host_' prefix for host_data struct

Keyon Jie yang.jie at linux.intel.com
Wed Mar 1 10:32:04 CET 2017


The struct host_data is designed to host the host
component specific datas, so 'host_' prefix there
looks superfluous.

Here remove them, rename some members of host_data,
and change comments to make them understandable.

Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
---
 src/audio/host.c | 92 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/src/audio/host.c b/src/audio/host.c
index 92b5cf3..195cd6c 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -72,12 +72,12 @@ struct host_data {
 	struct hc_buf local;
 	uint32_t host_size;
 	volatile uint32_t *host_pos;    /* read/write pos, update to mailbox for host side */
-	uint32_t host_w_ptr;		 /* the host buffer write pos in bytes */
-	uint32_t host_r_ptr;		   /* the host buffer read pos in bytes */
-	uint32_t host_period_bytes; /* host period size(host_pos update period) in bytes */
-	uint32_t host_period_pos;	/* position in current host period */
-	uint32_t host_avail;   /* host buffer available size */
-	uint32_t host_free;    /* host buffer free size */
+	uint32_t buff_w_off;		 /* the host side buffer write offset in bytes */
+	uint32_t buff_r_off;		   /* the host side buffer read offset in bytes */
+	uint32_t report_period; /* host_pos report/update to host side period, in bytes */
+	uint32_t report_pos;	/* position in current report period */
+	uint32_t buff_avail;   /* host side buffer available size */
+	uint32_t buff_free;    /* host side buffer free size */
 	/* pointers set during params to host or local above */
 	struct hc_buf *source;
 	struct hc_buf *sink;
@@ -91,13 +91,13 @@ struct host_data {
 
 static void host_update_buffer(struct host_data *hd, uint32_t produce)
 {
-	if (hd->host_r_ptr < hd->host_w_ptr)
-		hd->host_avail = hd->host_w_ptr - hd->host_r_ptr;
-	else if (hd->host_r_ptr == hd->host_w_ptr)
-		hd->host_avail = produce ? hd->host_size : 0;
+	if (hd->buff_r_off < hd->buff_w_off)
+		hd->buff_avail = hd->buff_w_off - hd->buff_r_off;
+	else if (hd->buff_r_off == hd->buff_w_off)
+		hd->buff_avail = produce ? hd->host_size : 0;
 	else
-		hd->host_avail = hd->host_size -hd->host_r_ptr + hd->host_w_ptr;
-	hd->host_free = hd->host_size - hd->host_avail;
+		hd->buff_avail = hd->host_size -hd->buff_r_off + hd->buff_w_off;
+	hd->buff_free = hd->host_size - hd->buff_avail;
 }
 
 static inline struct dma_sg_elem *next_buffer(struct hc_buf *hc)
@@ -150,22 +150,22 @@ static void host_dma_cb_playback(struct comp_dev *dev,
 	comp_update_buffer_produce(hd->dma_buffer);
 
 	/* new local period, update host buffer position blks */
-	hd->host_r_ptr += local_elem->size;
+	hd->buff_r_off += local_elem->size;
 
 	/* buffer overlap ? */
-	if (hd->host_r_ptr >= hd->host_size)
-		hd->host_r_ptr = 0;
+	if (hd->buff_r_off >= hd->host_size)
+		hd->buff_r_off = 0;
 	host_update_buffer(hd, 0); /* consume */
 
 	/* send IPC message to driver if needed */
-	hd->host_period_pos += local_elem->size;
-	if (hd->host_period_pos >= hd->host_period_bytes) {
-		hd->host_period_pos = 0;
+	hd->report_pos += local_elem->size;
+	if (hd->report_pos >= hd->report_period) {
+		hd->report_pos = 0;
 		/* for the last bytes/period, send notification later */
-		if (hd->host_avail) {
+		if (hd->buff_avail) {
 			/* update for host side */
 			if (hd->host_pos) {
-				*hd->host_pos = hd->host_r_ptr;
+				*hd->host_pos = hd->buff_r_off;
 				ipc_stream_send_notification(dev, &hd->cp);
 			}
 		}
@@ -204,8 +204,8 @@ static void host_dma_cb_playback(struct comp_dev *dev,
 	local_elem->size = next_size;
 
 	/* check if avail is enough, otherwise, drain the last bytes and stop */
-	if (hd->host_avail < local_elem->size) {
-		if (hd->host_avail == 0) {
+	if (hd->buff_avail < local_elem->size) {
+		if (hd->buff_avail == 0) {
 			/* end of stream, stop */
 			next->size = DMA_RELOAD_END;
 			need_copy = 0;
@@ -217,12 +217,12 @@ static void host_dma_cb_playback(struct comp_dev *dev,
 		}
 
 		/* end of stream, drain the last bytes */
-		local_elem->size = hd->host_avail;
+		local_elem->size = hd->buff_avail;
 
 		/* the split_remaining may not be copied anymore, but, let's make it
-		   correct. we have only hd->host_avail data, so the split_remaining
-		   should be (next_size - hd->host_avail) bigger */
-		hd->split_remaining += next_size - hd->host_avail;
+		   correct. we have only hd->buff_avail data, so the split_remaining
+		   should be (next_size - hd->buff_avail) bigger */
+		hd->split_remaining += next_size - hd->buff_avail;
 	}
 
 next_copy:
@@ -268,21 +268,21 @@ static void host_dma_cb_capture(struct comp_dev *dev,
 #endif
 
 	/* new local period, update host buffer position blks */
-	hd->host_w_ptr += local_elem->size;
+	hd->buff_w_off += local_elem->size;
 
 	/* buffer overlap ? */
-	if (hd->host_w_ptr >= hd->host_size)
-		hd->host_w_ptr = 0;
+	if (hd->buff_w_off >= hd->host_size)
+		hd->buff_w_off = 0;
 	if (hd->host_pos)
-		*hd->host_pos = hd->host_w_ptr;
+		*hd->host_pos = hd->buff_w_off;
 
 	/* recalc available buffer space */
 	comp_update_buffer_consume(hd->dma_buffer);
 
 	/* send IPC message to driver if needed */
-	hd->host_period_pos += local_elem->size;
-	if (hd->host_period_pos >= hd->host_period_bytes) {
-		hd->host_period_pos = 0;
+	hd->report_pos += local_elem->size;
+	if (hd->report_pos >= hd->report_period) {
+		hd->report_pos = 0;
 		ipc_stream_send_notification(dev, &hd->cp);
 	}
 
@@ -370,7 +370,7 @@ static uint32_t host_finish_work(void *data, uint32_t udelay)
 		if (hd->host_pos) {
 			*hd->host_pos =
 				hd->params.direction == STREAM_DIRECTION_PLAYBACK ?
-				hd->host_r_ptr : hd->host_w_ptr;
+				hd->buff_r_off : hd->buff_w_off;
 			/* send the last notification to host */
 			ipc_stream_send_notification(dev, &hd->cp);
 		}
@@ -606,7 +606,7 @@ static int host_prepare(struct comp_dev *dev)
 	struct comp_buffer *dma_buffer;
 
 	if (hd->params.direction == STREAM_DIRECTION_PLAYBACK) {
-		hd->host_r_ptr = 0;
+		hd->buff_r_off = 0;
 
 		dma_buffer = list_first_item(&dev->bsink_list,
 			struct comp_buffer, source_list);
@@ -614,7 +614,7 @@ static int host_prepare(struct comp_dev *dev)
 		dma_buffer->r_ptr = dma_buffer->addr;
 		dma_buffer->w_ptr = dma_buffer->addr;
 	} else {
-		hd->host_w_ptr = 0;
+		hd->buff_w_off = 0;
 
 		dma_buffer = list_first_item(&dev->bsource_list,
 			struct comp_buffer, sink_list);
@@ -625,8 +625,8 @@ static int host_prepare(struct comp_dev *dev)
 
 	if (hd->host_pos)
 		*hd->host_pos = 0;
-	hd->host_period_pos = 0;
-	hd->host_period_bytes =
+	hd->report_pos = 0;
+	hd->report_period =
 		hd->params.period_frames * hd->params.frame_size;
 	hd->split_remaining = 0;
 
@@ -665,9 +665,9 @@ static int host_pointer_reset(struct comp_dev *dev)
 	/* reset buffer pointers */
 	if (hd->host_pos)
 		*hd->host_pos = 0;
-	hd->host_r_ptr = 0;
-	hd->host_w_ptr = 0;
-	hd->host_period_pos = 0;
+	hd->buff_r_off = 0;
+	hd->buff_w_off = 0;
+	hd->report_pos = 0;
 
 	host_update_buffer(hd, 0); /* consume */
 
@@ -727,11 +727,11 @@ static int host_cmd(struct comp_dev *dev, int cmd, void *data)
 		app_pos = (struct ipc_intel_ipc_stream_set_position *)data;
 
 		if (hd->params.direction == STREAM_DIRECTION_PLAYBACK) {
-			hd->host_w_ptr = app_pos->position;
+			hd->buff_w_off = app_pos->position;
 			host_update_buffer(hd, 1); /* produce */
 		}
 		else {
-			hd->host_r_ptr = app_pos->position;
+			hd->buff_r_off = app_pos->position;
 			host_update_buffer(hd, 0); /* consume */
 		}
 		break;
@@ -792,7 +792,7 @@ static int host_reset(struct comp_dev *dev)
 	host_pointer_reset(dev);
 	hd->host_pos = NULL;
 
-	hd->host_period_bytes = 0;
+	hd->report_period = 0;
 	hd->source = NULL;
 	hd->sink = NULL;
 	dev->state = COMP_STATE_INIT;
@@ -812,10 +812,10 @@ static int host_copy(struct comp_dev *dev)
 
 	/* don't copy if the host side buffer is not ready */
 	if ((hd->params.direction == STREAM_DIRECTION_PLAYBACK)
-		&&  (hd->host_avail == 0))
+		&&  (hd->buff_avail == 0))
 		return 0;
 	if ((hd->params.direction == STREAM_DIRECTION_CAPTURE)
-		&& (hd->host_free == 0))
+		&& (hd->buff_free == 0))
 		return 0;
 
 	/* do DMA transfer */
-- 
2.7.4



More information about the Sound-open-firmware mailing list