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