ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / sound / core / ioctl32 / timer32.c
1 /*
2  *   32bit -> 64bit ioctl wrapper for timer 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/timer.h>
27 #include <asm/uaccess.h>
28 #include "ioctl32.h"
29
30 struct sndrv_timer_info32 {
31         u32 flags;
32         s32 card;
33         unsigned char id[64];
34         unsigned char name[80];
35         u32 reserved0;
36         u32 resolution;
37         unsigned char reserved[64];
38 };
39
40 #define CVT_sndrv_timer_info()\
41 {\
42         COPY(flags);\
43         COPY(card);\
44         memcpy(dst->id, src->id, sizeof(src->id));\
45         memcpy(dst->name, src->name, sizeof(src->name));\
46         COPY(resolution);\
47 }
48
49 struct sndrv_timer_status32 {
50         struct compat_timespec tstamp;
51         u32 resolution;
52         u32 lost;
53         u32 overrun;
54         u32 queue;
55         unsigned char reserved[64];
56 };
57
58 #define CVT_sndrv_timer_status()\
59 {\
60         COPY(tstamp.tv_sec);\
61         COPY(tstamp.tv_nsec);\
62         COPY(resolution);\
63         COPY(lost);\
64         COPY(overrun);\
65         COPY(queue);\
66 }
67
68 DEFINE_ALSA_IOCTL(timer_info);
69 DEFINE_ALSA_IOCTL(timer_status);
70
71 DEFINE_ALSA_IOCTL_ENTRY(timer_info, timer_info, SNDRV_TIMER_IOCTL_INFO);
72 DEFINE_ALSA_IOCTL_ENTRY(timer_status, timer_status, SNDRV_TIMER_IOCTL_STATUS);
73
74 /*
75  */
76
77 #define AP(x) snd_ioctl32_##x
78
79 enum {
80         SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct sndrv_timer_info32),
81         SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct sndrv_timer_status32),
82 };
83
84 struct ioctl32_mapper timer_mappers[] = {
85         MAP_COMPAT(SNDRV_TIMER_IOCTL_PVERSION),
86         MAP_COMPAT(SNDRV_TIMER_IOCTL_NEXT_DEVICE),
87         MAP_COMPAT(SNDRV_TIMER_IOCTL_SELECT),
88         { SNDRV_TIMER_IOCTL_INFO32, AP(timer_info) },
89         MAP_COMPAT(SNDRV_TIMER_IOCTL_PARAMS),
90         { SNDRV_TIMER_IOCTL_STATUS32, AP(timer_status) },
91 #if 0
92         /* ** FIXME **
93          * The following four entries are disabled because they conflict
94          * with the TCOC* definitions.
95          * Unfortunately, the current ioctl32 wrapper uses a single
96          * hash table for all devices.  Once when the wrapper is fixed
97          * with the table based on devices, they'll be back again.
98          */
99         MAP_COMPAT(SNDRV_TIMER_IOCTL_START),
100         MAP_COMPAT(SNDRV_TIMER_IOCTL_STOP),
101         MAP_COMPAT(SNDRV_TIMER_IOCTL_CONTINUE),
102         MAP_COMPAT(SNDRV_TIMER_IOCTL_PAUSE),
103 #endif
104         { 0 },
105 };