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

Commit a3bbd355 authored by Meng Wang's avatar Meng Wang Committed by Gerrit - the friendly Code Review server
Browse files

ALSA: core: Handle user defined ioctls



Handle ioctl magic 'U' as a 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>
Signed-off-by: default avatarMeng Wang <mwang@codeaurora.org>
parent df2a792c
Loading
Loading
Loading
Loading
+20 −2
Original line number Original line Diff line number Diff line
@@ -1274,6 +1274,19 @@ static int snd_compressed_ioctl(struct snd_pcm_substream *substream,
	return err;
	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
 * stop callbacks
 */
 */
@@ -2971,6 +2984,9 @@ static int snd_pcm_common_ioctl(struct file *file,
	case SNDRV_COMPRESS_TSTAMP:
	case SNDRV_COMPRESS_TSTAMP:
	case SNDRV_COMPRESS_DRAIN:
	case SNDRV_COMPRESS_DRAIN:
		return snd_compressed_ioctl(substream, cmd, arg);
		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);
	pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd);
	return -ENOTTY;
	return -ENOTTY;
@@ -2980,13 +2996,15 @@ static long snd_pcm_ioctl(struct file *file, unsigned int cmd,
			  unsigned long arg)
			  unsigned long arg)
{
{
	struct snd_pcm_file *pcm_file;
	struct snd_pcm_file *pcm_file;
	unsigned char ioctl_magic;


	pcm_file = file->private_data;
	pcm_file = file->private_data;
	ioctl_magic = ((cmd >> 8) & 0xff);


	if ((((cmd >> 8) & 0xff) != 'A') &&
	if (ioctl_magic != 'A' && ioctl_magic != 'U' &&
		((pcm_file->substream->stream == SNDRV_PCM_STREAM_CAPTURE) ||
		((pcm_file->substream->stream == SNDRV_PCM_STREAM_CAPTURE) ||
		(pcm_file->substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
		(pcm_file->substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
		(((cmd >> 8) & 0xff) != 'C'))))
		ioctl_magic != 'C')))
		return -ENOTTY;
		return -ENOTTY;


	return snd_pcm_common_ioctl(file, pcm_file->substream, cmd,
	return snd_pcm_common_ioctl(file, pcm_file->substream, cmd,