1/*
2 *  ALSA client/server header file
3 *  Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
4 *
5 *   This library is free software; you can redistribute it and/or modify
6 *   it under the terms of the GNU Lesser General Public License as
7 *   published by the Free Software Foundation; either version 2.1 of
8 *   the License, or (at your option) any later version.
9 *
10 *   This program is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *   GNU Lesser General Public License for more details.
14 *
15 *   You should have received a copy of the GNU Lesser General Public
16 *   License along with this library; if not, write to the Free Software
17 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 *
19 */
20
21#include "../src/pcm/pcm_local.h"
22#include "../src/control/control_local.h"
23#include <netdb.h>
24
25int snd_receive_fd(int sock, void *data, size_t len, int *fd);
26
27typedef enum _snd_dev_type {
28	SND_DEV_TYPE_PCM,
29	SND_DEV_TYPE_CONTROL,
30	SND_DEV_TYPE_RAWMIDI,
31	SND_DEV_TYPE_TIMER,
32	SND_DEV_TYPE_HWDEP,
33	SND_DEV_TYPE_SEQ,
34} snd_dev_type_t;
35
36typedef enum _snd_transport_type {
37	SND_TRANSPORT_TYPE_SHM,
38	SND_TRANSPORT_TYPE_TCP,
39} snd_transport_type_t;
40
41#define SND_PCM_IOCTL_HWSYNC		_IO ('A', 0x22)
42#define SND_PCM_IOCTL_STATE		_IO ('A', 0xf1)
43#define SND_PCM_IOCTL_MMAP		_IO ('A', 0xf2)
44#define SND_PCM_IOCTL_MUNMAP		_IO ('A', 0xf3)
45#define SND_PCM_IOCTL_MMAP_COMMIT	_IO ('A', 0xf4)
46#define SND_PCM_IOCTL_AVAIL_UPDATE	_IO ('A', 0xf5)
47#define SND_PCM_IOCTL_ASYNC		_IO ('A', 0xf6)
48#define SND_PCM_IOCTL_CLOSE		_IO ('A', 0xf7)
49#define SND_PCM_IOCTL_POLL_DESCRIPTOR	_IO ('A', 0xf8)
50#define SND_PCM_IOCTL_HW_PTR_FD		_IO ('A', 0xf9)
51#define SND_PCM_IOCTL_APPL_PTR_FD	_IO ('A', 0xfa)
52#define SND_PCM_IOCTL_FORWARD		_IO ('A', 0xfb)
53
54typedef struct {
55	snd_pcm_uframes_t ptr;
56	int use_mmap;
57	off_t offset;		/* for mmap */
58	int changed;
59} snd_pcm_shm_rbptr_t;
60
61typedef struct {
62	long result;
63	int cmd;
64	snd_pcm_shm_rbptr_t hw;
65	snd_pcm_shm_rbptr_t appl;
66	union {
67		struct {
68			int sig;
69			pid_t pid;
70		} async;
71		snd_pcm_info_t info;
72		snd_pcm_hw_params_t hw_refine;
73		snd_pcm_hw_params_t hw_params;
74		snd_pcm_sw_params_t sw_params;
75		snd_pcm_status_t status;
76		struct {
77			snd_pcm_uframes_t frames;
78		} avail;
79		struct {
80			snd_pcm_sframes_t frames;
81		} delay;
82		struct {
83			int enable;
84		} pause;
85		snd_pcm_channel_info_t channel_info;
86		struct {
87			snd_pcm_uframes_t frames;
88		} rewind;
89		struct {
90			snd_pcm_uframes_t frames;
91		} forward;
92		struct {
93			int fd;
94		} link;
95		struct {
96			snd_pcm_uframes_t offset;
97			snd_pcm_uframes_t frames;
98		} mmap_commit;
99		struct {
100			char use_mmap;
101			int shmid;
102			off_t offset;
103		} rbptr;
104	} u;
105	char data[0];
106} snd_pcm_shm_ctrl_t;
107
108#define PCM_SHM_SIZE sizeof(snd_pcm_shm_ctrl_t)
109
110#define SND_CTL_IOCTL_READ		_IOR('U', 0xf1, snd_ctl_event_t)
111#define SND_CTL_IOCTL_CLOSE		_IO ('U', 0xf2)
112#define SND_CTL_IOCTL_POLL_DESCRIPTOR	_IO ('U', 0xf3)
113#define SND_CTL_IOCTL_ASYNC		_IO ('U', 0xf4)
114
115typedef struct {
116	int result;
117	int cmd;
118	union {
119		struct {
120			int sig;
121			pid_t pid;
122		} async;
123		int device;
124		int subscribe_events;
125		snd_ctl_card_info_t card_info;
126		snd_ctl_elem_list_t element_list;
127		snd_ctl_elem_info_t element_info;
128		snd_ctl_elem_value_t element_read;
129		snd_ctl_elem_value_t element_write;
130		snd_ctl_elem_id_t element_lock;
131		snd_ctl_elem_id_t element_unlock;
132		snd_hwdep_info_t hwdep_info;
133		snd_pcm_info_t pcm_info;
134		int pcm_prefer_subdevice;
135		snd_rawmidi_info_t rawmidi_info;
136		int rawmidi_prefer_subdevice;
137		unsigned int power_state;
138		snd_ctl_event_t read;
139	} u;
140	char data[0];
141} snd_ctl_shm_ctrl_t;
142
143#define CTL_SHM_SIZE 65536
144#define CTL_SHM_DATA_MAXLEN (CTL_SHM_SIZE - offsetof(snd_ctl_shm_ctrl_t, data))
145
146typedef struct {
147	unsigned char dev_type;
148	unsigned char transport_type;
149	unsigned char stream;
150	unsigned char mode;
151	unsigned char namelen;
152	char name[0];
153} snd_client_open_request_t;
154
155typedef struct {
156	long result;
157	int cookie;
158} snd_client_open_answer_t;
159
160