Merge branch 'fix/hda' into topic/hda
authorTakashi Iwai <tiwai@suse.de>
Tue, 17 Nov 2009 15:00:33 +0000 (16:00 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 17 Nov 2009 15:00:33 +0000 (16:00 +0100)
1  2 
sound/pci/hda/patch_realtek.c

index ef7d21097eeb4055af1a7236fa2e719da7044191,70583719282bed6d0e62b44cc1c15127fc0b916e..ba339d745aabf27ccd9851532d4903cfdc56c83b
@@@ -2410,14 -2410,12 +2410,14 @@@ static const char *alc_slave_sws[] = 
  
  static void alc_free_kctls(struct hda_codec *codec);
  
 +#ifdef CONFIG_SND_HDA_INPUT_BEEP
  /* additional beep mixers; the actual parameters are overwritten at build */
  static struct snd_kcontrol_new alc_beep_mixer[] = {
        HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
 +      HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
        { } /* end */
  };
 +#endif
  
  static int alc_build_controls(struct hda_codec *codec)
  {
                        return err;
        }
  
 +#ifdef CONFIG_SND_HDA_INPUT_BEEP
        /* create beep controls if needed */
        if (spec->beep_amp) {
                struct snd_kcontrol_new *knew;
                        if (!kctl)
                                return -ENOMEM;
                        kctl->private_value = spec->beep_amp;
 -                      err = snd_hda_ctl_add(codec, kctl);
 +                      err = snd_hda_ctl_add(codec,
 +                                      get_amp_nid_(spec->beep_amp), kctl);
                        if (err < 0)
                                return err;
                }
        }
 +#endif
  
        /* if we have no master control, let's create it */
        if (!spec->no_analog &&
@@@ -4327,26 -4322,10 +4327,26 @@@ static int add_control(struct alc_spec 
        knew->name = kstrdup(name, GFP_KERNEL);
        if (!knew->name)
                return -ENOMEM;
 +      if (get_amp_nid_(val))
 +              knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
        knew->private_value = val;
        return 0;
  }
  
 +static int add_control_with_pfx(struct alc_spec *spec, int type,
 +                              const char *pfx, const char *dir,
 +                              const char *sfx, unsigned long val)
 +{
 +      char name[32];
 +      snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
 +      return add_control(spec, type, name, val);
 +}
 +
 +#define add_pb_vol_ctrl(spec, type, pfx, val) \
 +      add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
 +#define add_pb_sw_ctrl(spec, type, pfx, val) \
 +      add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
 +
  #define alc880_is_fixed_pin(nid)      ((nid) >= 0x14 && (nid) <= 0x17)
  #define alc880_fixed_pin_idx(nid)     ((nid) - 0x14)
  #define alc880_is_multi_pin(nid)      ((nid) >= 0x18)
@@@ -4400,6 -4379,7 +4400,6 @@@ static int alc880_auto_fill_dac_nids(st
  static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
                                             const struct auto_pin_cfg *cfg)
  {
 -      char name[32];
        static const char *chname[4] = {
                "Front", "Surround", NULL /*CLFE*/, "Side"
        };
                nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
                if (i == 2) {
                        /* Center/LFE */
 -                      err = add_control(spec, ALC_CTL_WIDGET_VOL,
 -                                        "Center Playback Volume",
 +                      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
 +                                            "Center",
                                          HDA_COMPOSE_AMP_VAL(nid, 1, 0,
                                                              HDA_OUTPUT));
                        if (err < 0)
                                return err;
 -                      err = add_control(spec, ALC_CTL_WIDGET_VOL,
 -                                        "LFE Playback Volume",
 +                      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
 +                                            "LFE",
                                          HDA_COMPOSE_AMP_VAL(nid, 2, 0,
                                                              HDA_OUTPUT));
                        if (err < 0)
                                return err;
 -                      err = add_control(spec, ALC_CTL_BIND_MUTE,
 -                                        "Center Playback Switch",
 +                      err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
 +                                           "Center",
                                          HDA_COMPOSE_AMP_VAL(nid, 1, 2,
                                                              HDA_INPUT));
                        if (err < 0)
                                return err;
 -                      err = add_control(spec, ALC_CTL_BIND_MUTE,
 -                                        "LFE Playback Switch",
 +                      err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
 +                                           "LFE",
                                          HDA_COMPOSE_AMP_VAL(nid, 2, 2,
                                                              HDA_INPUT));
                        if (err < 0)
                                pfx = "Speaker";
                        else
                                pfx = chname[i];
 -                      sprintf(name, "%s Playback Volume", pfx);
 -                      err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +                      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
                                          HDA_COMPOSE_AMP_VAL(nid, 3, 0,
                                                              HDA_OUTPUT));
                        if (err < 0)
                                return err;
 -                      sprintf(name, "%s Playback Switch", pfx);
 -                      err = add_control(spec, ALC_CTL_BIND_MUTE, name,
 +                      err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
                                          HDA_COMPOSE_AMP_VAL(nid, 3, 2,
                                                              HDA_INPUT));
                        if (err < 0)
@@@ -4464,6 -4446,7 +4464,6 @@@ static int alc880_auto_create_extra_out
  {
        hda_nid_t nid;
        int err;
 -      char name[32];
  
        if (!pin)
                return 0;
                        spec->multiout.extra_out_nid[0] = nid;
                /* control HP volume/switch on the output mixer amp */
                nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
 -              sprintf(name, "%s Playback Volume", pfx);
 -              err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +              err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
                                  HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
                if (err < 0)
                        return err;
 -              sprintf(name, "%s Playback Switch", pfx);
 -              err = add_control(spec, ALC_CTL_BIND_MUTE, name,
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
                                  HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
                if (err < 0)
                        return err;
        } else if (alc880_is_multi_pin(pin)) {
                /* set manual connection */
                /* we have only a switch on HP-out PIN */
 -              sprintf(name, "%s Playback Switch", pfx);
 -              err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
                                  HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
                if (err < 0)
                        return err;
@@@ -4501,13 -4487,16 +4501,13 @@@ static int new_analog_input(struct alc_
                            const char *ctlname,
                            int idx, hda_nid_t mix_nid)
  {
 -      char name[32];
        int err;
  
 -      sprintf(name, "%s Playback Volume", ctlname);
 -      err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
                          HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
        if (err < 0)
                return err;
 -      sprintf(name, "%s Playback Switch", ctlname);
 -      err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +      err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
                          HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
        if (err < 0)
                return err;
@@@ -4784,12 -4773,8 +4784,12 @@@ static void set_capture_mixer(struct hd
        }
  }
  
 +#ifdef CONFIG_SND_HDA_INPUT_BEEP
  #define set_beep_amp(spec, nid, idx, dir) \
        ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
 +#else
 +#define set_beep_amp(spec, nid, idx, dir) /* NOP */
 +#endif
  
  /*
   * OK, here we have finally the patch for ALC880
@@@ -6004,6 -5989,7 +6004,6 @@@ static int alc260_add_playback_controls
  {
        hda_nid_t nid_vol;
        unsigned long vol_val, sw_val;
 -      char name[32];
        int err;
  
        if (nid >= 0x0f && nid < 0x11) {
  
        if (!(*vol_bits & (1 << nid_vol))) {
                /* first control for the volume widget */
 -              snprintf(name, sizeof(name), "%s Playback Volume", pfx);
 -              err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
 +              err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
                if (err < 0)
                        return err;
                *vol_bits |= (1 << nid_vol);
        }
 -      snprintf(name, sizeof(name), "%s Playback Switch", pfx);
 -      err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
 +      err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
        if (err < 0)
                return err;
        return 1;
@@@ -7348,8 -7336,8 +7348,8 @@@ static struct snd_kcontrol_new alc882_m
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
        /* FIXME: this looks suspicious...
 -      HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
 -      HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
 +      HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
 +      HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
        */
        { } /* end */
  };
@@@ -10968,6 -10956,7 +10968,6 @@@ static int alc262_check_volbit(hda_nid_
  static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
                                  const char *pfx, int *vbits)
  {
 -      char name[32];
        unsigned long val;
        int vbit;
  
        if (*vbits & vbit) /* a volume control for this mixer already there */
                return 0;
        *vbits |= vbit;
 -      snprintf(name, sizeof(name), "%s Playback Volume", pfx);
        if (vbit == 2)
                val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
        else
                val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
 -      return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
 +      return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
  }
  
  static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
                                 const char *pfx)
  {
 -      char name[32];
        unsigned long val;
  
        if (!nid)
                return 0;
 -      snprintf(name, sizeof(name), "%s Playback Switch", pfx);
        if (nid == 0x16)
                val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
        else
                val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
 -      return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
 +      return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
  }
  
  /* add playback controls from the parsed DAC table */
@@@ -11470,6 -11462,7 +11470,7 @@@ static struct snd_pci_quirk alc262_cfg_
        SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
        SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
        SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
+       SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
        SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
                           ALC262_SONY_ASSAMD),
        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
