control.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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_CONTROL_H__
  9. #define __INCLUDE_SOUND_SOF_CONTROL_H__
  10. #include <uapi/sound/sof/header.h>
  11. #include <sound/sof/header.h>
  12. /*
  13. * Component Mixers and Controls
  14. */
  15. /* channel positions - uses same values as ALSA */
  16. enum sof_ipc_chmap {
  17. SOF_CHMAP_UNKNOWN = 0,
  18. SOF_CHMAP_NA, /**< N/A, silent */
  19. SOF_CHMAP_MONO, /**< mono stream */
  20. SOF_CHMAP_FL, /**< front left */
  21. SOF_CHMAP_FR, /**< front right */
  22. SOF_CHMAP_RL, /**< rear left */
  23. SOF_CHMAP_RR, /**< rear right */
  24. SOF_CHMAP_FC, /**< front centre */
  25. SOF_CHMAP_LFE, /**< LFE */
  26. SOF_CHMAP_SL, /**< side left */
  27. SOF_CHMAP_SR, /**< side right */
  28. SOF_CHMAP_RC, /**< rear centre */
  29. SOF_CHMAP_FLC, /**< front left centre */
  30. SOF_CHMAP_FRC, /**< front right centre */
  31. SOF_CHMAP_RLC, /**< rear left centre */
  32. SOF_CHMAP_RRC, /**< rear right centre */
  33. SOF_CHMAP_FLW, /**< front left wide */
  34. SOF_CHMAP_FRW, /**< front right wide */
  35. SOF_CHMAP_FLH, /**< front left high */
  36. SOF_CHMAP_FCH, /**< front centre high */
  37. SOF_CHMAP_FRH, /**< front right high */
  38. SOF_CHMAP_TC, /**< top centre */
  39. SOF_CHMAP_TFL, /**< top front left */
  40. SOF_CHMAP_TFR, /**< top front right */
  41. SOF_CHMAP_TFC, /**< top front centre */
  42. SOF_CHMAP_TRL, /**< top rear left */
  43. SOF_CHMAP_TRR, /**< top rear right */
  44. SOF_CHMAP_TRC, /**< top rear centre */
  45. SOF_CHMAP_TFLC, /**< top front left centre */
  46. SOF_CHMAP_TFRC, /**< top front right centre */
  47. SOF_CHMAP_TSL, /**< top side left */
  48. SOF_CHMAP_TSR, /**< top side right */
  49. SOF_CHMAP_LLFE, /**< left LFE */
  50. SOF_CHMAP_RLFE, /**< right LFE */
  51. SOF_CHMAP_BC, /**< bottom centre */
  52. SOF_CHMAP_BLC, /**< bottom left centre */
  53. SOF_CHMAP_BRC, /**< bottom right centre */
  54. SOF_CHMAP_LAST = SOF_CHMAP_BRC,
  55. };
  56. /* control data type and direction */
  57. enum sof_ipc_ctrl_type {
  58. /* per channel data - uses struct sof_ipc_ctrl_value_chan */
  59. SOF_CTRL_TYPE_VALUE_CHAN_GET = 0,
  60. SOF_CTRL_TYPE_VALUE_CHAN_SET,
  61. /* component data - uses struct sof_ipc_ctrl_value_comp */
  62. SOF_CTRL_TYPE_VALUE_COMP_GET,
  63. SOF_CTRL_TYPE_VALUE_COMP_SET,
  64. /* bespoke data - uses struct sof_abi_hdr */
  65. SOF_CTRL_TYPE_DATA_GET,
  66. SOF_CTRL_TYPE_DATA_SET,
  67. };
  68. /* control command type */
  69. enum sof_ipc_ctrl_cmd {
  70. SOF_CTRL_CMD_VOLUME = 0, /**< maps to ALSA volume style controls */
  71. SOF_CTRL_CMD_ENUM, /**< maps to ALSA enum style controls */
  72. SOF_CTRL_CMD_SWITCH, /**< maps to ALSA switch style controls */
  73. SOF_CTRL_CMD_BINARY, /**< maps to ALSA binary style controls */
  74. };
  75. /* generic channel mapped value data */
  76. struct sof_ipc_ctrl_value_chan {
  77. uint32_t channel; /**< channel map - enum sof_ipc_chmap */
  78. uint32_t value;
  79. } __packed;
  80. /* generic component mapped value data */
  81. struct sof_ipc_ctrl_value_comp {
  82. uint32_t index; /**< component source/sink/control index in control */
  83. union {
  84. uint32_t uvalue;
  85. int32_t svalue;
  86. };
  87. } __packed;
  88. /* generic control data */
  89. struct sof_ipc_ctrl_data {
  90. struct sof_ipc_reply rhdr;
  91. uint32_t comp_id;
  92. /* control access and data type */
  93. uint32_t type; /**< enum sof_ipc_ctrl_type */
  94. uint32_t cmd; /**< enum sof_ipc_ctrl_cmd */
  95. uint32_t index; /**< control index for comps > 1 control */
  96. /* control data - can either be appended or DMAed from host */
  97. struct sof_ipc_host_buffer buffer;
  98. uint32_t num_elems; /**< in array elems or bytes for data type */
  99. uint32_t elems_remaining; /**< elems remaining if sent in parts */
  100. uint32_t msg_index; /**< for large messages sent in parts */
  101. /* reserved for future use */
  102. uint32_t reserved[6];
  103. /* control data - add new types if needed */
  104. union {
  105. /* channel values can be used by volume type controls */
  106. DECLARE_FLEX_ARRAY(struct sof_ipc_ctrl_value_chan, chanv);
  107. /* component values used by routing controls like mux, mixer */
  108. DECLARE_FLEX_ARRAY(struct sof_ipc_ctrl_value_comp, compv);
  109. /* data can be used by binary controls */
  110. DECLARE_FLEX_ARRAY(struct sof_abi_hdr, data);
  111. };
  112. } __packed;
  113. /** Event type */
  114. enum sof_ipc_ctrl_event_type {
  115. SOF_CTRL_EVENT_GENERIC = 0, /**< generic event */
  116. SOF_CTRL_EVENT_GENERIC_METADATA, /**< generic event with metadata */
  117. SOF_CTRL_EVENT_KD, /**< keyword detection event */
  118. SOF_CTRL_EVENT_VAD, /**< voice activity detection event */
  119. };
  120. /**
  121. * Generic notification data.
  122. */
  123. struct sof_ipc_comp_event {
  124. struct sof_ipc_reply rhdr;
  125. uint16_t src_comp_type; /**< COMP_TYPE_ */
  126. uint32_t src_comp_id; /**< source component id */
  127. uint32_t event_type; /**< event type - SOF_CTRL_EVENT_* */
  128. uint32_t num_elems; /**< in array elems or bytes for data type */
  129. /* reserved for future use */
  130. uint32_t reserved[8];
  131. /* control data - add new types if needed */
  132. union {
  133. /* data can be used by binary controls */
  134. struct sof_abi_hdr data[0];
  135. /* event specific values */
  136. uint32_t event_value;
  137. };
  138. } __packed;
  139. #endif