ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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(buffer_size);\
42         COPY(avail_min);\
43         COPY(no_active_sensing);\
44 }
45
46 struct sndrv_rawmidi_status32 {
47         s32 stream;
48         struct compat_timespec tstamp;
49         u32 avail;
50         u32 xruns;
51         unsigned char reserved[16];
52 } __attribute__((packed));
53
54 #define CVT_sndrv_rawmidi_status()\
55 {\
56         COPY(stream);\
57         COPY(tstamp.tv_sec);\
58         COPY(tstamp.tv_nsec);\
59         COPY(avail);\
60         COPY(xruns);\
61 }
62
63 DEFINE_ALSA_IOCTL(rawmidi_params);
64 DEFINE_ALSA_IOCTL(rawmidi_status);
65
66 DEFINE_ALSA_IOCTL_ENTRY(rawmidi_params, rawmidi_params, SNDRV_RAWMIDI_IOCTL_PARAMS);
67 DEFINE_ALSA_IOCTL_ENTRY(rawmidi_status, rawmidi_status, SNDRV_RAWMIDI_IOCTL_STATUS);
68
69 #define AP(x) snd_ioctl32_##x
70
71 enum {
72         SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct sndrv_rawmidi_params32),
73         SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct sndrv_rawmidi_status32),
74 };
75
76 struct ioctl32_mapper rawmidi_mappers[] = {
77         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_PVERSION),
78         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_INFO),
79         { SNDRV_RAWMIDI_IOCTL_PARAMS32, AP(rawmidi_params) },
80         { SNDRV_RAWMIDI_IOCTL_STATUS32, AP(rawmidi_status) },
81         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_DROP),
82         MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_DRAIN),
83
84         MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE),
85         MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_INFO),
86         MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE),
87
88         { 0 },
89 };