diff options
author | James Courtier-Dutton <James@superbug.co.uk> | 2006-10-10 13:08:45 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:00:40 -0500 |
commit | b0dbdaea55d55c05be972cd2a040acfa073b0509 (patch) | |
tree | d1bcb3f75e87dd524832a43935c4c6569ca2f76a /sound/pci/emu10k1/emumixer.c | |
parent | 0f71e8b98506252db22a0c4fcfecb0aadcf393cc (diff) |
[ALSA] snd-emu10k1: Add emu1010 internal clock rate control for 44100 or 48000.
Signed-off-by: James Courtier-Dutton <James@superbug.co.uk>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/emu10k1/emumixer.c')
-rw-r--r-- | sound/pci/emu10k1/emumixer.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 2edf92a4f065..a118fee11cdd 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <sound/core.h> | 36 | #include <sound/core.h> |
37 | #include <sound/emu10k1.h> | 37 | #include <sound/emu10k1.h> |
38 | #include <linux/delay.h> | ||
38 | 39 | ||
39 | #define AC97_ID_STAC9758 0x83847658 | 40 | #define AC97_ID_STAC9758 0x83847658 |
40 | 41 | ||
@@ -490,6 +491,94 @@ static struct snd_kcontrol_new snd_emu1010_dac_pads[] __devinitdata = { | |||
490 | EMU1010_DAC_PADS("DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1), | 491 | EMU1010_DAC_PADS("DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1), |
491 | }; | 492 | }; |
492 | 493 | ||
494 | |||
495 | static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol, | ||
496 | struct snd_ctl_elem_info *uinfo) | ||
497 | { | ||
498 | static char *texts[2] = { | ||
499 | "44100", "48000" | ||
500 | }; | ||
501 | |||
502 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
503 | uinfo->count = 1; | ||
504 | uinfo->value.enumerated.items = 2; | ||
505 | if (uinfo->value.enumerated.item > 1) | ||
506 | uinfo->value.enumerated.item = 1; | ||
507 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
508 | return 0; | ||
509 | } | ||
510 | |||
511 | static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol, | ||
512 | struct snd_ctl_elem_value *ucontrol) | ||
513 | { | ||
514 | struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); | ||
515 | |||
516 | ucontrol->value.enumerated.item[0] = emu->emu1010.internal_clock; | ||
517 | return 0; | ||
518 | } | ||
519 | |||
520 | static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol, | ||
521 | struct snd_ctl_elem_value *ucontrol) | ||
522 | { | ||
523 | struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); | ||
524 | unsigned int val; | ||
525 | int change = 0; | ||
526 | |||
527 | val = ucontrol->value.enumerated.item[0] ; | ||
528 | change = (emu->emu1010.internal_clock != val); | ||
529 | if (change) { | ||
530 | emu->emu1010.internal_clock = val; | ||
531 | switch (val) { | ||
532 | case 0: | ||
533 | /* 44100 */ | ||
534 | /* Mute all */ | ||
535 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE ); | ||
536 | /* Default fallback clock 48kHz */ | ||
537 | snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_44_1K ); | ||
538 | /* Word Clock source, Internal 44.1kHz x1 */ | ||
539 | snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, | ||
540 | EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X ); | ||
541 | /* Set LEDs on Audio Dock */ | ||
542 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, | ||
543 | EMU_HANA_DOCK_LEDS_2_44K | EMU_HANA_DOCK_LEDS_2_LOCK ); | ||
544 | /* Allow DLL to settle */ | ||
545 | udelay(10000); | ||
546 | /* Unmute all */ | ||
547 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); | ||
548 | break; | ||
549 | case 1: | ||
550 | /* 48000 */ | ||
551 | /* Mute all */ | ||
552 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE ); | ||
553 | /* Default fallback clock 48kHz */ | ||
554 | snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K ); | ||
555 | /* Word Clock source, Internal 48kHz x1 */ | ||
556 | snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, | ||
557 | EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X ); | ||
558 | /* Set LEDs on Audio Dock */ | ||
559 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, | ||
560 | EMU_HANA_DOCK_LEDS_2_48K | EMU_HANA_DOCK_LEDS_2_LOCK ); | ||
561 | /* Allow DLL to settle */ | ||
562 | udelay(10000); | ||
563 | /* Unmute all */ | ||
564 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); | ||
565 | break; | ||
566 | } | ||
567 | } | ||
568 | return change; | ||
569 | } | ||
570 | |||
571 | static struct snd_kcontrol_new snd_emu1010_internal_clock = | ||
572 | { | ||
573 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
574 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
575 | .name = "Clock Internal Rate", | ||
576 | .count = 1, | ||
577 | .info = snd_emu1010_internal_clock_info, | ||
578 | .get = snd_emu1010_internal_clock_get, | ||
579 | .put = snd_emu1010_internal_clock_put | ||
580 | }; | ||
581 | |||
493 | #if 0 | 582 | #if 0 |
494 | static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 583 | static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
495 | { | 584 | { |
@@ -1491,6 +1580,9 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu, | |||
1491 | if (err < 0) | 1580 | if (err < 0) |
1492 | return err; | 1581 | return err; |
1493 | } | 1582 | } |
1583 | err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_internal_clock, emu)); | ||
1584 | if (err < 0) | ||
1585 | return err; | ||
1494 | } | 1586 | } |
1495 | 1587 | ||
1496 | return 0; | 1588 | return 0; |