vserver 1.9.5.x5
[linux-2.6.git] / sound / core / ioctl32 / rawmidi32.c
1 /*
2  *   32bit -> 64bit ioctl wrapper for raw MIDI 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 <linux/compat.h>
25 #include <sound/core.h>
26 #include <sound/rawmidi.h>
27 #include <asm/uaccess.h>
28 #include "ioctl32.h"
29
30 struct sndrv_rawmidi_params32 {
31         s32 stream;
32         u32 buffer_size;
33         u32 avail_min;
34         unsigned int no_active_sensing; /* avoid bit-field */
35         unsigned char reserved[16];
36 } __attribute__((packed));
37
38 #define CVT_sndrv_rawmidi_params()\
39 {\
40         COPY(stream);\
41         COPY_CVT(buffer_size);\
42         COPY_CVT(avail_min);\
43         if (copy_in_user(((size_t __user *)&dst->avail_min + 1),\
44                          ((size_t __user *)&src->avail_min + 1), 4)) \
45                 return -EFAULT;\
46 }
47
48 struct sndrv_rawmidi_status32 {
49         s32 stream;
50         struct compat_timespec tstamp;
51         u32 avail;
52         u32 xruns;
53         unsigned char reserved[16];
54 } __attribute__((packed));
55
56 #define CVT_sndrv_rawmidi_status()\
57 {\
58         COPY(stream);\
59         COPY_CVT(tstamp.tv_sec);\
60         COPY_CVT(tstamp.tv_nsec);\
61         COPY_CVT(avail);\
62         COPY_CVT(xruns);\
63 }
64
65 DEFINE_ALSA_IOCTL(rawmidi_params);
66 DEFINE_ALSA_IOCTL(rawmidi_status);
67
68 DEFINE_ALSA_IOCTL_ENTRY(rawmidi_params, rawmidi_params, SNDRV_RAWMIDI_IOCTL_PARAMS);
69 DEFINE_ALSA_IOCTL_ENTRY(rawmidi_status, rawmidi_status, SNDRV_RAWMIDI_IOCTL_STATUS);
70
71 #define AP(x) snd_ioctl32_##x
72
73 enum {
74         SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct sndrv_rawmidi_params32),
75         SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct sndrv_rawmidi_status32),
76 };
77
78 struct ioctl32_mapper rawmidi_mappers[] = {
79         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_PVERSION),
80         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_INFO),
81         { SNDRV_RAWMIDI_IOCTL_PARAMS32, AP(rawmidi_params) },
82         { SNDRV_RAWMIDI_IOCTL_STATUS32, AP(rawmidi_status) },
83         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_DROP),
84         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_DRAIN),
85
86         MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE),
87         MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_INFO),
88         MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE),
89
90         { 0 },
91 };