ipc.h revision ddf8edc54d666f9b6f75f28b6db5375e2f0982a8
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#include <stdint.h>
25
26#define IPC_TYPE_CONNECT  0x0001
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_STATUS_REQ	2
44#define PKT_TYPE_STATUS_RSP	3
45#define PKT_TYPE_CTL_REQ	4
46#define PKT_TYPE_CTL_RSP	5
47
48/* Errors codes */
49#define PKT_ERROR_NONE		0
50
51struct ipc_packet {
52	uint8_t id;		/* Device id */
53	uint8_t role;		/* Audio role eg: voice, wifi, auto... */
54	uint8_t type;		/* Packet type */
55	uint8_t error;		/* Packet error code */
56	uint8_t length;		/* Payload length in bytes */
57	uint8_t data[0];	/* Packet payload */
58} __attribute__ ((packed));
59
60/* File descriptor options */
61#define CFG_FD_OPT_READ		0
62#define CFG_FD_OPT_WRITE	1
63#define CFG_FD_OPT_READWRITE	2
64
65struct ipc_data_cfg {
66	int fd;			/* Stream file descriptor */
67	uint8_t fd_opt;		/* Stream file descriptor options: read, write or readwrite*/
68	uint8_t encoding;	/* Stream encoding */
69	uint8_t bitpool;	/* Encoding bitpool */
70	uint8_t channels;	/* Number of audio channel */
71	uint8_t pkt_len;	/* Stream packet length */
72	uint8_t sample_size;	/* Sample size in bytes */
73	uint16_t rate;		/* Stream sample rate */
74} __attribute__ ((packed));
75
76/* Device status */
77#define STATUS_DISCONNECTED	0
78#define STATUS_CONNECTING	1
79#define STATUS_CONNECTED	2
80#define STATUS_STREAMING	3
81
82struct ipc_data_status {
83	uint8_t status;		/* Stream status */
84} __attribute__ ((packed));
85
86/* Supported control operations */
87#define DATA_CTL_POWER		0x40
88#define DATA_CTL_VOL_UP		0x41
89#define DATA_CTL_VOL_DOWN	0x42
90#define DATA_CTL_MUTE		0x43
91#define DATA_CTL_PLAY		0x44
92#define DATA_CTL_STOP		0x45
93#define DATA_CTL_PAUSE		0x46
94#define DATA_CTL_RECORD		0x47
95#define DATA_CTL_REWIND		0x48
96#define DATA_CTL_FAST_FORWARD	0x49
97#define DATA_CTL_EJECT		0x4A
98#define DATA_CTL_FORWARD	0x4B
99#define DATA_CTL_BACKWARD	0x4C
100
101struct ipc_data_ctl {
102	uint8_t operation;	/* Operation ID */
103}  __attribute__ ((packed));
104