diff options
| author | Eric Laurent <elaurent@google.com> | 2013-08-28 14:42:27 -0700 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-23 20:10:47 -0700 |
| commit | 575eeabce906e0a173b03efe01feada4d64c39fd (patch) | |
| tree | 8f0de897f463dcf5243bd8b8955a428e14649912 | |
| parent | 8236e4d4970da0c5900b61d5901e66a9263714d4 (diff) | |
ALSA: Compress - dont use lock for all ioctls
Some simple ioctls like timsetamp query, capabities query can be done anytime
and should not be under the stream lock. Move these to
snd_compress_simple_iotcls() which is invoked without lock held.
While at it, improve readblity a bit by sprinkling some empty lines.
Change-Id: Icc8ffdadd565c635f6a95e7e5bdda76257f24ea3
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Eric Laurent <elaurent@google.com>
Git-commit: 6a44374b8b92e9946dc1e5c15c2a11003aa859b1
Git-repo: https://android.googlesource.com/kernel/msm
[dhakumar@codeaurora.org: resolved merge conflicts]
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
| -rw-r--r-- | sound/core/compress_offload.c | 80 |
1 files changed, 59 insertions, 21 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index e748bfaf5b42..6017a27936ab 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -780,70 +780,108 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) return snd_compress_wait_for_drain(stream); } -static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +static int snd_compress_simple_ioctls(struct file *file, + struct snd_compr_stream *stream, + unsigned int cmd, unsigned long arg) { - struct snd_compr_file *data = f->private_data; - struct snd_compr_stream *stream; int retval = -ENOTTY; - if (snd_BUG_ON(!data)) - return -EFAULT; - stream = &data->stream; - if (snd_BUG_ON(!stream)) - return -EFAULT; - mutex_lock(&stream->device->lock); switch (_IOC_NR(cmd)) { case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION): retval = put_user(SNDRV_COMPRESS_VERSION, (int __user *)arg) ? -EFAULT : 0; break; + case _IOC_NR(SNDRV_COMPRESS_GET_CAPS): retval = snd_compr_get_caps(stream, arg); break; + case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): retval = snd_compr_get_codec_caps(stream, arg); break; + + + case _IOC_NR(SNDRV_COMPRESS_TSTAMP): + retval = snd_compr_tstamp(stream, arg); + break; + + case _IOC_NR(SNDRV_COMPRESS_AVAIL): + retval = snd_compr_ioctl_avail(stream, arg); + break; + + /* drain and partial drain need special handling + * we need to drop the locks here as the streams would get blocked on + * the dsp to get drained. The locking would be handled in respective + * function here + */ + case _IOC_NR(SNDRV_COMPRESS_DRAIN): + retval = snd_compr_drain(stream); + break; + + case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN): + retval = snd_compr_partial_drain(stream); + break; + } + + return retval; +} + +static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +{ + struct snd_compr_file *data = f->private_data; + struct snd_compr_stream *stream; + int retval = -ENOTTY; + + if (snd_BUG_ON(!data)) + return -EFAULT; + stream = &data->stream; + if (snd_BUG_ON(!stream)) + return -EFAULT; + + mutex_lock(&stream->device->lock); + switch (_IOC_NR(cmd)) { case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS): retval = snd_compr_set_params(stream, arg); break; + case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS): retval = snd_compr_get_params(stream, arg); break; + case _IOC_NR(SNDRV_COMPRESS_SET_METADATA): retval = snd_compr_set_metadata(stream, arg); break; + case _IOC_NR(SNDRV_COMPRESS_GET_METADATA): retval = snd_compr_get_metadata(stream, arg); break; - case _IOC_NR(SNDRV_COMPRESS_TSTAMP): - retval = snd_compr_tstamp(stream, arg); - break; - case _IOC_NR(SNDRV_COMPRESS_AVAIL): - retval = snd_compr_ioctl_avail(stream, arg); - break; + case _IOC_NR(SNDRV_COMPRESS_PAUSE): retval = snd_compr_pause(stream); break; + case _IOC_NR(SNDRV_COMPRESS_RESUME): retval = snd_compr_resume(stream); break; + case _IOC_NR(SNDRV_COMPRESS_START): retval = snd_compr_start(stream); break; + case _IOC_NR(SNDRV_COMPRESS_STOP): retval = snd_compr_stop(stream); break; - case _IOC_NR(SNDRV_COMPRESS_DRAIN): - retval = snd_compr_drain(stream); - break; - case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN): - retval = snd_compr_partial_drain(stream); - break; + case _IOC_NR(SNDRV_COMPRESS_NEXT_TRACK): retval = snd_compr_next_track(stream); break; + default: + mutex_unlock(&stream->device->lock); + return snd_compress_simple_ioctls(f, stream, cmd, arg); + } + mutex_unlock(&stream->device->lock); return retval; } |
