Commit fc033cbf authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm: Allow NULL ioctl ops

Currently PCM ioctl ops is a mandatory field but almost all drivers
simply pass snd_pcm_lib_ioctl.  For simplicity, allow to set NULL in
the field and call snd_pcm_lib_ioctl() as default.

Link: https://lore.kernel.org/r/20191117085308.23915-4-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 72b4bcbf
...@@ -178,6 +178,16 @@ void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, ...@@ -178,6 +178,16 @@ void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
} }
EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irqrestore); EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irqrestore);
/* Run PCM ioctl ops */
static int snd_pcm_ops_ioctl(struct snd_pcm_substream *substream,
unsigned cmd, void *arg)
{
if (substream->ops->ioctl)
return substream->ops->ioctl(substream, cmd, arg);
else
return snd_pcm_lib_ioctl(substream, cmd, arg);
}
int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info)
{ {
struct snd_pcm *pcm = substream->pcm; struct snd_pcm *pcm = substream->pcm;
...@@ -448,8 +458,9 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream, ...@@ -448,8 +458,9 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream,
m = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT); m = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS); i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS);
if (snd_mask_single(m) && snd_interval_single(i)) { if (snd_mask_single(m) && snd_interval_single(i)) {
err = substream->ops->ioctl(substream, err = snd_pcm_ops_ioctl(substream,
SNDRV_PCM_IOCTL1_FIFO_SIZE, params); SNDRV_PCM_IOCTL1_FIFO_SIZE,
params);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -971,7 +982,7 @@ static int snd_pcm_channel_info(struct snd_pcm_substream *substream, ...@@ -971,7 +982,7 @@ static int snd_pcm_channel_info(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
info->channel = channel; info->channel = channel;
return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); return snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info);
} }
static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream,
...@@ -1647,7 +1658,7 @@ static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) ...@@ -1647,7 +1658,7 @@ static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state)
static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL);
if (err < 0) if (err < 0)
return err; return err;
runtime->hw_ptr_base = 0; runtime->hw_ptr_base = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment