Implement mmap support with STORE and RETRIEVE notifications
[ossp.git] / ossp.h
blob8fdd3938e3df0e0580711e546dd62771fee02c7f
1 /*
2 * ossp - OSS Proxy: emulate OSS device using CUSE
4 * Copyright (C) 2008-2010 SUSE Linux Products GmbH
5 * Copyright (C) 2008-2010 Tejun Heo <tj@kernel.org>
7 * This file is released under the GPLv2.
8 */
10 #ifndef _OSSP_H
11 #define _OSSP_H
13 #include <sys/types.h>
14 #include <inttypes.h>
15 #include <semaphore.h>
16 #include <sys/soundcard.h>
18 #define OSSP_VERSION "1.3.2"
19 #define OSSP_CMD_MAGIC 0xdeadbeef
20 #define OSSP_REPLY_MAGIC 0xbeefdead
21 #define OSSP_NOTIFY_MAGIC 0xbebebebe
23 #define PLAY 0
24 #define REC 1
25 #define LEFT 0
26 #define RIGHT 1
28 enum ossp_opcode {
29 OSSP_MIXER,
31 OSSP_DSP_OPEN,
32 OSSP_DSP_READ,
33 OSSP_DSP_WRITE,
34 OSSP_DSP_POLL,
35 OSSP_DSP_MMAP,
36 OSSP_DSP_MUNMAP,
38 OSSP_DSP_RESET,
39 OSSP_DSP_SYNC,
40 OSSP_DSP_POST,
42 OSSP_DSP_GET_RATE,
43 OSSP_DSP_GET_CHANNELS,
44 OSSP_DSP_GET_FORMAT,
45 OSSP_DSP_GET_BLKSIZE,
46 OSSP_DSP_GET_FORMATS,
47 OSSP_DSP_SET_RATE,
48 OSSP_DSP_SET_CHANNELS,
49 OSSP_DSP_SET_FORMAT,
50 OSSP_DSP_SET_SUBDIVISION,
52 OSSP_DSP_SET_FRAGMENT,
53 OSSP_DSP_GET_TRIGGER,
54 OSSP_DSP_SET_TRIGGER,
55 OSSP_DSP_GET_OSPACE,
56 OSSP_DSP_GET_ISPACE,
57 OSSP_DSP_GET_OPTR,
58 OSSP_DSP_GET_IPTR,
59 OSSP_DSP_GET_ODELAY,
61 OSSP_NR_OPCODES,
64 enum ossp_notify_opcode {
65 OSSP_NOTIFY_POLL,
66 OSSP_NOTIFY_OBITUARY,
67 OSSP_NOTIFY_VOLCHG,
68 OSSP_NOTIFY_FILL,
69 OSSP_NOTIFY_STORE,
71 OSSP_NR_NOTIFY_OPCODES,
74 struct ossp_transfer {
75 sem_t sem;
76 size_t pos;
77 size_t bytes;
80 struct ossp_mixer_arg {
81 int vol[2][2];
84 struct ossp_dsp_open_arg {
85 int flags;
86 pid_t opener_pid;
89 struct ossp_dsp_rw_arg {
90 unsigned nonblock:1;
93 struct ossp_dsp_mmap_arg {
94 int dir;
95 size_t size;
98 struct ossp_cmd {
99 unsigned magic;
100 enum ossp_opcode opcode;
101 size_t din_size;
102 size_t dout_size;
105 struct ossp_reply {
106 unsigned magic;
107 int result;
108 size_t dout_size; /* <= cmd.data_in_size */
111 struct ossp_notify {
112 unsigned magic;
113 enum ossp_notify_opcode opcode;
116 struct ossp_arg_size {
117 ssize_t carg_size;
118 ssize_t rarg_size;
119 unsigned has_fd:1;
122 extern const struct ossp_arg_size ossp_arg_sizes[OSSP_NR_OPCODES];
123 extern const char *ossp_cmd_str[OSSP_NR_OPCODES];
124 extern const char *ossp_notify_str[OSSP_NR_NOTIFY_OPCODES];
126 #endif /* _OSSP_H */