[ALSA] Fix and cleanup of CM9880 auto-configuration
authorTakashi Iwai <tiwai@suse.de>
Wed, 20 Apr 2005 11:45:55 +0000 (13:45 +0200)
committerJaroslav Kysela <perex@suse.cz>
Sun, 29 May 2005 08:04:58 +0000 (10:04 +0200)
HDA Codec driver
Fix and cleanup of CM9880 automatic PIN configuration.
snd_hda_codec_setup_stream() doesn't do anything when NID is 0.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/patch_cmedia.c

index 890b7566154a2c20063bebbc5a7418182ac88b05..44fac2182fcc913e85d8a3478df55941207c960b 100644 (file)
@@ -549,6 +549,9 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag,
                                int channel_id, int format)
 {
+       if (! nid)
+               return;
+
        snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
                    nid, stream_tag, channel_id, format);
        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
index 263f5b698bac4268f6a2b01ee57d993e147c4c2a..43fc245d9a624ad83027302116d4b2f62109f72d 100644 (file)
@@ -259,7 +259,9 @@ enum {
 /* configuration default - 32bit */
 #define AC_DEFCFG_SEQUENCE             (0xf<<0)
 #define AC_DEFCFG_DEF_ASSOC            (0xf<<4)
+#define AC_DEFCFG_ASSOC_SHIFT          4
 #define AC_DEFCFG_MISC                 (0xf<<8)
+#define AC_DEFCFG_MISC_SHIFT           8
 #define AC_DEFCFG_COLOR                        (0xf<<12)
 #define AC_DEFCFG_COLOR_SHIFT          12
 #define AC_DEFCFG_CONN_TYPE            (0xf<<16)
index e64e29dac8243f459623edfd06778a6917fb0e9c..087230ca20a5c87b4498a9b976af87bf1c5f9612 100644 (file)
@@ -365,7 +365,6 @@ static int cmi9880_build_controls(struct hda_codec *codec)
        return 0;
 }
 
-#define AC_DEFCFG_ASSOC_SHIFT          4
 #define get_defcfg_connect(cfg) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
 #define get_defcfg_association(cfg) ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
 #define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE)
@@ -796,6 +795,7 @@ static int patch_cmi9880(struct hda_codec *codec)
                {
                unsigned int port_e, port_f, port_g, port_h;
                unsigned int port_spdifi, port_spdifo;
+               int max_channels;
                /* collect pin default configuration */
                cmi9880_get_pin_def_config(codec);
                port_e = cmi9880_get_def_config(codec, 0x0f);
@@ -805,33 +805,40 @@ static int patch_cmi9880(struct hda_codec *codec)
                port_spdifi = cmi9880_get_def_config(codec, 0x13);
                port_spdifo = cmi9880_get_def_config(codec, 0x12);
                spec->front_panel = 1;
-               if ((get_defcfg_connect(port_e) == AC_JACK_PORT_NONE)
-               || (get_defcfg_connect(port_f) == AC_JACK_PORT_NONE)) {
+               if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE ||
+                   get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) {
                        spec->surr_switch = 1;
                        /* no front panel */
-                       if ((get_defcfg_connect(port_g) == AC_JACK_PORT_NONE)
-                       || (get_defcfg_connect(port_h) == AC_JACK_PORT_NONE)) {
+                       if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE ||
+                           get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) {
                                /* no optional rear panel */
                                spec->board_config = CMI_MINIMAL;
                                spec->front_panel = 0;
                                spec->num_ch_modes = 2;
-                       } else
+                       } else {
                                spec->board_config = CMI_MIN_FP;
                                spec->num_ch_modes = 3;
+                       }
                        spec->channel_modes = cmi9880_channel_modes;
                        spec->input_mux = &cmi9880_basic_mux;
+                       spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
                } else {
                        spec->input_mux = &cmi9880_basic_mux;
-                       if (get_defcfg_connect(port_spdifo) != 1)
+                       if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE)
                                spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
-                       if (get_defcfg_connect(port_spdifi) != 1)
+                       if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE)
                                spec->dig_in_nid = CMI_DIG_IN_NID;
+                       spec->multiout.max_channels = 8;
                }
-               spec->multiout.max_channels = cmi9880_get_multich_pins(codec);
-               cmi9880_fill_multi_dac_nids(codec);
-               cmi9880_fill_multi_init(codec);
-               }
+               max_channels = cmi9880_get_multich_pins(codec);
+               if (max_channels > 0) {
+                       spec->multiout.max_channels = max_channels;
+                       cmi9880_fill_multi_dac_nids(codec);
+                       cmi9880_fill_multi_init(codec);
+               } else
+                       snd_printd("patch_cmedia: cannot detect association in defcfg\n");
                break;
+               }
        }
 
        spec->multiout.num_dacs = 4;