es515.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*
  2. * es515.h -- ES515 Soc Audio driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef _ES515_H
  9. #define _ES515_H
  10. #include <linux/cdev.h>
  11. #include <linux/mutex.h>
  12. #include <sound/soc.h>
  13. #include <linux/time.h>
  14. #include "escore.h"
  15. /* TODO: condition of kernel version or commit code to specific kernels */
  16. #define ES_DAI_ID_BASE 1
  17. #define ES_SYNC_CMD 0x8000
  18. #define ES_SYNC_POLLING 0x0000
  19. #define ES_SYNC_ACK 0x80000000
  20. #define ES_RESET_CMD 0x8002
  21. #define ES_RESET_IMMED 0x0000
  22. #define ES_RESET_DELAYED 0x0001
  23. #define ES_GET_POWER_STATE 0x800f
  24. #define ES_SET_POWER_STATE 0x9010
  25. #define ES_SET_POWER_STATE_SLEEP 0x0001
  26. #define ES_SET_POWER_STATE_MP_SLEEP 0x0002
  27. #define ES_SET_POWER_STATE_MP_CMD 0x0003
  28. #define ES_SET_POWER_STATE_NORMAL 0x0004
  29. #define ES_STAGED_MSG_BIT (1 << 13)
  30. /*
  31. * Device parameter command codes
  32. */
  33. #define ES_DEV_PARAM_OFFSET 0x2000
  34. #define ES_GET_DEV_PARAM 0x800b
  35. #define ES_SET_DEV_PARAM_ID 0x900c
  36. #define ES_SET_DEV_PARAM 0x900d
  37. /*
  38. * Algoithm parameter command codes
  39. */
  40. #define ES_ALGO_PARAM_OFFSET 0x0000
  41. #define ES_GET_ALGO_PARAM 0x8016
  42. #define ES_SET_ALGO_PARAM_ID 0x9017
  43. #define ES_SET_ALGO_PARAM 0x9018
  44. /*digital gain commands codes */
  45. #define ES_SET_DIGITAL_GAIN 0x9015
  46. #define ES_GET_DIGITAL_GAIN 0x801d
  47. /*port timings codes */
  48. #define ES_SET_PORT_TIMING 0xb058
  49. #define ES_GET_PORT_TIMING 0x8059
  50. /* Mux setting codes */
  51. #define ES_SET_MUX_CMD 0xb05a
  52. #define ES_GET_MUX_CMD 0x805b
  53. /*
  54. * Audio sample rates and formats
  55. */
  56. #define ES_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
  57. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
  58. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  59. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  60. #define ES_SLIMBUS_RATES (SNDRV_PCM_RATE_48000)
  61. #define ES_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |\
  62. SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE |\
  63. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |\
  64. SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE)
  65. #define ES_SLIMBUS_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
  66. SNDRV_PCM_FMTBIT_S16_BE)
  67. /*
  68. * addresses
  69. * Ensure digital addresses do not overlap with analog
  70. */
  71. enum {
  72. ES_MIC_CONFIG = 0x100,
  73. ES_AEC_MODE,
  74. ES_TX_AGC,
  75. ES_TX_AGC_TARGET_LEVEL,
  76. ES_TX_AGC_NOISE_FLOOR,
  77. ES_TX_AGC_SNR_IMPROVEMENT,
  78. ES_VEQ_ENABLE,
  79. ES_RX_OUT_LIMITER_MAX_LEVEL,
  80. ES_RX_NOISE_SUPPRESS,
  81. ES_RX_STS,
  82. ES_RX_STS_RATE,
  83. ES_AEC_SPEAKER_VOLUME,
  84. ES_SIDETONE,
  85. ES_SIDETONE_GAIN,
  86. ES_TX_COMFORT_NOISE,
  87. ES_TX_COMFORT_NOISE_LEVEL,
  88. ES_ALGORITHM_RESET,
  89. ES_RX_POST_EQ,
  90. ES_TX_POST_EQ,
  91. ES_AEC_CNG,
  92. ES_VEQ_NOISE_ESTIMATION_ADJUSTMENT,
  93. ES_TX_AGC_SLEW_RATE_UP,
  94. ES_TX_AGC_SLEW_RATE_DOWN,
  95. ES_RX_AGC,
  96. ES_RX_AGC_TARGET_LEVEL,
  97. ES_RX_AGC_NOISE_FLOOR,
  98. ES_RX_AGC_SNR_IMPROVEMENT,
  99. ES_RX_AGC_SLEW_RATE_UP,
  100. ES_RX_AGC_SLEW_RATE_DOWN,
  101. ES_AEC_CNG_GAIN,
  102. ES_TX_MBC,
  103. ES_RX_MBC,
  104. ES_AEC_ESE,
  105. ES_TX_NS_ADAPTATION_SPEED,
  106. ES_TX_SNR_ESTIMATE,
  107. ES_VEQ_MAX_GAIN,
  108. ES_TX_AGC_GUARDBAND,
  109. ES_RX_AGC_GUARDBAND,
  110. ES_TX_OUT_LIMITER_MAX_LEVEL,
  111. ES_TX_IN_LIMITER_MAX_LEVEL,
  112. ES_RX_NS_ADAPTATION_SPEED,
  113. ES_AEC_VARIABLE_ECHO_REF_DELAY,
  114. ES_TX_NOISE_SUPPRESS_LEVEL,
  115. ES_RX_NOISE_SUPPRESS_LEVEL,
  116. ES_RX_CNG,
  117. ES_RX_CNG_GAIN,
  118. ES_TX_AGC_MAX_GAIN,
  119. ES_RX_AGC_MAX_GAIN,
  120. ES_TONE_PARAM_API_VERSION_LO,
  121. ES_TONE_PARAM_API_VERSION_HI,
  122. ES_TONE_PARAM_ENABLE_BEEP_SYS,
  123. ES_TONE_PARAM_ENABLE_GEN_BEEP,
  124. ES_TONE_PARAM_GEN_BEEP_ON,
  125. ES_TONE_PARAM_GEN_BEEP_FREQ1,
  126. ES_TONE_PARAM_GEN_BEEP_FREQ2,
  127. ES_TONE_PARAM_GEN_BEEP_PAN_LR,
  128. ES_TONE_PARAM_GEN_BEEP_GAIN,
  129. ES_DEREVERB_ENABLE,
  130. ES_DEREVERB_GAIN,
  131. ES_BWE_ENABLE,
  132. ES_BWE_HIGH_BAND_GAIN,
  133. ES_BWE_MAX_SNR,
  134. ES_BWE_POST_EQ_ENABLE,
  135. ES_PORTA_WORD_LEN,
  136. ES_PORTA_TDM_SLOTS_PER_FRAME,
  137. ES_PORTA_TX_DELAY_FROM_FS,
  138. ES_PORTA_RX_DELAY_FROM_FS,
  139. ES_PORTA_LATCH_EDGE,
  140. ES_PORTA_ENDIAN,
  141. ES_PORTA_TRISTATE,
  142. ES_PORTA_AUDIO_PORT_MODE,
  143. ES_PORTA_TDM_ENABLED,
  144. ES_PORTA_CLOCK_CONTROL,
  145. ES_PORTA_DATA_JUSTIFICATION,
  146. ES_PORTA_FS_DURATION,
  147. ES_PORTB_WORD_LEN,
  148. ES_PORTB_TDM_SLOTS_PER_FRAME,
  149. ES_PORTB_TX_DELAY_FROM_FS,
  150. ES_PORTB_RX_DELAY_FROM_FS,
  151. ES_PORTB_LATCH_EDGE,
  152. ES_PORTB_ENDIAN,
  153. ES_PORTB_TRISTATE,
  154. ES_PORTB_AUDIO_PORT_MODE,
  155. ES_PORTB_TDM_ENABLED,
  156. ES_PORTB_CLOCK_CONTROL,
  157. ES_PORTB_DATA_JUSTIFICATION,
  158. ES_PORTB_FS_DURATION,
  159. ES_PORTC_WORD_LEN,
  160. ES_PORTC_TDM_SLOTS_PER_FRAME,
  161. ES_PORTC_TX_DELAY_FROM_FS,
  162. ES_PORTC_RX_DELAY_FROM_FS,
  163. ES_PORTC_LATCH_EDGE,
  164. ES_PORTC_ENDIAN,
  165. ES_PORTC_TRISTATE,
  166. ES_PORTC_AUDIO_PORT_MODE,
  167. ES_PORTC_TDM_ENABLED,
  168. ES_PORTC_CLOCK_CONTROL,
  169. ES_PORTC_DATA_JUSTIFICATION,
  170. ES_PORTC_FS_DURATION,
  171. ES_PORTD_WORD_LEN,
  172. ES_PORTD_TDM_SLOTS_PER_FRAME,
  173. ES_PORTD_TX_DELAY_FROM_FS,
  174. ES_PORTD_RX_DELAY_FROM_FS,
  175. ES_PORTD_LATCH_EDGE,
  176. ES_PORTD_ENDIAN,
  177. ES_PORTD_TRISTATE,
  178. ES_PORTD_AUDIO_PORT_MODE,
  179. ES_PORTD_TDM_ENABLED,
  180. ES_PORTD_CLOCK_CONTROL,
  181. ES_PORTD_DATA_JUSTIFICATION,
  182. ES_PORTD_FS_DURATION,
  183. ES_SLIMBUS_LINK_MULTI_CHANNEL,
  184. ES_POWER_STATE,
  185. ES_STREAMING,
  186. ES_FE_STREAMING,
  187. ES_PRESET,
  188. ES_ALGO_STATS,
  189. ES_ALGO_PROCESSING,
  190. ES_ALGO_SAMPLE_RATE,
  191. ES_SMOOTH_RATE,
  192. ES_CHANGE_STATUS,
  193. ES_DIGITAL_PASS_THROUGH,
  194. ES_DATA_PATH,
  195. ES_ALGORITHM,
  196. ES_MIX_SAMPLE_RATE,
  197. ES_SIGNAL_RMS_PORTA_DIN_LEFT,
  198. ES_SIGNAL_RMS_PORTA_DIN_RIGHT,
  199. ES_SIGNAL_RMS_PORTA_DOUT_LEFT,
  200. ES_SIGNAL_RMS_PORTA_DOUT_RIGHT,
  201. ES_SIGNAL_RMS_PORTB_DIN_LEFT,
  202. ES_SIGNAL_RMS_PORTB_DIN_RIGHT,
  203. ES_SIGNAL_RMS_PORTB_DOUT_LEFT,
  204. ES_SIGNAL_RMS_PORTB_DOUT_RIGHT,
  205. ES_SIGNAL_RMS_PORTC_DIN_LEFT,
  206. ES_SIGNAL_RMS_PORTC_DIN_RIGHT,
  207. ES_SIGNAL_RMS_PORTC_DOUT_LEFT,
  208. ES_SIGNAL_RMS_PORTC_DOUT_RIGHT,
  209. ES_SIGNAL_RMS_PORTD_DIN_LEFT,
  210. ES_SIGNAL_RMS_PORTD_DIN_RIGHT,
  211. ES_SIGNAL_RMS_PORTD_DOUT_LEFT,
  212. ES_SIGNAL_RMS_PORTD_DOUT_RIGHT,
  213. ES_SIGNAL_PEAK_PORTA_DIN_LEFT,
  214. ES_SIGNAL_PEAK_PORTA_DIN_RIGHT,
  215. ES_SIGNAL_PEAK_PORTA_DOUT_LEFT,
  216. ES_SIGNAL_PEAK_PORTA_DOUT_RIGHT,
  217. ES_SIGNAL_PEAK_PORTB_DIN_LEFT,
  218. ES_SIGNAL_PEAK_PORTB_DIN_RIGHT,
  219. ES_SIGNAL_PEAK_PORTB_DOUT_LEFT,
  220. ES_SIGNAL_PEAK_PORTB_DOUT_RIGHT,
  221. ES_SIGNAL_PEAK_PORTC_DIN_LEFT,
  222. ES_SIGNAL_PEAK_PORTC_DIN_RIGHT,
  223. ES_SIGNAL_PEAK_PORTC_DOUT_LEFT,
  224. ES_SIGNAL_PEAK_PORTC_DOUT_RIGHT,
  225. ES_SIGNAL_PEAK_PORTD_DIN_LEFT,
  226. ES_SIGNAL_PEAK_PORTD_DIN_RIGHT,
  227. ES_SIGNAL_PEAK_PORTD_DOUT_LEFT,
  228. ES_SIGNAL_PEAK_PORTD_DOUT_RIGHT,
  229. ES_DIGITAL_GAIN_PRIMARY,
  230. ES_DIGITAL_GAIN_SECONDARY,
  231. ES_DIGITAL_GAIN_TERTIARY,
  232. ES_DIGITAL_GAIN_QUAD,
  233. ES_DIGITAL_GAIN_FEIN,
  234. ES_DIGITAL_GAIN_AUDIN1,
  235. ES_DIGITAL_GAIN_AUDIN2,
  236. ES_DIGITAL_GAIN_AUDIN3,
  237. ES_DIGITAL_GAIN_AUDIN4,
  238. ES_DIGITAL_GAIN_UITONE1,
  239. ES_DIGITAL_GAIN_UITONE2,
  240. ES_AECREF1_GAIN,
  241. ES_DIGITAL_GAIN_CSOUT,
  242. ES_DIGITAL_GAIN_FEOUT1,
  243. ES_DIGITAL_GAIN_FEOUT2,
  244. ES_DIGITAL_GAIN_AUDOUT1,
  245. ES_DIGITAL_GAIN_AUDOUT2,
  246. ES_DIGITAL_GAIN_AUDOUT3,
  247. ES_DIGITAL_GAIN_AUDOUT4,
  248. ES_PORTA_TIMING,
  249. ES_PORTB_TIMING,
  250. ES_PORTC_TIMING,
  251. ES_PORTD_TIMING,
  252. ES_FLUSH,
  253. ES_FW_FIRST_CHAR,
  254. ES_FW_NEXT_CHAR,
  255. ES_SET_CODEC_ADDR,
  256. ES_CODEC_VALUE,
  257. ES_EVENT_RESPONSE,
  258. ES_VOICE_SENSE_ENABLE,
  259. ES_VOICE_SENSE_SET_KEYWORD,
  260. ES_VOICE_SENSE_EVENT,
  261. ES_VOICE_SENSE_TRAINING_MODE,
  262. ES_VOICE_SENSE_TRAINING_RECORD,
  263. ES_VOICE_SENSE_TRAINING_STATUS,
  264. ES_VOICE_SENSE_DEMO_ENABLE,
  265. ES_VS_STORED_KEYWORD,
  266. ES_GET_SYS_INTERRUPT_STATUS,
  267. ES_CLEAR_SYS_INTERRUPT_STATUS,
  268. ES_ACCESSORY_DET_CONFIG,
  269. ES_ACCESSORY_DET_STATUS,
  270. ES_BUTTON_DETECTION_ENABLE,
  271. ES_BUTTON_SERIAL_CONFIG,
  272. ES_BUTTON_PARALLEL_CONFIG,
  273. ES_BUTTON_DETECTION_RATE,
  274. ES_BUTTON_PRESS_SETTLING_TIME,
  275. ES_BUTTON_BOUNCE_TIME,
  276. ES_BUTTON_DETECTION_LONG_PRESS_TIME,
  277. ES_PRIMARY_MUX,
  278. ES_SECONDARY_MUX,
  279. ES_TERITARY_MUX,
  280. ES_AECREF1_MUX,
  281. ES_FEIN_MUX,
  282. ES_UITONE1_MUX,
  283. ES_UITONE2_MUX,
  284. ES_AUDIN1_MUX,
  285. ES_AUDIN2_MUX,
  286. ES_AUDIN3_MUX,
  287. ES_AUDIN4_MUX,
  288. ES_PCM0_0_MUX,
  289. ES_PCM0_1_MUX,
  290. ES_PCM0_2_MUX,
  291. ES_PCM0_3_MUX,
  292. ES_PCM1_0_MUX,
  293. ES_PCM1_1_MUX,
  294. ES_PCM1_2_MUX,
  295. ES_PCM1_3_MUX,
  296. ES_PCM2_0_MUX,
  297. ES_PCM2_1_MUX,
  298. ES_PCM2_2_MUX,
  299. ES_PCM2_3_MUX,
  300. ES_SBUSTX0_MUX,
  301. ES_SBUSTX1_MUX,
  302. ES_SBUSTX2_MUX,
  303. ES_SBUSTX3_MUX,
  304. ES_SBUSTX4_MUX,
  305. ES_SBUSTX5_MUX,
  306. ES_DAC0_0_MUX,
  307. ES_DAC0_1_MUX,
  308. ES_DAC1_0_MUX,
  309. ES_DAC1_1_MUX,
  310. ES_API_ADDR_MAX,
  311. };
  312. #define ES_SLIM_1_PB_MAX_CHANS 2
  313. #define ES_SLIM_1_CAP_MAX_CHANS 2
  314. #define ES_SLIM_2_PB_MAX_CHANS 2
  315. #define ES_SLIM_2_CAP_MAX_CHANS 2
  316. #define ES_SLIM_3_PB_MAX_CHANS 2
  317. #define ES_SLIM_3_CAP_MAX_CHANS 2
  318. #define ES_SLIM_1_PB_OFFSET 0
  319. #define ES_SLIM_2_PB_OFFSET 2
  320. #define ES_SLIM_3_PB_OFFSET 4
  321. #define ES_SLIM_1_CAP_OFFSET 0
  322. #define ES_SLIM_2_CAP_OFFSET 2
  323. #define ES_SLIM_3_CAP_OFFSET 4
  324. #define ES_SLIM_CH_RX_OFFSET 152
  325. #define ES_SLIM_CH_TX_OFFSET 156
  326. /* #define ES_SLIM_RX_PORTS 10 */
  327. #define ES_SLIM_RX_PORTS 6
  328. #define ES_SLIM_TX_PORTS 6
  329. #define ES_I2S_PORTA 7
  330. #define ES_I2S_PORTB 8
  331. #define ES_I2S_PORTC 9
  332. #define ES_I2S_PORTD 10
  333. #if defined(CONFIG_SND_SOC_ES_SLIM)
  334. #define ES_NUM_CODEC_SLIM_DAIS 6
  335. #define ES_NUM_CODEC_I2S_DAIS 0
  336. #else
  337. #define ES_NUM_CODEC_SLIM_DAIS 0
  338. #define ES_NUM_CODEC_I2S_DAIS 4
  339. #endif
  340. #define ES_NUM_CODEC_DAIS (ES_NUM_CODEC_SLIM_DAIS + \
  341. ES_NUM_CODEC_I2S_DAIS)
  342. enum {
  343. ES_SLIM_1_PB = ES_DAI_ID_BASE,
  344. ES_SLIM_1_CAP,
  345. ES_SLIM_2_PB,
  346. ES_SLIM_2_CAP,
  347. ES_SLIM_3_PB,
  348. ES_SLIM_3_CAP,
  349. };
  350. enum {
  351. ES_PM_ACTIVE,
  352. ES_PM_SUSPENDING,
  353. ES_PM_SUSPENDED,
  354. };
  355. /* Maximum size of keyword parameter block in bytes. */
  356. #define ES_VS_KEYWORD_PARAM_MAX 512
  357. /* Base name used by character devices. */
  358. #define ES_CDEV_NAME "adnc"
  359. extern struct snd_soc_codec_driver soc_codec_dev_es515;
  360. extern struct snd_soc_dai_driver es515_dai[];
  361. extern int es515_core_probe(struct device *dev);
  362. extern int es515_bootup(struct escore_priv *es515);
  363. #define es515_resp(obj) ((obj)->last_response)
  364. int es515_cmd(struct escore_priv *es515, u32 cmd);
  365. int es515_bus_init(struct escore_priv *es515);
  366. int es515_boot_finish(struct escore_priv *es515);
  367. int es515_set_streaming(struct escore_priv *escore, int value);
  368. #endif /* _ES_H */