Git init
[framework/connectivity/bluez.git] / 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_PSM 23
26
27 #define AVC_MTU 512
28 #define AVC_HEADER_LENGTH 3
29
30 /* ctype entries */
31 #define AVC_CTYPE_CONTROL               0x0
32 #define AVC_CTYPE_STATUS                0x1
33 #define AVC_CTYPE_NOTIFY                0x3
34 #define AVC_CTYPE_NOT_IMPLEMENTED       0x8
35 #define AVC_CTYPE_ACCEPTED              0x9
36 #define AVC_CTYPE_REJECTED              0xA
37 #define AVC_CTYPE_STABLE                0xC
38 #define AVC_CTYPE_CHANGED               0xD
39 #define AVC_CTYPE_INTERIM               0xF
40
41 /* opcodes */
42 #define AVC_OP_VENDORDEP                0x00
43 #define AVC_OP_UNITINFO                 0x30
44 #define AVC_OP_SUBUNITINFO              0x31
45 #define AVC_OP_PASSTHROUGH              0x7c
46
47 /* subunits of interest */
48 #define AVC_SUBUNIT_PANEL               0x09
49
50 /* operands in passthrough commands */
51 #define VOL_UP_OP                       0x41
52 #define VOL_DOWN_OP                     0x42
53 #define MUTE_OP                         0x43
54 #define PLAY_OP                         0x44
55 #define STAVC_OP_OP                     0x45
56 #define PAUSE_OP                        0x46
57 #define RECORD_OP                       0x47
58 #define REWIND_OP                       0x48
59 #define FAST_FORWARD_OP                 0x49
60 #define EJECT_OP                        0x4a
61 #define FORWARD_OP                      0x4b
62 #define BACKWARD_OP                     0x4c
63
64 struct avctp;
65
66 typedef enum {
67         AVCTP_STATE_DISCONNECTED = 0,
68         AVCTP_STATE_CONNECTING,
69         AVCTP_STATE_CONNECTED
70 } avctp_state_t;
71
72 typedef void (*avctp_state_cb) (struct audio_device *dev,
73                                 avctp_state_t old_state,
74                                 avctp_state_t new_state,
75                                 void *user_data);
76
77 typedef size_t (*avctp_pdu_cb) (struct avctp *session, uint8_t transaction,
78                                         uint8_t *code, uint8_t *subunit,
79                                         uint8_t *operands, size_t operand_count,
80                                         void *user_data);
81
82 unsigned int avctp_add_state_cb(avctp_state_cb cb, void *user_data);
83 gboolean avctp_remove_state_cb(unsigned int id);
84
85 int avctp_register(const bdaddr_t *src, gboolean master);
86 void avctp_unregister(const bdaddr_t *src);
87
88 struct avctp *avctp_connect(const bdaddr_t *src, const bdaddr_t *dst);
89 struct avctp *avctp_get(const bdaddr_t *src, const bdaddr_t *dst);
90 void avctp_disconnect(struct avctp *session);
91
92 unsigned int avctp_register_pdu_handler(uint8_t opcode, avctp_pdu_cb cb,
93                                                         void *user_data);
94 gboolean avctp_unregister_pdu_handler(unsigned int id);
95
96 int avctp_send_passthrough(struct avctp *session, uint8_t op);
97 int avctp_send_vendordep(struct avctp *session, uint8_t transaction,
98                                 uint8_t code, uint8_t subunit,
99                                 uint8_t *operands, size_t operand_count);