q6usm.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Copyright (c) 2011-2014, 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 memory handle */
  57. struct ion_handle *handle;
  58. /* ION memory client */
  59. struct ion_client *client;
  60. /* extended parameters, related to q6 variants */
  61. void *ext;
  62. /* physical address of parameter buffer */
  63. dma_addr_t param_phys;
  64. /* buffer which stores the parameter data */
  65. void *param_buf;
  66. /* size of parameter buffer */
  67. uint32_t param_buf_size;
  68. /* parameter buffer memory handle */
  69. void *param_buf_mem_handle;
  70. /* ION memory handle for parameter buffer */
  71. struct ion_handle *param_handle;
  72. /* ION memory client for parameter buffer */
  73. struct ion_client *param_client;
  74. };
  75. struct us_client {
  76. int session;
  77. /* idx:1 out port, 0: in port*/
  78. struct us_port_data port[2];
  79. struct apr_svc *apr;
  80. struct mutex cmd_lock;
  81. atomic_t cmd_state;
  82. atomic_t eos_state;
  83. wait_queue_head_t cmd_wait;
  84. void (*cb)(uint32_t, uint32_t, uint32_t *, void *);
  85. void *priv;
  86. };
  87. int q6usm_run(struct us_client *usc, uint32_t flags,
  88. uint32_t msw_ts, uint32_t lsw_ts);
  89. int q6usm_cmd(struct us_client *usc, int cmd);
  90. int q6usm_us_client_buf_alloc(unsigned int dir, struct us_client *usc,
  91. unsigned int bufsz, unsigned int bufcnt);
  92. int q6usm_us_param_buf_alloc(unsigned int dir, struct us_client *usc,
  93. unsigned int bufsz);
  94. int q6usm_enc_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
  95. int q6usm_dec_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
  96. int q6usm_read(struct us_client *usc, uint32_t read_ind);
  97. struct us_client *q6usm_us_client_alloc(
  98. void (*cb)(uint32_t, uint32_t, uint32_t *, void *),
  99. void *priv);
  100. int q6usm_open_read(struct us_client *usc, uint32_t format);
  101. void q6usm_us_client_free(struct us_client *usc);
  102. uint32_t q6usm_get_virtual_address(int dir, struct us_client *usc,
  103. struct vm_area_struct *vms);
  104. int q6usm_open_write(struct us_client *usc, uint32_t format);
  105. int q6usm_write(struct us_client *usc, uint32_t write_ind);
  106. bool q6usm_is_write_buf_full(struct us_client *usc, uint32_t *free_region);
  107. int q6usm_set_us_detection(struct us_client *usc,
  108. struct usm_session_cmd_detect_info *detect_info,
  109. uint16_t detect_info_size);
  110. int q6usm_set_us_stream_param(int dir, struct us_client *usc,
  111. uint32_t module_id, uint32_t param_id, uint32_t buf_size);
  112. int q6usm_get_us_stream_param(int dir, struct us_client *usc,
  113. uint32_t module_id, uint32_t param_id, uint32_t buf_size);
  114. int q6usm_init(void);
  115. #endif /* __Q6_USM_H__ */