stream.h 4.6 KB

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