Commit 1efef61e authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] Export functions for ioctl32 wrapper

Control Midlevel,PCM Midlevel,ALSA Core
Export some functions to access from ioctl32 wrapper.
This will reduce the memory footprint (doublly kmalloc's for the same
ioctl records).
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ce15ed41
......@@ -122,6 +122,10 @@ int snd_ctl_unregister(snd_card_t *card);
int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn);
int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn);
/* for ioctl32 */
int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *control);
int snd_ctl_elem_write(snd_ctl_file_t *file, snd_ctl_elem_value_t *control);
static inline unsigned int snd_ctl_get_ioffnum(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id)
{
return id->numid - kctl->id.numid;
......
......@@ -810,6 +810,7 @@ int snd_pcm_hw_param_set(snd_pcm_substream_t *pcm,
int snd_pcm_hw_params_choose(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
int snd_pcm_hw_refine(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
int snd_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream);
int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream);
......
......@@ -635,19 +635,13 @@ static int snd_ctl_elem_info(snd_ctl_file_t *ctl, snd_ctl_elem_info_t __user *_i
return result;
}
static int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t __user *_control)
int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *control)
{
snd_ctl_elem_value_t *control;
snd_kcontrol_t *kctl;
snd_kcontrol_volatile_t *vd;
unsigned int index_offset;
int result, indirect;
control = kmalloc(sizeof(*control), GFP_KERNEL);
if (control == NULL)
return -ENOMEM;
if (copy_from_user(control, _control, sizeof(*control)))
return -EFAULT;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id);
if (kctl == NULL) {
......@@ -668,27 +662,37 @@ static int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t __user *_con
}
}
up_read(&card->controls_rwsem);
return result;
}
static int snd_ctl_elem_read_user(snd_card_t *card, snd_ctl_elem_value_t __user *_control)
{
snd_ctl_elem_value_t *control;
int result;
control = kmalloc(sizeof(*control), GFP_KERNEL);
if (control == NULL)
return -ENOMEM;
if (copy_from_user(control, _control, sizeof(*control))) {
kfree(control);
return -EFAULT;
}
result = snd_ctl_elem_read(card, control);
if (result >= 0)
if (copy_to_user(_control, control, sizeof(*control)))
return -EFAULT;
result = -EFAULT;
kfree(control);
return result;
}
static int snd_ctl_elem_write(snd_ctl_file_t *file, snd_ctl_elem_value_t __user *_control)
int snd_ctl_elem_write(snd_ctl_file_t *file, snd_ctl_elem_value_t *control)
{
snd_card_t *card = file->card;
snd_ctl_elem_value_t *control;
snd_kcontrol_t *kctl;
snd_kcontrol_volatile_t *vd;
unsigned int index_offset;
int result, indirect;
control = kmalloc(sizeof(*control), GFP_KERNEL);
if (control == NULL)
return -ENOMEM;
if (copy_from_user(control, _control, sizeof(*control)))
return -EFAULT;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id);
if (kctl == NULL) {
......@@ -711,16 +715,30 @@ static int snd_ctl_elem_write(snd_ctl_file_t *file, snd_ctl_elem_value_t __user
if (result > 0) {
up_read(&card->controls_rwsem);
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &control->id);
result = 0;
goto __unlocked;
return 0;
}
}
}
up_read(&card->controls_rwsem);
__unlocked:
return result;
}
static int snd_ctl_elem_write_user(snd_ctl_file_t *file, snd_ctl_elem_value_t __user *_control)
{
snd_ctl_elem_value_t *control;
int result;
control = kmalloc(sizeof(*control), GFP_KERNEL);
if (control == NULL)
return -ENOMEM;
if (copy_from_user(control, _control, sizeof(*control))) {
kfree(control);
return -EFAULT;
}
result = snd_ctl_elem_write(file, control);
if (result >= 0)
if (copy_to_user(_control, control, sizeof(*control)))
return -EFAULT;
result = -EFAULT;
kfree(control);
return result;
}
......@@ -1045,9 +1063,9 @@ static inline int _snd_ctl_ioctl(struct inode *inode, struct file *file,
case SNDRV_CTL_IOCTL_ELEM_INFO:
return snd_ctl_elem_info(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_READ:
return snd_ctl_elem_read(ctl->card, argp);
return snd_ctl_elem_read_user(ctl->card, argp);
case SNDRV_CTL_IOCTL_ELEM_WRITE:
return snd_ctl_elem_write(ctl, argp);
return snd_ctl_elem_write_user(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_LOCK:
return snd_ctl_elem_lock(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_UNLOCK:
......
......@@ -2660,6 +2660,7 @@ EXPORT_SYMBOL(snd_pcm_hw_param_last);
EXPORT_SYMBOL(snd_pcm_hw_param_near);
EXPORT_SYMBOL(snd_pcm_hw_param_set);
EXPORT_SYMBOL(snd_pcm_hw_refine);
EXPORT_SYMBOL(snd_pcm_hw_params);
EXPORT_SYMBOL(snd_pcm_hw_constraints_init);
EXPORT_SYMBOL(snd_pcm_hw_constraints_complete);
EXPORT_SYMBOL(snd_pcm_hw_constraint_list);
......
......@@ -329,8 +329,8 @@ static int snd_pcm_hw_refine_user(snd_pcm_substream_t * substream, snd_pcm_hw_pa
return err;
}
static int snd_pcm_hw_params(snd_pcm_substream_t *substream,
snd_pcm_hw_params_t *params)
int snd_pcm_hw_params(snd_pcm_substream_t *substream,
snd_pcm_hw_params_t *params)
{
snd_pcm_runtime_t *runtime;
int err;
......
......@@ -475,6 +475,10 @@ EXPORT_SYMBOL(snd_ctl_find_id);
EXPORT_SYMBOL(snd_ctl_notify);
EXPORT_SYMBOL(snd_ctl_register_ioctl);
EXPORT_SYMBOL(snd_ctl_unregister_ioctl);
#ifdef CONFIG_COMPAT
EXPORT_SYMBOL(snd_ctl_elem_read);
EXPORT_SYMBOL(snd_ctl_elem_write);
#endif
/* misc.c */
EXPORT_SYMBOL(snd_task_name);
#ifdef CONFIG_SND_VERBOSE_PRINTK
......
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