cs-protocol.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * cmt-speech interface definitions
  3. *
  4. * Copyright (C) 2008,2009,2010 Nokia Corporation. All rights reserved.
  5. *
  6. * Contact: Kai Vehmanen <kai.vehmanen@nokia.com>
  7. * Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. */
  23. #ifndef _CS_PROTOCOL_H
  24. #define _CS_PROTOCOL_H
  25. #include <linux/types.h>
  26. #include <linux/ioctl.h>
  27. /* chardev parameters */
  28. #define CS_DEV_FILE_NAME "/dev/cmt_speech"
  29. /* user-space API versioning */
  30. #define CS_IF_VERSION 2
  31. /* APE kernel <-> user space messages */
  32. #define CS_CMD_SHIFT 28
  33. #define CS_DOMAIN_SHIFT 24
  34. #define CS_CMD_MASK 0xff000000
  35. #define CS_PARAM_MASK 0xffffff
  36. #define CS_CMD(id, dom) \
  37. (((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
  38. #define CS_ERROR CS_CMD(1, 0)
  39. #define CS_RX_DATA_RECEIVED CS_CMD(2, 0)
  40. #define CS_TX_DATA_READY CS_CMD(3, 0)
  41. #define CS_TX_DATA_SENT CS_CMD(4, 0)
  42. /* params to CS_ERROR indication */
  43. #define CS_ERR_PEER_RESET 0
  44. /* ioctl interface */
  45. /* parameters to CS_CONFIG_BUFS ioctl */
  46. #define CS_FEAT_TSTAMP_RX_CTRL (1 << 0)
  47. #define CS_FEAT_ROLLING_RX_COUNTER (2 << 0)
  48. /* parameters to CS_GET_STATE ioctl */
  49. #define CS_STATE_CLOSED 0
  50. #define CS_STATE_OPENED 1 /* resource allocated */
  51. #define CS_STATE_CONFIGURED 2 /* data path active */
  52. /* maximum number of TX/RX buffers */
  53. #define CS_MAX_BUFFERS_SHIFT 4
  54. #define CS_MAX_BUFFERS (1 << CS_MAX_BUFFERS_SHIFT)
  55. /* Parameters for setting up the data buffers */
  56. struct cs_buffer_config {
  57. __u32 rx_bufs; /* number of RX buffer slots */
  58. __u32 tx_bufs; /* number of TX buffer slots */
  59. __u32 buf_size; /* bytes */
  60. __u32 flags; /* see CS_FEAT_* */
  61. __u32 reserved[4];
  62. };
  63. /*
  64. * struct for monotonic timestamp taken when the
  65. * last control command was received
  66. */
  67. struct cs_timestamp {
  68. __u32 tv_sec; /* seconds */
  69. __u32 tv_nsec; /* nanoseconds */
  70. };
  71. /*
  72. * Struct describing the layout and contents of the driver mmap area.
  73. * This information is meant as read-only information for the application.
  74. */
  75. struct cs_mmap_config_block {
  76. __u32 reserved1;
  77. __u32 buf_size; /* 0=disabled, otherwise the transfer size */
  78. __u32 rx_bufs; /* # of RX buffers */
  79. __u32 tx_bufs; /* # of TX buffers */
  80. __u32 reserved2;
  81. /* array of offsets within the mmap area for each RX and TX buffer */
  82. __u32 rx_offsets[CS_MAX_BUFFERS];
  83. __u32 tx_offsets[CS_MAX_BUFFERS];
  84. __u32 rx_ptr;
  85. __u32 rx_ptr_boundary;
  86. __u32 reserved3[2];
  87. /* enabled with CS_FEAT_TSTAMP_RX_CTRL */
  88. struct cs_timestamp tstamp_rx_ctrl;
  89. };
  90. #define CS_IO_MAGIC 'C'
  91. #define CS_IOW(num, dtype) _IOW(CS_IO_MAGIC, num, dtype)
  92. #define CS_IOR(num, dtype) _IOR(CS_IO_MAGIC, num, dtype)
  93. #define CS_IOWR(num, dtype) _IOWR(CS_IO_MAGIC, num, dtype)
  94. #define CS_IO(num) _IO(CS_IO_MAGIC, num)
  95. #define CS_GET_STATE CS_IOR(21, unsigned int)
  96. #define CS_SET_WAKELINE CS_IOW(23, unsigned int)
  97. #define CS_GET_IF_VERSION CS_IOR(30, unsigned int)
  98. #define CS_CONFIG_BUFS CS_IOW(31, struct cs_buffer_config)
  99. #endif /* _CS_PROTOCOL_H */