18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. All rights reserved.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __INCLUDE_SOUND_SOF_STREAM_H__
108c2ecf20Sopenharmony_ci#define __INCLUDE_SOUND_SOF_STREAM_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <sound/sof/header.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/*
158c2ecf20Sopenharmony_ci * Stream configuration.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define SOF_IPC_MAX_CHANNELS			8
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* common sample rates for use in masks */
218c2ecf20Sopenharmony_ci#define SOF_RATE_8000		(1 <<  0) /**< 8000Hz  */
228c2ecf20Sopenharmony_ci#define SOF_RATE_11025		(1 <<  1) /**< 11025Hz */
238c2ecf20Sopenharmony_ci#define SOF_RATE_12000		(1 <<  2) /**< 12000Hz */
248c2ecf20Sopenharmony_ci#define SOF_RATE_16000		(1 <<  3) /**< 16000Hz */
258c2ecf20Sopenharmony_ci#define SOF_RATE_22050		(1 <<  4) /**< 22050Hz */
268c2ecf20Sopenharmony_ci#define SOF_RATE_24000		(1 <<  5) /**< 24000Hz */
278c2ecf20Sopenharmony_ci#define SOF_RATE_32000		(1 <<  6) /**< 32000Hz */
288c2ecf20Sopenharmony_ci#define SOF_RATE_44100		(1 <<  7) /**< 44100Hz */
298c2ecf20Sopenharmony_ci#define SOF_RATE_48000		(1 <<  8) /**< 48000Hz */
308c2ecf20Sopenharmony_ci#define SOF_RATE_64000		(1 <<  9) /**< 64000Hz */
318c2ecf20Sopenharmony_ci#define SOF_RATE_88200		(1 << 10) /**< 88200Hz */
328c2ecf20Sopenharmony_ci#define SOF_RATE_96000		(1 << 11) /**< 96000Hz */
338c2ecf20Sopenharmony_ci#define SOF_RATE_176400		(1 << 12) /**< 176400Hz */
348c2ecf20Sopenharmony_ci#define SOF_RATE_192000		(1 << 13) /**< 192000Hz */
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* continuous and non-standard rates for flexibility */
378c2ecf20Sopenharmony_ci#define SOF_RATE_CONTINUOUS	(1 << 30)  /**< range */
388c2ecf20Sopenharmony_ci#define SOF_RATE_KNOT		(1 << 31)  /**< non-continuous */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* generic PCM flags for runtime settings */
418c2ecf20Sopenharmony_ci#define SOF_PCM_FLAG_XRUN_STOP	(1 << 0) /**< Stop on any XRUN */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* stream PCM frame format */
448c2ecf20Sopenharmony_cienum sof_ipc_frame {
458c2ecf20Sopenharmony_ci	SOF_IPC_FRAME_S16_LE = 0,
468c2ecf20Sopenharmony_ci	SOF_IPC_FRAME_S24_4LE,
478c2ecf20Sopenharmony_ci	SOF_IPC_FRAME_S32_LE,
488c2ecf20Sopenharmony_ci	SOF_IPC_FRAME_FLOAT,
498c2ecf20Sopenharmony_ci	/* other formats here */
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* stream buffer format */
538c2ecf20Sopenharmony_cienum sof_ipc_buffer_format {
548c2ecf20Sopenharmony_ci	SOF_IPC_BUFFER_INTERLEAVED,
558c2ecf20Sopenharmony_ci	SOF_IPC_BUFFER_NONINTERLEAVED,
568c2ecf20Sopenharmony_ci	/* other formats here */
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* stream direction */
608c2ecf20Sopenharmony_cienum sof_ipc_stream_direction {
618c2ecf20Sopenharmony_ci	SOF_IPC_STREAM_PLAYBACK = 0,
628c2ecf20Sopenharmony_ci	SOF_IPC_STREAM_CAPTURE,
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* stream ring info */
668c2ecf20Sopenharmony_cistruct sof_ipc_host_buffer {
678c2ecf20Sopenharmony_ci	struct sof_ipc_hdr hdr;
688c2ecf20Sopenharmony_ci	uint32_t phy_addr;
698c2ecf20Sopenharmony_ci	uint32_t pages;
708c2ecf20Sopenharmony_ci	uint32_t size;
718c2ecf20Sopenharmony_ci	uint32_t reserved[3];
728c2ecf20Sopenharmony_ci} __packed;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistruct sof_ipc_stream_params {
758c2ecf20Sopenharmony_ci	struct sof_ipc_hdr hdr;
768c2ecf20Sopenharmony_ci	struct sof_ipc_host_buffer buffer;
778c2ecf20Sopenharmony_ci	uint32_t direction;	/**< enum sof_ipc_stream_direction */
788c2ecf20Sopenharmony_ci	uint32_t frame_fmt;	/**< enum sof_ipc_frame */
798c2ecf20Sopenharmony_ci	uint32_t buffer_fmt;	/**< enum sof_ipc_buffer_format */
808c2ecf20Sopenharmony_ci	uint32_t rate;
818c2ecf20Sopenharmony_ci	uint16_t stream_tag;
828c2ecf20Sopenharmony_ci	uint16_t channels;
838c2ecf20Sopenharmony_ci	uint16_t sample_valid_bytes;
848c2ecf20Sopenharmony_ci	uint16_t sample_container_bytes;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	uint32_t host_period_bytes;
878c2ecf20Sopenharmony_ci	uint16_t no_stream_position; /**< 1 means don't send stream position */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	uint16_t reserved[3];
908c2ecf20Sopenharmony_ci	uint16_t chmap[SOF_IPC_MAX_CHANNELS];	/**< channel map - SOF_CHMAP_ */
918c2ecf20Sopenharmony_ci} __packed;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */
948c2ecf20Sopenharmony_cistruct sof_ipc_pcm_params {
958c2ecf20Sopenharmony_ci	struct sof_ipc_cmd_hdr hdr;
968c2ecf20Sopenharmony_ci	uint32_t comp_id;
978c2ecf20Sopenharmony_ci	uint32_t flags;		/**< generic PCM flags - SOF_PCM_FLAG_ */
988c2ecf20Sopenharmony_ci	uint32_t reserved[2];
998c2ecf20Sopenharmony_ci	struct sof_ipc_stream_params params;
1008c2ecf20Sopenharmony_ci}  __packed;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/* PCM params info reply - SOF_IPC_STREAM_PCM_PARAMS_REPLY */
1038c2ecf20Sopenharmony_cistruct sof_ipc_pcm_params_reply {
1048c2ecf20Sopenharmony_ci	struct sof_ipc_reply rhdr;
1058c2ecf20Sopenharmony_ci	uint32_t comp_id;
1068c2ecf20Sopenharmony_ci	uint32_t posn_offset;
1078c2ecf20Sopenharmony_ci} __packed;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/* free stream - SOF_IPC_STREAM_PCM_PARAMS */
1108c2ecf20Sopenharmony_cistruct sof_ipc_stream {
1118c2ecf20Sopenharmony_ci	struct sof_ipc_cmd_hdr hdr;
1128c2ecf20Sopenharmony_ci	uint32_t comp_id;
1138c2ecf20Sopenharmony_ci} __packed;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* flags indicating which time stamps are in sync with each other */
1168c2ecf20Sopenharmony_ci#define	SOF_TIME_HOST_SYNC	(1 << 0)
1178c2ecf20Sopenharmony_ci#define	SOF_TIME_DAI_SYNC	(1 << 1)
1188c2ecf20Sopenharmony_ci#define	SOF_TIME_WALL_SYNC	(1 << 2)
1198c2ecf20Sopenharmony_ci#define	SOF_TIME_STAMP_SYNC	(1 << 3)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* flags indicating which time stamps are valid */
1228c2ecf20Sopenharmony_ci#define	SOF_TIME_HOST_VALID	(1 << 8)
1238c2ecf20Sopenharmony_ci#define	SOF_TIME_DAI_VALID	(1 << 9)
1248c2ecf20Sopenharmony_ci#define	SOF_TIME_WALL_VALID	(1 << 10)
1258c2ecf20Sopenharmony_ci#define	SOF_TIME_STAMP_VALID	(1 << 11)
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci/* flags indicating time stamps are 64bit else 3use low 32bit */
1288c2ecf20Sopenharmony_ci#define	SOF_TIME_HOST_64	(1 << 16)
1298c2ecf20Sopenharmony_ci#define	SOF_TIME_DAI_64		(1 << 17)
1308c2ecf20Sopenharmony_ci#define	SOF_TIME_WALL_64	(1 << 18)
1318c2ecf20Sopenharmony_ci#define	SOF_TIME_STAMP_64	(1 << 19)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistruct sof_ipc_stream_posn {
1348c2ecf20Sopenharmony_ci	struct sof_ipc_reply rhdr;
1358c2ecf20Sopenharmony_ci	uint32_t comp_id;	/**< host component ID */
1368c2ecf20Sopenharmony_ci	uint32_t flags;		/**< SOF_TIME_ */
1378c2ecf20Sopenharmony_ci	uint32_t wallclock_hz;	/**< frequency of wallclock in Hz */
1388c2ecf20Sopenharmony_ci	uint32_t timestamp_ns;	/**< resolution of timestamp in ns */
1398c2ecf20Sopenharmony_ci	uint64_t host_posn;	/**< host DMA position in bytes */
1408c2ecf20Sopenharmony_ci	uint64_t dai_posn;	/**< DAI DMA position in bytes */
1418c2ecf20Sopenharmony_ci	uint64_t comp_posn;	/**< comp position in bytes */
1428c2ecf20Sopenharmony_ci	uint64_t wallclock;	/**< audio wall clock */
1438c2ecf20Sopenharmony_ci	uint64_t timestamp;	/**< system time stamp */
1448c2ecf20Sopenharmony_ci	uint32_t xrun_comp_id;	/**< comp ID of XRUN component */
1458c2ecf20Sopenharmony_ci	int32_t xrun_size;	/**< XRUN size in bytes */
1468c2ecf20Sopenharmony_ci}  __packed;
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#endif
149