avctp.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2006-2010 Nokia Corporation
  7. * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
  8. *
  9. *
  10. */
  11. #define AVCTP_CONTROL_PSM 23
  12. #define AVCTP_BROWSING_PSM 27
  13. #define AVCTP_HEADER_LENGTH 3
  14. #define AVC_HEADER_LENGTH 3
  15. #define AVC_DATA_OFFSET AVCTP_HEADER_LENGTH + AVC_HEADER_LENGTH
  16. #define AVC_DATA_MTU 512
  17. /* ctype entries */
  18. #define AVC_CTYPE_CONTROL 0x0
  19. #define AVC_CTYPE_STATUS 0x1
  20. #define AVC_CTYPE_NOTIFY 0x3
  21. #define AVC_CTYPE_NOT_IMPLEMENTED 0x8
  22. #define AVC_CTYPE_ACCEPTED 0x9
  23. #define AVC_CTYPE_REJECTED 0xA
  24. #define AVC_CTYPE_STABLE 0xC
  25. #define AVC_CTYPE_CHANGED 0xD
  26. #define AVC_CTYPE_INTERIM 0xF
  27. /* opcodes */
  28. #define AVC_OP_VENDORDEP 0x00
  29. #define AVC_OP_UNITINFO 0x30
  30. #define AVC_OP_SUBUNITINFO 0x31
  31. #define AVC_OP_PASSTHROUGH 0x7c
  32. /* subunits of interest */
  33. #define AVC_SUBUNIT_PANEL 0x09
  34. /* operands in passthrough commands */
  35. #define AVC_SELECT 0x00
  36. #define AVC_UP 0x01
  37. #define AVC_DOWN 0x02
  38. #define AVC_LEFT 0x03
  39. #define AVC_RIGHT 0x04
  40. #define AVC_ROOT_MENU 0x09
  41. #define AVC_CONTENTS_MENU 0x0b
  42. #define AVC_FAVORITE_MENU 0x0c
  43. #define AVC_EXIT 0x0d
  44. #define AVC_ON_DEMAND_MENU 0x0e
  45. #define AVC_APPS_MENU 0x0f
  46. #define AVC_0 0x20
  47. #define AVC_1 0x21
  48. #define AVC_2 0x22
  49. #define AVC_3 0x23
  50. #define AVC_4 0x24
  51. #define AVC_5 0x25
  52. #define AVC_6 0x26
  53. #define AVC_7 0x27
  54. #define AVC_8 0x28
  55. #define AVC_9 0x29
  56. #define AVC_DOT 0x2a
  57. #define AVC_ENTER 0x2b
  58. #define AVC_CHANNEL_UP 0x30
  59. #define AVC_CHANNEL_DOWN 0x31
  60. #define AVC_CHANNEL_PREVIOUS 0x32
  61. #define AVC_INPUT_SELECT 0x34
  62. #define AVC_INFO 0x35
  63. #define AVC_HELP 0x36
  64. #define AVC_PAGE_UP 0x37
  65. #define AVC_PAGE_DOWN 0x38
  66. #define AVC_LOCK 0x3a
  67. #define AVC_POWER 0x40
  68. #define AVC_VOLUME_UP 0x41
  69. #define AVC_VOLUME_DOWN 0x42
  70. #define AVC_MUTE 0x43
  71. #define AVC_PLAY 0x44
  72. #define AVC_STOP 0x45
  73. #define AVC_PAUSE 0x46
  74. #define AVC_RECORD 0x47
  75. #define AVC_REWIND 0x48
  76. #define AVC_FAST_FORWARD 0x49
  77. #define AVC_EJECT 0x4a
  78. #define AVC_FORWARD 0x4b
  79. #define AVC_BACKWARD 0x4c
  80. #define AVC_LIST 0x4d
  81. #define AVC_F1 0x71
  82. #define AVC_F2 0x72
  83. #define AVC_F3 0x73
  84. #define AVC_F4 0x74
  85. #define AVC_F5 0x75
  86. #define AVC_F6 0x76
  87. #define AVC_F7 0x77
  88. #define AVC_F8 0x78
  89. #define AVC_F9 0x79
  90. #define AVC_RED 0x7a
  91. #define AVC_GREEN 0x7b
  92. #define AVC_BLUE 0x7c
  93. #define AVC_YELLOW 0x7c
  94. #define AVC_VENDOR_UNIQUE 0x7e
  95. #define AVC_VENDOR_NEXT_GROUP 0x00
  96. #define AVC_VENDOR_PREV_GROUP 0x01
  97. struct avctp;
  98. typedef bool (*avctp_passthrough_cb) (struct avctp *session,
  99. uint8_t op, bool pressed,
  100. void *user_data);
  101. typedef ssize_t (*avctp_control_pdu_cb) (struct avctp *session,
  102. uint8_t transaction, uint8_t *code,
  103. uint8_t *subunit, uint8_t *operands,
  104. size_t operand_count, void *user_data);
  105. typedef gboolean (*avctp_rsp_cb) (struct avctp *session, uint8_t code,
  106. uint8_t subunit, uint8_t *operands,
  107. size_t operand_count, void *user_data);
  108. typedef gboolean (*avctp_browsing_rsp_cb) (struct avctp *session,
  109. uint8_t *operands, size_t operand_count,
  110. void *user_data);
  111. typedef ssize_t (*avctp_browsing_pdu_cb) (struct avctp *session,
  112. uint8_t transaction,
  113. uint8_t *operands, size_t operand_count,
  114. void *user_data);
  115. typedef void (*avctp_destroy_cb_t) (void *user_data);
  116. struct avctp *avctp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
  117. void avctp_set_destroy_cb(struct avctp *session, avctp_destroy_cb_t cb,
  118. void *user_data);
  119. int avctp_init_uinput(struct avctp *session, const char *name,
  120. const char *address);
  121. int avctp_connect_browsing(struct avctp *session, int fd, size_t imtu,
  122. size_t omtu);
  123. void avctp_shutdown(struct avctp *session);
  124. unsigned int avctp_register_passthrough_handler(struct avctp *session,
  125. avctp_passthrough_cb cb,
  126. void *user_data);
  127. bool avctp_unregister_passthrough_handler(struct avctp *session,
  128. unsigned int id);
  129. unsigned int avctp_register_pdu_handler(struct avctp *session, uint8_t opcode,
  130. avctp_control_pdu_cb cb,
  131. void *user_data);
  132. bool avctp_unregister_pdu_handler(struct avctp *session, unsigned int id);
  133. unsigned int avctp_register_browsing_pdu_handler(struct avctp *session,
  134. avctp_browsing_pdu_cb cb,
  135. void *user_data,
  136. avctp_destroy_cb_t destroy);
  137. bool avctp_unregister_browsing_pdu_handler(struct avctp *session,
  138. unsigned int id);
  139. int avctp_send_passthrough(struct avctp *session, uint8_t op, uint8_t *params,
  140. size_t params_len);
  141. int avctp_send_vendor(struct avctp *session, uint8_t transaction,
  142. uint8_t code, uint8_t subunit,
  143. const struct iovec *iov, int iov_cnt);
  144. int avctp_send_vendor_req(struct avctp *session, uint8_t code, uint8_t subunit,
  145. const struct iovec *iov, int iov_cnt,
  146. avctp_rsp_cb func, void *user_data);
  147. int avctp_send_browsing(struct avctp *session, uint8_t transaction,
  148. const struct iovec *iov, int iov_cnt);
  149. int avctp_send_browsing_req(struct avctp *session,
  150. const struct iovec *iov, int iov_cnt,
  151. avctp_browsing_rsp_cb func, void *user_data);