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