]> err.no Git - linux-2.6/blobdiff - sound/pci/hda/patch_via.c
Merge branch 'linus' into x86/cleanups
[linux-2.6] / sound / pci / hda / patch_via.c
index d42d8f753f11bc85f4ad66a690348b8f8923b8e8..e7e43524f8c732faeed283d6a223d30c918e5366 100644 (file)
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <sound/core.h>
 #include "hda_codec.h"
 #include "hda_local.h"
-
+#include "hda_patch.h"
 
 /* amp values */
 #define AMP_VAL_IDX_SHIFT      19
@@ -307,7 +306,6 @@ static struct snd_kcontrol_new vt1708_capture_mixer[] = {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                /* The multiple "Capture Source" controls confuse alsamixer
                 * So call somewhat different..
-                * FIXME: the controls appear in the "playback" view!
                 */
                /* .name = "Capture Source", */
                .name = "Input Source",
@@ -359,7 +357,8 @@ static int via_playback_pcm_open(struct hda_pcm_stream *hinfo,
                                 struct snd_pcm_substream *substream)
 {
        struct via_spec *spec = codec->spec;
-       return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
+       return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
+                                            hinfo);
 }
 
 static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -432,8 +431,7 @@ static int via_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
                                   struct snd_pcm_substream *substream)
 {
        struct via_spec *spec = codec->spec;
-       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
-                                  0, 0, 0);
+       snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
        return 0;
 }
 
@@ -449,6 +447,23 @@ static struct hda_pcm_stream vt1708_pcm_analog_playback = {
        },
 };
 
+static struct hda_pcm_stream vt1708_pcm_analog_s16_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 8,
+       .nid = 0x10, /* NID to query formats and rates */
+       /* We got noisy outputs on the right channel on VT1708 when
+        * 24bit samples are used.  Until any workaround is found,
+        * disable the 24bit format, so far.
+        */
+       .formats = SNDRV_PCM_FMTBIT_S16_LE,
+       .ops = {
+               .open = via_playback_pcm_open,
+               .prepare = via_playback_pcm_prepare,
+               .cleanup = via_playback_pcm_cleanup
+       },
+};
+
 static struct hda_pcm_stream vt1708_pcm_analog_capture = {
        .substreams = 2,
        .channels_min = 2,
@@ -495,6 +510,11 @@ static int via_build_controls(struct hda_codec *codec)
                                                    spec->multiout.dig_out_nid);
                if (err < 0)
                        return err;
+               err = snd_hda_create_spdif_share_sw(codec,
+                                                   &spec->multiout);
+               if (err < 0)
+                       return err;
+               spec->multiout.share_spdif = 1;
        }
        if (spec->dig_in_nid) {
                err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -525,6 +545,7 @@ static int via_build_pcms(struct hda_codec *codec)
                codec->num_pcms++;
                info++;
                info->name = spec->stream_name_digital;
+               info->pcm_type = HDA_PCM_TYPE_SPDIF;
                if (spec->multiout.dig_out_nid) {
                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
                                *(spec->stream_digital_playback);
@@ -568,25 +589,27 @@ static int via_init(struct hda_codec *codec)
                if (IS_VT1708_VENDORID(codec->vendor_id)) {
                        snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0,
                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
-                                           0x40);
+                                           PIN_OUT);
                        snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0,
                                            AC_VERB_SET_EAPD_BTLENABLE, 0x02);
                } else if (IS_VT1709_10CH_VENDORID(codec->vendor_id) ||
                           IS_VT1709_6CH_VENDORID(codec->vendor_id)) {
                        snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0,
                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
-                                           0x40);
+                                           PIN_OUT);
                        snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0,
                                            AC_VERB_SET_EAPD_BTLENABLE, 0x02);
                } else if (IS_VT1708B_8CH_VENDORID(codec->vendor_id) ||
                           IS_VT1708B_4CH_VENDORID(codec->vendor_id)) {
                        snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0,
                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
-                                           0x40);
+                                           PIN_OUT);
                        snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0,
                                            AC_VERB_SET_EAPD_BTLENABLE, 0x02);
                }
-       }
+       } else /* enable SPDIF-input pin */
+               snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0,
+                                   AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN);
 
        return 0;
 }
@@ -893,6 +916,9 @@ static int patch_vt1708(struct hda_codec *codec)
        
        spec->stream_name_analog = "VT1708 Analog";
        spec->stream_analog_playback = &vt1708_pcm_analog_playback;
+       /* disable 32bit format on VT1708 */
+       if (codec->vendor_id == 0x11061708)
+               spec->stream_analog_playback = &vt1708_pcm_analog_s16_playback;
        spec->stream_analog_capture = &vt1708_pcm_analog_capture;
 
        spec->stream_name_digital = "VT1708 Digital";
@@ -929,7 +955,6 @@ static struct snd_kcontrol_new vt1709_capture_mixer[] = {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                /* The multiple "Capture Source" controls confuse alsamixer
                 * So call somewhat different..
-                * FIXME: the controls appear in the "playback" view!
                 */
                /* .name = "Capture Source", */
                .name = "Input Source",
@@ -1478,7 +1503,6 @@ static struct snd_kcontrol_new vt1708B_capture_mixer[] = {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                /* The multiple "Capture Source" controls confuse alsamixer
                 * So call somewhat different..
-                * FIXME: the controls appear in the "playback" view!
                 */
                /* .name = "Capture Source", */
                .name = "Input Source",