ALSA: hda - Keep char arrays in input_mux items
authorTakashi Iwai <tiwai@suse.de>
Thu, 9 Sep 2010 12:21:17 +0000 (14:21 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 9 Sep 2010 14:45:58 +0000 (16:45 +0200)
Keep char array in the input_mux item itself instead of pointing to
an external string.  This is a preliminary work for improving the
input-mux name based on the pin role.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_local.h
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/hda/patch_via.c

index bfdde7b0bafb8e877b1b48d92046a9441f23a6a2..4348c33c6b85d9b1f8fd53f780651aff39fb8854 100644 (file)
@@ -4662,17 +4662,8 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
 };
 EXPORT_SYMBOL_HDA(auto_pin_cfg_labels);
 
-static const char *input_labels[AUTO_PIN_LAST][4] = {
-       { "Mic", "Mic 2", "Mic 3", "Mic 4" },
-       { "Front Mic", "Front Mic 2", "Front Mic 3", "Front Mic 4" },
-       { "Line", "Line 2", "Line 3", "Line 4" },
-       { "Front Line", "Front Line 2", "Front Line 3", "Front Line 4" },
-       { "CD", "CD 2", "CD 3", "CD 4" },
-       { "Aux", "Aux 2", "Aux 3", "Aux 4" },
-};
-
-const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
-                                       int input)
+void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
+                                int input, char *str)
 {
        int type = cfg->inputs[input].type;
        int idx;
@@ -4681,7 +4672,10 @@ const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
                if (type != cfg->inputs[input].type)
                        break;
        }
-       return input_labels[type][idx];
+       if (idx > 0)
+               sprintf(str, "%s %d", auto_pin_cfg_labels[type], idx);
+       else
+               strcpy(str, auto_pin_cfg_labels[type]);
 }
 EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label);
 
index 5ea21285ee1f6e700fa320b3710495e47f06aca7..cce18ba8b5a1f30662f340fa3c07df7afc0be904 100644 (file)
@@ -566,7 +566,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
        }
        label = spec->cap_labels[spec->input_mux.num_items];
        strcpy(label, type);
-       spec->input_mux.items[spec->input_mux.num_items].label = label;
+       strcpy(spec->input_mux.items[spec->input_mux.num_items].label, label);
 
        /* unmute the PIN external input */
        unmute_input(codec, node, 0); /* index = 0? */
index fb561748adb8bcd81e24809ad5b165093f713df7..b448b0a997b186f961df3bb843ae1d72c0cf83fc 100644 (file)
@@ -215,7 +215,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
  */
 #define HDA_MAX_NUM_INPUTS     16
 struct hda_input_mux_item {
-       const char *label;
+       char label[32];
        unsigned int index;
 };
 struct hda_input_mux {
@@ -391,8 +391,8 @@ struct auto_pin_cfg_item {
 };
 
 struct auto_pin_cfg;
-const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
-                                       int input);
+void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
+                                int input, char *label);
 
 struct auto_pin_cfg {
        int line_outs;
index 3409d315f5072cb84f0e440d0b4ba87c5acf6e22..8de3a0dc45e4084b8fae633a0b24f4c06e74e6ec 100644 (file)
@@ -2926,13 +2926,13 @@ static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
                                       type <= AUTO_PIN_FRONT_MIC);
                if (err < 0)
                        return err;
-               imux->items[imux->num_items].label =
-                       snd_hda_get_input_pin_label(cfg, i);
+               snd_hda_get_input_pin_label(cfg, i,
+                       imux->items[imux->num_items].label);
                imux->items[imux->num_items].index =
                        ad1988_pin_to_adc_idx(cfg->inputs[i].pin);
                imux->num_items++;
        }
-       imux->items[imux->num_items].label = "Mix";
+       strcpy(imux->items[imux->num_items].label, "Mix");
        imux->items[imux->num_items].index = 9;
        imux->num_items++;
 
index 0c25d22be8750eda8648ebaccca3b0fd5d682fb8..0a7d9d5ea40e7500a60f2aa3b1710324456e9449 100644 (file)
@@ -4974,8 +4974,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
                if (idx < 0 && cap2)
                        idx = get_connection_index(codec, cap2, pin);
                if (idx >= 0) {
-                       imux->items[imux->num_items].label =
-                               snd_hda_get_input_pin_label(cfg, i);
+                       snd_hda_get_input_pin_label(cfg, i,
+                               imux->items[imux->num_items].label);
                        imux->items[imux->num_items].index = idx;
                        imux->num_items++;
                }
@@ -10626,9 +10626,9 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
                        break;
                nid = cfg->inputs[i].pin;
                if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
-                       char label[32];
-                       snprintf(label, sizeof(label), "%s Boost",
-                                snd_hda_get_input_pin_label(cfg, i));
+                       char pinname[32], label[32];
+                       snd_hda_get_input_pin_label(cfg, i, pinname);
+                       snprintf(label, sizeof(label), "%s Boost", pinname);
                        err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
                                  HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
                        if (err < 0)
