[Sound-open-firmware] [PATCH v2 07/26] intel-ipc: add stream operation IPC_INTEL_STR_STOP

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


It used IPC_INTEL_STR_PAUSE plus IPC_INTEL_STR_RESET to stop a
stream, but sometimes we application only intend to stop the
stream(e.g. speaker-test with large buffer size( > .wav file
size)), which means we only reset the buffer pointers but don't
need set params again(for reset, we need set params again).

Here add this stream operation IPC_INTEL_STR_STOP to handle
this case.

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

diff --git a/src/include/uapi/intel-ipc.h b/src/include/uapi/intel-ipc.h
index a4589b3..5fae423 100644
--- a/src/include/uapi/intel-ipc.h
+++ b/src/include/uapi/intel-ipc.h
@@ -182,6 +182,7 @@ enum ipc_str_operation {
 	IPC_INTEL_STR_RESUME = 2,
 	IPC_INTEL_STR_STAGE_MESSAGE = 3,
 	IPC_INTEL_STR_NOTIFICATION = 4,
+	IPC_INTEL_STR_STOP = 5,
 	IPC_INTEL_STR_MAX_MESSAGE
 };
 
diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c
index f192917..7db4179 100644
--- a/src/ipc/intel-ipc.c
+++ b/src/ipc/intel-ipc.c
@@ -811,6 +811,39 @@ error:
 	return IPC_INTEL_GLB_REPLY_ERROR_INVALID_PARAM;
 }
 
+static uint32_t ipc_stream_stop(uint32_t header)
+{
+	struct ipc_pcm_dev *pcm_dev;
+	uint32_t stream_id;
+	int err;
+
+	trace_ipc("SSt");
+
+	stream_id = header & IPC_INTEL_STR_ID_MASK;
+	stream_id >>= IPC_INTEL_STR_ID_SHIFT;
+
+	/* get the pcm_dev */
+	pcm_dev = ipc_get_pcm_comp(stream_id);
+	if (pcm_dev == NULL) {
+		trace_ipc_error("erg");
+		goto error;
+	}
+
+	/* send stop TODO: this should be done in trigger */
+	err = pipeline_cmd(pcm_dev->dev.p, pcm_dev->dev.cd,
+		COMP_CMD_STOP, NULL);
+	if (err < 0) {
+		trace_ipc_error("erc");
+		goto error;
+	}
+
+	/* need prepare again before next start */
+	pcm_dev->state = IPC_HOST_ALLOC;
+	return IPC_INTEL_GLB_REPLY_SUCCESS;
+error:
+	return IPC_INTEL_GLB_REPLY_ERROR_INVALID_PARAM;
+}
+
 static uint32_t ipc_stream_pause(uint32_t header)
 {
 	struct ipc_pcm_dev *pcm_dev;
@@ -905,6 +938,8 @@ static uint32_t ipc_stream_message(uint32_t header)
 		return ipc_stream_reset(header);
 	case IPC_INTEL_STR_PAUSE:
 		return ipc_stream_pause(header);
+	case IPC_INTEL_STR_STOP:
+		return ipc_stream_stop(header);
 	case IPC_INTEL_STR_RESUME:
 		return ipc_stream_resume(header);
 	case IPC_INTEL_STR_STAGE_MESSAGE:
-- 
2.7.4



More information about the Sound-open-firmware mailing list