aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/mixart/mixart_mixer.c124
1 files changed, 83 insertions, 41 deletions
diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c
index 0e16512d25f7..5b3c224732af 100644
--- a/sound/pci/mixart/mixart_mixer.c
+++ b/sound/pci/mixart/mixart_mixer.c
@@ -376,15 +376,27 @@ static int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
376 376
377 mutex_lock(&chip->mgr->mixer_mutex); 377 mutex_lock(&chip->mgr->mixer_mutex);
378 is_capture = (kcontrol->private_value != 0); 378 is_capture = (kcontrol->private_value != 0);
379 for(i=0; i<2; i++) { 379 for (i = 0; i < 2; i++) {
380 int new_volume = ucontrol->value.integer.value[i]; 380 int new_volume = ucontrol->value.integer.value[i];
381 int* stored_volume = is_capture ? &chip->analog_capture_volume[i] : &chip->analog_playback_volume[i]; 381 int *stored_volume = is_capture ?
382 if(*stored_volume != new_volume) { 382 &chip->analog_capture_volume[i] :
383 &chip->analog_playback_volume[i];
384 if (is_capture) {
385 if (new_volume < MIXART_ANALOG_CAPTURE_LEVEL_MIN ||
386 new_volume > MIXART_ANALOG_CAPTURE_LEVEL_MAX)
387 continue;
388 } else {
389 if (new_volume < MIXART_ANALOG_PLAYBACK_LEVEL_MIN ||
390 new_volume > MIXART_ANALOG_PLAYBACK_LEVEL_MAX)
391 continue;
392 }
393 if (*stored_volume != new_volume) {
383 *stored_volume = new_volume; 394 *stored_volume = new_volume;
384 changed = 1; 395 changed = 1;
385 } 396 }
386 } 397 }
387 if(changed) mixart_update_analog_audio_level(chip, is_capture); 398 if (changed)
399 mixart_update_analog_audio_level(chip, is_capture);
388 mutex_unlock(&chip->mgr->mixer_mutex); 400 mutex_unlock(&chip->mgr->mixer_mutex);
389 return changed; 401 return changed;
390} 402}
@@ -421,13 +433,16 @@ static int mixart_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
421 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); 433 struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
422 int i, changed = 0; 434 int i, changed = 0;
423 mutex_lock(&chip->mgr->mixer_mutex); 435 mutex_lock(&chip->mgr->mixer_mutex);
424 for(i=0; i<2; i++) { 436 for (i = 0; i < 2; i++) {
425 if(chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) { 437 if (chip->analog_playback_active[i] !=
426 chip->analog_playback_active[i] = ucontrol->value.integer.value[i]; 438 ucontrol->value.integer.value[i]) {
439 chip->analog_playback_active[i] =
440 !!ucontrol->value.integer.value[i];
427 changed = 1; 441 changed = 1;
428 } 442 }
429 } 443 }
430 if(changed) mixart_update_analog_audio_level(chip, 0); /* update playback levels */ 444 if (changed) /* update playback levels */
445 mixart_update_analog_audio_level(chip, 0);
431 mutex_unlock(&chip->mgr->mixer_mutex); 446 mutex_unlock(&chip->mgr->mixer_mutex);
432 return changed; 447 return changed;
433} 448}
@@ -843,23 +858,33 @@ static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
843 int* stored_volume; 858 int* stored_volume;
844 int i; 859 int i;
845 mutex_lock(&chip->mgr->mixer_mutex); 860 mutex_lock(&chip->mgr->mixer_mutex);
846 if(is_capture) { 861 if (is_capture) {
847 if(is_aes) stored_volume = chip->digital_capture_volume[1]; /* AES capture */ 862 if (is_aes) /* AES capture */
848 else stored_volume = chip->digital_capture_volume[0]; /* analog capture */ 863 stored_volume = chip->digital_capture_volume[1];
864 else /* analog capture */
865 stored_volume = chip->digital_capture_volume[0];
849 } else { 866 } else {
850 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 867 snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
851 if(is_aes) stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */ 868 if (is_aes) /* AES playback */
852 else stored_volume = chip->digital_playback_volume[idx]; /* analog playback */ 869 stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx];
870 else /* analog playback */
871 stored_volume = chip->digital_playback_volume[idx];
853 } 872 }
854 for(i=0; i<2; i++) { 873 for (i = 0; i < 2; i++) {
855 if(stored_volume[i] != ucontrol->value.integer.value[i]) { 874 int vol = ucontrol->value.integer.value[i];
856 stored_volume[i] = ucontrol->value.integer.value[i]; 875 if (vol < MIXART_DIGITAL_LEVEL_MIN ||
876 vol > MIXART_DIGITAL_LEVEL_MAX)
877 continue;
878 if (stored_volume[i] != vol) {
879 stored_volume[i] = vol;
857 changed = 1; 880 changed = 1;
858 } 881 }
859 } 882 }
860 if(changed) { 883 if (changed) {
861 if(is_capture) mixart_update_capture_stream_level(chip, is_aes); 884 if (is_capture)
862 else mixart_update_playback_stream_level(chip, is_aes, idx); 885 mixart_update_capture_stream_level(chip, is_aes);
886 else
887 mixart_update_playback_stream_level(chip, is_aes, idx);
863 } 888 }
864 mutex_unlock(&chip->mgr->mixer_mutex); 889 mutex_unlock(&chip->mgr->mixer_mutex);
865 return changed; 890 return changed;
@@ -905,14 +930,18 @@ static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
905 snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); 930 snd_assert ( idx < MIXART_PLAYBACK_STREAMS );
906 mutex_lock(&chip->mgr->mixer_mutex); 931 mutex_lock(&chip->mgr->mixer_mutex);
907 j = idx; 932 j = idx;
908 if(is_aes) j += MIXART_PLAYBACK_STREAMS; 933 if (is_aes)
909 for(i=0; i<2; i++) { 934 j += MIXART_PLAYBACK_STREAMS;
910 if(chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) { 935 for (i = 0; i < 2; i++) {
911 chip->digital_playback_active[j][i] = ucontrol->value.integer.value[i]; 936 if (chip->digital_playback_active[j][i] !=
937 ucontrol->value.integer.value[i]) {
938 chip->digital_playback_active[j][i] =
939 !!ucontrol->value.integer.value[i];
912 changed = 1; 940 changed = 1;
913 } 941 }
914 } 942 }
915 if(changed) mixart_update_playback_stream_level(chip, is_aes, idx); 943 if (changed)
944 mixart_update_playback_stream_level(chip, is_aes, idx);
916 mutex_unlock(&chip->mgr->mixer_mutex); 945 mutex_unlock(&chip->mgr->mixer_mutex);
917 return changed; 946 return changed;
918} 947}
@@ -975,9 +1004,11 @@ static int mixart_monitor_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
975 int changed = 0; 1004 int changed = 0;
976 int i; 1005 int i;
977 mutex_lock(&chip->mgr->mixer_mutex); 1006 mutex_lock(&chip->mgr->mixer_mutex);
978 for(i=0; i<2; i++) { 1007 for (i = 0; i < 2; i++) {
979 if(chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) { 1008 if (chip->monitoring_volume[i] !=
980 chip->monitoring_volume[i] = ucontrol->value.integer.value[i]; 1009 ucontrol->value.integer.value[i]) {
1010 chip->monitoring_volume[i] =
1011 !!ucontrol->value.integer.value[i];
981 mixart_update_monitoring(chip, i); 1012 mixart_update_monitoring(chip, i);
982 changed = 1; 1013 changed = 1;
983 } 1014 }
@@ -1017,24 +1048,35 @@ static int mixart_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1017 int changed = 0; 1048 int changed = 0;
1018 int i; 1049 int i;
1019 mutex_lock(&chip->mgr->mixer_mutex); 1050 mutex_lock(&chip->mgr->mixer_mutex);
1020 for(i=0; i<2; i++) { 1051 for (i = 0; i < 2; i++) {
1021 if(chip->monitoring_active[i] != ucontrol->value.integer.value[i]) { 1052 if (chip->monitoring_active[i] !=
1022 chip->monitoring_active[i] = ucontrol->value.integer.value[i]; 1053 ucontrol->value.integer.value[i]) {
1054 chip->monitoring_active[i] =
1055 !!ucontrol->value.integer.value[i];
1023 changed |= (1<<i); /* mask 0x01 ans 0x02 */ 1056 changed |= (1<<i); /* mask 0x01 ans 0x02 */
1024 } 1057 }
1025 } 1058 }
1026 if(changed) { 1059 if (changed) {
1027 /* allocate or release resources for monitoring */ 1060 /* allocate or release resources for monitoring */
1028 int allocate = chip->monitoring_active[0] || chip->monitoring_active[1]; 1061 int allocate = chip->monitoring_active[0] ||
1029 if(allocate) { 1062 chip->monitoring_active[1];
1030 snd_mixart_add_ref_pipe( chip, MIXART_PCM_ANALOG, 0, 1); /* allocate the playback pipe for monitoring */ 1063 if (allocate) {
1031 snd_mixart_add_ref_pipe( chip, MIXART_PCM_ANALOG, 1, 1); /* allocate the capture pipe for monitoring */ 1064 /* allocate the playback pipe for monitoring */
1065 snd_mixart_add_ref_pipe(chip, MIXART_PCM_ANALOG, 0, 1);
1066 /* allocate the capture pipe for monitoring */
1067 snd_mixart_add_ref_pipe(chip, MIXART_PCM_ANALOG, 1, 1);
1032 } 1068 }
1033 if(changed & 0x01) mixart_update_monitoring(chip, 0); 1069 if (changed & 0x01)
1034 if(changed & 0x02) mixart_update_monitoring(chip, 1); 1070 mixart_update_monitoring(chip, 0);
1035 if(!allocate) { 1071 if (changed & 0x02)
1036 snd_mixart_kill_ref_pipe( chip->mgr, &chip->pipe_in_ana, 1); /* release the capture pipe for monitoring */ 1072 mixart_update_monitoring(chip, 1);
1037 snd_mixart_kill_ref_pipe( chip->mgr, &chip->pipe_out_ana, 1); /* release the playback pipe for monitoring */ 1073 if (!allocate) {
1074 /* release the capture pipe for monitoring */
1075 snd_mixart_kill_ref_pipe(chip->mgr,
1076 &chip->pipe_in_ana, 1);
1077 /* release the playback pipe for monitoring */
1078 snd_mixart_kill_ref_pipe(chip->mgr,
1079 &chip->pipe_out_ana, 1);
1038 } 1080 }
1039 } 1081 }
1040 1082