@@@ -12334,9 -12327,11 +12335,9 @@@ static struct snd_kcontrol_new alc268_t
  static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
                                    const char *ctlname, int idx)
  {
 -      char name[32];
        hda_nid_t dac;
        int err;
  
 -      sprintf(name, "%s Playback Volume", ctlname);
        switch (nid) {
        case 0x14:
        case 0x16:
        }
        if (spec->multiout.dac_nids[0] != dac &&
            spec->multiout.dac_nids[1] != dac) {
 -              err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +              err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
                                  HDA_COMPOSE_AMP_VAL(dac, 3, idx,
                                                      HDA_OUTPUT));
                if (err < 0)
                spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
        }
  
 -      sprintf(name, "%s Playback Switch", ctlname);
        if (nid != 0x16)
 -              err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
                          HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
        else /* mono */
 -              err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
                          HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
        if (err < 0)
                return err;
@@@ -12392,7 -12388,8 +12393,7 @@@ static int alc268_auto_create_multi_out
  
        nid = cfg->speaker_pins[0];
        if (nid == 0x1d) {
 -              err = add_control(spec, ALC_CTL_WIDGET_VOL,
 -                                "Speaker Playback Volume",
 +              err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
                                  HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
                if (err < 0)
                        return err;
  
        nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
        if (nid == 0x16) {
 -              err = add_control(spec, ALC_CTL_WIDGET_MUTE,
 -                                "Mono Playback Switch",
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
                                  HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
                if (err < 0)
                        return err;
@@@ -14262,7 -14260,9 +14263,7 @@@ static int alc861_auto_fill_dac_nids(st
  static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
                                hda_nid_t nid, unsigned int chs)
  {
 -      char name[32];
 -      snprintf(name, sizeof(name), "%s Playback Switch", pfx);
 -      return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
 +      return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
                           HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  }
  
@@@ -15386,6 -15386,7 +15387,6 @@@ static void alc861vd_auto_init_analog_i
  static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
                                             const struct auto_pin_cfg *cfg)
  {
 -      char name[32];
        static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
        hda_nid_t nid_v, nid_s;
        int i, err;
  
                if (i == 2) {
                        /* Center/LFE */
 -                      err = add_control(spec, ALC_CTL_WIDGET_VOL,
 -                                        "Center Playback Volume",
 +                      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
 +                                            "Center",
                                          HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
                                                              HDA_OUTPUT));
                        if (err < 0)
                                return err;
 -                      err = add_control(spec, ALC_CTL_WIDGET_VOL,
 -                                        "LFE Playback Volume",
 +                      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
 +                                            "LFE",
                                          HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
                                                              HDA_OUTPUT));
                        if (err < 0)
                                return err;
 -                      err = add_control(spec, ALC_CTL_BIND_MUTE,
 -                                        "Center Playback Switch",
 +                      err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
 +                                           "Center",
                                          HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
                                                              HDA_INPUT));
                        if (err < 0)
                                return err;
 -                      err = add_control(spec, ALC_CTL_BIND_MUTE,
 -                                        "LFE Playback Switch",
 +                      err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
 +                                           "LFE",
                                          HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
                                                              HDA_INPUT));
                        if (err < 0)
                                        pfx = "PCM";
                        } else
                                pfx = chname[i];
 -                      sprintf(name, "%s Playback Volume", pfx);
 -                      err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +                      err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
                                          HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
                                                              HDA_OUTPUT));
                        if (err < 0)
                        if (cfg->line_outs == 1 &&
                            cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
                                pfx = "Speaker";
 -                      sprintf(name, "%s Playback Switch", pfx);
 -                      err = add_control(spec, ALC_CTL_BIND_MUTE, name,
 +                      err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
                                          HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
                                                              HDA_INPUT));
                        if (err < 0)
