q6usm.h 4.0 KB

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