Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * 32bit -> 64bit ioctl wrapper for PCM 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 | /* This file included from pcm_native.c */ |
| 22 | |
| 23 | #include <linux/compat.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 26 | static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | s32 __user *src) |
| 28 | { |
| 29 | snd_pcm_sframes_t delay; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Takashi Iwai | c2c86a9 | 2017-05-10 14:33:44 +0200 | [diff] [blame] | 31 | delay = snd_pcm_delay(substream); |
| 32 | if (delay < 0) |
| 33 | return delay; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | if (put_user(delay, src)) |
| 35 | return -EFAULT; |
Takashi Iwai | c2c86a9 | 2017-05-10 14:33:44 +0200 | [diff] [blame] | 36 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 39 | static int snd_pcm_ioctl_rewind_compat(struct snd_pcm_substream *substream, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | u32 __user *src) |
| 41 | { |
| 42 | snd_pcm_uframes_t frames; |
| 43 | int err; |
| 44 | |
| 45 | if (get_user(frames, src)) |
| 46 | return -EFAULT; |
| 47 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 48 | err = snd_pcm_playback_rewind(substream, frames); |
| 49 | else |
| 50 | err = snd_pcm_capture_rewind(substream, frames); |
| 51 | if (put_user(err, src)) |
| 52 | return -EFAULT; |
| 53 | return err < 0 ? err : 0; |
| 54 | } |
| 55 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 56 | static int snd_pcm_ioctl_forward_compat(struct snd_pcm_substream *substream, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | u32 __user *src) |
| 58 | { |
| 59 | snd_pcm_uframes_t frames; |
| 60 | int err; |
| 61 | |
| 62 | if (get_user(frames, src)) |
| 63 | return -EFAULT; |
| 64 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 65 | err = snd_pcm_playback_forward(substream, frames); |
| 66 | else |
| 67 | err = snd_pcm_capture_forward(substream, frames); |
| 68 | if (put_user(err, src)) |
| 69 | return -EFAULT; |
| 70 | return err < 0 ? err : 0; |
| 71 | } |
| 72 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 73 | struct snd_pcm_hw_params32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | u32 flags; |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 75 | struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; /* this must be identical */ |
| 76 | struct snd_mask mres[5]; /* reserved masks */ |
| 77 | struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; |
| 78 | struct snd_interval ires[9]; /* reserved intervals */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | u32 rmask; |
| 80 | u32 cmask; |
| 81 | u32 info; |
| 82 | u32 msbits; |
| 83 | u32 rate_num; |
| 84 | u32 rate_den; |
| 85 | u32 fifo_size; |
| 86 | unsigned char reserved[64]; |
| 87 | }; |
| 88 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 89 | struct snd_pcm_sw_params32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | s32 tstamp_mode; |
| 91 | u32 period_step; |
| 92 | u32 sleep_min; |
| 93 | u32 avail_min; |
| 94 | u32 xfer_align; |
| 95 | u32 start_threshold; |
| 96 | u32 stop_threshold; |
| 97 | u32 silence_threshold; |
| 98 | u32 silence_size; |
| 99 | u32 boundary; |
Takashi Iwai | e58c295 | 2014-07-16 18:07:30 +0200 | [diff] [blame] | 100 | u32 proto; |
| 101 | u32 tstamp_type; |
| 102 | unsigned char reserved[56]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | }; |
| 104 | |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 105 | /* recalcuate the boundary within 32bit */ |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 106 | static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 107 | { |
| 108 | snd_pcm_uframes_t boundary; |
| 109 | |
| 110 | if (! runtime->buffer_size) |
| 111 | return 0; |
| 112 | boundary = runtime->buffer_size; |
| 113 | while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) |
| 114 | boundary *= 2; |
| 115 | return boundary; |
| 116 | } |
| 117 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 118 | static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream, |
| 119 | struct snd_pcm_sw_params32 __user *src) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 121 | struct snd_pcm_sw_params params; |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 122 | snd_pcm_uframes_t boundary; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | int err; |
| 124 | |
| 125 | memset(¶ms, 0, sizeof(params)); |
| 126 | if (get_user(params.tstamp_mode, &src->tstamp_mode) || |
| 127 | get_user(params.period_step, &src->period_step) || |
| 128 | get_user(params.sleep_min, &src->sleep_min) || |
| 129 | get_user(params.avail_min, &src->avail_min) || |
| 130 | get_user(params.xfer_align, &src->xfer_align) || |
| 131 | get_user(params.start_threshold, &src->start_threshold) || |
| 132 | get_user(params.stop_threshold, &src->stop_threshold) || |
| 133 | get_user(params.silence_threshold, &src->silence_threshold) || |
Takashi Iwai | e58c295 | 2014-07-16 18:07:30 +0200 | [diff] [blame] | 134 | get_user(params.silence_size, &src->silence_size) || |
| 135 | get_user(params.tstamp_type, &src->tstamp_type) || |
| 136 | get_user(params.proto, &src->proto)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | return -EFAULT; |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 138 | /* |
| 139 | * Check silent_size parameter. Since we have 64bit boundary, |
| 140 | * silence_size must be compared with the 32bit boundary. |
| 141 | */ |
| 142 | boundary = recalculate_boundary(substream->runtime); |
| 143 | if (boundary && params.silence_size >= boundary) |
| 144 | params.silence_size = substream->runtime->boundary; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | err = snd_pcm_sw_params(substream, ¶ms); |
| 146 | if (err < 0) |
| 147 | return err; |
Takashi Iwai | 7153a55 | 2005-08-25 19:51:47 +0200 | [diff] [blame] | 148 | if (boundary && put_user(boundary, &src->boundary)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | return -EFAULT; |
| 150 | return err; |
| 151 | } |
| 152 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 153 | struct snd_pcm_channel_info32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | u32 channel; |
| 155 | u32 offset; |
| 156 | u32 first; |
| 157 | u32 step; |
| 158 | }; |
| 159 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 160 | static int snd_pcm_ioctl_channel_info_compat(struct snd_pcm_substream *substream, |
| 161 | struct snd_pcm_channel_info32 __user *src) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 163 | struct snd_pcm_channel_info info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | int err; |
| 165 | |
| 166 | if (get_user(info.channel, &src->channel) || |
| 167 | get_user(info.offset, &src->offset) || |
| 168 | get_user(info.first, &src->first) || |
| 169 | get_user(info.step, &src->step)) |
| 170 | return -EFAULT; |
| 171 | err = snd_pcm_channel_info(substream, &info); |
| 172 | if (err < 0) |
| 173 | return err; |
| 174 | if (put_user(info.channel, &src->channel) || |
| 175 | put_user(info.offset, &src->offset) || |
| 176 | put_user(info.first, &src->first) || |
| 177 | put_user(info.step, &src->step)) |
| 178 | return -EFAULT; |
| 179 | return err; |
| 180 | } |
| 181 | |
Takashi Iwai | 513ace7 | 2016-02-28 11:23:09 +0100 | [diff] [blame] | 182 | #ifdef CONFIG_X86_X32 |
| 183 | /* X32 ABI has the same struct as x86-64 for snd_pcm_channel_info */ |
| 184 | static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, |
| 185 | struct snd_pcm_channel_info __user *src); |
| 186 | #define snd_pcm_ioctl_channel_info_x32(s, p) \ |
| 187 | snd_pcm_channel_info_user(s, p) |
| 188 | #endif /* CONFIG_X86_X32 */ |
| 189 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 190 | struct snd_pcm_status32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | s32 state; |
| 192 | struct compat_timespec trigger_tstamp; |
| 193 | struct compat_timespec tstamp; |
| 194 | u32 appl_ptr; |
| 195 | u32 hw_ptr; |
| 196 | s32 delay; |
| 197 | u32 avail; |
| 198 | u32 avail_max; |
| 199 | u32 overrange; |
| 200 | s32 suspended_state; |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 201 | u32 audio_tstamp_data; |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 202 | struct compat_timespec audio_tstamp; |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 203 | struct compat_timespec driver_tstamp; |
| 204 | u32 audio_tstamp_accuracy; |
| 205 | unsigned char reserved[52-2*sizeof(struct compat_timespec)]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } __attribute__((packed)); |
| 207 | |
| 208 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 209 | static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream, |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 210 | struct snd_pcm_status32 __user *src, |
| 211 | bool ext) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 213 | struct snd_pcm_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | int err; |
| 215 | |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 216 | memset(&status, 0, sizeof(status)); |
| 217 | /* |
| 218 | * with extension, parameters are read/write, |
| 219 | * get audio_tstamp_data from user, |
| 220 | * ignore rest of status structure |
| 221 | */ |
| 222 | if (ext && get_user(status.audio_tstamp_data, |
| 223 | (u32 __user *)(&src->audio_tstamp_data))) |
| 224 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | err = snd_pcm_status(substream, &status); |
| 226 | if (err < 0) |
| 227 | return err; |
| 228 | |
Takashi Iwai | 317168d | 2014-10-28 12:42:19 +0100 | [diff] [blame] | 229 | if (clear_user(src, sizeof(*src))) |
| 230 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | if (put_user(status.state, &src->state) || |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 232 | compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || |
| 233 | compat_put_timespec(&status.tstamp, &src->tstamp) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | put_user(status.appl_ptr, &src->appl_ptr) || |
| 235 | put_user(status.hw_ptr, &src->hw_ptr) || |
| 236 | put_user(status.delay, &src->delay) || |
| 237 | put_user(status.avail, &src->avail) || |
| 238 | put_user(status.avail_max, &src->avail_max) || |
| 239 | put_user(status.overrange, &src->overrange) || |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 240 | put_user(status.suspended_state, &src->suspended_state) || |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 241 | put_user(status.audio_tstamp_data, &src->audio_tstamp_data) || |
| 242 | compat_put_timespec(&status.audio_tstamp, &src->audio_tstamp) || |
| 243 | compat_put_timespec(&status.driver_tstamp, &src->driver_tstamp) || |
| 244 | put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | return -EFAULT; |
| 246 | |
| 247 | return err; |
| 248 | } |
| 249 | |
Takashi Iwai | 513ace7 | 2016-02-28 11:23:09 +0100 | [diff] [blame] | 250 | #ifdef CONFIG_X86_X32 |
| 251 | /* X32 ABI has 64bit timespec and 64bit alignment */ |
| 252 | struct snd_pcm_status_x32 { |
| 253 | s32 state; |
| 254 | u32 rsvd; /* alignment */ |
| 255 | struct timespec trigger_tstamp; |
| 256 | struct timespec tstamp; |
| 257 | u32 appl_ptr; |
| 258 | u32 hw_ptr; |
| 259 | s32 delay; |
| 260 | u32 avail; |
| 261 | u32 avail_max; |
| 262 | u32 overrange; |
| 263 | s32 suspended_state; |
| 264 | u32 audio_tstamp_data; |
| 265 | struct timespec audio_tstamp; |
| 266 | struct timespec driver_tstamp; |
| 267 | u32 audio_tstamp_accuracy; |
| 268 | unsigned char reserved[52-2*sizeof(struct timespec)]; |
| 269 | } __packed; |
| 270 | |
| 271 | #define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst)) |
| 272 | |
| 273 | static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream, |
| 274 | struct snd_pcm_status_x32 __user *src, |
| 275 | bool ext) |
| 276 | { |
| 277 | struct snd_pcm_status status; |
| 278 | int err; |
| 279 | |
| 280 | memset(&status, 0, sizeof(status)); |
| 281 | /* |
| 282 | * with extension, parameters are read/write, |
| 283 | * get audio_tstamp_data from user, |
| 284 | * ignore rest of status structure |
| 285 | */ |
| 286 | if (ext && get_user(status.audio_tstamp_data, |
| 287 | (u32 __user *)(&src->audio_tstamp_data))) |
| 288 | return -EFAULT; |
| 289 | err = snd_pcm_status(substream, &status); |
| 290 | if (err < 0) |
| 291 | return err; |
| 292 | |
| 293 | if (clear_user(src, sizeof(*src))) |
| 294 | return -EFAULT; |
| 295 | if (put_user(status.state, &src->state) || |
| 296 | put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || |
| 297 | put_timespec(&status.tstamp, &src->tstamp) || |
| 298 | put_user(status.appl_ptr, &src->appl_ptr) || |
| 299 | put_user(status.hw_ptr, &src->hw_ptr) || |
| 300 | put_user(status.delay, &src->delay) || |
| 301 | put_user(status.avail, &src->avail) || |
| 302 | put_user(status.avail_max, &src->avail_max) || |
| 303 | put_user(status.overrange, &src->overrange) || |
| 304 | put_user(status.suspended_state, &src->suspended_state) || |
| 305 | put_user(status.audio_tstamp_data, &src->audio_tstamp_data) || |
| 306 | put_timespec(&status.audio_tstamp, &src->audio_tstamp) || |
| 307 | put_timespec(&status.driver_tstamp, &src->driver_tstamp) || |
| 308 | put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy)) |
| 309 | return -EFAULT; |
| 310 | |
| 311 | return err; |
| 312 | } |
| 313 | #endif /* CONFIG_X86_X32 */ |
| 314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | /* both for HW_PARAMS and HW_REFINE */ |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 316 | static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | int refine, |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 318 | struct snd_pcm_hw_params32 __user *data32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 320 | struct snd_pcm_hw_params *data; |
| 321 | struct snd_pcm_runtime *runtime; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | int err; |
| 323 | |
| 324 | if (! (runtime = substream->runtime)) |
| 325 | return -ENOTTY; |
| 326 | |
Nicolas Boichat | 43c54b8 | 2016-01-18 21:35:00 +0800 | [diff] [blame] | 327 | data = kmalloc(sizeof(*data), GFP_KERNEL); |
| 328 | if (!data) |
| 329 | return -ENOMEM; |
| 330 | |
| 331 | /* only fifo_size (RO from userspace) is different, so just copy all */ |
| 332 | if (copy_from_user(data, data32, sizeof(*data32))) { |
| 333 | err = -EFAULT; |
| 334 | goto error; |
| 335 | } |
Li Zefan | ef44a1e | 2009-04-10 09:43:08 +0800 | [diff] [blame] | 336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | if (refine) |
| 338 | err = snd_pcm_hw_refine(substream, data); |
| 339 | else |
| 340 | err = snd_pcm_hw_params(substream, data); |
| 341 | if (err < 0) |
| 342 | goto error; |
| 343 | if (copy_to_user(data32, data, sizeof(*data32)) || |
| 344 | put_user(data->fifo_size, &data32->fifo_size)) { |
| 345 | err = -EFAULT; |
| 346 | goto error; |
| 347 | } |
| 348 | |
Takashi Iwai | 7153a55 | 2005-08-25 19:51:47 +0200 | [diff] [blame] | 349 | if (! refine) { |
| 350 | unsigned int new_boundary = recalculate_boundary(runtime); |
| 351 | if (new_boundary) |
| 352 | runtime->boundary = new_boundary; |
| 353 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | error: |
| 355 | kfree(data); |
| 356 | return err; |
| 357 | } |
| 358 | |
| 359 | |
| 360 | /* |
| 361 | */ |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 362 | struct snd_xferi32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | s32 result; |
| 364 | u32 buf; |
| 365 | u32 frames; |
| 366 | }; |
| 367 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 368 | static int snd_pcm_ioctl_xferi_compat(struct snd_pcm_substream *substream, |
| 369 | int dir, struct snd_xferi32 __user *data32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | { |
| 371 | compat_caddr_t buf; |
| 372 | u32 frames; |
| 373 | int err; |
| 374 | |
| 375 | if (! substream->runtime) |
| 376 | return -ENOTTY; |
| 377 | if (substream->stream != dir) |
| 378 | return -EINVAL; |
| 379 | if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) |
| 380 | return -EBADFD; |
| 381 | |
| 382 | if (get_user(buf, &data32->buf) || |
| 383 | get_user(frames, &data32->frames)) |
| 384 | return -EFAULT; |
| 385 | |
| 386 | if (dir == SNDRV_PCM_STREAM_PLAYBACK) |
| 387 | err = snd_pcm_lib_write(substream, compat_ptr(buf), frames); |
| 388 | else |
| 389 | err = snd_pcm_lib_read(substream, compat_ptr(buf), frames); |
| 390 | if (err < 0) |
| 391 | return err; |
| 392 | /* copy the result */ |
| 393 | if (put_user(err, &data32->result)) |
| 394 | return -EFAULT; |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | |
| 399 | /* snd_xfern needs remapping of bufs */ |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 400 | struct snd_xfern32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | s32 result; |
| 402 | u32 bufs; /* this is void **; */ |
| 403 | u32 frames; |
| 404 | }; |
| 405 | |
| 406 | /* |
| 407 | * xfern ioctl nees to copy (up to) 128 pointers on stack. |
| 408 | * although we may pass the copied pointers through f_op->ioctl, but the ioctl |
| 409 | * handler there expands again the same 128 pointers on stack, so it is better |
| 410 | * to handle the function (calling pcm_readv/writev) directly in this handler. |
| 411 | */ |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 412 | static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, |
| 413 | int dir, struct snd_xfern32 __user *data32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { |
| 415 | compat_caddr_t buf; |
| 416 | compat_caddr_t __user *bufptr; |
| 417 | u32 frames; |
| 418 | void __user **bufs; |
| 419 | int err, ch, i; |
| 420 | |
| 421 | if (! substream->runtime) |
| 422 | return -ENOTTY; |
| 423 | if (substream->stream != dir) |
| 424 | return -EINVAL; |
| 425 | |
| 426 | if ((ch = substream->runtime->channels) > 128) |
| 427 | return -EINVAL; |
| 428 | if (get_user(buf, &data32->bufs) || |
| 429 | get_user(frames, &data32->frames)) |
| 430 | return -EFAULT; |
| 431 | bufptr = compat_ptr(buf); |
| 432 | bufs = kmalloc(sizeof(void __user *) * ch, GFP_KERNEL); |
| 433 | if (bufs == NULL) |
| 434 | return -ENOMEM; |
| 435 | for (i = 0; i < ch; i++) { |
| 436 | u32 ptr; |
| 437 | if (get_user(ptr, bufptr)) { |
| 438 | kfree(bufs); |
| 439 | return -EFAULT; |
| 440 | } |
Julia Lawall | ca9380f | 2011-07-28 14:46:05 +0200 | [diff] [blame] | 441 | bufs[i] = compat_ptr(ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | bufptr++; |
| 443 | } |
| 444 | if (dir == SNDRV_PCM_STREAM_PLAYBACK) |
| 445 | err = snd_pcm_lib_writev(substream, bufs, frames); |
| 446 | else |
| 447 | err = snd_pcm_lib_readv(substream, bufs, frames); |
| 448 | if (err >= 0) { |
| 449 | if (put_user(err, &data32->result)) |
| 450 | err = -EFAULT; |
| 451 | } |
| 452 | kfree(bufs); |
| 453 | return err; |
| 454 | } |
| 455 | |
| 456 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 457 | struct snd_pcm_mmap_status32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | s32 state; |
| 459 | s32 pad1; |
| 460 | u32 hw_ptr; |
| 461 | struct compat_timespec tstamp; |
| 462 | s32 suspended_state; |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 463 | struct compat_timespec audio_tstamp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | } __attribute__((packed)); |
| 465 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 466 | struct snd_pcm_mmap_control32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | u32 appl_ptr; |
| 468 | u32 avail_min; |
| 469 | }; |
| 470 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 471 | struct snd_pcm_sync_ptr32 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | u32 flags; |
| 473 | union { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 474 | struct snd_pcm_mmap_status32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | unsigned char reserved[64]; |
| 476 | } s; |
| 477 | union { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 478 | struct snd_pcm_mmap_control32 control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | unsigned char reserved[64]; |
| 480 | } c; |
| 481 | } __attribute__((packed)); |
| 482 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 483 | static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, |
| 484 | struct snd_pcm_sync_ptr32 __user *src) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 486 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 487 | volatile struct snd_pcm_mmap_status *status; |
| 488 | volatile struct snd_pcm_mmap_control *control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | u32 sflags; |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 490 | struct snd_pcm_mmap_control scontrol; |
| 491 | struct snd_pcm_mmap_status sstatus; |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 492 | snd_pcm_uframes_t boundary; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | int err; |
| 494 | |
Takashi Iwai | 7eaa943 | 2008-08-08 17:09:09 +0200 | [diff] [blame] | 495 | if (snd_BUG_ON(!runtime)) |
| 496 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
| 498 | if (get_user(sflags, &src->flags) || |
| 499 | get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || |
| 500 | get_user(scontrol.avail_min, &src->c.control.avail_min)) |
| 501 | return -EFAULT; |
| 502 | if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) { |
| 503 | err = snd_pcm_hwsync(substream); |
| 504 | if (err < 0) |
| 505 | return err; |
| 506 | } |
| 507 | status = runtime->status; |
| 508 | control = runtime->control; |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 509 | boundary = recalculate_boundary(runtime); |
Takashi Iwai | 7153a55 | 2005-08-25 19:51:47 +0200 | [diff] [blame] | 510 | if (! boundary) |
| 511 | boundary = 0x7fffffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | snd_pcm_stream_lock_irq(substream); |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 513 | /* FIXME: we should consider the boundary for the sync from app */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) |
| 515 | control->appl_ptr = scontrol.appl_ptr; |
| 516 | else |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 517 | scontrol.appl_ptr = control->appl_ptr % boundary; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) |
| 519 | control->avail_min = scontrol.avail_min; |
| 520 | else |
| 521 | scontrol.avail_min = control->avail_min; |
| 522 | sstatus.state = status->state; |
Takashi Iwai | b271131 | 2005-08-15 15:01:10 +0200 | [diff] [blame] | 523 | sstatus.hw_ptr = status->hw_ptr % boundary; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | sstatus.tstamp = status->tstamp; |
| 525 | sstatus.suspended_state = status->suspended_state; |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 526 | sstatus.audio_tstamp = status->audio_tstamp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | snd_pcm_stream_unlock_irq(substream); |
| 528 | if (put_user(sstatus.state, &src->s.status.state) || |
| 529 | put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 530 | compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | put_user(sstatus.suspended_state, &src->s.status.suspended_state) || |
Pierre-Louis Bossart | 4eeaaea | 2012-10-22 16:42:15 -0500 | [diff] [blame] | 532 | compat_put_timespec(&sstatus.audio_tstamp, |
| 533 | &src->s.status.audio_tstamp) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || |
| 535 | put_user(scontrol.avail_min, &src->c.control.avail_min)) |
| 536 | return -EFAULT; |
| 537 | |
| 538 | return 0; |
| 539 | } |
| 540 | |
Takashi Iwai | 513ace7 | 2016-02-28 11:23:09 +0100 | [diff] [blame] | 541 | #ifdef CONFIG_X86_X32 |
| 542 | /* X32 ABI has 64bit timespec and 64bit alignment */ |
| 543 | struct snd_pcm_mmap_status_x32 { |
| 544 | s32 state; |
| 545 | s32 pad1; |
| 546 | u32 hw_ptr; |
| 547 | u32 pad2; /* alignment */ |
| 548 | struct timespec tstamp; |
| 549 | s32 suspended_state; |
Baolin Wang | c9adcdb | 2017-09-21 14:03:29 +0800 | [diff] [blame] | 550 | s32 pad3; |
Takashi Iwai | 513ace7 | 2016-02-28 11:23:09 +0100 | [diff] [blame] | 551 | struct timespec audio_tstamp; |
| 552 | } __packed; |
| 553 | |
| 554 | struct snd_pcm_mmap_control_x32 { |
| 555 | u32 appl_ptr; |
| 556 | u32 avail_min; |
| 557 | }; |
| 558 | |
| 559 | struct snd_pcm_sync_ptr_x32 { |
| 560 | u32 flags; |
| 561 | u32 rsvd; /* alignment */ |
| 562 | union { |
| 563 | struct snd_pcm_mmap_status_x32 status; |
| 564 | unsigned char reserved[64]; |
| 565 | } s; |
| 566 | union { |
| 567 | struct snd_pcm_mmap_control_x32 control; |
| 568 | unsigned char reserved[64]; |
| 569 | } c; |
| 570 | } __packed; |
| 571 | |
| 572 | static int snd_pcm_ioctl_sync_ptr_x32(struct snd_pcm_substream *substream, |
| 573 | struct snd_pcm_sync_ptr_x32 __user *src) |
| 574 | { |
| 575 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 576 | volatile struct snd_pcm_mmap_status *status; |
| 577 | volatile struct snd_pcm_mmap_control *control; |
| 578 | u32 sflags; |
| 579 | struct snd_pcm_mmap_control scontrol; |
| 580 | struct snd_pcm_mmap_status sstatus; |
| 581 | snd_pcm_uframes_t boundary; |
| 582 | int err; |
| 583 | |
| 584 | if (snd_BUG_ON(!runtime)) |
| 585 | return -EINVAL; |
| 586 | |
| 587 | if (get_user(sflags, &src->flags) || |
| 588 | get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || |
| 589 | get_user(scontrol.avail_min, &src->c.control.avail_min)) |
| 590 | return -EFAULT; |
| 591 | if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) { |
| 592 | err = snd_pcm_hwsync(substream); |
| 593 | if (err < 0) |
| 594 | return err; |
| 595 | } |
| 596 | status = runtime->status; |
| 597 | control = runtime->control; |
| 598 | boundary = recalculate_boundary(runtime); |
| 599 | if (!boundary) |
| 600 | boundary = 0x7fffffff; |
| 601 | snd_pcm_stream_lock_irq(substream); |
| 602 | /* FIXME: we should consider the boundary for the sync from app */ |
| 603 | if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) |
| 604 | control->appl_ptr = scontrol.appl_ptr; |
| 605 | else |
| 606 | scontrol.appl_ptr = control->appl_ptr % boundary; |
| 607 | if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) |
| 608 | control->avail_min = scontrol.avail_min; |
| 609 | else |
| 610 | scontrol.avail_min = control->avail_min; |
| 611 | sstatus.state = status->state; |
| 612 | sstatus.hw_ptr = status->hw_ptr % boundary; |
| 613 | sstatus.tstamp = status->tstamp; |
| 614 | sstatus.suspended_state = status->suspended_state; |
| 615 | sstatus.audio_tstamp = status->audio_tstamp; |
| 616 | snd_pcm_stream_unlock_irq(substream); |
| 617 | if (put_user(sstatus.state, &src->s.status.state) || |
| 618 | put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || |
| 619 | put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || |
| 620 | put_user(sstatus.suspended_state, &src->s.status.suspended_state) || |
| 621 | put_timespec(&sstatus.audio_tstamp, &src->s.status.audio_tstamp) || |
| 622 | put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || |
| 623 | put_user(scontrol.avail_min, &src->c.control.avail_min)) |
| 624 | return -EFAULT; |
| 625 | |
| 626 | return 0; |
| 627 | } |
| 628 | #endif /* CONFIG_X86_X32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | |
| 630 | /* |
| 631 | */ |
| 632 | enum { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 633 | SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct snd_pcm_hw_params32), |
| 634 | SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct snd_pcm_hw_params32), |
| 635 | SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct snd_pcm_sw_params32), |
| 636 | SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct snd_pcm_status32), |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 637 | SNDRV_PCM_IOCTL_STATUS_EXT32 = _IOWR('A', 0x24, struct snd_pcm_status32), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | SNDRV_PCM_IOCTL_DELAY32 = _IOR('A', 0x21, s32), |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 639 | SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct snd_pcm_channel_info32), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | SNDRV_PCM_IOCTL_REWIND32 = _IOW('A', 0x46, u32), |
| 641 | SNDRV_PCM_IOCTL_FORWARD32 = _IOW('A', 0x49, u32), |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 642 | SNDRV_PCM_IOCTL_WRITEI_FRAMES32 = _IOW('A', 0x50, struct snd_xferi32), |
| 643 | SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct snd_xferi32), |
| 644 | SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32), |
| 645 | SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32), |
| 646 | SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32), |
Takashi Iwai | 513ace7 | 2016-02-28 11:23:09 +0100 | [diff] [blame] | 647 | #ifdef CONFIG_X86_X32 |
| 648 | SNDRV_PCM_IOCTL_CHANNEL_INFO_X32 = _IOR('A', 0x32, struct snd_pcm_channel_info), |
| 649 | SNDRV_PCM_IOCTL_STATUS_X32 = _IOR('A', 0x20, struct snd_pcm_status_x32), |
| 650 | SNDRV_PCM_IOCTL_STATUS_EXT_X32 = _IOWR('A', 0x24, struct snd_pcm_status_x32), |
| 651 | SNDRV_PCM_IOCTL_SYNC_PTR_X32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr_x32), |
| 652 | #endif /* CONFIG_X86_X32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | }; |
| 654 | |
| 655 | static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) |
| 656 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 657 | struct snd_pcm_file *pcm_file; |
| 658 | struct snd_pcm_substream *substream; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | void __user *argp = compat_ptr(arg); |
| 660 | |
| 661 | pcm_file = file->private_data; |
| 662 | if (! pcm_file) |
| 663 | return -ENOTTY; |
| 664 | substream = pcm_file->substream; |
| 665 | if (! substream) |
| 666 | return -ENOTTY; |
| 667 | |
| 668 | /* |
| 669 | * When PCM is used on 32bit mode, we need to disable |
| 670 | * mmap of PCM status/control records because of the size |
| 671 | * incompatibility. |
| 672 | */ |
Takashi Iwai | 548a648 | 2006-07-31 16:51:51 +0200 | [diff] [blame] | 673 | pcm_file->no_compat_mmap = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | |
| 675 | switch (cmd) { |
| 676 | case SNDRV_PCM_IOCTL_PVERSION: |
| 677 | case SNDRV_PCM_IOCTL_INFO: |
Takashi Iwai | 5a7f261 | 2007-12-17 11:44:25 +0100 | [diff] [blame] | 678 | case SNDRV_PCM_IOCTL_TSTAMP: |
Takashi Iwai | 6b587ef | 2007-12-14 12:10:26 +0100 | [diff] [blame] | 679 | case SNDRV_PCM_IOCTL_TTSTAMP: |
Takashi Iwai | 4b671f5 | 2017-06-19 23:11:54 +0200 | [diff] [blame] | 680 | case SNDRV_PCM_IOCTL_USER_PVERSION: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | case SNDRV_PCM_IOCTL_HWSYNC: |
| 682 | case SNDRV_PCM_IOCTL_PREPARE: |
| 683 | case SNDRV_PCM_IOCTL_RESET: |
| 684 | case SNDRV_PCM_IOCTL_START: |
| 685 | case SNDRV_PCM_IOCTL_DROP: |
| 686 | case SNDRV_PCM_IOCTL_DRAIN: |
| 687 | case SNDRV_PCM_IOCTL_PAUSE: |
| 688 | case SNDRV_PCM_IOCTL_HW_FREE: |
| 689 | case SNDRV_PCM_IOCTL_RESUME: |
| 690 | case SNDRV_PCM_IOCTL_XRUN: |
| 691 | case SNDRV_PCM_IOCTL_LINK: |
| 692 | case SNDRV_PCM_IOCTL_UNLINK: |
Takashi Iwai | 67616fe | 2017-08-30 15:39:32 +0200 | [diff] [blame] | 693 | return snd_pcm_common_ioctl(file, substream, cmd, argp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | case SNDRV_PCM_IOCTL_HW_REFINE32: |
| 695 | return snd_pcm_ioctl_hw_params_compat(substream, 1, argp); |
| 696 | case SNDRV_PCM_IOCTL_HW_PARAMS32: |
| 697 | return snd_pcm_ioctl_hw_params_compat(substream, 0, argp); |
| 698 | case SNDRV_PCM_IOCTL_SW_PARAMS32: |
| 699 | return snd_pcm_ioctl_sw_params_compat(substream, argp); |
| 700 | case SNDRV_PCM_IOCTL_STATUS32: |
Pierre-Louis Bossart | 5442a73 | 2015-02-13 15:14:05 -0600 | [diff] [blame] | 701 | return snd_pcm_status_user_compat(substream, argp, false); |
| 702 | case SNDRV_PCM_IOCTL_STATUS_EXT32: |
| 703 | return snd_pcm_status_user_compat(substream, argp, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | case SNDRV_PCM_IOCTL_SYNC_PTR32: |
| 705 | return snd_pcm_ioctl_sync_ptr_compat(substream, argp); |
| 706 | case SNDRV_PCM_IOCTL_CHANNEL_INFO32: |
| 707 | return snd_pcm_ioctl_channel_info_compat(substream, argp); |
| 708 | case SNDRV_PCM_IOCTL_WRITEI_FRAMES32: |
| 709 | return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp); |
| 710 | case SNDRV_PCM_IOCTL_READI_FRAMES32: |
| 711 | return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_CAPTURE, argp); |
| 712 | case SNDRV_PCM_IOCTL_WRITEN_FRAMES32: |
| 713 | return snd_pcm_ioctl_xfern_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp); |
| 714 | case SNDRV_PCM_IOCTL_READN_FRAMES32: |
| 715 | return snd_pcm_ioctl_xfern_compat(substream, SNDRV_PCM_STREAM_CAPTURE, argp); |
| 716 | case SNDRV_PCM_IOCTL_DELAY32: |
| 717 | return snd_pcm_ioctl_delay_compat(substream, argp); |
| 718 | case SNDRV_PCM_IOCTL_REWIND32: |
| 719 | return snd_pcm_ioctl_rewind_compat(substream, argp); |
| 720 | case SNDRV_PCM_IOCTL_FORWARD32: |
| 721 | return snd_pcm_ioctl_forward_compat(substream, argp); |
Takashi Iwai | 513ace7 | 2016-02-28 11:23:09 +0100 | [diff] [blame] | 722 | #ifdef CONFIG_X86_X32 |
| 723 | case SNDRV_PCM_IOCTL_STATUS_X32: |
| 724 | return snd_pcm_status_user_x32(substream, argp, false); |
| 725 | case SNDRV_PCM_IOCTL_STATUS_EXT_X32: |
| 726 | return snd_pcm_status_user_x32(substream, argp, true); |
| 727 | case SNDRV_PCM_IOCTL_SYNC_PTR_X32: |
| 728 | return snd_pcm_ioctl_sync_ptr_x32(substream, argp); |
| 729 | case SNDRV_PCM_IOCTL_CHANNEL_INFO_X32: |
| 730 | return snd_pcm_ioctl_channel_info_x32(substream, argp); |
| 731 | #endif /* CONFIG_X86_X32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | return -ENOIOCTLCMD; |
| 735 | } |