Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / android / avctp.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2006-2010  Nokia Corporation
6  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #define AVCTP_CONTROL_PSM               23
26 #define AVCTP_BROWSING_PSM              27
27
28 #define AVCTP_HEADER_LENGTH             3
29 #define AVC_HEADER_LENGTH               3
30
31 #define AVC_DATA_OFFSET                 AVCTP_HEADER_LENGTH + AVC_HEADER_LENGTH
32 #define AVC_DATA_MTU                    512
33
34 /* ctype entries */
35 #define AVC_CTYPE_CONTROL               0x0
36 #define AVC_CTYPE_STATUS                0x1
37 #define AVC_CTYPE_NOTIFY                0x3
38 #define AVC_CTYPE_NOT_IMPLEMENTED       0x8
39 #define AVC_CTYPE_ACCEPTED              0x9
40 #define AVC_CTYPE_REJECTED              0xA
41 #define AVC_CTYPE_STABLE                0xC
42 #define AVC_CTYPE_CHANGED               0xD
43 #define AVC_CTYPE_INTERIM               0xF
44
45 /* opcodes */
46 #define AVC_OP_VENDORDEP                0x00
47 #define AVC_OP_UNITINFO                 0x30
48 #define AVC_OP_SUBUNITINFO              0x31
49 #define AVC_OP_PASSTHROUGH              0x7c
50
51 /* subunits of interest */
52 #define AVC_SUBUNIT_PANEL               0x09
53
54 /* operands in passthrough commands */
55 #define AVC_SELECT                      0x00
56 #define AVC_UP                          0x01
57 #define AVC_DOWN                        0x02
58 #define AVC_LEFT                        0x03
59 #define AVC_RIGHT                       0x04
60 #define AVC_ROOT_MENU                   0x09
61 #define AVC_CONTENTS_MENU               0x0b
62 #define AVC_FAVORITE_MENU               0x0c
63 #define AVC_EXIT                        0x0d
64 #define AVC_ON_DEMAND_MENU              0x0e
65 #define AVC_APPS_MENU                   0x0f
66 #define AVC_0                           0x20
67 #define AVC_1                           0x21
68 #define AVC_2                           0x22
69 #define AVC_3                           0x23
70 #define AVC_4                           0x24
71 #define AVC_5                           0x25
72 #define AVC_6                           0x26
73 #define AVC_7                           0x27
74 #define AVC_8                           0x28
75 #define AVC_9                           0x29
76 #define AVC_DOT                         0x2a
77 #define AVC_ENTER                       0x2b
78 #define AVC_CHANNEL_UP                  0x30
79 #define AVC_CHANNEL_DOWN                0x31
80 #define AVC_CHANNEL_PREVIOUS            0x32
81 #define AVC_INPUT_SELECT                0x34
82 #define AVC_INFO                        0x35
83 #define AVC_HELP                        0x36
84 #define AVC_PAGE_UP                     0x37
85 #define AVC_PAGE_DOWN                   0x38
86 #define AVC_LOCK                        0x3a
87 #define AVC_POWER                       0x40
88 #define AVC_VOLUME_UP                   0x41
89 #define AVC_VOLUME_DOWN                 0x42
90 #define AVC_MUTE                        0x43
91 #define AVC_PLAY                        0x44
92 #define AVC_STOP                        0x45
93 #define AVC_PAUSE                       0x46
94 #define AVC_RECORD                      0x47
95 #define AVC_REWIND                      0x48
96 #define AVC_FAST_FORWARD                0x49
97 #define AVC_EJECT                       0x4a
98 #define AVC_FORWARD                     0x4b
99 #define AVC_BACKWARD                    0x4c
100 #define AVC_LIST                        0x4d
101 #define AVC_F1                          0x71
102 #define AVC_F2                          0x72
103 #define AVC_F3                          0x73
104 #define AVC_F4                          0x74
105 #define AVC_F5                          0x75
106 #define AVC_F6                          0x76
107 #define AVC_F7                          0x77
108 #define AVC_F8                          0x78
109 #define AVC_F9                          0x79
110 #define AVC_RED                         0x7a
111 #define AVC_GREEN                       0x7b
112 #define AVC_BLUE                        0x7c
113 #define AVC_YELLOW                      0x7c
114
115 #define AVC_VENDOR_UNIQUE               0x7e
116
117 #define AVC_VENDOR_NEXT_GROUP           0x00
118 #define AVC_VENDOR_PREV_GROUP           0x01
119
120 struct avctp;
121
122 typedef bool (*avctp_passthrough_cb) (struct avctp *session,
123                                         uint8_t op, bool pressed,
124                                         void *user_data);
125 typedef ssize_t (*avctp_control_pdu_cb) (struct avctp *session,
126                                         uint8_t transaction, uint8_t *code,
127                                         uint8_t *subunit, uint8_t *operands,
128                                         size_t operand_count, void *user_data);
129 typedef gboolean (*avctp_rsp_cb) (struct avctp *session, uint8_t code,
130                                         uint8_t subunit, uint8_t *operands,
131                                         size_t operand_count, void *user_data);
132 typedef gboolean (*avctp_browsing_rsp_cb) (struct avctp *session,
133                                         uint8_t *operands, size_t operand_count,
134                                         void *user_data);
135 typedef ssize_t (*avctp_browsing_pdu_cb) (struct avctp *session,
136                                         uint8_t transaction,
137                                         uint8_t *operands, size_t operand_count,
138                                         void *user_data);
139
140 typedef void (*avctp_destroy_cb_t) (void *user_data);
141
142 struct avctp *avctp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
143 void avctp_set_destroy_cb(struct avctp *session, avctp_destroy_cb_t cb,
144                                                         void *user_data);
145
146 int avctp_init_uinput(struct avctp *session, const char *name,
147                                                         const char *address);
148 int avctp_connect_browsing(struct avctp *session, int fd, size_t imtu,
149                                                                 size_t omtu);
150
151 void avctp_shutdown(struct avctp *session);
152
153 unsigned int avctp_register_passthrough_handler(struct avctp *session,
154                                                 avctp_passthrough_cb cb,
155                                                 void *user_data);
156 bool avctp_unregister_passthrough_handler(struct avctp *session,
157                                                         unsigned int id);
158
159 unsigned int avctp_register_pdu_handler(struct avctp *session, uint8_t opcode,
160                                                 avctp_control_pdu_cb cb,
161                                                 void *user_data);
162 bool avctp_unregister_pdu_handler(struct avctp *session, unsigned int id);
163
164 unsigned int avctp_register_browsing_pdu_handler(struct avctp *session,
165                                                 avctp_browsing_pdu_cb cb,
166                                                 void *user_data,
167                                                 avctp_destroy_cb_t destroy);
168 bool avctp_unregister_browsing_pdu_handler(struct avctp *session,
169                                                         unsigned int id);
170
171 int avctp_send_passthrough(struct avctp *session, uint8_t op, uint8_t *params,
172                                                         size_t params_len);
173 int avctp_send_vendor(struct avctp *session, uint8_t transaction,
174                                 uint8_t code, uint8_t subunit,
175                                 const struct iovec *iov, int iov_cnt);
176 int avctp_send_vendor_req(struct avctp *session, uint8_t code, uint8_t subunit,
177                                         const struct iovec *iov, int iov_cnt,
178                                         avctp_rsp_cb func, void *user_data);
179 int avctp_send_browsing(struct avctp *session, uint8_t transaction,
180                                         const struct iovec *iov, int iov_cnt);
181 int avctp_send_browsing_req(struct avctp *session,
182                                 const struct iovec *iov, int iov_cnt,
183                                 avctp_browsing_rsp_cb func, void *user_data);