ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / sound / core / ioctl32 / seq32.c
1 /*
2  *   32bit -> 64bit ioctl wrapper for sequencer API
3  *   Copyright (c) by Takashi Iwai <tiwai@suse.de>
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (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 General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18  *
19  */
20
21 #include <sound/driver.h>
22 #include <linux/time.h>
23 #include <linux/fs.h>
24 #include <sound/core.h>
25 #include <sound/timer.h>
26 #include <asm/uaccess.h>
27 #include <sound/asequencer.h>
28 #include "ioctl32.h"
29
30 struct sndrv_seq_port_info32 {
31         struct sndrv_seq_addr addr;     /* client/port numbers */
32         char name[64];                  /* port name */
33
34         u32 capability; /* port capability bits */
35         u32 type;               /* port type bits */
36         s32 midi_channels;              /* channels per MIDI port */
37         s32 midi_voices;                /* voices per MIDI port */
38         s32 synth_voices;               /* voices per SYNTH port */
39
40         s32 read_use;                   /* R/O: subscribers for output (from this port) */
41         s32 write_use;                  /* R/O: subscribers for input (to this port) */
42
43         u32 kernel;                     /* reserved for kernel use (must be NULL) */
44         u32 flags;              /* misc. conditioning */
45         char reserved[60];              /* for future use */
46 };
47
48 #define CVT_sndrv_seq_port_info()\
49 {\
50         COPY(addr);\
51         memcpy(dst->name, src->name, sizeof(dst->name));\
52         COPY(capability);\
53         COPY(type);\
54         COPY(midi_channels);\
55         COPY(midi_voices);\
56         COPY(synth_voices);\
57         COPY(read_use);\
58         COPY(write_use);\
59         COPY(flags);\
60 }
61
62 DEFINE_ALSA_IOCTL(seq_port_info);
63 DEFINE_ALSA_IOCTL_ENTRY(create_port, seq_port_info, SNDRV_SEQ_IOCTL_CREATE_PORT);
64 DEFINE_ALSA_IOCTL_ENTRY(delete_port, seq_port_info, SNDRV_SEQ_IOCTL_DELETE_PORT);
65 DEFINE_ALSA_IOCTL_ENTRY(get_port_info, seq_port_info, SNDRV_SEQ_IOCTL_GET_PORT_INFO);
66 DEFINE_ALSA_IOCTL_ENTRY(set_port_info, seq_port_info, SNDRV_SEQ_IOCTL_SET_PORT_INFO);
67 DEFINE_ALSA_IOCTL_ENTRY(query_next_port, seq_port_info, SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT);
68
69 /*
70  */
71 #define AP(x) snd_ioctl32_##x
72
73 enum {
74   SNDRV_SEQ_IOCTL_CREATE_PORT32 = _IOWR('S', 0x20, struct sndrv_seq_port_info32),
75   SNDRV_SEQ_IOCTL_DELETE_PORT32 = _IOW ('S', 0x21, struct sndrv_seq_port_info32),
76   SNDRV_SEQ_IOCTL_GET_PORT_INFO32 = _IOWR('S', 0x22, struct sndrv_seq_port_info32),
77   SNDRV_SEQ_IOCTL_SET_PORT_INFO32 = _IOW ('S', 0x23, struct sndrv_seq_port_info32),
78   SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT32 = _IOWR('S', 0x52, struct sndrv_seq_port_info32),
79 };
80
81 struct ioctl32_mapper seq_mappers[] = {
82         MAP_COMPAT(SNDRV_SEQ_IOCTL_PVERSION),
83         MAP_COMPAT(SNDRV_SEQ_IOCTL_CLIENT_ID),
84         MAP_COMPAT(SNDRV_SEQ_IOCTL_SYSTEM_INFO),
85         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_CLIENT_INFO),
86         MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_CLIENT_INFO),
87         { SNDRV_SEQ_IOCTL_CREATE_PORT32, AP(create_port) },
88         { SNDRV_SEQ_IOCTL_DELETE_PORT32, AP(delete_port) },
89         { SNDRV_SEQ_IOCTL_GET_PORT_INFO32, AP(get_port_info) },
90         { SNDRV_SEQ_IOCTL_SET_PORT_INFO32, AP(set_port_info) },
91         MAP_COMPAT(SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT),
92         MAP_COMPAT(SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT),
93         MAP_COMPAT(SNDRV_SEQ_IOCTL_CREATE_QUEUE),
94         MAP_COMPAT(SNDRV_SEQ_IOCTL_DELETE_QUEUE),
95         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_INFO),
96         MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_INFO),
97         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE),
98         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS),
99         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO),
100         MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO),
101         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER),
102         MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER),
103         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT),
104         MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT),
105         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_CLIENT_POOL),
106         MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_CLIENT_POOL),
107         MAP_COMPAT(SNDRV_SEQ_IOCTL_REMOVE_EVENTS),
108         MAP_COMPAT(SNDRV_SEQ_IOCTL_QUERY_SUBS),
109         MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION),
110         MAP_COMPAT(SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT),
111         { SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT32, AP(query_next_port) },
112         MAP_COMPAT(SNDRV_SEQ_IOCTL_RUNNING_MODE),
113         { 0 },
114 };