@@@ -15462,6 -15465,7 +15463,6 @@@ static int alc861vd_auto_create_extra_o
  {
        hda_nid_t nid_v, nid_s;
        int err;
 -      char name[32];
  
        if (!pin)
                return 0;
                nid_s = alc861vd_idx_to_mixer_switch(
                                alc880_fixed_pin_idx(pin));
  
 -              sprintf(name, "%s Playback Volume", pfx);
 -              err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +              err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
                                  HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
                if (err < 0)
                        return err;
 -              sprintf(name, "%s Playback Switch", pfx);
 -              err = add_control(spec, ALC_CTL_BIND_MUTE, name,
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
                                  HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
                if (err < 0)
                        return err;
        } else if (alc880_is_multi_pin(pin)) {
                /* set manual connection */
                /* we have only a switch on HP-out PIN */
 -              sprintf(name, "%s Playback Switch", pfx);
 -              err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +              err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
                                  HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
                if (err < 0)
                        return err;
@@@ -17257,17 -17264,21 +17258,17 @@@ static int alc662_auto_fill_dac_nids(st
        return 0;
  }
  
 -static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
 +static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
                              hda_nid_t nid, unsigned int chs)
  {
 -      char name[32];
 -      sprintf(name, "%s Playback Volume", pfx);
 -      return add_control(spec, ALC_CTL_WIDGET_VOL, name,
 +      return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
                           HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  }
  
 -static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
 +static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
                             hda_nid_t nid, unsigned int chs)
  {
 -      char name[32];
 -      sprintf(name, "%s Playback Switch", pfx);
 -      return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +      return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
                           HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
  }
  
@@@ -17345,11 -17356,13 +17346,11 @@@ static int alc662_auto_create_extra_out
                return 0;
        nid = alc662_look_for_dac(codec, pin);
        if (!nid) {
 -              char name[32];
                /* the corresponding DAC is already occupied */
                if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
                        return 0; /* no way */
                /* create a switch only */
 -              sprintf(name, "%s Playback Switch", pfx);
 -              return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
 +              return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
                                   HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
        }