[Sound-open-firmware] [PATCH v2 06/26] intel-ipc: add application buffer pointer update from host side

Keyon Jie yang.jie at linux.intel.com
Thu Feb 9 16:03:58 CET 2017


We need the application buffer pointer(write pointer for playback)
update from the host side, to make the ALSA pcm buffer pointer
checking possible.

Here we introduce component command COMP_CMD_AVAIL_UPDATE for the
update event notification.

Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
---
 src/include/reef/audio/component.h |  1 +
 src/ipc/intel-ipc.c                | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/src/include/reef/audio/component.h b/src/include/reef/audio/component.h
index e521753..bbd9b33 100644
--- a/src/include/reef/audio/component.h
+++ b/src/include/reef/audio/component.h
@@ -72,6 +72,7 @@
 #define COMP_CMD_MUTE		101
 #define COMP_CMD_UNMUTE		102
 #define COMP_CMD_ROUTE		103
+#define COMP_CMD_AVAIL_UPDATE          104
 
 /* MMAP IPC status */
 #define COMP_CMD_IPC_MMAP_RPOS	200	/* host read position */
diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c
index 127541d..f192917 100644
--- a/src/ipc/intel-ipc.c
+++ b/src/ipc/intel-ipc.c
@@ -711,9 +711,43 @@ error:
 
 static uint32_t ipc_stage_write_pos(uint32_t header)
 {
+	struct ipc_comp_dev *stream_dev;
+	struct ipc_intel_ipc_stream_set_position app_pos;
+	uint32_t stream_id;
+	int err;
+
 	trace_ipc("PoW");
 
+	/* read volume from the inbox */
+	mailbox_inbox_read(&app_pos, 0, sizeof(app_pos));
+
+	trace_value(app_pos.position);
+	/* the driver uses stream ID to also identify certain mixers */
+	stream_id = header & IPC_INTEL_STR_ID_MASK;
+	stream_id >>= IPC_INTEL_STR_ID_SHIFT;
+
+	/* get the pcm_dev */
+	stream_dev = ipc_get_comp(stream_id);
+	if (stream_dev == NULL)
+		goto error;
+
+	err = pipeline_cmd(stream_dev->p, stream_dev->cd,
+		COMP_CMD_AVAIL_UPDATE, &app_pos);
+	if (err < 0)
+		goto error;
+
+	/* drain the pipeline for EOS */
+	if (app_pos.end_of_buffer) {
+		err = pipeline_cmd(stream_dev->p, stream_dev->cd,
+			COMP_CMD_DRAIN, NULL);
+		if (err < 0)
+			goto error;
+	}
+
 	return IPC_INTEL_GLB_REPLY_SUCCESS;
+
+error:
+	return IPC_INTEL_GLB_REPLY_ERROR_INVALID_PARAM;
 }
 
 static uint32_t ipc_stage_message(uint32_t header)
-- 
2.7.4



More information about the Sound-open-firmware mailing list