aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/drivers/vx/vx_mixer.c67
-rw-r--r--sound/pcmcia/vx/vxp_mixer.c11
2 files changed, 56 insertions, 22 deletions
diff --git a/sound/drivers/vx/vx_mixer.c b/sound/drivers/vx/vx_mixer.c
index b8fcd79a7e11..a37f0a8f17af 100644
--- a/sound/drivers/vx/vx_mixer.c
+++ b/sound/drivers/vx/vx_mixer.c
@@ -439,14 +439,19 @@ static int vx_output_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
439{ 439{
440 struct vx_core *chip = snd_kcontrol_chip(kcontrol); 440 struct vx_core *chip = snd_kcontrol_chip(kcontrol);
441 int codec = kcontrol->id.index; 441 int codec = kcontrol->id.index;
442 unsigned int val[2], vmax;
443
444 vmax = chip->hw->output_level_max;
445 val[0] = ucontrol->value.integer.value[0];
446 val[1] = ucontrol->value.integer.value[1];
447 if (val[0] > vmax || val[1] > vmax)
448 return -EINVAL;
442 mutex_lock(&chip->mixer_mutex); 449 mutex_lock(&chip->mixer_mutex);
443 if (ucontrol->value.integer.value[0] != chip->output_level[codec][0] || 450 if (val[0] != chip->output_level[codec][0] ||
444 ucontrol->value.integer.value[1] != chip->output_level[codec][1]) { 451 val[1] != chip->output_level[codec][1]) {
445 vx_set_analog_output_level(chip, codec, 452 vx_set_analog_output_level(chip, codec, val[0], val[1]);
446 ucontrol->value.integer.value[0], 453 chip->output_level[codec][0] = val[0];
447 ucontrol->value.integer.value[1]); 454 chip->output_level[codec][1] = val[1];
448 chip->output_level[codec][0] = ucontrol->value.integer.value[0];
449 chip->output_level[codec][1] = ucontrol->value.integer.value[1];
450 mutex_unlock(&chip->mixer_mutex); 455 mutex_unlock(&chip->mixer_mutex);
451 return 1; 456 return 1;
452 } 457 }
@@ -506,6 +511,14 @@ static int vx_audio_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
506static int vx_audio_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 511static int vx_audio_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
507{ 512{
508 struct vx_core *chip = snd_kcontrol_chip(kcontrol); 513 struct vx_core *chip = snd_kcontrol_chip(kcontrol);
514
515 if (chip->type >= VX_TYPE_VXPOCKET) {
516 if (ucontrol->value.enumerated.item[0] > 2)
517 return -EINVAL;
518 } else {
519 if (ucontrol->value.enumerated.item[0] > 1)
520 return -EINVAL;
521 }
509 mutex_lock(&chip->mixer_mutex); 522 mutex_lock(&chip->mixer_mutex);
510 if (chip->audio_source_target != ucontrol->value.enumerated.item[0]) { 523 if (chip->audio_source_target != ucontrol->value.enumerated.item[0]) {
511 chip->audio_source_target = ucontrol->value.enumerated.item[0]; 524 chip->audio_source_target = ucontrol->value.enumerated.item[0];
@@ -554,6 +567,9 @@ static int vx_clock_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
554static int vx_clock_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 567static int vx_clock_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
555{ 568{
556 struct vx_core *chip = snd_kcontrol_chip(kcontrol); 569 struct vx_core *chip = snd_kcontrol_chip(kcontrol);
570
571 if (ucontrol->value.enumerated.item[0] > 2)
572 return -EINVAL;
557 mutex_lock(&chip->mixer_mutex); 573 mutex_lock(&chip->mixer_mutex);
558 if (chip->clock_mode != ucontrol->value.enumerated.item[0]) { 574 if (chip->clock_mode != ucontrol->value.enumerated.item[0]) {
559 chip->clock_mode = ucontrol->value.enumerated.item[0]; 575 chip->clock_mode = ucontrol->value.enumerated.item[0];
@@ -603,12 +619,17 @@ static int vx_audio_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
603 struct vx_core *chip = snd_kcontrol_chip(kcontrol); 619 struct vx_core *chip = snd_kcontrol_chip(kcontrol);
604 int audio = kcontrol->private_value & 0xff; 620 int audio = kcontrol->private_value & 0xff;
605 int capture = (kcontrol->private_value >> 8) & 1; 621 int capture = (kcontrol->private_value >> 8) & 1;
622 unsigned int val[2];
606 623
624 val[0] = ucontrol->value.integer.value[0];
625 val[1] = ucontrol->value.integer.value[1];
626 if (val[0] > CVAL_MAX || val[1] > CVAL_MAX)
627 return -EINVAL;
607 mutex_lock(&chip->mixer_mutex); 628 mutex_lock(&chip->mixer_mutex);
608 if (ucontrol->value.integer.value[0] != chip->audio_gain[capture][audio] || 629 if (val[0] != chip->audio_gain[capture][audio] ||
609 ucontrol->value.integer.value[1] != chip->audio_gain[capture][audio+1]) { 630 val[1] != chip->audio_gain[capture][audio+1]) {
610 vx_set_audio_gain(chip, audio, capture, ucontrol->value.integer.value[0]); 631 vx_set_audio_gain(chip, audio, capture, val[0]);
611 vx_set_audio_gain(chip, audio+1, capture, ucontrol->value.integer.value[1]); 632 vx_set_audio_gain(chip, audio+1, capture, val[1]);
612 mutex_unlock(&chip->mixer_mutex); 633 mutex_unlock(&chip->mixer_mutex);
613 return 1; 634 return 1;
614 } 635 }
@@ -632,13 +653,19 @@ static int vx_audio_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
632{ 653{
633 struct vx_core *chip = snd_kcontrol_chip(kcontrol); 654 struct vx_core *chip = snd_kcontrol_chip(kcontrol);
634 int audio = kcontrol->private_value & 0xff; 655 int audio = kcontrol->private_value & 0xff;
656 unsigned int val[2];
657
658 val[0] = ucontrol->value.integer.value[0];
659 val[1] = ucontrol->value.integer.value[1];
660 if (val[0] > CVAL_MAX || val[1] > CVAL_MAX)
661 return -EINVAL;
635 662
636 mutex_lock(&chip->mixer_mutex); 663 mutex_lock(&chip->mixer_mutex);
637 if (ucontrol->value.integer.value[0] != chip->audio_monitor[audio] || 664 if (val[0] != chip->audio_monitor[audio] ||
638 ucontrol->value.integer.value[1] != chip->audio_monitor[audio+1]) { 665 val[1] != chip->audio_monitor[audio+1]) {
639 vx_set_monitor_level(chip, audio, ucontrol->value.integer.value[0], 666 vx_set_monitor_level(chip, audio, val[0],
640 chip->audio_monitor_active[audio]); 667 chip->audio_monitor_active[audio]);
641 vx_set_monitor_level(chip, audio+1, ucontrol->value.integer.value[1], 668 vx_set_monitor_level(chip, audio+1, val[1],
642 chip->audio_monitor_active[audio+1]); 669 chip->audio_monitor_active[audio+1]);
643 mutex_unlock(&chip->mixer_mutex); 670 mutex_unlock(&chip->mixer_mutex);
644 return 1; 671 return 1;
@@ -669,8 +696,10 @@ static int vx_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
669 mutex_lock(&chip->mixer_mutex); 696 mutex_lock(&chip->mixer_mutex);
670 if (ucontrol->value.integer.value[0] != chip->audio_active[audio] || 697 if (ucontrol->value.integer.value[0] != chip->audio_active[audio] ||
671 ucontrol->value.integer.value[1] != chip->audio_active[audio+1]) { 698 ucontrol->value.integer.value[1] != chip->audio_active[audio+1]) {
672 vx_set_audio_switch(chip, audio, ucontrol->value.integer.value[0]); 699 vx_set_audio_switch(chip, audio,
673 vx_set_audio_switch(chip, audio+1, ucontrol->value.integer.value[1]); 700 !!ucontrol->value.integer.value[0]);
701 vx_set_audio_switch(chip, audio+1,
702 !!ucontrol->value.integer.value[1]);
674 mutex_unlock(&chip->mixer_mutex); 703 mutex_unlock(&chip->mixer_mutex);
675 return 1; 704 return 1;
676 } 705 }
@@ -699,9 +728,9 @@ static int vx_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
699 if (ucontrol->value.integer.value[0] != chip->audio_monitor_active[audio] || 728 if (ucontrol->value.integer.value[0] != chip->audio_monitor_active[audio] ||
700 ucontrol->value.integer.value[1] != chip->audio_monitor_active[audio+1]) { 729 ucontrol->value.integer.value[1] != chip->audio_monitor_active[audio+1]) {
701 vx_set_monitor_level(chip, audio, chip->audio_monitor[audio], 730 vx_set_monitor_level(chip, audio, chip->audio_monitor[audio],
702 ucontrol->value.integer.value[0]); 731 !!ucontrol->value.integer.value[0]);
703 vx_set_monitor_level(chip, audio+1, chip->audio_monitor[audio+1], 732 vx_set_monitor_level(chip, audio+1, chip->audio_monitor[audio+1],
704 ucontrol->value.integer.value[1]); 733 !!ucontrol->value.integer.value[1]);
705 mutex_unlock(&chip->mixer_mutex); 734 mutex_unlock(&chip->mixer_mutex);
706 return 1; 735 return 1;
707 } 736 }
diff --git a/sound/pcmcia/vx/vxp_mixer.c b/sound/pcmcia/vx/vxp_mixer.c
index 1eff158b8687..bf9d3b37d6bc 100644
--- a/sound/pcmcia/vx/vxp_mixer.c
+++ b/sound/pcmcia/vx/vxp_mixer.c
@@ -53,6 +53,10 @@ static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
53{ 53{
54 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 54 struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
55 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; 55 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
56 unsigned int val = ucontrol->value.integer.value[0];
57
58 if (val > MIC_LEVEL_MAX)
59 return -EINVAL;
56 mutex_lock(&_chip->mixer_mutex); 60 mutex_lock(&_chip->mixer_mutex);
57 if (chip->mic_level != ucontrol->value.integer.value[0]) { 61 if (chip->mic_level != ucontrol->value.integer.value[0]) {
58 vx_set_mic_level(_chip, ucontrol->value.integer.value[0]); 62 vx_set_mic_level(_chip, ucontrol->value.integer.value[0]);
@@ -94,10 +98,11 @@ static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
94{ 98{
95 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 99 struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
96 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; 100 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
101 int val = !!ucontrol->value.integer.value[0];
97 mutex_lock(&_chip->mixer_mutex); 102 mutex_lock(&_chip->mixer_mutex);
98 if (chip->mic_level != ucontrol->value.integer.value[0]) { 103 if (chip->mic_level != val) {
99 vx_set_mic_boost(_chip, ucontrol->value.integer.value[0]); 104 vx_set_mic_boost(_chip, val);
100 chip->mic_level = ucontrol->value.integer.value[0]; 105 chip->mic_level = val;
101 mutex_unlock(&_chip->mixer_mutex); 106 mutex_unlock(&_chip->mixer_mutex);
102 return 1; 107 return 1;
103 } 108 }