aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorJonathan Woithe <jwoithe@physics.adelaide.edu.au>2006-02-28 05:47:47 -0500
committerJaroslav Kysela <perex@suse.cz>2006-03-22 04:32:59 -0500
commit92621f130e60da865de2f5aa6d3dec2ee844b803 (patch)
treefe71236c72e42e83de065983035bfd3d66e6cd7f /sound/pci
parentf7ace40d14c46dca9a12ab753677adc17b1b906c (diff)
[ALSA] HDA/ALC260: 7/7 - add SPDIF enable to test model
Modules: HDA Codec driver This patch adds mixer controls to the 'test' ALC260 model which allow the user to selectively enable or disable the SPDIF output pins. This should assist people identify digital outputs on machines which bring them to the outside world. Note that while the patch *should* work, I cannot personally verify it since my laptop doesn't bring the SPDIF lines out. As for the GPIO switches added in patch 4, these controls are currently only compiled in if debug mode is selected. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_realtek.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index c8b0ec814375..219ddf0b8d43 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -395,6 +395,60 @@ static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
395 .private_value = nid | (mask<<16) } 395 .private_value = nid | (mask<<16) }
396#endif /* CONFIG_SND_DEBUG */ 396#endif /* CONFIG_SND_DEBUG */
397 397
398/* A switch control to allow the enabling of the digital IO pins on the
399 * ALC260. This is incredibly simplistic; the intention of this control is
400 * to provide something in the test model allowing digital outputs to be
401 * identified if present. If models are found which can utilise these
402 * outputs a more complete mixer control can be devised for those models if
403 * necessary.
404 */
405#ifdef CONFIG_SND_DEBUG
406static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
407{
408 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
409 uinfo->count = 1;
410 uinfo->value.integer.min = 0;
411 uinfo->value.integer.max = 1;
412 return 0;
413}
414static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 hda_nid_t nid = kcontrol->private_value & 0xffff;
418 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
419 long *valp = ucontrol->value.integer.value;
420 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
421
422 *valp = (val & mask) != 0;
423 return 0;
424}
425static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
426{
427 signed int change;
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 hda_nid_t nid = kcontrol->private_value & 0xffff;
430 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
431 long val = *ucontrol->value.integer.value;
432 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
433
434 /* Set/unset the masked control bit(s) as needed */
435 change = (val==0?0:mask) != (ctrl_data & mask);
436 if (val==0)
437 ctrl_data &= ~mask;
438 else
439 ctrl_data |= mask;
440 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
441
442 return change;
443}
444#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
445 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
446 .info = alc_spdif_ctrl_info, \
447 .get = alc_spdif_ctrl_get, \
448 .put = alc_spdif_ctrl_put, \
449 .private_value = nid | (mask<<16) }
450#endif /* CONFIG_SND_DEBUG */
451
398/* 452/*
399 * set up from the preset table 453 * set up from the preset table
400 */ 454 */
@@ -3048,6 +3102,13 @@ static struct snd_kcontrol_new alc260_test_mixer[] = {
3048 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), 3102 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3049 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), 3103 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3050 3104
3105 /* Switches to allow the digital IO pins to be enabled. The datasheet
3106 * is ambigious as to which NID is which; testing on laptops which
3107 * make this output available should provide clarification.
3108 */
3109 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3110 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3111
3051 { } /* end */ 3112 { } /* end */
3052}; 3113};
3053static struct hda_verb alc260_test_init_verbs[] = { 3114static struct hda_verb alc260_test_init_verbs[] = {
@@ -3064,7 +3125,12 @@ static struct hda_verb alc260_test_init_verbs[] = {
3064 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3125 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3065 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3126 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3066 3127
3067 /* Disable digital (SPDIF) pins for now */ 3128 /* Disable digital (SPDIF) pins initially, but users can enable
3129 * them via a mixer switch. In the case of SPDIF-out, this initverb
3130 * payload also sets the generation to 0, output to be in "consumer"
3131 * PCM format, copyright asserted, no pre-emphasis and no validity
3132 * control.
3133 */
3068 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3134 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3069 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3135 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3070 3136