Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /*
0003  * This file is provided under a dual BSD/GPLv2 license.  When using or
0004  * redistributing this file, you may do so under either license.
0005  *
0006  * Copyright(c) 2018 Intel Corporation. All rights reserved.
0007  */
0008 
0009 #ifndef __INCLUDE_SOUND_SOF_STREAM_H__
0010 #define __INCLUDE_SOUND_SOF_STREAM_H__
0011 
0012 #include <sound/sof/header.h>
0013 
0014 /*
0015  * Stream configuration.
0016  */
0017 
0018 #define SOF_IPC_MAX_CHANNELS            8
0019 
0020 /* common sample rates for use in masks */
0021 #define SOF_RATE_8000       (1 <<  0) /**< 8000Hz  */
0022 #define SOF_RATE_11025      (1 <<  1) /**< 11025Hz */
0023 #define SOF_RATE_12000      (1 <<  2) /**< 12000Hz */
0024 #define SOF_RATE_16000      (1 <<  3) /**< 16000Hz */
0025 #define SOF_RATE_22050      (1 <<  4) /**< 22050Hz */
0026 #define SOF_RATE_24000      (1 <<  5) /**< 24000Hz */
0027 #define SOF_RATE_32000      (1 <<  6) /**< 32000Hz */
0028 #define SOF_RATE_44100      (1 <<  7) /**< 44100Hz */
0029 #define SOF_RATE_48000      (1 <<  8) /**< 48000Hz */
0030 #define SOF_RATE_64000      (1 <<  9) /**< 64000Hz */
0031 #define SOF_RATE_88200      (1 << 10) /**< 88200Hz */
0032 #define SOF_RATE_96000      (1 << 11) /**< 96000Hz */
0033 #define SOF_RATE_176400     (1 << 12) /**< 176400Hz */
0034 #define SOF_RATE_192000     (1 << 13) /**< 192000Hz */
0035 
0036 /* continuous and non-standard rates for flexibility */
0037 #define SOF_RATE_CONTINUOUS (1 << 30)  /**< range */
0038 #define SOF_RATE_KNOT       (1 << 31)  /**< non-continuous */
0039 
0040 /* generic PCM flags for runtime settings */
0041 #define SOF_PCM_FLAG_XRUN_STOP  (1 << 0) /**< Stop on any XRUN */
0042 
0043 /* stream PCM frame format */
0044 enum sof_ipc_frame {
0045     SOF_IPC_FRAME_S16_LE = 0,
0046     SOF_IPC_FRAME_S24_4LE,
0047     SOF_IPC_FRAME_S32_LE,
0048     SOF_IPC_FRAME_FLOAT,
0049     /* other formats here */
0050 };
0051 
0052 /* stream buffer format */
0053 enum sof_ipc_buffer_format {
0054     SOF_IPC_BUFFER_INTERLEAVED,
0055     SOF_IPC_BUFFER_NONINTERLEAVED,
0056     /* other formats here */
0057 };
0058 
0059 /* stream direction */
0060 enum sof_ipc_stream_direction {
0061     SOF_IPC_STREAM_PLAYBACK = 0,
0062     SOF_IPC_STREAM_CAPTURE,
0063 };
0064 
0065 /* stream ring info */
0066 struct sof_ipc_host_buffer {
0067     struct sof_ipc_hdr hdr;
0068     uint32_t phy_addr;
0069     uint32_t pages;
0070     uint32_t size;
0071     uint32_t reserved[3];
0072 } __packed;
0073 
0074 struct sof_ipc_stream_params {
0075     struct sof_ipc_hdr hdr;
0076     struct sof_ipc_host_buffer buffer;
0077     uint32_t direction; /**< enum sof_ipc_stream_direction */
0078     uint32_t frame_fmt; /**< enum sof_ipc_frame */
0079     uint32_t buffer_fmt;    /**< enum sof_ipc_buffer_format */
0080     uint32_t rate;
0081     uint16_t stream_tag;
0082     uint16_t channels;
0083     uint16_t sample_valid_bytes;
0084     uint16_t sample_container_bytes;
0085 
0086     uint32_t host_period_bytes;
0087     uint16_t no_stream_position; /**< 1 means don't send stream position */
0088     uint8_t cont_update_posn; /**< 1 means continuous update stream position */
0089     uint8_t reserved0;
0090     int16_t ext_data_length; /**< 0, means no extended data */
0091     uint8_t reserved[2];
0092     uint16_t chmap[SOF_IPC_MAX_CHANNELS];   /**< channel map - SOF_CHMAP_ */
0093     uint8_t ext_data[]; /**< extended data */
0094 } __packed;
0095 
0096 /* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */
0097 struct sof_ipc_pcm_params {
0098     struct sof_ipc_cmd_hdr hdr;
0099     uint32_t comp_id;
0100     uint32_t flags;     /**< generic PCM flags - SOF_PCM_FLAG_ */
0101     uint32_t reserved[2];
0102     struct sof_ipc_stream_params params;
0103 }  __packed;
0104 
0105 /* PCM params info reply - SOF_IPC_STREAM_PCM_PARAMS_REPLY */
0106 struct sof_ipc_pcm_params_reply {
0107     struct sof_ipc_reply rhdr;
0108     uint32_t comp_id;
0109     uint32_t posn_offset;
0110 } __packed;
0111 
0112 /* free stream - SOF_IPC_STREAM_PCM_PARAMS */
0113 struct sof_ipc_stream {
0114     struct sof_ipc_cmd_hdr hdr;
0115     uint32_t comp_id;
0116 } __packed;
0117 
0118 /* flags indicating which time stamps are in sync with each other */
0119 #define SOF_TIME_HOST_SYNC  (1 << 0)
0120 #define SOF_TIME_DAI_SYNC   (1 << 1)
0121 #define SOF_TIME_WALL_SYNC  (1 << 2)
0122 #define SOF_TIME_STAMP_SYNC (1 << 3)
0123 
0124 /* flags indicating which time stamps are valid */
0125 #define SOF_TIME_HOST_VALID (1 << 8)
0126 #define SOF_TIME_DAI_VALID  (1 << 9)
0127 #define SOF_TIME_WALL_VALID (1 << 10)
0128 #define SOF_TIME_STAMP_VALID    (1 << 11)
0129 
0130 /* flags indicating time stamps are 64bit else 3use low 32bit */
0131 #define SOF_TIME_HOST_64    (1 << 16)
0132 #define SOF_TIME_DAI_64     (1 << 17)
0133 #define SOF_TIME_WALL_64    (1 << 18)
0134 #define SOF_TIME_STAMP_64   (1 << 19)
0135 
0136 struct sof_ipc_stream_posn {
0137     struct sof_ipc_reply rhdr;
0138     uint32_t comp_id;   /**< host component ID */
0139     uint32_t flags;     /**< SOF_TIME_ */
0140     uint32_t wallclock_hz;  /**< frequency of wallclock in Hz */
0141     uint32_t timestamp_ns;  /**< resolution of timestamp in ns */
0142     uint64_t host_posn; /**< host DMA position in bytes */
0143     uint64_t dai_posn;  /**< DAI DMA position in bytes */
0144     uint64_t comp_posn; /**< comp position in bytes */
0145     uint64_t wallclock; /**< audio wall clock */
0146     uint64_t timestamp; /**< system time stamp */
0147     uint32_t xrun_comp_id;  /**< comp ID of XRUN component */
0148     int32_t xrun_size;  /**< XRUN size in bytes */
0149 }  __packed;
0150 
0151 #endif