apr_tal.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (c) 2010-2011, 2016-2017 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 __APR_TAL_H_
  14. #define __APR_TAL_H_
  15. #include <linux/kernel.h>
  16. #include <linux/kthread.h>
  17. #include <linux/uaccess.h>
  18. /* APR Client IDs */
  19. #define APR_CLIENT_AUDIO 0x0
  20. #define APR_CLIENT_VOICE 0x1
  21. #define APR_CLIENT_MAX 0x2
  22. #define APR_DL_SMD 0
  23. #define APR_DL_MAX 1
  24. #define APR_DEST_MODEM 0
  25. #define APR_DEST_QDSP6 1
  26. #define APR_DEST_MAX 2
  27. #if defined(CONFIG_MSM_QDSP6_APRV2_GLINK) || \
  28. defined(CONFIG_MSM_QDSP6_APRV3_GLINK)
  29. #define APR_MAX_BUF 512
  30. #else
  31. #define APR_MAX_BUF 8092
  32. #endif
  33. #define APR_DEFAULT_NUM_OF_INTENTS 20
  34. #define APR_OPEN_TIMEOUT_MS 5000
  35. enum {
  36. /* If client sets the pkt_owner to APR_PKT_OWNER_DRIVER, APR
  37. * driver will allocate a buffer, where the user packet is
  38. * copied into, for each and every single Tx transmission.
  39. * The buffer is thereafter passed to underlying link layer
  40. * and freed upon the notification received from the link layer
  41. * that the packet has been consumed.
  42. */
  43. APR_PKT_OWNER_DRIVER,
  44. /* If client sets the pkt_owner to APR_PKT_OWNER_CLIENT, APR
  45. * will pass the user packet memory address directly to underlying
  46. * link layer. In this case it is the client's responsibility to
  47. * make sure the packet is intact until being notified that the
  48. * packet has been consumed.
  49. */
  50. APR_PKT_OWNER_CLIENT,
  51. };
  52. struct apr_pkt_priv {
  53. /* This property is only applicable for APR over Glink.
  54. * It is ignored in APR over SMD cases.
  55. */
  56. uint8_t pkt_owner;
  57. };
  58. typedef void (*apr_svc_cb_fn)(void *buf, int len, void *priv);
  59. struct apr_svc_ch_dev *apr_tal_open(uint32_t svc, uint32_t dest,
  60. uint32_t dl, apr_svc_cb_fn func, void *priv);
  61. int apr_tal_write(struct apr_svc_ch_dev *apr_ch, void *data,
  62. struct apr_pkt_priv *pkt_priv, int len);
  63. int apr_tal_close(struct apr_svc_ch_dev *apr_ch);
  64. int apr_tal_rx_intents_config(struct apr_svc_ch_dev *apr_ch,
  65. int num_of_intents, uint32_t size);
  66. int apr_tal_init(void);
  67. int apr_tal_start_rx_rt(struct apr_svc_ch_dev *apr_ch);
  68. int apr_tal_end_rx_rt(struct apr_svc_ch_dev *apr_ch);
  69. struct apr_svc_ch_dev {
  70. void *handle;
  71. spinlock_t w_lock;
  72. spinlock_t r_lock;
  73. struct mutex m_lock;
  74. apr_svc_cb_fn func;
  75. wait_queue_head_t wait;
  76. void *priv;
  77. unsigned int channel_state;
  78. bool if_remote_intent_ready;
  79. };
  80. #endif