2 * 32bit -> 64bit ioctl wrapper for timer API
3 * Copyright (c) by Takashi Iwai <tiwai@suse.de>
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.
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.
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
21 /* This file included from timer.c */
23 #include <linux/compat.h>
25 struct snd_timer_info32
{
29 unsigned char name
[80];
32 unsigned char reserved
[64];
35 static int snd_timer_user_info_compat(struct file
*file
,
36 struct snd_timer_info32 __user
*_info
)
38 struct snd_timer_user
*tu
;
39 struct snd_timer_info32 info
;
42 tu
= file
->private_data
;
45 t
= tu
->timeri
->timer
;
48 memset(&info
, 0, sizeof(info
));
49 info
.card
= t
->card
? t
->card
->number
: -1;
50 if (t
->hw
.flags
& SNDRV_TIMER_HW_SLAVE
)
51 info
.flags
|= SNDRV_TIMER_FLG_SLAVE
;
52 strlcpy(info
.id
, t
->id
, sizeof(info
.id
));
53 strlcpy(info
.name
, t
->name
, sizeof(info
.name
));
54 info
.resolution
= t
->hw
.resolution
;
55 if (copy_to_user(_info
, &info
, sizeof(*_info
)))
60 struct snd_timer_status32
{
61 struct compat_timespec tstamp
;
66 unsigned char reserved
[64];
69 static int snd_timer_user_status_compat(struct file
*file
,
70 struct snd_timer_status32 __user
*_status
)
72 struct snd_timer_user
*tu
;
73 struct snd_timer_status32 status
;
75 tu
= file
->private_data
;
78 memset(&status
, 0, sizeof(status
));
79 status
.tstamp
.tv_sec
= tu
->tstamp
.tv_sec
;
80 status
.tstamp
.tv_nsec
= tu
->tstamp
.tv_nsec
;
81 status
.resolution
= snd_timer_resolution(tu
->timeri
);
82 status
.lost
= tu
->timeri
->lost
;
83 status
.overrun
= tu
->overrun
;
84 spin_lock_irq(&tu
->qlock
);
85 status
.queue
= tu
->qused
;
86 spin_unlock_irq(&tu
->qlock
);
87 if (copy_to_user(_status
, &status
, sizeof(status
)))
93 /* X32 ABI has the same struct as x86-64 */
94 #define snd_timer_user_status_x32(file, s) \
95 snd_timer_user_status(file, s)
96 #endif /* CONFIG_X86_X32 */
102 SNDRV_TIMER_IOCTL_INFO32
= _IOR('T', 0x11, struct snd_timer_info32
),
103 SNDRV_TIMER_IOCTL_STATUS32
= _IOW('T', 0x14, struct snd_timer_status32
),
104 #ifdef CONFIG_X86_X32
105 SNDRV_TIMER_IOCTL_STATUS_X32
= _IOW('T', 0x14, struct snd_timer_status
),
106 #endif /* CONFIG_X86_X32 */
109 static long __snd_timer_user_ioctl_compat(struct file
*file
, unsigned int cmd
,
112 void __user
*argp
= compat_ptr(arg
);
115 case SNDRV_TIMER_IOCTL_PVERSION
:
116 case SNDRV_TIMER_IOCTL_TREAD
:
117 case SNDRV_TIMER_IOCTL_GINFO
:
118 case SNDRV_TIMER_IOCTL_GPARAMS
:
119 case SNDRV_TIMER_IOCTL_GSTATUS
:
120 case SNDRV_TIMER_IOCTL_SELECT
:
121 case SNDRV_TIMER_IOCTL_PARAMS
:
122 case SNDRV_TIMER_IOCTL_START
:
123 case SNDRV_TIMER_IOCTL_START_OLD
:
124 case SNDRV_TIMER_IOCTL_STOP
:
125 case SNDRV_TIMER_IOCTL_STOP_OLD
:
126 case SNDRV_TIMER_IOCTL_CONTINUE
:
127 case SNDRV_TIMER_IOCTL_CONTINUE_OLD
:
128 case SNDRV_TIMER_IOCTL_PAUSE
:
129 case SNDRV_TIMER_IOCTL_PAUSE_OLD
:
130 case SNDRV_TIMER_IOCTL_NEXT_DEVICE
:
131 return __snd_timer_user_ioctl(file
, cmd
, (unsigned long)argp
);
132 case SNDRV_TIMER_IOCTL_INFO32
:
133 return snd_timer_user_info_compat(file
, argp
);
134 case SNDRV_TIMER_IOCTL_STATUS32
:
135 return snd_timer_user_status_compat(file
, argp
);
136 #ifdef CONFIG_X86_X32
137 case SNDRV_TIMER_IOCTL_STATUS_X32
:
138 return snd_timer_user_status_x32(file
, argp
);
139 #endif /* CONFIG_X86_X32 */
144 static long snd_timer_user_ioctl_compat(struct file
*file
, unsigned int cmd
,
147 struct snd_timer_user
*tu
= file
->private_data
;
150 mutex_lock(&tu
->ioctl_lock
);
151 ret
= __snd_timer_user_ioctl_compat(file
, cmd
, arg
);
152 mutex_unlock(&tu
->ioctl_lock
);