24 #include <linux/time.h>
82 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
83 ucontrol->
value.integer.value[0] =
val;
95 unsigned char val, oval;
97 val = (ucontrol->
value.integer.value[0] &
mask) << shift;
100 val = (oval & ~(mask << shift)) |
val;
101 change = val != oval;
104 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
137 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
153 unsigned char left,
right, oleft, oright;
155 left = (ucontrol->
value.integer.value[0] &
mask) << left_shift;
156 right = (ucontrol->
value.integer.value[1] &
mask) << right_shift;
158 if (left_reg == right_reg) {
160 left = (oleft & ~((mask << left_shift) | (mask << right_shift))) | left |
right;
161 change = left != oleft;
167 left = (oleft & ~(mask << left_shift)) |
left;
168 right = (oright & ~(mask << right_shift)) |
right;
169 change = left != oleft || right != oright;
175 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
185 static const char *texts[5] = {
186 "CD",
"Mic",
"Line",
"Synth",
"Master"
206 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
207 switch (oval & 0x07) {
209 ucontrol->
value.enumerated.item[0] = 0;
212 ucontrol->
value.enumerated.item[0] = 1;
215 ucontrol->
value.enumerated.item[0] = 2;
218 ucontrol->
value.enumerated.item[0] = 4;
228 ucontrol->
value.enumerated.item[0] = 4;
239 unsigned char nval, oval;
241 if (ucontrol->
value.enumerated.item[0] > 4)
243 switch (ucontrol->
value.enumerated.item[0]) {
264 change = nval != oval;
267 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
275 static int snd_als4k_mono_capture_route_info(
struct snd_kcontrol *kcontrol,
278 static const char *texts[3] = {
279 "L chan only",
"R chan only",
"L ch/2 + R ch/2"
292 static int snd_als4k_mono_capture_route_get(
struct snd_kcontrol *kcontrol,
301 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
306 ucontrol->
value.enumerated.item[0] = oval;
310 static int snd_als4k_mono_capture_route_put(
struct snd_kcontrol *kcontrol,
316 unsigned char nval, oval;
318 if (ucontrol->
value.enumerated.item[0] > 2)
323 nval = (oval & ~(3 << 6))
324 | (ucontrol->
value.enumerated.item[0] << 6);
325 change = nval != oval;
328 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
338 static const char *texts[3] = {
360 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
361 switch ((oval >> 0x01) & 0x03) {
363 ucontrol->
value.enumerated.item[0] = 1;
366 ucontrol->
value.enumerated.item[0] = 2;
369 ucontrol->
value.enumerated.item[0] = 0;
380 unsigned char nval, oval;
382 if (ucontrol->
value.enumerated.item[0] > 2)
384 switch (ucontrol->
value.enumerated.item[0]) {
397 nval |= oval & ~0x06;
398 change = nval != oval;
401 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
426 unsigned char val1, val2;
431 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
432 ucontrol->
value.integer.value[0] = (val1 >> left_shift) & 0x01;
433 ucontrol->
value.integer.value[1] = (val2 >> left_shift) & 0x01;
434 ucontrol->
value.integer.value[2] = (val1 >> right_shift) & 0x01;
435 ucontrol->
value.integer.value[3] = (val2 >> right_shift) & 0x01;
448 unsigned char val1, val2, oval1, oval2;
453 val1 = oval1 & ~((1 << left_shift) | (1 << right_shift));
454 val2 = oval2 & ~((1 << left_shift) | (1 << right_shift));
455 val1 |= (ucontrol->
value.integer.value[0] & 1) << left_shift;
456 val2 |= (ucontrol->
value.integer.value[1] & 1) << left_shift;
457 val1 |= (ucontrol->
value.integer.value[2] & 1) << right_shift;
458 val2 |= (ucontrol->
value.integer.value[3] & 1) << right_shift;
459 change = val1 != oval1 || val2 != oval2;
464 spin_unlock_irqrestore(&sb->
mixer_lock, flags);
478 .info = snd_sbmixer_info_single,
479 .get = snd_sbmixer_get_single,
480 .put = snd_sbmixer_put_single,
484 .info = snd_sbmixer_info_double,
485 .get = snd_sbmixer_get_double,
486 .put = snd_sbmixer_put_double,
490 .info = snd_sb16mixer_info_input_sw,
491 .get = snd_sb16mixer_get_input_sw,
492 .put = snd_sb16mixer_put_input_sw,
496 .info = snd_sb8mixer_info_mux,
497 .get = snd_sb8mixer_get_mux,
498 .put = snd_sb8mixer_put_mux,
502 .info = snd_dt019x_input_sw_info,
503 .get = snd_dt019x_input_sw_get,
504 .put = snd_dt019x_input_sw_put,
508 .info = snd_als4k_mono_capture_route_info,
509 .get = snd_als4k_mono_capture_route_get,
510 .put = snd_als4k_mono_capture_route_put,
531 static struct sbmix_elem snd_sb20_controls[] = {
538 static unsigned char snd_sb20_init_values[][2] = {
546 static struct sbmix_elem snd_sbpro_controls[] = {
559 .name =
"Capture Source",
566 static unsigned char snd_sbpro_init_values[][2] = {
575 static struct sbmix_elem snd_sb16_controls[] = {
613 static unsigned char snd_sb16_init_values[][2] = {
629 static struct sbmix_elem snd_dt019x_controls[] = {
654 .name =
"Capture Source",
659 static unsigned char snd_dt019x_init_values[][2] = {
674 static struct sbmix_elem snd_als4000_controls[] = {
682 .name =
"Master Mono Capture Route",
700 SB_SINGLE(
"Master Playback 8kHz / 20kHz LPF Switch",
708 static unsigned char snd_als4000_init_values[][2] = {
725 static int snd_sbmixer_init(
struct snd_sb *
chip,
728 unsigned char map[][2],
739 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
742 for (idx = 0; idx < map_count; idx++) {
745 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
749 err = snd_sbmixer_add_ctl_elem(chip, &controls[idx]);
773 if ((err = snd_sbmixer_init(chip,
776 snd_sb20_init_values,
783 if ((err = snd_sbmixer_init(chip,
786 snd_sbpro_init_values,
794 if ((err = snd_sbmixer_init(chip,
797 snd_sb16_init_values,
804 err = snd_sbmixer_init(chip,
807 snd_sb16_init_values,
812 if ((err = snd_sbmixer_init(chip,
813 snd_als4000_controls,
815 snd_als4000_init_values,
821 if ((err = snd_sbmixer_init(chip,
824 snd_dt019x_init_values,
835 static unsigned char sb20_saved_regs[] = {
842 static unsigned char sbpro_saved_regs[] = {
854 static unsigned char sb16_saved_regs[] = {
872 static unsigned char dt019x_saved_regs[] = {
885 static unsigned char als4000_saved_regs[] = {
907 static void save_mixer(
struct snd_sb *chip,
unsigned char *
regs,
int num_regs)
909 unsigned char *val = chip->saved_regs;
912 for (; num_regs; num_regs--)
916 static void restore_mixer(
struct snd_sb *chip,
unsigned char *regs,
int num_regs)
918 unsigned char *val = chip->saved_regs;
921 for (; num_regs; num_regs--)
925 void snd_sbmixer_suspend(
struct snd_sb *chip)
930 save_mixer(chip, sb20_saved_regs,
ARRAY_SIZE(sb20_saved_regs));
934 save_mixer(chip, sbpro_saved_regs,
ARRAY_SIZE(sbpro_saved_regs));
939 save_mixer(chip, sb16_saved_regs,
ARRAY_SIZE(sb16_saved_regs));
942 save_mixer(chip, als4000_saved_regs,
ARRAY_SIZE(als4000_saved_regs));
945 save_mixer(chip, dt019x_saved_regs,
ARRAY_SIZE(dt019x_saved_regs));
952 void snd_sbmixer_resume(
struct snd_sb *chip)
957 restore_mixer(chip, sb20_saved_regs,
ARRAY_SIZE(sb20_saved_regs));
961 restore_mixer(chip, sbpro_saved_regs,
ARRAY_SIZE(sbpro_saved_regs));
966 restore_mixer(chip, sb16_saved_regs,
ARRAY_SIZE(sb16_saved_regs));
969 restore_mixer(chip, als4000_saved_regs,
ARRAY_SIZE(als4000_saved_regs));
972 restore_mixer(chip, dt019x_saved_regs,
ARRAY_SIZE(dt019x_saved_regs));