index 7f09e140953eb0c159b317987cb21034ffa2c66a..852dae91edb1ce9dc92bc93f166d1640da4d7820 100644 (file)
@@ -1116,7 +1116,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
                struct hda_input_mux *smux = &spec->private_smux;
                /* check for mute support on SPDIF out */
                if (wcaps & AC_WCAP_OUT_AMP) {
-                       smux->items[smux->num_items].label = "Off";
+                       strcpy(smux->items[smux->num_items].label, "Off");
                        smux->items[smux->num_items].index = 0;
                        smux->num_items++;
                        spec->spdif_mute = 1;
@@ -3274,8 +3274,8 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
                return -EINVAL;
 
        for (i = 0; i < num_cons; i++) {
-               mono_mux->items[mono_mux->num_items].label =
-                                       stac92xx_mono_labels[i];
+               strcpy(mono_mux->items[mono_mux->num_items].label,
+                      stac92xx_mono_labels[i]);
                mono_mux->items[mono_mux->num_items].index = i;
                mono_mux->num_items++;
        }
@@ -3404,7 +3404,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
                labels = stac92xx_spdif_labels;
 
        for (i = 0; i < num_cons; i++) {
-               spdif_mux->items[spdif_mux->num_items].label = labels[i];
+               strcpy(spdif_mux->items[spdif_mux->num_items].label, labels[i]);
                spdif_mux->items[spdif_mux->num_items].index = i;
                spdif_mux->num_items++;
        }
@@ -3538,7 +3538,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
        int err, i;
        unsigned int def_conf;
 
-       dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
+       strcpy(dimux->items[dimux->num_items].label, stac92xx_dmic_labels[0]);
        dimux->items[dimux->num_items].index = 0;
        dimux->num_items++;
 
@@ -3572,11 +3572,11 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
                                return err;
                }
 
-               dimux->items[dimux->num_items].label = label;
+               strcpy(dimux->items[dimux->num_items].label, label);
                dimux->items[dimux->num_items].index = index;
                dimux->num_items++;
                if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
-                       imux->items[imux->num_items].label = label;
+                       strcpy(imux->items[imux->num_items].label, label);
                        imux->items[imux->num_items].index = index;
                        imux->num_items++;
                }
@@ -3713,7 +3713,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
                if (err < 0)
                        return err;
 
-               imux->items[imux->num_items].label = label;
+               strcpy(imux->items[imux->num_items].label, label);
                imux->items[imux->num_items].index = index;
                imux->num_items++;
        }
index 93b86adbce634883cd7a145ac61073466315d803..9c1909d398e32b84fa48003e661a2c809a91bb94 100644 (file)
@@ -2376,7 +2376,7 @@ static void create_hp_imux(struct via_spec *spec)
        /* for hp mode select */
        i = 0;
        while (texts[i] != NULL) {
-               imux->items[imux->num_items].label =  texts[i];
+               strcpy(imux->items[imux->num_items].label, texts[i]);
                imux->items[imux->num_items].index = i;
                imux->num_items++;
                i++;
@@ -2423,7 +2423,8 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec,
        /* for internal loopback recording select */
        for (idx = 0; idx < num_idxs; idx++) {
                if (pin_idxs[idx] == 0xff) {
-                       imux->items[imux->num_items].label = "Stereo Mixer";
+                       strcpy(imux->items[imux->num_items].label,
+                              "Stereo Mixer");
                        imux->items[imux->num_items].index = idx;
                        imux->num_items++;
                        break;
@@ -2445,8 +2446,8 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec,
                                           type_idx, idx, cap_nid);
                if (err < 0)
                        return err;
-               imux->items[imux->num_items].label =
-                       snd_hda_get_input_pin_label(cfg, i);
+               snd_hda_get_input_pin_label(cfg, i,
+                       imux->items[imux->num_items].label);
                imux->items[imux->num_items].index = idx;
                imux->num_items++;
        }
@@ -4336,7 +4337,7 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
        /* for hp mode select */
        i = 0;
        while (texts[i] != NULL)        {
-               imux->items[imux->num_items].label =  texts[i];
+               strcpy(imux->items[imux->num_items].label, texts[i]);
                imux->items[imux->num_items].index = i;
                imux->num_items++;
                i++;
@@ -5520,7 +5521,7 @@ static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec,
                return err;
 
        /* for digital mic select */
-       imux->items[imux->num_items].label = "Digital Mic";
+       strcpy(imux->items[imux->num_items].label, "Digital Mic");
        imux->items[imux->num_items].index = 4;
        imux->num_items++;
 
@@ -5843,7 +5844,7 @@ static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec,
                return err;
 
        /* for digital mic select */
-       imux->items[imux->num_items].label = "Digital Mic";
+       strcpy(imux->items[imux->num_items].label, "Digital Mic");
        imux->items[imux->num_items].index = 6;
        imux->num_items++;