q6usm.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2011-2014, 2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __Q6_USM_H__
  6. #define __Q6_USM_H__
  7. #include <ipc/apr_us.h>
  8. #define Q6USM_EVENT_UNDEF 0
  9. #define Q6USM_EVENT_READ_DONE 1
  10. #define Q6USM_EVENT_WRITE_DONE 2
  11. #define Q6USM_EVENT_SIGNAL_DETECT_RESULT 3
  12. /* cyclic buffer with 1 gap support */
  13. #define USM_MIN_BUF_CNT 3
  14. #define FORMAT_USPS_EPOS 0x00000000
  15. #define FORMAT_USRAW 0x00000001
  16. #define FORMAT_USPROX 0x00000002
  17. #define FORMAT_USGES_SYNC 0x00000003
  18. #define FORMAT_USRAW_SYNC 0x00000004
  19. #define INVALID_FORMAT 0xffffffff
  20. #define IN 0x000
  21. #define OUT 0x001
  22. #define USM_WRONG_TOKEN 0xffffffff
  23. #define USM_UNDEF_TOKEN 0xfffffffe
  24. #define CMD_CLOSE 0x0004
  25. /* bit 0:1 represents priority of stream */
  26. #define STREAM_PRIORITY_NORMAL 0x0000
  27. #define STREAM_PRIORITY_LOW 0x0001
  28. #define STREAM_PRIORITY_HIGH 0x0002
  29. /* bit 4 represents META enable of encoded data buffer */
  30. #define BUFFER_META_ENABLE 0x0010
  31. struct us_port_data {
  32. dma_addr_t phys;
  33. /* cyclic region of buffers with 1 gap */
  34. void *data;
  35. /* number of buffers in the region */
  36. uint32_t buf_cnt;
  37. /* size of buffer */
  38. size_t buf_size;
  39. /* write index */
  40. uint32_t dsp_buf;
  41. /* read index */
  42. uint32_t cpu_buf;
  43. /* expected token from dsp */
  44. uint32_t expected_token;
  45. /* read or write locks */
  46. struct mutex lock;
  47. spinlock_t dsp_lock;
  48. /* ION dma_buf memory */
  49. struct dma_buf *dma_buf;
  50. /* extended parameters, related to q6 variants */
  51. void *ext;
  52. /* physical address of parameter buffer */
  53. dma_addr_t param_phys;
  54. /* buffer which stores the parameter data */
  55. void *param_buf;
  56. /* size of parameter buffer */
  57. uint32_t param_buf_size;
  58. /* parameter buffer memory handle */
  59. void *param_buf_mem_handle;
  60. /* ION dma_buf memory for parameter buffer */
  61. struct dma_buf *param_dma_buf;
  62. };
  63. struct us_client {
  64. int session;
  65. /* idx:1 out port, 0: in port*/
  66. struct us_port_data port[2];
  67. struct apr_svc *apr;
  68. struct mutex cmd_lock;
  69. atomic_t cmd_state;
  70. atomic_t eos_state;
  71. wait_queue_head_t cmd_wait;
  72. void (*cb)(uint32_t, uint32_t, uint32_t *, void *);
  73. void *priv;
  74. };
  75. int q6usm_run(struct us_client *usc, uint32_t flags,
  76. uint32_t msw_ts, uint32_t lsw_ts);
  77. int q6usm_cmd(struct us_client *usc, int cmd);
  78. int q6usm_us_client_buf_alloc(unsigned int dir, struct us_client *usc,
  79. unsigned int bufsz, unsigned int bufcnt);
  80. int q6usm_us_param_buf_alloc(unsigned int dir, struct us_client *usc,
  81. unsigned int bufsz);
  82. int q6usm_enc_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
  83. int q6usm_dec_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
  84. int q6usm_read(struct us_client *usc, uint32_t read_ind);
  85. struct us_client *q6usm_us_client_alloc(
  86. void (*cb)(uint32_t, uint32_t, uint32_t *, void *),
  87. void *priv);
  88. int q6usm_open_read(struct us_client *usc, uint32_t format);
  89. void q6usm_us_client_free(struct us_client *usc);
  90. uint32_t q6usm_get_virtual_address(int dir, struct us_client *usc,
  91. struct vm_area_struct *vms);
  92. int q6usm_open_write(struct us_client *usc, uint32_t format);
  93. int q6usm_write(struct us_client *usc, uint32_t write_ind);
  94. bool q6usm_is_write_buf_full(struct us_client *usc, uint32_t *free_region);
  95. int q6usm_set_us_detection(struct us_client *usc,
  96. struct usm_session_cmd_detect_info *detect_info,
  97. uint16_t detect_info_size);
  98. int q6usm_set_us_stream_param(int dir, struct us_client *usc,
  99. uint32_t module_id, uint32_t param_id, uint32_t buf_size);
  100. int q6usm_get_us_stream_param(int dir, struct us_client *usc,
  101. uint32_t module_id, uint32_t param_id, uint32_t buf_size);
  102. int q6usm_init(void);
  103. #endif /* __Q6_USM_H__ */