Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04e0fcd6 authored by Sudheer Papothi's avatar Sudheer Papothi Committed by Banajit Goswami
Browse files

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.

Change-Id: I390b9e0428bfadc302ff074417aa69163b12c6ec
Signed-off-by: default avatarJoonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent b40e968a
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -1103,6 +1103,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
 */
@@ -2847,6 +2861,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;
@@ -3016,10 +3033,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,
@@ -3030,10 +3049,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,