Blame view

sound/core/timer_compat.c 3.53 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  /*
   *   32bit -> 64bit ioctl wrapper for timer API
   *   Copyright (c) by Takashi Iwai <tiwai@suse.de>
   *
   *   This program is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License as published by
   *   the Free Software Foundation; either version 2 of the License, or
   *   (at your option) any later version.
   *
   *   This program is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *   GNU General Public License for more details.
   *
   *   You should have received a copy of the GNU General Public License
   *   along with this program; if not, write to the Free Software
   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   *
   */
  
  /* This file included from timer.c */
  
  #include <linux/compat.h>
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
24
  struct snd_timer_info32 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
29
30
31
32
33
34
  	u32 flags;
  	s32 card;
  	unsigned char id[64];
  	unsigned char name[80];
  	u32 reserved0;
  	u32 resolution;
  	unsigned char reserved[64];
  };
  
  static int snd_timer_user_info_compat(struct file *file,
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
35
  				      struct snd_timer_info32 __user *_info)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
  {
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
37
38
39
  	struct snd_timer_user *tu;
  	struct snd_timer_info32 info;
  	struct snd_timer *t;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
  
  	tu = file->private_data;
7eaa943c8   Takashi Iwai   ALSA: Kill snd_as...
42
43
  	if (snd_BUG_ON(!tu->timeri))
  		return -ENXIO;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
  	t = tu->timeri->timer;
7eaa943c8   Takashi Iwai   ALSA: Kill snd_as...
45
46
  	if (snd_BUG_ON(!t))
  		return -ENXIO;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
49
50
51
52
53
54
55
56
57
  	memset(&info, 0, sizeof(info));
  	info.card = t->card ? t->card->number : -1;
  	if (t->hw.flags & SNDRV_TIMER_HW_SLAVE)
  		info.flags |= SNDRV_TIMER_FLG_SLAVE;
  	strlcpy(info.id, t->id, sizeof(info.id));
  	strlcpy(info.name, t->name, sizeof(info.name));
  	info.resolution = t->hw.resolution;
  	if (copy_to_user(_info, &info, sizeof(*_info)))
  		return -EFAULT;
  	return 0;
  }
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
58
  struct snd_timer_status32 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
61
62
63
64
65
66
67
  	struct compat_timespec tstamp;
  	u32 resolution;
  	u32 lost;
  	u32 overrun;
  	u32 queue;
  	unsigned char reserved[64];
  };
  
  static int snd_timer_user_status_compat(struct file *file,
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
68
  					struct snd_timer_status32 __user *_status)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
  {
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
70
71
  	struct snd_timer_user *tu;
  	struct snd_timer_status status;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
  	
  	tu = file->private_data;
7eaa943c8   Takashi Iwai   ALSA: Kill snd_as...
74
75
  	if (snd_BUG_ON(!tu->timeri))
  		return -ENXIO;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  	memset(&status, 0, sizeof(status));
  	status.tstamp = tu->tstamp;
  	status.resolution = snd_timer_resolution(tu->timeri);
  	status.lost = tu->timeri->lost;
  	status.overrun = tu->overrun;
  	spin_lock_irq(&tu->qlock);
  	status.queue = tu->qused;
  	spin_unlock_irq(&tu->qlock);
  	if (copy_to_user(_status, &status, sizeof(status)))
  		return -EFAULT;
  	return 0;
  }
  
  /*
   */
  
  enum {
53d2f744a   Takashi Iwai   [ALSA] Remove xxx...
93
94
  	SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32),
  	SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  };
  
  static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
  {
  	void __user *argp = compat_ptr(arg);
  
  	switch (cmd) {
  	case SNDRV_TIMER_IOCTL_PVERSION:
  	case SNDRV_TIMER_IOCTL_TREAD:
  	case SNDRV_TIMER_IOCTL_GINFO:
  	case SNDRV_TIMER_IOCTL_GPARAMS:
  	case SNDRV_TIMER_IOCTL_GSTATUS:
  	case SNDRV_TIMER_IOCTL_SELECT:
  	case SNDRV_TIMER_IOCTL_PARAMS:
  	case SNDRV_TIMER_IOCTL_START:
8c50b37c0   Takashi Iwai   [ALSA] Change som...
110
  	case SNDRV_TIMER_IOCTL_START_OLD:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111
  	case SNDRV_TIMER_IOCTL_STOP:
8c50b37c0   Takashi Iwai   [ALSA] Change som...
112
  	case SNDRV_TIMER_IOCTL_STOP_OLD:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  	case SNDRV_TIMER_IOCTL_CONTINUE:
8c50b37c0   Takashi Iwai   [ALSA] Change som...
114
  	case SNDRV_TIMER_IOCTL_CONTINUE_OLD:
15790a6be   Takashi Iwai   [ALSA] Add missin...
115
  	case SNDRV_TIMER_IOCTL_PAUSE:
8c50b37c0   Takashi Iwai   [ALSA] Change som...
116
  	case SNDRV_TIMER_IOCTL_PAUSE_OLD:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
117
118
119
120
121
122
123
124
125
  	case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
  		return snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
  	case SNDRV_TIMER_IOCTL_INFO32:
  		return snd_timer_user_info_compat(file, argp);
  	case SNDRV_TIMER_IOCTL_STATUS32:
  		return snd_timer_user_status_compat(file, argp);
  	}
  	return -ENOIOCTLCMD;
  }