avctp.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 AVC_MTU 512
  14. #define AVC_HEADER_LENGTH 3
  15. /* ctype entries */
  16. #define AVC_CTYPE_CONTROL 0x0
  17. #define AVC_CTYPE_STATUS 0x1
  18. #define AVC_CTYPE_NOTIFY 0x3
  19. #define AVC_CTYPE_NOT_IMPLEMENTED 0x8
  20. #define AVC_CTYPE_ACCEPTED 0x9
  21. #define AVC_CTYPE_REJECTED 0xA
  22. #define AVC_CTYPE_STABLE 0xC
  23. #define AVC_CTYPE_CHANGED 0xD
  24. #define AVC_CTYPE_INTERIM 0xF
  25. /* opcodes */
  26. #define AVC_OP_VENDORDEP 0x00
  27. #define AVC_OP_UNITINFO 0x30
  28. #define AVC_OP_SUBUNITINFO 0x31
  29. #define AVC_OP_PASSTHROUGH 0x7c
  30. /* subunits of interest */
  31. #define AVC_SUBUNIT_PANEL 0x09
  32. /* operands in passthrough commands */
  33. #define AVC_SELECT 0x00
  34. #define AVC_UP 0x01
  35. #define AVC_DOWN 0x02
  36. #define AVC_LEFT 0x03
  37. #define AVC_RIGHT 0x04
  38. #define AVC_RIGHT_UP 0x05
  39. #define AVC_RIGHT_DOWN 0x06
  40. #define AVC_LEFT_UP 0x07
  41. #define AVC_LEFT_DOWN 0x08
  42. #define AVC_ROOT_MENU 0x09
  43. #define AVC_SETUP_MENU 0x0a
  44. #define AVC_CONTENTS_MENU 0x0b
  45. #define AVC_FAVORITE_MENU 0x0c
  46. #define AVC_EXIT 0x0d
  47. #define AVC_ON_DEMAND_MENU 0x0e
  48. #define AVC_APPS_MENU 0x0f
  49. #define AVC_0 0x20
  50. #define AVC_1 0x21
  51. #define AVC_2 0x22
  52. #define AVC_3 0x23
  53. #define AVC_4 0x24
  54. #define AVC_5 0x25
  55. #define AVC_6 0x26
  56. #define AVC_7 0x27
  57. #define AVC_8 0x28
  58. #define AVC_9 0x29
  59. #define AVC_DOT 0x2a
  60. #define AVC_ENTER 0x2b
  61. #define AVC_CLEAR 0x2c
  62. #define AVC_CHANNEL_UP 0x30
  63. #define AVC_CHANNEL_DOWN 0x31
  64. #define AVC_CHANNEL_PREVIOUS 0x32
  65. #define AVC_SOUND_SELECT 0x33
  66. #define AVC_INPUT_SELECT 0x34
  67. #define AVC_INFO 0x35
  68. #define AVC_HELP 0x36
  69. #define AVC_PAGE_UP 0x37
  70. #define AVC_PAGE_DOWN 0x38
  71. #define AVC_LOCK 0x3a
  72. #define AVC_POWER 0x40
  73. #define AVC_VOLUME_UP 0x41
  74. #define AVC_VOLUME_DOWN 0x42
  75. #define AVC_MUTE 0x43
  76. #define AVC_PLAY 0x44
  77. #define AVC_STOP 0x45
  78. #define AVC_PAUSE 0x46
  79. #define AVC_RECORD 0x47
  80. #define AVC_REWIND 0x48
  81. #define AVC_FAST_FORWARD 0x49
  82. #define AVC_EJECT 0x4a
  83. #define AVC_FORWARD 0x4b
  84. #define AVC_BACKWARD 0x4c
  85. #define AVC_LIST 0x4d
  86. #define AVC_ANGLE 0x50
  87. #define AVC_SUBPICTURE 0x51
  88. #define AVC_F1 0x71
  89. #define AVC_F2 0x72
  90. #define AVC_F3 0x73
  91. #define AVC_F4 0x74
  92. #define AVC_F5 0x75
  93. #define AVC_F6 0x76
  94. #define AVC_F7 0x77
  95. #define AVC_F8 0x78
  96. #define AVC_F9 0x79
  97. #define AVC_RED 0x7a
  98. #define AVC_GREEN 0x7b
  99. #define AVC_BLUE 0x7c
  100. #define AVC_YELLOW 0x7c
  101. #define AVC_VENDOR_UNIQUE 0x7e
  102. #define AVC_INVALID 0xff
  103. struct avctp;
  104. typedef enum {
  105. AVCTP_STATE_DISCONNECTED = 0,
  106. AVCTP_STATE_CONNECTING,
  107. AVCTP_STATE_CONNECTED,
  108. AVCTP_STATE_BROWSING_CONNECTING,
  109. AVCTP_STATE_BROWSING_CONNECTED
  110. } avctp_state_t;
  111. typedef void (*avctp_state_cb) (struct btd_device *dev,
  112. avctp_state_t old_state,
  113. avctp_state_t new_state,
  114. int err, void *user_data);
  115. typedef bool (*avctp_passthrough_cb) (struct avctp *session,
  116. uint8_t op, bool pressed,
  117. void *user_data);
  118. typedef size_t (*avctp_control_pdu_cb) (struct avctp *session,
  119. uint8_t transaction, uint8_t *code,
  120. uint8_t *subunit, uint8_t *operands,
  121. size_t operand_count, void *user_data);
  122. typedef gboolean (*avctp_rsp_cb) (struct avctp *session, uint8_t code,
  123. uint8_t subunit, uint8_t transaction,
  124. uint8_t *operands, size_t operand_count,
  125. void *user_data);
  126. typedef gboolean (*avctp_browsing_rsp_cb) (struct avctp *session,
  127. uint8_t *operands, size_t operand_count,
  128. void *user_data);
  129. typedef size_t (*avctp_browsing_pdu_cb) (struct avctp *session,
  130. uint8_t transaction,
  131. uint8_t *operands, size_t operand_count,
  132. void *user_data);
  133. unsigned int avctp_add_state_cb(struct btd_device *dev, avctp_state_cb cb,
  134. void *user_data);
  135. gboolean avctp_remove_state_cb(unsigned int id);
  136. int avctp_register(struct btd_adapter *adapter, bool central, bool *browsing);
  137. void avctp_unregister(struct btd_adapter *adapter);
  138. struct avctp *avctp_connect(struct btd_device *device);
  139. struct avctp *avctp_get(struct btd_device *device);
  140. bool avctp_is_initiator(struct avctp *session);
  141. int avctp_connect_browsing(struct avctp *session);
  142. void avctp_disconnect(struct avctp *session);
  143. unsigned int avctp_register_passthrough_handler(struct avctp *session,
  144. avctp_passthrough_cb cb,
  145. void *user_data);
  146. bool avctp_unregister_passthrough_handler(unsigned int id);
  147. unsigned int avctp_register_pdu_handler(struct avctp *session, uint8_t opcode,
  148. avctp_control_pdu_cb cb,
  149. void *user_data);
  150. gboolean avctp_unregister_pdu_handler(unsigned int id);
  151. unsigned int avctp_register_browsing_pdu_handler(struct avctp *session,
  152. avctp_browsing_pdu_cb cb,
  153. void *user_data,
  154. GDestroyNotify destroy);
  155. gboolean avctp_unregister_browsing_pdu_handler(unsigned int id);
  156. int avctp_send_passthrough(struct avctp *session, uint8_t op, bool hold);
  157. int avctp_send_release_passthrough(struct avctp *session);
  158. int avctp_send_vendordep(struct avctp *session, uint8_t transaction,
  159. uint8_t code, uint8_t subunit,
  160. uint8_t *operands, size_t operand_count);
  161. int avctp_send_vendordep_req(struct avctp *session, uint8_t code,
  162. uint8_t subunit, uint8_t *operands,
  163. size_t operand_count,
  164. avctp_rsp_cb func, void *user_data);
  165. int avctp_send_browsing_req(struct avctp *session,
  166. uint8_t *operands, size_t operand_count,
  167. avctp_browsing_rsp_cb func, void *user_data);
  168. bool avctp_supports_avc(uint8_t avc);