ipc.h revision c2833e263d6cfc4cf82f4bfdcc59640a4071aeae
1/*
2 *
3 *  BlueZ - Bluetooth protocol stack for Linux
4 *
5 *  Copyright (C) 2004-2007  Marcel Holtmann <marcel@holtmann.org>
6 *
7 *
8 *  This program is free software; you can redistribute it and/or modify
9 *  it under the terms of the GNU General Public License as published by
10 *  the Free Software Foundation; either version 2 of the License, or
11 *  (at your option) any later version.
12 *
13 *  This program is distributed in the hope that it will be useful,
14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *  GNU General Public License for more details.
17 *
18 *  You should have received a copy of the GNU General Public License
19 *  along with this program; if not, write to the Free Software
20 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 *
22 */
23
24#define IPC_TYPE_CONNECT  0x0001
25
26#define IPC_MTU 32
27
28#define IPC_SOCKET_NAME "\0/org/bluez/audio"
29
30#ifndef UNIX_PATH_MAX
31#define UNIX_PATH_MAX 108
32#endif
33
34/* Supported roles */
35#define PKT_ROLE_NONE			0
36#define PKT_ROLE_AUTO			1
37#define PKT_ROLE_VOICE			2
38#define PKT_ROLE_HIFI			3
39
40/* Packet types */
41#define PKT_TYPE_CFG_REQ		0
42#define PKT_TYPE_CFG_RSP		1
43#define PKT_TYPE_STATE_REQ		2
44#define PKT_TYPE_STATE_RSP		3
45#define PKT_TYPE_CTL_REQ		4
46#define PKT_TYPE_CTL_RSP		5
47#define PKT_TYPE_CTL_NTFY		6
48
49/* Errors codes */
50#define PKT_ERROR_NONE			0
51
52struct ipc_packet {
53	uint8_t id;		/* Device id */
54	uint8_t role;		/* Audio role eg: voice, wifi, auto... */
55	uint8_t type;		/* Packet type */
56	uint8_t error;		/* Packet error code */
57	uint8_t length;		/* Payload length in bytes */
58	uint8_t data[0];	/* Packet payload */
59} __attribute__ ((packed));
60
61/* File descriptor options */
62#define CFG_FD_OPT_READ			0
63#define CFG_FD_OPT_WRITE		1
64#define CFG_FD_OPT_READWRITE		2
65
66/* Audio channel mode */
67#define CFG_CHANNEL_MODE_MONO		(1 << 3)
68#define CFG_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)
69#define CFG_CHANNEL_MODE_STEREO		(1 << 1)
70#define CFG_CHANNEL_MODE_JOINT_STEREO	1
71
72/* Codec options */
73#define CFG_CODEC_NONE			0
74#define CFG_CODEC_SBC			1
75
76struct ipc_data_cfg {
77	uint8_t fd_opt;		/* Stream file descriptor options: read,
78				   write or readwrite */
79	uint8_t channels;	/* Number of audio channel */
80	uint8_t channel_mode;	/* Audio channel mode*/
81	uint16_t pkt_len;	/* Stream packet length */
82	uint8_t sample_size;	/* Sample size in bytes */
83	uint16_t rate;		/* Stream sample rate */
84	uint8_t codec;		/* Stream codec */
85	uint8_t data[0];	/* Codec payload */
86} __attribute__ ((packed));
87
88/* SBC codec options */
89#define CODEC_SBC_ALLOCATION_SNR	(1 << 1)
90#define CODEC_SBC_ALLOCATION_LOUDNESS	1
91
92struct ipc_codec_sbc {
93	uint8_t allocation;
94	uint8_t subbands;
95	uint8_t blocks;
96	uint8_t bitpool;
97} __attribute__ ((packed));
98
99/* Device status */
100#define STATE_DISCONNECTED		0
101#define STATE_CONNECTING		1
102#define STATE_CONNECTED			2
103#define STATE_STREAM_STARTING		3
104#define STATE_STREAMING			4
105
106struct ipc_data_state {
107	uint8_t state;		/* Stream state */
108} __attribute__ ((packed));
109
110#define CTL_MODE_PLAYBACK		0
111#define CTL_MODE_CAPTURE		1
112#define CTL_MODE_GENERAL		2
113
114/* Supported control operations */
115#define CTL_KEY_POWER			0x40
116#define CTL_KEY_VOL_UP			0x41
117#define CTL_KEY_VOL_DOWN		0x42
118#define CTL_KEY_MUTE			0x43
119#define CTL_KEY_PLAY			0x44
120#define CTL_KEY_STOP			0x45
121#define CTL_KEY_PAUSE			0x46
122#define CTL_KEY_RECORD			0x47
123#define CTL_KEY_REWIND			0x48
124#define CTL_KEY_FAST_FORWARD		0x49
125#define CTL_KEY_EJECT			0x4A
126#define CTL_KEY_FORWARD			0x4B
127#define CTL_KEY_BACKWARD		0x4C
128
129struct ipc_data_ctl {
130	uint8_t mode;		/* Control Mode */
131	uint8_t key;		/* Control Key */
132}  __attribute__ ((packed));
133