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

Commit 57771a1e authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ALSA: core: Handle user defined ioctls" into msm-4.8

parents 4d63a58d 04e0fcd6
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,