aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/pcxhr/pcxhr_mixer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/pcxhr/pcxhr_mixer.c')
-rw-r--r--sound/pci/pcxhr/pcxhr_mixer.c75
1 files changed, 38 insertions, 37 deletions
diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c
index 760e733ac25e..94e63a1e90d9 100644
--- a/sound/pci/pcxhr/pcxhr_mixer.c
+++ b/sound/pci/pcxhr/pcxhr_mixer.c
@@ -25,6 +25,7 @@
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/mutex.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include "pcxhr.h" 30#include "pcxhr.h"
30#include "pcxhr_hwdep.h" 31#include "pcxhr_hwdep.h"
@@ -92,7 +93,7 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol,
92 struct snd_ctl_elem_value *ucontrol) 93 struct snd_ctl_elem_value *ucontrol)
93{ 94{
94 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 95 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
95 down(&chip->mgr->mixer_mutex); 96 mutex_lock(&chip->mgr->mixer_mutex);
96 if (kcontrol->private_value == 0) { /* playback */ 97 if (kcontrol->private_value == 0) { /* playback */
97 ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; 98 ucontrol->value.integer.value[0] = chip->analog_playback_volume[0];
98 ucontrol->value.integer.value[1] = chip->analog_playback_volume[1]; 99 ucontrol->value.integer.value[1] = chip->analog_playback_volume[1];
@@ -100,7 +101,7 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol,
100 ucontrol->value.integer.value[0] = chip->analog_capture_volume[0]; 101 ucontrol->value.integer.value[0] = chip->analog_capture_volume[0];
101 ucontrol->value.integer.value[1] = chip->analog_capture_volume[1]; 102 ucontrol->value.integer.value[1] = chip->analog_capture_volume[1];
102 } 103 }
103 up(&chip->mgr->mixer_mutex); 104 mutex_unlock(&chip->mgr->mixer_mutex);
104 return 0; 105 return 0;
105} 106}
106 107
@@ -111,7 +112,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
111 int changed = 0; 112 int changed = 0;
112 int is_capture, i; 113 int is_capture, i;
113 114
114 down(&chip->mgr->mixer_mutex); 115 mutex_lock(&chip->mgr->mixer_mutex);
115 is_capture = (kcontrol->private_value != 0); 116 is_capture = (kcontrol->private_value != 0);
116 for (i = 0; i < 2; i++) { 117 for (i = 0; i < 2; i++) {
117 int new_volume = ucontrol->value.integer.value[i]; 118 int new_volume = ucontrol->value.integer.value[i];
@@ -123,7 +124,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
123 pcxhr_update_analog_audio_level(chip, is_capture, i); 124 pcxhr_update_analog_audio_level(chip, is_capture, i);
124 } 125 }
125 } 126 }
126 up(&chip->mgr->mixer_mutex); 127 mutex_unlock(&chip->mgr->mixer_mutex);
127 return changed; 128 return changed;
128} 129}
129 130
@@ -150,10 +151,10 @@ static int pcxhr_audio_sw_get(struct snd_kcontrol *kcontrol,
150{ 151{
151 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 152 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
152 153
153 down(&chip->mgr->mixer_mutex); 154 mutex_lock(&chip->mgr->mixer_mutex);
154 ucontrol->value.integer.value[0] = chip->analog_playback_active[0]; 155 ucontrol->value.integer.value[0] = chip->analog_playback_active[0];
155 ucontrol->value.integer.value[1] = chip->analog_playback_active[1]; 156 ucontrol->value.integer.value[1] = chip->analog_playback_active[1];
156 up(&chip->mgr->mixer_mutex); 157 mutex_unlock(&chip->mgr->mixer_mutex);
157 return 0; 158 return 0;
158} 159}
159 160
@@ -162,7 +163,7 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
162{ 163{
163 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 164 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
164 int i, changed = 0; 165 int i, changed = 0;
165 down(&chip->mgr->mixer_mutex); 166 mutex_lock(&chip->mgr->mixer_mutex);
166 for(i = 0; i < 2; i++) { 167 for(i = 0; i < 2; i++) {
167 if (chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) { 168 if (chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) {
168 chip->analog_playback_active[i] = ucontrol->value.integer.value[i]; 169 chip->analog_playback_active[i] = ucontrol->value.integer.value[i];
@@ -170,7 +171,7 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
170 pcxhr_update_analog_audio_level(chip, 0, i); /* update playback levels */ 171 pcxhr_update_analog_audio_level(chip, 0, i); /* update playback levels */
171 } 172 }
172 } 173 }
173 up(&chip->mgr->mixer_mutex); 174 mutex_unlock(&chip->mgr->mixer_mutex);
174 return changed; 175 return changed;
175} 176}
176 177
@@ -299,14 +300,14 @@ static int pcxhr_pcm_vol_get(struct snd_kcontrol *kcontrol,
299 int *stored_volume; 300 int *stored_volume;
300 int is_capture = kcontrol->private_value; 301 int is_capture = kcontrol->private_value;
301 302
302 down(&chip->mgr->mixer_mutex); 303 mutex_lock(&chip->mgr->mixer_mutex);
303 if (is_capture) 304 if (is_capture)
304 stored_volume = chip->digital_capture_volume; /* digital capture */ 305 stored_volume = chip->digital_capture_volume; /* digital capture */
305 else 306 else
306 stored_volume = chip->digital_playback_volume[idx]; /* digital playback */ 307 stored_volume = chip->digital_playback_volume[idx]; /* digital playback */
307 ucontrol->value.integer.value[0] = stored_volume[0]; 308 ucontrol->value.integer.value[0] = stored_volume[0];
308 ucontrol->value.integer.value[1] = stored_volume[1]; 309 ucontrol->value.integer.value[1] = stored_volume[1];
309 up(&chip->mgr->mixer_mutex); 310 mutex_unlock(&chip->mgr->mixer_mutex);
310 return 0; 311 return 0;
311} 312}
312 313
@@ -320,7 +321,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
320 int *stored_volume; 321 int *stored_volume;
321 int i; 322 int i;
322 323
323 down(&chip->mgr->mixer_mutex); 324 mutex_lock(&chip->mgr->mixer_mutex);
324 if (is_capture) 325 if (is_capture)
325 stored_volume = chip->digital_capture_volume; /* digital capture */ 326 stored_volume = chip->digital_capture_volume; /* digital capture */
326 else 327 else
@@ -335,7 +336,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
335 } 336 }
336 if (! is_capture && changed) 337 if (! is_capture && changed)
337 pcxhr_update_playback_stream_level(chip, idx); /* update playback volume */ 338 pcxhr_update_playback_stream_level(chip, idx); /* update playback volume */
338 up(&chip->mgr->mixer_mutex); 339 mutex_unlock(&chip->mgr->mixer_mutex);
339 return changed; 340 return changed;
340} 341}
341 342
@@ -356,10 +357,10 @@ static int pcxhr_pcm_sw_get(struct snd_kcontrol *kcontrol,
356 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 357 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
357 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 358 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
358 359
359 down(&chip->mgr->mixer_mutex); 360 mutex_lock(&chip->mgr->mixer_mutex);
360 ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0]; 361 ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0];
361 ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1]; 362 ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1];
362 up(&chip->mgr->mixer_mutex); 363 mutex_unlock(&chip->mgr->mixer_mutex);
363 return 0; 364 return 0;
364} 365}
365 366
@@ -370,7 +371,7 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
370 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ 371 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
371 int i, j; 372 int i, j;
372 373
373 down(&chip->mgr->mixer_mutex); 374 mutex_lock(&chip->mgr->mixer_mutex);
374 j = idx; 375 j = idx;
375 for (i = 0; i < 2; i++) { 376 for (i = 0; i < 2; i++) {
376 if (chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) { 377 if (chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) {
@@ -380,7 +381,7 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
380 } 381 }
381 if (changed) 382 if (changed)
382 pcxhr_update_playback_stream_level(chip, idx); 383 pcxhr_update_playback_stream_level(chip, idx);
383 up(&chip->mgr->mixer_mutex); 384 mutex_unlock(&chip->mgr->mixer_mutex);
384 return changed; 385 return changed;
385} 386}
386 387
@@ -402,10 +403,10 @@ static int pcxhr_monitor_vol_get(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol) 403 struct snd_ctl_elem_value *ucontrol)
403{ 404{
404 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 405 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
405 down(&chip->mgr->mixer_mutex); 406 mutex_lock(&chip->mgr->mixer_mutex);
406 ucontrol->value.integer.value[0] = chip->monitoring_volume[0]; 407 ucontrol->value.integer.value[0] = chip->monitoring_volume[0];
407 ucontrol->value.integer.value[1] = chip->monitoring_volume[1]; 408 ucontrol->value.integer.value[1] = chip->monitoring_volume[1];
408 up(&chip->mgr->mixer_mutex); 409 mutex_unlock(&chip->mgr->mixer_mutex);
409 return 0; 410 return 0;
410} 411}
411 412
@@ -416,7 +417,7 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
416 int changed = 0; 417 int changed = 0;
417 int i; 418 int i;
418 419
419 down(&chip->mgr->mixer_mutex); 420 mutex_lock(&chip->mgr->mixer_mutex);
420 for (i = 0; i < 2; i++) { 421 for (i = 0; i < 2; i++) {
421 if (chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) { 422 if (chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) {
422 chip->monitoring_volume[i] = ucontrol->value.integer.value[i]; 423 chip->monitoring_volume[i] = ucontrol->value.integer.value[i];
@@ -426,7 +427,7 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
426 changed = 1; 427 changed = 1;
427 } 428 }
428 } 429 }
429 up(&chip->mgr->mixer_mutex); 430 mutex_unlock(&chip->mgr->mixer_mutex);
430 return changed; 431 return changed;
431} 432}
432 433
@@ -446,10 +447,10 @@ static int pcxhr_monitor_sw_get(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_value *ucontrol) 447 struct snd_ctl_elem_value *ucontrol)
447{ 448{
448 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 449 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
449 down(&chip->mgr->mixer_mutex); 450 mutex_lock(&chip->mgr->mixer_mutex);
450 ucontrol->value.integer.value[0] = chip->monitoring_active[0]; 451 ucontrol->value.integer.value[0] = chip->monitoring_active[0];
451 ucontrol->value.integer.value[1] = chip->monitoring_active[1]; 452 ucontrol->value.integer.value[1] = chip->monitoring_active[1];
452 up(&chip->mgr->mixer_mutex); 453 mutex_unlock(&chip->mgr->mixer_mutex);
453 return 0; 454 return 0;
454} 455}
455 456
@@ -460,7 +461,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
460 int changed = 0; 461 int changed = 0;
461 int i; 462 int i;
462 463
463 down(&chip->mgr->mixer_mutex); 464 mutex_lock(&chip->mgr->mixer_mutex);
464 for (i = 0; i < 2; i++) { 465 for (i = 0; i < 2; i++) {
465 if (chip->monitoring_active[i] != ucontrol->value.integer.value[i]) { 466 if (chip->monitoring_active[i] != ucontrol->value.integer.value[i]) {
466 chip->monitoring_active[i] = ucontrol->value.integer.value[i]; 467 chip->monitoring_active[i] = ucontrol->value.integer.value[i];
@@ -474,7 +475,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
474 /* update right monitoring volume and mute */ 475 /* update right monitoring volume and mute */
475 pcxhr_update_audio_pipe_level(chip, 0, 1); 476 pcxhr_update_audio_pipe_level(chip, 0, 1);
476 477
477 up(&chip->mgr->mixer_mutex); 478 mutex_unlock(&chip->mgr->mixer_mutex);
478 return (changed != 0); 479 return (changed != 0);
479} 480}
480 481
@@ -571,13 +572,13 @@ static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol,
571 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); 572 struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
572 int ret = 0; 573 int ret = 0;
573 574
574 down(&chip->mgr->mixer_mutex); 575 mutex_lock(&chip->mgr->mixer_mutex);
575 if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) { 576 if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) {
576 chip->audio_capture_source = ucontrol->value.enumerated.item[0]; 577 chip->audio_capture_source = ucontrol->value.enumerated.item[0];
577 pcxhr_set_audio_source(chip); 578 pcxhr_set_audio_source(chip);
578 ret = 1; 579 ret = 1;
579 } 580 }
580 up(&chip->mgr->mixer_mutex); 581 mutex_unlock(&chip->mgr->mixer_mutex);
581 return ret; 582 return ret;
582} 583}
583 584
@@ -636,9 +637,9 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
636 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); 637 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
637 int rate, ret = 0; 638 int rate, ret = 0;
638 639
639 down(&mgr->mixer_mutex); 640 mutex_lock(&mgr->mixer_mutex);
640 if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) { 641 if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
641 down(&mgr->setup_mutex); 642 mutex_lock(&mgr->setup_mutex);
642 mgr->use_clock_type = ucontrol->value.enumerated.item[0]; 643 mgr->use_clock_type = ucontrol->value.enumerated.item[0];
643 if (mgr->use_clock_type) 644 if (mgr->use_clock_type)
644 pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate); 645 pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate);
@@ -649,10 +650,10 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
649 if (mgr->sample_rate) 650 if (mgr->sample_rate)
650 mgr->sample_rate = rate; 651 mgr->sample_rate = rate;
651 } 652 }
652 up(&mgr->setup_mutex); 653 mutex_unlock(&mgr->setup_mutex);
653 ret = 1; /* return 1 even if the set was not done. ok ? */ 654 ret = 1; /* return 1 even if the set was not done. ok ? */
654 } 655 }
655 up(&mgr->mixer_mutex); 656 mutex_unlock(&mgr->mixer_mutex);
656 return ret; 657 return ret;
657} 658}
658 659
@@ -685,7 +686,7 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
685 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); 686 struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
686 int i, err, rate; 687 int i, err, rate;
687 688
688 down(&mgr->mixer_mutex); 689 mutex_lock(&mgr->mixer_mutex);
689 for(i = 0; i < 3 + mgr->capture_chips; i++) { 690 for(i = 0; i < 3 + mgr->capture_chips; i++) {
690 if (i == PCXHR_CLOCK_TYPE_INTERNAL) 691 if (i == PCXHR_CLOCK_TYPE_INTERNAL)
691 rate = mgr->sample_rate_real; 692 rate = mgr->sample_rate_real;
@@ -696,7 +697,7 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
696 } 697 }
697 ucontrol->value.integer.value[i] = rate; 698 ucontrol->value.integer.value[i] = rate;
698 } 699 }
699 up(&mgr->mixer_mutex); 700 mutex_unlock(&mgr->mixer_mutex);
700 return 0; 701 return 0;
701} 702}
702 703
@@ -765,7 +766,7 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
765 unsigned char aes_bits; 766 unsigned char aes_bits;
766 int i, err; 767 int i, err;
767 768
768 down(&chip->mgr->mixer_mutex); 769 mutex_lock(&chip->mgr->mixer_mutex);
769 for(i = 0; i < 5; i++) { 770 for(i = 0; i < 5; i++) {
770 if (kcontrol->private_value == 0) /* playback */ 771 if (kcontrol->private_value == 0) /* playback */
771 aes_bits = chip->aes_bits[i]; 772 aes_bits = chip->aes_bits[i];
@@ -776,7 +777,7 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
776 } 777 }
777 ucontrol->value.iec958.status[i] = aes_bits; 778 ucontrol->value.iec958.status[i] = aes_bits;
778 } 779 }
779 up(&chip->mgr->mixer_mutex); 780 mutex_unlock(&chip->mgr->mixer_mutex);
780 return 0; 781 return 0;
781} 782}
782 783
@@ -828,14 +829,14 @@ static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol,
828 int i, changed = 0; 829 int i, changed = 0;
829 830
830 /* playback */ 831 /* playback */
831 down(&chip->mgr->mixer_mutex); 832 mutex_lock(&chip->mgr->mixer_mutex);
832 for (i = 0; i < 5; i++) { 833 for (i = 0; i < 5; i++) {
833 if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) { 834 if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) {
834 pcxhr_iec958_update_byte(chip, i, ucontrol->value.iec958.status[i]); 835 pcxhr_iec958_update_byte(chip, i, ucontrol->value.iec958.status[i]);
835 changed = 1; 836 changed = 1;
836 } 837 }
837 } 838 }
838 up(&chip->mgr->mixer_mutex); 839 mutex_unlock(&chip->mgr->mixer_mutex);
839 return changed; 840 return changed;
840} 841}
841 842
@@ -916,7 +917,7 @@ int pcxhr_create_mixer(struct pcxhr_mgr *mgr)
916 struct snd_pcxhr *chip; 917 struct snd_pcxhr *chip;
917 int err, i; 918 int err, i;
918 919
919 init_MUTEX(&mgr->mixer_mutex); /* can be in another place */ 920 mutex_init(&mgr->mixer_mutex); /* can be in another place */
920 921
921 for (i = 0; i < mgr->num_cards; i++) { 922 for (i = 0; i < mgr->num_cards; i++) {
922 struct snd_kcontrol_new temp; 923 struct snd_kcontrol_new temp;