Initial debian packaging
[osspd.git] / ossp.h
1 /*
2  * ossp - OSS Proxy: emulate OSS device using CUSE
3  *
4  * Copyright (C) 2008-2010  SUSE Linux Products GmbH
5  * Copyright (C) 2008-2010  Tejun Heo <tj@kernel.org>
6  *
7  * This file is released under the GPLv2.
8  */
9
10 #ifndef _OSSP_H
11 #define _OSSP_H
12
13 #include <sys/types.h>
14 #include <inttypes.h>
15 #include <sys/soundcard.h>
16
17 #define OSSP_VERSION            "1.3.2"
18 #define OSSP_CMD_MAGIC          0xdeadbeef
19 #define OSSP_REPLY_MAGIC        0xbeefdead
20 #define OSSP_NOTIFY_MAGIC       0xbebebebe
21
22 #define PLAY                    0
23 #define REC                     1
24 #define LEFT                    0
25 #define RIGHT                   1
26
27 enum ossp_opcode {
28         OSSP_MIXER,
29
30         OSSP_DSP_OPEN,
31         OSSP_DSP_READ,
32         OSSP_DSP_WRITE,
33         OSSP_DSP_POLL,
34         OSSP_DSP_MMAP,
35         OSSP_DSP_MUNMAP,
36
37         OSSP_DSP_RESET,
38         OSSP_DSP_SYNC,
39         OSSP_DSP_POST,
40
41         OSSP_DSP_GET_RATE,
42         OSSP_DSP_GET_CHANNELS,
43         OSSP_DSP_GET_FORMAT,
44         OSSP_DSP_GET_BLKSIZE,
45         OSSP_DSP_GET_FORMATS,
46         OSSP_DSP_SET_RATE,
47         OSSP_DSP_SET_CHANNELS,
48         OSSP_DSP_SET_FORMAT,
49         OSSP_DSP_SET_SUBDIVISION,
50
51         OSSP_DSP_SET_FRAGMENT,
52         OSSP_DSP_GET_TRIGGER,
53         OSSP_DSP_SET_TRIGGER,
54         OSSP_DSP_GET_OSPACE,
55         OSSP_DSP_GET_ISPACE,
56         OSSP_DSP_GET_OPTR,
57         OSSP_DSP_GET_IPTR,
58         OSSP_DSP_GET_ODELAY,
59
60         OSSP_NR_OPCODES,
61 };
62
63 enum ossp_notify_opcode {
64         OSSP_NOTIFY_POLL,
65         OSSP_NOTIFY_OBITUARY,
66         OSSP_NOTIFY_VOLCHG,
67
68         OSSP_NR_NOTIFY_OPCODES,
69 };
70
71 struct ossp_mixer_arg {
72         int                     vol[2][2];
73 };
74
75 struct ossp_dsp_open_arg {
76         int                     flags;
77         pid_t                   opener_pid;
78 };
79
80 struct ossp_dsp_rw_arg {
81         unsigned                nonblock:1;
82 };
83
84 struct ossp_dsp_mmap_arg {
85         int                     dir;
86         size_t                  size;
87 };
88
89 struct ossp_cmd {
90         unsigned                magic;
91         enum ossp_opcode        opcode;
92         size_t                  din_size;
93         size_t                  dout_size;
94 };
95
96 struct ossp_reply {
97         unsigned                magic;
98         int                     result;
99         size_t                  dout_size;      /* <= cmd.data_in_size */
100 };
101
102 struct ossp_notify {
103         unsigned                magic;
104         enum ossp_notify_opcode opcode;
105 };
106
107 struct ossp_arg_size {
108         ssize_t                 carg_size;
109         ssize_t                 rarg_size;
110         unsigned                has_fd:1;
111 };
112
113 extern const struct ossp_arg_size ossp_arg_sizes[OSSP_NR_OPCODES];
114 extern const char *ossp_cmd_str[OSSP_NR_OPCODES];
115 extern const char *ossp_notify_str[OSSP_NR_NOTIFY_OPCODES];
116
117 #endif /* _OSSP_H */