ALSA: core: Handle user defined ioctls
Handle ioctl magic 'U' as an user defined ioctl so that ALSA core calls substream's ioctl handler. This gets rid of a requirement that ALSA core needs to be changed every time when a new user defined ioctl is introduced. Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org> Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org> Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
This commit is contained in:
parent
74e78b3452
commit
eb4032ed5c
1 changed files with 23 additions and 2 deletions
|
@ -1090,6 +1090,20 @@ static int snd_compressed_ioctl(struct snd_pcm_substream *substream,
|
|||
err = substream->ops->ioctl(substream, cmd, arg);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int snd_user_ioctl(struct snd_pcm_substream *substream,
|
||||
unsigned int cmd, void __user *arg)
|
||||
{
|
||||
struct snd_pcm_runtime *runtime;
|
||||
int err = 0;
|
||||
|
||||
if (PCM_RUNTIME_CHECK(substream))
|
||||
return -ENXIO;
|
||||
runtime = substream->runtime;
|
||||
err = substream->ops->ioctl(substream, cmd, arg);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* stop callbacks
|
||||
*/
|
||||
|
@ -2832,6 +2846,9 @@ static int snd_pcm_common_ioctl1(struct file *file,
|
|||
case SNDRV_COMPRESS_TSTAMP:
|
||||
case SNDRV_COMPRESS_DRAIN:
|
||||
return snd_compressed_ioctl(substream, cmd, arg);
|
||||
default:
|
||||
if (((cmd >> 8) & 0xff) == 'U')
|
||||
return snd_user_ioctl(substream, cmd, arg);
|
||||
}
|
||||
pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd);
|
||||
return -ENOTTY;
|
||||
|
@ -3001,10 +3018,12 @@ static long snd_pcm_playback_ioctl(struct file *file, unsigned int cmd,
|
|||
unsigned long arg)
|
||||
{
|
||||
struct snd_pcm_file *pcm_file;
|
||||
unsigned char ioctl_magic;
|
||||
|
||||
pcm_file = file->private_data;
|
||||
ioctl_magic = ((cmd >> 8) & 0xff);
|
||||
|
||||
if ((((cmd >> 8) & 0xff) != 'A') && (((cmd >> 8) & 0xff) != 'C'))
|
||||
if (ioctl_magic != 'A' && ioctl_magic != 'C' && ioctl_magic != 'U')
|
||||
return -ENOTTY;
|
||||
|
||||
return snd_pcm_playback_ioctl1(file, pcm_file->substream, cmd,
|
||||
|
@ -3015,10 +3034,12 @@ static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd,
|
|||
unsigned long arg)
|
||||
{
|
||||
struct snd_pcm_file *pcm_file;
|
||||
unsigned char ioctl_magic;
|
||||
|
||||
pcm_file = file->private_data;
|
||||
ioctl_magic = ((cmd >> 8) & 0xff);
|
||||
|
||||
if (((cmd >> 8) & 0xff) != 'A')
|
||||
if (ioctl_magic != 'A' && ioctl_magic != 'U')
|
||||
return -ENOTTY;
|
||||
|
||||
return snd_pcm_capture_ioctl1(file, pcm_file->substream, cmd,
|
||||
|
|
Loading…
Add table
Reference in a new issue