^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * This file is provided under a dual BSD/GPLv2 license. When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright(c) 2018 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef __INCLUDE_SOUND_SOF_STREAM_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define __INCLUDE_SOUND_SOF_STREAM_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <sound/sof/header.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Stream configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define SOF_IPC_MAX_CHANNELS 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* common sample rates for use in masks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define SOF_RATE_8000 (1 << 0) /**< 8000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define SOF_RATE_11025 (1 << 1) /**< 11025Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define SOF_RATE_12000 (1 << 2) /**< 12000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define SOF_RATE_16000 (1 << 3) /**< 16000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define SOF_RATE_22050 (1 << 4) /**< 22050Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define SOF_RATE_24000 (1 << 5) /**< 24000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define SOF_RATE_32000 (1 << 6) /**< 32000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define SOF_RATE_44100 (1 << 7) /**< 44100Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define SOF_RATE_48000 (1 << 8) /**< 48000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define SOF_RATE_64000 (1 << 9) /**< 64000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define SOF_RATE_88200 (1 << 10) /**< 88200Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define SOF_RATE_96000 (1 << 11) /**< 96000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define SOF_RATE_176400 (1 << 12) /**< 176400Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define SOF_RATE_192000 (1 << 13) /**< 192000Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* continuous and non-standard rates for flexibility */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define SOF_RATE_CONTINUOUS (1 << 30) /**< range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define SOF_RATE_KNOT (1 << 31) /**< non-continuous */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* generic PCM flags for runtime settings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define SOF_PCM_FLAG_XRUN_STOP (1 << 0) /**< Stop on any XRUN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* stream PCM frame format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) enum sof_ipc_frame {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) SOF_IPC_FRAME_S16_LE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) SOF_IPC_FRAME_S24_4LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) SOF_IPC_FRAME_S32_LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) SOF_IPC_FRAME_FLOAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* other formats here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* stream buffer format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) enum sof_ipc_buffer_format {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) SOF_IPC_BUFFER_INTERLEAVED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) SOF_IPC_BUFFER_NONINTERLEAVED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* other formats here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* stream direction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) enum sof_ipc_stream_direction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) SOF_IPC_STREAM_PLAYBACK = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) SOF_IPC_STREAM_CAPTURE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* stream ring info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct sof_ipc_host_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct sof_ipc_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) uint32_t phy_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) uint32_t pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) uint32_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) uint32_t reserved[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct sof_ipc_stream_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct sof_ipc_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct sof_ipc_host_buffer buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) uint32_t direction; /**< enum sof_ipc_stream_direction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) uint32_t frame_fmt; /**< enum sof_ipc_frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) uint32_t buffer_fmt; /**< enum sof_ipc_buffer_format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) uint32_t rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) uint16_t stream_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) uint16_t channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) uint16_t sample_valid_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) uint16_t sample_container_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) uint32_t host_period_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) uint16_t no_stream_position; /**< 1 means don't send stream position */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) uint16_t reserved[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct sof_ipc_pcm_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct sof_ipc_cmd_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) uint32_t comp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) uint32_t flags; /**< generic PCM flags - SOF_PCM_FLAG_ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) uint32_t reserved[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct sof_ipc_stream_params params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /* PCM params info reply - SOF_IPC_STREAM_PCM_PARAMS_REPLY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct sof_ipc_pcm_params_reply {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct sof_ipc_reply rhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) uint32_t comp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) uint32_t posn_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* free stream - SOF_IPC_STREAM_PCM_PARAMS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct sof_ipc_stream {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct sof_ipc_cmd_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) uint32_t comp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* flags indicating which time stamps are in sync with each other */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define SOF_TIME_HOST_SYNC (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define SOF_TIME_DAI_SYNC (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define SOF_TIME_WALL_SYNC (1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define SOF_TIME_STAMP_SYNC (1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* flags indicating which time stamps are valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define SOF_TIME_HOST_VALID (1 << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define SOF_TIME_DAI_VALID (1 << 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define SOF_TIME_WALL_VALID (1 << 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define SOF_TIME_STAMP_VALID (1 << 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* flags indicating time stamps are 64bit else 3use low 32bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define SOF_TIME_HOST_64 (1 << 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define SOF_TIME_DAI_64 (1 << 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define SOF_TIME_WALL_64 (1 << 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define SOF_TIME_STAMP_64 (1 << 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct sof_ipc_stream_posn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct sof_ipc_reply rhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) uint32_t comp_id; /**< host component ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) uint32_t flags; /**< SOF_TIME_ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) uint32_t wallclock_hz; /**< frequency of wallclock in Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) uint32_t timestamp_ns; /**< resolution of timestamp in ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) uint64_t host_posn; /**< host DMA position in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) uint64_t dai_posn; /**< DAI DMA position in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) uint64_t comp_posn; /**< comp position in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) uint64_t wallclock; /**< audio wall clock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) uint64_t timestamp; /**< system time stamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) uint32_t xrun_comp_id; /**< comp ID of XRUN component */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int32_t xrun_size; /**< XRUN size in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #endif