Changeset 86 for GPL/trunk/alsa-kernel


Ignore:
Timestamp:
Jan 23, 2007, 10:34:32 PM (19 years ago)
Author:
vladest
Message:

Added missed files
Applied latest modifications of ALSA
Reworked sharing strategy between MMOS2 and UNIAUD API

Location:
GPL/trunk/alsa-kernel
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/alsa-kernel/core/misc.c

    r84 r86  
    712712}
    713713
     714/**
     715 * snd_pci_quirk_lookup - look up a PCI SSID quirk list
     716 * @pci: pci_dev handle
     717 * @list: quirk list, terminated by a null entry
     718 *
     719 * Look through the given quirk list and finds a matching entry
     720 * with the same PCI SSID.  When subdevice is 0, all subdevice
     721 * values may match.
     722 *
     723 * Returns the matched entry pointer, or NULL if nothing matched.
     724 */
     725const struct snd_pci_quirk *
     726snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
     727{
     728        const struct snd_pci_quirk *q;
     729
     730        for (q = list; q->subvendor; q++)
     731                if (q->subvendor == pci->subsystem_vendor &&
     732                    (!q->subdevice || q->subdevice == pci->subsystem_device))
     733                        return q;
     734        return NULL;
     735}
     736
  • GPL/trunk/alsa-kernel/include/sound/ac97_codec.h

    r77 r86  
    3232#include "info.h"
    3333
    34 #define CONFIG_SND_AC97_POWER_SAVE /* experimental !!! */
    3534/*
    3635 *  AC'97 codec registers
     
    376375#define AC97_SCAP_NO_SPDIF      (1<<9)  /* don't build SPDIF controls */
    377376#define AC97_SCAP_EAPD_LED      (1<<10) /* EAPD as mute LED */
     377#define AC97_SCAP_POWER_SAVE    (1<<11) /* capable for aggresive power-saving */
    378378
    379379/* ac97->flags */
     
    425425
    426426struct snd_ac97_bus_ops {
    427         void (*reset) (struct snd_ac97 *ac97);
     427    void (*reset) (struct snd_ac97 *ac97);
     428    void (*warm_reset)(struct snd_ac97 *ac97);
    428429        void (*write) (struct snd_ac97 *ac97, unsigned short reg, unsigned short val);
    429430        unsigned short (*read) (struct snd_ac97 *ac97, unsigned short reg);
     
    501502                        unsigned short id[3];           // codec IDs (lower 16-bit word)
    502503                        unsigned short pcmreg[3];       // PCM registers
    503                         unsigned short codec_cfg[3];    // CODEC_CFG bits
     504                        unsigned short codec_cfg[3];    // CODEC_CFG bits
     505                        unsigned char swap_mic_linein;  // AD1986/AD1986A only
    504506                } ad18xx;
    505507                unsigned int dev_flags;         /* device specific */
  • GPL/trunk/alsa-kernel/include/sound/config.h

    r34 r86  
    204204};
    205205
     206/* PCI quirk list helper */
     207struct snd_pci_quirk {
     208        unsigned short subvendor;       /* PCI subvendor ID */
     209        unsigned short subdevice;       /* PCI subdevice ID */
     210        int value;                      /* value */
     211#ifdef CONFIG_SND_DEBUG_DETECT
     212        const char *name;               /* name of the device (optional) */
     213#endif
     214};
     215
     216#define _SND_PCI_QUIRK_ID(vend,dev) \
     217        .subvendor = (vend), .subdevice = (dev)
     218#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)}
     219#ifdef CONFIG_SND_DEBUG_DETECT
     220#define SND_PCI_QUIRK(vend,dev,xname,val) \
     221        {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)}
     222#else
     223#define SND_PCI_QUIRK(vend,dev,xname,val) \
     224        {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)}
     225#endif
     226
     227const struct snd_pci_quirk *
     228snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
     229
    206230/* misc.c */
    207231struct resource;
  • GPL/trunk/alsa-kernel/include/sound/driver.h

    r85 r86  
    753753#endif
    754754
     755static inline int snd_pci_enable_msi(struct pci_dev *dev) { return -1; }
     756#undef pci_enable_msi
     757#define pci_enable_msi(dev) snd_pci_enable_msi(dev)
     758#undef pci_disable_msi
     759#define pci_disable_msi(dev)
     760
     761#undef pci_intx
     762#define pci_intx(pci,x)
     763
     764
    755765#endif                          /* __DRIVER_H */
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_codec.c

    r77 r86  
    3131#include <sound/core.h>
    3232#include <sound/pcm.h>
     33#include <sound/tlv.h>
    3334#include <sound/ac97_codec.h>
    3435#include <sound/asoundef.h>
     
    110111{ 0x41445374, 0xffffffff, "AD1981B",            patch_ad1981b,  NULL },
    111112{ 0x41445375, 0xffffffff, "AD1985",             patch_ad1985,   NULL },
    112 { 0x41445378, 0xffffffff, "AD1986",             patch_ad1985,   NULL },
     113{ 0x41445378, 0xffffffff, "AD1986",             patch_ad1986,   NULL },
    113114{ 0x414c4300, 0xffffff00, "ALC100,100P",        NULL,           NULL },
    114115{ 0x414c4710, 0xfffffff0, "ALC200,200P",        NULL,           NULL },
     
    128129{ 0x434d4961, 0xffffffff, "CMI9739",            patch_cm9739,   NULL },
    129130{ 0x434d4969, 0xffffffff, "CMI9780",            patch_cm9780,   NULL },
    130 { 0x434d4978, 0xffffffff, "CMI9761",            patch_cm9761,   NULL },
    131 { 0x434d4982, 0xffffffff, "CMI9761",            patch_cm9761,   NULL },
    132 { 0x434d4983, 0xffffffff, "CMI9761",            patch_cm9761,   NULL },
     131{ 0x434d4978, 0xffffffff, "CMI9761A",           patch_cm9761,   NULL },
     132{ 0x434d4982, 0xffffffff, "CMI9761B",           patch_cm9761,   NULL },
     133{ 0x434d4983, 0xffffffff, "CMI9761A+",          patch_cm9761,   NULL },
    133134{ 0x43525900, 0xfffffff8, "CS4297",             NULL,           NULL },
    134135{ 0x43525910, 0xfffffff8, "CS4297A",            patch_cirrus_spdif,     NULL },
     
    155156{ 0x4e534300, 0xffffffff, "LM4540,43,45,46,48", NULL,           NULL }, // only guess --jk
    156157{ 0x4e534331, 0xffffffff, "LM4549",             NULL,           NULL },
    157 { 0x4e534350, 0xffffffff, "LM4550",             NULL,           NULL },
    158158{ 0x4e534350, 0xffffffff, "LM4550",             patch_lm4550,   NULL }, // volume wrap fix
    159159{ 0x50534304, 0xffffffff, "UCB1400",            patch_ucb1400,  NULL },
     
    166166{ 0x56494161, 0xffffffff, "VIA1612A",           NULL,           NULL }, // modified ICE1232 with S/PDIF
    167167{ 0x56494170, 0xffffffff, "VIA1617A",           patch_vt1617a,  NULL }, // modified VT1616 with S/PDIF
     168{ 0x56494182, 0xffffffff, "VIA1618",            NULL,           NULL },
    168169{ 0x57454301, 0xffffffff, "W83971D",            NULL,           NULL },
    169170{ 0x574d4c00, 0xffffffff, "WM9701A",            NULL,           NULL },
     
    192193
    193194static void update_power_regs(struct snd_ac97 *ac97);
     195#ifdef CONFIG_SND_AC97_POWER_SAVE
     196#define ac97_is_power_save_mode(ac97) \
     197        ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save)
     198#else
     199#define ac97_is_power_save_mode(ac97) 0
     200#endif
     201
    194202
    195203/*
     
    259267}
    260268
     269EXPORT_SYMBOL(snd_ac97_write);
     270
    261271/**
    262272 * snd_ac97_read - read a value from the given register
     
    276286        return ac97->bus->ops->read(ac97, reg);
    277287}
     288
     289EXPORT_SYMBOL(snd_ac97_read);
    278290
    279291/* read a register - return the cached value if already read */
     
    369381        unsigned short old, new;
    370382
    371         old = snd_ac97_read_cache(ac97, reg);
    372         new = (old & ~mask) | value;
     383        old = snd_ac97_read_cache(ac97, reg);
     384        new = (old & ~mask) | (value & mask);
    373385        change = old != new;
    374386        if (change) {
     
    386398
    387399        down(&ac97->page_mutex);
    388         old = ac97->spec.ad18xx.pcmreg[codec];
    389         new = (old & ~mask) | value;
     400        old = ac97->spec.ad18xx.pcmreg[codec];
     401        new = (old & ~mask) | (value & mask);
    390402        change = old != new;
    391403        if (change) {
     
    557569                        ac97->power_up &= ~(1 << (reg>>1));
    558570                else
    559                         ac97->power_up |= 1 << (reg>>1);
    560                 if (power_save)
    561                         update_power_regs(ac97);
     571                    ac97->power_up |= 1 << (reg>>1);
     572                update_power_regs(ac97);
    562573        }
    563574#endif
     
    11731184                kctl = snd_ctl_new1(&tmp, ac97);
    11741185        } else {
    1175                 struct snd_kcontrol_new tmp = AC97_SINGLE(name, reg, 15, 1, 1);
     1186            struct snd_kcontrol_new tmp = AC97_SINGLE(name, reg, 15, 1, 1);
     1187            if (check_amix)
     1188                tmp.private_value |= (1 << 30);
     1189
    11761190                tmp.index = ac97->num;
    11771191                kctl = snd_ctl_new1(&tmp, ac97);
     
    11871201
    11881202/*
     1203 * set dB information
     1204 */
     1205static DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
     1206static DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
     1207static DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
     1208static DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
     1209static DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
     1210
     1211static unsigned int *find_db_scale(unsigned int maxval)
     1212{
     1213        switch (maxval) {
     1214        case 0x0f: return db_scale_4bit;
     1215        case 0x1f: return db_scale_5bit;
     1216        case 0x3f: return db_scale_6bit;
     1217        }
     1218        return NULL;
     1219}
     1220
     1221static void set_tlv_db_scale(struct snd_kcontrol *kctl, unsigned int *tlv)
     1222{       
     1223        kctl->tlv.p = tlv;
     1224        if (tlv)
     1225                kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
     1226}
     1227
     1228/*
     1229
    11891230 * create a volume for normal stereo/mono controls
    11901231 */
     
    12281269        }
    12291270#endif
    1230         err = snd_ctl_add(card, kctl);
     1271        if (reg >= AC97_PHONE && reg <= AC97_PCM)
     1272                set_tlv_db_scale(kctl, db_scale_5bit_12db_max);
     1273        else
     1274                set_tlv_db_scale(kctl, find_db_scale(lo_max));
     1275        err = snd_ctl_add(card, kctl);
    12311276        if (err < 0)
    12321277                return err;
     
    13081353                snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 0, &max);
    13091354                kctl->private_value &= ~(0xff << 16);
    1310                 kctl->private_value |= (int)max << 16;
     1355                kctl->private_value |= (int)max << 16;
     1356                set_tlv_db_scale(kctl, find_db_scale(max));
    13111357                snd_ac97_write_cache(ac97, AC97_CENTER_LFE_MASTER, ac97->regs[AC97_CENTER_LFE_MASTER] | max);
    13121358        }
     
    13211367                snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 8, &max);
    13221368                kctl->private_value &= ~(0xff << 16);
    1323                 kctl->private_value |= (int)max << 16;
     1369                kctl->private_value |= (int)max << 16;
     1370                set_tlv_db_scale(kctl, find_db_scale(max));
    13241371                snd_ac97_write_cache(ac97, AC97_CENTER_LFE_MASTER, ac97->regs[AC97_CENTER_LFE_MASTER] | max << 8);
    13251372        }
     
    13691416            snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) {
    13701417                for (idx = 0; idx < 2; idx++)
    1371                         if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97))) < 0)
    1372                                 return err;
     1418                        if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97))) < 0)
     1419                                return err;
     1420                set_tlv_db_scale(kctl, db_scale_4bit);
    13731421                snd_ac97_write_cache(ac97, AC97_PC_BEEP,
    13741422                                     snd_ac97_read(ac97, AC97_PC_BEEP) | 0x801e);
     
    14361484                else
    14371485                        init_val = 0x9f1f;
    1438                 for (idx = 0; idx < 2; idx++)
    1439                         if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_ad18xx_pcm[idx], ac97))) < 0)
    1440                                 return err;
     1486                for (idx = 0; idx < 2; idx++)
     1487                    if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_pcm[idx], ac97))) < 0)
     1488                        return err;
     1489                set_tlv_db_scale(kctl, db_scale_5bit);
    14411490                ac97->spec.ad18xx.pcmreg[0] = init_val;
    14421491                if (ac97->scaps & AC97_SCAP_SURROUND_DAC) {
    1443                         for (idx = 0; idx < 2; idx++)
    1444                                 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_ad18xx_surround[idx], ac97))) < 0)
    1445                                         return err;
    1446                         ac97->spec.ad18xx.pcmreg[1] = init_val;
     1492                    for (idx = 0; idx < 2; idx++)
     1493                        if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_surround[idx], ac97))) < 0)
     1494                            return err;
     1495                    set_tlv_db_scale(kctl, db_scale_5bit);
     1496                    ac97->spec.ad18xx.pcmreg[1] = init_val;
    14471497                }
    14481498                if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) {
    1449                         for (idx = 0; idx < 2; idx++)
    1450                                 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_ad18xx_center[idx], ac97))) < 0)
    1451                                         return err;
    1452                         for (idx = 0; idx < 2; idx++)
    1453                                 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_ad18xx_lfe[idx], ac97))) < 0)
    1454                                         return err;
     1499                    for (idx = 0; idx < 2; idx++)
     1500                        if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_center[idx], ac97))) < 0)
     1501                            return err;
     1502                    set_tlv_db_scale(kctl, db_scale_5bit);
     1503                    for (idx = 0; idx < 2; idx++)
     1504                        if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_lfe[idx], ac97))) < 0)
     1505                            return err;
     1506                    set_tlv_db_scale(kctl, db_scale_5bit);
    14551507                        ac97->spec.ad18xx.pcmreg[2] = init_val;
    14561508                }
     
    14811533                    if (err < 0)
    14821534                        return err;
    1483                 }
    1484                 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97))) < 0)
    1485                         return err;
     1535                }
     1536                if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97))) < 0)
     1537                    return err;
     1538                set_tlv_db_scale(kctl, db_scale_rec_gain);
    14861539                snd_ac97_write_cache(ac97, AC97_REC_SEL, 0x0000);
    14871540                snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x0000);
     
    14891542        /* build MIC Capture controls */
    14901543        if (snd_ac97_try_volume_mix(ac97, AC97_REC_GAIN_MIC)) {
    1491                 for (idx = 0; idx < 2; idx++)
    1492                         if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_capture[idx], ac97))) < 0)
    1493                                 return err;
    1494                 snd_ac97_write_cache(ac97, AC97_REC_GAIN_MIC, 0x0000);
     1544            for (idx = 0; idx < 2; idx++)
     1545                if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_mic_capture[idx], ac97))) < 0)
     1546                    return err;
     1547            set_tlv_db_scale(kctl, db_scale_rec_gain);
     1548            snd_ac97_write_cache(ac97, AC97_REC_GAIN_MIC, 0x0000);
    14951549        }
    14961550
     
    15611615        }
    15621616
    1563         /* build S/PDIF controls */
     1617        /* build S/PDIF controls */
     1618
     1619        /* Hack for ASUS P5P800-VM, which does not indicate S/PDIF capability */
     1620        if (ac97->subsystem_vendor == 0x1043 &&
     1621            ac97->subsystem_device == 0x810f)
     1622                ac97->ext_id |= AC97_EI_SPDIF;
     1623
    15641624        if ((ac97->ext_id & AC97_EI_SPDIF) && !(ac97->scaps & AC97_SCAP_NO_SPDIF)) {
    15651625                if (ac97->build_ops->build_spdif) {
     
    16421702        unsigned short saved;
    16431703
    1644         if (ac97->bus->no_vra || !(ac97->ext_id & AC97_EI_VRA) ) {
     1704        if (ac97->bus->no_vra) {
    16451705                *r_result = SNDRV_PCM_RATE_48000;
    16461706                if ((ac97->flags & AC97_DOUBLE_RATE) &&
     
    22612321        power |= AC97_PD_PR2 | AC97_PD_PR3;     /* Analog Mixer powerdown */
    22622322        snd_ac97_write(ac97, AC97_POWERDOWN, power);
    2263 #ifdef CONFIG_SND_AC97_POWER_SAVE
    2264         if (power_save) {
     2323        if (ac97_is_power_save_mode(ac97)) {
    22652324            udelay(100);
    22662325            /* AC-link powerdown, internal Clk disable */
     
    22692328            snd_ac97_write(ac97, AC97_POWERDOWN, power);
    22702329        }
    2271 #endif
    22722330}
    22732331
     
    23232381    }
    23242382
    2325     if (! power_save)
    2326         return 0;
    2327 
    2328     if (! powerup && ac97->power_workq)
     2383    if (ac97_is_power_save_mode(ac97) && !powerup)
    23292384        /* adjust power-down bits after two seconds delay
    23302385         * (for avoiding loud click noises for many (OSS) apps
     
    23462401    int i;
    23472402
    2348 #ifdef CONFIG_SND_AC97_POWER_SAVE
    2349     if (power_save)
    2350         power_up = ac97->power_up;
    2351     else {
    2352 #endif
    23532403        power_up = (1 << PWIDX_FRONT) | (1 << PWIDX_ADC);
    23542404        power_up |= (1 << PWIDX_MIC);
     
    23582408            power_up |= (1 << PWIDX_CLFE);
    23592409#ifdef CONFIG_SND_AC97_POWER_SAVE
    2360     }
     2410        if (ac97_is_power_save_mode(ac97))
     2411                power_up = ac97->power_up;
    23612412#endif
    23622413    if (power_up) {
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.c

    r77 r86  
    3131#include <sound/pcm.h>
    3232#include <sound/control.h>
     33#include <sound/tlv.h>
    3334#include <sound/ac97_codec.h>
    3435#include "ac97_patch.h"
     
    4849                        return err;
    4950        return 0;
     51}
     52
     53/* replace with a new TLV */
     54static void reset_tlv(struct snd_ac97 *ac97, const char *name,
     55                      unsigned int *tlv)
     56{
     57        struct snd_ctl_elem_id sid;
     58        struct snd_kcontrol *kctl;
     59        memset(&sid, 0, sizeof(sid));
     60        strcpy(sid.name, name);
     61        sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     62        kctl = snd_ctl_find_id(ac97->bus->card, &sid);
     63        if (kctl && kctl->tlv.p)
     64                kctl->tlv.p = tlv;
    5065}
    5166
     
    174189}
    175190
     191/* system has shared jacks with surround out enabled */
     192static inline int is_shared_surrout(struct snd_ac97 *ac97)
     193{
     194        return ! ac97->indep_surround && is_surround_on(ac97);
     195}
     196
     197/* system has shared jacks with center/lfe out enabled */
     198static inline int is_shared_clfeout(struct snd_ac97 *ac97)
     199{
     200        return ! ac97->indep_surround && is_clfe_on(ac97);
     201}
     202
     203/* system has shared jacks with line in enabled */
    176204static inline int is_shared_linein(struct snd_ac97 *ac97)
    177205{
    178         return ! ac97->indep_surround && is_surround_on(ac97);
    179 }
    180 
     206        return !ac97->indep_surround && !is_surround_on(ac97);
     207}
     208
     209/* system has shared jacks with mic in enabled */
    181210static inline int is_shared_micin(struct snd_ac97 *ac97)
    182211{
    183         return ! ac97->indep_surround && is_clfe_on(ac97);
    184 }
    185 
     212        return !ac97->indep_surround && !is_clfe_on(ac97);
     213}
    186214
    187215/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
     
    514542
    515543AC97_SINGLE("Out3 Switch", AC97_AUX, 15, 1, 1),
    516 AC97_SINGLE("Out3 ZC Switch", AC97_AUX, 7, 1, 1),
     544AC97_SINGLE("Out3 ZC Switch", AC97_AUX, 7, 1, 0),
    517545AC97_ENUM("Out3 Mux", wm9711_enum[2]),
    518546AC97_ENUM("Out3 LR Mux", wm9711_enum[3]),
     
    559587AC97_SINGLE("ADC Switch", AC97_REC_GAIN, 15, 1, 1),
    560588AC97_ENUM("Capture Volume Steps", wm9711_enum[6]),
    561 AC97_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 15, 1),
     589AC97_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 63, 1),
    562590AC97_SINGLE("Capture ZC Switch", AC97_REC_GAIN, 7, 1, 0),
    563591
     
    565593AC97_SINGLE("Mic 2 to Phone Switch", AC97_MIC, 13, 1, 1),
    566594AC97_ENUM("Mic Select Source", wm9711_enum[7]),
    567 AC97_SINGLE("Mic 1 Volume", AC97_MIC, 8, 32, 1),
     595AC97_SINGLE("Mic 1 Volume", AC97_MIC, 8, 31, 1),
     596AC97_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1),
    568597AC97_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0),
    569598
     
    923952{
    924953        int err;
     954
     955        /* the register bit is writable, but the function is not implemented: */
     956        snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
    925957
    926958        snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
     
    13791411#endif
    13801412
     1413static const struct snd_ac97_res_table ad1819_restbl[] = {
     1414        { AC97_PHONE, 0x9f1f },
     1415        { AC97_MIC, 0x9f1f },
     1416        { AC97_LINE, 0x9f1f },
     1417        { AC97_CD, 0x9f1f },
     1418        { AC97_VIDEO, 0x9f1f },
     1419        { AC97_AUX, 0x9f1f },
     1420        { AC97_PCM, 0x9f1f },
     1421        {0} /* terminator */
     1422};
     1423
    13811424int patch_ad1819(struct snd_ac97 * ac97)
    13821425{
     
    13851428        // patch for Analog Devices
    13861429        scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
    1387         snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
     1430        snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
     1431        ac97->res_table = ad1819_restbl;
    13881432        return 0;
    13891433}
     
    14381482        ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002;
    14391483        if (cidx1 >= 0) {
    1440                 if (patch_ad1881_chained1(ac97, cidx1, 0x0006))         // SDIE | ID1C
     1484                if (cidx2 < 0)
     1485                        patch_ad1881_chained1(ac97, cidx1, 0);
     1486                else if (patch_ad1881_chained1(ac97, cidx1, 0x0006))    // SDIE | ID1C
    14411487                        patch_ad1881_chained1(ac97, cidx2, 0);
    14421488                else if (patch_ad1881_chained1(ac97, cidx2, 0x0006))    // SDIE | ID1C
     
    15211567};
    15221568
     1569static DECLARE_TLV_DB_SCALE(db_scale_6bit_6db_max, -8850, 150, 0);
     1570
    15231571static int patch_ad1885_specific(struct snd_ac97 * ac97)
    15241572{
     
    15271575        if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0)
    15281576                return err;
     1577        reset_tlv(ac97, "Headphone Playback Volume",
     1578                  db_scale_6bit_6db_max);
    15291579        return 0;
    15301580}
     
    15501600}
    15511601
     1602static int patch_ad1886_specific(struct snd_ac97 * ac97)
     1603{
     1604        reset_tlv(ac97, "Headphone Playback Volume",
     1605                  db_scale_6bit_6db_max);
     1606        return 0;
     1607}
     1608
     1609static struct snd_ac97_build_ops patch_ad1886_build_ops = {
     1610        .build_specific = &patch_ad1886_specific,
     1611#ifdef CONFIG_PM
     1612        .resume = ad18xx_resume
     1613#endif
     1614};
     1615
    15521616int patch_ad1886(struct snd_ac97 * ac97)
    15531617{
     
    15551619        /* Presario700 workaround */
    15561620        /* for Jack Sense/SPDIF Register misetting causing */
    1557         snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
    1558         return 0;
    1559 }
    1560 
    1561 /* MISC bits */
     1621        snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
     1622        ac97->build_ops = &patch_ad1886_build_ops;
     1623        return 0;
     1624}
     1625
     1626/* MISC bits (AD1888/AD1980/AD1985 register 0x76) */
    15621627#define AC97_AD198X_MBC         0x0003  /* mic boost */
    15631628#define AC97_AD198X_MBC_20      0x0000  /* +20dB */
     
    15651630#define AC97_AD198X_MBC_30      0x0002  /* +30dB */
    15661631#define AC97_AD198X_VREFD       0x0004  /* VREF high-Z */
    1567 #define AC97_AD198X_VREFH       0x0008  /* 2.25V, 3.7V */
    1568 #define AC97_AD198X_VREF_0      0x000c  /* 0V */
     1632#define AC97_AD198X_VREFH       0x0008  /* 0=2.25V, 1=3.7V */
     1633#define AC97_AD198X_VREF_0      0x000c  /* 0V (AD1985 only) */
     1634#define AC97_AD198X_VREF_MASK   (AC97_AD198X_VREFH | AC97_AD198X_VREFD)
     1635#define AC97_AD198X_VREF_SHIFT  2
    15691636#define AC97_AD198X_SRU         0x0010  /* sample rate unlock */
    15701637#define AC97_AD198X_LOSEL       0x0020  /* LINE_OUT amplifiers input select */
    15711638#define AC97_AD198X_2MIC        0x0040  /* 2-channel mic select */
    15721639#define AC97_AD198X_SPRD        0x0080  /* SPREAD enable */
    1573 #define AC97_AD198X_DMIX0       0x0100  /* downmix mode: 0 = 6-to-4, 1 = 6-to-2 downmix */
     1640#define AC97_AD198X_DMIX0       0x0100  /* downmix mode: */
     1641                                        /*  0 = 6-to-4, 1 = 6-to-2 downmix */
    15741642#define AC97_AD198X_DMIX1       0x0200  /* downmix mode: 1 = enabled */
    15751643#define AC97_AD198X_HPSEL       0x0400  /* headphone amplifier input select */
     
    15791647#define AC97_AD198X_AC97NC      0x4000  /* AC97 no compatible mode */
    15801648#define AC97_AD198X_DACZ        0x8000  /* DAC zero-fill mode */
     1649
     1650/* MISC 1 bits (AD1986 register 0x76) */
     1651#define AC97_AD1986_MBC         0x0003  /* mic boost */
     1652#define AC97_AD1986_MBC_20      0x0000  /* +20dB */
     1653#define AC97_AD1986_MBC_10      0x0001  /* +10dB */
     1654#define AC97_AD1986_MBC_30      0x0002  /* +30dB */
     1655#define AC97_AD1986_LISEL0      0x0004  /* LINE_IN select bit 0 */
     1656#define AC97_AD1986_LISEL1      0x0008  /* LINE_IN select bit 1 */
     1657#define AC97_AD1986_LISEL_MASK  (AC97_AD1986_LISEL1 | AC97_AD1986_LISEL0)
     1658#define AC97_AD1986_LISEL_LI    0x0000  /* LINE_IN pins as LINE_IN source */
     1659#define AC97_AD1986_LISEL_SURR  0x0004  /* SURROUND pins as LINE_IN source */
     1660#define AC97_AD1986_LISEL_MIC   0x0008  /* MIC_1/2 pins as LINE_IN source */
     1661#define AC97_AD1986_SRU         0x0010  /* sample rate unlock */
     1662#define AC97_AD1986_SOSEL       0x0020  /* SURROUND_OUT amplifiers input sel */
     1663#define AC97_AD1986_2MIC        0x0040  /* 2-channel mic select */
     1664#define AC97_AD1986_SPRD        0x0080  /* SPREAD enable */
     1665#define AC97_AD1986_DMIX0       0x0100  /* downmix mode: */
     1666                                        /*  0 = 6-to-4, 1 = 6-to-2 downmix */
     1667#define AC97_AD1986_DMIX1       0x0200  /* downmix mode: 1 = enabled */
     1668#define AC97_AD1986_CLDIS       0x0800  /* center/lfe disable */
     1669#define AC97_AD1986_SODIS       0x1000  /* SURROUND_OUT disable */
     1670#define AC97_AD1986_MSPLT       0x2000  /* mute split (read only 1) */
     1671#define AC97_AD1986_AC97NC      0x4000  /* AC97 no compatible mode (r/o 1) */
     1672#define AC97_AD1986_DACZ        0x8000  /* DAC zero-fill mode */
     1673
     1674/* MISC 2 bits (AD1986 register 0x70) */
     1675#define AC97_AD_MISC2           0x70    /* Misc Control Bits 2 (AD1986) */
     1676
     1677#define AC97_AD1986_CVREF0      0x0004  /* C/LFE VREF_OUT 2.25V */
     1678#define AC97_AD1986_CVREF1      0x0008  /* C/LFE VREF_OUT 0V */
     1679#define AC97_AD1986_CVREF2      0x0010  /* C/LFE VREF_OUT 3.7V */
     1680#define AC97_AD1986_CVREF_MASK \
     1681        (AC97_AD1986_CVREF2 | AC97_AD1986_CVREF1 | AC97_AD1986_CVREF0)
     1682#define AC97_AD1986_JSMAP       0x0020  /* Jack Sense Mapping 1 = alternate */
     1683#define AC97_AD1986_MMDIS       0x0080  /* Mono Mute Disable */
     1684#define AC97_AD1986_MVREF0      0x0400  /* MIC VREF_OUT 2.25V */
     1685#define AC97_AD1986_MVREF1      0x0800  /* MIC VREF_OUT 0V */
     1686#define AC97_AD1986_MVREF2      0x1000  /* MIC VREF_OUT 3.7V */
     1687#define AC97_AD1986_MVREF_MASK \
     1688        (AC97_AD1986_MVREF2 | AC97_AD1986_MVREF1 | AC97_AD1986_MVREF0)
     1689
     1690/* MISC 3 bits (AD1986 register 0x7a) */
     1691#define AC97_AD_MISC3           0x7a    /* Misc Control Bits 3 (AD1986) */
     1692
     1693#define AC97_AD1986_MMIX        0x0004  /* Mic Mix, left/right */
     1694#define AC97_AD1986_GPO         0x0008  /* General Purpose Out */
     1695#define AC97_AD1986_LOHPEN      0x0010  /* LINE_OUT headphone drive */
     1696#define AC97_AD1986_LVREF0      0x0100  /* LINE_OUT VREF_OUT 2.25V */
     1697#define AC97_AD1986_LVREF1      0x0200  /* LINE_OUT VREF_OUT 0V */
     1698#define AC97_AD1986_LVREF2      0x0400  /* LINE_OUT VREF_OUT 3.7V */
     1699#define AC97_AD1986_LVREF_MASK \
     1700        (AC97_AD1986_LVREF2 | AC97_AD1986_LVREF1 | AC97_AD1986_LVREF0)
     1701#define AC97_AD1986_JSINVA      0x0800  /* Jack Sense Invert SENSE_A */
     1702#define AC97_AD1986_LOSEL       0x1000  /* LINE_OUT amplifiers input select */
     1703#define AC97_AD1986_HPSEL0      0x2000  /* Headphone amplifiers */
     1704                                        /*   input select Surround DACs */
     1705#define AC97_AD1986_HPSEL1      0x4000  /* Headphone amplifiers input */
     1706                                        /*   select C/LFE DACs */
     1707#define AC97_AD1986_JSINVB      0x8000  /* Jack Sense Invert SENSE_B */
     1708
     1709/* Serial Config bits (AD1986 register 0x74) (incomplete) */
     1710#define AC97_AD1986_OMS0        0x0100  /* Optional Mic Selector bit 0 */
     1711#define AC97_AD1986_OMS1        0x0200  /* Optional Mic Selector bit 1 */
     1712#define AC97_AD1986_OMS2        0x0400  /* Optional Mic Selector bit 2 */
     1713#define AC97_AD1986_OMS_MASK \
     1714        (AC97_AD1986_OMS2 | AC97_AD1986_OMS1 | AC97_AD1986_OMS0)
     1715#define AC97_AD1986_OMS_M       0x0000  /* MIC_1/2 pins are MIC sources */
     1716#define AC97_AD1986_OMS_L       0x0100  /* LINE_IN pins are MIC sources */
     1717#define AC97_AD1986_OMS_C       0x0200  /* Center/LFE pins are MCI sources */
     1718#define AC97_AD1986_OMS_MC      0x0400  /* Mix of MIC and C/LFE pins */
     1719                                        /*   are MIC sources */
     1720#define AC97_AD1986_OMS_ML      0x0500  /* MIX of MIC and LINE_IN pins */
     1721                                        /*   are MIC sources */
     1722#define AC97_AD1986_OMS_LC      0x0600  /* MIX of LINE_IN and C/LFE pins */
     1723                                        /*   are MIC sources */
     1724#define AC97_AD1986_OMS_MLC     0x0700  /* MIX of MIC, LINE_IN, C/LFE pins */
     1725                                        /*   are MIC sources */
    15811726
    15821727
     
    19022047}
    19032048
     2049static int snd_ac97_ad1985_vrefout_info(struct snd_kcontrol *kcontrol,
     2050                                        struct snd_ctl_elem_info *uinfo)
     2051{
     2052        static char *texts[4] = {"High-Z", "3.7 V", "2.25 V", "0 V"};
     2053
     2054        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     2055        uinfo->count = 1;
     2056        uinfo->value.enumerated.items = 4;
     2057        if (uinfo->value.enumerated.item > 3)
     2058                uinfo->value.enumerated.item = 3;
     2059        strcpy(uinfo->value.enumerated.name,
     2060               texts[uinfo->value.enumerated.item]);
     2061        return 0;
     2062}
     2063
     2064static int snd_ac97_ad1985_vrefout_get(struct snd_kcontrol *kcontrol,
     2065                                       struct snd_ctl_elem_value *ucontrol)
     2066{
     2067        static const int reg2ctrl[4] = {2, 0, 1, 3};
     2068        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2069        unsigned short val;
     2070        val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
     2071              >> AC97_AD198X_VREF_SHIFT;
     2072        ucontrol->value.enumerated.item[0] = reg2ctrl[val];
     2073        return 0;
     2074}
     2075
     2076static int snd_ac97_ad1985_vrefout_put(struct snd_kcontrol *kcontrol,
     2077                                       struct snd_ctl_elem_value *ucontrol)
     2078{
     2079        static const int ctrl2reg[4] = {1, 2, 0, 3};
     2080        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2081        unsigned short val;
     2082
     2083        if (ucontrol->value.enumerated.item[0] > 3
     2084            || ucontrol->value.enumerated.item[0] < 0)
     2085                return -EINVAL;
     2086        val = ctrl2reg[ucontrol->value.enumerated.item[0]]
     2087              << AC97_AD198X_VREF_SHIFT;
     2088        return snd_ac97_update_bits(ac97, AC97_AD_MISC,
     2089                                    AC97_AD198X_VREF_MASK, val);
     2090}
     2091
     2092
    19042093static const struct snd_kcontrol_new snd_ac97_ad1985_controls[] = {
    1905         AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0)
     2094        AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0),
     2095        {
     2096                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2097                .name = "Exchange Front/Surround",
     2098                .info = snd_ac97_ad1888_lohpsel_info,
     2099                .get = snd_ac97_ad1888_lohpsel_get,
     2100                .put = snd_ac97_ad1888_lohpsel_put
     2101        },
     2102        AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1),
     2103        AC97_SINGLE("Spread Front to Surround and Center/LFE",
     2104                    AC97_AD_MISC, 7, 1, 0),
     2105        {
     2106                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2107                .name = "Downmix",
     2108                .info = snd_ac97_ad1888_downmix_info,
     2109                .get = snd_ac97_ad1888_downmix_get,
     2110                .put = snd_ac97_ad1888_downmix_put
     2111        },
     2112        {
     2113                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2114                .name = "V_REFOUT",
     2115                .info = snd_ac97_ad1985_vrefout_info,
     2116                .get = snd_ac97_ad1985_vrefout_get,
     2117                .put = snd_ac97_ad1985_vrefout_put
     2118        },
     2119        AC97_SURROUND_JACK_MODE_CTL,
     2120        AC97_CHANNEL_MODE_CTL,
     2121
     2122        AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),
     2123        AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),
    19062124};
    19072125
     
    19172135        int err;
    19182136
    1919         if ((err = patch_ad1980_specific(ac97)) < 0)
     2137        /* rename 0x04 as "Master" and 0x02 as "Master Surround" */
     2138        snd_ac97_rename_vol_ctl(ac97, "Master Playback",
     2139                                "Master Surround Playback");
     2140        snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
     2141
     2142        if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
    19202143                return err;
    1921         return patch_build_controls(ac97, snd_ac97_ad1985_controls, ARRAY_SIZE(snd_ac97_ad1985_controls));
     2144
     2145        return patch_build_controls(ac97, snd_ac97_ad1985_controls,
     2146                                    ARRAY_SIZE(snd_ac97_ad1985_controls));
    19222147}
    19232148
     
    19392164        misc = snd_ac97_read(ac97, AC97_AD_MISC);
    19402165        /* switch front/surround line-out/hp-out */
    1941         /* center/LFE, mic in 3.75V mode */
    19422166        /* AD-compatible mode */
    19432167        /* Stereo mutes enabled */
    1944         /* in accordance with ADI driver: misc | 0x5c28 */
    19452168        snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
    1946                              AC97_AD198X_VREFH |
    19472169                             AC97_AD198X_LOSEL |
    19482170                             AC97_AD198X_HPSEL |
    1949                              AC97_AD198X_CLDIS |
    1950                              AC97_AD198X_LODIS |
    19512171                             AC97_AD198X_MSPLT |
    19522172                             AC97_AD198X_AC97NC);
    19532173        ac97->flags |= AC97_STEREO_MUTES;
    1954         /* on AD1985 rev. 3, AC'97 revision bits are zero */
     2174
     2175        /* update current jack configuration */
     2176        ad1985_update_jacks(ac97);
     2177
     2178        /* on AD1985 rev. 3, AC'97 revision bits are zero */
    19552179        ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
    19562180        return 0;
    19572181}
     2182
     2183static int snd_ac97_ad1986_bool_info(struct snd_kcontrol *kcontrol,
     2184                                     struct snd_ctl_elem_info *uinfo)
     2185{
     2186        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     2187        uinfo->count = 1;
     2188        uinfo->value.integer.min = 0;
     2189        uinfo->value.integer.max = 1;
     2190        return 0;
     2191}
     2192
     2193static int snd_ac97_ad1986_lososel_get(struct snd_kcontrol *kcontrol,
     2194                                       struct snd_ctl_elem_value *ucontrol)
     2195{
     2196        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2197        unsigned short val;
     2198
     2199        val = ac97->regs[AC97_AD_MISC3];
     2200        ucontrol->value.integer.value[0] = (val & AC97_AD1986_LOSEL) != 0;
     2201        return 0;
     2202}
     2203
     2204static int snd_ac97_ad1986_lososel_put(struct snd_kcontrol *kcontrol,
     2205                                       struct snd_ctl_elem_value *ucontrol)
     2206{
     2207        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2208        int ret0;
     2209        int ret1;
     2210        int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
     2211
     2212        ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
     2213                                        ucontrol->value.integer.value[0] != 0
     2214                                    ? AC97_AD1986_LOSEL : 0);
     2215        if (ret0 < 0)
     2216                return ret0;
     2217
     2218        /* SOSEL is set to values of "Spread" or "Exchange F/S" controls */
     2219        ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
     2220                                    (ucontrol->value.integer.value[0] != 0
     2221                                     || sprd)
     2222                                    ? AC97_AD1986_SOSEL : 0);
     2223        if (ret1 < 0)
     2224                return ret1;
     2225
     2226        return (ret0 > 0 || ret1 > 0) ? 1 : 0;
     2227}
     2228
     2229static int snd_ac97_ad1986_spread_get(struct snd_kcontrol *kcontrol,
     2230                                      struct snd_ctl_elem_value *ucontrol)
     2231{
     2232        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2233        unsigned short val;
     2234
     2235        val = ac97->regs[AC97_AD_MISC];
     2236        ucontrol->value.integer.value[0] = (val & AC97_AD1986_SPRD) != 0;
     2237        return 0;
     2238}
     2239
     2240static int snd_ac97_ad1986_spread_put(struct snd_kcontrol *kcontrol,
     2241                                      struct snd_ctl_elem_value *ucontrol)
     2242{
     2243        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2244        int ret0;
     2245        int ret1;
     2246        int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
     2247
     2248        ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
     2249                                        ucontrol->value.integer.value[0] != 0
     2250                                    ? AC97_AD1986_SPRD : 0);
     2251        if (ret0 < 0)
     2252                return ret0;
     2253
     2254        /* SOSEL is set to values of "Spread" or "Exchange F/S" controls */
     2255        ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
     2256                                    (ucontrol->value.integer.value[0] != 0
     2257                                     || sprd)
     2258                                    ? AC97_AD1986_SOSEL : 0);
     2259        if (ret1 < 0)
     2260                return ret1;
     2261
     2262        return (ret0 > 0 || ret1 > 0) ? 1 : 0;
     2263}
     2264
     2265static int snd_ac97_ad1986_miclisel_get(struct snd_kcontrol *kcontrol,
     2266                                        struct snd_ctl_elem_value *ucontrol)
     2267{
     2268        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2269
     2270        ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
     2271        return 0;
     2272}
     2273
     2274static int snd_ac97_ad1986_miclisel_put(struct snd_kcontrol *kcontrol,
     2275                                        struct snd_ctl_elem_value *ucontrol)
     2276{
     2277        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2278        unsigned char swap = ucontrol->value.integer.value[0] != 0;
     2279
     2280        if (swap != ac97->spec.ad18xx.swap_mic_linein) {
     2281                ac97->spec.ad18xx.swap_mic_linein = swap;
     2282                if (ac97->build_ops->update_jacks)
     2283                        ac97->build_ops->update_jacks(ac97);
     2284                return 1;
     2285        }
     2286        return 0;
     2287}
     2288
     2289static int snd_ac97_ad1986_vrefout_get(struct snd_kcontrol *kcontrol,
     2290                                       struct snd_ctl_elem_value *ucontrol)
     2291{
     2292        /* Use MIC_1/2 V_REFOUT as the "get" value */
     2293        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2294        unsigned short val;
     2295        unsigned short reg = ac97->regs[AC97_AD_MISC2];
     2296        if ((reg & AC97_AD1986_MVREF0) != 0)
     2297                val = 2;
     2298        else if ((reg & AC97_AD1986_MVREF1) != 0)
     2299                val = 3;
     2300        else if ((reg & AC97_AD1986_MVREF2) != 0)
     2301                val = 1;
     2302        else
     2303                val = 0;
     2304        ucontrol->value.enumerated.item[0] = val;
     2305        return 0;
     2306}
     2307
     2308static int snd_ac97_ad1986_vrefout_put(struct snd_kcontrol *kcontrol,
     2309                                       struct snd_ctl_elem_value *ucontrol)
     2310{
     2311        struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
     2312        unsigned short cval;
     2313        unsigned short lval;
     2314        unsigned short mval;
     2315        int cret;
     2316        int lret;
     2317        int mret;
     2318
     2319        switch (ucontrol->value.enumerated.item[0])
     2320        {
     2321        case 0: /* High-Z */
     2322                cval = 0;
     2323                lval = 0;
     2324                mval = 0;
     2325                break;
     2326        case 1: /* 3.7 V */
     2327                cval = AC97_AD1986_CVREF2;
     2328                lval = AC97_AD1986_LVREF2;
     2329                mval = AC97_AD1986_MVREF2;
     2330                break;
     2331        case 2: /* 2.25 V */
     2332                cval = AC97_AD1986_CVREF0;
     2333                lval = AC97_AD1986_LVREF0;
     2334                mval = AC97_AD1986_MVREF0;
     2335                break;
     2336        case 3: /* 0 V */
     2337                cval = AC97_AD1986_CVREF1;
     2338                lval = AC97_AD1986_LVREF1;
     2339                mval = AC97_AD1986_MVREF1;
     2340                break;
     2341        default:
     2342                return -EINVAL;
     2343        }
     2344
     2345        cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
     2346                                    AC97_AD1986_CVREF_MASK, cval);
     2347        if (cret < 0)
     2348                return cret;
     2349        lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
     2350                                    AC97_AD1986_LVREF_MASK, lval);
     2351        if (lret < 0)
     2352                return lret;
     2353        mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
     2354                                    AC97_AD1986_MVREF_MASK, mval);
     2355        if (mret < 0)
     2356                return mret;
     2357
     2358        return (cret > 0 || lret > 0 || mret > 0) ? 1 : 0;
     2359}
     2360
     2361static const struct snd_kcontrol_new snd_ac97_ad1986_controls[] = {
     2362        AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0),
     2363        {
     2364                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2365                .name = "Exchange Front/Surround",
     2366                .info = snd_ac97_ad1986_bool_info,
     2367                .get = snd_ac97_ad1986_lososel_get,
     2368                .put = snd_ac97_ad1986_lososel_put
     2369        },
     2370        {
     2371                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2372                .name = "Exchange Mic/Line In",
     2373                .info = snd_ac97_ad1986_bool_info,
     2374                .get = snd_ac97_ad1986_miclisel_get,
     2375                .put = snd_ac97_ad1986_miclisel_put
     2376        },
     2377        {
     2378                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2379                .name = "Spread Front to Surround and Center/LFE",
     2380                .info = snd_ac97_ad1986_bool_info,
     2381                .get = snd_ac97_ad1986_spread_get,
     2382                .put = snd_ac97_ad1986_spread_put
     2383        },
     2384        {
     2385                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2386                .name = "Downmix",
     2387                .info = snd_ac97_ad1888_downmix_info,
     2388                .get = snd_ac97_ad1888_downmix_get,
     2389                .put = snd_ac97_ad1888_downmix_put
     2390        },
     2391        {
     2392                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2393                .name = "V_REFOUT",
     2394                .info = snd_ac97_ad1985_vrefout_info,
     2395                .get = snd_ac97_ad1986_vrefout_get,
     2396                .put = snd_ac97_ad1986_vrefout_put
     2397        },
     2398        AC97_SURROUND_JACK_MODE_CTL,
     2399        AC97_CHANNEL_MODE_CTL,
     2400
     2401        AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),
     2402        AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0)
     2403};
     2404
     2405static void ad1986_update_jacks(struct snd_ac97 *ac97)
     2406{
     2407        unsigned short misc_val = 0;
     2408        unsigned short ser_val;
     2409
     2410        /* disable SURROUND and CENTER/LFE if not surround mode */
     2411        if (! is_surround_on(ac97))
     2412                misc_val |= AC97_AD1986_SODIS;
     2413        if (! is_clfe_on(ac97))
     2414                misc_val |= AC97_AD1986_CLDIS;
     2415
     2416        /* select line input (default=LINE_IN, SURROUND or MIC_1/2) */
     2417        if (is_shared_linein(ac97))
     2418                misc_val |= AC97_AD1986_LISEL_SURR;
     2419        else if (ac97->spec.ad18xx.swap_mic_linein != 0)
     2420                misc_val |= AC97_AD1986_LISEL_MIC;
     2421        snd_ac97_update_bits(ac97, AC97_AD_MISC,
     2422                             AC97_AD1986_SODIS | AC97_AD1986_CLDIS |
     2423                             AC97_AD1986_LISEL_MASK,
     2424                             misc_val);
     2425
     2426        /* select microphone input (MIC_1/2, Center/LFE or LINE_IN) */
     2427        if (is_shared_micin(ac97))
     2428                ser_val = AC97_AD1986_OMS_C;
     2429        else if (ac97->spec.ad18xx.swap_mic_linein != 0)
     2430                ser_val = AC97_AD1986_OMS_L;
     2431        else
     2432                ser_val = AC97_AD1986_OMS_M;
     2433        snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
     2434                             AC97_AD1986_OMS_MASK,
     2435                             ser_val);
     2436}
     2437
     2438static int patch_ad1986_specific(struct snd_ac97 *ac97)
     2439{
     2440        int err;
     2441
     2442        if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
     2443                return err;
     2444
     2445        return patch_build_controls(ac97, snd_ac97_ad1986_controls,
     2446                                    ARRAY_SIZE(snd_ac97_ad1985_controls));
     2447}
     2448
     2449static struct snd_ac97_build_ops patch_ad1986_build_ops = {
     2450        .build_post_spdif = patch_ad198x_post_spdif,
     2451        .build_specific = patch_ad1986_specific,
     2452#ifdef CONFIG_PM
     2453        .resume = ad18xx_resume,
     2454#endif
     2455        .update_jacks = ad1986_update_jacks,
     2456};
     2457
     2458int patch_ad1986(struct snd_ac97 * ac97)
     2459{
     2460        patch_ad1881(ac97);
     2461        ac97->build_ops = &patch_ad1986_build_ops;
     2462        ac97->flags |= AC97_STEREO_MUTES;
     2463
     2464        /* update current jack configuration */
     2465        ad1986_update_jacks(ac97);
     2466
     2467        return 0;
     2468}
     2469
    19582470
    19592471/*
     
    19642476        int shared;
    19652477
    1966         /* shared Line-In */
    1967         shared = is_shared_linein(ac97);
     2478        /* shared Line-In / Surround Out */
     2479        shared = is_shared_surrout(ac97);
    19682480        snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
    19692481                             shared ? (1 << 9) : 0);
    1970         /* update shared Mic */
    1971         shared = is_shared_micin(ac97);
     2482        /* update shared Mic In / Center/LFE Out */
     2483        shared = is_shared_clfeout(ac97);
    19722484        /* disable/enable vref */
    19732485        snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
     
    20142526};
    20152527
     2528static DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_max, -4350, 150, 0);
     2529
    20162530static int patch_alc650_specific(struct snd_ac97 * ac97)
    20172531{
     
    20242538                        return err;
    20252539        }
     2540        if (ac97->id != AC97_ID_ALC650F)
     2541                reset_tlv(ac97, "Master Playback Volume",
     2542                          db_scale_5bit_3db_max);
    20262543        return 0;
    20272544}
     
    20942611        int shared;
    20952612
    2096         /* shared Line-In */
    2097         shared = is_shared_linein(ac97);
     2613        /* shared Line-In / Surround Out */
     2614        shared = is_shared_surrout(ac97);
    20982615        ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
    20992616                              shared ? (1 << 9) : 0, 0);
    2100         /* update shared mic */
    2101         shared = is_shared_micin(ac97);
     2617        /* update shared Mic In / Center/LFE Out */
     2618        shared = is_shared_clfeout(ac97);
    21022619        /* misc control; vrefout disable */
    21032620        snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
     
    22072724        else { /* ALC655 */
    22082725                if (ac97->subsystem_vendor == 0x1462 &&
    2209                     ac97->subsystem_device == 0x0131) /* MSI S270 laptop */
     2726                    (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
     2727                     ac97->subsystem_device == 0x0161 || /* LG K1 Express */
     2728                     ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
     2729                     ac97->subsystem_device == 0x0061))  /* MSI S250 laptop */
    22102730                        val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
    22112731                else
     
    22402760        int shared;
    22412761
    2242         /* shared Line-In */
    2243         shared = is_shared_linein(ac97);
     2762        /* shared Line-In / Surround Out */
     2763        shared = is_shared_surrout(ac97);
    22442764        /* SURR 1kOhm (bit4), Amp (bit5) */
    22452765        snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
     
    22482768        snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
    22492769                             shared ? (2<<12) : (0<<12));
    2250         /* update shared mic */
    2251         shared = is_shared_micin(ac97);
     2770        /* update shared Mic In / Center/LFE Out */
     2771        shared = is_shared_clfeout(ac97);
    22522772        /* Vref disable (bit12), 1kOhm (bit13) */
    22532773        snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
     
    23222842static void cm9738_update_jacks(struct snd_ac97 *ac97)
    23232843{
    2324         /* shared Line-In */
     2844        /* shared Line-In / Surround Out */
    23252845        snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
    2326                              is_shared_linein(ac97) ? (1 << 10) : 0);
     2846                             is_shared_surrout(ac97) ? (1 << 10) : 0);
    23272847}
    23282848
     
    24062926static void cm9739_update_jacks(struct snd_ac97 *ac97)
    24072927{
    2408         /* shared Line-In */
     2928        /* shared Line-In / Surround Out */
    24092929        snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
    2410                              is_shared_linein(ac97) ? (1 << 10) : 0);
    2411         /* shared Mic */
     2930                             is_shared_surrout(ac97) ? (1 << 10) : 0);
     2931        /* shared Mic In / Center/LFE Out **/
    24122932        snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
    2413                              is_shared_micin(ac97) ? 0x1000 : 0x2000);
     2933                             is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
    24142934}
    24152935
     
    25233043        val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
    25243044        val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
    2525         val |= surr_shared[ac97->spec.dev_flags][is_shared_linein(ac97)];
    2526         val |= clfe_shared[ac97->spec.dev_flags][is_shared_micin(ac97)];
     3045        val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
     3046        val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
    25273047
    25283048        snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
     
    27583278int patch_vt1617a(struct snd_ac97 * ac97)
    27593279{
     3280        /* bring analog power consumption to normal, like WinXP driver
     3281         * for EPIA SP
     3282         */
     3283        snd_ac97_write_cache(ac97, 0x5c, 0x20);
    27603284        ac97->ext_id |= AC97_EI_SPDIF;  /* force the detection of spdif */
    2761         ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
     3285        ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
     3286        ac97->build_ops = &patch_vt1616_ops;
    27623287        return 0;
    27633288}
     
    27673292static void it2646_update_jacks(struct snd_ac97 *ac97)
    27683293{
    2769         /* shared Line-In */
    2770         snd_ac97_update_bits(ac97, 0x76, 1 << 9,
    2771                              is_shared_linein(ac97) ? (1<<9) : 0);
    2772         /* shared Mic */
     3294    /* shared Line-In / Surround Out */
     3295    snd_ac97_update_bits(ac97, 0x76, 1 << 9,
     3296                             is_shared_surrout(ac97) ? (1<<9) : 0);
     3297        /* shared Mic / Center/LFE Out */
     3298
    27733299        snd_ac97_update_bits(ac97, 0x76, 1 << 10,
    2774                              is_shared_micin(ac97) ? (1<<10) : 0);
     3300                             is_shared_clfeout(ac97) ? (1<<10) : 0);
    27753301}
    27763302
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.h

    r77 r86  
    4949int patch_ad1981b(struct snd_ac97 * ac97);
    5050int patch_ad1985(struct snd_ac97 * ac97);
     51int patch_ad1986(struct snd_ac97 * ac97);
    5152int patch_alc650(struct snd_ac97 * ac97);
    5253int patch_alc655(struct snd_ac97 * ac97);
  • GPL/trunk/alsa-kernel/pci/hda/hda_codec.c

    r77 r86  
    2929#include "hda_codec.h"
    3030#include <sound/asoundef.h>
     31#include <sound/tlv.h>
    3132#include <sound/initval.h>
    3233#include "hda_local.h"
     
    5051static struct hda_vendor_id hda_vendor_ids[] = {
    5152    { 0x10ec, "Realtek" },
     53    { 0x1057, "Motorola" },
     54    { 0x1106, "VIA" },
    5255    { 0x11d4, "Analog Devices" },
    5356    { 0x13f6, "C-Media" },
     57    { 0x14f1, "Conexant" },
    5458    { 0x434d, "C-Media" },
    5559    { 0x8384, "SigmaTel" },
     
    8589    return res;
    8690}
     91
     92EXPORT_SYMBOL(snd_hda_codec_read);
    8793
    8894/**
     
    397403            if (! mask)
    398404                mask = ~0;
    399             if (preset->id == (codec->vendor_id & mask))
    400                 if (preset->id == (codec->vendor_id & mask) &&
    401                     (! preset->rev ||
    402                      preset->rev == codec->revision_id))
    403                     return preset;
     405            if (preset->id == (codec->vendor_id & mask) &&
     406                (! preset->rev ||
     407                 preset->rev == codec->revision_id))
     408                return preset;
    404409        }
    405410    }
     
    827832    return change;
    828833}
     834
     835int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
     836                          unsigned int size, unsigned int __user *_tlv)
     837{
     838    struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     839    hda_nid_t nid = get_amp_nid(kcontrol);
     840    int dir = get_amp_direction(kcontrol);
     841    u32 caps, val1, val2;
     842
     843    if (size < 4 * sizeof(unsigned int))
     844        return -ENOMEM;
     845    caps = query_amp_caps(codec, nid, dir);
     846    val2 = (((caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT) + 1) * 25;
     847    val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
     848    val1 = ((int)val1) * ((int)val2);
     849    if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
     850        return -EFAULT;
     851    if (put_user(2 * sizeof(unsigned int), _tlv + 1))
     852        return -EFAULT;
     853    if (put_user(val1, _tlv + 2))
     854        return -EFAULT;
     855    if (put_user(val2, _tlv + 3))
     856        return -EFAULT;
     857    return 0;
     858}
     859
    829860
    830861/* switch */
     
    13231354    { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
    13241355
    1325     /* not autodetected value */
    1326     { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
    1327 
    13281356    { 0 } /* terminator */
    13291357};
     
    14611489                if (val & AC_SUPPCM_BITS_32)
    14621490                    bps = 32;
     1491                else if (val & AC_SUPPCM_BITS_24)
     1492                    bps = 24;
    14631493                else if (val & AC_SUPPCM_BITS_20)
    14641494                    bps = 20;
    1465                 else if (val & AC_SUPPCM_BITS_24)
    1466                     bps = 24;
    14671495            }
    14681496        }
     
    16701698 * snd_hda_check_board_config - compare the current codec with the config table
    16711699 * @codec: the HDA codec
     1700 * @num_configs: number of config enums
     1701 * @models: array of model name strings
    16721702 * @tbl: configuration table, terminated by null entries
    16731703 *
     
    16781708 * If no entries are matching, the function returns a negative value.
    16791709 */
    1680 int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl)
    1681 {
    1682     const struct hda_board_config *c;
    1683 
    1684     if (codec->bus->modelname) {
    1685         for (c = tbl; c->modelname || c->pci_subvendor; c++) {
    1686             if (c->modelname &&
    1687                 ! strcmp(codec->bus->modelname, c->modelname)) {
    1688                 snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname);
    1689                 return c->config;
     1710int snd_hda_check_board_config(struct hda_codec *codec,
     1711                               int num_configs, const char **models,
     1712                               const struct snd_pci_quirk *tbl)
     1713{
     1714    if (codec->bus->modelname && models) {
     1715        int i;
     1716        for (i = 0; i < num_configs; i++) {
     1717            if (models[i] &&
     1718                !strcmp(codec->bus->modelname, models[i])) {
     1719                snd_printd(KERN_INFO "hda_codec: model '%s' is "
     1720                           "selected\n", models[i]);
     1721                return i;
    16901722            }
    16911723        }
    16921724    }
    16931725
    1694     if (codec->bus->pci) {
    1695         u16 subsystem_vendor, subsystem_device;
    1696         pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
    1697         pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device);
    1698         for (c = tbl; c->modelname || c->pci_subvendor; c++) {
    1699             if (c->pci_subvendor == subsystem_vendor &&
    1700                 (! c->pci_subdevice /* all match */||
    1701                  (c->pci_subdevice == subsystem_device))) {
    1702                 snd_printdd(KERN_INFO "hda_codec: PCI %x:%x, codec config %d is selected\n",
    1703                             subsystem_vendor, subsystem_device, c->config);
    1704                 return c->config;
    1705             }
     1726    if (!codec->bus->pci || !tbl)
     1727        return -1;
     1728
     1729    tbl = snd_pci_quirk_lookup(codec->bus->pci, tbl);
     1730    if (!tbl)
     1731        return -1;
     1732    if (tbl->value >= 0 && tbl->value < num_configs) {
     1733#ifdef CONFIG_SND_DEBUG_DETECT
     1734        char tmp[10];
     1735        const char *model = NULL;
     1736        if (models)
     1737            model = models[tbl->value];
     1738        if (!model) {
     1739            sprintf(tmp, "#%d", tbl->value);
     1740            model = tmp;
    17061741        }
     1742        snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
     1743                    "for config %x:%x (%s)\n",
     1744                    model, tbl->subvendor, tbl->subdevice,
     1745                    (tbl->name ? tbl->name : "Unknown device"));
     1746#endif
     1747        return tbl->value;
    17071748    }
    17081749    return -1;
     
    18991940    /* front */
    19001941    snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format);
    1901     if (mout->hp_nid)
     1942    if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
    19021943        /* headphone out will just decode front left/right (stereo) */
    19031944        snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format);
     
    19672008 *
    19682009 * If more extra outputs (speaker and headphone) are found, the pins are
    1969  * assisnged to hp_pin and speaker_pins[], respectively.  If no line-out jack
     2010 * assisnged to hp_pins[] and speaker_pins[], respectively.  If no line-out jack
    19702011 * is detected, one of speaker of HP pins is assigned as the primary
    19712012 * output, i.e. to line_out_pins[0].  So, line_outs is always positive
     
    20292070            break;
    20302071        case AC_JACK_HP_OUT:
    2031             cfg->hp_pin = nid;
     2072            if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins))
     2073                continue;
     2074            cfg->hp_pins[cfg->hp_outs] = nid;
     2075            cfg->hp_outs++;
    20322076            break;
    2033         case AC_JACK_MIC_IN:
    2034             if (loc == AC_JACK_LOC_FRONT)
    2035                 cfg->input_pins[AUTO_PIN_FRONT_MIC] = nid;
    2036             else
    2037                 cfg->input_pins[AUTO_PIN_MIC] = nid;
     2077        case AC_JACK_MIC_IN: {
     2078            int preferred, alt;
     2079            if (loc == AC_JACK_LOC_FRONT) {
     2080                preferred = AUTO_PIN_FRONT_MIC;
     2081                alt = AUTO_PIN_MIC;
     2082            } else {
     2083                preferred = AUTO_PIN_MIC;
     2084                alt = AUTO_PIN_FRONT_MIC;
     2085            }
     2086            if (!cfg->input_pins[preferred])
     2087                cfg->input_pins[preferred] = nid;
     2088            else if (!cfg->input_pins[alt])
     2089                cfg->input_pins[alt] = nid;
    20382090            break;
     2091        }
    20392092        case AC_JACK_LINE_IN:
    20402093            if (loc == AC_JACK_LOC_FRONT)
     
    21012154               cfg->speaker_pins[1], cfg->speaker_pins[2],
    21022155               cfg->speaker_pins[3], cfg->speaker_pins[4]);
    2103     snd_printd("   hp=0x%x, dig_out=0x%x, din_in=0x%x\n",
    2104                cfg->hp_pin, cfg->dig_out_pin, cfg->dig_in_pin);
     2156    snd_printd("   hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
     2157               cfg->hp_outs, cfg->hp_pins[0],
     2158               cfg->hp_pins[1], cfg->hp_pins[2],
     2159               cfg->hp_pins[3], cfg->hp_pins[4]);
    21052160    snd_printd("   inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
    21062161               " cd=0x%x, aux=0x%x\n",
     
    21232178            cfg->speaker_outs = 0;
    21242179            memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
    2125         } else if (cfg->hp_pin) {
    2126             cfg->line_outs = 1;
    2127             cfg->line_out_pins[0] = cfg->hp_pin;
    2128             cfg->hp_pin = 0;
     2180        } else if (cfg->hp_outs) {
     2181            cfg->line_outs = cfg->hp_outs;
     2182            memcpy(cfg->line_out_pins, cfg->hp_pins,
     2183                   sizeof(cfg->hp_pins));
     2184            cfg->hp_outs = 0;
     2185            memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
    21292186        }
    21302187    }
  • GPL/trunk/alsa-kernel/pci/hda/hda_generic.c

    r76 r86  
    4747
    4848/* patch-specific record */
     49
     50#define MAX_PCM_VOLS    2
     51struct pcm_vol {
     52        struct hda_gnode *node; /* Node for PCM volume */
     53        unsigned int index;     /* connection of PCM volume */
     54};
     55
    4956struct hda_gspec {
    50     struct hda_gnode *dac_node[2];  /* DAC node */
    51     struct hda_gnode *out_pin_node[2];      /* Output pin (Line-Out) node */
    52     struct hda_gnode *pcm_vol_node[2];      /* Node for PCM volume */
    53     unsigned int pcm_vol_index[2];  /* connection of PCM volume */
     57        struct hda_gnode *dac_node[2];  /* DAC node */
     58        struct hda_gnode *out_pin_node[2];      /* Output pin (Line-Out) node */
     59        struct pcm_vol pcm_vol[MAX_PCM_VOLS];   /* PCM volumes */
     60        unsigned int pcm_vol_nodes;     /* number of PCM volumes */
    5461
    5562        struct hda_gnode *adc_node;     /* ADC node */
     
    7178 */
    7279#define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> \
    73     AC_DEFCFG_DEVICE_SHIFT)
     80                           AC_DEFCFG_DEVICE_SHIFT)
    7481#define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> \
    75     AC_DEFCFG_LOCATION_SHIFT)
     82                               AC_DEFCFG_LOCATION_SHIFT)
    7683#define defcfg_port_conn(node) (((node)->def_cfg & AC_DEFCFG_PORT_CONN) >> \
    77     AC_DEFCFG_PORT_CONN_SHIFT)
     84                                AC_DEFCFG_PORT_CONN_SHIFT)
     85
    7886/*
    7987 * destructor
     
    265273 */
    266274static int parse_output_path(struct hda_codec *codec, struct hda_gspec *spec,
    267                              struct hda_gnode *node, int dac_idx)
     275                             struct hda_gnode *node, int dac_idx)
    268276{
    269277        int i, err;
     
    279287                        return 0;
    280288                }
    281                 snd_printdd("AUD_OUT found %x\n", node->nid);
    282                 if (spec->dac_node[dac_idx]) {
    283                     /* already DAC node is assigned, just unmute & connect */
    284                     return node == spec->dac_node[dac_idx];
    285                 }
    286                 spec->dac_node[dac_idx] = node;
    287                 if (node->wid_caps & AC_WCAP_OUT_AMP) {
    288                     spec->pcm_vol_node[dac_idx] = node;
    289                     spec->pcm_vol_index[dac_idx] = 0;
     289                snd_printdd("AUD_OUT found %x\n", node->nid);
     290                if (spec->dac_node[dac_idx]) {
     291                        /* already DAC node is assigned, just unmute & connect */
     292                        return node == spec->dac_node[dac_idx];
     293                }
     294                spec->dac_node[dac_idx] = node;
     295                if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
     296                    spec->pcm_vol_nodes < MAX_PCM_VOLS) {
     297                        spec->pcm_vol[spec->pcm_vol_nodes].node = node;
     298                        spec->pcm_vol[spec->pcm_vol_nodes].index = 0;
     299                        spec->pcm_vol_nodes++;
    290300                }
    291301                return 1; /* found */
     
    295305                child = hda_get_node(spec, node->conn_list[i]);
    296306                if (! child)
    297                     continue;
    298                 err = parse_output_path(codec, spec, child, dac_idx);
     307                        continue;
     308                err = parse_output_path(codec, spec, child, dac_idx);
    299309                if (err < 0)
    300310                        return err;
     
    306316                                select_input_connection(codec, node, i);
    307317                        unmute_input(codec, node, i);
    308                         unmute_output(codec, node);
    309                         if (! spec->pcm_vol_node[dac_idx]) {
    310                             if (node->wid_caps & AC_WCAP_IN_AMP) {
    311                                 spec->pcm_vol_node[dac_idx] = node;
    312                                 spec->pcm_vol_index[dac_idx] = i;
    313                             } else if (node->wid_caps & AC_WCAP_OUT_AMP) {
    314                                 spec->pcm_vol_node[dac_idx] = node;
    315                                 spec->pcm_vol_index[dac_idx] = 0;
    316                             }
     318                        unmute_output(codec, node);
     319                        if (spec->dac_node[dac_idx] &&
     320                            spec->pcm_vol_nodes < MAX_PCM_VOLS &&
     321                            !(spec->dac_node[dac_idx]->wid_caps &
     322                              AC_WCAP_OUT_AMP)) {
     323                                if ((node->wid_caps & AC_WCAP_IN_AMP) ||
     324                                    (node->wid_caps & AC_WCAP_OUT_AMP)) {
     325                                        int n = spec->pcm_vol_nodes;
     326                                        spec->pcm_vol[n].node = node;
     327                                        spec->pcm_vol[n].index = i;
     328                                        spec->pcm_vol_nodes++;
     329                                }
    317330                        }
    318331                        return 1;
     
    342355                /* output capable? */
    343356                if (! (node->pin_caps & AC_PINCAP_OUT))
    344                     continue;
    345                 if (defcfg_port_conn(node) == AC_JACK_PORT_NONE)
    346                     continue; /* unconnected */
     357                        continue;
     358                if (defcfg_port_conn(node) == AC_JACK_PORT_NONE)
     359                        continue; /* unconnected */
    347360                if (jack_type >= 0) {
    348361                        if (jack_type != defcfg_type(node))
     
    355368                                continue;
    356369                }
    357                 clear_check_flags(spec);
    358                 err = parse_output_path(codec, spec, node, 0);
     370                clear_check_flags(spec);
     371                err = parse_output_path(codec, spec, node, 0);
    359372                if (err < 0)
    360                     return NULL;
    361                 if (! err && spec->out_pin_node[0]) {
    362                     err = parse_output_path(codec, spec, node, 1);
    363                     if (err < 0)
    364                         return NULL;
    365                 }
    366                 if (err > 0) {
     373                        return NULL;
     374                if (! err && spec->out_pin_node[0]) {
     375                        err = parse_output_path(codec, spec, node, 1);
     376                        if (err < 0)
     377                                return NULL;
     378                }
     379                if (err > 0) {
    367380                        /* unmute the PIN output */
    368381                        unmute_output(codec, node);
     
    370383                        snd_hda_codec_write(codec, node->nid, 0,
    371384                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
    372                                             AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
     385                                            AC_PINCTL_OUT_EN |
     386                                            ((node->pin_caps & AC_PINCAP_HP_DRV) ?
     387                                             AC_PINCTL_HP_EN : 0));
    373388                        return node;
    374389                }
     
    391406        /* first, look for the line-out pin */
    392407        node = parse_output_jack(codec, spec, AC_JACK_LINE_OUT);
    393         if (node) /* found, remember the PIN node */
    394             spec->out_pin_node[0] = node;
    395         else {
    396             /* if no line-out is found, try speaker out */
    397             node = parse_output_jack(codec, spec, AC_JACK_SPEAKER);
    398             if (node)
    399                 spec->out_pin_node[0] = node;
    400         }
     408        if (node) /* found, remember the PIN node */
     409                spec->out_pin_node[0] = node;
     410        else {
     411                /* if no line-out is found, try speaker out */
     412                node = parse_output_jack(codec, spec, AC_JACK_SPEAKER);
     413                if (node)
     414                        spec->out_pin_node[0] = node;
     415        }
    401416        /* look for the HP-out pin */
    402417        node = parse_output_jack(codec, spec, AC_JACK_HP_OUT);
    403         if (node) {
    404             if (! spec->out_pin_node[0])
    405                 spec->out_pin_node[0] = node;
    406             else
    407                 spec->out_pin_node[1] = node;
    408         }
    409 
    410         if (! spec->out_pin_node[0]) {
     418        if (node) {
     419                if (! spec->out_pin_node[0])
     420                        spec->out_pin_node[0] = node;
     421                else
     422                        spec->out_pin_node[1] = node;
     423        }
     424
     425        if (! spec->out_pin_node[0]) {
    411426                /* no line-out or HP pins found,
    412427                 * then choose for the first output pin
    413                 */
    414             spec->out_pin_node[0] = parse_output_jack(codec, spec, -1);
    415             if (! spec->out_pin_node[0])
    416                 snd_printd("hda_generic: no proper output path found\n");
     428                */
     429                spec->out_pin_node[0] = parse_output_jack(codec, spec, -1);
     430                if (! spec->out_pin_node[0])
     431                        snd_printd("hda_generic: no proper output path found\n");
    417432        }
    418433
     
    461476                return "Line";
    462477        case AC_JACK_CD:
     478#if 0
    463479                if (pinctl)
    464480                        *pinctl |= AC_PINCTL_VREF_GRD;
     481#endif
    465482                return "CD";
    466483        case AC_JACK_AUX:
     
    469486                return "Aux";
    470487        case AC_JACK_MIC_IN:
    471                 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
    472                         return "Front Mic";
    473                 return "Mic";
     488            if (pinctl &&
     489                (node->pin_caps &
     490                 (AC_PINCAP_VREF_80 << AC_PINCAP_VREF_SHIFT)))
     491                *pinctl |= AC_PINCTL_VREF_80;
     492            if ((location & 0x0f) == AC_JACK_LOC_FRONT)
     493                return "Front Mic";
     494            return "Mic";
    474495        case AC_JACK_SPDIF_IN:
    475496                return "SPDIF";
     
    524545                return 0;
    525546
    526         if (defcfg_port_conn(node) == AC_JACK_PORT_NONE)
    527             return 0; /* unconnected */
    528 
    529         if (node->wid_caps & AC_WCAP_DIGITAL)
     547        if (defcfg_port_conn(node) == AC_JACK_PORT_NONE)
     548                return 0; /* unconnected */
     549
     550        if (node->wid_caps & AC_WCAP_DIGITAL)
    530551                return 0; /* skip SPDIF */
    531552
     
    556577}
    557578
     579/* add a capture source element */
     580static void add_cap_src(struct hda_gspec *spec, int idx)
     581{
     582        struct hda_input_mux_item *csrc;
     583        char *buf;
     584        int num, ocap;
     585
     586        num = spec->input_mux.num_items;
     587        csrc = &spec->input_mux.items[num];
     588        buf = spec->cap_labels[num];
     589        for (ocap = 0; ocap < num; ocap++) {
     590                if (! strcmp(buf, spec->cap_labels[ocap])) {
     591                        /* same label already exists,
     592                         * put the index number to be unique
     593                         */
     594                        sprintf(buf, "%s %d", spec->cap_labels[ocap], num);
     595                        break;
     596                }
     597        }
     598        csrc->index = idx;
     599        spec->input_mux.num_items++;
     600}
     601
    558602/*
    559603 * parse input
     
    570614        // awk added - fixed no recording due to muted widget
    571615        unmute_input(codec, adc_node, 0);
    572 
     616       
    573617        /*
    574618         * check each connection of the ADC
     
    576620         * input path.
    577621         */
     622        /* first, check the direct connections to PIN widgets */
    578623        for (i = 0; i < adc_node->nconns; i++) {
    579624                node = hda_get_node(spec, adc_node->conn_list[i]);
    580                 if (! node)
    581                         continue;
    582                 err = parse_adc_sub_nodes(codec, spec, node);
    583                 if (err < 0)
    584                         return err;
    585                 else if (err > 0) {
    586                         struct hda_input_mux_item *csrc = &spec->input_mux.items[spec->input_mux.num_items];
    587                         char *buf = spec->cap_labels[spec->input_mux.num_items];
    588                         int ocap;
    589                         for (ocap = 0; ocap < spec->input_mux.num_items; ocap++) {
    590                                 if (! strcmp(buf, spec->cap_labels[ocap])) {
    591                                         /* same label already exists,
    592                                          * put the index number to be unique
    593                                          */
    594                                         sprintf(buf, "%s %d", spec->cap_labels[ocap],
    595                                                 spec->input_mux.num_items);
    596                                 }
    597                         }
    598                         csrc->index = i;
    599                         spec->input_mux.num_items++;
     625                if (node && node->type == AC_WID_PIN) {
     626                        err = parse_adc_sub_nodes(codec, spec, node);
     627                        if (err < 0)
     628                                return err;
     629                        else if (err > 0)
     630                                add_cap_src(spec, i);
     631                }
     632        }
     633        /* ... then check the rests, more complicated connections */
     634        for (i = 0; i < adc_node->nconns; i++) {
     635                node = hda_get_node(spec, adc_node->conn_list[i]);
     636                if (node && node->type != AC_WID_PIN) {
     637                        err = parse_adc_sub_nodes(codec, spec, node);
     638                        if (err < 0)
     639                                return err;
     640                        else if (err > 0)
     641                                add_cap_src(spec, i);
    600642                }
    601643        }
     
    644686}
    645687
     688
    646689/*
    647690 * create mixer controls if possible
    648691 */
    649 #define DIR_OUT         0x1
    650 #define DIR_IN          0x2
    651 
    652692static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
    653693                        unsigned int index, const char *type, const char *dir_sfx)
     
    656696        int err;
    657697        int created = 0;
    658         struct snd_kcontrol_new knew = {0};
     698        struct snd_kcontrol_new knew;
    659699
    660700        if (type)
     
    663703                sprintf(name, "%s Switch", dir_sfx);
    664704        if ((node->wid_caps & AC_WCAP_IN_AMP) &&
    665             (node->amp_in_caps & AC_AMPCAP_MUTE)) {
     705            (node->amp_in_caps & AC_AMPCAP_MUTE)) {
     706            /*knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT);*/
    666707            knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    667708            knew.name = name;
     
    671712            knew.private_value = (node->nid | (3 << 16) | (HDA_INPUT << 18) | (index << 19));
    672713
    673             //knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT);
    674714                snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
    675715                if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
     
    677717                created = 1;
    678718        } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
    679                    (node->amp_out_caps & AC_AMPCAP_MUTE)) {
     719                   (node->amp_out_caps & AC_AMPCAP_MUTE)) {
     720            /*knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT);*/
    680721        knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    681722        knew.name = name;
     
    685726        knew.private_value = (node->nid | (3 << 16) | (HDA_OUTPUT << 18) | (0 << 19));
    686727
    687                 //knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT);
    688728                snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
    689729                if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
     
    697737                sprintf(name, "%s Volume", dir_sfx);
    698738        if ((node->wid_caps & AC_WCAP_IN_AMP) &&
    699             (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) {
     739            (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) {
     740            /*knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT);*/
    700741        knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    701742        knew.name = name;
     
    705746        knew.private_value = (node->nid | (3 << 16) | (HDA_INPUT << 18) | (index << 19));
    706747
    707                 //knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT);
    708748                snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
    709749                if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
     
    712752        } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
    713753                   (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) {
    714             //knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);
     754                /*knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);*/
    715755        knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    716756        knew.name = name;
     
    719759        knew.put = snd_hda_mixer_amp_volume_put;
    720760        knew.private_value = (node->nid | (3 << 16) | (HDA_OUTPUT << 18) | (0 << 19));
    721 
    722761                snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
    723762                if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
     
    750789 * build output mixer controls
    751790 */
     791static int create_output_mixers(struct hda_codec *codec, const char **names)
     792{
     793        struct hda_gspec *spec = codec->spec;
     794        int i, err;
     795
     796        for (i = 0; i < spec->pcm_vol_nodes; i++) {
     797                err = create_mixer(codec, spec->pcm_vol[i].node,
     798                                   spec->pcm_vol[i].index,
     799                                   names[i], "Playback");
     800                if (err < 0)
     801                        return err;
     802        }
     803        return 0;
     804}
     805
    752806static int build_output_controls(struct hda_codec *codec)
    753807{
    754808        struct hda_gspec *spec = codec->spec;
    755         static const char *types[2] = { "Master", "Headphone" };
    756         int i, err;
    757 
    758         for (i = 0; i < 2 && spec->pcm_vol_node[i]; i++) {
    759             err = create_mixer(codec, spec->pcm_vol_node[i],
    760                                spec->pcm_vol_index[i],
    761                                types[i], "Playback");
    762             if (err < 0)
    763                 return err;
    764         }
     809        static const char *types_speaker[] = { "Speaker", "Headphone" };
     810        static const char *types_line[] = { "Front", "Headphone" };
     811
     812        switch (spec->pcm_vol_nodes) {
     813        case 1:
     814                return create_mixer(codec, spec->pcm_vol[0].node,
     815                                    spec->pcm_vol[0].index,
     816                                    "Master", "Playback");
     817        case 2:
     818                if (defcfg_type(spec->out_pin_node[0]) == AC_JACK_SPEAKER)
     819                        return create_output_mixers(codec, types_speaker);
     820                else
     821                        return create_output_mixers(codec, types_line);
     822        }
    765823        return 0;
    766824}
     
    771829        struct hda_gspec *spec = codec->spec;
    772830        struct hda_gnode *adc_node = spec->adc_node;
    773         int err;
    774 
    775         if (! adc_node)
     831        int i, err;
     832        static struct snd_kcontrol_new cap_sel = {
     833                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     834                .name = "Capture Source",
     835                .info = capture_source_info,
     836                .get = capture_source_get,
     837                .put = capture_source_put,
     838        };
     839
     840        if (! adc_node || ! spec->input_mux.num_items)
    776841                return 0; /* not found */
    777842
     843        spec->cur_cap_src = 0;
     844        select_input_connection(codec, adc_node,
     845                                spec->input_mux.items[0].index);
     846
    778847        /* create capture volume and switch controls if the ADC has an amp */
    779         err = create_mixer(codec, adc_node, 0, NULL, "Capture");
     848        /* do we have only a single item? */
     849        if (spec->input_mux.num_items == 1) {
     850                err = create_mixer(codec, adc_node,
     851                                   spec->input_mux.items[0].index,
     852                                   NULL, "Capture");
     853                if (err < 0)
     854                        return err;
     855                return 0;
     856        }
    780857
    781858        /* create input MUX if multiple sources are available */
    782         if (spec->input_mux.num_items > 1) {
    783                 static struct snd_kcontrol_new cap_sel = {
    784                         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    785                         .name = "Capture Source",
    786                         .info = capture_source_info,
    787                         .get = capture_source_get,
    788                         .put = capture_source_put,
    789                 };
    790                 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&cap_sel, codec))) < 0)
     859        if ((err = snd_ctl_add(codec->bus->card,
     860                               snd_ctl_new1(&cap_sel, codec))) < 0)
     861                return err;
     862
     863        /* no volume control? */
     864        if (! (adc_node->wid_caps & AC_WCAP_IN_AMP) ||
     865            ! (adc_node->amp_in_caps & AC_AMPCAP_NUM_STEPS))
     866                return 0;
     867
     868        for (i = 0; i < spec->input_mux.num_items; i++) {
     869                struct snd_kcontrol_new knew;
     870                char name[32];
     871                sprintf(name, "%s Capture Volume",
     872                        spec->input_mux.items[i].label);
     873                /*knew = (struct snd_kcontrol_new)
     874                        HDA_CODEC_VOLUME(name, adc_node->nid,
     875                                         spec->input_mux.items[i].index,
     876                                         HDA_INPUT);*/
     877                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     878                knew.name = name;
     879                knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
     880                    SNDRV_CTL_ELEM_ACCESS_TLV_READ |
     881                    SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
     882                knew.info = snd_hda_mixer_amp_volume_info;
     883                knew.get = snd_hda_mixer_amp_volume_get;
     884                knew.put = snd_hda_mixer_amp_volume_put;
     885                knew.tlv.c = snd_hda_mixer_amp_tlv,
     886                knew.private_value = (adc_node->nid | (3 << 16) | (HDA_INPUT << 18) | (spec->input_mux.items[i].index << 19));
     887
     888                if ((err = snd_ctl_add(codec->bus->card,
     889                                       snd_ctl_new1(&knew, codec))) < 0)
    791890                        return err;
    792                 spec->cur_cap_src = 0;
    793                 select_input_connection(codec, adc_node, spec->input_mux.items[0].index);
    794         }
     891        }
     892
    795893        return 0;
    796894}
     
    859957        const char *type;
    860958
    861         if (! spec->out_pin_node[0])
     959        if (! spec->out_pin_node[0])
    862960                return 0;
    863961
     
    873971                        if (check_existing_control(codec, type, "Playback"))
    874972                                continue;
    875                         clear_check_flags(spec);
    876                         err = parse_loopback_path(codec, spec,
    877                                                   spec->out_pin_node[0],
     973                        clear_check_flags(spec);
     974                        err = parse_loopback_path(codec, spec,
     975                                                  spec->out_pin_node[0],
    878976                                                  node, type);
    879977                        if (err < 0)
     
    9111009
    9121010static int generic_pcm2_prepare(struct hda_pcm_stream *hinfo,
    913                                 struct hda_codec *codec,
    914                                 unsigned int stream_tag,
    915                                 unsigned int format,
    916                                 struct snd_pcm_substream *substream)
    917 {
    918     struct hda_gspec *spec = codec->spec;
    919 
    920     snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format);
    921     snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid,
    922                                stream_tag, 0, format);
    923     return 0;
     1011                                struct hda_codec *codec,
     1012                                unsigned int stream_tag,
     1013                                unsigned int format,
     1014                                struct snd_pcm_substream *substream)
     1015{
     1016        struct hda_gspec *spec = codec->spec;
     1017
     1018        snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format);
     1019        snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid,
     1020                                   stream_tag, 0, format);
     1021        return 0;
    9241022}
    9251023
    9261024static int generic_pcm2_cleanup(struct hda_pcm_stream *hinfo,
    927                                 struct hda_codec *codec,
    928                                 struct snd_pcm_substream *substream)
    929 {
    930     struct hda_gspec *spec = codec->spec;
    931 
    932     snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0);
    933     snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 0, 0, 0);
    934     return 0;
     1025                                struct hda_codec *codec,
     1026                                struct snd_pcm_substream *substream)
     1027{
     1028        struct hda_gspec *spec = codec->spec;
     1029
     1030        snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0);
     1031        snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 0, 0, 0);
     1032        return 0;
    9351033}
    9361034
     
    9401038        struct hda_pcm *info = &spec->pcm_rec;
    9411039
    942         if (! spec->dac_node[0] && ! spec->adc_node) {
     1040        if (! spec->dac_node[0] && ! spec->adc_node) {
    9431041                snd_printd("hda_generic: no PCM found\n");
    9441042                return 0;
     
    9481046        codec->pcm_info = info;
    9491047
    950         info->name = "HDA Generic";
    951         if (spec->dac_node[0]) {
    952             info->stream[0] = generic_pcm_playback;
    953             info->stream[0].nid = spec->dac_node[0]->nid;
    954             if (spec->dac_node[1]) {
    955                 info->stream[0].ops.prepare = generic_pcm2_prepare;
    956                 info->stream[0].ops.cleanup = generic_pcm2_cleanup;
    957             }
     1048        info->name = "HDA Generic";
     1049        if (spec->dac_node[0]) {
     1050                info->stream[0] = generic_pcm_playback;
     1051                info->stream[0].nid = spec->dac_node[0]->nid;
     1052                if (spec->dac_node[1]) {
     1053                        info->stream[0].ops.prepare = generic_pcm2_prepare;
     1054                        info->stream[0].ops.cleanup = generic_pcm2_cleanup;
     1055                }
    9581056        }
    9591057        if (spec->adc_node) {
  • GPL/trunk/alsa-kernel/pci/hda/hda_intel.c

    r84 r86  
    3131 *
    3232 *  2004.12.01  Major rewrite by tiwai, merged the work of pshou
    33  *
     33 * 
    3434 */
    3535
     
    4444#include <linux/slab.h>
    4545#include <linux/pci.h>
     46#include <linux/mutex.h>
    4647#include <sound/core.h>
    4748#include <sound/initval.h>
     
    5556static int probe_mask = -1;
    5657static int single_cmd;
     58static int enable_msi;
    5759
    5860//module_param(index, int, 0444);
     
    6870//module_param(single_cmd, bool, 0444);
    6971MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs (for debugging only).");
     72//module_param(enable_msi, int, 0);
     73MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)");
    7074
    7175
     
    8084                         "{Intel, ESB2},"
    8185                         "{Intel, ICH8},"
    82                         "{ATI, SB450},"
    83                         "{ATI, RS600},"
     86                         "{Intel, ICH9},"
     87                         "{ATI, SB450},"
     88                         "{ATI, SB600},"
     89                         "{ATI, RS600},"
     90                         "{ATI, RS690},"
    8491                         "{VIA, VT8251},"
    8592                         "{VIA, VT8237A},"
     
    105112#define ICH6_REG_INTSTS                 0x24
    106113#define ICH6_REG_WALCLK                 0x30
    107 #define ICH6_REG_SYNC                   0x34
     114#define ICH6_REG_SYNC                   0x34   
    108115#define ICH6_REG_CORBLBASE              0x40
    109116#define ICH6_REG_CORBUBASE              0x44
     
    251258        u32 *bdl;                       /* virtual address of the BDL */
    252259        dma_addr_t bdl_addr;            /* physical address of the BDL */
    253         volatile u32 *posbuf;                   /* position buffer pointer */
     260        u32 *posbuf;                    /* position buffer pointer */
    254261
    255262        unsigned int bufsize;           /* size of the play buffer in bytes */
     
    266273        unsigned int format_val;        /* format value to be set in the controller and the codec */
    267274        unsigned char stream_tag;       /* assigned stream */
    268         unsigned char index;            /* stream index */
    269         /* for sanity check of position buffer */
    270         unsigned int period_intr;
    271 
    272         unsigned int opened: 1;
    273         unsigned int running: 1;
     275        unsigned char index;            /* stream index */
     276        /* for sanity check of position buffer */
     277        unsigned int period_intr;
     278
     279        unsigned int opened :1;
     280        unsigned int running :1;
    274281};
    275282
     
    305312        /* locks */
    306313        spinlock_t reg_lock;
    307         struct semaphore open_mutex;
     314        struct mutex open_mutex;
    308315
    309316        /* streams (x num_streams) */
     
    329336        /* flags */
    330337        int position_fix;
    331         unsigned int initialized: 1;
    332         unsigned int single_cmd: 1;
     338        unsigned int initialized :1;
     339        unsigned int single_cmd :1;
     340        unsigned int polling_mode :1;
     341        unsigned int msi :1;
    333342};
    334343
     
    336345enum {
    337346        AZX_DRIVER_ICH,
    338         AZX_DRIVER_ATI,
    339         AZX_DRIVER_ATIHDMI,
     347        AZX_DRIVER_ATI,
     348        AZX_DRIVER_ATIHDMI,
    340349        AZX_DRIVER_VIA,
    341350        AZX_DRIVER_SIS,
     
    346355static char *driver_short_names[] __devinitdata = {
    347356        [AZX_DRIVER_ICH] = "HDA Intel",
    348         [AZX_DRIVER_ATI] = "HDA ATI SB",
    349         [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
     357        [AZX_DRIVER_ATI] = "HDA ATI SB",
     358        [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
    350359        [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
    351360        [AZX_DRIVER_SIS] = "HDA SIS966",
     
    391400#define upper_32bit(addr) (sizeof(addr) > 4 ? (u32)((addr) >> 32) : (u32)0)
    392401
     402static int azx_acquire_irq(struct azx *chip, int do_disconnect);
    393403
    394404/*
     
    456466/* send a command */
    457467static int azx_corb_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,
    458                         unsigned int verb, unsigned int para)
     468                             unsigned int verb, unsigned int para)
    459469{
    460470        struct azx *chip = codec->bus->private_data;
     
    494504                return;
    495505        chip->rirb.wp = wp;
    496 
     506               
    497507        while (chip->rirb.rp != wp) {
    498508                chip->rirb.rp++;
     
    515525{
    516526        struct azx *chip = codec->bus->private_data;
    517         int timeout = 50;
    518 
    519         while (chip->rirb.cmds) {
    520             if (! --timeout) {
    521                 snd_printk(KERN_ERR
    522                            "hda_intel: azx_get_response timeout, "
    523                            "switching to single_cmd mode...\n");
    524                 chip->rirb.rp = azx_readb(chip, RIRBWP);
    525                 chip->rirb.cmds = 0;
    526                 /* switch to single_cmd mode */
    527                 chip->single_cmd = 1;
    528                 azx_free_cmd_io(chip);
    529                 return -1;
    530             }
    531             msleep(1);
    532         }
    533         return chip->rirb.res; /* the last value */
     527        unsigned long timeout;
     528
     529 again:
     530        timeout = jiffies + msecs_to_jiffies(1000);
     531        do {
     532                if (chip->polling_mode) {
     533                        spin_lock_irq(&chip->reg_lock);
     534                        azx_update_rirb(chip);
     535                        spin_unlock_irq(&chip->reg_lock);
     536                }
     537                if (! chip->rirb.cmds)
     538                        return chip->rirb.res; /* the last value */
     539                schedule_timeout_interruptible(1);
     540        } while (time_after_eq(timeout, jiffies));
     541
     542        if (chip->msi) {
     543                snd_printk(KERN_WARNING "hda_intel: No response from codec, "
     544                           "disabling MSI...\n");
     545                free_irq(chip->irq, chip);
     546                chip->irq = -1;
     547                pci_disable_msi(chip->pci);
     548                chip->msi = 0;
     549                if (azx_acquire_irq(chip, 1) < 0)
     550                        return -1;
     551                goto again;
     552        }
     553
     554        if (!chip->polling_mode) {
     555                snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, "
     556                           "switching to polling mode...\n");
     557                chip->polling_mode = 1;
     558                goto again;
     559        }
     560
     561        snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
     562                   "switching to single_cmd mode...\n");
     563        chip->rirb.rp = azx_readb(chip, RIRBWP);
     564        chip->rirb.cmds = 0;
     565        /* switch to single_cmd mode */
     566        chip->single_cmd = 1;
     567        azx_free_cmd_io(chip);
     568        return -1;
    534569}
    535570
     
    599634/* send a command */
    600635static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid,
    601                         int direct, unsigned int verb,
    602                         unsigned int para)
    603 {
    604     struct azx *chip = codec->bus->private_data;
    605     if (chip->single_cmd)
    606         return azx_single_send_cmd(codec, nid, direct, verb, para);
    607     else
    608         return azx_corb_send_cmd(codec, nid, direct, verb, para);
     636                        int direct, unsigned int verb,
     637                        unsigned int para)
     638{
     639        struct azx *chip = codec->bus->private_data;
     640        if (chip->single_cmd)
     641                return azx_single_send_cmd(codec, nid, direct, verb, para);
     642        else
     643                return azx_corb_send_cmd(codec, nid, direct, verb, para);
    609644}
    610645
     
    612647static unsigned int azx_get_response(struct hda_codec *codec)
    613648{
    614     struct azx *chip = codec->bus->private_data;
    615     if (chip->single_cmd)
    616         return azx_single_get_response(codec);
    617     else
    618         return azx_rirb_get_response(codec);
     649        struct azx *chip = codec->bus->private_data;
     650        if (chip->single_cmd)
     651                return azx_single_get_response(codec);
     652        else
     653                return azx_rirb_get_response(codec);
    619654}
    620655
     
    641676
    642677        count = 50;
    643         while (! azx_readb(chip, GCTL) && --count)
     678        while (!azx_readb(chip, GCTL) && --count)
    644679                msleep(1);
    645680
    646         /* Brent Chartrand said to wait >= 540us for codecs to intialize */
     681        /* Brent Chartrand said to wait >= 540us for codecs to initialize */
    647682        msleep(1);
    648683
    649684        /* check to see if controller is ready */
    650         if (! azx_readb(chip, GCTL)) {
     685        if (!azx_readb(chip, GCTL)) {
    651686                snd_printd("azx_reset: controller not ready!\n");
    652687                return -EBUSY;
     
    657692
    658693        /* detect codecs */
    659         if (! chip->codec_mask) {
     694        if (!chip->codec_mask) {
    660695                chip->codec_mask = azx_readw(chip, STATESTS);
    661696                snd_printdd("codec_mask = 0x%x\n", chip->codec_mask);
     
    668703/*
    669704 * Lowlevel interface
    670  */
     705 */ 
    671706
    672707/* enable interrupts */
     
    765800
    766801        /* initialize the codec command I/O */
    767         if (! chip->single_cmd)
     802        if (!chip->single_cmd)
    768803                azx_init_cmd_io(chip);
    769804
     
    775810        case AZX_DRIVER_ATI:
    776811                /* For ATI SB450 azalia HD audio, we need to enable snoop */
    777                 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
     812                pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 
    778813                                     &reg);
    779                 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
     814                pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 
    780815                                      (reg & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP);
    781816                break;
     
    793828 * interrupt handler
    794829 */
    795 static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs)
     830static irqreturn_t azx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    796831{
    797832        struct azx *chip = dev_id;
     
    807842                return IRQ_NONE;
    808843        }
    809 
     844       
    810845        for (i = 0; i < chip->num_streams; i++) {
    811846                azx_dev = &chip->azx_dev[i];
    812847                if (status & azx_dev->sd_int_sta_mask) {
    813848                        azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
    814                         if (azx_dev->substream && azx_dev->running) {
    815                             azx_dev->period_intr++;
     849                        if (azx_dev->substream && azx_dev->running) {
     850                                azx_dev->period_intr++;
    816851                                spin_unlock(&chip->reg_lock);
    817852                                snd_pcm_period_elapsed(azx_dev->substream);
     
    835870#endif
    836871        spin_unlock(&chip->reg_lock);
    837 
     872       
    838873        return IRQ_HANDLED;
    839874}
     
    940975        bus_temp.private_data = chip;
    941976        bus_temp.modelname = model;
    942         bus_temp.pci = chip->pci;
    943         bus_temp.ops.command = azx_send_cmd;
    944         bus_temp.ops.get_response = azx_get_response;
     977        bus_temp.pci = chip->pci;
     978        bus_temp.ops.command = azx_send_cmd;
     979        bus_temp.ops.get_response = azx_get_response;
    945980
    946981        if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0)
     
    9981033                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
    9991034                                 SNDRV_PCM_INFO_MMAP_VALID |
    1000                                  SNDRV_PCM_INFO_PAUSE /*|*/
    1001                                  /*SNDRV_PCM_INFO_RESUME*/),
     1035                                 /* No full-resume yet implemented */
     1036                                 /* SNDRV_PCM_INFO_RESUME |*/
     1037                                 SNDRV_PCM_INFO_PAUSE),
    10021038        .formats =              SNDRV_PCM_FMTBIT_S16_LE,
    10031039        .rates =                SNDRV_PCM_RATE_48000,
     
    10301066        int err;
    10311067
    1032         down(&chip->open_mutex);
     1068        mutex_lock(&chip->open_mutex);
    10331069        azx_dev = azx_assign_device(chip, substream->stream);
    10341070        if (azx_dev == NULL) {
    1035                 up(&chip->open_mutex);
     1071                mutex_unlock(&chip->open_mutex);
    10361072                return -EBUSY;
    10371073        }
     
    10401076        runtime->hw.channels_max = hinfo->channels_max;
    10411077        runtime->hw.formats = hinfo->formats;
    1042         runtime->hw.rates = hinfo->rates;
    1043         printk("azx hw rates: %x. ratemin: %i, ratemax: %i\n",
    1044                runtime->hw.rates, runtime->hw.rate_min, runtime->hw.rate_max);
     1078        runtime->hw.rates = hinfo->rates;
    10451079        snd_pcm_limit_hw_rates(runtime);
    10461080        snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
    10471081        if ((err = hinfo->ops.open(hinfo, apcm->codec, substream)) < 0) {
    10481082                azx_release_device(azx_dev);
    1049                 up(&chip->open_mutex);
     1083                mutex_unlock(&chip->open_mutex);
    10501084                return err;
    10511085        }
     
    10561090
    10571091        runtime->private_data = azx_dev;
    1058         up(&chip->open_mutex);
     1092        mutex_unlock(&chip->open_mutex);
    10591093        return 0;
    10601094}
     
    10681102        unsigned long flags;
    10691103
    1070         down(&chip->open_mutex);
     1104        mutex_lock(&chip->open_mutex);
    10711105        spin_lock_irqsave(&chip->reg_lock, flags);
    10721106        azx_dev->substream = NULL;
     
    10751109        azx_release_device(azx_dev);
    10761110        hinfo->ops.close(hinfo, apcm->codec, substream);
    1077         up(&chip->open_mutex);
     1111        mutex_unlock(&chip->open_mutex);
    10781112        return 0;
    10791113}
     
    11761210        unsigned int pos;
    11771211
    1178         if (chip->position_fix == POS_FIX_POSBUF ||
    1179             chip->position_fix == POS_FIX_AUTO) {
     1212        if (chip->position_fix == POS_FIX_POSBUF ||
     1213            chip->position_fix == POS_FIX_AUTO) {
    11801214                /* use the position buffer */
    1181             pos = *azx_dev->posbuf;
    1182             if (chip->position_fix == POS_FIX_AUTO &&
    1183                 azx_dev->period_intr == 1 && ! pos) {
    1184                 printk(KERN_WARNING
    1185                        "hda-intel: Invalid position buffer, "
    1186                        "using LPIB read method instead.\n");
    1187                 chip->position_fix = POS_FIX_NONE;
    1188                 goto read_lpib;
    1189             }
    1190         } else {
    1191         read_lpib:
     1215                pos = le32_to_cpu(*azx_dev->posbuf);
     1216                if (chip->position_fix == POS_FIX_AUTO &&
     1217                    azx_dev->period_intr == 1 && ! pos) {
     1218                        printk(KERN_WARNING
     1219                               "hda-intel: Invalid position buffer, "
     1220                               "using LPIB read method instead.\n");
     1221                        chip->position_fix = POS_FIX_NONE;
     1222                        goto read_lpib;
     1223                }
     1224        } else {
     1225        read_lpib:
    11921226                /* read LPIB */
    11931227                pos = azx_sd_readl(azx_dev, SD_LPIB);
     
    12231257        struct azx_pcm *apcm;
    12241258
    1225         snd_assert(cpcm->stream[0].substreams || cpcm->stream[1].substreams, return -EINVAL);
     1259        /* if no substreams are defined for both playback and capture,
     1260         * it's just a placeholder.  ignore it.
     1261         */
     1262        if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
     1263                return 0;
     1264
    12261265        snd_assert(cpcm->name, return -EINVAL);
    12271266
     
    12471286        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    12481287                                              snd_dma_pci_data(chip->pci),
    1249                                               1024 * 64, 1024 * 128);
     1288                                              1024 * 64, 1024 * 1024);
    12501289        chip->pcm[pcm_dev] = pcm;
    1251         chip->pcm_devs = pcm_dev + 1;
     1290        if (chip->pcm_devs < pcm_dev + 1)
     1291                chip->pcm_devs = pcm_dev + 1;
    12521292
    12531293        return 0;
     
    13271367                azx_dev->bdl = (u32 *)(chip->bdl.area + off);
    13281368                azx_dev->bdl_addr = chip->bdl.addr + off;
    1329                 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8);
     1369                azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
    13301370                /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
    13311371                azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
     
    13401380}
    13411381
     1382static int azx_acquire_irq(struct azx *chip, int do_disconnect)
     1383{
     1384        if (request_irq(chip->pci->irq, azx_interrupt,
     1385                        chip->msi ? 0 : SA_INTERRUPT|SA_SHIRQ,
     1386                        "HDA Intel", chip)) {
     1387                printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
     1388                       "disabling device\n", chip->pci->irq);
     1389/*              if (do_disconnect)
     1390                        snd_card_disconnect(chip->card);*/
     1391                return -1;
     1392        }
     1393        chip->irq = chip->pci->irq;
     1394        pci_intx(chip->pci, !chip->msi);
     1395        return 0;
     1396}
     1397
    13421398
    13431399#ifdef CONFIG_PM
     
    13541410        for (i = 0; i < chip->pcm_devs; i++)
    13551411                snd_pcm_suspend_all(chip->pcm[i]);
    1356         snd_hda_suspend(chip->bus, state);
    1357         azx_free_cmd_io(chip);
     1412        snd_hda_suspend(chip->bus, state);
     1413        azx_free_cmd_io(chip);
     1414        if (chip->irq >= 0) {
     1415                synchronize_irq(chip->irq);
     1416                free_irq(chip->irq, chip);
     1417                chip->irq = -1;
     1418        }
     1419        if (chip->msi)
     1420                pci_disable_msi(chip->pci);
    13581421        pci_disable_device(pci);
    13591422        pci_save_state(pci);
     1423        pci_set_power_state(pci, pci_choose_state(pci, state));
    13601424        return 0;
    13611425}
     
    13661430        struct azx *chip = card->private_data;
    13671431
     1432        pci_set_power_state(pci, PCI_D0);
    13681433        pci_restore_state(pci);
    1369         pci_enable_device(pci);
     1434        if (pci_enable_device(pci) < 0) {
     1435                printk(KERN_ERR "hda-intel: pci_enable_device failed, "
     1436                       "disabling device\n");
     1437                snd_card_disconnect(card);
     1438                return -EIO;
     1439        }
    13701440        pci_set_master(pci);
     1441        if (chip->msi)
     1442                if (pci_enable_msi(pci) < 0)
     1443                        chip->msi = 0;
     1444        if (azx_acquire_irq(chip, 1) < 0)
     1445                return -EIO;
    13711446        azx_init_chip(chip);
    13721447        snd_hda_resume(chip->bus);
     
    13921467                azx_int_clear(chip);
    13931468
    1394                 /* disable CORB/RIRB */
    1395                 azx_free_cmd_io(chip);
     1469                /* disable CORB/RIRB */
     1470                azx_free_cmd_io(chip);
    13961471
    13971472                /* disable position buffer */
    13981473                azx_writel(chip, DPLBASE, 0);
    13991474                azx_writel(chip, DPUBASE, 0);
    1400 
    1401                 /* wait a little for interrupts to finish */
    1402                 msleep(1);
    1403         }
    1404 
    1405         if (chip->irq >= 0)
     1475        }
     1476
     1477        if (chip->irq >= 0) {
     1478                synchronize_irq(chip->irq);
    14061479                free_irq(chip->irq, (void*)chip);
     1480        }
     1481        if (chip->msi)
     1482                pci_disable_msi(chip->pci);
    14071483        if (chip->remap_addr)
    14081484                iounmap(chip->remap_addr);
     
    14351511{
    14361512        struct azx *chip;
    1437         int err = 0;
     1513        int err;
    14381514        static struct snd_device_ops ops = {
    14391515                .dev_free = azx_dev_free,
     
    14411517
    14421518        *rchip = NULL;
    1443 
    1444         if ((err = pci_enable_device(pci)) < 0)
     1519       
     1520        err = pci_enable_device(pci);
     1521        if (err < 0)
    14451522                return err;
    14461523
    14471524        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    1448 
    1449         if (NULL == chip) {
     1525        if (!chip) {
    14501526                snd_printk(KERN_ERR SFX "cannot allocate chip\n");
    14511527                pci_disable_device(pci);
     
    14541530
    14551531        spin_lock_init(&chip->reg_lock);
    1456         init_MUTEX(&chip->open_mutex);
     1532        mutex_init(&chip->open_mutex);
    14571533        chip->card = card;
    14581534        chip->pci = pci;
    14591535        chip->irq = -1;
    14601536        chip->driver_type = driver_type;
    1461 
    1462         chip->position_fix = position_fix;
     1537        chip->msi = enable_msi;
     1538
     1539        chip->position_fix = position_fix;
    14631540        chip->single_cmd = single_cmd;
    14641541
     
    14731550#endif
    14741551
    1475         if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) {
     1552        err = pci_request_regions(pci, "ICH HD audio");
     1553        if (err < 0) {
    14761554                kfree(chip);
    14771555                pci_disable_device(pci);
     
    14791557        }
    14801558
    1481         chip->addr = pci_resource_start(pci,0);
     1559        chip->addr = pci_resource_start(pci, 0);
    14821560        chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci,0));
    14831561        if (chip->remap_addr == NULL) {
     
    14871565        }
    14881566
    1489         if (request_irq(pci->irq, azx_interrupt, SA_INTERRUPT|SA_SHIRQ,
    1490                         "HDA Intel", (void*)chip)) {
    1491                 snd_printk(KERN_ERR SFX "unable to grab IRQ %d\n", pci->irq);
     1567        if (chip->msi)
     1568                if (pci_enable_msi(pci) < 0)
     1569                        chip->msi = 0;
     1570
     1571        if (azx_acquire_irq(chip, 0) < 0) {
    14921572                err = -EBUSY;
    14931573                goto errout;
    14941574        }
    1495         chip->irq = pci->irq;
    14961575
    14971576        pci_set_master(pci);
     
    15041583                chip->playback_index_offset = ULI_PLAYBACK_INDEX;
    15051584                chip->capture_index_offset = ULI_CAPTURE_INDEX;
    1506                 break;
    1507         case AZX_DRIVER_ATIHDMI:
     1585                break;
     1586        case AZX_DRIVER_ATIHDMI:
    15081587                chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
    15091588                chip->capture_streams = ATIHDMI_NUM_CAPTURE;
     
    15201599        chip->num_streams = chip->playback_streams + chip->capture_streams;
    15211600        chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL);
    1522         if (! chip->azx_dev) {
     1601        if (!chip->azx_dev) {
    15231602                snd_printk(KERN_ERR "cannot malloc azx_dev\n");
    15241603                goto errout;
     
    15511630
    15521631        /* codec detection */
    1553         if (! chip->codec_mask) {
     1632        if (!chip->codec_mask) {
    15541633                snd_printk(KERN_ERR SFX "no codecs found!\n");
    15551634                err = -ENODEV;
     
    15781657        struct snd_card *card;
    15791658        struct azx *chip;
    1580         int err = 0;
     1659        int err;
    15811660
    15821661        card = snd_card_new(index, id, THIS_MODULE, 0);
    1583         if (NULL == card) {
     1662        if (!card) {
    15841663                snd_printk(KERN_ERR SFX "Error creating card!\n");
    15851664                return -ENOMEM;
    15861665        }
    15871666
    1588         if ((err = azx_create(card, pci, pci_id->driver_data,
    1589                               &chip)) < 0) {
     1667        err = azx_create(card, pci, pci_id->driver_data, &chip);
     1668        if (err < 0) {
    15901669                snd_card_free(card);
    15911670                return err;
     
    16351714        { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */
    16361715        { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */
    1637         { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
    1638         { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
     1716        { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */
     1717        { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */
     1718        { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
     1719        { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
     1720        { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
     1721        { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
    16391722        { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
    16401723        { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
    16411724        { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
    1642         { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 026c */
    1643         { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 0371 */
     1725        { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP51 */
     1726        { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP55 */
     1727        { 0x10de, 0x03e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */
     1728        { 0x10de, 0x03f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */
     1729        { 0x10de, 0x044a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */
     1730        { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */
     1731        { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
     1732        { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
    16441733        { 0, }
    16451734};
  • GPL/trunk/alsa-kernel/pci/hda/hda_local.h

    r76 r86  
    3131#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
    3232        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx,  \
     33          .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
     34                    SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
     35                    SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
    3336          .info = snd_hda_mixer_amp_volume_info, \
    3437          .get = snd_hda_mixer_amp_volume_get, \
    3538          .put = snd_hda_mixer_amp_volume_put, \
     39          .tlv = { .c = snd_hda_mixer_amp_tlv },                \
    3640          .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
    3741/* stereo volume with index */
     
    6468int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
    6569int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
     70int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, unsigned int size, unsigned int __user *tlv);
    6671int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
    6772int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
     
    169174 * Misc
    170175 */
    171 struct hda_board_config {
    172         const char *modelname;
    173         int config;
    174         unsigned short pci_subvendor;
    175         unsigned short pci_subdevice;
    176 };
    177 
    178 int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl);
     176int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
     177                               const char **modelnames,
     178                               const struct snd_pci_quirk *pci_list);
    179179int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew);
    180180
     
    225225        int speaker_outs;
    226226        hda_nid_t speaker_pins[5];
    227         hda_nid_t hp_pin;
     227        int hp_outs;
     228        hda_nid_t hp_pins[5];
    228229        hda_nid_t input_pins[AUTO_PIN_LAST];
    229230        hda_nid_t dig_out_pin;
  • GPL/trunk/alsa-kernel/pci/hda/makefile.os2

    r77 r86  
    1515FILE1    = hda_intel.obj hda_codec.obj hda_generic.obj patch_realtek.obj
    1616FILE2    = patch_cmedia.obj hda_proc.obj patch_analog.obj patch_sigmatel.obj
    17 FILE3    = patch_si3054.obj patch_atihdmi.obj
    18 FILE4    =
     17FILE3    = patch_si3054.obj patch_atihdmi.obj patch_conexant.obj
     18FILE4    = patch_via.obj
    1919FILE5    =
    2020FILE6    =
  • GPL/trunk/alsa-kernel/pci/hda/patch_analog.c

    r77 r86  
    2424#include <linux/slab.h>
    2525#include <linux/pci.h>
     26#include <linux/mutex.h>
     27
    2628#include <sound/core.h>
    2729#include "hda_codec.h"
     
    4345                                         */
    4446        unsigned int cur_eapd;
     47        unsigned int need_dac_fix;
    4548
    4649        /* capture */
     
    6164        struct hda_pcm pcm_rec[2];      /* used in alc_build_pcms() */
    6265
    63         struct semaphore amp_mutex;     /* PCM volume/mute control mutex */
     66        struct mutex amp_mutex; /* PCM volume/mute control mutex */
    6467        unsigned int spdif_route;
    6568
     
    132135                if (err < 0)
    133136                        return err;
    134         }
     137        } 
    135138        if (spec->dig_in_nid) {
    136139                err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
     
    309312        int i;
    310313
    311         codec->patch_ops.init(codec);
     314        codec->patch_ops.init(codec);
    312315        for (i = 0; i < spec->num_mixers; i++)
    313316                snd_hda_resume_ctls(codec, spec->mixers[i]);
     
    336339 */
    337340static int ad198x_eapd_info(struct snd_kcontrol *kcontrol,
    338                             struct snd_ctl_elem_info *uinfo)
    339 {
    340     uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
    341     uinfo->count = 1;
    342     uinfo->value.integer.min = 0;
    343     uinfo->value.integer.max = 1;
    344     return 0;
     341                            struct snd_ctl_elem_info *uinfo)
     342{
     343        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     344        uinfo->count = 1;
     345        uinfo->value.integer.min = 0;
     346        uinfo->value.integer.max = 1;
     347        return 0;
    345348}
    346349
    347350static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
    348                            struct snd_ctl_elem_value *ucontrol)
    349 {
    350     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    351     struct ad198x_spec *spec = codec->spec;
    352     int invert = (kcontrol->private_value >> 8) & 1;
    353     if (invert)
    354         ucontrol->value.integer.value[0] = ! spec->cur_eapd;
    355     else
    356         ucontrol->value.integer.value[0] = spec->cur_eapd;
    357     return 0;
     351                           struct snd_ctl_elem_value *ucontrol)
     352{
     353        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     354        struct ad198x_spec *spec = codec->spec;
     355        int invert = (kcontrol->private_value >> 8) & 1;
     356        if (invert)
     357                ucontrol->value.integer.value[0] = ! spec->cur_eapd;
     358        else
     359                ucontrol->value.integer.value[0] = spec->cur_eapd;
     360        return 0;
    358361}
    359362
    360363static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
    361                            struct snd_ctl_elem_value *ucontrol)
    362 {
    363     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    364     struct ad198x_spec *spec = codec->spec;
    365     int invert = (kcontrol->private_value >> 8) & 1;
    366     hda_nid_t nid = kcontrol->private_value & 0xff;
    367     unsigned int eapd;
    368     eapd = ucontrol->value.integer.value[0];
    369     if (invert)
    370         eapd = !eapd;
    371     if (eapd == spec->cur_eapd && ! codec->in_resume)
    372         return 0;
    373     spec->cur_eapd = eapd;
    374     snd_hda_codec_write(codec, nid,
    375                         0, AC_VERB_SET_EAPD_BTLENABLE,
    376                         eapd ? 0x02 : 0x00);
    377     return 1;
     364                           struct snd_ctl_elem_value *ucontrol)
     365{
     366        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     367        struct ad198x_spec *spec = codec->spec;
     368        int invert = (kcontrol->private_value >> 8) & 1;
     369        hda_nid_t nid = kcontrol->private_value & 0xff;
     370        unsigned int eapd;
     371        eapd = ucontrol->value.integer.value[0];
     372        if (invert)
     373                eapd = !eapd;
     374        if (eapd == spec->cur_eapd && ! codec->in_resume)
     375                return 0;
     376        spec->cur_eapd = eapd;
     377        snd_hda_codec_write(codec, nid,
     378                            0, AC_VERB_SET_EAPD_BTLENABLE,
     379                            eapd ? 0x02 : 0x00);
     380        return 1;
    378381}
    379382
    380383static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
    381                                struct snd_ctl_elem_info *uinfo);
     384                               struct snd_ctl_elem_info *uinfo);
    382385static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
    383                               struct snd_ctl_elem_value *ucontrol);
     386                              struct snd_ctl_elem_value *ucontrol);
    384387static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
    385                               struct snd_ctl_elem_value *ucontrol);
     388                              struct snd_ctl_elem_value *ucontrol);
     389
    386390
    387391/*
     
    427431        struct ad198x_spec *ad = codec->spec;
    428432
    429         down(&ad->amp_mutex);
     433        mutex_lock(&ad->amp_mutex);
    430434        snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
    431         up(&ad->amp_mutex);
     435        mutex_unlock(&ad->amp_mutex);
    432436        return 0;
    433437}
     
    439443        int i, change = 0;
    440444
    441         down(&ad->amp_mutex);
     445        mutex_lock(&ad->amp_mutex);
    442446        for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
    443447                kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
     
    445449        }
    446450        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
    447         up(&ad->amp_mutex);
     451        mutex_unlock(&ad->amp_mutex);
    448452        return change;
    449453}
     
    456460        struct ad198x_spec *ad = codec->spec;
    457461
    458         down(&ad->amp_mutex);
     462        mutex_lock(&ad->amp_mutex);
    459463        snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
    460         up(&ad->amp_mutex);
     464        mutex_unlock(&ad->amp_mutex);
    461465        return 0;
    462466}
     
    468472        int i, change = 0;
    469473
    470         down(&ad->amp_mutex);
     474        mutex_lock(&ad->amp_mutex);
    471475        for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
    472476                kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
     
    474478        }
    475479        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
    476         up(&ad->amp_mutex);
     480        mutex_unlock(&ad->amp_mutex);
    477481        return change;
    478482}
     
    485489                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    486490                .name = "PCM Playback Volume",
     491                .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
     492                          SNDRV_CTL_ELEM_ACCESS_TLV_READ |
     493                          SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
    487494                .info = ad1986a_pcm_amp_vol_info,
    488495                .get = ad1986a_pcm_amp_vol_get,
    489496                .put = ad1986a_pcm_amp_vol_put,
     497                .tlv = { .c = snd_hda_mixer_amp_tlv },
    490498                .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
    491499        },
     
    535543/* additional mixers for 3stack mode */
    536544static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
    537     {
    538         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    539         .name = "Channel Mode",
    540         .info = ad198x_ch_mode_info,
    541         .get = ad198x_ch_mode_get,
    542         .put = ad198x_ch_mode_put,
    543     },
    544     {0} /* end */
     545        {
     546                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     547                .name = "Channel Mode",
     548                .info = ad198x_ch_mode_info,
     549                .get = ad198x_ch_mode_get,
     550                .put = ad198x_ch_mode_put,
     551        },
     552        {0} /* end */
    545553};
    546554
     
    549557
    550558static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
    551     HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    552     HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
    553     HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
    554     HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    555     /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
    556      HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
    557     HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
    558     HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
    559     HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
    560     HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
    561     HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
    562     HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
    563     HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
    564     HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    565     /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
    566      HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
    567      HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
    568      HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
    569     HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
    570     HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
    571     {
    572         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    573         .name = "Capture Source",
    574         .info = ad198x_mux_enum_info,
    575         .get = ad198x_mux_enum_get,
    576         .put = ad198x_mux_enum_put,
    577     },
    578     {0} /* end */
     559        HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
     560        HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     561        HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
     562        HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     563        /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
     564           HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
     565        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
     566        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     567        HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
     568        HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
     569        HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
     570        HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
     571        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
     572        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
     573        /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
     574           HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
     575           HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
     576           HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
     577        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
     578        HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
     579        {
     580                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     581                .name = "Capture Source",
     582                .info = ad198x_mux_enum_info,
     583                .get = ad198x_mux_enum_get,
     584                .put = ad198x_mux_enum_put,
     585        },
     586        {0} /* end */
    579587};
    580588
     
    583591/* master controls both pins 0x1a and 0x1b */
    584592static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol,
    585                                         struct snd_ctl_elem_value *ucontrol)
    586 {
    587     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    588     long *valp = ucontrol->value.integer.value;
    589     int change;
    590 
    591     change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
    592                                       0x7f, valp[0] & 0x7f);
    593     change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
    594                                        0x7f, valp[1] & 0x7f);
    595     snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
    596                             0x7f, valp[0] & 0x7f);
    597     snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
    598                             0x7f, valp[1] & 0x7f);
    599     return change;
     593                                        struct snd_ctl_elem_value *ucontrol)
     594{
     595        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     596        long *valp = ucontrol->value.integer.value;
     597        int change;
     598
     599        change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
     600                                          0x7f, valp[0] & 0x7f);
     601        change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
     602                                           0x7f, valp[1] & 0x7f);
     603        snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
     604                                0x7f, valp[0] & 0x7f);
     605        snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
     606                                0x7f, valp[1] & 0x7f);
     607        return change;
    600608}
    601609
    602610static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol,
    603                                         struct snd_ctl_elem_value *ucontrol)
    604 {
    605     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    606     long *valp = ucontrol->value.integer.value;
    607     int change;
    608 
    609     change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
    610                                       0x80, valp[0] ? 0 : 0x80);
    611     change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
    612                                        0x80, valp[1] ? 0 : 0x80);
    613     snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
    614                             0x80, valp[0] ? 0 : 0x80);
    615     snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
    616                             0x80, valp[1] ? 0 : 0x80);
    617     return change;
     611                                        struct snd_ctl_elem_value *ucontrol)
     612{
     613        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     614        long *valp = ucontrol->value.integer.value;
     615        int change;
     616
     617        change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
     618                                          0x80, valp[0] ? 0 : 0x80);
     619        change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
     620                                           0x80, valp[1] ? 0 : 0x80);
     621        snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
     622                                0x80, valp[0] ? 0 : 0x80);
     623        snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
     624                                0x80, valp[1] ? 0 : 0x80);
     625        return change;
    618626}
    619627
    620628static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
    621     .num_items = 3,
    622     .items = {
    623         { "Mic", 0x0 },
    624         { "Internal Mic", 0x4 },
    625         { "Mix", 0x5 },
    626     },
     629        .num_items = 3,
     630        .items = {
     631                { "Mic", 0x0 },
     632                { "Internal Mic", 0x4 },
     633                { "Mix", 0x5 },
     634        },
    627635};
    628636
    629637static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
    630     {
    631         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    632         .name = "Master Playback Volume",
    633         .info = snd_hda_mixer_amp_volume_info,
    634         .get = snd_hda_mixer_amp_volume_get,
    635         .put = ad1986a_laptop_master_vol_put,
    636         .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
    637     },
    638     {
    639         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    640         .name = "Master Playback Switch",
    641         .info = snd_hda_mixer_amp_switch_info,
    642         .get = snd_hda_mixer_amp_switch_get,
    643         .put = ad1986a_laptop_master_sw_put,
    644         .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
    645     },
    646     HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    647     HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
    648     HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
    649     HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
    650     HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
    651     HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    652     HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
    653     HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
    654     {
    655         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    656         .name = "Capture Source",
    657         .info = ad198x_mux_enum_info,
    658         .get = ad198x_mux_enum_get,
    659         .put = ad198x_mux_enum_put,
    660     },
    661     {
    662         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    663         .name = "External Amplifier",
    664         .info = ad198x_eapd_info,
    665         .get = ad198x_eapd_get,
    666         .put = ad198x_eapd_put,
    667         .private_value = 0x1b | (1 << 8), /* port-D, inversed */
    668     },
    669     {0} /* end */
     638        {
     639                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     640                .name = "Master Playback Volume",
     641                .info = snd_hda_mixer_amp_volume_info,
     642                .get = snd_hda_mixer_amp_volume_get,
     643                .put = ad1986a_laptop_master_vol_put,
     644                .tlv = { .c = snd_hda_mixer_amp_tlv },
     645                .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
     646        },
     647        {
     648                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     649                .name = "Master Playback Switch",
     650                .info = snd_hda_mixer_amp_switch_info,
     651                .get = snd_hda_mixer_amp_switch_get,
     652                .put = ad1986a_laptop_master_sw_put,
     653                .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
     654        },
     655        HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
     656        HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     657        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
     658        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
     659        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
     660        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
     661        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
     662        HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
     663        {
     664                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     665                .name = "Capture Source",
     666                .info = ad198x_mux_enum_info,
     667                .get = ad198x_mux_enum_get,
     668                .put = ad198x_mux_enum_put,
     669        },
     670        {
     671                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     672                .name = "External Amplifier",
     673                .info = ad198x_eapd_info,
     674                .get = ad198x_eapd_get,
     675                .put = ad198x_eapd_put,
     676                .private_value = 0x1b | (1 << 8), /* port-D, inversed */
     677        },
     678        {0} /* end */
    670679};
    671680
     
    730739/* additional verbs for 3-stack model */
    731740static struct hda_verb ad1986a_3st_init_verbs[] = {
    732     /* Mic and line-in selectors */
    733     {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
    734     {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
    735     {0} /* end */
     741        /* Mic and line-in selectors */
     742        {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
     743        {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
     744        {0} /* end */
    736745};
    737746
    738747static struct hda_verb ad1986a_ch2_init[] = {
    739     /* Surround out -> Line In */
    740     { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    741     { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
    742     /* CLFE -> Mic in */
    743     { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    744     { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
    745     {0} /* end */
     748        /* Surround out -> Line In */
     749        { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     750        { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
     751        /* CLFE -> Mic in */
     752        { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     753        { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
     754        {0} /* end */
    746755};
    747756
    748757static struct hda_verb ad1986a_ch4_init[] = {
    749     /* Surround out -> Surround */
    750     { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    751     { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    752     /* CLFE -> Mic in */
    753     { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    754     { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
    755     {0} /* end */
     758        /* Surround out -> Surround */
     759        { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     760        { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     761        /* CLFE -> Mic in */
     762        { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     763        { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
     764        {0} /* end */
    756765};
    757766
    758767static struct hda_verb ad1986a_ch6_init[] = {
    759     /* Surround out -> Surround out */
    760     { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    761     { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    762     /* CLFE -> CLFE */
    763     { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    764     { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    765     {0} /* end */
     768        /* Surround out -> Surround out */
     769        { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     770        { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     771        /* CLFE -> CLFE */
     772        { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     773        { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     774        {0} /* end */
    766775};
    767776
    768777static struct hda_channel_mode ad1986a_modes[3] = {
    769     { 2, ad1986a_ch2_init },
    770     { 4, ad1986a_ch4_init },
    771     { 6, ad1986a_ch6_init },
     778        { 2, ad1986a_ch2_init },
     779        { 4, ad1986a_ch4_init },
     780        { 6, ad1986a_ch6_init },
    772781};
    773782
    774783/* eapd initialization */
    775784static struct hda_verb ad1986a_eapd_init_verbs[] = {
    776     {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00},
    777     {0}
     785        {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00},
     786        {0}
    778787};
    779788
    780789/* models */
    781 enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD };
    782 
    783 static struct hda_board_config ad1986a_cfg_tbl[] = {
    784     { .modelname = "6stack",        .config = AD1986A_6STACK },
    785     { .modelname = "3stack",        .config = AD1986A_3STACK },
    786     { .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84,
    787     .config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */
    788     { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b3,
    789     .config = AD1986A_3STACK }, /* ASUS P5RD2-VM / P5GPL-X SE */
    790     { .modelname = "laptop",        .config = AD1986A_LAPTOP },
    791     { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e,
    792     .config = AD1986A_LAPTOP }, /* FSC V2060 */
    793     { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017,
    794     .config = AD1986A_LAPTOP }, /* Samsung M50 */
    795     { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f,
    796     .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */
    797     { .pci_subvendor = 0x144d, .pci_subdevice = 0xc023,
    798     .config = AD1986A_LAPTOP_EAPD }, /* Samsung X60 Chane */
    799     { .modelname = "laptop-eapd",   .config = AD1986A_LAPTOP_EAPD },
    800     { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024,
    801     .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */
    802     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213,
    803     .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */
    804     { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7,
    805     .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */
    806     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1297,
    807     .config = AD1986A_LAPTOP_EAPD }, /* ASUS Z62F */
    808     { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af,
    809     .config = AD1986A_LAPTOP_EAPD }, /* HP Compaq Presario B2800 */
    810     { .pci_subvendor = 0x17aa, .pci_subdevice = 0x2066,
    811     .config = AD1986A_LAPTOP_EAPD }, /* Lenovo 3000 N100-07684JU */
    812     {0}
     790enum {
     791        AD1986A_6STACK,
     792        AD1986A_3STACK,
     793        AD1986A_LAPTOP,
     794        AD1986A_LAPTOP_EAPD,
     795        AD1986A_MODELS
     796};
     797
     798static const char *ad1986a_models[AD1986A_MODELS] = {
     799        [AD1986A_6STACK]        = "6stack",
     800        [AD1986A_3STACK]        = "3stack",
     801        [AD1986A_LAPTOP]        = "laptop",
     802        [AD1986A_LAPTOP_EAPD]   = "laptop-eapd",
     803};
     804
     805static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
     806        SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
     807        SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
     808        SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
     809        SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
     810        SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
     811        SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
     812        SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
     813        SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
     814        SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
     815        SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
     816        SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
     817        SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
     818        SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
     819        SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
     820        SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
     821        SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
     822        SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
     823        SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
     824        SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
     825        SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
     826        SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
     827        {0}
    813828};
    814829
    815830static int patch_ad1986a(struct hda_codec *codec)
    816831{
    817     struct ad198x_spec *spec;
    818     int board_config;
     832        struct ad198x_spec *spec;
     833        int board_config;
    819834
    820835        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    822837                return -ENOMEM;
    823838
    824         init_MUTEX(&spec->amp_mutex);
     839        mutex_init(&spec->amp_mutex);
    825840        codec->spec = spec;
    826841
     
    830845        spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
    831846        spec->num_adc_nids = 1;
    832         spec->adc_nids = ad1986a_adc_nids;
    833         spec->capsrc_nids = ad1986a_capsrc_nids;
     847        spec->adc_nids = ad1986a_adc_nids;
     848        spec->capsrc_nids = ad1986a_capsrc_nids;
    834849        spec->input_mux = &ad1986a_capture_source;
    835850        spec->num_mixers = 1;
     
    839854
    840855        codec->patch_ops = ad198x_patch_ops;
    841         /* override some parameters */
    842         board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl);
    843         switch (board_config) {
    844         case AD1986A_3STACK:
    845             spec->num_mixers = 2;
    846             spec->mixers[1] = ad1986a_3st_mixers;
    847             spec->num_init_verbs = 2;
    848             spec->init_verbs[1] = ad1986a_3st_init_verbs;
    849             spec->channel_mode = ad1986a_modes;
    850             spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
    851             break;
    852         case AD1986A_LAPTOP:
    853             spec->mixers[0] = ad1986a_laptop_mixers;
    854             spec->multiout.max_channels = 2;
    855             spec->multiout.num_dacs = 1;
    856             spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
    857             break;
    858         case AD1986A_LAPTOP_EAPD:
    859             spec->mixers[0] = ad1986a_laptop_eapd_mixers;
    860             spec->num_init_verbs = 2;
    861             spec->init_verbs[1] = ad1986a_eapd_init_verbs;
    862             spec->multiout.max_channels = 2;
    863             spec->multiout.num_dacs = 1;
    864             spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
    865             spec->multiout.dig_out_nid = 0;
    866             spec->input_mux = &ad1986a_laptop_eapd_capture_source;
    867                          break;
    868         }
     856
     857        /* override some parameters */
     858        board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
     859                                                  ad1986a_models,
     860                                                  ad1986a_cfg_tbl);
     861        switch (board_config) {
     862        case AD1986A_3STACK:
     863                spec->num_mixers = 2;
     864                spec->mixers[1] = ad1986a_3st_mixers;
     865                spec->num_init_verbs = 3;
     866                spec->init_verbs[1] = ad1986a_3st_init_verbs;
     867                spec->init_verbs[2] = ad1986a_ch2_init;
     868                spec->channel_mode = ad1986a_modes;
     869                spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
     870                spec->need_dac_fix = 1;
     871                spec->multiout.max_channels = 2;
     872                spec->multiout.num_dacs = 1;
     873                break;
     874        case AD1986A_LAPTOP:
     875                spec->mixers[0] = ad1986a_laptop_mixers;
     876                spec->multiout.max_channels = 2;
     877                spec->multiout.num_dacs = 1;
     878                spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
     879                break;
     880        case AD1986A_LAPTOP_EAPD:
     881                spec->mixers[0] = ad1986a_laptop_eapd_mixers;
     882                spec->num_init_verbs = 2;
     883                spec->init_verbs[1] = ad1986a_eapd_init_verbs;
     884                spec->multiout.max_channels = 2;
     885                spec->multiout.num_dacs = 1;
     886                spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
     887                spec->multiout.dig_out_nid = 0;
     888                spec->input_mux = &ad1986a_laptop_eapd_capture_source;
     889                break;
     890        }
    869891
    870892        return 0;
     
    959981        {
    960982                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    961                 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
     983                .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
    962984                .info = ad1983_spdif_route_info,
    963985                .get = ad1983_spdif_route_get,
     
    10151037                return -ENOMEM;
    10161038
    1017         init_MUTEX(&spec->amp_mutex);
     1039        mutex_init(&spec->amp_mutex);
    10181040        codec->spec = spec;
    10191041
     
    10231045        spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
    10241046        spec->num_adc_nids = 1;
    1025         spec->adc_nids = ad1983_adc_nids;
    1026         spec->capsrc_nids = ad1983_capsrc_nids;
     1047        spec->adc_nids = ad1983_adc_nids;
     1048        spec->capsrc_nids = ad1983_capsrc_nids;
    10271049        spec->input_mux = &ad1983_capture_source;
    10281050        spec->num_mixers = 1;
     
    10981120        /* identical with AD1983 */
    10991121        {
    1100             .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1101             .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
     1122                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1123                .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
    11021124                .info = ad1983_spdif_route_info,
    11031125                .get = ad1983_spdif_route_get,
    11041126                .put = ad1983_spdif_route_put,
    1105         },
     1127        },
    11061128        {0} /* end */
    11071129};
     
    11611183 */
    11621184
    1163 #define AD1981_HP_EVENT         0x37
    1164 #define AD1981_MIC_EVENT        0x38
     1185#define AD1981_HP_EVENT         0x37
     1186#define AD1981_MIC_EVENT        0x38
    11651187
    11661188static struct hda_verb ad1981_hp_init_verbs[] = {
    1167     {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
    1168     /* pin sensing on HP and Mic jacks */
    1169     {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
    1170     {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
    1171     {0}
     1189        {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
     1190        /* pin sensing on HP and Mic jacks */
     1191        {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
     1192        {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
     1193        {0}
    11721194};
    11731195
    11741196/* turn on/off EAPD (+ mute HP) as a master switch */
    11751197static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
    1176                                    struct snd_ctl_elem_value *ucontrol)
    1177 {
    1178     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1179     struct ad198x_spec *spec = codec->spec;
    1180 
    1181     if (! ad198x_eapd_put(kcontrol, ucontrol))
    1182         return 0;
    1183 
    1184     /* toggle HP mute appropriately */
    1185     snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
    1186                             0x80, spec->cur_eapd ? 0 : 0x80);
    1187     snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
    1188                             0x80, spec->cur_eapd ? 0 : 0x80);
    1189     return 1;
     1198                                   struct snd_ctl_elem_value *ucontrol)
     1199{
     1200        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     1201        struct ad198x_spec *spec = codec->spec;
     1202
     1203        if (! ad198x_eapd_put(kcontrol, ucontrol))
     1204                return 0;
     1205
     1206        /* toggle HP mute appropriately */
     1207        snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
     1208                                0x80, spec->cur_eapd ? 0 : 0x80);
     1209        snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
     1210                                0x80, spec->cur_eapd ? 0 : 0x80);
     1211        return 1;
    11901212}
    11911213
    11921214/* bind volumes of both NID 0x05 and 0x06 */
    11931215static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
    1194                                     struct snd_ctl_elem_value *ucontrol)
    1195 {
    1196     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1197     long *valp = ucontrol->value.integer.value;
    1198     int change;
    1199 
    1200     change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
    1201                                       0x7f, valp[0] & 0x7f);
    1202     change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
    1203                                        0x7f, valp[1] & 0x7f);
    1204     snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
    1205                             0x7f, valp[0] & 0x7f);
    1206     snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
    1207                             0x7f, valp[1] & 0x7f);
    1208     return change;
     1216                                    struct snd_ctl_elem_value *ucontrol)
     1217{
     1218        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     1219        long *valp = ucontrol->value.integer.value;
     1220        int change;
     1221
     1222        change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
     1223                                          0x7f, valp[0] & 0x7f);
     1224        change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
     1225                                           0x7f, valp[1] & 0x7f);
     1226        snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
     1227                                0x7f, valp[0] & 0x7f);
     1228        snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
     1229                                0x7f, valp[1] & 0x7f);
     1230        return change;
    12091231}
    12101232
     
    12121234static void ad1981_hp_automute(struct hda_codec *codec)
    12131235{
    1214     unsigned int present;
    1215 
    1216     present = snd_hda_codec_read(codec, 0x06, 0,
    1217                                  AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1218     snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
    1219                             0x80, present ? 0x80 : 0);
    1220     snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
    1221                             0x80, present ? 0x80 : 0);
     1236        unsigned int present;
     1237
     1238        present = snd_hda_codec_read(codec, 0x06, 0,
     1239                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1240        snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
     1241                                0x80, present ? 0x80 : 0);
     1242        snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
     1243                                0x80, present ? 0x80 : 0);
    12221244}
    12231245
     
    12251247static void ad1981_hp_automic(struct hda_codec *codec)
    12261248{
    1227     static struct hda_verb mic_jack_on[] = {
    1228         {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
    1229         {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    1230         {0}
    1231     };
    1232     static struct hda_verb mic_jack_off[] = {
    1233         {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
    1234         {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    1235         {0}
    1236     };
    1237     unsigned int present;
    1238 
    1239     present = snd_hda_codec_read(codec, 0x08, 0,
    1240                                 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1241     if (present)
    1242         snd_hda_sequence_write(codec, mic_jack_on);
    1243     else
    1244         snd_hda_sequence_write(codec, mic_jack_off);
     1249        static struct hda_verb mic_jack_on[] = {
     1250                {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
     1251                {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     1252                {0}
     1253        };
     1254        static struct hda_verb mic_jack_off[] = {
     1255                {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
     1256                {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     1257                {0}
     1258        };
     1259        unsigned int present;
     1260
     1261        present = snd_hda_codec_read(codec, 0x08, 0,
     1262                                AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1263        if (present)
     1264                snd_hda_sequence_write(codec, mic_jack_on);
     1265        else
     1266                snd_hda_sequence_write(codec, mic_jack_off);
    12451267}
    12461268
    12471269/* unsolicited event for HP jack sensing */
    12481270static void ad1981_hp_unsol_event(struct hda_codec *codec,
    1249                                   unsigned int res)
    1250 {
    1251     res >>= 26;
    1252     switch (res) {
    1253     case AD1981_HP_EVENT:
    1254         ad1981_hp_automute(codec);
    1255         break;
    1256     case AD1981_MIC_EVENT:
    1257         ad1981_hp_automic(codec);
    1258         break;
    1259     }
     1271                                  unsigned int res)
     1272{
     1273        res >>= 26;
     1274        switch (res) {
     1275        case AD1981_HP_EVENT:
     1276                ad1981_hp_automute(codec);
     1277                break;
     1278        case AD1981_MIC_EVENT:
     1279                ad1981_hp_automic(codec);
     1280                break;
     1281        }
    12601282}
    12611283
    12621284static struct hda_input_mux ad1981_hp_capture_source = {
    1263     .num_items = 3,
    1264     .items = {
    1265         { "Mic", 0x0 },
    1266         { "Docking-Station", 0x1 },
    1267         { "Mix", 0x2 },
    1268     },
     1285        .num_items = 3,
     1286        .items = {
     1287                { "Mic", 0x0 },
     1288                { "Docking-Station", 0x1 },
     1289                { "Mix", 0x2 },
     1290        },
    12691291};
    12701292
    12711293static struct snd_kcontrol_new ad1981_hp_mixers[] = {
    1272     {
    1273         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1274         .name = "Master Playback Volume",
    1275         .info = snd_hda_mixer_amp_volume_info,
    1276         .get = snd_hda_mixer_amp_volume_get,
    1277         .put = ad1981_hp_master_vol_put,
    1278         .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
    1279     },
    1280     {
    1281         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1282         .name = "Master Playback Switch",
    1283         .info = ad198x_eapd_info,
    1284         .get = ad198x_eapd_get,
    1285         .put = ad1981_hp_master_sw_put,
    1286         .private_value = 0x05,
    1287     },
    1288     HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
    1289     HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
     1294        {
     1295                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1296                .name = "Master Playback Volume",
     1297                .info = snd_hda_mixer_amp_volume_info,
     1298                .get = snd_hda_mixer_amp_volume_get,
     1299                .put = ad1981_hp_master_vol_put,
     1300                .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
     1301        },
     1302        {
     1303                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1304                .name = "Master Playback Switch",
     1305                .info = ad198x_eapd_info,
     1306                .get = ad198x_eapd_get,
     1307                .put = ad1981_hp_master_sw_put,
     1308                .private_value = 0x05,
     1309        },
     1310        HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
     1311        HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
    12901312#if 0
    1291     /* FIXME: analog mic/line loopback doesn't work with my tests...
    1292     *        (although recording is OK)
    1293     */
    1294     HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
    1295     HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
    1296     HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
    1297     HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    1298     HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
    1299     HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
    1300     /* FIXME: does this laptop have analog CD connection? */
    1301     HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
    1302     HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
     1313        /* FIXME: analog mic/line loopback doesn't work with my tests...
     1314        *        (although recording is OK)
     1315        */
     1316        HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
     1317        HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
     1318        HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
     1319        HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
     1320        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
     1321        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
     1322        /* FIXME: does this laptop have analog CD connection? */
     1323        HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
     1324        HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
    13031325#endif
    1304     HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
    1305     HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
    1306     HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
    1307     HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
    1308     {
    1309         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1310         .name = "Capture Source",
    1311         .info = ad198x_mux_enum_info,
    1312         .get = ad198x_mux_enum_get,
    1313         .put = ad198x_mux_enum_put,
    1314     },
    1315         /* identical with AD1983 */
     1326        HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
     1327        HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
     1328        HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
     1329        HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
     1330        {
     1331                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1332                .name = "Capture Source",
     1333                .info = ad198x_mux_enum_info,
     1334                .get = ad198x_mux_enum_get,
     1335                .put = ad198x_mux_enum_put,
     1336        },
     1337        {0} /* end */
     1338};
     1339
     1340/* initialize jack-sensing, too */
     1341static int ad1981_hp_init(struct hda_codec *codec)
     1342{
     1343        ad198x_init(codec);
     1344        ad1981_hp_automute(codec);
     1345        ad1981_hp_automic(codec);
     1346        return 0;
     1347}
     1348
     1349/* configuration for Lenovo Thinkpad T60 */
     1350static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
     1351        HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
     1352        HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
     1353        HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
     1354        HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
     1355        HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
     1356        HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
     1357        HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
     1358        HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
     1359        HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
     1360        HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
     1361        HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
     1362        {
     1363                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1364                .name = "Capture Source",
     1365                .info = ad198x_mux_enum_info,
     1366                .get = ad198x_mux_enum_get,
     1367                .put = ad198x_mux_enum_put,
     1368        },
     1369        /* identical with AD1983 */
    13161370        {
    13171371                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    13211375                .put = ad1983_spdif_route_put,
    13221376        },
    1323     {0} /* end */
    1324 };
    1325 
    1326 /* initialize jack-sensing, too */
    1327 static int ad1981_hp_init(struct hda_codec *codec)
    1328 {
    1329     ad198x_init(codec);
    1330     ad1981_hp_automute(codec);
    1331     ad1981_hp_automic(codec);
    1332     return 0;
    1333 }
    1334 
    1335 /* configuration for Lenovo Thinkpad T60 */
    1336 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
    1337     HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
    1338     HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
    1339     HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
    1340     HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
    1341     HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
    1342     HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
    1343     HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
    1344     HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
    1345     HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
    1346     HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
    1347     HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
    1348     {
    1349         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1350         .name = "Capture Source",
    1351         .info = ad198x_mux_enum_info,
    1352         .get = ad198x_mux_enum_get,
    1353         .put = ad198x_mux_enum_put,
    1354     },
    1355     {0} /* end */
     1377        {0} /* end */
    13561378};
    13571379
    13581380static struct hda_input_mux ad1981_thinkpad_capture_source = {
    1359     .num_items = 3,
    1360     .items = {
    1361         { "Mic", 0x0 },
    1362         { "Mix", 0x2 },
    1363         { "CD", 0x4 },
    1364     },
     1381        .num_items = 3,
     1382        .items = {
     1383                { "Mic", 0x0 },
     1384                { "Mix", 0x2 },
     1385                { "CD", 0x4 },
     1386        },
    13651387};
    13661388
    13671389/* models */
    1368 enum { AD1981_BASIC, AD1981_HP, AD1981_THINKPAD };
    1369 
    1370 static struct hda_board_config ad1981_cfg_tbl[] = {
    1371     { .modelname = "hp", .config = AD1981_HP },
    1372     { .pci_subvendor = 0x103c, .pci_subdevice = 0x30aa,
    1373     .config = AD1981_HP }, /* HP nx6320 */
    1374     { .pci_subvendor = 0x103c, .pci_subdevice = 0x309f,
    1375     .config = AD1981_HP }, /* HP nx9420 AngelFire */
    1376     { .pci_subvendor = 0x30b0, .pci_subdevice = 0x103c,
    1377     .config = AD1981_HP }, /* HP nx6320 (reversed SSID, H/W bug) */
    1378     { .modelname = "basic", .config = AD1981_BASIC },
    1379     { .modelname = "thinkpad", .config = AD1981_THINKPAD },
    1380     /* Lenovo Thinkpad T60/X60/Z6xx */
    1381     { .pci_subvendor = 0x17aa, .config = AD1981_THINKPAD },
    1382     { .pci_subvendor = 0x1014, .pci_subdevice = 0x0597,
    1383     .config = AD1981_THINKPAD }, /* Z60m/t */
    1384     { .modelname = "basic", .config = AD1981_BASIC },
    1385     {0}
     1390enum {
     1391        AD1981_BASIC,
     1392        AD1981_HP,
     1393        AD1981_THINKPAD,
     1394        AD1981_MODELS
     1395};
     1396
     1397static const char *ad1981_models[AD1981_MODELS] = {
     1398        [AD1981_HP]             = "hp",
     1399        [AD1981_THINKPAD]       = "thinkpad",
     1400        [AD1981_BASIC]          = "basic",
     1401};
     1402
     1403static struct snd_pci_quirk ad1981_cfg_tbl[] = {
     1404        /* All HP models */
     1405        SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
     1406        /* HP nx6320 (reversed SSID, H/W bug) */
     1407        SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
     1408        /* Lenovo Thinkpad T60/X60/Z6xx */
     1409        SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
     1410        SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
     1411        {0}
    13861412};
    13871413
    13881414static int patch_ad1981(struct hda_codec *codec)
    13891415{
    1390     struct ad198x_spec *spec;
    1391     int board_config;
     1416        struct ad198x_spec *spec;
     1417        int board_config;
    13921418
    13931419        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    13951421                return -ENOMEM;
    13961422
    1397         init_MUTEX(&spec->amp_mutex);
     1423        mutex_init(&spec->amp_mutex);
    13981424        codec->spec = spec;
    13991425
     
    14041430        spec->num_adc_nids = 1;
    14051431        spec->adc_nids = ad1981_adc_nids;
    1406         spec->capsrc_nids = ad1981_capsrc_nids;
     1432        spec->capsrc_nids = ad1981_capsrc_nids;
    14071433        spec->input_mux = &ad1981_capture_source;
    14081434        spec->num_mixers = 1;
     
    14141440        codec->patch_ops = ad198x_patch_ops;
    14151441
    1416         /* override some parameters */
    1417         board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl);
    1418         switch (board_config) {
    1419         case AD1981_HP:
    1420             spec->mixers[0] = ad1981_hp_mixers;
    1421             spec->num_init_verbs = 2;
    1422             spec->init_verbs[1] = ad1981_hp_init_verbs;
    1423             spec->multiout.dig_out_nid = 0;
    1424             spec->input_mux = &ad1981_hp_capture_source;
    1425 
    1426             codec->patch_ops.init = ad1981_hp_init;
    1427             codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
    1428             break;
    1429         case AD1981_THINKPAD:
    1430             spec->mixers[0] = ad1981_thinkpad_mixers;
    1431             spec->multiout.dig_out_nid = 0;
    1432             spec->input_mux = &ad1981_thinkpad_capture_source;
    1433             break;
    1434         }
     1442        /* override some parameters */
     1443        board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
     1444                                                  ad1981_models,
     1445                                                  ad1981_cfg_tbl);
     1446        switch (board_config) {
     1447        case AD1981_HP:
     1448                spec->mixers[0] = ad1981_hp_mixers;
     1449                spec->num_init_verbs = 2;
     1450                spec->init_verbs[1] = ad1981_hp_init_verbs;
     1451                spec->multiout.dig_out_nid = 0;
     1452                spec->input_mux = &ad1981_hp_capture_source;
     1453
     1454                codec->patch_ops.init = ad1981_hp_init;
     1455                codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
     1456                break;
     1457        case AD1981_THINKPAD:
     1458                spec->mixers[0] = ad1981_thinkpad_mixers;
     1459                spec->input_mux = &ad1981_thinkpad_capture_source;
     1460                break;
     1461        }
     1462
    14351463        return 0;
    14361464}
     
    15411569        ((codec)->vendor_id == 0x11d41988 && \
    15421570         (codec)->revision_id == AD1988A_REV2)
     1571
    15431572/*
    15441573 * mixers
     
    16181647        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    16191648        struct ad198x_spec *spec = codec->spec;
    1620         return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
    1621                                    spec->num_channel_mode, &spec->multiout.max_channels);
     1649        int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
     1650                                      spec->num_channel_mode,
     1651                                      &spec->multiout.max_channels);
     1652        if (err >= 0 && spec->need_dac_fix)
     1653                spec->multiout.num_dacs = spec->multiout.max_channels / 2;
     1654        return err;
    16221655}
    16231656
     
    16291662        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
    16301663        HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
     1664        {0} /* end */
    16311665};
    16321666
     
    16371671        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
    16381672        HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
     1673        {0} /* end */
    16391674};
    16401675
     
    16751710        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
    16761711        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
     1712        {0} /* end */
    16771713};
    16781714
     
    16821718        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
    16831719        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
     1720        {0} /* end */
    16841721};
    16851722
     
    17431780        {
    17441781                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1745                 .name = "External Amplifier",
    1746                 .info = ad198x_eapd_info,
    1747                 .get = ad198x_eapd_get,
    1748                 .put = ad198x_eapd_put,
    1749                 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
     1782                .name = "External Amplifier",
     1783                .info = ad198x_eapd_info,
     1784                .get = ad198x_eapd_get,
     1785                .put = ad198x_eapd_put,
     1786                .private_value = 0x12 | (1 << 8), /* port-D, inversed */
    17501787        },
    17511788
     
    21192156        else
    21202157                snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
    2121 }
     2158} 
    21222159
    21232160
     
    21872224                /* A     B     C     D     E     F     G     H */
    21882225                0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
    2189         };
    2190         if (is_rev2(codec))
     2226        };
     2227        if (is_rev2(codec))
    21912228                return idx_to_dac_rev2[idx];
    21922229        else
     
    23202357        idx = ad1988_pin_idx(pin);
    23212358        nid = ad1988_idx_to_dac(codec, idx);
    2322         /* specify the DAC as the extra output */
    2323         if (! spec->multiout.hp_nid)
    2324             spec->multiout.hp_nid = nid;
    2325         else
    2326             spec->multiout.extra_out_nid[0] = nid;
     2359        /* specify the DAC as the extra output */
     2360        if (! spec->multiout.hp_nid)
     2361                spec->multiout.hp_nid = nid;
     2362        else
     2363                spec->multiout.extra_out_nid[0] = nid;
    23272364        /* control HP volume/switch on the output mixer amp */
    23282365        sprintf(name, "%s Playback Volume", pfx);
     
    24432480        hda_nid_t pin;
    24442481
    2445         pin = spec->autocfg.speaker_pins[0];
     2482        pin = spec->autocfg.speaker_pins[0];
    24462483        if (pin) /* connect to front */
    24472484                ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    2448         pin = spec->autocfg.hp_pin;
     2485        pin = spec->autocfg.hp_pins[0];
    24492486        if (pin) /* connect to front */
    24502487                ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     
    24912528                return err;
    24922529        if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
    2493             return err;
    2494         if (! spec->autocfg.line_outs)
     2530                return err;
     2531        if (! spec->autocfg.line_outs)
    24952532                return 0; /* can't find valid BIOS pin config */
    2496         if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
    2497             (err = ad1988_auto_create_extra_out(codec,
    2498                                                 spec->autocfg.speaker_pins[0],
    2499                                                 "Speaker")) < 0 ||
    2500             (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pin,
     2533        if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
     2534            (err = ad1988_auto_create_extra_out(codec,
     2535                                                spec->autocfg.speaker_pins[0],
     2536                                                "Speaker")) < 0 ||
     2537            (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
    25012538                                                "Headphone")) < 0 ||
    25022539            (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
     
    25342571 */
    25352572
    2536 static struct hda_board_config ad1988_cfg_tbl[] = {
    2537         { .modelname = "6stack",        .config = AD1988_6STACK },
    2538         { .modelname = "6stack-dig",    .config = AD1988_6STACK_DIG },
    2539         { .modelname = "3stack",        .config = AD1988_3STACK },
    2540         { .modelname = "3stack-dig",    .config = AD1988_3STACK_DIG },
    2541         { .modelname = "laptop",        .config = AD1988_LAPTOP },
    2542         { .modelname = "laptop-dig",    .config = AD1988_LAPTOP_DIG },
    2543         { .modelname = "auto",          .config = AD1988_AUTO },
    2544         {0}
     2573static const char *ad1988_models[AD1988_MODEL_LAST] = {
     2574        [AD1988_6STACK]         = "6stack",
     2575        [AD1988_6STACK_DIG]     = "6stack-dig",
     2576        [AD1988_3STACK]         = "3stack",
     2577        [AD1988_3STACK_DIG]     = "3stack-dig",
     2578        [AD1988_LAPTOP]         = "laptop",
     2579        [AD1988_LAPTOP_DIG]     = "laptop-dig",
     2580        [AD1988_AUTO]           = "auto",
    25452581};
    25462582
     
    25542590                return -ENOMEM;
    25552591
    2556         init_MUTEX(&spec->amp_mutex);
     2592        mutex_init(&spec->amp_mutex);
    25572593        codec->spec = spec;
    25582594
    2559         if (is_rev2(codec))
     2595        if (is_rev2(codec))
    25602596                snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
    25612597
    2562         board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl);
    2563         if (board_config < 0 || board_config >= AD1988_MODEL_LAST) {
     2598        board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
     2599                                                  ad1988_models, NULL);
     2600        if (board_config < 0) {
    25642601                printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
    25652602                board_config = AD1988_AUTO;
     
    25822619        case AD1988_6STACK_DIG:
    25832620                spec->multiout.max_channels = 8;
    2584                 spec->multiout.num_dacs = 4;
    2585                 if (is_rev2(codec))
     2621                spec->multiout.num_dacs = 4;
     2622                if (is_rev2(codec))
    25862623                        spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
    25872624                else
    25882625                        spec->multiout.dac_nids = ad1988_6stack_dac_nids;
    25892626                spec->input_mux = &ad1988_6stack_capture_source;
    2590                 spec->num_mixers = 2;
    2591                 if (is_rev2(codec))
     2627                spec->num_mixers = 2;
     2628                if (is_rev2(codec))
    25922629                        spec->mixers[0] = ad1988_6stack_mixers1_rev2;
    25932630                else
     
    26042641        case AD1988_3STACK_DIG:
    26052642                spec->multiout.max_channels = 6;
    2606                 spec->multiout.num_dacs = 3;
    2607                 if (is_rev2(codec))
     2643                spec->multiout.num_dacs = 3;
     2644                if (is_rev2(codec))
    26082645                        spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
    26092646                else
     
    26122649                spec->channel_mode = ad1988_3stack_modes;
    26132650                spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
    2614                 spec->num_mixers = 2;
    2615                 if (is_rev2(codec))
     2651                spec->num_mixers = 2;
     2652                if (is_rev2(codec))
    26162653                        spec->mixers[0] = ad1988_3stack_mixers1_rev2;
    26172654                else
     
    26732710        { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
    26742711        { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
     2712        { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
    26752713        {0} /* terminator */
    26762714};
  • GPL/trunk/alsa-kernel/pci/hda/patch_cmedia.c

    r69 r86  
    4141        CMI_ALLOUT,     /* back 5-jack + front-panel 2-jack + digital out */
    4242        CMI_AUTO,       /* let driver guess it */
     43        CMI_MODELS
    4344};
    4445
     
    604605 */
    605606
    606 static struct hda_board_config cmi9880_cfg_tbl[] = {
    607         { .modelname = "minimal", .config = CMI_MINIMAL },
    608         { .modelname = "min_fp", .config = CMI_MIN_FP },
    609         { .modelname = "full", .config = CMI_FULL },
    610         { .modelname = "full_dig", .config = CMI_FULL_DIG },
    611         { .pci_subvendor = 0x1043, .pci_subdevice = 0x813d, .config = CMI_FULL_DIG }, /* ASUS P5AD2 */
    612         { .modelname = "allout", .config = CMI_ALLOUT },
    613         { .modelname = "auto", .config = CMI_AUTO },
     607static const char *cmi9880_models[CMI_MODELS] = {
     608        [CMI_MINIMAL]   = "minimal",
     609        [CMI_MIN_FP]    = "min_fp",
     610        [CMI_FULL]      = "full",
     611        [CMI_FULL_DIG]  = "full_dig",
     612        [CMI_ALLOUT]    = "allout",
     613        [CMI_AUTO]      = "auto",
     614};
     615
     616static struct snd_pci_quirk cmi9880_cfg_tbl[] = {
     617        SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG),
    614618        {0} /* terminator */
    615619};
     
    634638
    635639        codec->spec = spec;
    636         spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl);
     640        spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS,
     641                                                        cmi9880_models,
     642                                                        cmi9880_cfg_tbl);
    637643        if (spec->board_config < 0) {
    638644                snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n");
  • GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c

    r77 r86  
    3333#include "hda_local.h"
    3434
     35#define ALC880_FRONT_EVENT              0x01
     36#define ALC880_DCVOL_EVENT              0x02
     37#define ALC880_HP_EVENT                 0x04
     38#define ALC880_MIC_EVENT                0x08
    3539
    3640/* ALC880 board config type */
    3741enum {
    38     ALC880_3ST,
    39     ALC880_3ST_DIG,
    40     ALC880_5ST,
    41     ALC880_5ST_DIG,
    42     ALC880_W810,
    43     ALC880_Z71V,
    44     ALC880_6ST,
    45     ALC880_6ST_DIG,
    46     ALC880_F1734,
    47     ALC880_ASUS,
    48     ALC880_ASUS_DIG,
    49     ALC880_ASUS_W1V,
    50     ALC880_ASUS_DIG2,
    51     ALC880_UNIWILL_DIG,
    52     ALC880_CLEVO,
    53     ALC880_TCL_S700,
    54     ALC880_LG,
    55     ALC880_LG_LW,
     42        ALC880_3ST,
     43        ALC880_3ST_DIG,
     44        ALC880_5ST,
     45        ALC880_5ST_DIG,
     46        ALC880_W810,
     47        ALC880_Z71V,
     48        ALC880_6ST,
     49        ALC880_6ST_DIG,
     50        ALC880_F1734,
     51        ALC880_ASUS,
     52        ALC880_ASUS_DIG,
     53        ALC880_ASUS_W1V,
     54        ALC880_ASUS_DIG2,
     55        ALC880_UNIWILL_DIG,
     56        ALC880_UNIWILL,
     57        ALC880_UNIWILL_P53,
     58        ALC880_CLEVO,
     59        ALC880_TCL_S700,
     60        ALC880_LG,
     61        ALC880_LG_LW,
    5662#ifdef CONFIG_SND_DEBUG
    57     ALC880_TEST,
     63        ALC880_TEST,
    5864#endif
    59     ALC880_AUTO,
    60     ALC880_MODEL_LAST /* last tag */
     65        ALC880_AUTO,
     66        ALC880_MODEL_LAST /* last tag */
    6167};
    6268
    6369/* ALC260 models */
    6470enum {
    65     ALC260_BASIC,
    66     ALC260_HP,
    67     ALC260_HP_3013,
    68     ALC260_FUJITSU_S702X,
    69     ALC260_ACER,
     71        ALC260_BASIC,
     72        ALC260_HP,
     73        ALC260_HP_3013,
     74        ALC260_FUJITSU_S702X,
     75        ALC260_ACER,
    7076#ifdef CONFIG_SND_DEBUG
    71     ALC260_TEST,
     77        ALC260_TEST,
    7278#endif
    73     ALC260_AUTO,
    74     ALC260_MODEL_LAST /* last tag */
     79        ALC260_AUTO,
     80        ALC260_MODEL_LAST /* last tag */
    7581};
    7682
    7783/* ALC262 models */
    7884enum {
    79     ALC262_BASIC,
    80     ALC262_FUJITSU,
    81     ALC262_HP_BPC,
    82     ALC262_AUTO,
    83     ALC262_MODEL_LAST /* last tag */
     85        ALC262_BASIC,
     86        ALC262_HIPPO,
     87        ALC262_HIPPO_1,
     88        ALC262_FUJITSU,
     89        ALC262_HP_BPC,
     90        ALC262_BENQ_ED8,
     91        ALC262_AUTO,
     92        ALC262_MODEL_LAST /* last tag */
    8493};
    8594
    8695/* ALC861 models */
    8796enum {
    88     ALC861_3ST,
    89     ALC660_3ST,
    90     ALC861_3ST_DIG,
    91     ALC861_6ST_DIG,
    92     ALC861_AUTO,
    93     ALC861_MODEL_LAST,
     97        ALC861_3ST,
     98        ALC660_3ST,
     99        ALC861_3ST_DIG,
     100        ALC861_6ST_DIG,
     101        ALC861_UNIWILL_M31,
     102        ALC861_TOSHIBA,
     103        ALC861_ASUS,
     104        ALC861_ASUS_LAPTOP,
     105        ALC861_AUTO,
     106        ALC861_MODEL_LAST,
    94107};
    95108
    96109/* ALC882 models */
    97110enum {
    98     ALC882_3ST_DIG,
    99     ALC882_6ST_DIG,
    100     ALC882_AUTO,
    101     ALC882_MODEL_LAST,
     111        ALC882_3ST_DIG,
     112        ALC882_6ST_DIG,
     113        ALC882_ARIMA,
     114        ALC882_AUTO,
     115        ALC885_MACPRO,
     116        ALC882_MODEL_LAST,
    102117};
    103118
    104119/* ALC883 models */
    105120enum {
    106     ALC883_3ST_2ch_DIG,
    107     ALC883_3ST_6ch_DIG,
    108     ALC883_3ST_6ch,
    109     ALC883_6ST_DIG,
    110     ALC888_DEMO_BOARD,
    111     ALC883_AUTO,
    112     ALC883_MODEL_LAST,
     121        ALC883_3ST_2ch_DIG,
     122        ALC883_3ST_6ch_DIG,
     123        ALC883_3ST_6ch,
     124        ALC883_6ST_DIG,
     125        ALC883_TARGA_DIG,
     126        ALC883_TARGA_2ch_DIG,
     127        ALC888_DEMO_BOARD,
     128        ALC883_ACER,
     129        ALC883_MEDION,
     130        ALC883_LAPTOP_EAPD,
     131        ALC883_AUTO,
     132        ALC883_MODEL_LAST,
    113133};
    114134
     
    117137
    118138struct alc_spec {
    119     /* codec parameterization */
    120     struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
    121     unsigned int num_mixers;
    122 
    123     const struct hda_verb *init_verbs[5]; /* initialization verbs
    124     * don't forget NULL
    125     * termination!
    126     */
    127     unsigned int num_init_verbs;
    128 
    129     char *stream_name_analog;   /* analog PCM stream */
    130     struct hda_pcm_stream *stream_analog_playback;
    131     struct hda_pcm_stream *stream_analog_capture;
    132 
    133     char *stream_name_digital;  /* digital PCM stream */
    134     struct hda_pcm_stream *stream_digital_playback;
    135     struct hda_pcm_stream *stream_digital_capture;
    136 
    137     /* playback */
    138     struct hda_multi_out multiout;      /* playback set-up
    139     * max_channels, dacs must be set
    140     * dig_out_nid and hp_nid are optional
    141     */
    142 
    143     /* capture */
    144     unsigned int num_adc_nids;
    145     hda_nid_t *adc_nids;
    146     hda_nid_t dig_in_nid;               /* digital-in NID; optional */
    147 
    148     /* capture source */
    149     const struct hda_input_mux *input_mux;
    150     unsigned int cur_mux[3];
    151 
    152     /* channel model */
    153     const struct hda_channel_mode *channel_mode;
    154     int num_channel_mode;
    155 
    156     /* PCM information */
    157     struct hda_pcm pcm_rec[3];  /* used in alc_build_pcms() */
    158 
    159     /* dynamic controls, init_verbs and input_mux */
    160     struct auto_pin_cfg autocfg;
    161     unsigned int num_kctl_alloc, num_kctl_used;
    162     struct snd_kcontrol_new *kctl_alloc;
    163     struct hda_input_mux private_imux;
    164     hda_nid_t private_dac_nids[5];
    165 
    166     /* hooks */
    167     void (*init_hook)(struct hda_codec *codec);
    168     void (*unsol_event)(struct hda_codec *codec, unsigned int res);
    169 
    170     /* for pin sensing */
    171     unsigned int sense_updated: 1;
    172     unsigned int jack_present: 1;
     139        /* codec parameterization */
     140        struct snd_kcontrol_new *mixers[5];     /* mixer arrays */
     141        unsigned int num_mixers;
     142
     143        const struct hda_verb *init_verbs[5];   /* initialization verbs
     144                                                 * don't forget NULL
     145                                                 * termination!
     146                                                 */
     147        unsigned int num_init_verbs;
     148
     149        char *stream_name_analog;       /* analog PCM stream */
     150        struct hda_pcm_stream *stream_analog_playback;
     151        struct hda_pcm_stream *stream_analog_capture;
     152
     153        char *stream_name_digital;      /* digital PCM stream */
     154        struct hda_pcm_stream *stream_digital_playback;
     155        struct hda_pcm_stream *stream_digital_capture;
     156
     157        /* playback */
     158        struct hda_multi_out multiout;  /* playback set-up
     159                                         * max_channels, dacs must be set
     160                                         * dig_out_nid and hp_nid are optional
     161                                         */
     162
     163        /* capture */
     164        unsigned int num_adc_nids;
     165        hda_nid_t *adc_nids;
     166        hda_nid_t dig_in_nid;           /* digital-in NID; optional */
     167
     168        /* capture source */
     169        unsigned int num_mux_defs;
     170        const struct hda_input_mux *input_mux;
     171        unsigned int cur_mux[3];
     172
     173        /* channel model */
     174        const struct hda_channel_mode *channel_mode;
     175        int num_channel_mode;
     176        int need_dac_fix;
     177
     178        /* PCM information */
     179        struct hda_pcm pcm_rec[3];      /* used in alc_build_pcms() */
     180
     181        /* dynamic controls, init_verbs and input_mux */
     182        struct auto_pin_cfg autocfg;
     183        unsigned int num_kctl_alloc, num_kctl_used;
     184        struct snd_kcontrol_new *kctl_alloc;
     185        struct hda_input_mux private_imux;
     186        hda_nid_t private_dac_nids[5];
     187
     188        /* hooks */
     189        void (*init_hook)(struct hda_codec *codec);
     190        void (*unsol_event)(struct hda_codec *codec, unsigned int res);
     191
     192        /* for pin sensing */
     193        unsigned int sense_updated: 1;
     194        unsigned int jack_present: 1;
    173195};
    174196
     
    177199 */
    178200struct alc_config_preset {
    179     struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
    180     const struct hda_verb *init_verbs[5];
    181     unsigned int num_dacs;
    182     hda_nid_t *dac_nids;
    183     hda_nid_t dig_out_nid;              /* optional */
    184     hda_nid_t hp_nid;           /* optional */
    185     unsigned int num_adc_nids;
    186     hda_nid_t *adc_nids;
    187     hda_nid_t dig_in_nid;
    188     unsigned int num_channel_mode;
    189     const struct hda_channel_mode *channel_mode;
    190     const struct hda_input_mux *input_mux;
    191     void (*unsol_event)(struct hda_codec *, unsigned int);
    192     void (*init_hook)(struct hda_codec *);
     201        struct snd_kcontrol_new *mixers[5]; /* should be identical size
     202                                             * with spec
     203                                             */
     204        const struct hda_verb *init_verbs[5];
     205        unsigned int num_dacs;
     206        hda_nid_t *dac_nids;
     207        hda_nid_t dig_out_nid;          /* optional */
     208        hda_nid_t hp_nid;               /* optional */
     209        unsigned int num_adc_nids;
     210        hda_nid_t *adc_nids;
     211        hda_nid_t dig_in_nid;
     212        unsigned int num_channel_mode;
     213        const struct hda_channel_mode *channel_mode;
     214        int need_dac_fix;
     215        unsigned int num_mux_defs;
     216        const struct hda_input_mux *input_mux;
     217        void (*unsol_event)(struct hda_codec *, unsigned int);
     218        void (*init_hook)(struct hda_codec *);
    193219};
    194220
     
    197223 * input MUX handling
    198224 */
    199 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    200 {
    201     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    202     struct alc_spec *spec = codec->spec;
    203     return snd_hda_input_mux_info(spec->input_mux, uinfo);
    204 }
    205 
    206 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    207 {
    208     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    209     struct alc_spec *spec = codec->spec;
    210     unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    211 
    212     ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
    213     return 0;
    214 }
    215 
    216 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    217 {
    218     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    219     struct alc_spec *spec = codec->spec;
    220     unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    221     return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
    222                                  spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
     225static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
     226                             struct snd_ctl_elem_info *uinfo)
     227{
     228        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     229        struct alc_spec *spec = codec->spec;
     230        unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
     231        if (mux_idx >= spec->num_mux_defs)
     232                mux_idx = 0;
     233        return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
     234}
     235
     236static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
     237                            struct snd_ctl_elem_value *ucontrol)
     238{
     239        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     240        struct alc_spec *spec = codec->spec;
     241        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
     242
     243        ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
     244        return 0;
     245}
     246
     247static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
     248                            struct snd_ctl_elem_value *ucontrol)
     249{
     250        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     251        struct alc_spec *spec = codec->spec;
     252        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
     253        unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
     254        return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
     255                                     spec->adc_nids[adc_idx],
     256                                     &spec->cur_mux[adc_idx]);
    223257}
    224258
     
    227261 * channel mode setting
    228262 */
    229 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    230 {
    231     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    232     struct alc_spec *spec = codec->spec;
    233     return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
    234                                 spec->num_channel_mode);
     263static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
     264                            struct snd_ctl_elem_info *uinfo)
     265{
     266        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     267        struct alc_spec *spec = codec->spec;
     268        return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
     269                                    spec->num_channel_mode);
    235270}
    236271
    237272static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
    238                            struct snd_ctl_elem_value *ucontrol)
    239 {
    240     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    241     struct alc_spec *spec = codec->spec;
    242     return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
    243                                spec->num_channel_mode,
    244                                spec->multiout.max_channels);
     273                           struct snd_ctl_elem_value *ucontrol)
     274{
     275        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     276        struct alc_spec *spec = codec->spec;
     277        return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
     278                                   spec->num_channel_mode,
     279                                   spec->multiout.max_channels);
    245280}
    246281
    247282static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
    248                            struct snd_ctl_elem_value *ucontrol)
    249 {
    250     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    251     struct alc_spec *spec = codec->spec;
    252     return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
    253                                spec->num_channel_mode,
    254                                &spec->multiout.max_channels);
     283                           struct snd_ctl_elem_value *ucontrol)
     284{
     285        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     286        struct alc_spec *spec = codec->spec;
     287        int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
     288                                      spec->num_channel_mode,
     289                                      &spec->multiout.max_channels);
     290        if (err >= 0 && spec->need_dac_fix)
     291                spec->multiout.num_dacs = spec->multiout.max_channels / 2;
     292        return err;
    255293}
    256294
    257295/*
    258296 * Control the mode of pin widget settings via the mixer.  "pc" is used
    259  * instead of "%" to avoid consequences of accidently treating the % as
     297 * instead of "%" to avoid consequences of accidently treating the % as 
    260298 * being part of a format specifier.  Maximum allowed length of a value is
    261299 * 63 characters plus NULL terminator.
     
    265303 * are requested.  Therefore order this list so that this behaviour will not
    266304 * cause problems when mixer clients move through the enum sequentially.
    267  * NIDs 0x0f and 0x10 have been observed to have this behaviour.
     305 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
     306 * March 2006.
    268307 */
    269308static char *alc_pin_mode_names[] = {
    270     "Mic 50pc bias", "Mic 80pc bias",
    271     "Line in", "Line out", "Headphone out",
     309        "Mic 50pc bias", "Mic 80pc bias",
     310        "Line in", "Line out", "Headphone out",
    272311};
    273312static unsigned char alc_pin_mode_values[] = {
    274     PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
     313        PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
    275314};
    276315/* The control can present all 5 options, or it can limit the options based
    277  * in the pin being assumed to be exclusively an input or an output pin.
    278  */
    279 #define ALC_PIN_DIR_IN    0x00
    280 #define ALC_PIN_DIR_OUT   0x01
    281 #define ALC_PIN_DIR_INOUT 0x02
    282 
    283 /* Info about the pin modes supported by the three different pin directions.
     316 * in the pin being assumed to be exclusively an input or an output pin.  In
     317 * addition, "input" pins may or may not process the mic bias option
     318 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
     319 * accept requests for bias as of chip versions up to March 2006) and/or
     320 * wiring in the computer.
     321 */
     322#define ALC_PIN_DIR_IN              0x00
     323#define ALC_PIN_DIR_OUT             0x01
     324#define ALC_PIN_DIR_INOUT           0x02
     325#define ALC_PIN_DIR_IN_NOMICBIAS    0x03
     326#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
     327
     328/* Info about the pin modes supported by the different pin direction modes.
    284329 * For each direction the minimum and maximum values are given.
    285330 */
    286 static signed char alc_pin_mode_dir_info[3][2] = {
    287     { 0, 2 },    /* ALC_PIN_DIR_IN */
    288     { 3, 4 },    /* ALC_PIN_DIR_OUT */
    289     { 0, 4 },    /* ALC_PIN_DIR_INOUT */
     331static signed char alc_pin_mode_dir_info[5][2] = {
     332        { 0, 2 },    /* ALC_PIN_DIR_IN */
     333        { 3, 4 },    /* ALC_PIN_DIR_OUT */
     334        { 0, 4 },    /* ALC_PIN_DIR_INOUT */
     335        { 2, 2 },    /* ALC_PIN_DIR_IN_NOMICBIAS */
     336        { 2, 4 },    /* ALC_PIN_DIR_INOUT_NOMICBIAS */
    290337};
    291338#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
    292339#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
    293340#define alc_pin_mode_n_items(_dir) \
    294     (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
    295 
    296 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    297 {
    298     unsigned int item_num = uinfo->value.enumerated.item;
    299     unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
    300 
    301     uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    302     uinfo->count = 1;
    303     uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
    304 
    305     if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
    306         item_num = alc_pin_mode_min(dir);
    307     strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
    308     return 0;
    309 }
    310 
    311 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    312 {
    313     unsigned int i;
    314     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    315     hda_nid_t nid = kcontrol->private_value & 0xffff;
    316     unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
    317     long *valp = ucontrol->value.integer.value;
    318     unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
    319 
    320     /* Find enumerated value for current pinctl setting */
    321     i = alc_pin_mode_min(dir);
    322     while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
    323         i++;
    324     *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
    325     return 0;
    326 }
    327 
    328 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    329 {
    330     signed int change;
    331     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    332     hda_nid_t nid = kcontrol->private_value & 0xffff;
    333     unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
    334     long val = *ucontrol->value.integer.value;
    335     unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
    336 
    337     if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
    338         val = alc_pin_mode_min(dir);
    339 
    340     change = pinctl != alc_pin_mode_values[val];
    341     if (change) {
    342         /* Set pin mode to that requested */
    343         snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
    344                             alc_pin_mode_values[val]);
    345 
    346         /* Also enable the retasking pin's input/output as required
    347          * for the requested pin mode.  Enum values of 2 or less are
    348          * input modes.
    349          *
    350          * Dynamically switching the input/output buffers probably
    351          * reduces noise slightly, particularly on input.  However,
    352          * havingboth input and output buffers enabled
    353          * simultaneously doesn't seem to be problematic.
    354          */
    355         if (val <= 2) {
    356             snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
    357                                 AMP_OUT_MUTE);
    358             snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
    359                                 AMP_IN_UNMUTE(0));
    360         } else {
    361             snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
    362                                 AMP_IN_MUTE(0));
    363             snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
    364                                 AMP_OUT_UNMUTE);
    365         }
    366     }
    367     return change;
     341        (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
     342
     343static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
     344                             struct snd_ctl_elem_info *uinfo)
     345{
     346        unsigned int item_num = uinfo->value.enumerated.item;
     347        unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
     348
     349        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     350        uinfo->count = 1;
     351        uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
     352
     353        if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
     354                item_num = alc_pin_mode_min(dir);
     355        strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
     356        return 0;
     357}
     358
     359static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
     360                            struct snd_ctl_elem_value *ucontrol)
     361{
     362        unsigned int i;
     363        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     364        hda_nid_t nid = kcontrol->private_value & 0xffff;
     365        unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
     366        long *valp = ucontrol->value.integer.value;
     367        unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
     368                                                 AC_VERB_GET_PIN_WIDGET_CONTROL,
     369                                                 0x00);
     370
     371        /* Find enumerated value for current pinctl setting */
     372        i = alc_pin_mode_min(dir);
     373        while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
     374                i++;
     375        *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
     376        return 0;
     377}
     378
     379static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
     380                            struct snd_ctl_elem_value *ucontrol)
     381{
     382        signed int change;
     383        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     384        hda_nid_t nid = kcontrol->private_value & 0xffff;
     385        unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
     386        long val = *ucontrol->value.integer.value;
     387        unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
     388                                                 AC_VERB_GET_PIN_WIDGET_CONTROL,
     389                                                 0x00);
     390
     391        if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
     392                val = alc_pin_mode_min(dir);
     393
     394        change = pinctl != alc_pin_mode_values[val];
     395        if (change) {
     396                /* Set pin mode to that requested */
     397                snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
     398                                    alc_pin_mode_values[val]);
     399
     400                /* Also enable the retasking pin's input/output as required
     401                 * for the requested pin mode.  Enum values of 2 or less are
     402                 * input modes.
     403                 *
     404                 * Dynamically switching the input/output buffers probably
     405                 * reduces noise slightly (particularly on input) so we'll
     406                 * do it.  However, having both input and output buffers
     407                 * enabled simultaneously doesn't seem to be problematic if
     408                 * this turns out to be necessary in the future.
     409                 */
     410                if (val <= 2) {
     411                        snd_hda_codec_write(codec, nid, 0,
     412                                            AC_VERB_SET_AMP_GAIN_MUTE,
     413                                            AMP_OUT_MUTE);
     414                        snd_hda_codec_write(codec, nid, 0,
     415                                            AC_VERB_SET_AMP_GAIN_MUTE,
     416                                            AMP_IN_UNMUTE(0));
     417                } else {
     418                        snd_hda_codec_write(codec, nid, 0,
     419                                            AC_VERB_SET_AMP_GAIN_MUTE,
     420                                            AMP_IN_MUTE(0));
     421                        snd_hda_codec_write(codec, nid, 0,
     422                                            AC_VERB_SET_AMP_GAIN_MUTE,
     423                                            AMP_OUT_UNMUTE);
     424                }
     425        }
     426        return change;
    368427}
    369428
    370429#define ALC_PIN_MODE(xname, nid, dir) \
    371     { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
    372     .info = alc_pin_mode_info, \
    373     .get = alc_pin_mode_get, \
    374     .put = alc_pin_mode_put, \
    375     .private_value = nid | (dir<<16) }
     430        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
     431          .info = alc_pin_mode_info, \
     432          .get = alc_pin_mode_get, \
     433          .put = alc_pin_mode_put, \
     434          .private_value = nid | (dir<<16) }
    376435
    377436/* A switch control for ALC260 GPIO pins.  Multiple GPIOs can be ganged
     
    381440 */
    382441#ifdef CONFIG_SND_DEBUG
    383 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    384 {
    385     uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
    386     uinfo->count = 1;
    387     uinfo->value.integer.min = 0;
    388     uinfo->value.integer.max = 1;
    389     return 0;
    390 }
    391 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    392 {
    393     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    394     hda_nid_t nid = kcontrol->private_value & 0xffff;
    395     unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
    396     long *valp = ucontrol->value.integer.value;
    397     unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
    398 
    399     *valp = (val & mask) != 0;
    400     return 0;
    401 }
    402 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    403 {
    404     signed int change;
    405     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    406     hda_nid_t nid = kcontrol->private_value & 0xffff;
    407     unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
    408     long val = *ucontrol->value.integer.value;
    409     unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
    410 
    411     /* Set/unset the masked GPIO bit(s) as needed */
    412     change = (val==0?0:mask) != (gpio_data & mask);
    413     if (val==0)
    414         gpio_data &= ~mask;
    415     else
    416         gpio_data |= mask;
    417     snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
    418 
    419     return change;
     442static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
     443                              struct snd_ctl_elem_info *uinfo)
     444{
     445        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     446        uinfo->count = 1;
     447        uinfo->value.integer.min = 0;
     448        uinfo->value.integer.max = 1;
     449        return 0;
     450}                               
     451static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
     452                             struct snd_ctl_elem_value *ucontrol)
     453{
     454        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     455        hda_nid_t nid = kcontrol->private_value & 0xffff;
     456        unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
     457        long *valp = ucontrol->value.integer.value;
     458        unsigned int val = snd_hda_codec_read(codec, nid, 0,
     459                                              AC_VERB_GET_GPIO_DATA, 0x00);
     460
     461        *valp = (val & mask) != 0;
     462        return 0;
     463}
     464static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
     465                             struct snd_ctl_elem_value *ucontrol)
     466{
     467        signed int change;
     468        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     469        hda_nid_t nid = kcontrol->private_value & 0xffff;
     470        unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
     471        long val = *ucontrol->value.integer.value;
     472        unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
     473                                                    AC_VERB_GET_GPIO_DATA,
     474                                                    0x00);
     475
     476        /* Set/unset the masked GPIO bit(s) as needed */
     477        change = (val == 0 ? 0 : mask) != (gpio_data & mask);
     478        if (val == 0)
     479                gpio_data &= ~mask;
     480        else
     481                gpio_data |= mask;
     482        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
     483
     484        return change;
    420485}
    421486#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
    422     { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
    423     .info = alc_gpio_data_info, \
    424     .get = alc_gpio_data_get, \
    425     .put = alc_gpio_data_put, \
    426     .private_value = nid | (mask<<16) }
     487        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
     488          .info = alc_gpio_data_info, \
     489          .get = alc_gpio_data_get, \
     490          .put = alc_gpio_data_put, \
     491          .private_value = nid | (mask<<16) }
    427492#endif   /* CONFIG_SND_DEBUG */
    428493
     
    435500 */
    436501#ifdef CONFIG_SND_DEBUG
    437 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    438 {
    439     uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
    440     uinfo->count = 1;
    441     uinfo->value.integer.min = 0;
    442     uinfo->value.integer.max = 1;
    443     return 0;
    444 }
    445 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    446 {
    447     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    448     hda_nid_t nid = kcontrol->private_value & 0xffff;
    449     unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
    450     long *valp = ucontrol->value.integer.value;
    451     unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
    452 
    453     *valp = (val & mask) != 0;
    454     return 0;
    455 }
    456 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    457 {
    458     signed int change;
    459     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    460     hda_nid_t nid = kcontrol->private_value & 0xffff;
    461     unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
    462     long val = *ucontrol->value.integer.value;
    463     unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
    464 
    465     /* Set/unset the masked control bit(s) as needed */
    466     change = (val==0?0:mask) != (ctrl_data & mask);
    467     if (val==0)
    468         ctrl_data &= ~mask;
    469     else
    470         ctrl_data |= mask;
    471     snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
    472 
    473     return change;
     502static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
     503                               struct snd_ctl_elem_info *uinfo)
     504{
     505        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     506        uinfo->count = 1;
     507        uinfo->value.integer.min = 0;
     508        uinfo->value.integer.max = 1;
     509        return 0;
     510}                               
     511static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
     512                              struct snd_ctl_elem_value *ucontrol)
     513{
     514        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     515        hda_nid_t nid = kcontrol->private_value & 0xffff;
     516        unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
     517        long *valp = ucontrol->value.integer.value;
     518        unsigned int val = snd_hda_codec_read(codec, nid, 0,
     519                                              AC_VERB_GET_DIGI_CONVERT, 0x00);
     520
     521        *valp = (val & mask) != 0;
     522        return 0;
     523}
     524static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
     525                              struct snd_ctl_elem_value *ucontrol)
     526{
     527        signed int change;
     528        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     529        hda_nid_t nid = kcontrol->private_value & 0xffff;
     530        unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
     531        long val = *ucontrol->value.integer.value;
     532        unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
     533                                                    AC_VERB_GET_DIGI_CONVERT,
     534                                                    0x00);
     535
     536        /* Set/unset the masked control bit(s) as needed */
     537        change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
     538        if (val==0)
     539                ctrl_data &= ~mask;
     540        else
     541                ctrl_data |= mask;
     542        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
     543                            ctrl_data);
     544
     545        return change;
    474546}
    475547#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
    476     { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
    477     .info = alc_spdif_ctrl_info, \
    478     .get = alc_spdif_ctrl_get, \
    479     .put = alc_spdif_ctrl_put, \
    480     .private_value = nid | (mask<<16) }
     548        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
     549          .info = alc_spdif_ctrl_info, \
     550          .get = alc_spdif_ctrl_get, \
     551          .put = alc_spdif_ctrl_put, \
     552          .private_value = nid | (mask<<16) }
    481553#endif   /* CONFIG_SND_DEBUG */
    482554
     
    484556 * set up from the preset table
    485557 */
    486 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
    487 {
    488     int i;
    489 
    490     for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
    491         spec->mixers[spec->num_mixers++] = preset->mixers[i];
    492     for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
    493         spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
    494 
    495     spec->channel_mode = preset->channel_mode;
    496     spec->num_channel_mode = preset->num_channel_mode;
    497 
    498     spec->multiout.max_channels = spec->channel_mode[0].channels;
    499 
    500     spec->multiout.num_dacs = preset->num_dacs;
    501     spec->multiout.dac_nids = preset->dac_nids;
    502     spec->multiout.dig_out_nid = preset->dig_out_nid;
    503     spec->multiout.hp_nid = preset->hp_nid;
    504 
    505     spec->input_mux = preset->input_mux;
    506 
    507     spec->num_adc_nids = preset->num_adc_nids;
    508     spec->adc_nids = preset->adc_nids;
    509     spec->dig_in_nid = preset->dig_in_nid;
    510     spec->unsol_event = preset->unsol_event;
    511     spec->init_hook = preset->init_hook;
     558static void setup_preset(struct alc_spec *spec,
     559                         const struct alc_config_preset *preset)
     560{
     561        int i;
     562
     563        for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
     564                spec->mixers[spec->num_mixers++] = preset->mixers[i];
     565        for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
     566             i++)
     567                spec->init_verbs[spec->num_init_verbs++] =
     568                        preset->init_verbs[i];
     569       
     570        spec->channel_mode = preset->channel_mode;
     571        spec->num_channel_mode = preset->num_channel_mode;
     572        spec->need_dac_fix = preset->need_dac_fix;
     573
     574        spec->multiout.max_channels = spec->channel_mode[0].channels;
     575
     576        spec->multiout.num_dacs = preset->num_dacs;
     577        spec->multiout.dac_nids = preset->dac_nids;
     578        spec->multiout.dig_out_nid = preset->dig_out_nid;
     579        spec->multiout.hp_nid = preset->hp_nid;
     580       
     581        spec->num_mux_defs = preset->num_mux_defs;
     582        if (! spec->num_mux_defs)
     583                spec->num_mux_defs = 1;
     584        spec->input_mux = preset->input_mux;
     585
     586        spec->num_adc_nids = preset->num_adc_nids;
     587        spec->adc_nids = preset->adc_nids;
     588        spec->dig_in_nid = preset->dig_in_nid;
     589
     590        spec->unsol_event = preset->unsol_event;
     591        spec->init_hook = preset->init_hook;
    512592}
    513593
     
    516596 *
    517597 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
    518  * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
    519  *                 HP = 0x19
     598 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
     599 *                 F-Mic = 0x1b, HP = 0x19
    520600 */
    521601
    522602static hda_nid_t alc880_dac_nids[4] = {
    523     /* front, rear, clfe, rear_surr */
    524     0x02, 0x05, 0x04, 0x03
     603        /* front, rear, clfe, rear_surr */
     604        0x02, 0x05, 0x04, 0x03
    525605};
    526606
    527607static hda_nid_t alc880_adc_nids[3] = {
    528     /* ADC0-2 */
    529     0x07, 0x08, 0x09,
     608        /* ADC0-2 */
     609        0x07, 0x08, 0x09,
    530610};
    531611
     
    535615 */
    536616static hda_nid_t alc880_adc_nids_alt[2] = {
    537     /* ADC1-2 */
    538     0x08, 0x09,
     617        /* ADC1-2 */
     618        0x08, 0x09,
    539619};
    540620
     
    543623
    544624static struct hda_input_mux alc880_capture_source = {
    545     .num_items = 4,
    546     .items = {
    547         { "Mic", 0x0 },
    548         { "Front Mic", 0x3 },
    549         { "Line", 0x2 },
    550         { "CD", 0x4 },
    551     },
     625        .num_items = 4,
     626        .items = {
     627                { "Mic", 0x0 },
     628                { "Front Mic", 0x3 },
     629                { "Line", 0x2 },
     630                { "CD", 0x4 },
     631        },
    552632};
    553633
     
    555635/* 2ch mode */
    556636static struct hda_verb alc880_threestack_ch2_init[] = {
    557     /* set line-in to input, mute it */
    558     { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
    559     { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    560     /* set mic-in to input vref 80%, mute it */
    561     { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    562     { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    563     {0} /* end */
     637        /* set line-in to input, mute it */
     638        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     639        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     640        /* set mic-in to input vref 80%, mute it */
     641        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     642        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     643        {0} /* end */
    564644};
    565645
    566646/* 6ch mode */
    567647static struct hda_verb alc880_threestack_ch6_init[] = {
    568     /* set line-in to output, unmute it */
    569     { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    570     { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    571     /* set mic-in to output, unmute it */
    572     { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    573     { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    574     {0} /* end */
     648        /* set line-in to output, unmute it */
     649        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     650        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     651        /* set mic-in to output, unmute it */
     652        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     653        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     654        {0} /* end */
    575655};
    576656
    577657static struct hda_channel_mode alc880_threestack_modes[2] = {
    578     { 2, alc880_threestack_ch2_init },
    579     { 6, alc880_threestack_ch6_init },
     658        { 2, alc880_threestack_ch2_init },
     659        { 6, alc880_threestack_ch6_init },
    580660};
    581661
    582662static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
    583     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    584     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    585     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    586     HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
    587     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    588     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    589     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    590     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    591     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    592     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    593     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    594     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    595     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    596     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    597     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
    598     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
    599     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    600     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    601     HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
    602     {
    603         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    604         .name = "Channel Mode",
    605         .info = alc_ch_mode_info,
    606         .get = alc_ch_mode_get,
    607         .put = alc_ch_mode_put,
    608     },
    609     {0} /* end */
     663        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     664        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     665        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     666        HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
     667        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     668        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     669        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     670        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     671        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     672        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     673        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     674        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     675        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     676        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     677        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
     678        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
     679        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     680        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     681        HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
     682        {
     683                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     684                .name = "Channel Mode",
     685                .info = alc_ch_mode_info,
     686                .get = alc_ch_mode_get,
     687                .put = alc_ch_mode_put,
     688        },
     689        {0} /* end */
    610690};
    611691
    612692/* capture mixer elements */
    613693static struct snd_kcontrol_new alc880_capture_mixer[] = {
    614     HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
    615     HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
    616     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
    617     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
    618     HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
    619     HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
    620     {
    621         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    622         /* The multiple "Capture Source" controls confuse alsamixer
    623         * So call somewhat different..
    624         * FIXME: the controls appear in the "playback" view!
    625         */
    626         /* .name = "Capture Source", */
    627         .name = "Input Source",
    628         .count = 3,
    629         .info = alc_mux_enum_info,
    630         .get = alc_mux_enum_get,
    631         .put = alc_mux_enum_put,
    632     },
    633     {0} /* end */
     694        HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
     695        HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
     696        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
     697        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
     698        HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
     699        HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
     700        {
     701                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     702                /* The multiple "Capture Source" controls confuse alsamixer
     703                * So call somewhat different..
     704                * FIXME: the controls appear in the "playback" view!
     705                */
     706                /* .name = "Capture Source", */
     707                .name = "Input Source",
     708                .count = 3,
     709                .info = alc_mux_enum_info,
     710                .get = alc_mux_enum_get,
     711                .put = alc_mux_enum_put,
     712        },
     713        {0} /* end */
    634714};
    635715
    636716/* capture mixer elements (in case NID 0x07 not available) */
    637717static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
    638     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    639     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    640     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    641     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    642     {
    643         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    644         /* The multiple "Capture Source" controls confuse alsamixer
    645         * So call somewhat different..
    646         * FIXME: the controls appear in the "playback" view!
    647         */
    648         /* .name = "Capture Source", */
    649         .name = "Input Source",
    650         .count = 2,
    651         .info = alc_mux_enum_info,
    652         .get = alc_mux_enum_get,
    653         .put = alc_mux_enum_put,
    654     },
    655     {0} /* end */
     718        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     719        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     720        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     721        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     722        {
     723                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     724                /* The multiple "Capture Source" controls confuse alsamixer
     725                * So call somewhat different..
     726                * FIXME: the controls appear in the "playback" view!
     727                */
     728                /* .name = "Capture Source", */
     729                .name = "Input Source",
     730                .count = 2,
     731                .info = alc_mux_enum_info,
     732                .get = alc_mux_enum_get,
     733                .put = alc_mux_enum_put,
     734        },
     735        {0} /* end */
    656736};
    657737
     
    661741 * ALC880 5-stack model
    662742 *
    663  * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
     743 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
     744 *      Side = 0x02 (0xd)
    664745 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
    665746 *                 Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
     
    668749/* additional mixers to alc880_three_stack_mixer */
    669750static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
    670     HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    671     HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
    672     {0} /* end */
     751        HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     752        HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
     753        {0} /* end */
    673754};
    674755
     
    676757/* 6ch mode */
    677758static struct hda_verb alc880_fivestack_ch6_init[] = {
    678     /* set line-in to input, mute it */
    679     { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
    680     { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    681     {0} /* end */
     759        /* set line-in to input, mute it */
     760        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     761        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     762        {0} /* end */
    682763};
    683764
    684765/* 8ch mode */
    685766static struct hda_verb alc880_fivestack_ch8_init[] = {
    686     /* set line-in to output, unmute it */
    687     { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    688     { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    689     {0} /* end */
     767        /* set line-in to output, unmute it */
     768        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     769        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     770        {0} /* end */
    690771};
    691772
    692773static struct hda_channel_mode alc880_fivestack_modes[2] = {
    693     { 6, alc880_fivestack_ch6_init },
    694     { 8, alc880_fivestack_ch8_init },
     774        { 6, alc880_fivestack_ch6_init },
     775        { 8, alc880_fivestack_ch8_init },
    695776};
    696777
     
    699780 * ALC880 6-stack model
    700781 *
    701  * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
     782 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
     783 *      Side = 0x05 (0x0f)
    702784 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
    703785 *   Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
     
    705787
    706788static hda_nid_t alc880_6st_dac_nids[4] = {
    707     /* front, rear, clfe, rear_surr */
    708     0x02, 0x03, 0x04, 0x05
    709 };
     789        /* front, rear, clfe, rear_surr */
     790        0x02, 0x03, 0x04, 0x05
     791};     
    710792
    711793static struct hda_input_mux alc880_6stack_capture_source = {
    712     .num_items = 4,
    713     .items = {
    714         { "Mic", 0x0 },
    715         { "Front Mic", 0x1 },
    716         { "Line", 0x2 },
    717         { "CD", 0x4 },
    718     },
     794        .num_items = 4,
     795        .items = {
     796                { "Mic", 0x0 },
     797                { "Front Mic", 0x1 },
     798                { "Line", 0x2 },
     799                { "CD", 0x4 },
     800        },
    719801};
    720802
    721803/* fixed 8-channels */
    722804static struct hda_channel_mode alc880_sixstack_modes[1] = {
    723     { 8, NULL },
     805        { 8, NULL },
    724806};
    725807
    726808static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
    727     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    728     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    729     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    730     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    731     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    732     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    733     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    734     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    735     HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    736     HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    737     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    738     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    739     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    740     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    741     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    742     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    743     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    744     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    745     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    746     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    747     {
    748         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    749         .name = "Channel Mode",
    750         .info = alc_ch_mode_info,
    751         .get = alc_ch_mode_get,
    752         .put = alc_ch_mode_put,
    753     },
    754     {0} /* end */
     809        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     810        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     811        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     812        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     813        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     814        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     815        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     816        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     817        HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     818        HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
     819        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     820        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     821        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     822        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     823        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     824        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     825        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     826        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     827        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     828        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     829        {
     830                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     831                .name = "Channel Mode",
     832                .info = alc_ch_mode_info,
     833                .get = alc_ch_mode_get,
     834                .put = alc_ch_mode_put,
     835        },
     836        {0} /* end */
    755837};
    756838
     
    767849 * The system also has a pair of internal speakers, and a headphone jack.
    768850 * These are both connected to Line2 on the codec, hence to DAC 02.
    769  *
     851 * 
    770852 * There is a variable resistor to control the speaker or headphone
    771853 * volume. This is a hardware-only device without a software API.
     
    782864
    783865static hda_nid_t alc880_w810_dac_nids[3] = {
    784     /* front, rear/surround, clfe */
    785     0x02, 0x03, 0x04
     866        /* front, rear/surround, clfe */
     867        0x02, 0x03, 0x04
    786868};
    787869
    788870/* fixed 6 channels */
    789871static struct hda_channel_mode alc880_w810_modes[1] = {
    790     { 6, NULL }
     872        { 6, NULL }
    791873};
    792874
    793875/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
    794876static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
    795     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    796     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    797     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    798     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    799     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    800     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    801     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    802     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    803     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    804     {0} /* end */
     877        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     878        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     879        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     880        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     881        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     882        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     883        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     884        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     885        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     886        {0} /* end */
    805887};
    806888
     
    810892 *
    811893 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
    812  * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
     894 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
     895 *                 Line = 0x1a
    813896 */
    814897
    815898static hda_nid_t alc880_z71v_dac_nids[1] = {
    816     0x02
     899        0x02
    817900};
    818901#define ALC880_Z71V_HP_DAC      0x03
     
    820903/* fixed 2 channels */
    821904static struct hda_channel_mode alc880_2_jack_modes[1] = {
    822     { 2, NULL }
     905        { 2, NULL }
    823906};
    824907
    825908static struct snd_kcontrol_new alc880_z71v_mixer[] = {
    826     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    827     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    828     HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    829     HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
    830     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    831     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    832     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    833     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    834     {0} /* end */
     909        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     910        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     911        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     912        HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
     913        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     914        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     915        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     916        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     917        {0} /* end */
    835918};
    836919
     
    845928
    846929static hda_nid_t alc880_f1734_dac_nids[1] = {
    847     0x03
     930        0x03
    848931};
    849932#define ALC880_F1734_HP_DAC     0x02
    850933
    851934static struct snd_kcontrol_new alc880_f1734_mixer[] = {
    852     HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    853     HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
    854     HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    855     HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
    856     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    857     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    858     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    859     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    860     {0} /* end */
     935        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     936        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
     937        HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     938        HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
     939        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     940        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     941        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     942        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     943        {0} /* end */
    861944};
    862945
     
    875958
    876959static struct snd_kcontrol_new alc880_asus_mixer[] = {
    877     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    878     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    879     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    880     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    881     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    882     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    883     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    884     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    885     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    886     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    887     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    888     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    889     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    890     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    891     {
    892         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    893         .name = "Channel Mode",
    894         .info = alc_ch_mode_info,
    895         .get = alc_ch_mode_get,
    896         .put = alc_ch_mode_put,
    897     },
    898     {0} /* end */
     960        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     961        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     962        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     963        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     964        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     965        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     966        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     967        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     968        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     969        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     970        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     971        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     972        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     973        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     974        {
     975                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     976                .name = "Channel Mode",
     977                .info = alc_ch_mode_info,
     978                .get = alc_ch_mode_get,
     979                .put = alc_ch_mode_put,
     980        },
     981        {0} /* end */
    899982};
    900983
     
    910993/* additional mixers to alc880_asus_mixer */
    911994static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
    912     HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
    913     HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
    914     {0} /* end */
     995        HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
     996        HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
     997        {0} /* end */
    915998};
    916999
    9171000/* additional mixers to alc880_asus_mixer */
    9181001static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
    919     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    920     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    921     {0} /* end */
     1002        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     1003        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     1004        {0} /* end */
    9221005};
    9231006
    9241007/* TCL S700 */
    9251008static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
    926     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    927     HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    928     HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
    929     HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
    930     HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
    931     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
    932     HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
    933     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    934     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    935     {
    936         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    937         /* The multiple "Capture Source" controls confuse alsamixer
    938          * So call somewhat different..
    939          * FIXME: the controls appear in the "playback" view!
    940          */
    941         /* .name = "Capture Source", */
    942         .name = "Input Source",
    943         .count = 1,
    944         .info = alc_mux_enum_info,
    945         .get = alc_mux_enum_get,
    946         .put = alc_mux_enum_put,
    947     },
    948     {0} /* end */
     1009        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     1010        HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     1011        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     1012        HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
     1013        HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
     1014        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
     1015        HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
     1016        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     1017        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     1018        {
     1019                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1020                /* The multiple "Capture Source" controls confuse alsamixer
     1021                 * So call somewhat different..
     1022                 * FIXME: the controls appear in the "playback" view!
     1023                 */
     1024                /* .name = "Capture Source", */
     1025                .name = "Input Source",
     1026                .count = 1,
     1027                .info = alc_mux_enum_info,
     1028                .get = alc_mux_enum_get,
     1029                .put = alc_mux_enum_put,
     1030        },
     1031        {0} /* end */
     1032};
     1033
     1034/* Uniwill */
     1035static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
     1036        HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     1037        HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
     1038        HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     1039        HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
     1040        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     1041        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     1042        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     1043        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     1044        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     1045        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     1046        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     1047        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     1048        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     1049        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     1050        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     1051        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     1052        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     1053        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     1054        {
     1055                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1056                .name = "Channel Mode",
     1057                .info = alc_ch_mode_info,
     1058                .get = alc_ch_mode_get,
     1059                .put = alc_ch_mode_put,
     1060        },
     1061        {0} /* end */
     1062};
     1063
     1064static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
     1065        HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     1066        HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
     1067        HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     1068        HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
     1069        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     1070        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     1071        {0} /* end */
    9491072};
    9501073
     
    9541077static int alc_build_controls(struct hda_codec *codec)
    9551078{
    956     struct alc_spec *spec = codec->spec;
    957     int err;
    958     int i;
    959 
    960     for (i = 0; i < spec->num_mixers; i++) {
    961         err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
    962         if (err < 0)
    963             return err;
    964     }
    965 
    966     if (spec->multiout.dig_out_nid) {
    967         err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
    968         if (err < 0)
    969             return err;
    970     }
    971     if (spec->dig_in_nid) {
    972         err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
    973         if (err < 0)
    974             return err;
    975     }
    976     return 0;
     1079        struct alc_spec *spec = codec->spec;
     1080        int err;
     1081        int i;
     1082
     1083        for (i = 0; i < spec->num_mixers; i++) {
     1084                err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
     1085                if (err < 0)
     1086                        return err;
     1087        }
     1088
     1089        if (spec->multiout.dig_out_nid) {
     1090                err = snd_hda_create_spdif_out_ctls(codec,
     1091                                                    spec->multiout.dig_out_nid);
     1092                if (err < 0)
     1093                        return err;
     1094        }
     1095        if (spec->dig_in_nid) {
     1096                err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
     1097                if (err < 0)
     1098                        return err;
     1099        }
     1100        return 0;
    9771101}
    9781102
     
    9861110 */
    9871111static struct hda_verb alc880_volume_init_verbs[] = {
    988     /*
    989     * Unmute ADC0-2 and set the default input to mic-in
    990     */
    991     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    992     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    993     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    994     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    995     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    996     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    997 
    998     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    999     * mixer widget
    1000      * Note: PASD motherboards uses the Line In 2 as the input for front panel
    1001      * mic (mic 2)
    1002     */
    1003     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    1004     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1005     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1006     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    1007     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    1008     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    1009 
    1010     /*
    1011     * Set up output mixers (0x0c - 0x0f)
    1012     */
    1013     /* set vol=0 to output mixers */
    1014     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1015     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1016     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1017     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1018     /* set up input amps for analog loopback */
    1019     /* Amp Indices: DAC = 0, mixer = 1 */
    1020     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    1021     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    1022     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    1023     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    1024     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    1025     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    1026     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    1027     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    1028 
    1029     {0}
     1112        /*
     1113        * Unmute ADC0-2 and set the default input to mic-in
     1114        */
     1115        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     1116        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1117        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     1118        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1119        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     1120        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1121
     1122        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     1123        * mixer widget
     1124         * Note: PASD motherboards uses the Line In 2 as the input for front
     1125         * panel mic (mic 2)
     1126        */
     1127        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     1128        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1129        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     1130        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     1131        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     1132        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     1133
     1134        /*
     1135        * Set up output mixers (0x0c - 0x0f)
     1136        */
     1137        /* set vol=0 to output mixers */
     1138        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     1139        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     1140        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     1141        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     1142        /* set up input amps for analog loopback */
     1143        /* Amp Indices: DAC = 0, mixer = 1 */
     1144        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     1145        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     1146        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     1147        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     1148        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     1149        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     1150        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     1151        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     1152
     1153        {0}
    10301154};
    10311155
     
    10351159 */
    10361160static struct hda_verb alc880_pin_3stack_init_verbs[] = {
    1037     /*
    1038     * preset connection lists of input pins
    1039     * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
    1040     */
    1041     {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
    1042     {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
    1043     {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
    1044 
    1045     /*
    1046     * Set pin mode and muting
    1047     */
    1048     /* set front pin widgets 0x14 for output */
    1049     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1050     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1051     /* Mic1 (rear panel) pin widget for input and vref at 80% */
    1052     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1053     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1054     /* Mic2 (as headphone out) for HP output */
    1055     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1056     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1057     /* Line In pin widget for input */
    1058     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1059     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1060     /* Line2 (as front mic) pin widget for input and vref at 80% */
    1061     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1062     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1063     /* CD pin widget for input */
    1064     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1065 
    1066     {0}
     1161        /*
     1162        * preset connection lists of input pins
     1163        * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
     1164        */
     1165        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
     1166        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     1167        {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
     1168
     1169        /*
     1170        * Set pin mode and muting
     1171        */
     1172        /* set front pin widgets 0x14 for output */
     1173        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1174        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1175        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     1176        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1177        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1178        /* Mic2 (as headphone out) for HP output */
     1179        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1180        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1181        /* Line In pin widget for input */
     1182        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1183        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1184        /* Line2 (as front mic) pin widget for input and vref at 80% */
     1185        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1186        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1187        /* CD pin widget for input */
     1188        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1189
     1190        {0}
    10671191};
    10681192
     
    10731197 */
    10741198static struct hda_verb alc880_pin_5stack_init_verbs[] = {
    1075     /*
    1076     * preset connection lists of input pins
    1077     * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
    1078     */
    1079     {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
    1080     {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
    1081 
    1082     /*
    1083     * Set pin mode and muting
    1084     */
    1085     /* set pin widgets 0x14-0x17 for output */
    1086     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1087     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1088     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1089     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1090     /* unmute pins for output (no gain on this amp) */
    1091     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1092     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1093     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1094     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1095 
    1096     /* Mic1 (rear panel) pin widget for input and vref at 80% */
    1097     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1098     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1099     /* Mic2 (as headphone out) for HP output */
    1100     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1101     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1102     /* Line In pin widget for input */
    1103     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1104     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1105     /* Line2 (as front mic) pin widget for input and vref at 80% */
    1106     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1107     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1108     /* CD pin widget for input */
    1109     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1110 
    1111     {0}
     1199        /*
     1200        * preset connection lists of input pins
     1201        * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
     1202        */
     1203        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     1204        {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
     1205
     1206        /*
     1207        * Set pin mode and muting
     1208        */
     1209        /* set pin widgets 0x14-0x17 for output */
     1210        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1211        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1212        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1213        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1214        /* unmute pins for output (no gain on this amp) */
     1215        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1216        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1217        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1218        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1219
     1220        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     1221        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1222        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1223        /* Mic2 (as headphone out) for HP output */
     1224        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1225        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1226        /* Line In pin widget for input */
     1227        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1228        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1229        /* Line2 (as front mic) pin widget for input and vref at 80% */
     1230        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1231        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1232        /* CD pin widget for input */
     1233        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1234
     1235        {0}
    11121236};
    11131237
     
    11171241 */
    11181242static struct hda_verb alc880_pin_w810_init_verbs[] = {
    1119     /* hphone/speaker input selector: front DAC */
    1120     {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
    1121 
    1122     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1123     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1124     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1125     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1126     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1127     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1128 
    1129     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1130     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1131 
    1132     {0}
     1243        /* hphone/speaker input selector: front DAC */
     1244        {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
     1245
     1246        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1247        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1248        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1249        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1250        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1251        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1252
     1253        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1254        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1255
     1256        {0}
    11331257};
    11341258
     
    11381262 */
    11391263static struct hda_verb alc880_pin_z71v_init_verbs[] = {
    1140     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1141     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1142     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1143     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1144 
    1145     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1146     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1147     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1148     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1149 
    1150     {0}
     1264        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1265        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1266        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1267        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1268
     1269        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1270        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1271        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1272        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1273
     1274        {0}
    11511275};
    11521276
    11531277/*
    11541278 * 6-stack pin configuration:
    1155  * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
    1156  * line = 0x1a, HP = 0x1b
     1279 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
     1280 * f-mic = 0x19, line = 0x1a, HP = 0x1b
    11571281 */
    11581282static struct hda_verb alc880_pin_6stack_init_verbs[] = {
    1159     {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
    1160 
    1161     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1162     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1163     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1164     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1165     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1166     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1167     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1168     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1169 
    1170     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1171     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1172     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1173     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1174     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1175     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1176     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1177     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1178     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1179 
    1180     {0}
    1181 };
     1283        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     1284
     1285        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1286        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1287        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1288        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1289        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1290        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1291        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1292        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1293
     1294        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1295        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1296        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1297        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1298        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1299        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1300        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1301        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1302        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1303       
     1304        {0}
     1305};
     1306
     1307/*
     1308 * Uniwill pin configuration:
     1309 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
     1310 * line = 0x1a
     1311 */
     1312static struct hda_verb alc880_uniwill_init_verbs[] = {
     1313        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     1314
     1315        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1316        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1317        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1318        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1319        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1320        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1321        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1322        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1323        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     1324        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     1325        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     1326        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     1327        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     1328        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     1329
     1330        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1331        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1332        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1333        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1334        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1335        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1336        /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
     1337        /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
     1338        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1339
     1340        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     1341        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
     1342
     1343        {0}
     1344};
     1345
     1346/*
     1347* Uniwill P53
     1348* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
     1349 */
     1350static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
     1351        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     1352
     1353        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1354        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1355        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1356        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1357        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1358        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1359        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     1360        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     1361        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     1362        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     1363        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     1364        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     1365
     1366        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1367        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1368        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1369        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1370        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1371        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1372
     1373        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     1374        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
     1375
     1376        {0}
     1377};
     1378
     1379/* toggle speaker-output according to the hp-jack state */
     1380static void alc880_uniwill_automute(struct hda_codec *codec)
     1381{
     1382        unsigned int present;
     1383
     1384        present = snd_hda_codec_read(codec, 0x14, 0,
     1385                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1386        snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
     1387                                 0x80, present ? 0x80 : 0);
     1388        snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
     1389                                 0x80, present ? 0x80 : 0);
     1390        snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
     1391                                 0x80, present ? 0x80 : 0);
     1392        snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
     1393                                 0x80, present ? 0x80 : 0);
     1394
     1395        present = snd_hda_codec_read(codec, 0x18, 0,
     1396                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1397        snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     1398                            0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
     1399}
     1400
     1401static void alc880_uniwill_unsol_event(struct hda_codec *codec,
     1402                                       unsigned int res)
     1403{
     1404        /* Looks like the unsol event is incompatible with the standard
     1405         * definition.  4bit tag is placed at 28 bit!
     1406         */
     1407        if ((res >> 28) == ALC880_HP_EVENT ||
     1408            (res >> 28) == ALC880_MIC_EVENT)
     1409                alc880_uniwill_automute(codec);
     1410}
     1411
     1412static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
     1413{
     1414        unsigned int present;
     1415
     1416        present = snd_hda_codec_read(codec, 0x14, 0,
     1417                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1418
     1419        snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
     1420                                 0x80, present ? 0x80 : 0);
     1421        snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
     1422                                 0x80, present ? 0x80 : 0);
     1423}
     1424
     1425static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
     1426{
     1427        unsigned int present;
     1428       
     1429        present = snd_hda_codec_read(codec, 0x21, 0,
     1430                                     AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
     1431
     1432        snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
     1433                                 0x7f, present);
     1434        snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
     1435                                 0x7f,  present);
     1436
     1437        snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
     1438                                 0x7f,  present);
     1439        snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
     1440                                 0x7f, present);
     1441
     1442}
     1443static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
     1444                                           unsigned int res)
     1445{
     1446        /* Looks like the unsol event is incompatible with the standard
     1447         * definition.  4bit tag is placed at 28 bit!
     1448         */
     1449        if ((res >> 28) == ALC880_HP_EVENT)
     1450                alc880_uniwill_p53_hp_automute(codec);
     1451        if ((res >> 28) == ALC880_DCVOL_EVENT)
     1452                alc880_uniwill_p53_dcvol_automute(codec);
     1453}
    11821454
    11831455/* FIXME! */
     
    11871459 */
    11881460static struct hda_verb alc880_pin_f1734_init_verbs[] = {
    1189     {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
    1190     {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
    1191     {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
    1192     {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
    1193 
    1194     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1195     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1196     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1197     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1198 
    1199     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1200     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1201     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1202     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1203     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1204     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1205     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1206     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1207     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1208 
    1209     {0}
     1461        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
     1462        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
     1463        {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
     1464        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
     1465
     1466        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1467        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1468        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1469        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1470
     1471        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1472        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1473        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1474        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1475        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1476        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1477        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1478        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1479        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1480
     1481        {0}
    12101482};
    12111483
     
    12161488 */
    12171489static struct hda_verb alc880_pin_asus_init_verbs[] = {
    1218     {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
    1219     {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
    1220     {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
    1221     {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
    1222 
    1223     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1224     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1225     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1226     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1227     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1228     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1229     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1230     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1231 
    1232     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1233     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1234     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1235     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1236     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1237     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1238     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1239     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1240     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1241 
    1242     {0}
     1490        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
     1491        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
     1492        {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
     1493        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
     1494
     1495        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1496        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1497        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1498        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1499        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1500        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1501        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1502        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1503
     1504        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1505        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1506        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1507        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1508        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1509        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     1510        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1511        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1512        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1513       
     1514        {0}
    12431515};
    12441516
    12451517/* Enable GPIO mask and set output */
    12461518static struct hda_verb alc880_gpio1_init_verbs[] = {
    1247     {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
    1248     {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
    1249     {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
    1250 
    1251     {0}
     1519        {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
     1520        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
     1521        {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
     1522
     1523        {0}
    12521524};
    12531525
    12541526/* Enable GPIO mask and set output */
    12551527static struct hda_verb alc880_gpio2_init_verbs[] = {
    1256     {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
    1257     {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
    1258     {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
    1259 
    1260     {0}
     1528        {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
     1529        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
     1530        {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
     1531
     1532        {0}
    12611533};
    12621534
    12631535/* Clevo m520g init */
    12641536static struct hda_verb alc880_pin_clevo_init_verbs[] = {
    1265     /* headphone output */
    1266     {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
    1267     /* line-out */
    1268     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1269     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1270     /* Line-in */
    1271     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1272     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1273     /* CD */
    1274     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1275     {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1276     /* Mic1 (rear panel) */
    1277     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1278     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1279     /* Mic2 (front panel) */
    1280     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1281     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1282     /* headphone */
    1283     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1284     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1285     /* change to EAPD mode */
    1286     {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
    1287     {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
    1288 
    1289     {0}
     1537        /* headphone output */
     1538        {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
     1539        /* line-out */
     1540        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1541        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1542        /* Line-in */
     1543        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1544        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1545        /* CD */
     1546        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1547        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1548        /* Mic1 (rear panel) */
     1549        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1550        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1551        /* Mic2 (front panel) */
     1552        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1553        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1554        /* headphone */
     1555        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1556        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1557        /* change to EAPD mode */
     1558        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     1559        {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
     1560
     1561        {0}
    12901562};
    12911563
    12921564static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
    1293     /* Headphone output */
    1294     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1295     /* Front output*/
    1296     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1297     {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
    1298 
    1299     /* Line In pin widget for input */
    1300     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1301     /* CD pin widget for input */
    1302     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1303     /* Mic1 (rear panel) pin widget for input and vref at 80% */
    1304     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1305 
    1306     /* change to EAPD mode */
    1307     {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
    1308     {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
    1309 
    1310     {0}
     1565        /* change to EAPD mode */
     1566        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     1567        {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
     1568
     1569        /* Headphone output */
     1570        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1571        /* Front output*/
     1572        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1573        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
     1574
     1575        /* Line In pin widget for input */
     1576        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1577        /* CD pin widget for input */
     1578        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1579        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     1580        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1581
     1582        /* change to EAPD mode */
     1583        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     1584        {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
     1585
     1586        {0}
    13111587};
    13121588
     
    13251601/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
    13261602static hda_nid_t alc880_lg_dac_nids[3] = {
    1327     0x05, 0x02, 0x03
     1603        0x05, 0x02, 0x03
    13281604};
    13291605
    13301606/* seems analog CD is not working */
    13311607static struct hda_input_mux alc880_lg_capture_source = {
    1332     .num_items = 3,
    1333     .items = {
    1334         { "Mic", 0x1 },
    1335         { "Line", 0x5 },
    1336         { "Internal Mic", 0x6 },
    1337     },
     1608        .num_items = 3,
     1609        .items = {
     1610                { "Mic", 0x1 },
     1611                { "Line", 0x5 },
     1612                { "Internal Mic", 0x6 },
     1613        },
    13381614};
    13391615
    13401616/* 2,4,6 channel modes */
    13411617static struct hda_verb alc880_lg_ch2_init[] = {
    1342     /* set line-in and mic-in to input */
    1343     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
    1344     { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    1345     {0}
     1618        /* set line-in and mic-in to input */
     1619        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     1620        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     1621        {0}
    13461622};
    13471623
    13481624static struct hda_verb alc880_lg_ch4_init[] = {
    1349     /* set line-in to out and mic-in to input */
    1350     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
    1351     { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    1352     {0}
     1625        /* set line-in to out and mic-in to input */
     1626        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
     1627        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     1628        {0}
    13531629};
    13541630
    13551631static struct hda_verb alc880_lg_ch6_init[] = {
    1356     /* set line-in and mic-in to output */
    1357     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
    1358     { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
    1359     {0}
     1632        /* set line-in and mic-in to output */
     1633        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
     1634        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
     1635        {0}
    13601636};
    13611637
    13621638static struct hda_channel_mode alc880_lg_ch_modes[3] = {
    1363     { 2, alc880_lg_ch2_init },
    1364     { 4, alc880_lg_ch4_init },
    1365     { 6, alc880_lg_ch6_init },
     1639        { 2, alc880_lg_ch2_init },
     1640        { 4, alc880_lg_ch4_init },
     1641        { 6, alc880_lg_ch6_init },
    13661642};
    13671643
    13681644static struct snd_kcontrol_new alc880_lg_mixer[] = {
    1369     /* FIXME: it's not really "master" but front channels */
    1370     HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    1371     HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
    1372     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    1373     HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
    1374     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
    1375     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
    1376     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
    1377     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
    1378     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    1379     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    1380     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
    1381     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
    1382     HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
    1383     HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
    1384     {
    1385         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1386         .name = "Channel Mode",
    1387         .info = alc_ch_mode_info,
    1388         .get = alc_ch_mode_get,
    1389         .put = alc_ch_mode_put,
    1390     },
    1391     {0} /* end */
     1645        /* FIXME: it's not really "master" but front channels */
     1646        HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     1647        HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
     1648        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     1649        HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
     1650        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
     1651        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
     1652        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
     1653        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
     1654        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     1655        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     1656        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
     1657        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
     1658        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
     1659        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
     1660        {
     1661                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1662                .name = "Channel Mode",
     1663                .info = alc_ch_mode_info,
     1664                .get = alc_ch_mode_get,
     1665                .put = alc_ch_mode_put,
     1666        },
     1667        {0} /* end */
    13921668};
    13931669
    13941670static struct hda_verb alc880_lg_init_verbs[] = {
    1395     /* set capture source to mic-in */
    1396     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1397     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1398     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1399     /* mute all amp mixer inputs */
    1400     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
    1401     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
    1402     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
    1403     /* line-in to input */
    1404     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1405     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1406     /* built-in mic */
    1407     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1408     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1409     /* speaker-out */
    1410     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1411     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1412     /* mic-in to input */
    1413     {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
    1414     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1415     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1416     /* HP-out */
    1417     {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
    1418     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1419     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1420     /* jack sense */
    1421     {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
    1422     {0}
     1671        /* set capture source to mic-in */
     1672        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     1673        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     1674        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     1675        /* mute all amp mixer inputs */
     1676        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
     1677        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
     1678        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
     1679        /* line-in to input */
     1680        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1681        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1682        /* built-in mic */
     1683        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1684        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1685        /* speaker-out */
     1686        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1687        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1688        /* mic-in to input */
     1689        {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
     1690        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1691        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1692        /* HP-out */
     1693        {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
     1694        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1695        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1696        /* jack sense */
     1697        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
     1698        {0}
    14231699};
    14241700
     
    14261702static void alc880_lg_automute(struct hda_codec *codec)
    14271703{
    1428     unsigned int present;
    1429 
    1430     present = snd_hda_codec_read(codec, 0x1b, 0,
    1431                                  AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1432     snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
    1433                             0x80, present ? 0x80 : 0);
    1434     snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
    1435                             0x80, present ? 0x80 : 0);
     1704        unsigned int present;
     1705
     1706        present = snd_hda_codec_read(codec, 0x1b, 0,
     1707                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1708        snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
     1709                                0x80, present ? 0x80 : 0);
     1710        snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
     1711                                0x80, present ? 0x80 : 0);
    14361712}
    14371713
    14381714static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
    14391715{
    1440     /* Looks like the unsol event is incompatible with the standard
    1441     * definition.  4bit tag is placed at 28 bit!
    1442     */
    1443     if ((res >> 28) == 0x01)
    1444         alc880_lg_automute(codec);
     1716        /* Looks like the unsol event is incompatible with the standard
     1717        * definition.  4bit tag is placed at 28 bit!
     1718        */
     1719        if ((res >> 28) == 0x01)
     1720                alc880_lg_automute(codec);
    14451721}
    14461722
     
    14581734/* seems analog CD is not working */
    14591735static struct hda_input_mux alc880_lg_lw_capture_source = {
    1460     .num_items = 2,
    1461     .items = {
    1462         { "Mic", 0x0 },
    1463         { "Internal Mic", 0x1 },
    1464     },
     1736        .num_items = 2,
     1737        .items = {
     1738                { "Mic", 0x0 },
     1739                { "Internal Mic", 0x1 },
     1740        },
    14651741};
    14661742
    14671743static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
    1468     HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    1469     HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
    1470     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    1471     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    1472     HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
    1473     HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    1474     {0} /* end */
     1744        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     1745        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
     1746        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     1747        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     1748        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
     1749        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
     1750        {0} /* end */
    14751751};
    14761752
    14771753static struct hda_verb alc880_lg_lw_init_verbs[] = {
    1478     /* set capture source to mic-in */
    1479     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1480     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1481     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1482     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
    1483     /* speaker-out */
    1484     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1485     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1486     /* HP-out */
    1487     {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
    1488     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    1489     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1490     /* mic-in to input */
    1491     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1492     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1493     /* built-in mic */
    1494     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    1495     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1496     /* jack sense */
    1497     {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
    1498     {0}
     1754        /* set capture source to mic-in */
     1755        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1756        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1757        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1758        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
     1759        /* speaker-out */
     1760        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1761        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1762        /* HP-out */
     1763        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
     1764        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1765        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1766        /* mic-in to input */
     1767        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1768        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1769        /* built-in mic */
     1770        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1771        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1772        /* jack sense */
     1773        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
     1774        {0}
    14991775};
    15001776
     
    15021778static void alc880_lg_lw_automute(struct hda_codec *codec)
    15031779{
    1504     unsigned int present;
    1505 
    1506     present = snd_hda_codec_read(codec, 0x1b, 0,
    1507                                  AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1508     snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
    1509                             0x80, present ? 0x80 : 0);
    1510     snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
    1511                             0x80, present ? 0x80 : 0);
     1780        unsigned int present;
     1781
     1782        present = snd_hda_codec_read(codec, 0x1b, 0,
     1783                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1784        snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
     1785                                0x80, present ? 0x80 : 0);
     1786        snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
     1787                                0x80, present ? 0x80 : 0);
    15121788}
    15131789
    15141790static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
    15151791{
    1516     /* Looks like the unsol event is incompatible with the standard
    1517     * definition.  4bit tag is placed at 28 bit!
    1518     */
    1519     if ((res >> 28) == 0x01)
    1520         alc880_lg_lw_automute(codec);
     1792        /* Looks like the unsol event is incompatible with the standard
     1793        * definition.  4bit tag is placed at 28 bit!
     1794        */
     1795        if ((res >> 28) == 0x01)
     1796                alc880_lg_lw_automute(codec);
    15211797}
    15221798
     
    15271803static int alc_init(struct hda_codec *codec)
    15281804{
    1529     struct alc_spec *spec = codec->spec;
    1530     unsigned int i;
    1531 
    1532     for (i = 0; i < spec->num_init_verbs; i++)
    1533         snd_hda_sequence_write(codec, spec->init_verbs[i]);
    1534     if (spec->init_hook)
    1535         spec->init_hook(codec);
    1536     return 0;
     1805        struct alc_spec *spec = codec->spec;
     1806        unsigned int i;
     1807
     1808        for (i = 0; i < spec->num_init_verbs; i++)
     1809                snd_hda_sequence_write(codec, spec->init_verbs[i]);
     1810
     1811        if (spec->init_hook)
     1812                spec->init_hook(codec);
     1813
     1814        return 0;
    15371815}
    15381816
    15391817static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
    15401818{
    1541     struct alc_spec *spec = codec->spec;
    1542 
    1543     if (spec->unsol_event)
    1544         spec->unsol_event(codec, res);
     1819        struct alc_spec *spec = codec->spec;
     1820
     1821        if (spec->unsol_event)
     1822                spec->unsol_event(codec, res);
    15451823}
    15461824
     
    15511829static int alc_resume(struct hda_codec *codec)
    15521830{
    1553     struct alc_spec *spec = codec->spec;
    1554     int i;
    1555 
    1556     alc_init(codec);
    1557     for (i = 0; i < spec->num_mixers; i++)
    1558         snd_hda_resume_ctls(codec, spec->mixers[i]);
    1559     if (spec->multiout.dig_out_nid)
    1560         snd_hda_resume_spdif_out(codec);
    1561     if (spec->dig_in_nid)
    1562         snd_hda_resume_spdif_in(codec);
    1563 
    1564     return 0;
     1831        struct alc_spec *spec = codec->spec;
     1832        int i;
     1833
     1834        alc_init(codec);
     1835        for (i = 0; i < spec->num_mixers; i++)
     1836                snd_hda_resume_ctls(codec, spec->mixers[i]);
     1837        if (spec->multiout.dig_out_nid)
     1838                snd_hda_resume_spdif_out(codec);
     1839        if (spec->dig_in_nid)
     1840                snd_hda_resume_spdif_in(codec);
     1841
     1842        return 0;
    15651843}
    15661844#endif
     
    15701848 */
    15711849static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
    1572                                     struct hda_codec *codec,
    1573                                     struct snd_pcm_substream *substream)
    1574 {
    1575     struct alc_spec *spec = codec->spec;
    1576     return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     1850                                    struct hda_codec *codec,
     1851                                    struct snd_pcm_substream *substream)
     1852{
     1853        struct alc_spec *spec = codec->spec;
     1854        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
    15771855}
    15781856
    15791857static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
    1580                                        struct hda_codec *codec,
    1581                                        unsigned int stream_tag,
    1582                                        unsigned int format,
    1583                                        struct snd_pcm_substream *substream)
    1584 {
    1585     struct alc_spec *spec = codec->spec;
    1586     return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
    1587                                             format, substream);
     1858                                       struct hda_codec *codec,
     1859                                       unsigned int stream_tag,
     1860                                       unsigned int format,
     1861                                       struct snd_pcm_substream *substream)
     1862{
     1863        struct alc_spec *spec = codec->spec;
     1864        return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
     1865                                                stream_tag, format, substream);
    15881866}
    15891867
    15901868static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
    1591                                        struct hda_codec *codec,
    1592                                        struct snd_pcm_substream *substream)
    1593 {
    1594     struct alc_spec *spec = codec->spec;
    1595     return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
     1869                                       struct hda_codec *codec,
     1870                                       struct snd_pcm_substream *substream)
     1871{
     1872        struct alc_spec *spec = codec->spec;
     1873        return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
    15961874}
    15971875
     
    16001878 */
    16011879static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
    1602                                         struct hda_codec *codec,
    1603                                         struct snd_pcm_substream *substream)
    1604 {
    1605     struct alc_spec *spec = codec->spec;
    1606     return snd_hda_multi_out_dig_open(codec, &spec->multiout);
     1880                                        struct hda_codec *codec,
     1881                                        struct snd_pcm_substream *substream)
     1882{
     1883        struct alc_spec *spec = codec->spec;
     1884        return snd_hda_multi_out_dig_open(codec, &spec->multiout);
    16071885}
    16081886
    16091887static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
    1610                                         struct hda_codec *codec,
    1611                                         struct snd_pcm_substream *substream)
    1612 {
    1613     struct alc_spec *spec = codec->spec;
    1614     return snd_hda_multi_out_dig_close(codec, &spec->multiout);
     1888                                        struct hda_codec *codec,
     1889                                        struct snd_pcm_substream *substream)
     1890{
     1891        struct alc_spec *spec = codec->spec;
     1892        return snd_hda_multi_out_dig_close(codec, &spec->multiout);
    16151893}
    16161894
     
    16191897 */
    16201898static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
    1621                                       struct hda_codec *codec,
    1622                                       unsigned int stream_tag,
    1623                                       unsigned int format,
    1624                                       struct snd_pcm_substream *substream)
    1625 {
    1626     struct alc_spec *spec = codec->spec;
    1627 
    1628     snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
    1629                                stream_tag, 0, format);
    1630     return 0;
     1899                                      struct hda_codec *codec,
     1900                                      unsigned int stream_tag,
     1901                                      unsigned int format,
     1902                                      struct snd_pcm_substream *substream)
     1903{
     1904        struct alc_spec *spec = codec->spec;
     1905
     1906        snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
     1907                                   stream_tag, 0, format);
     1908        return 0;
    16311909}
    16321910
    16331911static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
    1634                                       struct hda_codec *codec,
    1635                                       struct snd_pcm_substream *substream)
    1636 {
    1637     struct alc_spec *spec = codec->spec;
    1638 
    1639     snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
    1640     return 0;
     1912                                      struct hda_codec *codec,
     1913                                      struct snd_pcm_substream *substream)
     1914{
     1915        struct alc_spec *spec = codec->spec;
     1916
     1917        snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
     1918                                   0, 0, 0);
     1919        return 0;
    16411920}
    16421921
     
    16451924 */
    16461925static struct hda_pcm_stream alc880_pcm_analog_playback = {
    1647     .substreams = 1,
    1648     .channels_min = 2,
    1649     .channels_max = 8,
    1650     /* NID is set in alc_build_pcms */
    1651     .ops = {
    1652         .open = alc880_playback_pcm_open,
    1653         .prepare = alc880_playback_pcm_prepare,
    1654         .cleanup = alc880_playback_pcm_cleanup
    1655     },
     1926        .substreams = 1,
     1927        .channels_min = 2,
     1928        .channels_max = 8,
     1929        /* NID is set in alc_build_pcms */
     1930        .ops = {
     1931                .open = alc880_playback_pcm_open,
     1932                .prepare = alc880_playback_pcm_prepare,
     1933                .cleanup = alc880_playback_pcm_cleanup
     1934        },
    16561935};
    16571936
    16581937static struct hda_pcm_stream alc880_pcm_analog_capture = {
    1659     .substreams = 2,
    1660     .channels_min = 2,
    1661     .channels_max = 2,
    1662     /* NID is set in alc_build_pcms */
    1663     .ops = {
    1664         .prepare = alc880_capture_pcm_prepare,
    1665         .cleanup = alc880_capture_pcm_cleanup
    1666     },
     1938        .substreams = 2,
     1939        .channels_min = 2,
     1940        .channels_max = 2,
     1941        /* NID is set in alc_build_pcms */
     1942        .ops = {
     1943                .prepare = alc880_capture_pcm_prepare,
     1944                .cleanup = alc880_capture_pcm_cleanup
     1945        },
    16671946};
    16681947
    16691948static struct hda_pcm_stream alc880_pcm_digital_playback = {
    1670     .substreams = 1,
    1671     .channels_min = 2,
    1672     .channels_max = 2,
    1673     /* NID is set in alc_build_pcms */
    1674     .ops = {
    1675         .open = alc880_dig_playback_pcm_open,
    1676         .close = alc880_dig_playback_pcm_close
    1677     },
     1949        .substreams = 1,
     1950        .channels_min = 2,
     1951        .channels_max = 2,
     1952        /* NID is set in alc_build_pcms */
     1953        .ops = {
     1954                .open = alc880_dig_playback_pcm_open,
     1955                .close = alc880_dig_playback_pcm_close
     1956        },
    16781957};
    16791958
    16801959static struct hda_pcm_stream alc880_pcm_digital_capture = {
    1681     .substreams = 1,
    1682     .channels_min = 2,
    1683     .channels_max = 2,
    1684     /* NID is set in alc_build_pcms */
     1960        .substreams = 1,
     1961        .channels_min = 2,
     1962        .channels_max = 2,
     1963        /* NID is set in alc_build_pcms */
    16851964};
    16861965
    16871966/* Used by alc_build_pcms to flag that a PCM has no playback stream */
    16881967static struct hda_pcm_stream alc_pcm_null_playback = {
    1689     .substreams = 0,
    1690     .channels_min = 0,
    1691     .channels_max = 0,
     1968        .substreams = 0,
     1969        .channels_min = 0,
     1970        .channels_max = 0,
    16921971};
    16931972
    16941973static int alc_build_pcms(struct hda_codec *codec)
    16951974{
    1696     struct alc_spec *spec = codec->spec;
    1697     struct hda_pcm *info = spec->pcm_rec;
    1698     int i;
    1699 
    1700     codec->num_pcms = 1;
    1701     codec->pcm_info = info;
    1702 
    1703     info->name = spec->stream_name_analog;
    1704     if (spec->stream_analog_playback) {
    1705         snd_assert(spec->multiout.dac_nids, return -EINVAL);
    1706         info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
    1707         info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
    1708     }
    1709     if (spec->stream_analog_capture) {
    1710         snd_assert(spec->adc_nids, return -EINVAL);
    1711         info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
    1712         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
    1713     }
    1714 
    1715     if (spec->channel_mode) {
    1716         info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
    1717         for (i = 0; i < spec->num_channel_mode; i++) {
    1718             if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
    1719                 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
    1720             }
    1721         }
    1722     }
    1723 
    1724     /* If the use of more than one ADC is requested for the current
    1725      * model, configure a second analog capture-only PCM.
    1726      */
    1727     if (spec->num_adc_nids > 1) {
    1728         codec->num_pcms++;
    1729         info++;
    1730         info->name = spec->stream_name_analog;
    1731         /* No playback stream for second PCM */
    1732         info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
    1733         info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
    1734         if (spec->stream_analog_capture) {
    1735             snd_assert(spec->adc_nids, return -EINVAL);
    1736             info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
    1737             info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
    1738         }
    1739     }
    1740 
    1741     if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
    1742         codec->num_pcms++;
    1743         info++;
    1744         info->name = spec->stream_name_digital;
    1745         if (spec->multiout.dig_out_nid &&
    1746             spec->stream_digital_playback) {
    1747             info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
    1748             info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
    1749         }
    1750         if (spec->dig_in_nid &&
    1751             spec->stream_digital_capture) {
    1752             info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
    1753             info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
    1754         }
    1755     }
    1756 
    1757     return 0;
     1975        struct alc_spec *spec = codec->spec;
     1976        struct hda_pcm *info = spec->pcm_rec;
     1977        int i;
     1978
     1979        codec->num_pcms = 1;
     1980        codec->pcm_info = info;
     1981
     1982        info->name = spec->stream_name_analog;
     1983        if (spec->stream_analog_playback) {
     1984                snd_assert(spec->multiout.dac_nids, return -EINVAL);
     1985                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
     1986                info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
     1987        }
     1988        if (spec->stream_analog_capture) {
     1989                snd_assert(spec->adc_nids, return -EINVAL);
     1990                info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
     1991                info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
     1992        }
     1993
     1994        if (spec->channel_mode) {
     1995                info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
     1996                for (i = 0; i < spec->num_channel_mode; i++) {
     1997                        if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
     1998                                info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
     1999                        }
     2000                }
     2001        }
     2002
     2003        /* SPDIF for stream index #1 */
     2004        if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
     2005                codec->num_pcms = 2;
     2006                info = spec->pcm_rec + 1;
     2007                info->name = spec->stream_name_digital;
     2008                if (spec->multiout.dig_out_nid &&
     2009                    spec->stream_digital_playback) {
     2010                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
     2011                        info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
     2012                }
     2013                if (spec->dig_in_nid &&
     2014                    spec->stream_digital_capture) {
     2015                        info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
     2016                        info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
     2017                }
     2018        }
     2019
     2020        /* If the use of more than one ADC is requested for the current
     2021         * model, configure a second analog capture-only PCM.
     2022         */
     2023        /* Additional Analaog capture for index #2 */
     2024        if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
     2025            spec->adc_nids) {
     2026                codec->num_pcms = 3;
     2027                info = spec->pcm_rec + 2;
     2028                info->name = spec->stream_name_analog;
     2029                /* No playback stream for second PCM */
     2030                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
     2031                info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
     2032                if (spec->stream_analog_capture) {
     2033                        info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
     2034                        info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
     2035                }
     2036        }
     2037
     2038        return 0;
    17582039}
    17592040
    17602041static void alc_free(struct hda_codec *codec)
    17612042{
    1762     struct alc_spec *spec = codec->spec;
    1763     unsigned int i;
    1764 
    1765     if (! spec)
    1766         return;
    1767 
    1768     if (spec->kctl_alloc) {
    1769         for (i = 0; i < spec->num_kctl_used; i++)
    1770             kfree(spec->kctl_alloc[i].name);
    1771         kfree(spec->kctl_alloc);
    1772     }
    1773     kfree(spec);
     2043        struct alc_spec *spec = codec->spec;
     2044        unsigned int i;
     2045
     2046        if (! spec)
     2047                return;
     2048
     2049        if (spec->kctl_alloc) {
     2050                for (i = 0; i < spec->num_kctl_used; i++)
     2051                        kfree(spec->kctl_alloc[i].name);
     2052                kfree(spec->kctl_alloc);
     2053        }
     2054        kfree(spec);
    17742055}
    17752056
     
    17772058 */
    17782059static struct hda_codec_ops alc_patch_ops = {
    1779     .build_controls = alc_build_controls,
    1780     .build_pcms = alc_build_pcms,
    1781     .init = alc_init,
    1782     .free = alc_free,
    1783     .unsol_event = alc_unsol_event,
     2060        .build_controls = alc_build_controls,
     2061        .build_pcms = alc_build_pcms,
     2062        .init = alc_init,
     2063        .free = alc_free,
     2064        .unsol_event = alc_unsol_event,
    17842065#ifdef CONFIG_PM
    1785     .resume = alc_resume,
     2066        .resume = alc_resume,
    17862067#endif
    17872068};
     
    17962077#ifdef CONFIG_SND_DEBUG
    17972078static hda_nid_t alc880_test_dac_nids[4] = {
    1798     0x02, 0x03, 0x04, 0x05
     2079        0x02, 0x03, 0x04, 0x05
    17992080};
    18002081
    18012082static struct hda_input_mux alc880_test_capture_source = {
    1802     .num_items = 7,
    1803     .items = {
    1804         { "In-1", 0x0 },
    1805         { "In-2", 0x1 },
    1806         { "In-3", 0x2 },
    1807         { "In-4", 0x3 },
    1808         { "CD", 0x4 },
    1809         { "Front", 0x5 },
    1810         { "Surround", 0x6 },
    1811     },
     2083        .num_items = 7,
     2084        .items = {
     2085                { "In-1", 0x0 },
     2086                { "In-2", 0x1 },
     2087                { "In-3", 0x2 },
     2088                { "In-4", 0x3 },
     2089                { "CD", 0x4 },
     2090                { "Front", 0x5 },
     2091                { "Surround", 0x6 },
     2092        },
    18122093};
    18132094
    18142095static struct hda_channel_mode alc880_test_modes[4] = {
    1815     { 2, NULL },
    1816     { 4, NULL },
    1817     { 6, NULL },
    1818     { 8, NULL },
    1819 };
    1820 
    1821 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    1822 {
    1823     static char *texts[] = {
    1824         "N/A", "Line Out", "HP Out",
    1825         "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
    1826     };
    1827     uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    1828     uinfo->count = 1;
    1829     uinfo->value.enumerated.items = 8;
    1830     if (uinfo->value.enumerated.item >= 8)
    1831         uinfo->value.enumerated.item = 7;
    1832     strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    1833     return 0;
    1834 }
    1835 
    1836 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1837 {
    1838     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1839     hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
    1840     unsigned int pin_ctl, item = 0;
    1841 
    1842     pin_ctl = snd_hda_codec_read(codec, nid, 0,
    1843                                  AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    1844     if (pin_ctl & AC_PINCTL_OUT_EN) {
    1845         if (pin_ctl & AC_PINCTL_HP_EN)
    1846             item = 2;
    1847         else
    1848             item = 1;
    1849     } else if (pin_ctl & AC_PINCTL_IN_EN) {
    1850         switch (pin_ctl & AC_PINCTL_VREFEN) {
    1851         case AC_PINCTL_VREF_HIZ: item = 3; break;
    1852         case AC_PINCTL_VREF_50:  item = 4; break;
    1853         case AC_PINCTL_VREF_GRD: item = 5; break;
    1854         case AC_PINCTL_VREF_80:  item = 6; break;
    1855         case AC_PINCTL_VREF_100: item = 7; break;
    1856         }
    1857     }
    1858     ucontrol->value.enumerated.item[0] = item;
    1859     return 0;
    1860 }
    1861 
    1862 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1863 {
    1864     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1865     hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
    1866     static unsigned int ctls[] = {
    1867         0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
    1868         AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
    1869         AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
    1870         AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
    1871         AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
    1872         AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
    1873     };
    1874     unsigned int old_ctl, new_ctl;
    1875 
    1876     old_ctl = snd_hda_codec_read(codec, nid, 0,
    1877                                  AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    1878     new_ctl = ctls[ucontrol->value.enumerated.item[0]];
    1879     if (old_ctl != new_ctl) {
    1880         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
    1881         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    1882                             ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
    1883         return 1;
    1884     }
    1885     return 0;
    1886 }
    1887 
    1888 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    1889 {
    1890     static char *texts[] = {
    1891         "Front", "Surround", "CLFE", "Side"
    1892     };
    1893     uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    1894     uinfo->count = 1;
    1895     uinfo->value.enumerated.items = 4;
    1896     if (uinfo->value.enumerated.item >= 4)
    1897         uinfo->value.enumerated.item = 3;
    1898     strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    1899     return 0;
    1900 }
    1901 
    1902 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1903 {
    1904     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1905     hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
    1906     unsigned int sel;
    1907 
    1908     sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
    1909     ucontrol->value.enumerated.item[0] = sel & 3;
    1910     return 0;
    1911 }
    1912 
    1913 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1914 {
    1915     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1916     hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
    1917     unsigned int sel;
    1918 
    1919     sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
    1920     if (ucontrol->value.enumerated.item[0] != sel) {
    1921         sel = ucontrol->value.enumerated.item[0] & 3;
    1922         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
    1923         return 1;
    1924     }
    1925     return 0;
     2096        { 2, NULL },
     2097        { 4, NULL },
     2098        { 6, NULL },
     2099        { 8, NULL },
     2100};
     2101
     2102static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
     2103                                 struct snd_ctl_elem_info *uinfo)
     2104{
     2105        static char *texts[] = {
     2106                "N/A", "Line Out", "HP Out",
     2107                "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
     2108        };
     2109        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     2110        uinfo->count = 1;
     2111        uinfo->value.enumerated.items = 8;
     2112        if (uinfo->value.enumerated.item >= 8)
     2113                uinfo->value.enumerated.item = 7;
     2114        strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
     2115        return 0;
     2116}
     2117
     2118static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
     2119                                struct snd_ctl_elem_value *ucontrol)
     2120{
     2121        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     2122        hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
     2123        unsigned int pin_ctl, item = 0;
     2124
     2125        pin_ctl = snd_hda_codec_read(codec, nid, 0,
     2126                                     AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     2127        if (pin_ctl & AC_PINCTL_OUT_EN) {
     2128                if (pin_ctl & AC_PINCTL_HP_EN)
     2129                        item = 2;
     2130                else
     2131                        item = 1;
     2132        } else if (pin_ctl & AC_PINCTL_IN_EN) {
     2133                switch (pin_ctl & AC_PINCTL_VREFEN) {
     2134                case AC_PINCTL_VREF_HIZ: item = 3; break;
     2135                case AC_PINCTL_VREF_50:  item = 4; break;
     2136                case AC_PINCTL_VREF_GRD: item = 5; break;
     2137                case AC_PINCTL_VREF_80:  item = 6; break;
     2138                case AC_PINCTL_VREF_100: item = 7; break;
     2139                }
     2140        }
     2141        ucontrol->value.enumerated.item[0] = item;
     2142        return 0;
     2143}
     2144
     2145static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
     2146                                struct snd_ctl_elem_value *ucontrol)
     2147{
     2148        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     2149        hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
     2150        static unsigned int ctls[] = {
     2151                0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
     2152                AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
     2153                AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
     2154                AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
     2155                AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
     2156                AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
     2157        };
     2158        unsigned int old_ctl, new_ctl;
     2159
     2160        old_ctl = snd_hda_codec_read(codec, nid, 0,
     2161                                     AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     2162        new_ctl = ctls[ucontrol->value.enumerated.item[0]];
     2163        if (old_ctl != new_ctl) {
     2164                snd_hda_codec_write(codec, nid, 0,
     2165                                    AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
     2166                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     2167                                    (ucontrol->value.enumerated.item[0] >= 3 ?
     2168                                     0xb080 : 0xb000));
     2169                return 1;
     2170        }
     2171        return 0;
     2172}
     2173
     2174static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
     2175                                 struct snd_ctl_elem_info *uinfo)
     2176{
     2177        static char *texts[] = {
     2178                "Front", "Surround", "CLFE", "Side"
     2179        };
     2180        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     2181        uinfo->count = 1;
     2182        uinfo->value.enumerated.items = 4;
     2183        if (uinfo->value.enumerated.item >= 4)
     2184                uinfo->value.enumerated.item = 3;
     2185        strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
     2186        return 0;
     2187}
     2188
     2189static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
     2190                                struct snd_ctl_elem_value *ucontrol)
     2191{
     2192        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     2193        hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
     2194        unsigned int sel;
     2195
     2196        sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
     2197        ucontrol->value.enumerated.item[0] = sel & 3;
     2198        return 0;
     2199}
     2200
     2201static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
     2202                                struct snd_ctl_elem_value *ucontrol)
     2203{
     2204        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     2205        hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
     2206        unsigned int sel;
     2207
     2208        sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
     2209        if (ucontrol->value.enumerated.item[0] != sel) {
     2210                sel = ucontrol->value.enumerated.item[0] & 3;
     2211                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
     2212                return 1;
     2213        }
     2214        return 0;
    19262215}
    19272216
    19282217#define PIN_CTL_TEST(xname,nid) {                       \
    1929     .iface = SNDRV_CTL_ELEM_IFACE_MIXER,        \
    1930     .name = xname,                     \
    1931     .info = alc_test_pin_ctl_info, \
    1932     .get = alc_test_pin_ctl_get,   \
    1933     .put = alc_test_pin_ctl_put,   \
    1934     .private_value = nid               \
    1935     }
     2218                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,    \
     2219                        .name = xname,                 \
     2220                        .info = alc_test_pin_ctl_info, \
     2221                        .get = alc_test_pin_ctl_get,   \
     2222                        .put = alc_test_pin_ctl_put,   \
     2223                        .private_value = nid           \
     2224                        }
    19362225
    19372226#define PIN_SRC_TEST(xname,nid) {                       \
    1938     .iface = SNDRV_CTL_ELEM_IFACE_MIXER,        \
    1939     .name = xname,                     \
    1940     .info = alc_test_pin_src_info, \
    1941     .get = alc_test_pin_src_get,   \
    1942     .put = alc_test_pin_src_put,   \
    1943     .private_value = nid               \
    1944     }
     2227                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,    \
     2228                        .name = xname,                 \
     2229                        .info = alc_test_pin_src_info, \
     2230                        .get = alc_test_pin_src_get,   \
     2231                        .put = alc_test_pin_src_put,   \
     2232                        .private_value = nid           \
     2233                        }
    19452234
    19462235static struct snd_kcontrol_new alc880_test_mixer[] = {
    1947     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    1948     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    1949     HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
    1950     HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    1951     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    1952     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    1953     HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
    1954     HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    1955     PIN_CTL_TEST("Front Pin Mode", 0x14),
    1956     PIN_CTL_TEST("Surround Pin Mode", 0x15),
    1957     PIN_CTL_TEST("CLFE Pin Mode", 0x16),
    1958     PIN_CTL_TEST("Side Pin Mode", 0x17),
    1959     PIN_CTL_TEST("In-1 Pin Mode", 0x18),
    1960     PIN_CTL_TEST("In-2 Pin Mode", 0x19),
    1961     PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
    1962     PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
    1963     PIN_SRC_TEST("In-1 Pin Source", 0x18),
    1964     PIN_SRC_TEST("In-2 Pin Source", 0x19),
    1965     PIN_SRC_TEST("In-3 Pin Source", 0x1a),
    1966     PIN_SRC_TEST("In-4 Pin Source", 0x1b),
    1967     HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
    1968     HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
    1969     HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
    1970     HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
    1971     HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
    1972     HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
    1973     HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
    1974     HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
    1975     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
    1976     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
    1977     {
    1978         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1979         .name = "Channel Mode",
    1980         .info = alc_ch_mode_info,
    1981         .get = alc_ch_mode_get,
    1982         .put = alc_ch_mode_put,
    1983     },
    1984     {0} /* end */
     2236        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     2237        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     2238        HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
     2239        HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     2240        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     2241        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     2242        HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
     2243        HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
     2244        PIN_CTL_TEST("Front Pin Mode", 0x14),
     2245        PIN_CTL_TEST("Surround Pin Mode", 0x15),
     2246        PIN_CTL_TEST("CLFE Pin Mode", 0x16),
     2247        PIN_CTL_TEST("Side Pin Mode", 0x17),
     2248        PIN_CTL_TEST("In-1 Pin Mode", 0x18),
     2249        PIN_CTL_TEST("In-2 Pin Mode", 0x19),
     2250        PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
     2251        PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
     2252        PIN_SRC_TEST("In-1 Pin Source", 0x18),
     2253        PIN_SRC_TEST("In-2 Pin Source", 0x19),
     2254        PIN_SRC_TEST("In-3 Pin Source", 0x1a),
     2255        PIN_SRC_TEST("In-4 Pin Source", 0x1b),
     2256        HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
     2257        HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
     2258        HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
     2259        HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
     2260        HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
     2261        HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
     2262        HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
     2263        HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
     2264        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
     2265        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
     2266        {
     2267                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2268                .name = "Channel Mode",
     2269                .info = alc_ch_mode_info,
     2270                .get = alc_ch_mode_get,
     2271                .put = alc_ch_mode_put,
     2272        },
     2273        {0} /* end */
    19852274};
    19862275
    19872276static struct hda_verb alc880_test_init_verbs[] = {
    1988     /* Unmute inputs of 0x0c - 0x0f */
    1989     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1990     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1991     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1992     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1993     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1994     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1995     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1996     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1997     /* Vol output for 0x0c-0x0f */
    1998     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1999     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    2000     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    2001     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    2002     /* Set output pins 0x14-0x17 */
    2003     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    2004     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    2005     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    2006     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    2007     /* Unmute output pins 0x14-0x17 */
    2008     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    2009     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    2010     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    2011     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    2012     /* Set input pins 0x18-0x1c */
    2013     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    2014     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    2015     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    2016     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    2017     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    2018     /* Mute input pins 0x18-0x1b */
    2019     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2020     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2021     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2022     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2023     /* ADC set up */
    2024     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    2025     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    2026     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    2027     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    2028     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    2029     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    2030     /* Analog input/passthru */
    2031     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    2032     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    2033     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
    2034     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
    2035     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
    2036     {0}
     2277        /* Unmute inputs of 0x0c - 0x0f */
     2278        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     2279        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     2280        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     2281        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     2282        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     2283        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     2284        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     2285        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     2286        /* Vol output for 0x0c-0x0f */
     2287        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     2288        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     2289        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     2290        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     2291        /* Set output pins 0x14-0x17 */
     2292        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     2293        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     2294        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     2295        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     2296        /* Unmute output pins 0x14-0x17 */
     2297        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     2298        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     2299        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     2300        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     2301        /* Set input pins 0x18-0x1c */
     2302        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     2303        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     2304        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     2305        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     2306        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     2307        /* Mute input pins 0x18-0x1b */
     2308        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     2309        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     2310        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     2311        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     2312        /* ADC set up */
     2313        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     2314        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     2315        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     2316        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     2317        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     2318        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     2319        /* Analog input/passthru */
     2320        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     2321        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     2322        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     2323        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     2324        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     2325        {0}
    20372326};
    20382327#endif
     
    20412330 */
    20422331
    2043 static struct hda_board_config alc880_cfg_tbl[] = {
    2044     /* Back 3 jack, front 2 jack */
    2045     { .modelname = "3stack", .config = ALC880_3ST },
    2046     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
    2047     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
    2048     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
    2049     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
    2050     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
    2051     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
    2052     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
    2053     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
    2054     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
    2055     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
    2056     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
    2057     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
    2058     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
    2059     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
    2060     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
    2061     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
    2062     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
    2063     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
    2064     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
    2065     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
    2066     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
    2067     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
    2068     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
    2069     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
    2070     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
    2071     { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
    2072     { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
    2073     { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
    2074     { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
    2075     { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
    2076     { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
    2077     { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
    2078     /* TCL S700 */
    2079     { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
    2080 
    2081     /* Back 3 jack, front 2 jack (Internal add Aux-In) */
    2082     { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
    2083     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
    2084     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
    2085 
    2086     /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
    2087     { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
    2088     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
    2089     { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
    2090     /* Clevo m520G NB */
    2091     { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
    2092 
    2093     /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
    2094     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
    2095     { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
    2096     { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
    2097 
    2098     /* Back 5 jack, front 2 jack */
    2099     { .modelname = "5stack", .config = ALC880_5ST },
    2100     { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
    2101     { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
    2102     { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
    2103     { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
    2104     { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
    2105 
    2106     /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
    2107     { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
    2108     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
    2109     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
    2110     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
    2111     { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
    2112     { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
    2113     { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
    2114     { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
    2115     { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
    2116     { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
    2117     { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560, .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
    2118     /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
    2119     { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
    2120     /* note subvendor = 0 below */
    2121     /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
    2122 
    2123     { .modelname = "w810", .config = ALC880_W810 },
    2124     { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
    2125 
    2126     { .modelname = "z71v", .config = ALC880_Z71V },
    2127     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
    2128 
    2129     { .modelname = "6stack", .config = ALC880_6ST },
    2130     { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
    2131     { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
    2132     { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
    2133     { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
    2134 
    2135     { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
    2136     { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
    2137     { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
    2138     { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
    2139     { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
    2140     { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
    2141     { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
    2142     { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
    2143     { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
    2144     { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
    2145     { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
    2146 
    2147     { .modelname = "asus", .config = ALC880_ASUS },
    2148     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
    2149     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
    2150     { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
    2151     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
    2152     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
    2153     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
    2154     { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
    2155     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
    2156     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
    2157     { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
    2158     { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
    2159     { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
    2160     { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
    2161 
    2162     { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
    2163     { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
    2164 
    2165     { .modelname = "F1734", .config = ALC880_F1734 },
    2166     { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
    2167     { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
    2168 
    2169     { .modelname = "lg", .config = ALC880_LG },
    2170     { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
    2171     { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
    2172     { .modelname = "lg-lw", .config = ALC880_LG_LW },
    2173     { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
    2174 
     2332static const char *alc880_models[ALC880_MODEL_LAST] = {
     2333        [ALC880_3ST]            = "3stack",
     2334        [ALC880_TCL_S700]       = "tcl",
     2335        [ALC880_3ST_DIG]        = "3stack-digout",
     2336        [ALC880_CLEVO]          = "clevo",
     2337        [ALC880_5ST]            = "5stack",
     2338        [ALC880_5ST_DIG]        = "5stack-digout",
     2339        [ALC880_W810]           = "w810",
     2340        [ALC880_Z71V]           = "z71v",
     2341        [ALC880_6ST]            = "6stack",
     2342        [ALC880_6ST_DIG]        = "6stack-digout",
     2343        [ALC880_ASUS]           = "asus",
     2344        [ALC880_ASUS_W1V]       = "asus-w1v",
     2345        [ALC880_ASUS_DIG]       = "asus-dig",
     2346        [ALC880_ASUS_DIG2]      = "asus-dig2",
     2347        [ALC880_UNIWILL_DIG]    = "uniwill",
     2348        [ALC880_F1734]          = "F1734",
     2349        [ALC880_LG]             = "lg",
     2350        [ALC880_LG_LW]          = "lg-lw",
    21752351#ifdef CONFIG_SND_DEBUG
    2176     { .modelname = "test", .config = ALC880_TEST },
     2352        [ALC880_TEST]           = "test",
    21772353#endif
    2178     { .modelname = "auto", .config = ALC880_AUTO },
    2179 
    2180     {0}
     2354        [ALC880_AUTO]           = "auto",
     2355};
     2356
     2357static struct snd_pci_quirk alc880_cfg_tbl[] = {
     2358        /* Broken BIOS configuration */
     2359        SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
     2360        SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
     2361
     2362        SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
     2363        SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
     2364        SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
     2365        SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
     2366        SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
     2367        SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
     2368        SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
     2369        SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
     2370        SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
     2371
     2372        SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
     2373        SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
     2374
     2375        SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
     2376        SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
     2377        SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
     2378        SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
     2379        SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
     2380        SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
     2381        SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
     2382        /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
     2383        SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
     2384        SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
     2385        SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
     2386        SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
     2387        SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
     2388        SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
     2389        SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
     2390
     2391        SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
     2392        SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
     2393        SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
     2394        SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
     2395        SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
     2396        SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
     2397        SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
     2398        SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
     2399        SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
     2400        SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
     2401        SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
     2402        SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
     2403        SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
     2404        SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
     2405        SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
     2406        SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
     2407        SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
     2408        SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
     2409
     2410        SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
     2411        SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
     2412        SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
     2413        SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
     2414
     2415        SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
     2416        SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
     2417        SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
     2418
     2419        SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
     2420        SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
     2421        SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
     2422        SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
     2423
     2424        SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
     2425        SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
     2426        SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
     2427        SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
     2428        SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
     2429        SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
     2430        SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
     2431        SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
     2432        SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
     2433        SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
     2434        SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
     2435
     2436        {0}
    21812437};
    21822438
     
    21852441 */
    21862442static struct alc_config_preset alc880_presets[] = {
    2187     [ALC880_3ST] = {
    2188         .mixers = { alc880_three_stack_mixer },
    2189         .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
    2190         .num_dacs = ARRAY_SIZE(alc880_dac_nids),
    2191         .dac_nids = alc880_dac_nids,
    2192         .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
    2193         .channel_mode = alc880_threestack_modes,
    2194         .input_mux = &alc880_capture_source,
    2195     },
    2196     [ALC880_3ST_DIG] = {
    2197         .mixers = { alc880_three_stack_mixer },
    2198         .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
    2199         .num_dacs = ARRAY_SIZE(alc880_dac_nids),
    2200         .dac_nids = alc880_dac_nids,
    2201         .dig_out_nid = ALC880_DIGOUT_NID,
    2202         .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
    2203         .channel_mode = alc880_threestack_modes,
    2204         .input_mux = &alc880_capture_source,
    2205     },
    2206     [ALC880_TCL_S700] = {
    2207         .mixers = { alc880_tcl_s700_mixer },
    2208         .init_verbs = { alc880_volume_init_verbs,
    2209         alc880_pin_tcl_S700_init_verbs,
    2210         alc880_gpio2_init_verbs },
    2211         .num_dacs = ARRAY_SIZE(alc880_dac_nids),
    2212         .dac_nids = alc880_dac_nids,
    2213         .hp_nid = 0x03,
    2214         .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
    2215         .channel_mode = alc880_2_jack_modes,
    2216         .input_mux = &alc880_capture_source,
    2217     },
    2218     [ALC880_5ST] = {
    2219         .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
    2220         .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
    2221         .num_dacs = ARRAY_SIZE(alc880_dac_nids),
    2222         .dac_nids = alc880_dac_nids,
    2223         .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
    2224         .channel_mode = alc880_fivestack_modes,
    2225         .input_mux = &alc880_capture_source,
    2226     },
    2227     [ALC880_5ST_DIG] = {
    2228         .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
    2229         .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
    2230         .num_dacs = ARRAY_SIZE(alc880_dac_nids),
    2231         .dac_nids = alc880_dac_nids,
    2232         .dig_out_nid = ALC880_DIGOUT_NID,
    2233         .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
    2234         .channel_mode = alc880_fivestack_modes,
    2235         .input_mux = &alc880_capture_source,
    2236     },
    2237     [ALC880_6ST] = {
    2238         .mixers = { alc880_six_stack_mixer },
    2239         .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
    2240         .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
    2241         .dac_nids = alc880_6st_dac_nids,
    2242         .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
    2243         .channel_mode = alc880_sixstack_modes,
    2244         .input_mux = &alc880_6stack_capture_source,
    2245     },
    2246     [ALC880_6ST_DIG] = {
    2247         .mixers = { alc880_six_stack_mixer },
    2248         .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
    2249         .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
    2250         .dac_nids = alc880_6st_dac_nids,
    2251         .dig_out_nid = ALC880_DIGOUT_NID,
    2252         .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
    2253         .channel_mode = alc880_sixstack_modes,
    2254         .input_mux = &alc880_6stack_capture_source,
    2255     },
    2256     [ALC880_W810] = {
    2257         .mixers = { alc880_w810_base_mixer },
    2258         .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
    2259         alc880_gpio2_init_verbs },
    2260         .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
    2261         .dac_nids = alc880_w810_dac_nids,
    2262         .dig_out_nid = ALC880_DIGOUT_NID,
    2263         .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
    2264         .channel_mode = alc880_w810_modes,
    2265         .input_mux = &alc880_capture_source,
    2266     },
    2267     [ALC880_Z71V] = {
    2268         .mixers = { alc880_z71v_mixer },
    2269         .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
    2270         .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
    2271         .dac_nids = alc880_z71v_dac_nids,
    2272         .dig_out_nid = ALC880_DIGOUT_NID,
    2273         .hp_nid = 0x03,
    2274         .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
    2275         .channel_mode = alc880_2_jack_modes,
    2276         .input_mux = &alc880_capture_source,
    2277     },
    2278     [ALC880_F1734] = {
    2279         .mixers = { alc880_f1734_mixer },
    2280         .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
    2281         .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
    2282         .dac_nids = alc880_f1734_dac_nids,
    2283         .hp_nid = 0x02,
    2284         .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
    2285         .channel_mode = alc880_2_jack_modes,
    2286         .input_mux = &alc880_capture_source,
    2287     },
    2288     [ALC880_ASUS] = {
    2289         .mixers = { alc880_asus_mixer },
    2290         .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
    2291         alc880_gpio1_init_verbs },
    2292         .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
    2293         .dac_nids = alc880_asus_dac_nids,
    2294         .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
    2295         .channel_mode = alc880_asus_modes,
    2296         .input_mux = &alc880_capture_source,
    2297     },
    2298     [ALC880_ASUS_DIG] = {
    2299         .mixers = { alc880_asus_mixer },
    2300         .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
    2301         alc880_gpio1_init_verbs },
    2302         .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
    2303         .dac_nids = alc880_asus_dac_nids,
    2304         .dig_out_nid = ALC880_DIGOUT_NID,
    2305         .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
    2306         .channel_mode = alc880_asus_modes,
    2307         .input_mux = &alc880_capture_source,
    2308     },
    2309     [ALC880_ASUS_DIG2] = {
    2310         .mixers = { alc880_asus_mixer },
    2311         .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
    2312         alc880_gpio2_init_verbs }, /* use GPIO2 */
    2313         .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
    2314         .dac_nids = alc880_asus_dac_nids,
    2315         .dig_out_nid = ALC880_DIGOUT_NID,
    2316         .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
    2317         .channel_mode = alc880_asus_modes,
    2318         .input_mux = &alc880_capture_source,
    2319     },
    2320     [ALC880_ASUS_W1V] = {
    2321         .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
    2322         .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
    2323         alc880_gpio1_init_verbs },
    2324         .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
    2325         .dac_nids = alc880_asus_dac_nids,
    2326         .dig_out_nid = ALC880_DIGOUT_NID,
    2327         .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
    2328         .channel_mode = alc880_asus_modes,
    2329         .input_mux = &alc880_capture_source,
    2330     },
    2331     [ALC880_UNIWILL_DIG] = {
    2332         .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
    2333         .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
    2334         .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
    2335         .dac_nids = alc880_asus_dac_nids,
    2336         .dig_out_nid = ALC880_DIGOUT_NID,
    2337         .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
    2338         .channel_mode = alc880_asus_modes,
    2339         .input_mux = &alc880_capture_source,
    2340     },
    2341     [ALC880_CLEVO] = {
    2342         .mixers = { alc880_three_stack_mixer },
    2343         .init_verbs = { alc880_volume_init_verbs,
    2344         alc880_pin_clevo_init_verbs },
    2345         .num_dacs = ARRAY_SIZE(alc880_dac_nids),
    2346         .dac_nids = alc880_dac_nids,
    2347         .hp_nid = 0x03,
    2348         .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
    2349         .channel_mode = alc880_threestack_modes,
    2350         .input_mux = &alc880_capture_source,
    2351     },
    2352     [ALC880_LG] = {
    2353         .mixers = { alc880_lg_mixer },
    2354         .init_verbs = { alc880_volume_init_verbs,
    2355         alc880_lg_init_verbs },
    2356         .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
    2357         .dac_nids = alc880_lg_dac_nids,
    2358         .dig_out_nid = ALC880_DIGOUT_NID,
    2359         .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
    2360         .channel_mode = alc880_lg_ch_modes,
    2361         .input_mux = &alc880_lg_capture_source,
    2362         .unsol_event = alc880_lg_unsol_event,
    2363         .init_hook = alc880_lg_automute,
    2364     },
    2365     [ALC880_LG_LW] = {
    2366         .mixers = { alc880_lg_lw_mixer },
    2367         .init_verbs = { alc880_volume_init_verbs,
    2368         alc880_lg_lw_init_verbs },
    2369         .num_dacs = 1,
    2370         .dac_nids = alc880_dac_nids,
    2371         .dig_out_nid = ALC880_DIGOUT_NID,
    2372         .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
    2373         .channel_mode = alc880_2_jack_modes,
    2374         .input_mux = &alc880_lg_lw_capture_source,
    2375         .unsol_event = alc880_lg_lw_unsol_event,
    2376         .init_hook = alc880_lg_lw_automute,
    2377     },
     2443        [ALC880_3ST] = {
     2444                .mixers = { alc880_three_stack_mixer },
     2445                .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
     2446                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     2447                .dac_nids = alc880_dac_nids,
     2448                .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
     2449                .channel_mode = alc880_threestack_modes,
     2450                .need_dac_fix = 1,
     2451                .input_mux = &alc880_capture_source,
     2452        },
     2453        [ALC880_3ST_DIG] = {
     2454                .mixers = { alc880_three_stack_mixer },
     2455                .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
     2456                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     2457                .dac_nids = alc880_dac_nids,
     2458                .dig_out_nid = ALC880_DIGOUT_NID,
     2459                .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
     2460                .channel_mode = alc880_threestack_modes,
     2461                .need_dac_fix = 1,
     2462                .input_mux = &alc880_capture_source,
     2463        },
     2464        [ALC880_TCL_S700] = {
     2465                .mixers = { alc880_tcl_s700_mixer },
     2466                .init_verbs = { alc880_volume_init_verbs,
     2467                                alc880_pin_tcl_S700_init_verbs,
     2468                                alc880_gpio2_init_verbs },
     2469                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     2470                .dac_nids = alc880_dac_nids,
     2471                .hp_nid = 0x03,
     2472                .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
     2473                .channel_mode = alc880_2_jack_modes,
     2474                .input_mux = &alc880_capture_source,
     2475        },
     2476        [ALC880_5ST] = {
     2477                .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
     2478                .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
     2479                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     2480                .dac_nids = alc880_dac_nids,
     2481                .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
     2482                .channel_mode = alc880_fivestack_modes,
     2483                .input_mux = &alc880_capture_source,
     2484        },
     2485        [ALC880_5ST_DIG] = {
     2486                .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
     2487                .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
     2488                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     2489                .dac_nids = alc880_dac_nids,
     2490                .dig_out_nid = ALC880_DIGOUT_NID,
     2491                .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
     2492                .channel_mode = alc880_fivestack_modes,
     2493                .input_mux = &alc880_capture_source,
     2494        },
     2495        [ALC880_6ST] = {
     2496                .mixers = { alc880_six_stack_mixer },
     2497                .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
     2498                .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
     2499                .dac_nids = alc880_6st_dac_nids,
     2500                .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
     2501                .channel_mode = alc880_sixstack_modes,
     2502                .input_mux = &alc880_6stack_capture_source,
     2503        },
     2504        [ALC880_6ST_DIG] = {
     2505                .mixers = { alc880_six_stack_mixer },
     2506                .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
     2507                .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
     2508                .dac_nids = alc880_6st_dac_nids,
     2509                .dig_out_nid = ALC880_DIGOUT_NID,
     2510                .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
     2511                .channel_mode = alc880_sixstack_modes,
     2512                .input_mux = &alc880_6stack_capture_source,
     2513        },
     2514        [ALC880_W810] = {
     2515                .mixers = { alc880_w810_base_mixer },
     2516                .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
     2517                                alc880_gpio2_init_verbs },
     2518                .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
     2519                .dac_nids = alc880_w810_dac_nids,
     2520                .dig_out_nid = ALC880_DIGOUT_NID,
     2521                .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
     2522                .channel_mode = alc880_w810_modes,
     2523                .input_mux = &alc880_capture_source,
     2524        },
     2525        [ALC880_Z71V] = {
     2526                .mixers = { alc880_z71v_mixer },
     2527                .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
     2528                .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
     2529                .dac_nids = alc880_z71v_dac_nids,
     2530                .dig_out_nid = ALC880_DIGOUT_NID,
     2531                .hp_nid = 0x03,
     2532                .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
     2533                .channel_mode = alc880_2_jack_modes,
     2534                .input_mux = &alc880_capture_source,
     2535        },
     2536        [ALC880_F1734] = {
     2537                .mixers = { alc880_f1734_mixer },
     2538                .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
     2539                .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
     2540                .dac_nids = alc880_f1734_dac_nids,
     2541                .hp_nid = 0x02,
     2542                .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
     2543                .channel_mode = alc880_2_jack_modes,
     2544                .input_mux = &alc880_capture_source,
     2545        },
     2546        [ALC880_ASUS] = {
     2547                .mixers = { alc880_asus_mixer },
     2548                .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
     2549                                alc880_gpio1_init_verbs },
     2550                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2551                .dac_nids = alc880_asus_dac_nids,
     2552                .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
     2553                .channel_mode = alc880_asus_modes,
     2554                .need_dac_fix = 1,
     2555                .input_mux = &alc880_capture_source,
     2556        },
     2557        [ALC880_ASUS_DIG] = {
     2558                .mixers = { alc880_asus_mixer },
     2559                .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
     2560                                alc880_gpio1_init_verbs },
     2561                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2562                .dac_nids = alc880_asus_dac_nids,
     2563                .dig_out_nid = ALC880_DIGOUT_NID,
     2564                .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
     2565                .channel_mode = alc880_asus_modes,
     2566                .need_dac_fix = 1,
     2567                .input_mux = &alc880_capture_source,
     2568        },
     2569        [ALC880_ASUS_DIG2] = {
     2570                .mixers = { alc880_asus_mixer },
     2571                .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
     2572                                alc880_gpio2_init_verbs }, /* use GPIO2 */
     2573                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2574                .dac_nids = alc880_asus_dac_nids,
     2575                .dig_out_nid = ALC880_DIGOUT_NID,
     2576                .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
     2577                .channel_mode = alc880_asus_modes,
     2578                .need_dac_fix = 1,
     2579                .input_mux = &alc880_capture_source,
     2580        },
     2581        [ALC880_ASUS_W1V] = {
     2582                .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
     2583                .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
     2584                                alc880_gpio1_init_verbs },
     2585                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2586                .dac_nids = alc880_asus_dac_nids,
     2587                .dig_out_nid = ALC880_DIGOUT_NID,
     2588                .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
     2589                .channel_mode = alc880_asus_modes,
     2590                .need_dac_fix = 1,
     2591                .input_mux = &alc880_capture_source,
     2592        },
     2593        [ALC880_UNIWILL_DIG] = {
     2594                .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
     2595                .init_verbs = { alc880_volume_init_verbs,
     2596                                alc880_pin_asus_init_verbs },
     2597                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2598                .dac_nids = alc880_asus_dac_nids,
     2599                .dig_out_nid = ALC880_DIGOUT_NID,
     2600                .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
     2601                .channel_mode = alc880_asus_modes,
     2602                .need_dac_fix = 1,
     2603                .input_mux = &alc880_capture_source,
     2604        },
     2605        [ALC880_UNIWILL] = {
     2606                .mixers = { alc880_uniwill_mixer },
     2607                .init_verbs = { alc880_volume_init_verbs,
     2608                                alc880_uniwill_init_verbs },
     2609                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2610                .dac_nids = alc880_asus_dac_nids,
     2611                .dig_out_nid = ALC880_DIGOUT_NID,
     2612                .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
     2613                .channel_mode = alc880_threestack_modes,
     2614                .need_dac_fix = 1,
     2615                .input_mux = &alc880_capture_source,
     2616                .unsol_event = alc880_uniwill_unsol_event,
     2617                .init_hook = alc880_uniwill_automute,
     2618        },
     2619        [ALC880_UNIWILL_P53] = {
     2620                .mixers = { alc880_uniwill_p53_mixer },
     2621                .init_verbs = { alc880_volume_init_verbs,
     2622                                alc880_uniwill_p53_init_verbs },
     2623                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
     2624                .dac_nids = alc880_asus_dac_nids,
     2625                .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
     2626                .channel_mode = alc880_w810_modes,
     2627                .input_mux = &alc880_capture_source,
     2628                .unsol_event = alc880_uniwill_p53_unsol_event,
     2629                .init_hook = alc880_uniwill_p53_hp_automute,
     2630        },
     2631        [ALC880_CLEVO] = {
     2632                .mixers = { alc880_three_stack_mixer },
     2633                .init_verbs = { alc880_volume_init_verbs,
     2634                                alc880_pin_clevo_init_verbs },
     2635                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     2636                .dac_nids = alc880_dac_nids,
     2637                .hp_nid = 0x03,
     2638                .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
     2639                .channel_mode = alc880_threestack_modes,
     2640                .need_dac_fix = 1,
     2641                .input_mux = &alc880_capture_source,
     2642        },
     2643        [ALC880_LG] = {
     2644                .mixers = { alc880_lg_mixer },
     2645                .init_verbs = { alc880_volume_init_verbs,
     2646                                alc880_lg_init_verbs },
     2647                .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
     2648                .dac_nids = alc880_lg_dac_nids,
     2649                .dig_out_nid = ALC880_DIGOUT_NID,
     2650                .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
     2651                .channel_mode = alc880_lg_ch_modes,
     2652                .need_dac_fix = 1,
     2653                .input_mux = &alc880_lg_capture_source,
     2654                .unsol_event = alc880_lg_unsol_event,
     2655                .init_hook = alc880_lg_automute,
     2656        },
     2657        [ALC880_LG_LW] = {
     2658                .mixers = { alc880_lg_lw_mixer },
     2659                .init_verbs = { alc880_volume_init_verbs,
     2660                                alc880_lg_lw_init_verbs },
     2661                .num_dacs = 1,
     2662                .dac_nids = alc880_dac_nids,
     2663                .dig_out_nid = ALC880_DIGOUT_NID,
     2664                .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
     2665                .channel_mode = alc880_2_jack_modes,
     2666                .input_mux = &alc880_lg_lw_capture_source,
     2667                .unsol_event = alc880_lg_lw_unsol_event,
     2668                .init_hook = alc880_lg_lw_automute,
     2669        },
    23782670#ifdef CONFIG_SND_DEBUG
    2379     [ALC880_TEST] = {
    2380         .mixers = { alc880_test_mixer },
    2381         .init_verbs = { alc880_test_init_verbs },
    2382         .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
    2383         .dac_nids = alc880_test_dac_nids,
    2384         .dig_out_nid = ALC880_DIGOUT_NID,
    2385         .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
    2386         .channel_mode = alc880_test_modes,
    2387         .input_mux = &alc880_test_capture_source,
    2388     },
     2671        [ALC880_TEST] = {
     2672                .mixers = { alc880_test_mixer },
     2673                .init_verbs = { alc880_test_init_verbs },
     2674                .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
     2675                .dac_nids = alc880_test_dac_nids,
     2676                .dig_out_nid = ALC880_DIGOUT_NID,
     2677                .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
     2678                .channel_mode = alc880_test_modes,
     2679                .input_mux = &alc880_test_capture_source,
     2680        },
    23892681#endif
    23902682};
     
    23982690
    23992691enum {
    2400     ALC_CTL_WIDGET_VOL,
    2401     ALC_CTL_WIDGET_MUTE,
    2402     ALC_CTL_BIND_MUTE,
     2692        ALC_CTL_WIDGET_VOL,
     2693        ALC_CTL_WIDGET_MUTE,
     2694        ALC_CTL_BIND_MUTE,
    24032695};
    24042696static struct snd_kcontrol_new alc880_control_templates[] = {
    2405     HDA_CODEC_VOLUME(NULL, 0, 0, 0),
    2406     HDA_CODEC_MUTE(NULL, 0, 0, 0),
    2407     HDA_BIND_MUTE(NULL, 0, 0, 0),
     2697        HDA_CODEC_VOLUME(NULL, 0, 0, 0),
     2698        HDA_CODEC_MUTE(NULL, 0, 0, 0),
     2699        HDA_BIND_MUTE(NULL, 0, 0, 0),
    24082700};
    24092701
     
    24112703static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
    24122704{
    2413     struct snd_kcontrol_new *knew;
    2414 
    2415     if (spec->num_kctl_used >= spec->num_kctl_alloc) {
    2416         int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
    2417 
    2418         knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
    2419         if (! knew)
    2420             return -ENOMEM;
    2421         if (spec->kctl_alloc) {
    2422             memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
    2423             kfree(spec->kctl_alloc);
    2424         }
    2425         spec->kctl_alloc = knew;
    2426         spec->num_kctl_alloc = num;
    2427     }
    2428 
    2429     knew = &spec->kctl_alloc[spec->num_kctl_used];
    2430     *knew = alc880_control_templates[type];
    2431     knew->name = kstrdup(name, GFP_KERNEL);
    2432     if (! knew->name)
    2433         return -ENOMEM;
    2434     knew->private_value = val;
    2435     spec->num_kctl_used++;
    2436     return 0;
     2705        struct snd_kcontrol_new *knew;
     2706
     2707        if (spec->num_kctl_used >= spec->num_kctl_alloc) {
     2708                int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
     2709
     2710                knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
     2711                if (! knew)
     2712                        return -ENOMEM;
     2713                if (spec->kctl_alloc) {
     2714                        memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
     2715                        kfree(spec->kctl_alloc);
     2716                }
     2717                spec->kctl_alloc = knew;
     2718                spec->num_kctl_alloc = num;
     2719        }
     2720
     2721        knew = &spec->kctl_alloc[spec->num_kctl_used];
     2722        *knew = alc880_control_templates[type];
     2723        knew->name = kstrdup(name, GFP_KERNEL);
     2724        if (! knew->name)
     2725                return -ENOMEM;
     2726        knew->private_value = val;
     2727        spec->num_kctl_used++;
     2728        return 0;
    24372729}
    24382730
     
    24522744static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
    24532745{
    2454     hda_nid_t nid;
    2455     int assigned[4];
    2456     int i, j;
    2457 
    2458     memset(assigned, 0, sizeof(assigned));
    2459     spec->multiout.dac_nids = spec->private_dac_nids;
    2460 
    2461     /* check the pins hardwired to audio widget */
    2462     for (i = 0; i < cfg->line_outs; i++) {
    2463         nid = cfg->line_out_pins[i];
    2464         if (alc880_is_fixed_pin(nid)) {
    2465             int idx = alc880_fixed_pin_idx(nid);
    2466             spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
    2467             assigned[idx] = 1;
    2468         }
    2469     }
    2470     /* left pins can be connect to any audio widget */
    2471     for (i = 0; i < cfg->line_outs; i++) {
    2472         nid = cfg->line_out_pins[i];
    2473         if (alc880_is_fixed_pin(nid))
    2474             continue;
    2475         /* search for an empty channel */
    2476         for (j = 0; j < cfg->line_outs; j++) {
    2477             if (! assigned[j]) {
    2478                 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
    2479                 assigned[j] = 1;
    2480                 break;
    2481             }
    2482         }
    2483     }
    2484     spec->multiout.num_dacs = cfg->line_outs;
    2485     return 0;
     2746        hda_nid_t nid;
     2747        int assigned[4];
     2748        int i, j;
     2749
     2750        memset(assigned, 0, sizeof(assigned));
     2751        spec->multiout.dac_nids = spec->private_dac_nids;
     2752
     2753        /* check the pins hardwired to audio widget */
     2754        for (i = 0; i < cfg->line_outs; i++) {
     2755                nid = cfg->line_out_pins[i];
     2756                if (alc880_is_fixed_pin(nid)) {
     2757                        int idx = alc880_fixed_pin_idx(nid);
     2758                        spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
     2759                        assigned[idx] = 1;
     2760                }
     2761        }
     2762        /* left pins can be connect to any audio widget */
     2763        for (i = 0; i < cfg->line_outs; i++) {
     2764                nid = cfg->line_out_pins[i];
     2765                if (alc880_is_fixed_pin(nid))
     2766                        continue;
     2767                /* search for an empty channel */
     2768                for (j = 0; j < cfg->line_outs; j++) {
     2769                        if (! assigned[j]) {
     2770                                spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
     2771                                assigned[j] = 1;
     2772                                break;
     2773                        }
     2774                }
     2775        }
     2776        spec->multiout.num_dacs = cfg->line_outs;
     2777        return 0;
    24862778}
    24872779
    24882780/* add playback controls from the parsed DAC table */
    24892781static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
    2490                                              const struct auto_pin_cfg *cfg)
    2491 {
    2492     char name[32];
    2493     static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
    2494     hda_nid_t nid;
    2495     int i, err;
    2496 
    2497     for (i = 0; i < cfg->line_outs; i++) {
    2498         if (! spec->multiout.dac_nids[i])
    2499             continue;
    2500         nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
    2501         if (i == 2) {
    2502             /* Center/LFE */
    2503             if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
    2504                                    HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
    2505                 return err;
    2506             if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
    2507                                    HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
    2508                 return err;
    2509             if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
    2510                                    HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
    2511                 return err;
    2512             if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
    2513                                    HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
    2514                 return err;
    2515         } else {
    2516             sprintf(name, "%s Playback Volume", chname[i]);
    2517             if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
    2518                                    HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    2519                 return err;
    2520             sprintf(name, "%s Playback Switch", chname[i]);
    2521             if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
    2522                                    HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
    2523                 return err;
    2524         }
    2525     }
    2526     return 0;
     2782                                             const struct auto_pin_cfg *cfg)
     2783{
     2784        char name[32];
     2785        static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
     2786        hda_nid_t nid;
     2787        int i, err;
     2788
     2789        for (i = 0; i < cfg->line_outs; i++) {
     2790                if (! spec->multiout.dac_nids[i])
     2791                        continue;
     2792                nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
     2793                if (i == 2) {
     2794                        /* Center/LFE */
     2795                        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
     2796                                               HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
     2797                                return err;
     2798                        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
     2799                                               HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
     2800                                return err;
     2801                        if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
     2802                                               HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
     2803                                return err;
     2804                        if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
     2805                                               HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
     2806                                return err;
     2807                } else {
     2808                        sprintf(name, "%s Playback Volume", chname[i]);
     2809                        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
     2810                                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     2811                                return err;
     2812                        sprintf(name, "%s Playback Switch", chname[i]);
     2813                        if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
     2814                                               HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
     2815                                return err;
     2816                }
     2817        }
     2818        return 0;
    25272819}
    25282820
    25292821/* add playback controls for speaker and HP outputs */
    25302822static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
    2531                                         const char *pfx)
    2532 {
    2533     hda_nid_t nid;
    2534     int err;
    2535     char name[32];
    2536 
    2537     if (! pin)
    2538         return 0;
    2539 
    2540     if (alc880_is_fixed_pin(pin)) {
    2541         nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
    2542         /* specify the DAC as the extra output */
    2543         if (! spec->multiout.hp_nid)
    2544             spec->multiout.hp_nid = nid;
    2545         else
    2546             spec->multiout.extra_out_nid[0] = nid;
    2547         /* control HP volume/switch on the output mixer amp */
    2548         nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
    2549         sprintf(name, "%s Playback Volume", pfx);
    2550         if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
    2551                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    2552             return err;
    2553         sprintf(name, "%s Playback Switch", pfx);
    2554         if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
    2555                                HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
    2556             return err;
    2557     } else if (alc880_is_multi_pin(pin)) {
    2558         /* set manual connection */
    2559         /* we have only a switch on HP-out PIN */
    2560         sprintf(name, "%s Playback Switch", pfx);
    2561         if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
    2562                                HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
    2563             return err;
    2564     }
    2565     return 0;
     2823                                        const char *pfx)
     2824{
     2825        hda_nid_t nid;
     2826        int err;
     2827        char name[32];
     2828
     2829        if (! pin)
     2830                return 0;
     2831
     2832        if (alc880_is_fixed_pin(pin)) {
     2833                nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
     2834                /* specify the DAC as the extra output */
     2835                if (! spec->multiout.hp_nid)
     2836                        spec->multiout.hp_nid = nid;
     2837                else
     2838                        spec->multiout.extra_out_nid[0] = nid;
     2839                /* control HP volume/switch on the output mixer amp */
     2840                nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
     2841                sprintf(name, "%s Playback Volume", pfx);
     2842                if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
     2843                                       HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     2844                        return err;
     2845                sprintf(name, "%s Playback Switch", pfx);
     2846                if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
     2847                                       HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
     2848                        return err;
     2849        } else if (alc880_is_multi_pin(pin)) {
     2850                /* set manual connection */
     2851                /* we have only a switch on HP-out PIN */
     2852                sprintf(name, "%s Playback Switch", pfx);
     2853                if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
     2854                                       HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
     2855                        return err;
     2856        }
     2857        return 0;
    25662858}
    25672859
    25682860/* create input playback/capture controls for the given pin */
    25692861static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
    2570                             int idx, hda_nid_t mix_nid)
    2571 {
    2572     char name[32];
    2573     int err;
    2574 
    2575     sprintf(name, "%s Playback Volume", ctlname);
    2576     if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
    2577                            HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
    2578         return err;
    2579     sprintf(name, "%s Playback Switch", ctlname);
    2580     if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
    2581                            HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
    2582         return err;
    2583     return 0;
     2862                            int idx, hda_nid_t mix_nid)
     2863{
     2864        char name[32];
     2865        int err;
     2866
     2867        sprintf(name, "%s Playback Volume", ctlname);
     2868        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
     2869                               HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
     2870                return err;
     2871        sprintf(name, "%s Playback Switch", ctlname);
     2872        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
     2873                               HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
     2874                return err;
     2875        return 0;
    25842876}
    25852877
    25862878/* create playback/capture controls for input pins */
    25872879static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
    2588                                                 const struct auto_pin_cfg *cfg)
    2589 {
    2590     struct hda_input_mux *imux = &spec->private_imux;
    2591     int i, err, idx;
    2592 
    2593     for (i = 0; i < AUTO_PIN_LAST; i++) {
    2594         if (alc880_is_input_pin(cfg->input_pins[i])) {
    2595             idx = alc880_input_pin_idx(cfg->input_pins[i]);
    2596             err = new_analog_input(spec, cfg->input_pins[i],
    2597                                    auto_pin_cfg_labels[i],
    2598                                    idx, 0x0b);
    2599             if (err < 0)
    2600                 return err;
    2601             imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
    2602             imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
    2603             imux->num_items++;
    2604         }
    2605     }
    2606     return 0;
     2880                                                const struct auto_pin_cfg *cfg)
     2881{
     2882        struct hda_input_mux *imux = &spec->private_imux;
     2883        int i, err, idx;
     2884
     2885        for (i = 0; i < AUTO_PIN_LAST; i++) {
     2886                if (alc880_is_input_pin(cfg->input_pins[i])) {
     2887                        idx = alc880_input_pin_idx(cfg->input_pins[i]);
     2888                        err = new_analog_input(spec, cfg->input_pins[i],
     2889                                               auto_pin_cfg_labels[i],
     2890                                               idx, 0x0b);
     2891                        if (err < 0)
     2892                                return err;
     2893                        imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
     2894                        imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
     2895                        imux->num_items++;
     2896                }
     2897        }
     2898        return 0;
    26072899}
    26082900
    26092901static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
    2610                                               hda_nid_t nid, int pin_type,
    2611                                               int dac_idx)
    2612 {
    2613     /* set as output */
    2614     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
    2615     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
    2616     /* need the manual connection? */
    2617     if (alc880_is_multi_pin(nid)) {
    2618         struct alc_spec *spec = codec->spec;
    2619         int idx = alc880_multi_pin_idx(nid);
    2620         snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
    2621                             AC_VERB_SET_CONNECT_SEL,
    2622                             alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
    2623     }
     2902                                              hda_nid_t nid, int pin_type,
     2903                                              int dac_idx)
     2904{
     2905        /* set as output */
     2906        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
     2907        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
     2908        /* need the manual connection? */
     2909        if (alc880_is_multi_pin(nid)) {
     2910                struct alc_spec *spec = codec->spec;
     2911                int idx = alc880_multi_pin_idx(nid);
     2912                snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
     2913                                    AC_VERB_SET_CONNECT_SEL,
     2914                                    alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
     2915        }
    26242916}
    26252917
    26262918static void alc880_auto_init_multi_out(struct hda_codec *codec)
    26272919{
    2628     struct alc_spec *spec = codec->spec;
    2629     int i;
    2630 
    2631     for (i = 0; i < spec->autocfg.line_outs; i++) {
    2632         hda_nid_t nid = spec->autocfg.line_out_pins[i];
    2633         alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
    2634     }
     2920        struct alc_spec *spec = codec->spec;
     2921        int i;
     2922
     2923        for (i = 0; i < spec->autocfg.line_outs; i++) {
     2924                hda_nid_t nid = spec->autocfg.line_out_pins[i];
     2925                alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
     2926        }
    26352927}
    26362928
    26372929static void alc880_auto_init_extra_out(struct hda_codec *codec)
    26382930{
    2639     struct alc_spec *spec = codec->spec;
    2640     hda_nid_t pin;
    2641 
    2642     pin = spec->autocfg.speaker_pins[0];
    2643     if (pin) /* connect to front */
    2644         alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    2645     pin = spec->autocfg.hp_pin;
    2646     if (pin) /* connect to front */
    2647         alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     2931        struct alc_spec *spec = codec->spec;
     2932        hda_nid_t pin;
     2933
     2934        pin = spec->autocfg.speaker_pins[0];
     2935        if (pin) /* connect to front */
     2936                alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
     2937        pin = spec->autocfg.hp_pins[0];
     2938        if (pin) /* connect to front */
     2939                alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
    26482940}
    26492941
    26502942static void alc880_auto_init_analog_input(struct hda_codec *codec)
    26512943{
    2652     struct alc_spec *spec = codec->spec;
    2653     int i;
    2654 
    2655     for (i = 0; i < AUTO_PIN_LAST; i++) {
    2656         hda_nid_t nid = spec->autocfg.input_pins[i];
    2657         if (alc880_is_input_pin(nid)) {
    2658             snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    2659                                 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
    2660             if (nid != ALC880_PIN_CD_NID)
    2661                 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    2662                                     AMP_OUT_MUTE);
    2663         }
    2664     }
     2944        struct alc_spec *spec = codec->spec;
     2945        int i;
     2946
     2947        for (i = 0; i < AUTO_PIN_LAST; i++) {
     2948                hda_nid_t nid = spec->autocfg.input_pins[i];
     2949                if (alc880_is_input_pin(nid)) {
     2950                        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     2951                                            i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
     2952                        if (nid != ALC880_PIN_CD_NID)
     2953                                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     2954                                                    AMP_OUT_MUTE);
     2955                }
     2956        }
    26652957}
    26662958
     
    26692961static int alc880_parse_auto_config(struct hda_codec *codec)
    26702962{
    2671     struct alc_spec *spec = codec->spec;
    2672     int err;
    2673     static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
    2674 
    2675     if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
    2676                                             alc880_ignore)) < 0)
    2677         return err;
    2678     if (! spec->autocfg.line_outs)
    2679         return 0; /* can't find valid BIOS pin config */
    2680 
    2681     if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
    2682         (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
    2683         (err = alc880_auto_create_extra_out(spec,
    2684                                             spec->autocfg.speaker_pins[0],
    2685                                             "Speaker")) < 0 ||
    2686         (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
    2687                                             "Headphone")) < 0 ||
    2688         (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
    2689         return err;
    2690 
    2691     spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    2692 
    2693     if (spec->autocfg.dig_out_pin)
    2694         spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
    2695     if (spec->autocfg.dig_in_pin)
    2696         spec->dig_in_nid = ALC880_DIGIN_NID;
    2697 
    2698     if (spec->kctl_alloc)
    2699         spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
    2700 
    2701     spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
    2702 
    2703     spec->input_mux = &spec->private_imux;
    2704 
    2705     return 1;
     2963        struct alc_spec *spec = codec->spec;
     2964        int err;
     2965        static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
     2966
     2967        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
     2968                                                alc880_ignore)) < 0)
     2969                return err;
     2970        if (! spec->autocfg.line_outs)
     2971                return 0; /* can't find valid BIOS pin config */
     2972
     2973        if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
     2974            (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
     2975            (err = alc880_auto_create_extra_out(spec,
     2976                                                spec->autocfg.speaker_pins[0],
     2977                                                "Speaker")) < 0 ||
     2978            (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
     2979                                                "Headphone")) < 0 ||
     2980            (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
     2981                return err;
     2982
     2983        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
     2984
     2985        if (spec->autocfg.dig_out_pin)
     2986                spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
     2987        if (spec->autocfg.dig_in_pin)
     2988                spec->dig_in_nid = ALC880_DIGIN_NID;
     2989
     2990        if (spec->kctl_alloc)
     2991                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
     2992
     2993        spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
     2994
     2995        spec->num_mux_defs = 1;
     2996        spec->input_mux = &spec->private_imux;
     2997
     2998        return 1;
    27062999}
    27073000
     
    27093002static void alc880_auto_init(struct hda_codec *codec)
    27103003{
    2711     alc880_auto_init_multi_out(codec);
    2712     alc880_auto_init_extra_out(codec);
    2713     alc880_auto_init_analog_input(codec);
     3004        alc880_auto_init_multi_out(codec);
     3005        alc880_auto_init_extra_out(codec);
     3006        alc880_auto_init_analog_input(codec);
    27143007}
    27153008
     
    27203013static int patch_alc880(struct hda_codec *codec)
    27213014{
    2722     struct alc_spec *spec;
    2723     int board_config;
    2724     int err;
    2725 
    2726     spec = kzalloc(sizeof(*spec), GFP_KERNEL);
    2727     if (spec == NULL)
    2728         return -ENOMEM;
    2729 
    2730     codec->spec = spec;
    2731 
    2732     board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
    2733     if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
    2734         printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
    2735         board_config = ALC880_AUTO;
    2736     }
    2737 
    2738     if (board_config == ALC880_AUTO) {
    2739         /* automatic parse from the BIOS config */
    2740         err = alc880_parse_auto_config(codec);
    2741         if (err < 0) {
    2742             alc_free(codec);
    2743             return err;
    2744         } else if (! err) {
    2745             printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS.  Using 3-stack mode...\n");
    2746             board_config = ALC880_3ST;
    2747         }
    2748     }
    2749 
    2750     if (board_config != ALC880_AUTO)
    2751         setup_preset(spec, &alc880_presets[board_config]);
    2752 
    2753     spec->stream_name_analog = "ALC880 Analog";
    2754     spec->stream_analog_playback = &alc880_pcm_analog_playback;
    2755     spec->stream_analog_capture = &alc880_pcm_analog_capture;
    2756 
    2757     spec->stream_name_digital = "ALC880 Digital";
    2758     spec->stream_digital_playback = &alc880_pcm_digital_playback;
    2759     spec->stream_digital_capture = &alc880_pcm_digital_capture;
    2760 
    2761     if (! spec->adc_nids && spec->input_mux) {
    2762         /* check whether NID 0x07 is valid */
    2763         unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
    2764         wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
    2765         if (wcap != AC_WID_AUD_IN) {
    2766             spec->adc_nids = alc880_adc_nids_alt;
    2767             spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
    2768             spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
    2769             spec->num_mixers++;
    2770         } else {
    2771             spec->adc_nids = alc880_adc_nids;
    2772             spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
    2773             spec->mixers[spec->num_mixers] = alc880_capture_mixer;
    2774             spec->num_mixers++;
    2775         }
    2776     }
    2777 
    2778     codec->patch_ops = alc_patch_ops;
    2779     if (board_config == ALC880_AUTO)
    2780         spec->init_hook = alc880_auto_init;
    2781 
    2782     return 0;
     3015        struct alc_spec *spec;
     3016        int board_config;
     3017        int err;
     3018
     3019        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     3020        if (spec == NULL)
     3021                return -ENOMEM;
     3022
     3023        codec->spec = spec;
     3024
     3025        board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
     3026                                                  alc880_models,
     3027                                                  alc880_cfg_tbl);
     3028        if (board_config < 0) {
     3029                printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
     3030                       "trying auto-probe from BIOS...\n");
     3031                board_config = ALC880_AUTO;
     3032        }
     3033
     3034        if (board_config == ALC880_AUTO) {
     3035                /* automatic parse from the BIOS config */
     3036                err = alc880_parse_auto_config(codec);
     3037                if (err < 0) {
     3038                        alc_free(codec);
     3039                        return err;
     3040                } else if (! err) {
     3041                        printk(KERN_INFO
     3042                               "hda_codec: Cannot set up configuration "
     3043                               "from BIOS.  Using 3-stack mode...\n");
     3044                        board_config = ALC880_3ST;
     3045                }
     3046        }
     3047
     3048        if (board_config != ALC880_AUTO)
     3049                setup_preset(spec, &alc880_presets[board_config]);
     3050
     3051        spec->stream_name_analog = "ALC880 Analog";
     3052        spec->stream_analog_playback = &alc880_pcm_analog_playback;
     3053        spec->stream_analog_capture = &alc880_pcm_analog_capture;
     3054
     3055        spec->stream_name_digital = "ALC880 Digital";
     3056        spec->stream_digital_playback = &alc880_pcm_digital_playback;
     3057        spec->stream_digital_capture = &alc880_pcm_digital_capture;
     3058
     3059        if (! spec->adc_nids && spec->input_mux) {
     3060                /* check whether NID 0x07 is valid */
     3061                unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
     3062                wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
     3063                if (wcap != AC_WID_AUD_IN) {
     3064                        spec->adc_nids = alc880_adc_nids_alt;
     3065                        spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
     3066                        spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
     3067                        spec->num_mixers++;
     3068                } else {
     3069                        spec->adc_nids = alc880_adc_nids;
     3070                        spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
     3071                        spec->mixers[spec->num_mixers] = alc880_capture_mixer;
     3072                        spec->num_mixers++;
     3073                }
     3074        }
     3075
     3076        codec->patch_ops = alc_patch_ops;
     3077        if (board_config == ALC880_AUTO)
     3078                spec->init_hook = alc880_auto_init;
     3079
     3080        return 0;
    27833081}
    27843082
     
    27893087
    27903088static hda_nid_t alc260_dac_nids[1] = {
    2791     /* front */
    2792     0x02,
     3089        /* front */
     3090        0x02,
    27933091};
    27943092
    27953093static hda_nid_t alc260_adc_nids[1] = {
    2796     /* ADC0 */
    2797     0x04,
     3094        /* ADC0 */
     3095        0x04,
    27983096};
    27993097
    28003098static hda_nid_t alc260_adc_nids_alt[1] = {
    2801     /* ADC1 */
    2802     0x05,
     3099        /* ADC1 */
     3100        0x05,
    28033101};
    28043102
    28053103static hda_nid_t alc260_hp_adc_nids[2] = {
    2806     /* ADC1, 0 */
    2807     0x05, 0x04
     3104        /* ADC1, 0 */
     3105        0x05, 0x04
    28083106};
    28093107
     
    28123110 */
    28133111static hda_nid_t alc260_dual_adc_nids[2] = {
    2814     /* ADC0, ADC1 */
    2815     0x04, 0x05
     3112        /* ADC0, ADC1 */
     3113        0x04, 0x05
    28163114};
    28173115
     
    28203118
    28213119static struct hda_input_mux alc260_capture_source = {
    2822     .num_items = 4,
    2823     .items = {
    2824         { "Mic", 0x0 },
    2825         { "Front Mic", 0x1 },
    2826         { "Line", 0x2 },
    2827         { "CD", 0x4 },
    2828     },
     3120        .num_items = 4,
     3121        .items = {
     3122                { "Mic", 0x0 },
     3123                { "Front Mic", 0x1 },
     3124                { "Line", 0x2 },
     3125                { "CD", 0x4 },
     3126        },
    28293127};
    28303128
    28313129/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
    2832  * headphone jack and the internal CD lines.
    2833  */
    2834 static struct hda_input_mux alc260_fujitsu_capture_source = {
    2835     .num_items = 3,
    2836     .items = {
    2837         { "Mic/Line", 0x0 },
    2838         { "CD", 0x4 },
    2839         { "Headphone", 0x2 },
    2840     },
    2841 };
    2842 
    2843 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
    2844  * the Fujitsu S702x, but jacks are marked differently. We won't allow
    2845  * retasking the Headphone jack, so it won't be available here.
    2846  */
    2847 static struct hda_input_mux alc260_acer_capture_source = {
    2848     .num_items = 3,
    2849     .items = {
    2850         { "Mic", 0x0 },
    2851         { "Line", 0x2 },
    2852         { "CD", 0x4 },
    2853     },
    2854 };
    2855 
     3130 * headphone jack and the internal CD lines since these are the only pins at
     3131 * which audio can appear.  For flexibility, also allow the option of
     3132 * recording the mixer output on the second ADC (ADC0 doesn't have a
     3133 * connection to the mixer output).
     3134 */
     3135static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
     3136        {
     3137                .num_items = 3,
     3138                .items = {
     3139                        { "Mic/Line", 0x0 },
     3140                        { "CD", 0x4 },
     3141                        { "Headphone", 0x2 },
     3142                },
     3143        },
     3144        {
     3145                .num_items = 4,
     3146                .items = {
     3147                        { "Mic/Line", 0x0 },
     3148                        { "CD", 0x4 },
     3149                        { "Headphone", 0x2 },
     3150                        { "Mixer", 0x5 },
     3151                },
     3152        },
     3153
     3154};
     3155
     3156/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
     3157 * the Fujitsu S702x, but jacks are marked differently.
     3158 */
     3159static struct hda_input_mux alc260_acer_capture_sources[2] = {
     3160        {
     3161                .num_items = 4,
     3162                .items = {
     3163                        { "Mic", 0x0 },
     3164                        { "Line", 0x2 },
     3165                        { "CD", 0x4 },
     3166                        { "Headphone", 0x5 },
     3167                },
     3168        },
     3169        {
     3170                .num_items = 5,
     3171                .items = {
     3172                        { "Mic", 0x0 },
     3173                        { "Line", 0x2 },
     3174                        { "CD", 0x4 },
     3175                        { "Headphone", 0x6 },
     3176                        { "Mixer", 0x5 },
     3177                },
     3178        },
     3179};
    28563180/*
    28573181 * This is just place-holder, so there's something for alc_build_pcms to look
     
    28613185 */
    28623186static struct hda_channel_mode alc260_modes[1] = {
    2863     { 2, NULL },
     3187        { 2, NULL },
    28643188};
    28653189
     
    28753199
    28763200static struct snd_kcontrol_new alc260_base_output_mixer[] = {
    2877     HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
    2878     HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
    2879     HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
    2880     HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
    2881     HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
    2882     HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
    2883     {0} /* end */
    2884 };
     3201        HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
     3202        HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
     3203        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
     3204        HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
     3205        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
     3206        HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
     3207        {0} /* end */
     3208};     
    28853209
    28863210static struct snd_kcontrol_new alc260_input_mixer[] = {
    2887     HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
    2888     HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
    2889     HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
    2890     HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
    2891     HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
    2892     HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
    2893     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
    2894     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
    2895     {0} /* end */
     3211        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
     3212        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
     3213        HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
     3214        HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
     3215        HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
     3216        HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
     3217        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
     3218        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
     3219        {0} /* end */
    28963220};
    28973221
    28983222static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
    2899     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
    2900     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
    2901     {0} /* end */
     3223        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
     3224        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
     3225        {0} /* end */
    29023226};
    29033227
    29043228static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
    2905     HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
    2906     HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
    2907     HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
    2908     HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
    2909     HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
    2910     HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
    2911     HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
    2912     HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
    2913     {0} /* end */
    2914 };
    2915 
     3229        HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
     3230        HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
     3231        HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
     3232        HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
     3233        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
     3234        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     3235        HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
     3236        HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
     3237        {0} /* end */
     3238};
     3239
     3240/* Fujitsu S702x series laptops.  ALC260 pin usage: Mic/Line jack = 0x12,
     3241 * HP jack = 0x14, CD audio =  0x16, internal speaker = 0x10.
     3242 */
    29163243static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
    2917     HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
    2918     HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
    2919     ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
    2920     HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
    2921     HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
    2922     HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
    2923     HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
    2924     ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
    2925     HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    2926     HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    2927     HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
    2928     HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
    2929     {0} /* end */
    2930 };
    2931 
     3244        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
     3245        HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
     3246        ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
     3247        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
     3248        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
     3249        HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
     3250        HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
     3251        ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
     3252        HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
     3253        HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
     3254        HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
     3255        HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
     3256        {0} /* end */
     3257};
     3258
     3259/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks.  Note that current
     3260 * versions of the ALC260 don't act on requests to enable mic bias from NID
     3261 * 0x0f (used to drive the headphone jack in these laptops).  The ALC260
     3262 * datasheet doesn't mention this restriction.  At this stage it's not clear
     3263 * whether this behaviour is intentional or is a hardware bug in chip
     3264 * revisions available in early 2006.  Therefore for now allow the
     3265 * "Headphone Jack Mode" control to span all choices, but if it turns out
     3266 * that the lack of mic bias for this NID is intentional we could change the
     3267 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
     3268 *
     3269 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
     3270 * don't appear to make the mic bias available from the "line" jack, even
     3271 * though the NID used for this jack (0x14) can supply it.  The theory is
     3272 * that perhaps Acer have included blocking capacitors between the ALC260
     3273 * and the output jack.  If this turns out to be the case for all such
     3274 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
     3275 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
     3276 *
     3277 * The C20x Tablet series have a mono internal speaker which is controlled
     3278 * via the chip's Mono sum widget and pin complex, so include the necessary
     3279 * controls for such models.  On models without a "mono speaker" the control
     3280 * won't do anything.
     3281 */
    29323282static struct snd_kcontrol_new alc260_acer_mixer[] = {
    2933     HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
    2934     HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
    2935     HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
    2936     HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
    2937     HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
    2938     HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
    2939     ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
    2940     HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
    2941     HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
    2942     ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
    2943     HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    2944     HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    2945     {0} /* end */
     3283        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
     3284        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
     3285        ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
     3286        HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
     3287                              HDA_OUTPUT),
     3288        HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
     3289                           HDA_INPUT),
     3290        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
     3291        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
     3292        HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
     3293        HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
     3294        ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
     3295        HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
     3296        HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
     3297        ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
     3298        HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
     3299        HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
     3300        {0} /* end */
    29463301};
    29473302
    29483303/* capture mixer elements */
    29493304static struct snd_kcontrol_new alc260_capture_mixer[] = {
    2950     HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
    2951     HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
    2952     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
    2953     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
    2954     {
    2955         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    2956         /* The multiple "Capture Source" controls confuse alsamixer
    2957         * So call somewhat different..
    2958         * FIXME: the controls appear in the "playback" view!
    2959         */
    2960         /* .name = "Capture Source", */
    2961         .name = "Input Source",
    2962         .count = 2,
    2963         .info = alc_mux_enum_info,
    2964         .get = alc_mux_enum_get,
    2965         .put = alc_mux_enum_put,
    2966     },
    2967     {0} /* end */
     3305        HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
     3306        HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
     3307        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
     3308        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
     3309        {
     3310                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3311                /* The multiple "Capture Source" controls confuse alsamixer
     3312                * So call somewhat different..
     3313                * FIXME: the controls appear in the "playback" view!
     3314                */
     3315                /* .name = "Capture Source", */
     3316                .name = "Input Source",
     3317                .count = 2,
     3318                .info = alc_mux_enum_info,
     3319                .get = alc_mux_enum_get,
     3320                .put = alc_mux_enum_put,
     3321        },
     3322        {0} /* end */
    29683323};
    29693324
    29703325static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
    2971     HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
    2972     HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
    2973     {
    2974         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    2975         /* The multiple "Capture Source" controls confuse alsamixer
    2976         * So call somewhat different..
    2977         * FIXME: the controls appear in the "playback" view!
    2978         */
    2979         /* .name = "Capture Source", */
    2980         .name = "Input Source",
    2981         .count = 1,
    2982         .info = alc_mux_enum_info,
    2983         .get = alc_mux_enum_get,
    2984         .put = alc_mux_enum_put,
    2985     },
    2986     {0} /* end */
     3326        HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
     3327        HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
     3328        {
     3329                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3330                /* The multiple "Capture Source" controls confuse alsamixer
     3331                * So call somewhat different..
     3332                * FIXME: the controls appear in the "playback" view!
     3333                */
     3334                /* .name = "Capture Source", */
     3335                .name = "Input Source",
     3336                .count = 1,
     3337                .info = alc_mux_enum_info,
     3338                .get = alc_mux_enum_get,
     3339                .put = alc_mux_enum_put,
     3340        },
     3341        {0} /* end */
    29873342};
    29883343
     
    29913346 */
    29923347static struct hda_verb alc260_init_verbs[] = {
    2993     /* Line In pin widget for input */
    2994     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    2995     /* CD pin widget for input */
    2996     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    2997     /* Mic1 (rear panel) pin widget for input and vref at 80% */
    2998     {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    2999     /* Mic2 (front panel) pin widget for input and vref at 80% */
    3000     {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    3001     /* LINE-2 is used for line-out in rear */
    3002     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3003     /* select line-out */
    3004     {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
    3005     /* LINE-OUT pin */
    3006     {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3007     /* enable HP */
    3008     {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    3009     /* enable Mono */
    3010     {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3011     /* mute capture amp left and right */
    3012     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3013     /* set connection select to line in (default select for this ADC) */
    3014     {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
    3015     /* mute capture amp left and right */
    3016     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3017     /* set connection select to line in (default select for this ADC) */
    3018     {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
    3019     /* set vol=0 Line-Out mixer amp left and right */
    3020     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3021     /* unmute pin widget amp left and right (no gain on this amp) */
    3022     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3023     /* set vol=0 HP mixer amp left and right */
    3024     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3025     /* unmute pin widget amp left and right (no gain on this amp) */
    3026     {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3027     /* set vol=0 Mono mixer amp left and right */
    3028     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3029     /* unmute pin widget amp left and right (no gain on this amp) */
    3030     {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3031     /* unmute LINE-2 out pin */
    3032     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3033     /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
    3034     /* mute CD */
    3035     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    3036     /* mute Line In */
    3037     {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    3038     /* mute Mic */
    3039     {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3040     /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
    3041     /* mute Front out path */
    3042     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3043     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3044     /* mute Headphone out path */
    3045     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3046     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3047     /* mute Mono out path */
    3048     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3049     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3050     {0}
     3348        /* Line In pin widget for input */
     3349        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3350        /* CD pin widget for input */
     3351        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3352        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     3353        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3354        /* Mic2 (front panel) pin widget for input and vref at 80% */
     3355        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3356        /* LINE-2 is used for line-out in rear */
     3357        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3358        /* select line-out */
     3359        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
     3360        /* LINE-OUT pin */
     3361        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3362        /* enable HP */
     3363        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3364        /* enable Mono */
     3365        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3366        /* mute capture amp left and right */
     3367        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     3368        /* set connection select to line in (default select for this ADC) */
     3369        {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
     3370        /* mute capture amp left and right */
     3371        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     3372        /* set connection select to line in (default select for this ADC) */
     3373        {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
     3374        /* set vol=0 Line-Out mixer amp left and right */
     3375        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3376        /* unmute pin widget amp left and right (no gain on this amp) */
     3377        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3378        /* set vol=0 HP mixer amp left and right */
     3379        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3380        /* unmute pin widget amp left and right (no gain on this amp) */
     3381        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3382        /* set vol=0 Mono mixer amp left and right */
     3383        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3384        /* unmute pin widget amp left and right (no gain on this amp) */
     3385        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3386        /* unmute LINE-2 out pin */
     3387        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3388        /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
     3389        /* mute CD */
     3390        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     3391        /* mute Line In */
     3392        {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     3393        /* mute Mic */
     3394        {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     3395        /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
     3396        /* mute Front out path */
     3397        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3398        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3399        /* mute Headphone out path */
     3400        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3401        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3402        /* mute Mono out path */
     3403        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3404        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3405        {0}
    30513406};
    30523407
    30533408#if 0 /* should be identical with alc260_init_verbs? */
    30543409static struct hda_verb alc260_hp_init_verbs[] = {
    3055     /* Headphone and output */
    3056     {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
    3057     /* mono output */
    3058     {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    3059     /* Mic1 (rear panel) pin widget for input and vref at 80% */
    3060     {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    3061     /* Mic2 (front panel) pin widget for input and vref at 80% */
    3062     {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    3063     /* Line In pin widget for input */
    3064     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    3065     /* Line-2 pin widget for output */
    3066     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    3067     /* CD pin widget for input */
    3068     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    3069     /* unmute amp left and right */
    3070     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
    3071     /* set connection select to line in (default select for this ADC) */
    3072     {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
    3073     /* unmute Line-Out mixer amp left and right (volume = 0) */
    3074     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    3075     /* mute pin widget amp left and right (no gain on this amp) */
    3076     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    3077     /* unmute HP mixer amp left and right (volume = 0) */
    3078     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    3079     /* mute pin widget amp left and right (no gain on this amp) */
    3080     {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    3081     /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
    3082     /* unmute CD */
    3083     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
    3084     /* unmute Line In */
    3085     {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
    3086     /* unmute Mic */
    3087     {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3088     /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
    3089     /* Unmute Front out path */
    3090     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3091     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    3092     /* Unmute Headphone out path */
    3093     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3094     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    3095     /* Unmute Mono out path */
    3096     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3097     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    3098     {0}
     3410        /* Headphone and output */
     3411        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
     3412        /* mono output */
     3413        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
     3414        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     3415        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     3416        /* Mic2 (front panel) pin widget for input and vref at 80% */
     3417        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     3418        /* Line In pin widget for input */
     3419        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     3420        /* Line-2 pin widget for output */
     3421        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
     3422        /* CD pin widget for input */
     3423        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     3424        /* unmute amp left and right */
     3425        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
     3426        /* set connection select to line in (default select for this ADC) */
     3427        {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
     3428        /* unmute Line-Out mixer amp left and right (volume = 0) */
     3429        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     3430        /* mute pin widget amp left and right (no gain on this amp) */
     3431        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     3432        /* unmute HP mixer amp left and right (volume = 0) */
     3433        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     3434        /* mute pin widget amp left and right (no gain on this amp) */
     3435        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     3436        /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
     3437        /* unmute CD */
     3438        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
     3439        /* unmute Line In */
     3440        {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
     3441        /* unmute Mic */
     3442        {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3443        /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
     3444        /* Unmute Front out path */
     3445        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3446        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     3447        /* Unmute Headphone out path */
     3448        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3449        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     3450        /* Unmute Mono out path */
     3451        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3452        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     3453        {0}
    30993454};
    31003455#endif
    31013456
    31023457static struct hda_verb alc260_hp_3013_init_verbs[] = {
    3103     /* Line out and output */
    3104     {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    3105     /* mono output */
    3106     {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    3107     /* Mic1 (rear panel) pin widget for input and vref at 80% */
    3108     {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    3109     /* Mic2 (front panel) pin widget for input and vref at 80% */
    3110     {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    3111     /* Line In pin widget for input */
    3112     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    3113     /* Headphone pin widget for output */
    3114     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
    3115     /* CD pin widget for input */
    3116     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    3117     /* unmute amp left and right */
    3118     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
    3119     /* set connection select to line in (default select for this ADC) */
    3120     {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
    3121     /* unmute Line-Out mixer amp left and right (volume = 0) */
    3122     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    3123     /* mute pin widget amp left and right (no gain on this amp) */
    3124     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    3125     /* unmute HP mixer amp left and right (volume = 0) */
    3126     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    3127     /* mute pin widget amp left and right (no gain on this amp) */
    3128     {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    3129     /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
    3130     /* unmute CD */
    3131     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
    3132     /* unmute Line In */
    3133     {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
    3134     /* unmute Mic */
    3135     {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3136     /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
    3137     /* Unmute Front out path */
    3138     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3139     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    3140     /* Unmute Headphone out path */
    3141     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3142     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    3143     /* Unmute Mono out path */
    3144     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    3145     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    3146     {0}
     3458        /* Line out and output */
     3459        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
     3460        /* mono output */
     3461        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
     3462        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     3463        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     3464        /* Mic2 (front panel) pin widget for input and vref at 80% */
     3465        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     3466        /* Line In pin widget for input */
     3467        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     3468        /* Headphone pin widget for output */
     3469        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
     3470        /* CD pin widget for input */
     3471        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     3472        /* unmute amp left and right */
     3473        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
     3474        /* set connection select to line in (default select for this ADC) */
     3475        {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
     3476        /* unmute Line-Out mixer amp left and right (volume = 0) */
     3477        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     3478        /* mute pin widget amp left and right (no gain on this amp) */
     3479        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     3480        /* unmute HP mixer amp left and right (volume = 0) */
     3481        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     3482        /* mute pin widget amp left and right (no gain on this amp) */
     3483        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     3484        /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
     3485        /* unmute CD */
     3486        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
     3487        /* unmute Line In */
     3488        {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
     3489        /* unmute Mic */
     3490        {0x07,  AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3491        /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
     3492        /* Unmute Front out path */
     3493        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3494        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     3495        /* Unmute Headphone out path */
     3496        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3497        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     3498        /* Unmute Mono out path */
     3499        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     3500        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     3501        {0}
    31473502};
    31483503
    31493504/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
    3150  * laptops.
     3505 * laptops.  ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
     3506 * audio = 0x16, internal speaker = 0x10.
    31513507 */
    31523508static struct hda_verb alc260_fujitsu_init_verbs[] = {
    3153     /* Disable all GPIOs */
    3154     {0x01, AC_VERB_SET_GPIO_MASK, 0},
    3155     /* Internal speaker is connected to headphone pin */
    3156     {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    3157     /* Headphone/Line-out jack connects to Line1 pin; make it an output */
    3158     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3159     /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
    3160     {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    3161     /* Ensure all other unused pins are disabled and muted. */
    3162     {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3163     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3164     {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3165     {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3166     {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3167     {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3168     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3169     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3170 
    3171     /* Disable digital (SPDIF) pins */
    3172     {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
    3173     {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
    3174 
    3175     /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
    3176     * when acting as an output.
    3177     */
    3178     {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
    3179 
    3180     /* Start with output sum widgets muted and their output gains at min */
    3181     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3182     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3183     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3184     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3185     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3186     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3187     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3188     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3189     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3190 
    3191     /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
    3192     {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3193     /* Unmute Line1 pin widget output buffer since it starts as an output.
    3194     * If the pin mode is changed by the user the pin mode control will
    3195     * take care of enabling the pin's input/output buffers as needed.
    3196     * Therefore there's no need to enable the input buffer at this
    3197     * stage.
    3198     */
    3199     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3200     /* Unmute input buffer of pin widget used for Line-in (no equiv
    3201     * mixer ctrl)
    3202     */
    3203     {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3204 
    3205     /* Mute capture amp left and right */
    3206     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3207     /* Set ADC connection select to match default mixer setting - line
    3208     * in (on mic1 pin)
    3209     */
    3210     {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
    3211 
    3212     /* Do the same for the second ADC: mute capture input amp and
    3213     * set ADC connection to line in (on mic1 pin)
    3214     */
    3215     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3216     {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
    3217 
    3218     /* Mute all inputs to mixer widget (even unconnected ones) */
    3219     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
    3220     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
    3221     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
    3222     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
    3223     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
    3224     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
    3225     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
    3226     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
    3227 
    3228     {0}
     3509        /* Disable all GPIOs */
     3510        {0x01, AC_VERB_SET_GPIO_MASK, 0},
     3511        /* Internal speaker is connected to headphone pin */
     3512        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3513        /* Headphone/Line-out jack connects to Line1 pin; make it an output */
     3514        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3515        /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
     3516        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3517        /* Ensure all other unused pins are disabled and muted. */
     3518        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3519        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3520        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3521        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3522        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3523        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3524        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3525        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3526
     3527        /* Disable digital (SPDIF) pins */
     3528        {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
     3529        {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
     3530
     3531        /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
     3532        * when acting as an output.
     3533        */
     3534        {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
     3535
     3536        /* Start with output sum widgets muted and their output gains at min */
     3537        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3538        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3539        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3540        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3541        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3542        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3543        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3544        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3545        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3546
     3547        /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
     3548        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3549        /* Unmute Line1 pin widget output buffer since it starts as an output.
     3550        * If the pin mode is changed by the user the pin mode control will
     3551        * take care of enabling the pin's input/output buffers as needed.
     3552        * Therefore there's no need to enable the input buffer at this
     3553        * stage.
     3554        */
     3555        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3556        /* Unmute input buffer of pin widget used for Line-in (no equiv
     3557        * mixer ctrl)
     3558        */
     3559        {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     3560
     3561        /* Mute capture amp left and right */
     3562        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3563        /* Set ADC connection select to match default mixer setting - line
     3564        * in (on mic1 pin)
     3565        */
     3566        {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
     3567
     3568        /* Do the same for the second ADC: mute capture input amp and
     3569        * set ADC connection to line in (on mic1 pin)
     3570        */
     3571        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3572        {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
     3573
     3574        /* Mute all inputs to mixer widget (even unconnected ones) */
     3575        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
     3576        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
     3577        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
     3578        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
     3579        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
     3580        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
     3581        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
     3582        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
     3583
     3584        {0}
    32293585};
    32303586
     
    32333589 */
    32343590static struct hda_verb alc260_acer_init_verbs[] = {
    3235     /* On TravelMate laptops, GPIO 0 enables the internal speaker and
    3236      * the headphone jack.  Turn this on and rely on the standard mute
    3237      * methods whenever the user wants to turn these outputs off.
    3238      */
    3239     {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
    3240     {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
    3241     {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
    3242     /* Internal speaker/Headphone jack is connected to Line-out pin */
    3243     {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    3244     /* Internal microphone/Mic jack is connected to Mic1 pin */
    3245     {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
    3246     /* Line In jack is connected to Line1 pin */
    3247     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    3248     /* Ensure all other unused pins are disabled and muted. */
    3249     {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3250     {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3251     {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3252     {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3253     {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3254     {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3255     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
    3256     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3257     /* Disable digital (SPDIF) pins */
    3258     {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
    3259     {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
    3260 
    3261     /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
    3262      * bus when acting as outputs.
    3263      */
    3264     {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
    3265     {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
    3266 
    3267     /* Start with output sum widgets muted and their output gains at min */
    3268     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3269     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3270     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3271     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3272     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3273     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3274     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3275     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3276     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3277 
    3278     /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
    3279     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3280     /* Unmute Mic1 and Line1 pin widget input buffers since they start as
    3281      * inputs. If the pin mode is changed by the user the pin mode control
    3282      * will take care of enabling the pin's input/output buffers as needed.
    3283      * Therefore there's no need to enable the input buffer at this
    3284      * stage.
    3285      */
    3286     {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3287     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3288 
    3289     /* Mute capture amp left and right */
    3290     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3291     /* Set ADC connection select to match default mixer setting - mic
    3292      * (on mic1 pin)
    3293      */
    3294     {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
    3295 
    3296     /* Do similar with the second ADC: mute capture input amp and
    3297      * set ADC connection to line (on line1 pin)
    3298      */
    3299     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3300     {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
    3301 
    3302     /* Mute all inputs to mixer widget (even unconnected ones) */
    3303     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
    3304     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
    3305     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
    3306     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
    3307     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
    3308     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
    3309     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
    3310     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
    3311 
    3312     {0}
     3591        /* On TravelMate laptops, GPIO 0 enables the internal speaker and
     3592         * the headphone jack.  Turn this on and rely on the standard mute
     3593         * methods whenever the user wants to turn these outputs off.
     3594         */
     3595        {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
     3596        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
     3597        {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
     3598        /* Internal speaker/Headphone jack is connected to Line-out pin */
     3599        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3600        /* Internal microphone/Mic jack is connected to Mic1 pin */
     3601        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
     3602        /* Line In jack is connected to Line1 pin */
     3603        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3604        /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
     3605        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3606        /* Ensure all other unused pins are disabled and muted. */
     3607        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3608        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3609        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3610        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3611        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     3612        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3613        /* Disable digital (SPDIF) pins */
     3614        {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
     3615        {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
     3616
     3617        /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
     3618         * bus when acting as outputs.
     3619         */
     3620        {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
     3621        {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
     3622
     3623        /* Start with output sum widgets muted and their output gains at min */
     3624        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3625        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3626        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3627        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3628        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3629        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3630        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3631        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3632        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3633
     3634        /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
     3635        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3636        /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
     3637        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3638        /* Unmute Mic1 and Line1 pin widget input buffers since they start as
     3639         * inputs. If the pin mode is changed by the user the pin mode control
     3640         * will take care of enabling the pin's input/output buffers as needed.
     3641         * Therefore there's no need to enable the input buffer at this
     3642         * stage.
     3643         */
     3644        {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     3645        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     3646
     3647        /* Mute capture amp left and right */
     3648        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3649        /* Set ADC connection select to match default mixer setting - mic
     3650         * (on mic1 pin)
     3651         */
     3652        {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
     3653
     3654        /* Do similar with the second ADC: mute capture input amp and
     3655         * set ADC connection to mic to match ALSA's default state.
     3656         */
     3657        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3658        {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
     3659
     3660        /* Mute all inputs to mixer widget (even unconnected ones) */
     3661        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
     3662        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
     3663        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
     3664        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
     3665        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
     3666        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
     3667        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
     3668        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
     3669
     3670        {0}
    33133671};
    33143672
     
    33183676#ifdef CONFIG_SND_DEBUG
    33193677static hda_nid_t alc260_test_dac_nids[1] = {
    3320     0x02,
     3678        0x02,
    33213679};
    33223680static hda_nid_t alc260_test_adc_nids[2] = {
    3323     0x04, 0x05,
    3324 };
    3325 /* This is a bit messy since the two input muxes in the ALC260 have slight
    3326  * variations in their signal assignments.  The ideal way to deal with this
    3327  * is to extend alc_spec.input_mux to allow a different input MUX for each
    3328  * ADC.  For the purposes of the test model it's sufficient to just list
    3329  * both options for affected signal indices.  The separate input mux
    3330  * functionality only needs to be considered if a model comes along which
    3331  * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
    3332  * record.
    3333  */
    3334 static struct hda_input_mux alc260_test_capture_source = {
    3335     .num_items = 8,
    3336     .items = {
    3337         { "MIC1 pin", 0x0 },
    3338         { "MIC2 pin", 0x1 },
    3339         { "LINE1 pin", 0x2 },
    3340         { "LINE2 pin", 0x3 },
    3341         { "CD pin", 0x4 },
    3342         { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
    3343         { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
    3344         { "HP-OUT pin (cap2 only)", 0x7 },
    3345     },
     3681        0x04, 0x05,
     3682};
     3683/* For testing the ALC260, each input MUX needs its own definition since
     3684 * the signal assignments are different.  This assumes that the first ADC
     3685 * is NID 0x04.
     3686 */
     3687static struct hda_input_mux alc260_test_capture_sources[2] = {
     3688        {
     3689                .num_items = 7,
     3690                .items = {
     3691                        { "MIC1 pin", 0x0 },
     3692                        { "MIC2 pin", 0x1 },
     3693                        { "LINE1 pin", 0x2 },
     3694                        { "LINE2 pin", 0x3 },
     3695                        { "CD pin", 0x4 },
     3696                        { "LINE-OUT pin", 0x5 },
     3697                        { "HP-OUT pin", 0x6 },
     3698                },
     3699        },
     3700        {
     3701                .num_items = 8,
     3702                .items = {
     3703                        { "MIC1 pin", 0x0 },
     3704                        { "MIC2 pin", 0x1 },
     3705                        { "LINE1 pin", 0x2 },
     3706                        { "LINE2 pin", 0x3 },
     3707                        { "CD pin", 0x4 },
     3708                        { "Mixer", 0x5 },
     3709                        { "LINE-OUT pin", 0x6 },
     3710                        { "HP-OUT pin", 0x7 },
     3711                },
     3712        },
    33463713};
    33473714static struct snd_kcontrol_new alc260_test_mixer[] = {
    3348     /* Output driver widgets */
    3349     HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
    3350     HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
    3351     HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
    3352     HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
    3353     HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
    3354     HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
    3355 
    3356     /* Modes for retasking pin widgets */
    3357     ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
    3358     ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
    3359     ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
    3360     ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
    3361     ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
    3362     ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
    3363 
    3364     /* Loopback mixer controls */
    3365     HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
    3366     HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
    3367     HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
    3368     HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
    3369     HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
    3370     HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
    3371     HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
    3372     HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
    3373     HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
    3374     HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
    3375     HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    3376     HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    3377     HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
    3378     HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
    3379     HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
    3380     HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
    3381 
    3382     /* Controls for GPIO pins, assuming they are configured as outputs */
    3383     ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
    3384     ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
    3385     ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
    3386     ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
    3387 
    3388     /* Switches to allow the digital IO pins to be enabled.  The datasheet
    3389      * is ambigious as to which NID is which; testing on laptops which
    3390      * make this output available should provide clarification.
    3391      */
    3392     ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
    3393     ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
    3394 
    3395     {0} /* end */
     3715        /* Output driver widgets */
     3716        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
     3717        HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
     3718        HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
     3719        HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
     3720        HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
     3721        HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
     3722
     3723        /* Modes for retasking pin widgets
     3724         * Note: the ALC260 doesn't seem to act on requests to enable mic
     3725         * bias from NIDs 0x0f and 0x10.  The ALC260 datasheet doesn't
     3726         * mention this restriction.  At this stage it's not clear whether
     3727         * this behaviour is intentional or is a hardware bug in chip
     3728         * revisions available at least up until early 2006.  Therefore for
     3729         * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
     3730         * choices, but if it turns out that the lack of mic bias for these
     3731         * NIDs is intentional we could change their modes from
     3732         * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
     3733         */
     3734        ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
     3735        ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
     3736        ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
     3737        ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
     3738        ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
     3739        ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
     3740
     3741        /* Loopback mixer controls */
     3742        HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
     3743        HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
     3744        HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
     3745        HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
     3746        HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
     3747        HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
     3748        HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
     3749        HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
     3750        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
     3751        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
     3752        HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
     3753        HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
     3754        HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
     3755        HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
     3756        HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
     3757        HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
     3758
     3759        /* Controls for GPIO pins, assuming they are configured as outputs */
     3760        ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
     3761        ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
     3762        ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
     3763        ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
     3764
     3765        /* Switches to allow the digital IO pins to be enabled.  The datasheet
     3766         * is ambigious as to which NID is which; testing on laptops which
     3767         * make this output available should provide clarification.
     3768         */
     3769        ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
     3770        ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
     3771
     3772        {0} /* end */
    33963773};
    33973774static struct hda_verb alc260_test_init_verbs[] = {
    3398     /* Enable all GPIOs as outputs with an initial value of 0 */
    3399     {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
    3400     {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
    3401     {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
    3402 
    3403     /* Enable retasking pins as output, initially without power amp */
    3404     {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3405     {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3406     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3407     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3408     {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3409     {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    3410 
    3411     /* Disable digital (SPDIF) pins initially, but users can enable
    3412     * them via a mixer switch.  In the case of SPDIF-out, this initverb
    3413     * payload also sets the generation to 0, output to be in "consumer"
    3414     * PCM format, copyright asserted, no pre-emphasis and no validity
    3415     * control.
    3416     */
    3417     {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
    3418     {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
    3419 
    3420     /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
    3421     * OUT1 sum bus when acting as an output.
    3422     */
    3423     {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
    3424     {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
    3425     {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
    3426     {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
    3427 
    3428     /* Start with output sum widgets muted and their output gains at min */
    3429     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3430     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3431     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3432     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3433     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3434     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3435     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3436     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    3437     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3438 
    3439     /* Unmute retasking pin widget output buffers since the default
    3440     * state appears to be output.  As the pin mode is changed by the
    3441     * user the pin mode control will take care of enabling the pin's
    3442     * input/output buffers as needed.
    3443     */
    3444     {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3445     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3446     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3447     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3448     {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3449     {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3450     /* Also unmute the mono-out pin widget */
    3451     {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    3452 
    3453     /* Mute capture amp left and right */
    3454     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3455     /* Set ADC connection select to match default mixer setting (mic1
    3456     * pin)
    3457     */
    3458     {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
    3459 
    3460     /* Do the same for the second ADC: mute capture input amp and
    3461     * set ADC connection to mic1 pin
    3462     */
    3463     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    3464     {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
    3465 
    3466     /* Mute all inputs to mixer widget (even unconnected ones) */
    3467     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
    3468     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
    3469     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
    3470     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
    3471     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
    3472     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
    3473     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
    3474     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
    3475 
    3476     {0}
     3775        /* Enable all GPIOs as outputs with an initial value of 0 */
     3776        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
     3777        {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
     3778        {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
     3779
     3780        /* Enable retasking pins as output, initially without power amp */
     3781        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3782        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3783        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3784        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3785        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3786        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     3787
     3788        /* Disable digital (SPDIF) pins initially, but users can enable
     3789        * them via a mixer switch.  In the case of SPDIF-out, this initverb
     3790        * payload also sets the generation to 0, output to be in "consumer"
     3791        * PCM format, copyright asserted, no pre-emphasis and no validity
     3792        * control.
     3793        */
     3794        {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
     3795        {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
     3796
     3797        /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
     3798        * OUT1 sum bus when acting as an output.
     3799        */
     3800        {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
     3801        {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
     3802        {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
     3803        {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
     3804
     3805        /* Start with output sum widgets muted and their output gains at min */
     3806        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3807        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3808        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3809        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3810        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3811        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3812        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3813        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3814        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     3815
     3816        /* Unmute retasking pin widget output buffers since the default
     3817        * state appears to be output.  As the pin mode is changed by the
     3818        * user the pin mode control will take care of enabling the pin's
     3819        * input/output buffers as needed.
     3820        */
     3821        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3822        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3823        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3824        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3825        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3826        {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3827        /* Also unmute the mono-out pin widget */
     3828        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3829
     3830        /* Mute capture amp left and right */
     3831        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3832        /* Set ADC connection select to match default mixer setting (mic1
     3833        * pin)
     3834        */
     3835        {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
     3836
     3837        /* Do the same for the second ADC: mute capture input amp and
     3838        * set ADC connection to mic1 pin
     3839        */
     3840        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3841        {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
     3842
     3843        /* Mute all inputs to mixer widget (even unconnected ones) */
     3844        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
     3845        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
     3846        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
     3847        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
     3848        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
     3849        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
     3850        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
     3851        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
     3852
     3853        {0}
    34773854};
    34783855#endif
    34793856
    34803857static struct hda_pcm_stream alc260_pcm_analog_playback = {
    3481     .substreams = 1,
    3482     .channels_min = 2,
    3483     .channels_max = 2,
     3858        .substreams = 1,
     3859        .channels_min = 2,
     3860        .channels_max = 2,
    34843861};
    34853862
    34863863static struct hda_pcm_stream alc260_pcm_analog_capture = {
    3487     .substreams = 1,
    3488     .channels_min = 2,
    3489     .channels_max = 2,
     3864        .substreams = 1,
     3865        .channels_min = 2,
     3866        .channels_max = 2,
    34903867};
    34913868
     
    34983875
    34993876static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
    3500                                         const char *pfx)
    3501 {
    3502     hda_nid_t nid_vol;
    3503     unsigned long vol_val, sw_val;
    3504     char name[32];
    3505     int err;
    3506 
    3507     if (nid >= 0x0f && nid < 0x11) {
    3508         nid_vol = nid - 0x7;
    3509         vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
    3510         sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
    3511     } else if (nid == 0x11) {
    3512         nid_vol = nid - 0x7;
    3513         vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
    3514         sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
    3515     } else if (nid >= 0x12 && nid <= 0x15) {
    3516         nid_vol = 0x08;
    3517         vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
    3518         sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
    3519     } else
    3520         return 0; /* N/A */
    3521 
    3522     sprintf(name, /*sizeof(name), */"%s Playback Volume", pfx);
    3523     if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
    3524         return err;
    3525     sprintf(name, /*sizeof(name), */"%s Playback Switch", pfx);
    3526     if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
    3527         return err;
    3528     return 1;
     3877                                        const char *pfx)
     3878{
     3879        hda_nid_t nid_vol;
     3880        unsigned long vol_val, sw_val;
     3881        char name[32];
     3882        int err;
     3883
     3884        if (nid >= 0x0f && nid < 0x11) {
     3885                nid_vol = nid - 0x7;
     3886                vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
     3887                sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
     3888        } else if (nid == 0x11) {
     3889                nid_vol = nid - 0x7;
     3890                vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
     3891                sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
     3892        } else if (nid >= 0x12 && nid <= 0x15) {
     3893                nid_vol = 0x08;
     3894                vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
     3895                sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
     3896        } else
     3897                return 0; /* N/A */
     3898       
     3899        sprintf(name, "%s Playback Volume", pfx);
     3900        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
     3901                return err;
     3902        sprintf(name, "%s Playback Switch", pfx);
     3903        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
     3904                return err;
     3905        return 1;
    35293906}
    35303907
    35313908/* add playback controls from the parsed DAC table */
    35323909static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
    3533                                              const struct auto_pin_cfg *cfg)
    3534 {
    3535     hda_nid_t nid;
    3536     int err;
    3537 
    3538     spec->multiout.num_dacs = 1;
    3539     spec->multiout.dac_nids = spec->private_dac_nids;
    3540     spec->multiout.dac_nids[0] = 0x02;
    3541 
    3542     nid = cfg->line_out_pins[0];
    3543     if (nid) {
    3544         err = alc260_add_playback_controls(spec, nid, "Front");
    3545         if (err < 0)
    3546             return err;
    3547     }
    3548 
    3549     nid = cfg->speaker_pins[0];
    3550     if (nid) {
    3551         err = alc260_add_playback_controls(spec, nid, "Speaker");
    3552         if (err < 0)
    3553             return err;
    3554     }
    3555 
    3556     nid = cfg->hp_pin;
    3557     if (nid) {
    3558         err = alc260_add_playback_controls(spec, nid, "Headphone");
    3559         if (err < 0)
    3560             return err;
    3561     }
    3562     return 0;
     3910                                             const struct auto_pin_cfg *cfg)
     3911{
     3912        hda_nid_t nid;
     3913        int err;
     3914
     3915        spec->multiout.num_dacs = 1;
     3916        spec->multiout.dac_nids = spec->private_dac_nids;
     3917        spec->multiout.dac_nids[0] = 0x02;
     3918
     3919        nid = cfg->line_out_pins[0];
     3920        if (nid) {
     3921                err = alc260_add_playback_controls(spec, nid, "Front");
     3922                if (err < 0)
     3923                        return err;
     3924        }
     3925
     3926        nid = cfg->speaker_pins[0];
     3927        if (nid) {
     3928                err = alc260_add_playback_controls(spec, nid, "Speaker");
     3929                if (err < 0)
     3930                        return err;
     3931        }
     3932
     3933        nid = cfg->hp_pins[0];
     3934        if (nid) {
     3935                err = alc260_add_playback_controls(spec, nid, "Headphone");
     3936                if (err < 0)
     3937                        return err;
     3938        }
     3939        return 0;       
    35633940}
    35643941
    35653942/* create playback/capture controls for input pins */
    35663943static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
    3567                                                 const struct auto_pin_cfg *cfg)
    3568 {
    3569     struct hda_input_mux *imux = &spec->private_imux;
    3570     int i, err, idx;
    3571 
    3572     for (i = 0; i < AUTO_PIN_LAST; i++) {
    3573         if (cfg->input_pins[i] >= 0x12) {
    3574             idx = cfg->input_pins[i] - 0x12;
    3575             err = new_analog_input(spec, cfg->input_pins[i],
    3576                                    auto_pin_cfg_labels[i], idx, 0x07);
    3577             if (err < 0)
    3578                 return err;
    3579             imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
    3580             imux->items[imux->num_items].index = idx;
    3581             imux->num_items++;
    3582         }
    3583         if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
    3584             idx = cfg->input_pins[i] - 0x09;
    3585             err = new_analog_input(spec, cfg->input_pins[i],
    3586                                    auto_pin_cfg_labels[i], idx, 0x07);
    3587             if (err < 0)
    3588                 return err;
    3589             imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
    3590             imux->items[imux->num_items].index = idx;
    3591             imux->num_items++;
    3592         }
    3593     }
    3594     return 0;
     3944                                                const struct auto_pin_cfg *cfg)
     3945{
     3946        struct hda_input_mux *imux = &spec->private_imux;
     3947        int i, err, idx;
     3948
     3949        for (i = 0; i < AUTO_PIN_LAST; i++) {
     3950                if (cfg->input_pins[i] >= 0x12) {
     3951                        idx = cfg->input_pins[i] - 0x12;
     3952                        err = new_analog_input(spec, cfg->input_pins[i],
     3953                                               auto_pin_cfg_labels[i], idx, 0x07);
     3954                        if (err < 0)
     3955                                return err;
     3956                        imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
     3957                        imux->items[imux->num_items].index = idx;
     3958                        imux->num_items++;
     3959                }
     3960                if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
     3961                        idx = cfg->input_pins[i] - 0x09;
     3962                        err = new_analog_input(spec, cfg->input_pins[i],
     3963                                               auto_pin_cfg_labels[i], idx, 0x07);
     3964                        if (err < 0)
     3965                                return err;
     3966                        imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
     3967                        imux->items[imux->num_items].index = idx;
     3968                        imux->num_items++;
     3969                }
     3970        }
     3971        return 0;
    35953972}
    35963973
    35973974static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
    3598                                               hda_nid_t nid, int pin_type,
    3599                                               int sel_idx)
    3600 {
    3601     /* set as output */
    3602     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
    3603     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
    3604     /* need the manual connection? */
    3605     if (nid >= 0x12) {
    3606         int idx = nid - 0x12;
    3607         snd_hda_codec_write(codec, idx + 0x0b, 0,
    3608                             AC_VERB_SET_CONNECT_SEL, sel_idx);
    3609 
    3610     }
     3975                                              hda_nid_t nid, int pin_type,
     3976                                              int sel_idx)
     3977{
     3978        /* set as output */
     3979        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
     3980        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
     3981        /* need the manual connection? */
     3982        if (nid >= 0x12) {
     3983                int idx = nid - 0x12;
     3984                snd_hda_codec_write(codec, idx + 0x0b, 0,
     3985                                    AC_VERB_SET_CONNECT_SEL, sel_idx);
     3986                                   
     3987        }
    36113988}
    36123989
    36133990static void alc260_auto_init_multi_out(struct hda_codec *codec)
    36143991{
    3615     struct alc_spec *spec = codec->spec;
    3616     hda_nid_t nid;
    3617 
    3618     nid = spec->autocfg.line_out_pins[0];
    3619     if (nid)
    3620         alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
    3621 
    3622     nid = spec->autocfg.speaker_pins[0];
    3623     if (nid)
    3624         alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
    3625 
    3626     nid = spec->autocfg.hp_pin;
    3627     if (nid)
    3628         alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
    3629 }
     3992        struct alc_spec *spec = codec->spec;
     3993        hda_nid_t nid;
     3994
     3995        nid = spec->autocfg.line_out_pins[0];   
     3996        if (nid)
     3997                alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
     3998       
     3999        nid = spec->autocfg.speaker_pins[0];
     4000        if (nid)
     4001                alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
     4002
     4003        nid = spec->autocfg.hp_pins[0];
     4004        if (nid)
     4005                alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
     4006}       
    36304007
    36314008#define ALC260_PIN_CD_NID               0x16
    36324009static void alc260_auto_init_analog_input(struct hda_codec *codec)
    36334010{
    3634     struct alc_spec *spec = codec->spec;
    3635     int i;
    3636 
    3637     for (i = 0; i < AUTO_PIN_LAST; i++) {
    3638         hda_nid_t nid = spec->autocfg.input_pins[i];
    3639         if (nid >= 0x12) {
    3640             snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    3641                                 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
    3642             if (nid != ALC260_PIN_CD_NID)
    3643                 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    3644                                     AMP_OUT_MUTE);
    3645         }
    3646     }
     4011        struct alc_spec *spec = codec->spec;
     4012        int i;
     4013
     4014        for (i = 0; i < AUTO_PIN_LAST; i++) {
     4015                hda_nid_t nid = spec->autocfg.input_pins[i];
     4016                if (nid >= 0x12) {
     4017                        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     4018                                            i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
     4019                        if (nid != ALC260_PIN_CD_NID)
     4020                                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     4021                                                    AMP_OUT_MUTE);
     4022                }
     4023        }
    36474024}
    36484025
     
    36514028 */
    36524029static struct hda_verb alc260_volume_init_verbs[] = {
    3653     /*
    3654     * Unmute ADC0-1 and set the default input to mic-in
    3655     */
    3656     {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
    3657     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3658     {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
    3659     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3660 
    3661     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    3662     * mixer widget
    3663     * Note: PASD motherboards uses the Line In 2 as the input for front panel
    3664     * mic (mic 2)
    3665     */
    3666     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    3667     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3668     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    3669     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    3670     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    3671     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    3672 
    3673     /*
    3674     * Set up output mixers (0x08 - 0x0a)
    3675     */
    3676     /* set vol=0 to output mixers */
    3677     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3678     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3679     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    3680     /* set up input amps for analog loopback */
    3681     /* Amp Indices: DAC = 0, mixer = 1 */
    3682     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3683     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    3684     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3685     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    3686     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    3687     {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    3688 
    3689     {0}
     4030        /*
     4031        * Unmute ADC0-1 and set the default input to mic-in
     4032        */
     4033        {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
     4034        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4035        {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
     4036        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4037       
     4038        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     4039        * mixer widget
     4040        * Note: PASD motherboards uses the Line In 2 as the input for front panel
     4041        * mic (mic 2)
     4042        */
     4043        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     4044        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4045        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4046        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     4047        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     4048        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     4049
     4050        /*
     4051        * Set up output mixers (0x08 - 0x0a)
     4052        */
     4053        /* set vol=0 to output mixers */
     4054        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4055        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4056        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4057        /* set up input amps for analog loopback */
     4058        /* Amp Indices: DAC = 0, mixer = 1 */
     4059        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4060        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4061        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4062        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4063        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4064        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4065       
     4066        {0}
    36904067};
    36914068
    36924069static int alc260_parse_auto_config(struct hda_codec *codec)
    36934070{
    3694     struct alc_spec *spec = codec->spec;
    3695     unsigned int wcap;
    3696     int err;
    3697     static hda_nid_t alc260_ignore[] = { 0x17, 0 };
    3698 
    3699     if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
    3700                                             alc260_ignore)) < 0)
    3701         return err;
    3702     if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
    3703         return err;
    3704     if (! spec->kctl_alloc)
    3705         return 0; /* can't find valid BIOS pin config */
    3706     if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
    3707         return err;
    3708 
    3709     spec->multiout.max_channels = 2;
    3710 
    3711     if (spec->autocfg.dig_out_pin)
    3712         spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
    3713     if (spec->kctl_alloc)
    3714         spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
    3715 
    3716     spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
    3717 
    3718     spec->input_mux = &spec->private_imux;
    3719 
    3720     /* check whether NID 0x04 is valid */
    3721     wcap = get_wcaps(codec, 0x04);
    3722     wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
    3723     if (wcap != AC_WID_AUD_IN) {
    3724         spec->adc_nids = alc260_adc_nids_alt;
    3725         spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
    3726         spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
    3727     } else {
    3728         spec->adc_nids = alc260_adc_nids;
    3729         spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
    3730         spec->mixers[spec->num_mixers] = alc260_capture_mixer;
    3731     }
    3732     spec->num_mixers++;
    3733 
    3734     return 1;
     4071        struct alc_spec *spec = codec->spec;
     4072        unsigned int wcap;
     4073        int err;
     4074        static hda_nid_t alc260_ignore[] = { 0x17, 0 };
     4075
     4076        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
     4077                                                alc260_ignore)) < 0)
     4078                return err;
     4079        if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
     4080                return err;
     4081        if (! spec->kctl_alloc)
     4082                return 0; /* can't find valid BIOS pin config */
     4083        if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
     4084                return err;
     4085
     4086        spec->multiout.max_channels = 2;
     4087
     4088        if (spec->autocfg.dig_out_pin)
     4089                spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
     4090        if (spec->kctl_alloc)
     4091                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
     4092
     4093        spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
     4094
     4095        spec->num_mux_defs = 1;
     4096        spec->input_mux = &spec->private_imux;
     4097
     4098        /* check whether NID 0x04 is valid */
     4099        wcap = get_wcaps(codec, 0x04);
     4100        wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
     4101        if (wcap != AC_WID_AUD_IN) {
     4102                spec->adc_nids = alc260_adc_nids_alt;
     4103                spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
     4104                spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
     4105        } else {
     4106                spec->adc_nids = alc260_adc_nids;
     4107                spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
     4108                spec->mixers[spec->num_mixers] = alc260_capture_mixer;
     4109        }
     4110        spec->num_mixers++;
     4111
     4112        return 1;
    37354113}
    37364114
     
    37384116static void alc260_auto_init(struct hda_codec *codec)
    37394117{
    3740     alc260_auto_init_multi_out(codec);
    3741     alc260_auto_init_analog_input(codec);
     4118        alc260_auto_init_multi_out(codec);
     4119        alc260_auto_init_analog_input(codec);
    37424120}
    37434121
     
    37454123 * ALC260 configurations
    37464124 */
    3747 static struct hda_board_config alc260_cfg_tbl[] = {
    3748     { .modelname = "basic", .config = ALC260_BASIC },
    3749     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
    3750     .config = ALC260_BASIC }, /* Sony VAIO */
    3751     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
    3752     .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
    3753     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
    3754     .config = ALC260_BASIC }, /* Sony VAIO */
    3755     { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
    3756     .config = ALC260_BASIC }, /* CTL Travel Master U553W */
    3757     { .modelname = "hp", .config = ALC260_HP },
    3758     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
    3759     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
    3760     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
    3761     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
    3762     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
    3763     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
    3764     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
    3765     { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
    3766     { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
    3767     { .modelname = "acer", .config = ALC260_ACER },
    3768     { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
     4125static const char *alc260_models[ALC260_MODEL_LAST] = {
     4126        [ALC260_BASIC]          = "basic",
     4127        [ALC260_HP]             = "hp",
     4128        [ALC260_HP_3013]        = "hp-3013",
     4129        [ALC260_FUJITSU_S702X]  = "fujitsu",
     4130        [ALC260_ACER]           = "acer",
    37694131#ifdef CONFIG_SND_DEBUG
    3770     { .modelname = "test", .config = ALC260_TEST },
     4132        [ALC260_TEST]           = "test",
    37714133#endif
    3772     { .modelname = "auto", .config = ALC260_AUTO },
    3773     {0}
     4134        [ALC260_AUTO]           = "auto",
     4135};
     4136
     4137static struct snd_pci_quirk alc260_cfg_tbl[] = {
     4138        SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
     4139        SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
     4140        SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
     4141        SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
     4142        SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
     4143        SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
     4144        SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
     4145        SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
     4146        SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
     4147        SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
     4148        SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
     4149        SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
     4150        SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
     4151        SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
     4152        {0}
    37744153};
    37754154
    37764155static struct alc_config_preset alc260_presets[] = {
    3777     [ALC260_BASIC] = {
    3778         .mixers = { alc260_base_output_mixer,
    3779         alc260_input_mixer,
    3780         alc260_pc_beep_mixer,
    3781         alc260_capture_mixer },
    3782         .init_verbs = { alc260_init_verbs },
    3783         .num_dacs = ARRAY_SIZE(alc260_dac_nids),
    3784         .dac_nids = alc260_dac_nids,
    3785         .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
    3786         .adc_nids = alc260_adc_nids,
    3787         .num_channel_mode = ARRAY_SIZE(alc260_modes),
    3788         .channel_mode = alc260_modes,
    3789         .input_mux = &alc260_capture_source,
    3790     },
    3791     [ALC260_HP] = {
    3792         .mixers = { alc260_base_output_mixer,
    3793         alc260_input_mixer,
    3794         alc260_capture_alt_mixer },
    3795         .init_verbs = { alc260_init_verbs },
    3796         .num_dacs = ARRAY_SIZE(alc260_dac_nids),
    3797         .dac_nids = alc260_dac_nids,
    3798         .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
    3799         .adc_nids = alc260_hp_adc_nids,
    3800         .num_channel_mode = ARRAY_SIZE(alc260_modes),
    3801         .channel_mode = alc260_modes,
    3802         .input_mux = &alc260_capture_source,
    3803     },
    3804     [ALC260_HP_3013] = {
    3805         .mixers = { alc260_hp_3013_mixer,
    3806         alc260_input_mixer,
    3807         alc260_capture_alt_mixer },
    3808         .init_verbs = { alc260_hp_3013_init_verbs },
    3809         .num_dacs = ARRAY_SIZE(alc260_dac_nids),
    3810         .dac_nids = alc260_dac_nids,
    3811         .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
    3812         .adc_nids = alc260_hp_adc_nids,
    3813         .num_channel_mode = ARRAY_SIZE(alc260_modes),
    3814         .channel_mode = alc260_modes,
    3815         .input_mux = &alc260_capture_source,
    3816     },
    3817     [ALC260_FUJITSU_S702X] = {
    3818         .mixers = { alc260_fujitsu_mixer,
    3819         alc260_capture_mixer },
    3820         .init_verbs = { alc260_fujitsu_init_verbs },
    3821         .num_dacs = ARRAY_SIZE(alc260_dac_nids),
    3822         .dac_nids = alc260_dac_nids,
    3823         .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
    3824         .adc_nids = alc260_dual_adc_nids,
    3825         .num_channel_mode = ARRAY_SIZE(alc260_modes),
    3826         .channel_mode = alc260_modes,
    3827         .input_mux = &alc260_fujitsu_capture_source,
    3828     },
    3829     [ALC260_ACER] = {
    3830         .mixers = { alc260_acer_mixer,
    3831         alc260_capture_mixer },
    3832         .init_verbs = { alc260_acer_init_verbs },
    3833         .num_dacs = ARRAY_SIZE(alc260_dac_nids),
    3834         .dac_nids = alc260_dac_nids,
    3835         .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
    3836         .adc_nids = alc260_dual_adc_nids,
    3837         .num_channel_mode = ARRAY_SIZE(alc260_modes),
    3838         .channel_mode = alc260_modes,
    3839         .input_mux = &alc260_acer_capture_source,
    3840     },
     4156        [ALC260_BASIC] = {
     4157                .mixers = { alc260_base_output_mixer,
     4158                            alc260_input_mixer,
     4159                            alc260_pc_beep_mixer,
     4160                            alc260_capture_mixer },
     4161                .init_verbs = { alc260_init_verbs },
     4162                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     4163                .dac_nids = alc260_dac_nids,
     4164                .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
     4165                .adc_nids = alc260_adc_nids,
     4166                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     4167                .channel_mode = alc260_modes,
     4168                .input_mux = &alc260_capture_source,
     4169        },
     4170        [ALC260_HP] = {
     4171                .mixers = { alc260_base_output_mixer,
     4172                            alc260_input_mixer,
     4173                            alc260_capture_alt_mixer },
     4174                .init_verbs = { alc260_init_verbs },
     4175                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     4176                .dac_nids = alc260_dac_nids,
     4177                .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
     4178                .adc_nids = alc260_hp_adc_nids,
     4179                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     4180                .channel_mode = alc260_modes,
     4181                .input_mux = &alc260_capture_source,
     4182        },
     4183        [ALC260_HP_3013] = {
     4184                .mixers = { alc260_hp_3013_mixer,
     4185                            alc260_input_mixer,
     4186                            alc260_capture_alt_mixer },
     4187                .init_verbs = { alc260_hp_3013_init_verbs },
     4188                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     4189                .dac_nids = alc260_dac_nids,
     4190                .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
     4191                .adc_nids = alc260_hp_adc_nids,
     4192                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     4193                .channel_mode = alc260_modes,
     4194                .input_mux = &alc260_capture_source,
     4195        },
     4196        [ALC260_FUJITSU_S702X] = {
     4197                .mixers = { alc260_fujitsu_mixer,
     4198                            alc260_capture_mixer },
     4199                .init_verbs = { alc260_fujitsu_init_verbs },
     4200                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     4201                .dac_nids = alc260_dac_nids,
     4202                .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
     4203                .adc_nids = alc260_dual_adc_nids,
     4204                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     4205                .channel_mode = alc260_modes,
     4206                .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
     4207                .input_mux = alc260_fujitsu_capture_sources,
     4208        },
     4209        [ALC260_ACER] = {
     4210                .mixers = { alc260_acer_mixer,
     4211                            alc260_capture_mixer },
     4212                .init_verbs = { alc260_acer_init_verbs },
     4213                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     4214                .dac_nids = alc260_dac_nids,
     4215                .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
     4216                .adc_nids = alc260_dual_adc_nids,
     4217                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     4218                .channel_mode = alc260_modes,
     4219                .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
     4220                .input_mux = alc260_acer_capture_sources,
     4221        },
    38414222#ifdef CONFIG_SND_DEBUG
    3842     [ALC260_TEST] = {
    3843         .mixers = { alc260_test_mixer,
    3844         alc260_capture_mixer },
    3845         .init_verbs = { alc260_test_init_verbs },
    3846         .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
    3847         .dac_nids = alc260_test_dac_nids,
    3848         .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
    3849         .adc_nids = alc260_test_adc_nids,
    3850         .num_channel_mode = ARRAY_SIZE(alc260_modes),
    3851         .channel_mode = alc260_modes,
    3852         .input_mux = &alc260_test_capture_source,
    3853     },
     4223        [ALC260_TEST] = {
     4224                .mixers = { alc260_test_mixer,
     4225                            alc260_capture_mixer },
     4226                .init_verbs = { alc260_test_init_verbs },
     4227                .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
     4228                .dac_nids = alc260_test_dac_nids,
     4229                .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
     4230                .adc_nids = alc260_test_adc_nids,
     4231                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     4232                .channel_mode = alc260_modes,
     4233                .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
     4234                .input_mux = alc260_test_capture_sources,
     4235        },
    38544236#endif
    38554237};
     
    38574239static int patch_alc260(struct hda_codec *codec)
    38584240{
    3859     struct alc_spec *spec;
    3860     int err, board_config;
    3861 
    3862     spec = kzalloc(sizeof(*spec), GFP_KERNEL);
    3863     if (spec == NULL)
    3864         return -ENOMEM;
    3865 
    3866     codec->spec = spec;
    3867 
    3868     board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
    3869     if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
    3870         snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
    3871         board_config = ALC260_AUTO;
    3872     }
    3873 
    3874     if (board_config == ALC260_AUTO) {
    3875         /* automatic parse from the BIOS config */
    3876         err = alc260_parse_auto_config(codec);
    3877         if (err < 0) {
    3878             alc_free(codec);
    3879             return err;
    3880         } else if (! err) {
    3881             printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS.  Using base mode...\n");
    3882             board_config = ALC260_BASIC;
    3883         }
    3884     }
    3885 
    3886     if (board_config != ALC260_AUTO)
    3887         setup_preset(spec, &alc260_presets[board_config]);
    3888 
    3889     spec->stream_name_analog = "ALC260 Analog";
    3890     spec->stream_analog_playback = &alc260_pcm_analog_playback;
    3891     spec->stream_analog_capture = &alc260_pcm_analog_capture;
    3892 
    3893     spec->stream_name_digital = "ALC260 Digital";
    3894     spec->stream_digital_playback = &alc260_pcm_digital_playback;
    3895     spec->stream_digital_capture = &alc260_pcm_digital_capture;
    3896 
    3897     codec->patch_ops = alc_patch_ops;
    3898     if (board_config == ALC260_AUTO)
    3899         spec->init_hook = alc260_auto_init;
    3900 
    3901     return 0;
     4241        struct alc_spec *spec;
     4242        int err, board_config;
     4243
     4244        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     4245        if (spec == NULL)
     4246                return -ENOMEM;
     4247
     4248        codec->spec = spec;
     4249
     4250        board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
     4251                                                  alc260_models,
     4252                                                  alc260_cfg_tbl);
     4253        if (board_config < 0) {
     4254                snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
     4255                           "trying auto-probe from BIOS...\n");
     4256                board_config = ALC260_AUTO;
     4257        }
     4258
     4259        if (board_config == ALC260_AUTO) {
     4260                /* automatic parse from the BIOS config */
     4261                err = alc260_parse_auto_config(codec);
     4262                if (err < 0) {
     4263                        alc_free(codec);
     4264                        return err;
     4265                } else if (! err) {
     4266                        printk(KERN_INFO
     4267                               "hda_codec: Cannot set up configuration "
     4268                               "from BIOS.  Using base mode...\n");
     4269                        board_config = ALC260_BASIC;
     4270                }
     4271        }
     4272
     4273        if (board_config != ALC260_AUTO)
     4274                setup_preset(spec, &alc260_presets[board_config]);
     4275
     4276        spec->stream_name_analog = "ALC260 Analog";
     4277        spec->stream_analog_playback = &alc260_pcm_analog_playback;
     4278        spec->stream_analog_capture = &alc260_pcm_analog_capture;
     4279
     4280        spec->stream_name_digital = "ALC260 Digital";
     4281        spec->stream_digital_playback = &alc260_pcm_digital_playback;
     4282        spec->stream_digital_capture = &alc260_pcm_digital_capture;
     4283
     4284        codec->patch_ops = alc_patch_ops;
     4285        if (board_config == ALC260_AUTO)
     4286                spec->init_hook = alc260_auto_init;
     4287
     4288        return 0;
    39024289}
    39034290
     
    39184305
    39194306static struct hda_channel_mode alc882_ch_modes[1] = {
    3920     { 8, NULL }
     4307        { 8, NULL }
    39214308};
    39224309
    39234310static hda_nid_t alc882_dac_nids[4] = {
    3924     /* front, rear, clfe, rear_surr */
    3925     0x02, 0x03, 0x04, 0x05
     4311        /* front, rear, clfe, rear_surr */
     4312        0x02, 0x03, 0x04, 0x05
    39264313};
    39274314
     
    39344321
    39354322static struct hda_input_mux alc882_capture_source = {
    3936     .num_items = 4,
    3937     .items = {
    3938         { "Mic", 0x0 },
    3939         { "Front Mic", 0x1 },
    3940         { "Line", 0x2 },
    3941         { "CD", 0x4 },
    3942     },
    3943 };
    3944 
     4323        .num_items = 4,
     4324        .items = {
     4325                { "Mic", 0x0 },
     4326                { "Front Mic", 0x1 },
     4327                { "Line", 0x2 },
     4328                { "CD", 0x4 },
     4329        },
     4330};
    39454331#define alc882_mux_enum_info alc_mux_enum_info
    39464332#define alc882_mux_enum_get alc_mux_enum_get
     
    39484334static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    39494335{
    3950     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    3951     struct alc_spec *spec = codec->spec;
    3952     const struct hda_input_mux *imux = spec->input_mux;
    3953     unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    3954     static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
    3955     hda_nid_t nid = capture_mixers[adc_idx];
    3956     unsigned int *cur_val = &spec->cur_mux[adc_idx];
    3957     unsigned int i, idx;
    3958 
    3959     idx = ucontrol->value.enumerated.item[0];
    3960     if (idx >= imux->num_items)
    3961         idx = imux->num_items - 1;
    3962     if (*cur_val == idx && ! codec->in_resume)
    3963         return 0;
    3964     for (i = 0; i < imux->num_items; i++) {
    3965         unsigned int v = (i == idx) ? 0x7000 : 0x7080;
    3966         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    3967                             v | (imux->items[i].index << 8));
    3968     }
    3969     *cur_val = idx;
    3970     return 1;
     4336        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     4337        struct alc_spec *spec = codec->spec;
     4338        const struct hda_input_mux *imux = spec->input_mux;
     4339        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
     4340        static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
     4341        hda_nid_t nid = capture_mixers[adc_idx];
     4342        unsigned int *cur_val = &spec->cur_mux[adc_idx];
     4343        unsigned int i, idx;
     4344
     4345        idx = ucontrol->value.enumerated.item[0];
     4346        if (idx >= imux->num_items)
     4347                idx = imux->num_items - 1;
     4348        if (*cur_val == idx && ! codec->in_resume)
     4349                return 0;
     4350        for (i = 0; i < imux->num_items; i++) {
     4351                unsigned int v = (i == idx) ? 0x7000 : 0x7080;
     4352                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     4353                                    v | (imux->items[i].index << 8));
     4354        }
     4355        *cur_val = idx;
     4356        return 1;
    39714357}
    39724358
     
    39754361 */
    39764362static struct hda_verb alc882_sixstack_ch6_init[] = {
    3977     { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
    3978     { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3979     { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3980     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3981     {0} /* end */
     4363        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     4364        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4365        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4366        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4367        {0} /* end */
    39824368};
    39834369
     
    39864372 */
    39874373static struct hda_verb alc882_sixstack_ch8_init[] = {
    3988     { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3989     { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3990     { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3991     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    3992     {0} /* end */
     4374        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4375        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4376        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4377        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     4378        {0} /* end */
    39934379};
    39944380
    39954381static struct hda_channel_mode alc882_sixstack_modes[2] = {
    3996     { 6, alc882_sixstack_ch6_init },
    3997     { 8, alc882_sixstack_ch8_init },
     4382        { 6, alc882_sixstack_ch6_init },
     4383        { 8, alc882_sixstack_ch8_init },
    39984384};
    39994385
     
    40024388 */
    40034389static struct snd_kcontrol_new alc882_base_mixer[] = {
    4004     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    4005     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    4006     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    4007     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    4008     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    4009     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    4010     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    4011     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    4012     HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    4013     HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    4014     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    4015     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    4016     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    4017     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    4018     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    4019     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    4020     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    4021     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    4022     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    4023     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    4024     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    4025     {0} /* end */
     4390        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     4391        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     4392        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     4393        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     4394        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     4395        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     4396        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     4397        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     4398        HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     4399        HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
     4400        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     4401        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     4402        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     4403        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     4404        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     4405        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     4406        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     4407        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     4408        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     4409        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     4410        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     4411        {0} /* end */
    40264412};
    40274413
    40284414static struct snd_kcontrol_new alc882_chmode_mixer[] = {
    4029     {
    4030         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4031         .name = "Channel Mode",
    4032         .info = alc_ch_mode_info,
    4033         .get = alc_ch_mode_get,
    4034         .put = alc_ch_mode_put,
    4035     },
    4036     {0} /* end */
     4415        {
     4416                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     4417                .name = "Channel Mode",
     4418                .info = alc_ch_mode_info,
     4419                .get = alc_ch_mode_get,
     4420                .put = alc_ch_mode_put,
     4421        },
     4422        {0} /* end */
    40374423};
    40384424
    40394425static struct hda_verb alc882_init_verbs[] = {
    4040     /* Front mixer: unmute input/output amp left and right (volume = 0) */
    4041     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4042     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4043     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4044     /* Rear mixer */
    4045     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4046     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4047     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4048     /* CLFE mixer */
    4049     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4050     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4051     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4052     /* Side mixer */
    4053     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4054     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4055     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4056 
    4057     /* Front Pin: output 0 (0x0c) */
    4058     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4059     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4060     {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
    4061     /* Rear Pin: output 1 (0x0d) */
    4062     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4063     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4064     {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
    4065     /* CLFE Pin: output 2 (0x0e) */
    4066     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4067     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4068     {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
    4069     /* Side Pin: output 3 (0x0f) */
    4070     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4071     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4072     {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
    4073     /* Mic (rear) pin: input vref at 80% */
    4074     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    4075     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    4076     /* Front Mic pin: input vref at 80% */
    4077     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    4078     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    4079     /* Line In pin: input */
    4080     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    4081     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    4082     /* Line-2 In: Headphone output (output 0 - 0x0c) */
    4083     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    4084     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4085     {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
    4086     /* CD pin widget for input */
    4087     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    4088 
    4089     /* FIXME: use matrix-type input source selection */
    4090     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    4091     /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
    4092     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4093     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
    4094     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
    4095     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
    4096     /* Input mixer2 */
    4097     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4098     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
    4099     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
    4100     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
    4101     /* Input mixer3 */
    4102     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4103     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
    4104     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
    4105     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
    4106     /* ADC1: mute amp left and right */
    4107     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4108     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    4109     /* ADC2: mute amp left and right */
    4110     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4111     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    4112     /* ADC3: mute amp left and right */
    4113     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4114     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    4115 
    4116     {0}
    4117 };
     4426        /* Front mixer: unmute input/output amp left and right (volume = 0) */
     4427        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4428        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4429        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     4430        /* Rear mixer */
     4431        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4432        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4433        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     4434        /* CLFE mixer */
     4435        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4436        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4437        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     4438        /* Side mixer */
     4439        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4440        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4441        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     4442
     4443        /* Front Pin: output 0 (0x0c) */
     4444        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     4445        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4446        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     4447        /* Rear Pin: output 1 (0x0d) */
     4448        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     4449        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4450        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
     4451        /* CLFE Pin: output 2 (0x0e) */
     4452        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     4453        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4454        {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
     4455        /* Side Pin: output 3 (0x0f) */
     4456        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     4457        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4458        {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
     4459        /* Mic (rear) pin: input vref at 80% */
     4460        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     4461        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     4462        /* Front Mic pin: input vref at 80% */
     4463        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     4464        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     4465        /* Line In pin: input */
     4466        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     4467        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     4468        /* Line-2 In: Headphone output (output 0 - 0x0c) */
     4469        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     4470        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4471        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
     4472        /* CD pin widget for input */
     4473        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     4474
     4475        /* FIXME: use matrix-type input source selection */
     4476        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     4477        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
     4478        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4479        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     4480        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     4481        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     4482        /* Input mixer2 */
     4483        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4484        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     4485        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     4486        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     4487        /* Input mixer3 */
     4488        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4489        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     4490        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     4491        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     4492        /* ADC1: mute amp left and right */
     4493        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4494        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     4495        /* ADC2: mute amp left and right */
     4496        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4497        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     4498        /* ADC3: mute amp left and right */
     4499        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4500        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     4501
     4502        {0}
     4503};
     4504
     4505static struct hda_verb alc882_eapd_verbs[] = {
     4506        /* change to EAPD mode */
     4507        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     4508        {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
     4509        {0}
     4510};
     4511
     4512
     4513/* Mac Pro test */
     4514static struct snd_kcontrol_new alc882_macpro_mixer[] = {
     4515        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     4516        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     4517        HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
     4518        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
     4519        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
     4520        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
     4521        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
     4522        {0} /* end */
     4523};
     4524 
     4525static struct hda_verb alc882_macpro_init_verbs[] = {
     4526        /* Front mixer: unmute input/output amp left and right (volume = 0) */
     4527        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4528        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4529        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     4530        /* Front Pin: output 0 (0x0c) */
     4531        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     4532        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4533        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
     4534        /* Front Mic pin: input vref at 80% */
     4535        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     4536        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     4537        /* Speaker:  output */
     4538        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     4539        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4540        {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
     4541        /* Headphone output (output 0 - 0x0c) */
     4542        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     4543        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     4544        {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
     4545
     4546        /* FIXME: use matrix-type input source selection */
     4547        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     4548        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
     4549        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4550        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     4551        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     4552        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     4553        /* Input mixer2 */
     4554        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4555        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     4556        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     4557        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     4558        /* Input mixer3 */
     4559        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4560        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     4561        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     4562        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     4563        /* ADC1: mute amp left and right */
     4564        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4565        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     4566        /* ADC2: mute amp left and right */
     4567        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4568        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     4569        /* ADC3: mute amp left and right */
     4570        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     4571        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     4572
     4573        {0}
     4574};
     4575static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
     4576{
     4577        unsigned int gpiostate, gpiomask, gpiodir;
     4578
     4579        gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
     4580                                       AC_VERB_GET_GPIO_DATA, 0);
     4581
     4582        if (!muted)
     4583                gpiostate |= (1 << pin);
     4584        else
     4585                gpiostate &= ~(1 << pin);
     4586
     4587        gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
     4588                                      AC_VERB_GET_GPIO_MASK, 0);
     4589        gpiomask |= (1 << pin);
     4590
     4591        gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
     4592                                     AC_VERB_GET_GPIO_DIRECTION, 0);
     4593        gpiodir |= (1 << pin);
     4594
     4595
     4596        snd_hda_codec_write(codec, codec->afg, 0,
     4597                            AC_VERB_SET_GPIO_MASK, gpiomask);
     4598        snd_hda_codec_write(codec, codec->afg, 0,
     4599                            AC_VERB_SET_GPIO_DIRECTION, gpiodir);
     4600
     4601        msleep(1);
     4602
     4603        snd_hda_codec_write(codec, codec->afg, 0,
     4604                            AC_VERB_SET_GPIO_DATA, gpiostate);
     4605}
     4606
    41184607
    41194608/*
     
    41214610 */
    41224611static struct hda_verb alc882_auto_init_verbs[] = {
    4123     /*
    4124     * Unmute ADC0-2 and set the default input to mic-in
    4125     */
    4126     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    4127     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4128     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    4129     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4130     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    4131     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4132 
    4133     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    4134     * mixer widget
    4135     * Note: PASD motherboards uses the Line In 2 as the input for front panel
    4136     * mic (mic 2)
    4137     */
    4138     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    4139     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4140     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4141     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4142     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    4143     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4144 
    4145     /*
    4146     * Set up output mixers (0x0c - 0x0f)
    4147     */
    4148     /* set vol=0 to output mixers */
    4149     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4150     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4151     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4152     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4153     /* set up input amps for analog loopback */
    4154     /* Amp Indices: DAC = 0, mixer = 1 */
    4155     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4156     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4157     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4158     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4159     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4160     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4161     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4162     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4163     {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4164     {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4165 
    4166     /* FIXME: use matrix-type input source selection */
    4167     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    4168     /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
    4169     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    4170     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    4171     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    4172     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    4173     /* Input mixer2 */
    4174     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    4175     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    4176     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    4177     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    4178     /* Input mixer3 */
    4179     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    4180     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    4181     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    4182     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    4183 
    4184     {0}
     4612        /*
     4613        * Unmute ADC0-2 and set the default input to mic-in
     4614        */
     4615        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     4616        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4617        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     4618        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4619        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     4620        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4621
     4622        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     4623        * mixer widget
     4624        * Note: PASD motherboards uses the Line In 2 as the input for front panel
     4625        * mic (mic 2)
     4626        */
     4627        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     4628        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4629        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4630        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     4631        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     4632        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     4633
     4634        /*
     4635        * Set up output mixers (0x0c - 0x0f)
     4636        */
     4637        /* set vol=0 to output mixers */
     4638        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4639        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4640        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4641        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     4642        /* set up input amps for analog loopback */
     4643        /* Amp Indices: DAC = 0, mixer = 1 */
     4644        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4645        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4646        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4647        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4648        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4649        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4650        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4651        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4652        {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     4653        {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     4654
     4655        /* FIXME: use matrix-type input source selection */
     4656        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     4657        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
     4658        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     4659        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     4660        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     4661        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     4662        /* Input mixer2 */
     4663        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     4664        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     4665        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     4666        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     4667        /* Input mixer3 */
     4668        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     4669        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     4670        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     4671        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     4672
     4673        {0}
    41854674};
    41864675
    41874676/* capture mixer elements */
    41884677static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
    4189     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    4190     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    4191     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    4192     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    4193     {
    4194         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4195         /* The multiple "Capture Source" controls confuse alsamixer
    4196         * So call somewhat different..
    4197         * FIXME: the controls appear in the "playback" view!
    4198         */
    4199         /* .name = "Capture Source", */
    4200         .name = "Input Source",
    4201         .count = 2,
    4202         .info = alc882_mux_enum_info,
    4203         .get = alc882_mux_enum_get,
    4204         .put = alc882_mux_enum_put,
    4205     },
    4206     {0} /* end */
     4678        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     4679        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     4680        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     4681        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     4682        {
     4683                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     4684                /* The multiple "Capture Source" controls confuse alsamixer
     4685                * So call somewhat different..
     4686                * FIXME: the controls appear in the "playback" view!
     4687                */
     4688                /* .name = "Capture Source", */
     4689                .name = "Input Source",
     4690                .count = 2,
     4691                .info = alc882_mux_enum_info,
     4692                .get = alc882_mux_enum_get,
     4693                .put = alc882_mux_enum_put,
     4694        },
     4695        {0} /* end */
    42074696};
    42084697
    42094698static struct snd_kcontrol_new alc882_capture_mixer[] = {
    4210     HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
    4211     HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
    4212     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
    4213     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
    4214     HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
    4215     HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
    4216     {
    4217         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4218         /* The multiple "Capture Source" controls confuse alsamixer
    4219         * So call somewhat different..
    4220         * FIXME: the controls appear in the "playback" view!
    4221         */
    4222         /* .name = "Capture Source", */
    4223         .name = "Input Source",
    4224         .count = 3,
    4225         .info = alc882_mux_enum_info,
    4226         .get = alc882_mux_enum_get,
    4227         .put = alc882_mux_enum_put,
    4228     },
    4229     {0} /* end */
     4699        HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
     4700        HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
     4701        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
     4702        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
     4703        HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
     4704        HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
     4705        {
     4706                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     4707                /* The multiple "Capture Source" controls confuse alsamixer
     4708                * So call somewhat different..
     4709                * FIXME: the controls appear in the "playback" view!
     4710                */
     4711                /* .name = "Capture Source", */
     4712                .name = "Input Source",
     4713                .count = 3,
     4714                .info = alc882_mux_enum_info,
     4715                .get = alc882_mux_enum_get,
     4716                .put = alc882_mux_enum_put,
     4717        },
     4718        {0} /* end */
    42304719};
    42314720
     
    42394728 * configuration and preset
    42404729 */
    4241 static struct hda_board_config alc882_cfg_tbl[] = {
    4242     { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
    4243     { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
    4244     { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI  */
    4245     { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
    4246     { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
    4247     { .modelname = "auto", .config = ALC882_AUTO },
    4248     {0}
     4730static const char *alc882_models[ALC882_MODEL_LAST] = {
     4731        [ALC882_3ST_DIG]        = "3stack-dig",
     4732        [ALC882_6ST_DIG]        = "6stack-dig",
     4733        [ALC882_ARIMA]          = "arima",
     4734        [ALC885_MACPRO]         = "macpro",
     4735        [ALC882_AUTO]           = "auto",
     4736};
     4737
     4738static struct snd_pci_quirk alc882_cfg_tbl[] = {
     4739        SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
     4740        SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
     4741        SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
     4742        SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
     4743        SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
     4744        {0}
    42494745};
    42504746
    42514747static struct alc_config_preset alc882_presets[] = {
    4252     [ALC882_3ST_DIG] = {
    4253         .mixers = { alc882_base_mixer },
    4254         .init_verbs = { alc882_init_verbs },
    4255         .num_dacs = ARRAY_SIZE(alc882_dac_nids),
    4256         .dac_nids = alc882_dac_nids,
    4257         .dig_out_nid = ALC882_DIGOUT_NID,
    4258         .dig_in_nid = ALC882_DIGIN_NID,
    4259         .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
    4260         .channel_mode = alc882_ch_modes,
    4261         .input_mux = &alc882_capture_source,
    4262     },
    4263     [ALC882_6ST_DIG] = {
    4264         .mixers = { alc882_base_mixer, alc882_chmode_mixer },
    4265         .init_verbs = { alc882_init_verbs },
    4266         .num_dacs = ARRAY_SIZE(alc882_dac_nids),
    4267         .dac_nids = alc882_dac_nids,
    4268         .dig_out_nid = ALC882_DIGOUT_NID,
    4269         .dig_in_nid = ALC882_DIGIN_NID,
    4270         .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
    4271         .channel_mode = alc882_sixstack_modes,
    4272         .input_mux = &alc882_capture_source,
    4273     },
     4748        [ALC882_3ST_DIG] = {
     4749                .mixers = { alc882_base_mixer },
     4750                .init_verbs = { alc882_init_verbs },
     4751                .num_dacs = ARRAY_SIZE(alc882_dac_nids),
     4752                .dac_nids = alc882_dac_nids,
     4753                .dig_out_nid = ALC882_DIGOUT_NID,
     4754                .dig_in_nid = ALC882_DIGIN_NID,
     4755                .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
     4756                .channel_mode = alc882_ch_modes,
     4757                .need_dac_fix = 1,
     4758                .input_mux = &alc882_capture_source,
     4759        },
     4760        [ALC882_6ST_DIG] = {
     4761                .mixers = { alc882_base_mixer, alc882_chmode_mixer },
     4762                .init_verbs = { alc882_init_verbs },
     4763                .num_dacs = ARRAY_SIZE(alc882_dac_nids),
     4764                .dac_nids = alc882_dac_nids,
     4765                .dig_out_nid = ALC882_DIGOUT_NID,
     4766                .dig_in_nid = ALC882_DIGIN_NID,
     4767                .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
     4768                .channel_mode = alc882_sixstack_modes,
     4769                .input_mux = &alc882_capture_source,
     4770        },
     4771        [ALC882_ARIMA] = {
     4772                .mixers = { alc882_base_mixer, alc882_chmode_mixer },
     4773                .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
     4774                .num_dacs = ARRAY_SIZE(alc882_dac_nids),
     4775                .dac_nids = alc882_dac_nids,
     4776                .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
     4777                .channel_mode = alc882_sixstack_modes,
     4778                .input_mux = &alc882_capture_source,
     4779        },
     4780        [ALC885_MACPRO] = {
     4781                .mixers = { alc882_macpro_mixer },
     4782                .init_verbs = { alc882_macpro_init_verbs },
     4783                .num_dacs = ARRAY_SIZE(alc882_dac_nids),
     4784                .dac_nids = alc882_dac_nids,
     4785                .dig_out_nid = ALC882_DIGOUT_NID,
     4786                .dig_in_nid = ALC882_DIGIN_NID,
     4787                .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
     4788                .channel_mode = alc882_ch_modes,
     4789                .input_mux = &alc882_capture_source,
     4790        },
    42744791};
    42754792
     
    42794796 */
    42804797static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
    4281                                               hda_nid_t nid, int pin_type,
    4282                                               int dac_idx)
    4283 {
    4284     /* set as output */
    4285     struct alc_spec *spec = codec->spec;
    4286     int idx;
    4287 
    4288     if (spec->multiout.dac_nids[dac_idx] == 0x25)
    4289         idx = 4;
    4290     else
    4291         idx = spec->multiout.dac_nids[dac_idx] - 2;
    4292 
    4293     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
    4294     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
    4295     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
     4798                                              hda_nid_t nid, int pin_type,
     4799                                              int dac_idx)
     4800{
     4801        /* set as output */
     4802        struct alc_spec *spec = codec->spec;
     4803        int idx;
     4804       
     4805        if (spec->multiout.dac_nids[dac_idx] == 0x25)
     4806                idx = 4;
     4807        else
     4808                idx = spec->multiout.dac_nids[dac_idx] - 2;
     4809
     4810        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
     4811        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
     4812        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
    42964813
    42974814}
     
    42994816static void alc882_auto_init_multi_out(struct hda_codec *codec)
    43004817{
    4301     struct alc_spec *spec = codec->spec;
    4302     int i;
    4303 
    4304     for (i = 0; i <= HDA_SIDE; i++) {
    4305         hda_nid_t nid = spec->autocfg.line_out_pins[i];
    4306         if (nid)
    4307             alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
    4308     }
     4818        struct alc_spec *spec = codec->spec;
     4819        int i;
     4820
     4821        for (i = 0; i <= HDA_SIDE; i++) {
     4822                hda_nid_t nid = spec->autocfg.line_out_pins[i];
     4823                if (nid)
     4824                        alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
     4825        }
    43094826}
    43104827
    43114828static void alc882_auto_init_hp_out(struct hda_codec *codec)
    43124829{
    4313     struct alc_spec *spec = codec->spec;
    4314     hda_nid_t pin;
    4315 
    4316     pin = spec->autocfg.hp_pin;
    4317     if (pin) /* connect to front */
    4318         alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
     4830        struct alc_spec *spec = codec->spec;
     4831        hda_nid_t pin;
     4832
     4833        pin = spec->autocfg.hp_pins[0];
     4834        if (pin) /* connect to front */
     4835                alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
    43194836}
    43204837
     
    43244841static void alc882_auto_init_analog_input(struct hda_codec *codec)
    43254842{
    4326     struct alc_spec *spec = codec->spec;
    4327     int i;
    4328 
    4329     for (i = 0; i < AUTO_PIN_LAST; i++) {
    4330         hda_nid_t nid = spec->autocfg.input_pins[i];
    4331         if (alc882_is_input_pin(nid)) {
    4332             snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    4333                                 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
    4334             if (nid != ALC882_PIN_CD_NID)
    4335                 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    4336                                     AMP_OUT_MUTE);
    4337         }
    4338     }
     4843        struct alc_spec *spec = codec->spec;
     4844        int i;
     4845
     4846        for (i = 0; i < AUTO_PIN_LAST; i++) {
     4847                hda_nid_t nid = spec->autocfg.input_pins[i];
     4848                if (alc882_is_input_pin(nid)) {
     4849                        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     4850                                            i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
     4851                        if (nid != ALC882_PIN_CD_NID)
     4852                                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     4853                                                    AMP_OUT_MUTE);
     4854                }
     4855        }
    43394856}
    43404857
     
    43424859static int alc882_parse_auto_config(struct hda_codec *codec)
    43434860{
    4344     struct alc_spec *spec = codec->spec;
    4345     int err = alc880_parse_auto_config(codec);
    4346 
    4347     if (err < 0)
    4348         return err;
    4349     else if (err > 0)
    4350         /* hack - override the init verbs */
    4351         spec->init_verbs[0] = alc882_auto_init_verbs;
    4352     return err;
     4861        struct alc_spec *spec = codec->spec;
     4862        int err = alc880_parse_auto_config(codec);
     4863
     4864        if (err < 0)
     4865                return err;
     4866        else if (err > 0)
     4867                /* hack - override the init verbs */
     4868                spec->init_verbs[0] = alc882_auto_init_verbs;
     4869        return err;
    43534870}
    43544871
     
    43564873static void alc882_auto_init(struct hda_codec *codec)
    43574874{
    4358     alc882_auto_init_multi_out(codec);
    4359     alc882_auto_init_hp_out(codec);
    4360     alc882_auto_init_analog_input(codec);
     4875        alc882_auto_init_multi_out(codec);
     4876        alc882_auto_init_hp_out(codec);
     4877        alc882_auto_init_analog_input(codec);
    43614878}
    43624879
    43634880static int patch_alc882(struct hda_codec *codec)
    43644881{
    4365     struct alc_spec *spec;
    4366     int err, board_config;
    4367 
    4368     spec = kzalloc(sizeof(*spec), GFP_KERNEL);
    4369     if (spec == NULL)
    4370         return -ENOMEM;
    4371 
    4372     codec->spec = spec;
    4373 
    4374     board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
    4375 
    4376     if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
    4377         printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
    4378         board_config = ALC882_AUTO;
    4379     }
    4380 
    4381     if (board_config == ALC882_AUTO) {
    4382         /* automatic parse from the BIOS config */
    4383         err = alc882_parse_auto_config(codec);
    4384         if (err < 0) {
    4385             alc_free(codec);
    4386             return err;
    4387         } else if (! err) {
    4388             printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS.  Using base mode...\n");
    4389             board_config = ALC882_3ST_DIG;
    4390         }
    4391     }
    4392 
    4393     if (board_config != ALC882_AUTO)
    4394         setup_preset(spec, &alc882_presets[board_config]);
    4395 
    4396     spec->stream_name_analog = "ALC882 Analog";
    4397     spec->stream_analog_playback = &alc882_pcm_analog_playback;
    4398     spec->stream_analog_capture = &alc882_pcm_analog_capture;
    4399 
    4400     spec->stream_name_digital = "ALC882 Digital";
    4401     spec->stream_digital_playback = &alc882_pcm_digital_playback;
    4402     spec->stream_digital_capture = &alc882_pcm_digital_capture;
    4403 
    4404     if (! spec->adc_nids && spec->input_mux) {
    4405         /* check whether NID 0x07 is valid */
    4406         unsigned int wcap = get_wcaps(codec, 0x07);
    4407         wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
    4408         if (wcap != AC_WID_AUD_IN) {
    4409             spec->adc_nids = alc882_adc_nids_alt;
    4410             spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
    4411             spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
    4412             spec->num_mixers++;
    4413         } else {
    4414             spec->adc_nids = alc882_adc_nids;
    4415             spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
    4416             spec->mixers[spec->num_mixers] = alc882_capture_mixer;
    4417             spec->num_mixers++;
    4418         }
    4419     }
    4420 
    4421     codec->patch_ops = alc_patch_ops;
    4422     if (board_config == ALC882_AUTO)
    4423         spec->init_hook = alc882_auto_init;
    4424 
    4425     return 0;
     4882        struct alc_spec *spec;
     4883        int err, board_config;
     4884
     4885        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     4886        if (spec == NULL)
     4887                return -ENOMEM;
     4888
     4889        codec->spec = spec;
     4890
     4891        board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
     4892                                                  alc882_models,
     4893                                                  alc882_cfg_tbl);
     4894
     4895        if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
     4896                printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
     4897                       "trying auto-probe from BIOS...\n");
     4898                board_config = ALC882_AUTO;
     4899        }
     4900
     4901        if (board_config == ALC882_AUTO) {
     4902                /* automatic parse from the BIOS config */
     4903                err = alc882_parse_auto_config(codec);
     4904                if (err < 0) {
     4905                        alc_free(codec);
     4906                        return err;
     4907                } else if (! err) {
     4908                        printk(KERN_INFO
     4909                               "hda_codec: Cannot set up configuration "
     4910                               "from BIOS.  Using base mode...\n");
     4911                        board_config = ALC882_3ST_DIG;
     4912                }
     4913        }
     4914
     4915        if (board_config != ALC882_AUTO)
     4916                setup_preset(spec, &alc882_presets[board_config]);
     4917
     4918        if (board_config == ALC885_MACPRO) {
     4919                alc882_gpio_mute(codec, 0, 0);
     4920                alc882_gpio_mute(codec, 1, 0);
     4921        }
     4922
     4923        spec->stream_name_analog = "ALC882 Analog";
     4924        spec->stream_analog_playback = &alc882_pcm_analog_playback;
     4925        spec->stream_analog_capture = &alc882_pcm_analog_capture;
     4926
     4927        spec->stream_name_digital = "ALC882 Digital";
     4928        spec->stream_digital_playback = &alc882_pcm_digital_playback;
     4929        spec->stream_digital_capture = &alc882_pcm_digital_capture;
     4930
     4931        if (! spec->adc_nids && spec->input_mux) {
     4932                /* check whether NID 0x07 is valid */
     4933                unsigned int wcap = get_wcaps(codec, 0x07);
     4934                wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
     4935                if (wcap != AC_WID_AUD_IN) {
     4936                        spec->adc_nids = alc882_adc_nids_alt;
     4937                        spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
     4938                        spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
     4939                        spec->num_mixers++;
     4940                } else {
     4941                        spec->adc_nids = alc882_adc_nids;
     4942                        spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
     4943                        spec->mixers[spec->num_mixers] = alc882_capture_mixer;
     4944                        spec->num_mixers++;
     4945                }
     4946        }
     4947
     4948        codec->patch_ops = alc_patch_ops;
     4949        if (board_config == ALC882_AUTO)
     4950                spec->init_hook = alc882_auto_init;
     4951
     4952        return 0;
    44264953}
    44274954
     
    44414968
    44424969static hda_nid_t alc883_dac_nids[4] = {
    4443     /* front, rear, clfe, rear_surr */
    4444     0x02, 0x04, 0x03, 0x05
     4970        /* front, rear, clfe, rear_surr */
     4971        0x02, 0x04, 0x03, 0x05
    44454972};
    44464973
    44474974static hda_nid_t alc883_adc_nids[2] = {
    4448     /* ADC1-2 */
    4449     0x08, 0x09,
     4975        /* ADC1-2 */
     4976        0x08, 0x09,
    44504977};
    44514978/* input MUX */
     
    44534980
    44544981static struct hda_input_mux alc883_capture_source = {
    4455     .num_items = 4,
    4456     .items = {
    4457         { "Mic", 0x0 },
    4458         { "Front Mic", 0x1 },
    4459         { "Line", 0x2 },
    4460         { "CD", 0x4 },
    4461     },
     4982        .num_items = 4,
     4983        .items = {
     4984                { "Mic", 0x0 },
     4985                { "Front Mic", 0x1 },
     4986                { "Line", 0x2 },
     4987                { "CD", 0x4 },
     4988        },
    44624989};
    44634990#define alc883_mux_enum_info alc_mux_enum_info
     
    44654992
    44664993static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
    4467                                struct snd_ctl_elem_value *ucontrol)
    4468 {
    4469     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    4470     struct alc_spec *spec = codec->spec;
    4471     const struct hda_input_mux *imux = spec->input_mux;
    4472     unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    4473     static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
    4474     hda_nid_t nid = capture_mixers[adc_idx];
    4475     unsigned int *cur_val = &spec->cur_mux[adc_idx];
    4476     unsigned int i, idx;
    4477 
    4478     idx = ucontrol->value.enumerated.item[0];
    4479     if (idx >= imux->num_items)
    4480         idx = imux->num_items - 1;
    4481     if (*cur_val == idx && ! codec->in_resume)
    4482         return 0;
    4483     for (i = 0; i < imux->num_items; i++) {
    4484         unsigned int v = (i == idx) ? 0x7000 : 0x7080;
    4485         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    4486                             v | (imux->items[i].index << 8));
    4487     }
    4488     *cur_val = idx;
    4489     return 1;
     4994                               struct snd_ctl_elem_value *ucontrol)
     4995{
     4996        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     4997        struct alc_spec *spec = codec->spec;
     4998        const struct hda_input_mux *imux = spec->input_mux;
     4999        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
     5000        static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
     5001        hda_nid_t nid = capture_mixers[adc_idx];
     5002        unsigned int *cur_val = &spec->cur_mux[adc_idx];
     5003        unsigned int i, idx;
     5004
     5005        idx = ucontrol->value.enumerated.item[0];
     5006        if (idx >= imux->num_items)
     5007                idx = imux->num_items - 1;
     5008        if (*cur_val == idx && ! codec->in_resume)
     5009                return 0;
     5010        for (i = 0; i < imux->num_items; i++) {
     5011                unsigned int v = (i == idx) ? 0x7000 : 0x7080;
     5012                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     5013                                    v | (imux->items[i].index << 8));
     5014        }
     5015        *cur_val = idx;
     5016        return 1;
    44905017}
    44915018/*
     
    44935020 */
    44945021static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
    4495     { 2, NULL }
     5022        { 2, NULL }
    44965023};
    44975024
     
    45005027 */
    45015028static struct hda_verb alc883_3ST_ch2_init[] = {
    4502     { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    4503     { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    4504     { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
    4505     { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    4506     {0} /* end */
     5029        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     5030        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     5031        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     5032        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     5033        {0} /* end */
    45075034};
    45085035
     
    45115038 */
    45125039static struct hda_verb alc883_3ST_ch6_init[] = {
    4513     { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4514     { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    4515     { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
    4516     { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4517     { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    4518     { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
    4519     {0} /* end */
     5040        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5041        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     5042        { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
     5043        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5044        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     5045        { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
     5046        {0} /* end */
    45205047};
    45215048
    45225049static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
    4523     { 2, alc883_3ST_ch2_init },
    4524     { 6, alc883_3ST_ch6_init },
     5050        { 2, alc883_3ST_ch2_init },
     5051        { 6, alc883_3ST_ch6_init },
    45255052};
    45265053
     
    45295056 */
    45305057static struct hda_verb alc883_sixstack_ch6_init[] = {
    4531     { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
    4532     { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4533     { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4534     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4535     {0} /* end */
     5058        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     5059        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5060        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5061        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5062        {0} /* end */
    45365063};
    45375064
     
    45405067 */
    45415068static struct hda_verb alc883_sixstack_ch8_init[] = {
    4542     { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4543     { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4544     { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4545     { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    4546     {0} /* end */
     5069        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5070        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5071        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5072        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     5073        {0} /* end */
    45475074};
    45485075
    45495076static struct hda_channel_mode alc883_sixstack_modes[2] = {
    4550     { 6, alc883_sixstack_ch6_init },
    4551     { 8, alc883_sixstack_ch8_init },
     5077        { 6, alc883_sixstack_ch6_init },
     5078        { 8, alc883_sixstack_ch8_init },
     5079};
     5080
     5081static struct hda_verb alc883_medion_eapd_verbs[] = {
     5082        /* eanable EAPD on medion laptop */
     5083        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     5084        {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
     5085        {0}
    45525086};
    45535087
     
    45575091
    45585092static struct snd_kcontrol_new alc883_base_mixer[] = {
    4559     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    4560     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    4561     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    4562     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    4563     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    4564     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    4565     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    4566     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    4567     HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    4568     HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    4569     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    4570     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    4571     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    4572     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    4573     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    4574     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    4575     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    4576     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    4577     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    4578     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    4579     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    4580     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    4581     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    4582     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    4583     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    4584     {
    4585         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4586         /* .name = "Capture Source", */
    4587         .name = "Input Source",
    4588         .count = 2,
    4589         .info = alc883_mux_enum_info,
    4590         .get = alc883_mux_enum_get,
    4591         .put = alc883_mux_enum_put,
    4592     },
    4593     {0} /* end */
     5093        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5094        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     5095        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     5096        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     5097        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     5098        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     5099        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     5100        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     5101        HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     5102        HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
     5103        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5104        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5105        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5106        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5107        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5108        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5109        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5110        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     5111        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     5112        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5113        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     5114        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5115        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5116        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     5117        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     5118        {
     5119                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5120                /* .name = "Capture Source", */
     5121                .name = "Input Source",
     5122                .count = 2,
     5123                .info = alc883_mux_enum_info,
     5124                .get = alc883_mux_enum_get,
     5125                .put = alc883_mux_enum_put,
     5126        },
     5127        {0} /* end */
    45945128};
    45955129
    45965130static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
    4597     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    4598     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    4599     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    4600     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    4601     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    4602     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    4603     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    4604     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    4605     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    4606     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    4607     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    4608     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    4609     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    4610     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    4611     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    4612     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    4613     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    4614     {
    4615         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4616         /* .name = "Capture Source", */
    4617         .name = "Input Source",
    4618         .count = 2,
    4619         .info = alc883_mux_enum_info,
    4620         .get = alc883_mux_enum_get,
    4621         .put = alc883_mux_enum_put,
    4622     },
    4623     {0} /* end */
     5131        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5132        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     5133        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5134        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5135        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5136        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5137        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5138        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5139        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5140        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     5141        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     5142        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5143        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     5144        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5145        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5146        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     5147        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     5148        {
     5149                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5150                /* .name = "Capture Source", */
     5151                .name = "Input Source",
     5152                .count = 2,
     5153                .info = alc883_mux_enum_info,
     5154                .get = alc883_mux_enum_get,
     5155                .put = alc883_mux_enum_put,
     5156        },
     5157        {0} /* end */
    46245158};
    46255159
    46265160static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
    4627     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    4628     HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    4629     HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    4630     HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    4631     HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    4632     HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    4633     HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    4634     HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    4635     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    4636     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    4637     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    4638     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    4639     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    4640     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    4641     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    4642     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    4643     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    4644     HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    4645     HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    4646     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    4647     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    4648     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    4649     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    4650     {
    4651         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4652         /* .name = "Capture Source", */
    4653         .name = "Input Source",
    4654         .count = 2,
    4655         .info = alc883_mux_enum_info,
    4656         .get = alc883_mux_enum_get,
    4657         .put = alc883_mux_enum_put,
    4658     },
    4659     {0} /* end */
    4660 };
     5161        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5162        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     5163        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     5164        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     5165        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     5166        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     5167        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     5168        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     5169        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5170        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5171        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5172        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5173        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5174        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5175        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5176        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     5177        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     5178        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5179        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     5180        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5181        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5182        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     5183        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     5184        {
     5185                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5186                /* .name = "Capture Source", */
     5187                .name = "Input Source",
     5188                .count = 2,
     5189                .info = alc883_mux_enum_info,
     5190                .get = alc883_mux_enum_get,
     5191                .put = alc883_mux_enum_put,
     5192        },
     5193        {0} /* end */
     5194};
     5195
     5196static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
     5197        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5198        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     5199        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     5200        HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     5201        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     5202        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     5203        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
     5204        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
     5205        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5206        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5207        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5208        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5209        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5210        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5211        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5212        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     5213        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     5214        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5215        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     5216        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5217        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5218
     5219        {
     5220                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5221                /* .name = "Capture Source", */
     5222                .name = "Input Source",
     5223                .count = 1,
     5224                .info = alc883_mux_enum_info,
     5225                .get = alc883_mux_enum_get,
     5226                .put = alc883_mux_enum_put,
     5227        },
     5228        {0} /* end */
     5229};
     5230
     5231static struct snd_kcontrol_new alc883_tagra_mixer[] = {
     5232        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5233        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     5234        HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5235        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     5236        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     5237        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
     5238        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     5239        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     5240        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     5241        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5242        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5243        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5244        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5245        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5246        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5247        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5248        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5249        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     5250        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     5251        {
     5252                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5253                /* .name = "Capture Source", */
     5254                .name = "Input Source",
     5255                .count = 2,
     5256                .info = alc883_mux_enum_info,
     5257                .get = alc883_mux_enum_get,
     5258                .put = alc883_mux_enum_put,
     5259        },
     5260        {0} /* end */
     5261};     
     5262
     5263static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
     5264        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5265        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     5266        HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5267        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5268        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5269        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5270        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5271        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5272        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5273        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     5274        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     5275        {
     5276                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5277                /* .name = "Capture Source", */
     5278                .name = "Input Source",
     5279                .count = 2,
     5280                .info = alc883_mux_enum_info,
     5281                .get = alc883_mux_enum_get,
     5282                .put = alc883_mux_enum_put,
     5283        },
     5284        {0} /* end */
     5285};     
    46615286
    46625287static struct snd_kcontrol_new alc883_chmode_mixer[] = {
    4663     {
    4664         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4665         .name = "Channel Mode",
    4666         .info = alc_ch_mode_info,
    4667         .get = alc_ch_mode_get,
    4668         .put = alc_ch_mode_put,
    4669     },
    4670     {0} /* end */
     5288        {
     5289                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5290                .name = "Channel Mode",
     5291                .info = alc_ch_mode_info,
     5292                .get = alc_ch_mode_get,
     5293                .put = alc_ch_mode_put,
     5294        },
     5295        {0} /* end */
    46715296};
    46725297
    46735298static struct hda_verb alc883_init_verbs[] = {
    4674     /* ADC1: mute amp left and right */
    4675     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4676     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    4677     /* ADC2: mute amp left and right */
    4678     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4679     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    4680     /* Front mixer: unmute input/output amp left and right (volume = 0) */
    4681     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4682     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4683     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4684     /* Rear mixer */
    4685     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4686     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4687     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4688     /* CLFE mixer */
    4689     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4690     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4691     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4692     /* Side mixer */
    4693     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4694     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    4695     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    4696 
    4697     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4698     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4699     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4700     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    4701     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4702 
    4703     /* Front Pin: output 0 (0x0c) */
    4704     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4705     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4706     {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
    4707     /* Rear Pin: output 1 (0x0d) */
    4708     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4709     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4710     {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
    4711     /* CLFE Pin: output 2 (0x0e) */
    4712     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4713     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4714     {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
    4715     /* Side Pin: output 3 (0x0f) */
    4716     {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    4717     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4718     {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
    4719     /* Mic (rear) pin: input vref at 80% */
    4720     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    4721     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    4722     /* Front Mic pin: input vref at 80% */
    4723     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    4724     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    4725     /* Line In pin: input */
    4726     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    4727     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    4728     /* Line-2 In: Headphone output (output 0 - 0x0c) */
    4729     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    4730     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    4731     {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
    4732     /* CD pin widget for input */
    4733     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    4734 
    4735     /* FIXME: use matrix-type input source selection */
    4736     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    4737     /* Input mixer2 */
    4738     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4739     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4740     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4741     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4742     /* Input mixer3 */
    4743     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4744     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4745     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4746     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4747     {0}
    4748 };
     5299        /* ADC1: mute amp left and right */
     5300        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5301        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     5302        /* ADC2: mute amp left and right */
     5303        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5304        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     5305        /* Front mixer: unmute input/output amp left and right (volume = 0) */
     5306        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5307        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5308        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5309        /* Rear mixer */
     5310        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5311        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5312        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5313        /* CLFE mixer */
     5314        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5315        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5316        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5317        /* Side mixer */
     5318        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5319        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5320        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5321
     5322        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5323        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5324        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5325        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     5326        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5327
     5328        /* Front Pin: output 0 (0x0c) */
     5329        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     5330        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     5331        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     5332        /* Rear Pin: output 1 (0x0d) */
     5333        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     5334        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     5335        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
     5336        /* CLFE Pin: output 2 (0x0e) */
     5337        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     5338        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     5339        {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
     5340        /* Side Pin: output 3 (0x0f) */
     5341        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     5342        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     5343        {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
     5344        /* Mic (rear) pin: input vref at 80% */
     5345        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     5346        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     5347        /* Front Mic pin: input vref at 80% */
     5348        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     5349        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     5350        /* Line In pin: input */
     5351        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     5352        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     5353        /* Line-2 In: Headphone output (output 0 - 0x0c) */
     5354        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     5355        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     5356        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
     5357        /* CD pin widget for input */
     5358        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     5359
     5360        /* FIXME: use matrix-type input source selection */
     5361        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     5362        /* Input mixer2 */
     5363        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5364        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5365        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5366        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5367        /* Input mixer3 */
     5368        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5369        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5370        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5371        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5372        {0}
     5373};
     5374
     5375static struct hda_verb alc883_tagra_verbs[] = {
     5376        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5377        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5378
     5379        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     5380        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     5381       
     5382        {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
     5383        {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
     5384        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     5385
     5386        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     5387        {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
     5388        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
     5389        {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
     5390
     5391        {0} /* end */
     5392};
     5393
     5394/* toggle speaker-output according to the hp-jack state */
     5395static void alc883_tagra_automute(struct hda_codec *codec)
     5396{
     5397        unsigned int present;
     5398
     5399        present = snd_hda_codec_read(codec, 0x14, 0,
     5400                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     5401        snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
     5402                                 0x80, present ? 0x80 : 0);
     5403        snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
     5404                                 0x80, present ? 0x80 : 0);
     5405        snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
     5406}
     5407
     5408static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
     5409{
     5410        if ((res >> 26) == ALC880_HP_EVENT)
     5411                alc883_tagra_automute(codec);
     5412}
    47495413
    47505414/*
     
    47525416 */
    47535417static struct hda_verb alc883_auto_init_verbs[] = {
    4754     /*
    4755     * Unmute ADC0-2 and set the default input to mic-in
    4756     */
    4757     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    4758     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4759     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    4760     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4761 
    4762     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    4763     * mixer widget
    4764     * Note: PASD motherboards uses the Line In 2 as the input for front panel
    4765     * mic (mic 2)
    4766     */
    4767     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    4768     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4769     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4770     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4771     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    4772     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4773 
    4774     /*
    4775     * Set up output mixers (0x0c - 0x0f)
    4776     */
    4777     /* set vol=0 to output mixers */
    4778     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4779     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4780     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4781     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    4782     /* set up input amps for analog loopback */
    4783     /* Amp Indices: DAC = 0, mixer = 1 */
    4784     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4785     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4786     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4787     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4788     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4789     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4790     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4791     {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4792     {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4793     {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4794 
    4795     /* FIXME: use matrix-type input source selection */
    4796     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    4797     /* Input mixer1 */
    4798     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4799     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4800     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4801     //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    4802     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4803     /* Input mixer2 */
    4804     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    4805     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    4806     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    4807     //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    4808     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    4809 
    4810     {0}
     5418        /*
     5419        * Unmute ADC0-2 and set the default input to mic-in
     5420        */
     5421        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     5422        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5423        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     5424        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5425
     5426        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     5427        * mixer widget
     5428        * Note: PASD motherboards uses the Line In 2 as the input for front panel
     5429        * mic (mic 2)
     5430        */
     5431        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     5432        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5433        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5434        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5435        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     5436        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5437
     5438        /*
     5439        * Set up output mixers (0x0c - 0x0f)
     5440        */
     5441        /* set vol=0 to output mixers */
     5442        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5443        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5444        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5445        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5446        /* set up input amps for analog loopback */
     5447        /* Amp Indices: DAC = 0, mixer = 1 */
     5448        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5449        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5450        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5451        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5452        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5453        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5454        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5455        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5456        {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5457        {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5458
     5459        /* FIXME: use matrix-type input source selection */
     5460        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     5461        /* Input mixer1 */
     5462        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5463        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5464        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5465        //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     5466        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5467        /* Input mixer2 */
     5468        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5469        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5470        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5471        //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     5472        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5473
     5474        {0}
    48115475};
    48125476
    48135477/* capture mixer elements */
    48145478static struct snd_kcontrol_new alc883_capture_mixer[] = {
    4815     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    4816     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    4817     HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    4818     HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    4819     {
    4820         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4821         /* The multiple "Capture Source" controls confuse alsamixer
    4822         * So call somewhat different..
    4823         * FIXME: the controls appear in the "playback" view!
    4824         */
    4825         /* .name = "Capture Source", */
    4826         .name = "Input Source",
    4827         .count = 2,
    4828         .info = alc882_mux_enum_info,
    4829         .get = alc882_mux_enum_get,
    4830         .put = alc882_mux_enum_put,
    4831     },
    4832     {0} /* end */
     5479        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     5480        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     5481        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     5482        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     5483        {
     5484                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     5485                /* The multiple "Capture Source" controls confuse alsamixer
     5486                * So call somewhat different..
     5487                * FIXME: the controls appear in the "playback" view!
     5488                */
     5489                /* .name = "Capture Source", */
     5490                .name = "Input Source",
     5491                .count = 2,
     5492                .info = alc882_mux_enum_info,
     5493                .get = alc882_mux_enum_get,
     5494                .put = alc882_mux_enum_put,
     5495        },
     5496        {0} /* end */
    48335497};
    48345498
     
    48425506 * configuration and preset
    48435507 */
    4844 static struct hda_board_config alc883_cfg_tbl[] = {
    4845     { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
    4846     { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
    4847     { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
    4848     { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
    4849     .config = ALC883_6ST_DIG }, /* MSI  */
    4850     { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
    4851     .config = ALC883_6ST_DIG }, /* Foxconn */
    4852     { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
    4853     .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
    4854     { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
    4855     .config = ALC883_3ST_6ch },
    4856     { .modelname = "auto", .config = ALC883_AUTO },
    4857     {0}
     5508static const char *alc883_models[ALC883_MODEL_LAST] = {
     5509        [ALC883_3ST_2ch_DIG]    = "3stack-dig",
     5510        [ALC883_3ST_6ch_DIG]    = "3stack-6ch-dig",
     5511        [ALC883_3ST_6ch]        = "3stack-6ch",
     5512        [ALC883_6ST_DIG]        = "6stack-dig",
     5513        [ALC883_TARGA_DIG]      = "targa-dig",
     5514        [ALC883_TARGA_2ch_DIG]  = "targa-2ch-dig",
     5515        [ALC888_DEMO_BOARD]     = "6stack-dig-demo",
     5516        [ALC883_ACER]           = "acer",
     5517        [ALC883_MEDION]         = "medion",
     5518        [ALC883_LAPTOP_EAPD]    = "laptop-eapd",
     5519        [ALC883_AUTO]           = "auto",
     5520};
     5521
     5522static struct snd_pci_quirk alc883_cfg_tbl[] = {
     5523        SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
     5524        SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
     5525        SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
     5526        SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
     5527        SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
     5528        SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
     5529        SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
     5530        SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
     5531        SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
     5532        SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
     5533        SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
     5534        SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
     5535        SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
     5536        SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
     5537        SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
     5538        SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
     5539        SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
     5540        SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
     5541        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
     5542        SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
     5543        SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
     5544        {0}
    48585545};
    48595546
    48605547static struct alc_config_preset alc883_presets[] = {
    4861     [ALC883_3ST_2ch_DIG] = {
    4862         .mixers = { alc883_3ST_2ch_mixer },
    4863         .init_verbs = { alc883_init_verbs },
    4864         .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    4865         .dac_nids = alc883_dac_nids,
    4866         .dig_out_nid = ALC883_DIGOUT_NID,
    4867         .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    4868         .adc_nids = alc883_adc_nids,
    4869         .dig_in_nid = ALC883_DIGIN_NID,
    4870         .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    4871         .channel_mode = alc883_3ST_2ch_modes,
    4872         .input_mux = &alc883_capture_source,
    4873     },
    4874     [ALC883_3ST_6ch_DIG] = {
    4875         .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
    4876         .init_verbs = { alc883_init_verbs },
    4877         .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    4878         .dac_nids = alc883_dac_nids,
    4879         .dig_out_nid = ALC883_DIGOUT_NID,
    4880         .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    4881         .adc_nids = alc883_adc_nids,
    4882         .dig_in_nid = ALC883_DIGIN_NID,
    4883         .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
    4884         .channel_mode = alc883_3ST_6ch_modes,
    4885         .input_mux = &alc883_capture_source,
    4886     },
    4887     [ALC883_3ST_6ch] = {
    4888         .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
    4889         .init_verbs = { alc883_init_verbs },
    4890         .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    4891         .dac_nids = alc883_dac_nids,
    4892         .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    4893         .adc_nids = alc883_adc_nids,
    4894         .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
    4895         .channel_mode = alc883_3ST_6ch_modes,
    4896         .input_mux = &alc883_capture_source,
    4897     },
    4898     [ALC883_6ST_DIG] = {
    4899         .mixers = { alc883_base_mixer, alc883_chmode_mixer },
    4900         .init_verbs = { alc883_init_verbs },
    4901         .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    4902         .dac_nids = alc883_dac_nids,
    4903         .dig_out_nid = ALC883_DIGOUT_NID,
    4904         .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    4905         .adc_nids = alc883_adc_nids,
    4906         .dig_in_nid = ALC883_DIGIN_NID,
    4907         .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
    4908         .channel_mode = alc883_sixstack_modes,
    4909         .input_mux = &alc883_capture_source,
    4910     },
    4911     [ALC888_DEMO_BOARD] = {
    4912         .mixers = { alc883_base_mixer, alc883_chmode_mixer },
    4913         .init_verbs = { alc883_init_verbs },
    4914         .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    4915         .dac_nids = alc883_dac_nids,
    4916         .dig_out_nid = ALC883_DIGOUT_NID,
    4917         .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    4918         .adc_nids = alc883_adc_nids,
    4919         .dig_in_nid = ALC883_DIGIN_NID,
    4920         .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
    4921         .channel_mode = alc883_sixstack_modes,
    4922         .input_mux = &alc883_capture_source,
    4923     },
     5548        [ALC883_3ST_2ch_DIG] = {
     5549                .mixers = { alc883_3ST_2ch_mixer },
     5550                .init_verbs = { alc883_init_verbs },
     5551                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5552                .dac_nids = alc883_dac_nids,
     5553                .dig_out_nid = ALC883_DIGOUT_NID,
     5554                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5555                .adc_nids = alc883_adc_nids,
     5556                .dig_in_nid = ALC883_DIGIN_NID,
     5557                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     5558                .channel_mode = alc883_3ST_2ch_modes,
     5559                .input_mux = &alc883_capture_source,
     5560        },
     5561        [ALC883_3ST_6ch_DIG] = {
     5562                .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
     5563                .init_verbs = { alc883_init_verbs },
     5564                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5565                .dac_nids = alc883_dac_nids,
     5566                .dig_out_nid = ALC883_DIGOUT_NID,
     5567                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5568                .adc_nids = alc883_adc_nids,
     5569                .dig_in_nid = ALC883_DIGIN_NID,
     5570                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
     5571                .channel_mode = alc883_3ST_6ch_modes,
     5572                .need_dac_fix = 1,
     5573                .input_mux = &alc883_capture_source,
     5574        },     
     5575        [ALC883_3ST_6ch] = {
     5576                .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
     5577                .init_verbs = { alc883_init_verbs },
     5578                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5579                .dac_nids = alc883_dac_nids,
     5580                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5581                .adc_nids = alc883_adc_nids,
     5582                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
     5583                .channel_mode = alc883_3ST_6ch_modes,
     5584                .need_dac_fix = 1,
     5585                .input_mux = &alc883_capture_source,
     5586        },     
     5587        [ALC883_6ST_DIG] = {
     5588                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
     5589                .init_verbs = { alc883_init_verbs },
     5590                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5591                .dac_nids = alc883_dac_nids,
     5592                .dig_out_nid = ALC883_DIGOUT_NID,
     5593                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5594                .adc_nids = alc883_adc_nids,
     5595                .dig_in_nid = ALC883_DIGIN_NID,
     5596                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
     5597                .channel_mode = alc883_sixstack_modes,
     5598                .input_mux = &alc883_capture_source,
     5599        },
     5600        [ALC883_TARGA_DIG] = {
     5601                .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
     5602                .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
     5603                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5604                .dac_nids = alc883_dac_nids,
     5605                .dig_out_nid = ALC883_DIGOUT_NID,
     5606                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5607                .adc_nids = alc883_adc_nids,
     5608                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
     5609                .channel_mode = alc883_3ST_6ch_modes,
     5610                .need_dac_fix = 1,
     5611                .input_mux = &alc883_capture_source,
     5612                .unsol_event = alc883_tagra_unsol_event,
     5613                .init_hook = alc883_tagra_automute,
     5614        },
     5615        [ALC883_TARGA_2ch_DIG] = {
     5616                .mixers = { alc883_tagra_2ch_mixer},
     5617                .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
     5618                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5619                .dac_nids = alc883_dac_nids,
     5620                .dig_out_nid = ALC883_DIGOUT_NID,
     5621                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5622                .adc_nids = alc883_adc_nids,
     5623                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     5624                .channel_mode = alc883_3ST_2ch_modes,
     5625                .input_mux = &alc883_capture_source,
     5626                .unsol_event = alc883_tagra_unsol_event,
     5627                .init_hook = alc883_tagra_automute,
     5628        },
     5629        [ALC888_DEMO_BOARD] = {
     5630                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
     5631                .init_verbs = { alc883_init_verbs },
     5632                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5633                .dac_nids = alc883_dac_nids,
     5634                .dig_out_nid = ALC883_DIGOUT_NID,
     5635                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5636                .adc_nids = alc883_adc_nids,
     5637                .dig_in_nid = ALC883_DIGIN_NID,
     5638                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
     5639                .channel_mode = alc883_sixstack_modes,
     5640                .input_mux = &alc883_capture_source,
     5641        },
     5642        [ALC883_ACER] = {
     5643                .mixers = { alc883_base_mixer,
     5644                            alc883_chmode_mixer },
     5645                /* On TravelMate laptops, GPIO 0 enables the internal speaker
     5646                 * and the headphone jack.  Turn this on and rely on the
     5647                 * standard mute methods whenever the user wants to turn
     5648                 * these outputs off.
     5649                 */
     5650                .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
     5651                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5652                .dac_nids = alc883_dac_nids,
     5653                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5654                .adc_nids = alc883_adc_nids,
     5655                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     5656                .channel_mode = alc883_3ST_2ch_modes,
     5657                .input_mux = &alc883_capture_source,
     5658        },
     5659        [ALC883_MEDION] = {
     5660                .mixers = { alc883_fivestack_mixer,
     5661                            alc883_chmode_mixer },
     5662                .init_verbs = { alc883_init_verbs,
     5663                                alc883_medion_eapd_verbs },
     5664                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5665                .dac_nids = alc883_dac_nids,
     5666                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5667                .adc_nids = alc883_adc_nids,
     5668                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
     5669                .channel_mode = alc883_sixstack_modes,
     5670                .input_mux = &alc883_capture_source,
     5671        },
     5672        [ALC883_LAPTOP_EAPD] = {
     5673                .mixers = { alc883_base_mixer,
     5674                            alc883_chmode_mixer },
     5675                .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
     5676                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     5677                .dac_nids = alc883_dac_nids,
     5678                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
     5679                .adc_nids = alc883_adc_nids,
     5680                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     5681                .channel_mode = alc883_3ST_2ch_modes,
     5682                .input_mux = &alc883_capture_source,
     5683        },
    49245684};
    49255685
     
    49295689 */
    49305690static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
    4931                                               hda_nid_t nid, int pin_type,
    4932                                               int dac_idx)
    4933 {
    4934     /* set as output */
    4935     struct alc_spec *spec = codec->spec;
    4936     int idx;
    4937 
    4938     if (spec->multiout.dac_nids[dac_idx] == 0x25)
    4939         idx = 4;
    4940     else
    4941         idx = spec->multiout.dac_nids[dac_idx] - 2;
    4942 
    4943     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    4944                         pin_type);
    4945     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    4946                         AMP_OUT_UNMUTE);
    4947     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
     5691                                              hda_nid_t nid, int pin_type,
     5692                                              int dac_idx)
     5693{
     5694        /* set as output */
     5695        struct alc_spec *spec = codec->spec;
     5696        int idx;
     5697       
     5698        if (spec->multiout.dac_nids[dac_idx] == 0x25)
     5699                idx = 4;
     5700        else
     5701                idx = spec->multiout.dac_nids[dac_idx] - 2;
     5702
     5703        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     5704                            pin_type);
     5705        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     5706                            AMP_OUT_UNMUTE);
     5707        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
    49485708
    49495709}
     
    49515711static void alc883_auto_init_multi_out(struct hda_codec *codec)
    49525712{
    4953     struct alc_spec *spec = codec->spec;
    4954     int i;
    4955 
    4956     for (i = 0; i <= HDA_SIDE; i++) {
    4957         hda_nid_t nid = spec->autocfg.line_out_pins[i];
    4958         if (nid)
    4959             alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
    4960     }
     5713        struct alc_spec *spec = codec->spec;
     5714        int i;
     5715
     5716        for (i = 0; i <= HDA_SIDE; i++) {
     5717                hda_nid_t nid = spec->autocfg.line_out_pins[i];
     5718                if (nid)
     5719                        alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
     5720        }
    49615721}
    49625722
    49635723static void alc883_auto_init_hp_out(struct hda_codec *codec)
    49645724{
    4965     struct alc_spec *spec = codec->spec;
    4966     hda_nid_t pin;
    4967 
    4968     pin = spec->autocfg.hp_pin;
    4969     if (pin) /* connect to front */
    4970         /* use dac 0 */
    4971         alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     5725        struct alc_spec *spec = codec->spec;
     5726        hda_nid_t pin;
     5727
     5728        pin = spec->autocfg.hp_pins[0];
     5729        if (pin) /* connect to front */
     5730                /* use dac 0 */
     5731                alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
    49725732}
    49735733
     
    49775737static void alc883_auto_init_analog_input(struct hda_codec *codec)
    49785738{
    4979     struct alc_spec *spec = codec->spec;
    4980     int i;
    4981 
    4982     for (i = 0; i < AUTO_PIN_LAST; i++) {
    4983         hda_nid_t nid = spec->autocfg.input_pins[i];
    4984         if (alc883_is_input_pin(nid)) {
    4985             snd_hda_codec_write(codec, nid, 0,
    4986                                 AC_VERB_SET_PIN_WIDGET_CONTROL,
    4987                                 (i <= AUTO_PIN_FRONT_MIC ?
    4988                                  PIN_VREF80 : PIN_IN));
    4989             if (nid != ALC883_PIN_CD_NID)
    4990                 snd_hda_codec_write(codec, nid, 0,
    4991                                     AC_VERB_SET_AMP_GAIN_MUTE,
    4992                                     AMP_OUT_MUTE);
    4993         }
    4994     }
     5739        struct alc_spec *spec = codec->spec;
     5740        int i;
     5741
     5742        for (i = 0; i < AUTO_PIN_LAST; i++) {
     5743                hda_nid_t nid = spec->autocfg.input_pins[i];
     5744                if (alc883_is_input_pin(nid)) {
     5745                        snd_hda_codec_write(codec, nid, 0,
     5746                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
     5747                                            (i <= AUTO_PIN_FRONT_MIC ?
     5748                                             PIN_VREF80 : PIN_IN));
     5749                        if (nid != ALC883_PIN_CD_NID)
     5750                                snd_hda_codec_write(codec, nid, 0,
     5751                                                    AC_VERB_SET_AMP_GAIN_MUTE,
     5752                                                    AMP_OUT_MUTE);
     5753                }
     5754        }
    49955755}
    49965756
     
    49985758static int alc883_parse_auto_config(struct hda_codec *codec)
    49995759{
    5000     struct alc_spec *spec = codec->spec;
    5001     int err = alc880_parse_auto_config(codec);
    5002 
    5003     if (err < 0)
    5004         return err;
    5005     else if (err > 0)
    5006         /* hack - override the init verbs */
    5007         spec->init_verbs[0] = alc883_auto_init_verbs;
    5008     spec->mixers[spec->num_mixers] = alc883_capture_mixer;
    5009     spec->num_mixers++;
    5010     return err;
     5760        struct alc_spec *spec = codec->spec;
     5761        int err = alc880_parse_auto_config(codec);
     5762
     5763        if (err < 0)
     5764                return err;
     5765        else if (err > 0)
     5766                /* hack - override the init verbs */
     5767                spec->init_verbs[0] = alc883_auto_init_verbs;
     5768                spec->mixers[spec->num_mixers] = alc883_capture_mixer;
     5769                spec->num_mixers++;
     5770        return err;
    50115771}
    50125772
     
    50145774static void alc883_auto_init(struct hda_codec *codec)
    50155775{
    5016     alc883_auto_init_multi_out(codec);
    5017     alc883_auto_init_hp_out(codec);
    5018     alc883_auto_init_analog_input(codec);
     5776        alc883_auto_init_multi_out(codec);
     5777        alc883_auto_init_hp_out(codec);
     5778        alc883_auto_init_analog_input(codec);
    50195779}
    50205780
    50215781static int patch_alc883(struct hda_codec *codec)
    50225782{
    5023     struct alc_spec *spec;
    5024     int err, board_config;
    5025 
    5026     spec = kzalloc(sizeof(*spec), GFP_KERNEL);
    5027     if (spec == NULL)
    5028         return -ENOMEM;
    5029 
    5030     codec->spec = spec;
    5031 
    5032     board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
    5033     if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
    5034         printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
    5035                "trying auto-probe from BIOS...\n");
    5036         board_config = ALC883_AUTO;
    5037     }
    5038 
    5039     if (board_config == ALC883_AUTO) {
    5040         /* automatic parse from the BIOS config */
    5041         err = alc883_parse_auto_config(codec);
    5042         if (err < 0) {
    5043             alc_free(codec);
    5044             return err;
    5045         } else if (! err) {
    5046             printk(KERN_INFO
    5047                    "hda_codec: Cannot set up configuration "
    5048                    "from BIOS.  Using base mode...\n");
    5049             board_config = ALC883_3ST_2ch_DIG;
    5050         }
    5051     }
    5052 
    5053     if (board_config != ALC883_AUTO)
    5054         setup_preset(spec, &alc883_presets[board_config]);
    5055 
    5056     spec->stream_name_analog = "ALC883 Analog";
    5057     spec->stream_analog_playback = &alc883_pcm_analog_playback;
    5058     spec->stream_analog_capture = &alc883_pcm_analog_capture;
    5059 
    5060     spec->stream_name_digital = "ALC883 Digital";
    5061     spec->stream_digital_playback = &alc883_pcm_digital_playback;
    5062     spec->stream_digital_capture = &alc883_pcm_digital_capture;
    5063 
    5064     spec->adc_nids = alc883_adc_nids;
    5065     spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
    5066 
    5067     codec->patch_ops = alc_patch_ops;
    5068     if (board_config == ALC883_AUTO)
    5069         spec->init_hook = alc883_auto_init;
    5070     return 0;
     5783        struct alc_spec *spec;
     5784        int err, board_config;
     5785
     5786        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     5787        if (spec == NULL)
     5788                return -ENOMEM;
     5789
     5790        codec->spec = spec;
     5791
     5792        board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
     5793                                                  alc883_models,
     5794                                                  alc883_cfg_tbl);
     5795        if (board_config < 0) {
     5796                printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
     5797                       "trying auto-probe from BIOS...\n");
     5798                board_config = ALC883_AUTO;
     5799        }
     5800
     5801        if (board_config == ALC883_AUTO) {
     5802                /* automatic parse from the BIOS config */
     5803                err = alc883_parse_auto_config(codec);
     5804                if (err < 0) {
     5805                        alc_free(codec);
     5806                        return err;
     5807                } else if (! err) {
     5808                        printk(KERN_INFO
     5809                               "hda_codec: Cannot set up configuration "
     5810                               "from BIOS.  Using base mode...\n");
     5811                        board_config = ALC883_3ST_2ch_DIG;
     5812                }
     5813        }
     5814
     5815        if (board_config != ALC883_AUTO)
     5816                setup_preset(spec, &alc883_presets[board_config]);
     5817
     5818        spec->stream_name_analog = "ALC883 Analog";
     5819        spec->stream_analog_playback = &alc883_pcm_analog_playback;
     5820        spec->stream_analog_capture = &alc883_pcm_analog_capture;
     5821
     5822        spec->stream_name_digital = "ALC883 Digital";
     5823        spec->stream_digital_playback = &alc883_pcm_digital_playback;
     5824        spec->stream_digital_capture = &alc883_pcm_digital_capture;
     5825
     5826        if (! spec->adc_nids && spec->input_mux) {
     5827                spec->adc_nids = alc883_adc_nids;
     5828                spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
     5829        }
     5830
     5831        codec->patch_ops = alc_patch_ops;
     5832        if (board_config == ALC883_AUTO)
     5833                spec->init_hook = alc883_auto_init;
     5834
     5835        return 0;
    50715836}
    50725837
     
    50865851
    50875852static struct snd_kcontrol_new alc262_base_mixer[] = {
    5088     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    5089     HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
    5090     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    5091     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    5092     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    5093     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    5094     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    5095     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    5096     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
    5097     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    5098     /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    5099      HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
    5100     HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
    5101     HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
    5102     HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    5103     HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
    5104     {0} /* end */
     5853        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5854        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     5855        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5856        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5857        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5858        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5859        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5860        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5861        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
     5862        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
     5863        /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5864           HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
     5865        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
     5866        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     5867        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     5868        HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
     5869        {0} /* end */
     5870};
     5871
     5872static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
     5873        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5874        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     5875        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5876        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5877        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5878        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5879        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5880        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5881        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
     5882        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
     5883        /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5884           HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
     5885        /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
     5886        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5887        {0} /* end */
    51055888};
    51065889
    51075890static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
    5108     HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    5109     HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
    5110     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    5111     HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    5112     HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
    5113 
    5114     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    5115     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    5116     HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
    5117     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    5118     HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    5119     HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    5120     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    5121     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    5122     HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    5123     HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
    5124     HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
    5125     HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
    5126     {0} /* end */
     5891        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     5892        HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     5893        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     5894        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     5895        HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
     5896
     5897        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     5898        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     5899        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
     5900        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
     5901        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     5902        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     5903        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     5904        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     5905        HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
     5906        HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
     5907        HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
     5908        HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
     5909        {0} /* end */
    51275910};
    51285911
     
    51345917 */
    51355918static struct hda_verb alc262_init_verbs[] = {
    5136     /*
    5137      * Unmute ADC0-2 and set the default input to mic-in
    5138      */
    5139     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    5140     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5141     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    5142     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5143     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    5144     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5145 
    5146     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    5147      * mixer widget
    5148      * Note: PASD motherboards uses the Line In 2 as the input for front panel
    5149      * mic (mic 2)
    5150      */
    5151     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    5152     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5153     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5154     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5155     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    5156     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    5157 
    5158     /*
    5159      * Set up output mixers (0x0c - 0x0e)
    5160      */
    5161     /* set vol=0 to output mixers */
    5162     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5163     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5164     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5165     /* set up input amps for analog loopback */
    5166     /* Amp Indices: DAC = 0, mixer = 1 */
    5167     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5168     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5169     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5170     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5171     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5172     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5173 
    5174     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    5175     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
    5176     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    5177     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    5178     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    5179     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    5180 
    5181     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    5182     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    5183     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    5184     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    5185     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
    5186 
    5187     {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
    5188     {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
    5189 
    5190     /* FIXME: use matrix-type input source selection */
    5191     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    5192     /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
    5193     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5194     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    5195     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    5196     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    5197     /* Input mixer2 */
    5198     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5199     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    5200     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    5201     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    5202     /* Input mixer3 */
    5203     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5204     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    5205     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    5206     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    5207 
    5208     {0}
    5209 };
     5919        /*
     5920         * Unmute ADC0-2 and set the default input to mic-in
     5921         */
     5922        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     5923        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5924        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     5925        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5926        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     5927        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5928
     5929        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     5930         * mixer widget
     5931         * Note: PASD motherboards uses the Line In 2 as the input for front panel
     5932         * mic (mic 2)
     5933         */
     5934        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     5935        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5936        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5937        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     5938        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     5939        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     5940
     5941        /*
     5942         * Set up output mixers (0x0c - 0x0e)
     5943         */
     5944        /* set vol=0 to output mixers */
     5945        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5946        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5947        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5948        /* set up input amps for analog loopback */
     5949        /* Amp Indices: DAC = 0, mixer = 1 */
     5950        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5951        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5952        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5953        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5954        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5955        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     5956
     5957        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
     5958        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
     5959        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
     5960        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     5961        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     5962        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     5963
     5964        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     5965        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     5966        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     5967        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     5968        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     5969       
     5970        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     5971        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
     5972       
     5973        /* FIXME: use matrix-type input source selection */
     5974        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     5975        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
     5976        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     5977        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     5978        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     5979        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     5980        /* Input mixer2 */
     5981        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     5982        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     5983        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     5984        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     5985        /* Input mixer3 */
     5986        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     5987        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     5988        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     5989        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},     
     5990
     5991        {0}
     5992};
     5993
     5994static struct hda_verb alc262_hippo_unsol_verbs[] = {
     5995        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     5996        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     5997        {0}
     5998};
     5999
     6000static struct hda_verb alc262_hippo1_unsol_verbs[] = {
     6001        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
     6002        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
     6003        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
     6004
     6005        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     6006        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     6007        {0}
     6008};
     6009
     6010/* mute/unmute internal speaker according to the hp jack and mute state */
     6011static void alc262_hippo_automute(struct hda_codec *codec, int force)
     6012{
     6013        struct alc_spec *spec = codec->spec;
     6014        unsigned int mute;
     6015
     6016        if (force || ! spec->sense_updated) {
     6017                unsigned int present;
     6018                /* need to execute and sync at first */
     6019                snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
     6020                present = snd_hda_codec_read(codec, 0x15, 0,
     6021                                         AC_VERB_GET_PIN_SENSE, 0);
     6022                spec->jack_present = (present & 0x80000000) != 0;
     6023                spec->sense_updated = 1;
     6024        }
     6025        if (spec->jack_present) {
     6026                /* mute internal speaker */
     6027                snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
     6028                                         0x80, 0x80);
     6029                snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
     6030                                         0x80, 0x80);
     6031        } else {
     6032                /* unmute internal speaker if necessary */
     6033                mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
     6034                snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
     6035                                         0x80, mute & 0x80);
     6036                mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
     6037                snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
     6038                                         0x80, mute & 0x80);
     6039        }
     6040}
     6041
     6042/* unsolicited event for HP jack sensing */
     6043static void alc262_hippo_unsol_event(struct hda_codec *codec,
     6044                                       unsigned int res)
     6045{
     6046        if ((res >> 26) != ALC880_HP_EVENT)
     6047                return;
     6048        alc262_hippo_automute(codec, 1);
     6049}
     6050
     6051static void alc262_hippo1_automute(struct hda_codec *codec, int force)
     6052{
     6053        struct alc_spec *spec = codec->spec;
     6054        unsigned int mute;
     6055
     6056        if (force || ! spec->sense_updated) {
     6057                unsigned int present;
     6058                /* need to execute and sync at first */
     6059                snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
     6060                present = snd_hda_codec_read(codec, 0x1b, 0,
     6061                                         AC_VERB_GET_PIN_SENSE, 0);
     6062                spec->jack_present = (present & 0x80000000) != 0;
     6063                spec->sense_updated = 1;
     6064        }
     6065        if (spec->jack_present) {
     6066                /* mute internal speaker */
     6067                snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
     6068                                         0x80, 0x80);
     6069                snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
     6070                                         0x80, 0x80);
     6071        } else {
     6072                /* unmute internal speaker if necessary */
     6073                mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
     6074                snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
     6075                                         0x80, mute & 0x80);
     6076                mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
     6077                snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
     6078                                         0x80, mute & 0x80);
     6079        }
     6080}
     6081
     6082/* unsolicited event for HP jack sensing */
     6083static void alc262_hippo1_unsol_event(struct hda_codec *codec,
     6084                                       unsigned int res)
     6085{
     6086        if ((res >> 26) != ALC880_HP_EVENT)
     6087                return;
     6088        alc262_hippo1_automute(codec, 1);
     6089}
    52106090
    52116091/*
     
    52176097
    52186098static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
    5219     {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
    5220     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    5221     {0}
     6099        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
     6100        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     6101        {0}
    52226102};
    52236103
    52246104static struct hda_input_mux alc262_fujitsu_capture_source = {
    5225     .num_items = 2,
    5226     .items = {
    5227         { "Mic", 0x0 },
    5228         { "CD", 0x4 },
    5229     },
     6105        .num_items = 2,
     6106        .items = {
     6107                { "Mic", 0x0 },
     6108                { "CD", 0x4 },
     6109        },
    52306110};
    52316111
    52326112static struct hda_input_mux alc262_HP_capture_source = {
    5233     .num_items = 5,
    5234     .items = {
    5235         { "Mic", 0x0 },
    5236         { "Front Mic", 0x3 },
    5237         { "Line", 0x2 },
    5238         { "CD", 0x4 },
    5239         { "AUX IN", 0x6 },
    5240     },
     6113        .num_items = 5,
     6114        .items = {
     6115                { "Mic", 0x0 },
     6116                { "Front Mic", 0x3 },
     6117                { "Line", 0x2 },
     6118                { "CD", 0x4 },
     6119                { "AUX IN", 0x6 },
     6120        },
    52416121};
    52426122
     
    52446124static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
    52456125{
    5246     struct alc_spec *spec = codec->spec;
    5247     unsigned int mute;
    5248 
    5249     if (force || ! spec->sense_updated) {
    5250         unsigned int present;
    5251         /* need to execute and sync at first */
    5252         snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
    5253         present = snd_hda_codec_read(codec, 0x14, 0,
    5254                                     AC_VERB_GET_PIN_SENSE, 0);
    5255         spec->jack_present = (present & 0x80000000) != 0;
    5256         spec->sense_updated = 1;
    5257     }
    5258     if (spec->jack_present) {
    5259         /* mute internal speaker */
    5260         snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
    5261                                 0x80, 0x80);
    5262         snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
    5263                                 0x80, 0x80);
    5264     } else {
    5265         /* unmute internal speaker if necessary */
    5266         mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
    5267         snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
    5268                                 0x80, mute & 0x80);
    5269         mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
    5270         snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
    5271                                 0x80, mute & 0x80);
    5272     }
     6126        struct alc_spec *spec = codec->spec;
     6127        unsigned int mute;
     6128
     6129        if (force || ! spec->sense_updated) {
     6130                unsigned int present;
     6131                /* need to execute and sync at first */
     6132                snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
     6133                present = snd_hda_codec_read(codec, 0x14, 0,
     6134                                        AC_VERB_GET_PIN_SENSE, 0);
     6135                spec->jack_present = (present & 0x80000000) != 0;
     6136                spec->sense_updated = 1;
     6137        }
     6138        if (spec->jack_present) {
     6139                /* mute internal speaker */
     6140                snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
     6141                                        0x80, 0x80);
     6142                snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
     6143                                        0x80, 0x80);
     6144        } else {
     6145                /* unmute internal speaker if necessary */
     6146                mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
     6147                snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
     6148                                        0x80, mute & 0x80);
     6149                mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
     6150                snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
     6151                                        0x80, mute & 0x80);
     6152        }
    52736153}
    52746154
    52756155/* unsolicited event for HP jack sensing */
    52766156static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
    5277                                        unsigned int res)
    5278 {
    5279     if ((res >> 26) != ALC_HP_EVENT)
    5280         return;
    5281     alc262_fujitsu_automute(codec, 1);
     6157                                       unsigned int res)
     6158{
     6159        if ((res >> 26) != ALC_HP_EVENT)
     6160                return;
     6161        alc262_fujitsu_automute(codec, 1);
    52826162}
    52836163
    52846164/* bind volumes of both NID 0x0c and 0x0d */
    52856165static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
    5286                                         struct snd_ctl_elem_value *ucontrol)
    5287 {
    5288     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    5289     long *valp = ucontrol->value.integer.value;
    5290     int change;
    5291 
    5292     change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
    5293                                       0x7f, valp[0] & 0x7f);
    5294     change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
    5295                                        0x7f, valp[1] & 0x7f);
    5296     snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
    5297                             0x7f, valp[0] & 0x7f);
    5298     snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
    5299                             0x7f, valp[1] & 0x7f);
    5300     return change;
     6166                                        struct snd_ctl_elem_value *ucontrol)
     6167{
     6168        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     6169        long *valp = ucontrol->value.integer.value;
     6170        int change;
     6171
     6172        change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
     6173                                          0x7f, valp[0] & 0x7f);
     6174        change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
     6175                                           0x7f, valp[1] & 0x7f);
     6176        snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
     6177                                0x7f, valp[0] & 0x7f);
     6178        snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
     6179                                0x7f, valp[1] & 0x7f);
     6180        return change;
    53016181}
    53026182
    53036183/* bind hp and internal speaker mute (with plug check) */
    53046184static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
    5305                                         struct snd_ctl_elem_value *ucontrol)
    5306 {
    5307     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    5308     long *valp = ucontrol->value.integer.value;
    5309     int change;
    5310 
    5311     change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
    5312                                       0x80, valp[0] ? 0 : 0x80);
    5313     change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
    5314                                        0x80, valp[1] ? 0 : 0x80);
    5315     if (change || codec->in_resume)
    5316         alc262_fujitsu_automute(codec, codec->in_resume);
    5317     return change;
     6185                                        struct snd_ctl_elem_value *ucontrol)
     6186{
     6187        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     6188        long *valp = ucontrol->value.integer.value;
     6189        int change;
     6190
     6191        change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
     6192                                          0x80, valp[0] ? 0 : 0x80);
     6193        change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
     6194                                           0x80, valp[1] ? 0 : 0x80);
     6195        if (change || codec->in_resume)
     6196                alc262_fujitsu_automute(codec, codec->in_resume);
     6197        return change;
    53186198}
    53196199
    53206200static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
    5321     {
    5322         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5323         .name = "Master Playback Volume",
    5324         .info = snd_hda_mixer_amp_volume_info,
    5325         .get = snd_hda_mixer_amp_volume_get,
    5326         .put = alc262_fujitsu_master_vol_put,
    5327         .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
    5328     },
    5329     {
    5330         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5331         .name = "Master Playback Switch",
    5332         .info = snd_hda_mixer_amp_switch_info,
    5333         .get = snd_hda_mixer_amp_switch_get,
    5334         .put = alc262_fujitsu_master_sw_put,
    5335         .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
    5336     },
    5337     HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    5338     HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    5339     HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    5340     HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    5341     HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    5342     {0} /* end */
     6201        {
     6202                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6203                .name = "Master Playback Volume",
     6204                .info = snd_hda_mixer_amp_volume_info,
     6205                .get = snd_hda_mixer_amp_volume_get,
     6206                .put = alc262_fujitsu_master_vol_put,
     6207                .tlv = { .c = snd_hda_mixer_amp_tlv },
     6208                .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
     6209        },
     6210        {
     6211                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6212                .name = "Master Playback Switch",
     6213                .info = snd_hda_mixer_amp_switch_info,
     6214                .get = snd_hda_mixer_amp_switch_get,
     6215                .put = alc262_fujitsu_master_sw_put,
     6216                .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
     6217        },
     6218        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     6219        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     6220        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
     6221        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     6222        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     6223        {0} /* end */
     6224};
     6225
     6226/* additional init verbs for Benq laptops */
     6227static struct hda_verb alc262_EAPD_verbs[] = {
     6228        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     6229        {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
     6230        {0}
    53436231};
    53446232
     
    53466234static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
    53476235{
    5348     hda_nid_t nid;
    5349     int err;
    5350 
    5351     spec->multiout.num_dacs = 1;        /* only use one dac */
    5352     spec->multiout.dac_nids = spec->private_dac_nids;
    5353     spec->multiout.dac_nids[0] = 2;
    5354 
    5355     nid = cfg->line_out_pins[0];
    5356     if (nid) {
    5357         if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
    5358                                HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
    5359             return err;
    5360         if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
    5361                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    5362             return err;
    5363     }
    5364 
    5365     nid = cfg->speaker_pins[0];
    5366     if (nid) {
    5367         if (nid == 0x16) {
    5368             if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
    5369                                    HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
    5370                 return err;
    5371         } else {
    5372             if (! cfg->line_out_pins[0])
    5373                 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
    5374                                        HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
    5375                     return err;
    5376             if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
    5377                                    HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    5378                 return err;
    5379         }
    5380     }
    5381     nid = cfg->hp_pin;
    5382     if (nid) {
    5383         /* spec->multiout.hp_nid = 2; */
    5384         if (nid == 0x16) {
    5385             if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
    5386                                    HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
    5387                 return err;
    5388             if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
    5389                                    HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
    5390                 return err;
    5391         } else {
    5392             if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
    5393                                    HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    5394                 return err;
    5395         }
    5396     }
    5397     return 0;
     6236        hda_nid_t nid;
     6237        int err;
     6238
     6239        spec->multiout.num_dacs = 1;    /* only use one dac */
     6240        spec->multiout.dac_nids = spec->private_dac_nids;
     6241        spec->multiout.dac_nids[0] = 2;
     6242
     6243        nid = cfg->line_out_pins[0];
     6244        if (nid) {
     6245                if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
     6246                                       HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
     6247                        return err;
     6248                if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
     6249                                       HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     6250                        return err;
     6251        }
     6252
     6253        nid = cfg->speaker_pins[0];
     6254        if (nid) {
     6255                if (nid == 0x16) {
     6256                        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
     6257                                               HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
     6258                                return err;
     6259                        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
     6260                                               HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
     6261                                return err;
     6262                } else {
     6263                        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
     6264                                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     6265                                return err;
     6266                }
     6267        }
     6268        nid = cfg->hp_pins[0];
     6269        if (nid) {
     6270                /* spec->multiout.hp_nid = 2; */
     6271                if (nid == 0x16) {
     6272                        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
     6273                                               HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
     6274                                return err;
     6275                        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
     6276                                               HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
     6277                                return err;
     6278                } else {
     6279                        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
     6280                                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     6281                                return err;
     6282                }
     6283        }
     6284        return 0;       
    53986285}
    53996286
     
    54056292 */
    54066293static struct hda_verb alc262_volume_init_verbs[] = {
    5407     /*
    5408     * Unmute ADC0-2 and set the default input to mic-in
    5409     */
    5410     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    5411     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5412     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    5413     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5414     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    5415     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5416 
    5417     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    5418     * mixer widget
    5419     * Note: PASD motherboards uses the Line In 2 as the input for front panel
    5420     * mic (mic 2)
    5421     */
    5422     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    5423     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5424     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5425     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5426     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    5427     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    5428 
    5429     /*
    5430     * Set up output mixers (0x0c - 0x0f)
    5431     */
    5432     /* set vol=0 to output mixers */
    5433     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5434     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5435     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5436 
    5437     /* set up input amps for analog loopback */
    5438     /* Amp Indices: DAC = 0, mixer = 1 */
    5439     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5440     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5441     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5442     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5443     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5444     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5445 
    5446     /* FIXME: use matrix-type input source selection */
    5447     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    5448     /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
    5449     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5450     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    5451     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    5452     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    5453     /* Input mixer2 */
    5454     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5455     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    5456     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    5457     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    5458     /* Input mixer3 */
    5459     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5460     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
    5461     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
    5462     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
    5463 
    5464     {0}
     6294        /*
     6295        * Unmute ADC0-2 and set the default input to mic-in
     6296        */
     6297        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     6298        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6299        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     6300        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6301        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     6302        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6303
     6304        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     6305        * mixer widget
     6306        * Note: PASD motherboards uses the Line In 2 as the input for front panel
     6307        * mic (mic 2)
     6308        */
     6309        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     6310        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6311        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6312        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     6313        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     6314        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     6315
     6316        /*
     6317        * Set up output mixers (0x0c - 0x0f)
     6318        */
     6319        /* set vol=0 to output mixers */
     6320        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     6321        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     6322        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     6323       
     6324        /* set up input amps for analog loopback */
     6325        /* Amp Indices: DAC = 0, mixer = 1 */
     6326        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6327        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6328        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6329        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6330        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6331        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6332
     6333        /* FIXME: use matrix-type input source selection */
     6334        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     6335        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
     6336        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     6337        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     6338        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     6339        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     6340        /* Input mixer2 */
     6341        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     6342        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     6343        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     6344        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     6345        /* Input mixer3 */
     6346        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     6347        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
     6348        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
     6349        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
     6350
     6351        {0}
    54656352};
    54666353
    54676354static struct hda_verb alc262_HP_BPC_init_verbs[] = {
    5468     /*
    5469     * Unmute ADC0-2 and set the default input to mic-in
    5470     */
    5471     {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
    5472     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5473     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    5474     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5475     {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
    5476     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5477 
    5478     /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
    5479     * mixer widget
    5480     * Note: PASD motherboards uses the Line In 2 as the input for front panel
    5481     * mic (mic 2)
    5482     */
    5483     /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
    5484     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5485     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5486     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5487     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    5488     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    5489     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
    5490     {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
    5491 
    5492     /*
    5493     * Set up output mixers (0x0c - 0x0e)
    5494     */
    5495     /* set vol=0 to output mixers */
    5496     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5497     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5498     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    5499 
    5500     /* set up input amps for analog loopback */
    5501     /* Amp Indices: DAC = 0, mixer = 1 */
    5502     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5503     {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5504     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5505     {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5506     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5507     {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5508 
    5509     {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
    5510     {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    5511     {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    5512 
    5513     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    5514     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    5515 
    5516     {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
    5517     {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
    5518 
    5519     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    5520     {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    5521     {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    5522     {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    5523     {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    5524 
    5525     {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
    5526     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
    5527     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
    5528     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
    5529     {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
    5530     {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
    5531 
    5532 
    5533     /* FIXME: use matrix-type input source selection */
    5534     /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
    5535     /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
    5536     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5537     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
    5538     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
    5539     {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
    5540     /* Input mixer2 */
    5541     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5542     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
    5543     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
    5544     {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
    5545     /* Input mixer3 */
    5546     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
    5547     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
    5548     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
    5549     {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
    5550 
    5551     {0}
     6355        /*
     6356        * Unmute ADC0-2 and set the default input to mic-in
     6357        */
     6358        {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
     6359        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6360        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     6361        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6362        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
     6363        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6364
     6365        /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
     6366        * mixer widget
     6367        * Note: PASD motherboards uses the Line In 2 as the input for front panel
     6368        * mic (mic 2)
     6369        */
     6370        /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
     6371        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6372        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6373        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     6374        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
     6375        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     6376        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
     6377        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
     6378       
     6379        /*
     6380        * Set up output mixers (0x0c - 0x0e)
     6381        */
     6382        /* set vol=0 to output mixers */
     6383        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     6384        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     6385        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     6386
     6387        /* set up input amps for analog loopback */
     6388        /* Amp Indices: DAC = 0, mixer = 1 */
     6389        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6390        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6391        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6392        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6393        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     6394        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     6395
     6396        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
     6397        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     6398        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     6399
     6400        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     6401        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     6402
     6403        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
     6404        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
     6405
     6406        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     6407        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     6408        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     6409        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     6410        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
     6411
     6412        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
     6413        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
     6414        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
     6415        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
     6416        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
     6417        {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
     6418
     6419
     6420        /* FIXME: use matrix-type input source selection */
     6421        /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
     6422        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
     6423        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     6424        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
     6425        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
     6426        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
     6427        /* Input mixer2 */
     6428        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     6429        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
     6430        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
     6431        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
     6432        /* Input mixer3 */
     6433        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     6434        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
     6435        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
     6436        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
     6437
     6438        {0}
    55526439};
    55536440
     
    55636450static int alc262_parse_auto_config(struct hda_codec *codec)
    55646451{
    5565     struct alc_spec *spec = codec->spec;
    5566     int err;
    5567     static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
    5568 
    5569     if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
    5570                                             alc262_ignore)) < 0)
    5571         return err;
    5572     if (! spec->autocfg.line_outs)
    5573         return 0; /* can't find valid BIOS pin config */
    5574     if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
    5575         (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
    5576         return err;
    5577 
    5578     spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    5579 
    5580     if (spec->autocfg.dig_out_pin)
    5581         spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
    5582     if (spec->autocfg.dig_in_pin)
    5583         spec->dig_in_nid = ALC262_DIGIN_NID;
    5584 
    5585     if (spec->kctl_alloc)
    5586         spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
    5587 
    5588     spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
    5589     spec->input_mux = &spec->private_imux;
    5590 
    5591     return 1;
     6452        struct alc_spec *spec = codec->spec;
     6453        int err;
     6454        static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
     6455
     6456        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
     6457                                                alc262_ignore)) < 0)
     6458                return err;
     6459        if (! spec->autocfg.line_outs)
     6460                return 0; /* can't find valid BIOS pin config */
     6461        if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
     6462            (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
     6463                return err;
     6464
     6465        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
     6466
     6467        if (spec->autocfg.dig_out_pin)
     6468                spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
     6469        if (spec->autocfg.dig_in_pin)
     6470                spec->dig_in_nid = ALC262_DIGIN_NID;
     6471
     6472        if (spec->kctl_alloc)
     6473                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
     6474
     6475        spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
     6476        spec->num_mux_defs = 1;
     6477        spec->input_mux = &spec->private_imux;
     6478
     6479        return 1;
    55926480}
    55936481
     
    56006488static void alc262_auto_init(struct hda_codec *codec)
    56016489{
    5602     alc262_auto_init_multi_out(codec);
    5603     alc262_auto_init_hp_out(codec);
    5604     alc262_auto_init_analog_input(codec);
     6490        alc262_auto_init_multi_out(codec);
     6491        alc262_auto_init_hp_out(codec);
     6492        alc262_auto_init_analog_input(codec);
    56056493}
    56066494
     
    56086496 * configuration and preset
    56096497 */
    5610 static struct hda_board_config alc262_cfg_tbl[] = {
    5611     { .modelname = "basic", .config = ALC262_BASIC },
    5612     { .modelname = "fujitsu", .config = ALC262_FUJITSU },
    5613     { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
    5614     .config = ALC262_FUJITSU },
    5615     { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
    5616     .config = ALC262_HP_BPC }, /* xw4400 */
    5617     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
    5618     .config = ALC262_HP_BPC }, /* xw6400 */
    5619     { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
    5620     .config = ALC262_HP_BPC }, /* xw8400 */
    5621     { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
    5622     .config = ALC262_HP_BPC }, /* xw9400 */
    5623     { .modelname = "auto", .config = ALC262_AUTO },
    5624     {0}
     6498static const char *alc262_models[ALC262_MODEL_LAST] = {
     6499        [ALC262_BASIC]          = "basic",
     6500        [ALC262_HIPPO]          = "hippo",
     6501        [ALC262_HIPPO_1]        = "hippo_1",
     6502        [ALC262_FUJITSU]        = "fujitsu",
     6503        [ALC262_HP_BPC]         = "hp-bpc",
     6504        [ALC262_BENQ_ED8]       = "benq",
     6505        [ALC262_AUTO]           = "auto",
     6506};
     6507
     6508static struct snd_pci_quirk alc262_cfg_tbl[] = {
     6509        SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
     6510        SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
     6511        SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
     6512        SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC),
     6513        SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
     6514        SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
     6515        SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
     6516        SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
     6517        SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
     6518        SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
     6519        {0}
    56256520};
    56266521
    56276522static struct alc_config_preset alc262_presets[] = {
    5628     [ALC262_BASIC] = {
    5629         .mixers = { alc262_base_mixer },
    5630         .init_verbs = { alc262_init_verbs },
    5631         .num_dacs = ARRAY_SIZE(alc262_dac_nids),
    5632         .dac_nids = alc262_dac_nids,
    5633         .hp_nid = 0x03,
    5634         .num_channel_mode = ARRAY_SIZE(alc262_modes),
    5635         .channel_mode = alc262_modes,
    5636         .input_mux = &alc262_capture_source,
    5637     },
    5638     [ALC262_FUJITSU] = {
    5639         .mixers = { alc262_fujitsu_mixer },
    5640         .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
    5641         .num_dacs = ARRAY_SIZE(alc262_dac_nids),
    5642         .dac_nids = alc262_dac_nids,
    5643         .hp_nid = 0x03,
    5644         .dig_out_nid = ALC262_DIGOUT_NID,
    5645         .num_channel_mode = ARRAY_SIZE(alc262_modes),
    5646         .channel_mode = alc262_modes,
    5647         .input_mux = &alc262_fujitsu_capture_source,
    5648         .unsol_event = alc262_fujitsu_unsol_event,
    5649     },
    5650     [ALC262_HP_BPC] = {
    5651         .mixers = { alc262_HP_BPC_mixer },
    5652         .init_verbs = { alc262_HP_BPC_init_verbs },
    5653         .num_dacs = ARRAY_SIZE(alc262_dac_nids),
    5654         .dac_nids = alc262_dac_nids,
    5655         .hp_nid = 0x03,
    5656         .num_channel_mode = ARRAY_SIZE(alc262_modes),
    5657         .channel_mode = alc262_modes,
    5658         .input_mux = &alc262_HP_capture_source,
    5659     },
     6523        [ALC262_BASIC] = {
     6524                .mixers = { alc262_base_mixer },
     6525                .init_verbs = { alc262_init_verbs },
     6526                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     6527                .dac_nids = alc262_dac_nids,
     6528                .hp_nid = 0x03,
     6529                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     6530                .channel_mode = alc262_modes,
     6531                .input_mux = &alc262_capture_source,
     6532        },
     6533        [ALC262_HIPPO] = {
     6534                .mixers = { alc262_base_mixer },
     6535                .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
     6536                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     6537                .dac_nids = alc262_dac_nids,
     6538                .hp_nid = 0x03,
     6539                .dig_out_nid = ALC262_DIGOUT_NID,
     6540                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     6541                .channel_mode = alc262_modes,
     6542                .input_mux = &alc262_capture_source,
     6543                .unsol_event = alc262_hippo_unsol_event,
     6544        },
     6545        [ALC262_HIPPO_1] = {
     6546                .mixers = { alc262_hippo1_mixer },
     6547                .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
     6548                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     6549                .dac_nids = alc262_dac_nids,
     6550                .hp_nid = 0x02,
     6551                .dig_out_nid = ALC262_DIGOUT_NID,
     6552                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     6553                .channel_mode = alc262_modes,
     6554                .input_mux = &alc262_capture_source,
     6555                .unsol_event = alc262_hippo1_unsol_event,
     6556        },
     6557        [ALC262_FUJITSU] = {
     6558                .mixers = { alc262_fujitsu_mixer },
     6559                .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
     6560                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     6561                .dac_nids = alc262_dac_nids,
     6562                .hp_nid = 0x03,
     6563                .dig_out_nid = ALC262_DIGOUT_NID,
     6564                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     6565                .channel_mode = alc262_modes,
     6566                .input_mux = &alc262_fujitsu_capture_source,
     6567                .unsol_event = alc262_fujitsu_unsol_event,
     6568        },
     6569        [ALC262_HP_BPC] = {
     6570                .mixers = { alc262_HP_BPC_mixer },
     6571                .init_verbs = { alc262_HP_BPC_init_verbs },
     6572                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     6573                .dac_nids = alc262_dac_nids,
     6574                .hp_nid = 0x03,
     6575                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     6576                .channel_mode = alc262_modes,
     6577                .input_mux = &alc262_HP_capture_source,
     6578        },     
     6579        [ALC262_BENQ_ED8] = {
     6580                .mixers = { alc262_base_mixer },
     6581                .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
     6582                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     6583                .dac_nids = alc262_dac_nids,
     6584                .hp_nid = 0x03,
     6585                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     6586                .channel_mode = alc262_modes,
     6587                .input_mux = &alc262_capture_source,
     6588        },             
    56606589};
    56616590
    56626591static int patch_alc262(struct hda_codec *codec)
    56636592{
    5664     struct alc_spec *spec;
    5665     int board_config;
    5666     int err;
    5667 
    5668     spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
    5669     if (spec == NULL)
    5670         return -ENOMEM;
    5671 
    5672     codec->spec = spec;
     6593        struct alc_spec *spec;
     6594        int board_config;
     6595        int err;
     6596
     6597        spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
     6598        if (spec == NULL)
     6599                return -ENOMEM;
     6600
     6601        codec->spec = spec;
    56736602#if 0
    5674     /* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is under-run */
    5675     {
    5676         int tmp;
    5677         snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
    5678         tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
    5679         snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
    5680         snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
    5681     }
     6603        /* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is under-run */
     6604        {
     6605        int tmp;
     6606        snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
     6607        tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
     6608        snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
     6609        snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
     6610        }
    56826611#endif
    56836612
    5684     board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
    5685 
    5686     if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
    5687         printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
    5688         board_config = ALC262_AUTO;
    5689     }
    5690 
    5691     if (board_config == ALC262_AUTO) {
    5692         /* automatic parse from the BIOS config */
    5693         err = alc262_parse_auto_config(codec);
    5694         if (err < 0) {
    5695             alc_free(codec);
    5696             return err;
    5697         } else if (! err) {
    5698             printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS.  Using base mode...\n");
    5699             board_config = ALC262_BASIC;
    5700         }
    5701     }
    5702 
    5703     if (board_config != ALC262_AUTO)
    5704         setup_preset(spec, &alc262_presets[board_config]);
    5705 
    5706     spec->stream_name_analog = "ALC262 Analog";
    5707     spec->stream_analog_playback = &alc262_pcm_analog_playback;
    5708     spec->stream_analog_capture = &alc262_pcm_analog_capture;
    5709 
    5710     spec->stream_name_digital = "ALC262 Digital";
    5711     spec->stream_digital_playback = &alc262_pcm_digital_playback;
    5712     spec->stream_digital_capture = &alc262_pcm_digital_capture;
    5713 
    5714     if (! spec->adc_nids && spec->input_mux) {
    5715         /* check whether NID 0x07 is valid */
    5716         unsigned int wcap = get_wcaps(codec, 0x07);
    5717 
    5718         wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
    5719         if (wcap != AC_WID_AUD_IN) {
    5720             spec->adc_nids = alc262_adc_nids_alt;
    5721             spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
    5722             spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
    5723             spec->num_mixers++;
    5724         } else {
    5725             spec->adc_nids = alc262_adc_nids;
    5726             spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
    5727             spec->mixers[spec->num_mixers] = alc262_capture_mixer;
    5728             spec->num_mixers++;
    5729         }
    5730     }
    5731 
    5732     codec->patch_ops = alc_patch_ops;
    5733     if (board_config == ALC262_AUTO)
    5734         spec->init_hook = alc262_auto_init;
    5735 
    5736     return 0;
    5737 }
    5738 
     6613        board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
     6614                                                  alc262_models,
     6615                                                  alc262_cfg_tbl);
     6616       
     6617        if (board_config < 0) {
     6618                printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
     6619                       "trying auto-probe from BIOS...\n");
     6620                board_config = ALC262_AUTO;
     6621        }
     6622
     6623        if (board_config == ALC262_AUTO) {
     6624                /* automatic parse from the BIOS config */
     6625                err = alc262_parse_auto_config(codec);
     6626                if (err < 0) {
     6627                        alc_free(codec);
     6628                        return err;
     6629                } else if (! err) {
     6630                        printk(KERN_INFO
     6631                               "hda_codec: Cannot set up configuration "
     6632                               "from BIOS.  Using base mode...\n");
     6633                        board_config = ALC262_BASIC;
     6634                }
     6635        }
     6636
     6637        if (board_config != ALC262_AUTO)
     6638                setup_preset(spec, &alc262_presets[board_config]);
     6639
     6640        spec->stream_name_analog = "ALC262 Analog";
     6641        spec->stream_analog_playback = &alc262_pcm_analog_playback;
     6642        spec->stream_analog_capture = &alc262_pcm_analog_capture;
     6643               
     6644        spec->stream_name_digital = "ALC262 Digital";
     6645        spec->stream_digital_playback = &alc262_pcm_digital_playback;
     6646        spec->stream_digital_capture = &alc262_pcm_digital_capture;
     6647
     6648        if (! spec->adc_nids && spec->input_mux) {
     6649                /* check whether NID 0x07 is valid */
     6650                unsigned int wcap = get_wcaps(codec, 0x07);
     6651
     6652                wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
     6653                if (wcap != AC_WID_AUD_IN) {
     6654                        spec->adc_nids = alc262_adc_nids_alt;
     6655                        spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
     6656                        spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
     6657                        spec->num_mixers++;
     6658                } else {
     6659                        spec->adc_nids = alc262_adc_nids;
     6660                        spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
     6661                        spec->mixers[spec->num_mixers] = alc262_capture_mixer;
     6662                        spec->num_mixers++;
     6663                }
     6664        }
     6665
     6666        codec->patch_ops = alc_patch_ops;
     6667        if (board_config == ALC262_AUTO)
     6668                spec->init_hook = alc262_auto_init;
     6669               
     6670        return 0;
     6671}
    57396672
    57406673/*
     
    57476680 */
    57486681static struct hda_verb alc861_threestack_ch2_init[] = {
    5749     /* set pin widget 1Ah (line in) for input */
    5750     { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
    5751     /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
    5752     { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    5753 
    5754     { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
     6682        /* set pin widget 1Ah (line in) for input */
     6683        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     6684        /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
     6685        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     6686
     6687        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
    57556688#if 0
    5756     { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
    5757     { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
     6689        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
     6690        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
    57586691#endif
    5759     {0} /* end */
     6692        {0} /* end */
    57606693};
    57616694/*
     
    57646697 */
    57656698static struct hda_verb alc861_threestack_ch6_init[] = {
    5766     /* set pin widget 1Ah (line in) for output (Back Surround)*/
    5767     { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5768     /* set pin widget 18h (mic1) for output (CLFE)*/
    5769     { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5770 
    5771     { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5772     { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5773 
    5774     { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
     6699        /* set pin widget 1Ah (line in) for output (Back Surround)*/
     6700        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6701        /* set pin widget 18h (mic1) for output (CLFE)*/
     6702        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6703
     6704        { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6705        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6706
     6707        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
    57756708#if 0
    5776     { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
    5777     { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
     6709        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
     6710        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
    57786711#endif
    5779     {0} /* end */
     6712        {0} /* end */
    57806713};
    57816714
    57826715static struct hda_channel_mode alc861_threestack_modes[2] = {
    5783     { 2, alc861_threestack_ch2_init },
    5784     { 6, alc861_threestack_ch6_init },
     6716        { 2, alc861_threestack_ch2_init },
     6717        { 6, alc861_threestack_ch6_init },
     6718};
     6719/* Set mic1 as input and unmute the mixer */
     6720static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
     6721        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     6722        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
     6723        {0} /* end */
     6724};
     6725/* Set mic1 as output and mute mixer */
     6726static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
     6727        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6728        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
     6729        {0} /* end */
     6730};
     6731
     6732static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
     6733        { 2, alc861_uniwill_m31_ch2_init },
     6734        { 4, alc861_uniwill_m31_ch4_init },
     6735};
     6736
     6737/* Set mic1 and line-in as input and unmute the mixer */
     6738static struct hda_verb alc861_asus_ch2_init[] = {
     6739        /* set pin widget 1Ah (line in) for input */
     6740        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     6741        /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
     6742        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     6743
     6744        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
     6745#if 0
     6746        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
     6747        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
     6748#endif
     6749        {0} /* end */
     6750};
     6751/* Set mic1 nad line-in as output and mute mixer */
     6752static struct hda_verb alc861_asus_ch6_init[] = {
     6753        /* set pin widget 1Ah (line in) for output (Back Surround)*/
     6754        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6755        /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
     6756        /* set pin widget 18h (mic1) for output (CLFE)*/
     6757        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6758        /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
     6759        { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6760        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6761
     6762        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
     6763#if 0
     6764        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
     6765        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
     6766#endif
     6767        {0} /* end */
     6768};
     6769
     6770static struct hda_channel_mode alc861_asus_modes[2] = {
     6771        { 2, alc861_asus_ch2_init },
     6772        { 6, alc861_asus_ch6_init },
    57856773};
    57866774
     
    57886776
    57896777static struct snd_kcontrol_new alc861_base_mixer[] = {
    5790     /* output mixer control */
    5791     HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
    5792     HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
    5793     HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
    5794     HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
    5795     HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
    5796 
    5797     /*Input mixer control */
    5798     /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
    5799      HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
    5800     HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
    5801     HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
    5802     HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
    5803     HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
    5804     HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
    5805     HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
    5806     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
    5807     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
    5808 
    5809     /* Capture mixer control */
    5810     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    5811     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    5812     {
    5813         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5814         .name = "Capture Source",
    5815         .count = 1,
    5816         .info = alc_mux_enum_info,
    5817         .get = alc_mux_enum_get,
    5818         .put = alc_mux_enum_put,
    5819     },
    5820     {0} /* end */
     6778        /* output mixer control */
     6779        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     6780        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
     6781        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
     6782        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
     6783        HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
     6784
     6785        /*Input mixer control */
     6786        /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
     6787           HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
     6788        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
     6789        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
     6790        HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
     6791        HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
     6792        HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
     6793        HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
     6794        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
     6795        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
     6796 
     6797        /* Capture mixer control */
     6798        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6799        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6800        {
     6801                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6802                .name = "Capture Source",
     6803                .count = 1,
     6804                .info = alc_mux_enum_info,
     6805                .get = alc_mux_enum_get,
     6806                .put = alc_mux_enum_put,
     6807        },
     6808        {0} /* end */
    58216809};
    58226810
    58236811static struct snd_kcontrol_new alc861_3ST_mixer[] = {
    5824     /* output mixer control */
    5825     HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
    5826     HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
    5827     HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
    5828     HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
    5829     /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
    5830 
    5831     /* Input mixer control */
    5832     /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
    5833      HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
    5834     HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
    5835     HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
    5836     HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
    5837     HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
    5838     HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
    5839     HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
    5840     HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
    5841     HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
    5842 
    5843     /* Capture mixer control */
    5844     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    5845     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    5846     {
    5847         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5848         .name = "Capture Source",
    5849         .count = 1,
    5850         .info = alc_mux_enum_info,
    5851         .get = alc_mux_enum_get,
    5852         .put = alc_mux_enum_put,
    5853     },
    5854     {
    5855         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5856         .name = "Channel Mode",
    5857         .info = alc_ch_mode_info,
    5858         .get = alc_ch_mode_get,
    5859         .put = alc_ch_mode_put,
    5860         .private_value = ARRAY_SIZE(alc861_threestack_modes),
    5861     },
    5862     {0} /* end */
     6812        /* output mixer control */
     6813        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     6814        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
     6815        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
     6816        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
     6817        /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
     6818
     6819        /* Input mixer control */
     6820        /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
     6821           HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
     6822        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
     6823        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
     6824        HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
     6825        HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
     6826        HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
     6827        HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
     6828        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
     6829        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
     6830 
     6831        /* Capture mixer control */
     6832        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6833        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6834        {
     6835                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6836                .name = "Capture Source",
     6837                .count = 1,
     6838                .info = alc_mux_enum_info,
     6839                .get = alc_mux_enum_get,
     6840                .put = alc_mux_enum_put,
     6841        },
     6842        {
     6843                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6844                .name = "Channel Mode",
     6845                .info = alc_ch_mode_info,
     6846                .get = alc_ch_mode_get,
     6847                .put = alc_ch_mode_put,
     6848                .private_value = ARRAY_SIZE(alc861_threestack_modes),
     6849        },
     6850        {0} /* end */
     6851};
     6852
     6853static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
     6854        /* output mixer control */
     6855        HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     6856        HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
     6857        HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
     6858       
     6859        /*Capture mixer control */
     6860        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6861        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6862        {
     6863                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6864                .name = "Capture Source",
     6865                .count = 1,
     6866                .info = alc_mux_enum_info,
     6867                .get = alc_mux_enum_get,
     6868                .put = alc_mux_enum_put,
     6869        },
     6870
     6871        {0} /* end */
     6872};     
     6873
     6874static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
     6875        /* output mixer control */
     6876        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     6877        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
     6878        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
     6879        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
     6880        /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
     6881
     6882        /* Input mixer control */
     6883        /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
     6884           HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
     6885        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
     6886        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
     6887        HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
     6888        HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
     6889        HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
     6890        HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
     6891        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
     6892        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
     6893 
     6894        /* Capture mixer control */
     6895        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6896        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6897        {
     6898                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6899                .name = "Capture Source",
     6900                .count = 1,
     6901                .info = alc_mux_enum_info,
     6902                .get = alc_mux_enum_get,
     6903                .put = alc_mux_enum_put,
     6904        },
     6905        {
     6906                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6907                .name = "Channel Mode",
     6908                .info = alc_ch_mode_info,
     6909                .get = alc_ch_mode_get,
     6910                .put = alc_ch_mode_put,
     6911                .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
     6912        },
     6913        {0} /* end */
     6914};                     
     6915
     6916static struct snd_kcontrol_new alc861_asus_mixer[] = {
     6917        /* output mixer control */
     6918        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     6919        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
     6920        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
     6921        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
     6922        HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
     6923
     6924        /* Input mixer control */
     6925        HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
     6926        HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     6927        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
     6928        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
     6929        HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
     6930        HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
     6931        HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
     6932        HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
     6933        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
     6934        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
     6935 
     6936        /* Capture mixer control */
     6937        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6938        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6939        {
     6940                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6941                .name = "Capture Source",
     6942                .count = 1,
     6943                .info = alc_mux_enum_info,
     6944                .get = alc_mux_enum_get,
     6945                .put = alc_mux_enum_put,
     6946        },
     6947        {
     6948                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6949                .name = "Channel Mode",
     6950                .info = alc_ch_mode_info,
     6951                .get = alc_ch_mode_get,
     6952                .put = alc_ch_mode_put,
     6953                .private_value = ARRAY_SIZE(alc861_asus_modes),
     6954        },
     6955        {0}
     6956};
     6957
     6958/* additional mixer */
     6959static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
     6960        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
     6961        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
     6962        HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
     6963        HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
     6964        {0}
    58636965};
    58646966
     
    58676969 */
    58686970static struct hda_verb alc861_base_init_verbs[] = {
    5869     /*
    5870     * Unmute ADC0 and set the default input to mic-in
    5871     */
    5872     /* port-A for surround (rear panel) */
    5873     { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5874     { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5875     /* port-B for mic-in (rear panel) with vref */
    5876     { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    5877     /* port-C for line-in (rear panel) */
    5878     { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
    5879     /* port-D for Front */
    5880     { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5881     { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5882     /* port-E for HP out (front panel) */
    5883     { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
    5884     /* route front PCM to HP */
    5885     { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
    5886     /* port-F for mic-in (front panel) with vref */
    5887     { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    5888     /* port-G for CLFE (rear panel) */
    5889     { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5890     { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5891     /* port-H for side (rear panel) */
    5892     { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5893     { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5894     /* CD-in */
    5895     { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
    5896     /* route front mic to ADC1*/
    5897     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    5898     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5899 
    5900     /* Unmute DAC0~3 & spdif out*/
    5901     {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5902     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5903     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5904     {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5905     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5906 
    5907     /* Unmute Mixer 14 (mic) 1c (Line in)*/
    5908     {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5909     {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5910     {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5911     {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5912 
    5913     /* Unmute Stereo Mixer 15 */
    5914     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5915     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5916     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5917     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, //Output 0~12 step
    5918 
    5919     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5920     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5921     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5922     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5923     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5924     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5925     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5926     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5927     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
    5928     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5929 
    5930     {0}
     6971        /*
     6972        * Unmute ADC0 and set the default input to mic-in
     6973        */
     6974        /* port-A for surround (rear panel) */
     6975        { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6976        { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6977        /* port-B for mic-in (rear panel) with vref */
     6978        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     6979        /* port-C for line-in (rear panel) */
     6980        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     6981        /* port-D for Front */
     6982        { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6983        { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6984        /* port-E for HP out (front panel) */
     6985        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
     6986        /* route front PCM to HP */
     6987        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6988        /* port-F for mic-in (front panel) with vref */
     6989        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     6990        /* port-G for CLFE (rear panel) */
     6991        { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6992        { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6993        /* port-H for side (rear panel) */
     6994        { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     6995        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
     6996        /* CD-in */
     6997        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     6998        /* route front mic to ADC1*/
     6999        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     7000        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7001       
     7002        /* Unmute DAC0~3 & spdif out*/
     7003        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7004        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7005        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7006        {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7007        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7008       
     7009        /* Unmute Mixer 14 (mic) 1c (Line in)*/
     7010        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7011        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7012        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7013        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7014       
     7015        /* Unmute Stereo Mixer 15 */
     7016        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7017        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7018        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7019        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, //Output 0~12 step
     7020
     7021        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7022        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7023        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7024        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7025        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7026        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7027        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7028        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7029        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
     7030        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7031
     7032        {0}
    59317033};
    59327034
    59337035static struct hda_verb alc861_threestack_init_verbs[] = {
    5934     /*
    5935      * Unmute ADC0 and set the default input to mic-in
    5936      */
    5937     /* port-A for surround (rear panel) */
    5938     { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
    5939     /* port-B for mic-in (rear panel) with vref */
    5940     { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    5941     /* port-C for line-in (rear panel) */
    5942     { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
    5943     /* port-D for Front */
    5944     { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
    5945     { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
    5946     /* port-E for HP out (front panel) */
    5947     { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
    5948     /* route front PCM to HP */
    5949     { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
    5950     /* port-F for mic-in (front panel) with vref */
    5951     { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
    5952     /* port-G for CLFE (rear panel) */
    5953     { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
    5954     /* port-H for side (rear panel) */
    5955     { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
    5956     /* CD-in */
    5957     { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
    5958     /* route front mic to ADC1*/
    5959     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    5960     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5961     /* Unmute DAC0~3 & spdif out*/
    5962     {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5963     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5964     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5965     {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5966     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    5967 
    5968     /* Unmute Mixer 14 (mic) 1c (Line in)*/
    5969     {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5970     {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5971     {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5972     {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5973 
    5974     /* Unmute Stereo Mixer 15 */
    5975     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5976     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5977     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5978     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, //Output 0~12 step
    5979 
    5980     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5981     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5982     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5983     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5984     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5985     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5986     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    5987     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    5988     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
    5989     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    5990     {0}
    5991 };
     7036        /*
     7037         * Unmute ADC0 and set the default input to mic-in
     7038         */
     7039        /* port-A for surround (rear panel) */
     7040        { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     7041        /* port-B for mic-in (rear panel) with vref */
     7042        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     7043        /* port-C for line-in (rear panel) */
     7044        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     7045        /* port-D for Front */
     7046        { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     7047        { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
     7048        /* port-E for HP out (front panel) */
     7049        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
     7050        /* route front PCM to HP */
     7051        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
     7052        /* port-F for mic-in (front panel) with vref */
     7053        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     7054        /* port-G for CLFE (rear panel) */
     7055        { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     7056        /* port-H for side (rear panel) */
     7057        { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     7058        /* CD-in */
     7059        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     7060        /* route front mic to ADC1*/
     7061        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     7062        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7063        /* Unmute DAC0~3 & spdif out*/
     7064        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7065        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7066        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7067        {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7068        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7069       
     7070        /* Unmute Mixer 14 (mic) 1c (Line in)*/
     7071        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7072        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7073        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7074        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7075       
     7076        /* Unmute Stereo Mixer 15 */
     7077        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7078        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7079        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7080        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, //Output 0~12 step
     7081
     7082        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7083        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7084        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7085        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7086        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7087        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7088        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7089        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7090        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
     7091        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7092        {0}
     7093};
     7094
     7095static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
     7096        /*
     7097         * Unmute ADC0 and set the default input to mic-in
     7098         */
     7099        /* port-A for surround (rear panel) */
     7100        { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     7101        /* port-B for mic-in (rear panel) with vref */
     7102        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     7103        /* port-C for line-in (rear panel) */
     7104        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     7105        /* port-D for Front */
     7106        { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     7107        { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
     7108        /* port-E for HP out (front panel) */
     7109        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
     7110        /* route front PCM to HP */
     7111        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
     7112        /* port-F for mic-in (front panel) with vref */
     7113        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     7114        /* port-G for CLFE (rear panel) */
     7115        { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     7116        /* port-H for side (rear panel) */
     7117        { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
     7118        /* CD-in */
     7119        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     7120        /* route front mic to ADC1*/
     7121        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     7122        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7123        /* Unmute DAC0~3 & spdif out*/
     7124        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7125        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7126        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7127        {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7128        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7129       
     7130        /* Unmute Mixer 14 (mic) 1c (Line in)*/
     7131        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7132        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7133        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7134        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7135       
     7136        /* Unmute Stereo Mixer 15 */
     7137        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7138        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7139        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7140        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, //Output 0~12 step
     7141
     7142        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7143        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7144        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7145        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7146        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7147        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7148        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7149        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7150        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
     7151        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7152        {0}
     7153};
     7154
     7155static struct hda_verb alc861_asus_init_verbs[] = {
     7156        /*
     7157         * Unmute ADC0 and set the default input to mic-in
     7158         */
     7159        /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
     7160        { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
     7161        /* route front PCM to HP */
     7162        { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
     7163        /* port-B for mic-in (rear panel) with vref */
     7164        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     7165        /* port-C for line-in (rear panel) */
     7166        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     7167        /* port-D for Front */
     7168        { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     7169        { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
     7170        /* port-E for HP out (front panel) */
     7171        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
     7172        /* route front PCM to HP */
     7173        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
     7174        /* port-F for mic-in (front panel) with vref */
     7175        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
     7176        /* port-G for CLFE (rear panel) */
     7177        { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     7178        /* port-H for side (rear panel) */
     7179        { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
     7180        /* CD-in */
     7181        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
     7182        /* route front mic to ADC1*/
     7183        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     7184        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7185        /* Unmute DAC0~3 & spdif out*/
     7186        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7187        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7188        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7189        {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7190        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7191        /* Unmute Mixer 14 (mic) 1c (Line in)*/
     7192        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7193        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7194        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7195        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7196       
     7197        /* Unmute Stereo Mixer 15 */
     7198        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7199        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7200        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7201        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, /* Output 0~12 step */
     7202
     7203        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7204        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7205        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7206        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7207        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7208        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7209        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7210        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7211        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
     7212        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7213        {0}
     7214};
     7215
     7216/* additional init verbs for ASUS laptops */
     7217static struct hda_verb alc861_asus_laptop_init_verbs[] = {
     7218        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
     7219        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
     7220        {0}
     7221};
     7222
    59927223/*
    59937224 * generic initialization of ADC, input mixers and output mixers
    59947225 */
    59957226static struct hda_verb alc861_auto_init_verbs[] = {
    5996     /*
    5997      * Unmute ADC0 and set the default input to mic-in
    5998      */
    5999     //  {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
    6000     {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6001 
    6002     /* Unmute DAC0~3 & spdif out*/
    6003     {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    6004     {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    6005     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    6006     {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    6007     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    6008 
    6009     /* Unmute Mixer 14 (mic) 1c (Line in)*/
    6010     {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6011     {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6012     {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6013     {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6014 
    6015     /* Unmute Stereo Mixer 15 */
    6016     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6017     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6018     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    6019     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
    6020 
    6021     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6022     {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6023     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6024     {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6025     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6026     {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6027     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    6028     {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    6029 
    6030     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    6031     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    6032     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    6033     {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    6034     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
    6035     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    6036     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    6037     {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
    6038 
    6039     {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},      // set Mic 1
    6040 
    6041     {0}
    6042 };
     7227        /*
     7228         * Unmute ADC0 and set the default input to mic-in
     7229         */
     7230//      {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
     7231        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7232       
     7233        /* Unmute DAC0~3 & spdif out*/
     7234        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     7235        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     7236        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     7237        {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     7238        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     7239       
     7240        /* Unmute Mixer 14 (mic) 1c (Line in)*/
     7241        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7242        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7243        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7244        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7245       
     7246        /* Unmute Stereo Mixer 15 */
     7247        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7248        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7249        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
     7250        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
     7251
     7252        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7253        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7254        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7255        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7256        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7257        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7258        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     7259        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     7260
     7261        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     7262        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     7263        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},   
     7264        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},           
     7265        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     7266        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     7267        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},   
     7268        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},   
     7269
     7270        {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},  // set Mic 1
     7271
     7272        {0}
     7273};
     7274
     7275static struct hda_verb alc861_toshiba_init_verbs[] = {
     7276        {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     7277       
     7278        {0}
     7279};
     7280
     7281/* toggle speaker-output according to the hp-jack state */
     7282static void alc861_toshiba_automute(struct hda_codec *codec)
     7283{
     7284        unsigned int present;
     7285
     7286        present = snd_hda_codec_read(codec, 0x0f, 0,
     7287                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     7288        snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
     7289                                 0x80, present ? 0x80 : 0);
     7290        snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
     7291                                 0x80, present ? 0x80 : 0);
     7292        snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
     7293                                 0x80, present ? 0 : 0x80);
     7294        snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
     7295                                 0x80, present ? 0 : 0x80);
     7296}
     7297
     7298static void alc861_toshiba_unsol_event(struct hda_codec *codec,
     7299                                       unsigned int res)
     7300{
     7301        /* Looks like the unsol event is incompatible with the standard
     7302         * definition.  6bit tag is placed at 26 bit!
     7303         */
     7304        if ((res >> 26) == ALC880_HP_EVENT)
     7305                alc861_toshiba_automute(codec);
     7306}
    60437307
    60447308/* pcm configuration: identiacal with ALC880 */
     
    60527316
    60537317static struct hda_channel_mode alc861_8ch_modes[1] = {
    6054     { 8, NULL }
     7318        { 8, NULL }
    60557319};
    60567320
    60577321static hda_nid_t alc861_dac_nids[4] = {
    6058     /* front, surround, clfe, side */
    6059     0x03, 0x06, 0x05, 0x04
     7322        /* front, surround, clfe, side */
     7323        0x03, 0x06, 0x05, 0x04
    60607324};
    60617325
    60627326static hda_nid_t alc660_dac_nids[3] = {
    6063     /* front, clfe, surround */
    6064     0x03, 0x05, 0x06
     7327        /* front, clfe, surround */
     7328        0x03, 0x05, 0x06
    60657329};
    60667330
    60677331static hda_nid_t alc861_adc_nids[1] = {
    6068     /* ADC0-2 */
    6069     0x08,
     7332        /* ADC0-2 */
     7333        0x08,
    60707334};
    60717335
    60727336static struct hda_input_mux alc861_capture_source = {
    6073     .num_items = 5,
    6074     .items = {
    6075         { "Mic", 0x0 },
    6076         { "Front Mic", 0x3 },
    6077         { "Line", 0x1 },
    6078         { "CD", 0x4 },
    6079         { "Mixer", 0x5 },
    6080     },
     7337        .num_items = 5,
     7338        .items = {
     7339                { "Mic", 0x0 },
     7340                { "Front Mic", 0x3 },
     7341                { "Line", 0x1 },
     7342                { "CD", 0x4 },
     7343                { "Mixer", 0x5 },
     7344        },
    60817345};
    60827346
     
    60847348static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
    60857349{
    6086     int i;
    6087     hda_nid_t nid;
    6088 
    6089     spec->multiout.dac_nids = spec->private_dac_nids;
    6090     for (i = 0; i < cfg->line_outs; i++) {
    6091         nid = cfg->line_out_pins[i];
    6092         if (nid) {
    6093             if (i >= ARRAY_SIZE(alc861_dac_nids))
    6094                 continue;
    6095             spec->multiout.dac_nids[i] = alc861_dac_nids[i];
    6096         }
    6097     }
    6098     spec->multiout.num_dacs = cfg->line_outs;
    6099     return 0;
     7350        int i;
     7351        hda_nid_t nid;
     7352
     7353        spec->multiout.dac_nids = spec->private_dac_nids;
     7354        for (i = 0; i < cfg->line_outs; i++) {
     7355                nid = cfg->line_out_pins[i];
     7356                if (nid) {
     7357                        if (i >= ARRAY_SIZE(alc861_dac_nids))
     7358                                continue;
     7359                        spec->multiout.dac_nids[i] = alc861_dac_nids[i];
     7360                }
     7361        }
     7362        spec->multiout.num_dacs = cfg->line_outs;
     7363        return 0;
    61007364}
    61017365
    61027366/* add playback controls from the parsed DAC table */
    61037367static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
    6104                                              const struct auto_pin_cfg *cfg)
    6105 {
    6106     char name[32];
    6107     static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
    6108     hda_nid_t nid;
    6109     int i, idx, err;
    6110 
    6111     for (i = 0; i < cfg->line_outs; i++) {
    6112         nid = spec->multiout.dac_nids[i];
    6113         if (! nid)
    6114             continue;
    6115         if (nid == 0x05) {
    6116             /* Center/LFE */
    6117             if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
    6118                                    HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
    6119                 return err;
    6120             if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
    6121                                    HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
    6122                 return err;
    6123         } else {
    6124             for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
    6125                 if (nid == alc861_dac_nids[idx])
    6126                     break;
    6127             sprintf(name, "%s Playback Switch", chname[idx]);
    6128             if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
    6129                                    HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    6130                 return err;
    6131         }
    6132     }
    6133     return 0;
     7368                                             const struct auto_pin_cfg *cfg)
     7369{
     7370        char name[32];
     7371        static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
     7372        hda_nid_t nid;
     7373        int i, idx, err;
     7374
     7375        for (i = 0; i < cfg->line_outs; i++) {
     7376                nid = spec->multiout.dac_nids[i];
     7377                if (! nid)
     7378                        continue;
     7379                if (nid == 0x05) {
     7380                        /* Center/LFE */
     7381                        if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
     7382                                               HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
     7383                                return err;
     7384                        if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
     7385                                               HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
     7386                                return err;
     7387                } else {
     7388                        for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
     7389                                if (nid == alc861_dac_nids[idx])
     7390                                        break;
     7391                        sprintf(name, "%s Playback Switch", chname[idx]);
     7392                        if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
     7393                                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     7394                                return err;
     7395                }
     7396        }
     7397        return 0;
    61347398}
    61357399
    61367400static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
    61377401{
    6138     int err;
    6139     hda_nid_t nid;
    6140 
    6141     if (! pin)
    6142         return 0;
    6143 
    6144     if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
    6145         nid = 0x03;
    6146         if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
    6147                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    6148             return err;
    6149         spec->multiout.hp_nid = nid;
    6150     }
    6151     return 0;
     7402        int err;
     7403        hda_nid_t nid;
     7404
     7405        if (! pin)
     7406                return 0;
     7407
     7408        if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
     7409                nid = 0x03;
     7410                if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
     7411                                       HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     7412                        return err;
     7413                spec->multiout.hp_nid = nid;
     7414        }
     7415        return 0;
    61527416}
    61537417
     
    61557419static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
    61567420{
    6157     struct hda_input_mux *imux = &spec->private_imux;
    6158     int i, err, idx, idx1;
    6159 
    6160     for (i = 0; i < AUTO_PIN_LAST; i++) {
    6161         switch(cfg->input_pins[i]) {
    6162         case 0x0c:
    6163             idx1 = 1;
    6164             idx = 2;    // Line In
    6165             break;
    6166         case 0x0f:
    6167             idx1 = 2;
    6168             idx = 2;    // Line In
    6169             break;
    6170         case 0x0d:
    6171             idx1 = 0;
    6172             idx = 1;    // Mic In
    6173             break;
    6174         case 0x10:
    6175             idx1 = 3;
    6176             idx = 1;    // Mic In
    6177             break;
    6178         case 0x11:
    6179             idx1 = 4;
    6180             idx = 0;    // CD
    6181             break;
    6182         default:
    6183             continue;
    6184         }
    6185 
    6186         err = new_analog_input(spec, cfg->input_pins[i],
    6187                                auto_pin_cfg_labels[i], idx, 0x15);
    6188         if (err < 0)
    6189             return err;
    6190 
    6191         imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
    6192         imux->items[imux->num_items].index = idx1;
    6193         imux->num_items++;
    6194     }
    6195     return 0;
     7421        struct hda_input_mux *imux = &spec->private_imux;
     7422        int i, err, idx, idx1;
     7423
     7424        for (i = 0; i < AUTO_PIN_LAST; i++) {
     7425                switch(cfg->input_pins[i]) {
     7426                case 0x0c:
     7427                        idx1 = 1;
     7428                        idx = 2;        // Line In
     7429                        break;
     7430                case 0x0f:
     7431                        idx1 = 2;
     7432                        idx = 2;        // Line In
     7433                        break;
     7434                case 0x0d:
     7435                        idx1 = 0;
     7436                        idx = 1;        // Mic In
     7437                        break;
     7438                case 0x10:     
     7439                        idx1 = 3;
     7440                        idx = 1;        // Mic In
     7441                        break;
     7442                case 0x11:
     7443                        idx1 = 4;
     7444                        idx = 0;        // CD
     7445                        break;
     7446                default:
     7447                        continue;
     7448                }
     7449
     7450                err = new_analog_input(spec, cfg->input_pins[i],
     7451                                       auto_pin_cfg_labels[i], idx, 0x15);
     7452                if (err < 0)
     7453                        return err;
     7454
     7455                imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
     7456                imux->items[imux->num_items].index = idx1;
     7457                imux->num_items++;     
     7458        }
     7459        return 0;
    61967460}
    61977461
    61987462static struct snd_kcontrol_new alc861_capture_mixer[] = {
    6199     HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    6200     HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    6201 
    6202     {
    6203         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    6204         /* The multiple "Capture Source" controls confuse alsamixer
    6205         * So call somewhat different..
    6206         *FIXME: the controls appear in the "playback" view!
    6207         */
    6208         /* .name = "Capture Source", */
    6209         .name = "Input Source",
    6210         .count = 1,
    6211         .info = alc_mux_enum_info,
    6212         .get = alc_mux_enum_get,
    6213         .put = alc_mux_enum_put,
    6214     },
    6215     {0} /* end */
     7463        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     7464        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     7465
     7466        {
     7467                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     7468                /* The multiple "Capture Source" controls confuse alsamixer
     7469                * So call somewhat different..
     7470                *FIXME: the controls appear in the "playback" view!
     7471                */
     7472                /* .name = "Capture Source", */
     7473                .name = "Input Source",
     7474                .count = 1,
     7475                .info = alc_mux_enum_info,
     7476                .get = alc_mux_enum_get,
     7477                .put = alc_mux_enum_put,
     7478        },
     7479        {0} /* end */
    62167480};
    62177481
    62187482static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
    6219                                               int pin_type, int dac_idx)
    6220 {
    6221     /* set as output */
    6222 
    6223     snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
    6224     snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
     7483                                              int pin_type, int dac_idx)
     7484{
     7485        /* set as output */
     7486
     7487        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
     7488        snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
    62257489
    62267490}
     
    62287492static void alc861_auto_init_multi_out(struct hda_codec *codec)
    62297493{
    6230     struct alc_spec *spec = codec->spec;
    6231     int i;
    6232 
    6233     for (i = 0; i < spec->autocfg.line_outs; i++) {
    6234         hda_nid_t nid = spec->autocfg.line_out_pins[i];
    6235         if (nid)
    6236             alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
    6237     }
     7494        struct alc_spec *spec = codec->spec;
     7495        int i;
     7496
     7497        for (i = 0; i < spec->autocfg.line_outs; i++) {
     7498                hda_nid_t nid = spec->autocfg.line_out_pins[i];
     7499                if (nid)
     7500                        alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
     7501        }
    62387502}
    62397503
    62407504static void alc861_auto_init_hp_out(struct hda_codec *codec)
    62417505{
    6242     struct alc_spec *spec = codec->spec;
    6243     hda_nid_t pin;
    6244 
    6245     pin = spec->autocfg.hp_pin;
    6246     if (pin) /* connect to front */
    6247         alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
     7506        struct alc_spec *spec = codec->spec;
     7507        hda_nid_t pin;
     7508
     7509        pin = spec->autocfg.hp_pins[0];
     7510        if (pin) /* connect to front */
     7511                alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
    62487512}
    62497513
    62507514static void alc861_auto_init_analog_input(struct hda_codec *codec)
    62517515{
    6252     struct alc_spec *spec = codec->spec;
    6253     int i;
    6254 
    6255     for (i = 0; i < AUTO_PIN_LAST; i++) {
    6256         hda_nid_t nid = spec->autocfg.input_pins[i];
    6257         if ((nid>=0x0c) && (nid <=0x11)) {
    6258             snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    6259                                 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
    6260         }
    6261     }
     7516        struct alc_spec *spec = codec->spec;
     7517        int i;
     7518
     7519        for (i = 0; i < AUTO_PIN_LAST; i++) {
     7520                hda_nid_t nid = spec->autocfg.input_pins[i];
     7521                if ((nid>=0x0c) && (nid <=0x11)) {
     7522                        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     7523                                            i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
     7524                }
     7525        }
    62627526}
    62637527
     
    62667530static int alc861_parse_auto_config(struct hda_codec *codec)
    62677531{
    6268     struct alc_spec *spec = codec->spec;
    6269     int err;
    6270     static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
    6271 
    6272     if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
    6273                                             alc861_ignore)) < 0)
    6274         return err;
    6275     if (! spec->autocfg.line_outs)
    6276         return 0; /* can't find valid BIOS pin config */
    6277 
    6278     if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
    6279         (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
    6280         (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
    6281         (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
    6282         return err;
    6283 
    6284     spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    6285 
    6286     if (spec->autocfg.dig_out_pin)
    6287         spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
    6288 
    6289     if (spec->kctl_alloc)
    6290         spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
    6291 
    6292     spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
    6293 
    6294     spec->input_mux = &spec->private_imux;
    6295 
    6296     spec->adc_nids = alc861_adc_nids;
    6297     spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
    6298     spec->mixers[spec->num_mixers] = alc861_capture_mixer;
    6299     spec->num_mixers++;
    6300 
    6301     return 1;
     7532        struct alc_spec *spec = codec->spec;
     7533        int err;
     7534        static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
     7535
     7536        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
     7537                                                alc861_ignore)) < 0)
     7538                return err;
     7539        if (! spec->autocfg.line_outs)
     7540                return 0; /* can't find valid BIOS pin config */
     7541
     7542        if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
     7543            (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
     7544            (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
     7545            (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
     7546                return err;
     7547
     7548        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
     7549
     7550        if (spec->autocfg.dig_out_pin)
     7551                spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
     7552
     7553        if (spec->kctl_alloc)
     7554                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
     7555
     7556        spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
     7557
     7558        spec->num_mux_defs = 1;
     7559        spec->input_mux = &spec->private_imux;
     7560
     7561        spec->adc_nids = alc861_adc_nids;
     7562        spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
     7563        spec->mixers[spec->num_mixers] = alc861_capture_mixer;
     7564        spec->num_mixers++;
     7565
     7566        return 1;
    63027567}
    63037568
     
    63057570static void alc861_auto_init(struct hda_codec *codec)
    63067571{
    6307     alc861_auto_init_multi_out(codec);
    6308     alc861_auto_init_hp_out(codec);
    6309     alc861_auto_init_analog_input(codec);
    6310 
     7572        alc861_auto_init_multi_out(codec);
     7573        alc861_auto_init_hp_out(codec);
     7574        alc861_auto_init_analog_input(codec);
    63117575}
    63127576
     
    63157579 * configuration and preset
    63167580 */
    6317 static struct hda_board_config alc861_cfg_tbl[] = {
    6318     { .modelname = "3stack", .config = ALC861_3ST },
    6319     { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
    6320     .config = ALC861_3ST },
    6321     { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
    6322     .config = ALC660_3ST },
    6323     { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
    6324     { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
    6325     { .modelname = "auto", .config = ALC861_AUTO },
    6326     {0}
     7581static const char *alc861_models[ALC861_MODEL_LAST] = {
     7582        [ALC861_3ST]            = "3stack",
     7583        [ALC660_3ST]            = "3stack-660",
     7584        [ALC861_3ST_DIG]        = "3stack-dig",
     7585        [ALC861_6ST_DIG]        = "6stack-dig",
     7586        [ALC861_UNIWILL_M31]    = "uniwill-m31",
     7587        [ALC861_TOSHIBA]        = "toshiba",
     7588        [ALC861_ASUS]           = "asus",
     7589        [ALC861_ASUS_LAPTOP]    = "asus-laptop",
     7590        [ALC861_AUTO]           = "auto",
     7591};
     7592
     7593static struct snd_pci_quirk alc861_cfg_tbl[] = {
     7594    SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
     7595        SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
     7596        SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
     7597        SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
     7598        SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
     7599        SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
     7600        SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
     7601        SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
     7602        SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
     7603        {0}
    63277604};
    63287605
    63297606static struct alc_config_preset alc861_presets[] = {
    6330     [ALC861_3ST] = {
    6331         .mixers = { alc861_3ST_mixer },
    6332         .init_verbs = { alc861_threestack_init_verbs },
    6333         .num_dacs = ARRAY_SIZE(alc861_dac_nids),
    6334         .dac_nids = alc861_dac_nids,
    6335         .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
    6336         .channel_mode = alc861_threestack_modes,
    6337         .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
    6338         .adc_nids = alc861_adc_nids,
    6339         .input_mux = &alc861_capture_source,
    6340     },
    6341     [ALC861_3ST_DIG] = {
    6342         .mixers = { alc861_base_mixer },
    6343         .init_verbs = { alc861_threestack_init_verbs },
    6344         .num_dacs = ARRAY_SIZE(alc861_dac_nids),
    6345         .dac_nids = alc861_dac_nids,
    6346         .dig_out_nid = ALC861_DIGOUT_NID,
    6347         .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
    6348         .channel_mode = alc861_threestack_modes,
    6349         .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
    6350         .adc_nids = alc861_adc_nids,
    6351         .input_mux = &alc861_capture_source,
    6352     },
    6353     [ALC861_6ST_DIG] = {
    6354         .mixers = { alc861_base_mixer },
    6355         .init_verbs = { alc861_base_init_verbs },
    6356         .num_dacs = ARRAY_SIZE(alc861_dac_nids),
    6357         .dac_nids = alc861_dac_nids,
    6358         .dig_out_nid = ALC861_DIGOUT_NID,
    6359         .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
    6360         .channel_mode = alc861_8ch_modes,
    6361         .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
    6362         .adc_nids = alc861_adc_nids,
    6363         .input_mux = &alc861_capture_source,
    6364     },
    6365     [ALC660_3ST] = {
    6366         .mixers = { alc861_3ST_mixer },
    6367         .init_verbs = { alc861_threestack_init_verbs },
    6368         .num_dacs = ARRAY_SIZE(alc660_dac_nids),
    6369         .dac_nids = alc660_dac_nids,
    6370         .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
    6371         .channel_mode = alc861_threestack_modes,
    6372         .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
    6373         .adc_nids = alc861_adc_nids,
    6374         .input_mux = &alc861_capture_source,
    6375     },
     7607        [ALC861_3ST] = {
     7608                .mixers = { alc861_3ST_mixer },
     7609                .init_verbs = { alc861_threestack_init_verbs },
     7610                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7611                .dac_nids = alc861_dac_nids,
     7612                .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
     7613                .channel_mode = alc861_threestack_modes,
     7614                .need_dac_fix = 1,
     7615                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7616                .adc_nids = alc861_adc_nids,
     7617                .input_mux = &alc861_capture_source,
     7618        },
     7619        [ALC861_3ST_DIG] = {
     7620                .mixers = { alc861_base_mixer },
     7621                .init_verbs = { alc861_threestack_init_verbs },
     7622                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7623                .dac_nids = alc861_dac_nids,
     7624                .dig_out_nid = ALC861_DIGOUT_NID,
     7625                .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
     7626                .channel_mode = alc861_threestack_modes,
     7627                .need_dac_fix = 1,
     7628                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7629                .adc_nids = alc861_adc_nids,
     7630                .input_mux = &alc861_capture_source,
     7631        },
     7632        [ALC861_6ST_DIG] = {
     7633                .mixers = { alc861_base_mixer },
     7634                .init_verbs = { alc861_base_init_verbs },
     7635                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7636                .dac_nids = alc861_dac_nids,
     7637                .dig_out_nid = ALC861_DIGOUT_NID,
     7638                .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
     7639                .channel_mode = alc861_8ch_modes,
     7640                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7641                .adc_nids = alc861_adc_nids,
     7642                .input_mux = &alc861_capture_source,
     7643        },
     7644        [ALC660_3ST] = {
     7645                .mixers = { alc861_3ST_mixer },
     7646                .init_verbs = { alc861_threestack_init_verbs },
     7647                .num_dacs = ARRAY_SIZE(alc660_dac_nids),
     7648                .dac_nids = alc660_dac_nids,
     7649                .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
     7650                .channel_mode = alc861_threestack_modes,
     7651                .need_dac_fix = 1,
     7652                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7653                .adc_nids = alc861_adc_nids,
     7654                .input_mux = &alc861_capture_source,
     7655        },
     7656        [ALC861_UNIWILL_M31] = {
     7657                .mixers = { alc861_uniwill_m31_mixer },
     7658                .init_verbs = { alc861_uniwill_m31_init_verbs },
     7659                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7660                .dac_nids = alc861_dac_nids,
     7661                .dig_out_nid = ALC861_DIGOUT_NID,
     7662                .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
     7663                .channel_mode = alc861_uniwill_m31_modes,
     7664                .need_dac_fix = 1,
     7665                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7666                .adc_nids = alc861_adc_nids,
     7667                .input_mux = &alc861_capture_source,
     7668        },
     7669        [ALC861_TOSHIBA] = {
     7670                .mixers = { alc861_toshiba_mixer },
     7671                .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
     7672                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7673                .dac_nids = alc861_dac_nids,
     7674                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     7675                .channel_mode = alc883_3ST_2ch_modes,
     7676                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7677                .adc_nids = alc861_adc_nids,
     7678                .input_mux = &alc861_capture_source,
     7679                .unsol_event = alc861_toshiba_unsol_event,
     7680                .init_hook = alc861_toshiba_automute,
     7681        },
     7682        [ALC861_ASUS] = {
     7683                .mixers = { alc861_asus_mixer },
     7684                .init_verbs = { alc861_asus_init_verbs },
     7685                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7686                .dac_nids = alc861_dac_nids,
     7687                .dig_out_nid = ALC861_DIGOUT_NID,
     7688                .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
     7689                .channel_mode = alc861_asus_modes,
     7690                .need_dac_fix = 1,
     7691                .hp_nid = 0x06,
     7692                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7693                .adc_nids = alc861_adc_nids,
     7694                .input_mux = &alc861_capture_source,
     7695        },
     7696        [ALC861_ASUS_LAPTOP] = {
     7697                .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
     7698                .init_verbs = { alc861_asus_init_verbs,
     7699                                alc861_asus_laptop_init_verbs },
     7700                .num_dacs = ARRAY_SIZE(alc861_dac_nids),
     7701                .dac_nids = alc861_dac_nids,
     7702                .dig_out_nid = ALC861_DIGOUT_NID,
     7703                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     7704                .channel_mode = alc883_3ST_2ch_modes,
     7705                .need_dac_fix = 1,
     7706                .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
     7707                .adc_nids = alc861_adc_nids,
     7708                .input_mux = &alc861_capture_source,
     7709        },
    63767710};
    63777711
     
    63797713static int patch_alc861(struct hda_codec *codec)
    63807714{
    6381     struct alc_spec *spec;
    6382     int board_config;
    6383     int err;
    6384 
    6385     spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
    6386     if (spec == NULL)
    6387         return -ENOMEM;
    6388 
    6389     codec->spec = spec;
    6390 
    6391     board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
    6392     if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
    6393         printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
    6394         board_config = ALC861_AUTO;
    6395     }
    6396 
    6397     if (board_config == ALC861_AUTO) {
    6398         /* automatic parse from the BIOS config */
    6399         err = alc861_parse_auto_config(codec);
    6400         if (err < 0) {
    6401             alc_free(codec);
    6402             return err;
    6403         } else if (! err) {
    6404             printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS.  Using base mode...\n");
    6405             board_config = ALC861_3ST_DIG;
    6406         }
    6407     }
    6408 
    6409     if (board_config != ALC861_AUTO)
    6410         setup_preset(spec, &alc861_presets[board_config]);
    6411 
    6412     spec->stream_name_analog = "ALC861 Analog";
    6413     spec->stream_analog_playback = &alc861_pcm_analog_playback;
    6414     spec->stream_analog_capture = &alc861_pcm_analog_capture;
    6415 
    6416     spec->stream_name_digital = "ALC861 Digital";
    6417     spec->stream_digital_playback = &alc861_pcm_digital_playback;
    6418     spec->stream_digital_capture = &alc861_pcm_digital_capture;
    6419 
    6420     codec->patch_ops = alc_patch_ops;
    6421     if (board_config == ALC861_AUTO)
    6422         spec->init_hook = alc861_auto_init;
    6423 
    6424     return 0;
     7715        struct alc_spec *spec;
     7716        int board_config;
     7717        int err;
     7718
     7719        spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
     7720        if (spec == NULL)
     7721                return -ENOMEM;
     7722
     7723        codec->spec = spec;     
     7724
     7725        board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
     7726                                                  alc861_models,
     7727                                                  alc861_cfg_tbl);
     7728
     7729        if (board_config < 0) {
     7730                printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
     7731                       "trying auto-probe from BIOS...\n");
     7732                board_config = ALC861_AUTO;
     7733        }
     7734
     7735        if (board_config == ALC861_AUTO) {
     7736                /* automatic parse from the BIOS config */
     7737                err = alc861_parse_auto_config(codec);
     7738                if (err < 0) {
     7739                        alc_free(codec);
     7740                        return err;
     7741                } else if (! err) {
     7742                        printk(KERN_INFO
     7743                               "hda_codec: Cannot set up configuration "
     7744                               "from BIOS.  Using base mode...\n");
     7745                   board_config = ALC861_3ST_DIG;
     7746                }
     7747        }
     7748
     7749        if (board_config != ALC861_AUTO)
     7750                setup_preset(spec, &alc861_presets[board_config]);
     7751
     7752        spec->stream_name_analog = "ALC861 Analog";
     7753        spec->stream_analog_playback = &alc861_pcm_analog_playback;
     7754        spec->stream_analog_capture = &alc861_pcm_analog_capture;
     7755
     7756        spec->stream_name_digital = "ALC861 Digital";
     7757        spec->stream_digital_playback = &alc861_pcm_digital_playback;
     7758        spec->stream_digital_capture = &alc861_pcm_digital_capture;
     7759
     7760        codec->patch_ops = alc_patch_ops;
     7761        if (board_config == ALC861_AUTO)
     7762                spec->init_hook = alc861_auto_init;
     7763               
     7764        return 0;
    64257765}
    64267766
     
    64297769 */
    64307770struct hda_codec_preset snd_hda_preset_realtek[] = {
    6431     { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
    6432     { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
    6433     { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
    6434     { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
    6435     { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
    6436     { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
    6437     { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
    6438     { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
    6439     .patch = patch_alc861 },
    6440     { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
    6441     .patch = patch_alc861 },
    6442     {0} /* terminator */
    6443 };
     7771        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
     7772        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
     7773        { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
     7774        { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
     7775        { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
     7776        { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
     7777        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
     7778        { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
     7779          .patch = patch_alc861 },
     7780        { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
     7781          .patch = patch_alc861 },
     7782        { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
     7783        {0} /* terminator */
     7784};
  • GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c

    r77 r86  
    3737#define NUM_CONTROL_ALLOC       32
    3838#define STAC_HP_EVENT           0x37
    39 #define STAC_UNSOL_ENABLE       (AC_USRSP_EN | STAC_HP_EVENT)
    40 
    41 #define STAC_REF                0
    42 #define STAC_D945GTP3           1
    43 #define STAC_D945GTP5           2
    44 #define STAC_MACMINI            3
    45 #define STAC_D965_2112          4
    46 #define STAC_D965_284B          5
    47 #define STAC_922X_MODELS        6       /* number of 922x models */
     39
     40#define PCI_VENDOR_ID_DELL              0x1028
     41
     42enum {
     43        STAC_REF,
     44        STAC_9200_MODELS
     45};
     46
     47enum {
     48        STAC_9205_REF,
     49        STAC_9205_MODELS
     50};
     51
     52enum {
     53        STAC_D945_REF,
     54        STAC_D945GTP3,
     55        STAC_D945GTP5,
     56        STAC_MACMINI,
     57        STAC_922X_MODELS
     58};
     59
     60enum {
     61        STAC_D965_REF,
     62        STAC_D965_3ST,
     63        STAC_D965_5ST,
     64        STAC_927X_MODELS
     65};
    4866
    4967struct sigmatel_spec {
     
    5472        unsigned int surr_switch: 1;
    5573        unsigned int line_switch: 1;
    56         unsigned int mic_switch: 1;
    57         unsigned int alt_switch: 1;
    58         unsigned int hp_detect: 1;
    59         unsigned int gpio_mute: 1;
     74        unsigned int mic_switch: 1;
     75        unsigned int alt_switch: 1;
     76        unsigned int hp_detect: 1;
     77        unsigned int gpio_mute: 1;
    6078
    6179        /* playback */
    62         struct hda_multi_out multiout;
    63         hda_nid_t dac_nids[5];
     80        struct hda_multi_out multiout;
     81        hda_nid_t dac_nids[5];
    6482
    6583        /* capture */
     
    6886        hda_nid_t *mux_nids;
    6987        unsigned int num_muxes;
     88        hda_nid_t *dmic_nids;
     89        unsigned int num_dmics;
     90        hda_nid_t dmux_nid;
    7091        hda_nid_t dig_in_nid;
    7192
     
    7495        unsigned int num_pins;
    7596        unsigned int *pin_configs;
     97        unsigned int *bios_pin_configs;
    7698
    7799        /* codec specific stuff */
     
    80102
    81103        /* capture source */
    82         struct hda_input_mux *input_mux;
    83         unsigned int cur_mux[3];
     104        struct hda_input_mux *dinput_mux;
     105        unsigned int cur_dmux;
     106        struct hda_input_mux *input_mux;
     107        unsigned int cur_mux[3];
    84108
    85109        /* i/o switches */
     
    92116        unsigned int num_kctl_alloc, num_kctl_used;
    93117        struct snd_kcontrol_new *kctl_alloc;
     118        struct hda_input_mux private_dimux;
    94119        struct hda_input_mux private_imux;
    95120};
     
    111136};
    112137
    113 static hda_nid_t stac9227_adc_nids[2] = {
    114         0x07, 0x08,
    115 };
    116 
    117 #if 0
    118 static hda_nid_t d965_2112_dac_nids[3] = {
    119         0x02, 0x03, 0x05,
    120 };
    121 #endif
    122 
    123138static hda_nid_t stac922x_mux_nids[2] = {
    124     0x12, 0x13,
    125 };
    126 
    127 static hda_nid_t stac9227_mux_nids[2] = {
    128         0x15, 0x16,
     139        0x12, 0x13,
    129140};
    130141
    131142static hda_nid_t stac927x_adc_nids[3] = {
    132     0x07, 0x08, 0x09
     143        0x07, 0x08, 0x09
    133144};
    134145
    135146static hda_nid_t stac927x_mux_nids[3] = {
    136     0x15, 0x16, 0x17
     147        0x15, 0x16, 0x17
     148};
     149
     150static hda_nid_t stac9205_adc_nids[2] = {
     151        0x12, 0x13
     152};
     153
     154static hda_nid_t stac9205_mux_nids[2] = {
     155        0x19, 0x1a
     156};
     157
     158static hda_nid_t stac9205_dmic_nids[3] = {
     159        0x17, 0x18, 0
    137160};
    138161
    139162static hda_nid_t stac9200_pin_nids[8] = {
    140         0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
     163        0x08, 0x09, 0x0d, 0x0e,
     164        0x0f, 0x10, 0x11, 0x12,
    141165};
    142166
     
    147171
    148172static hda_nid_t stac927x_pin_nids[14] = {
    149     0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
    150     0x0f, 0x10, 0x11, 0x12, 0x13,
    151     0x14, 0x21, 0x22, 0x23,
    152 };
     173        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
     174        0x0f, 0x10, 0x11, 0x12, 0x13,
     175        0x14, 0x21, 0x22, 0x23,
     176};
     177
     178static hda_nid_t stac9205_pin_nids[12] = {
     179        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
     180        0x0f, 0x14, 0x16, 0x17, 0x18,
     181        0x21, 0x22,
     182       
     183};
     184
     185static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
     186                                   struct snd_ctl_elem_info *uinfo)
     187{
     188        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     189        struct sigmatel_spec *spec = codec->spec;
     190        return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
     191}
     192
     193static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
     194                                  struct snd_ctl_elem_value *ucontrol)
     195{
     196        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     197        struct sigmatel_spec *spec = codec->spec;
     198
     199        ucontrol->value.enumerated.item[0] = spec->cur_dmux;
     200        return 0;
     201}
     202
     203static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
     204                                  struct snd_ctl_elem_value *ucontrol)
     205{
     206        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     207        struct sigmatel_spec *spec = codec->spec;
     208
     209        return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
     210                                     spec->dmux_nid, &spec->cur_dmux);
     211}
    153212
    154213static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
     
    186245
    187246static struct hda_verb stac922x_core_init[] = {
    188         /* set master volume and direct control */
    189     { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    190     {0}
    191 };
    192 
    193 static struct hda_verb stac9227_core_init[] = {
    194         /* set master volume and direct control */
     247        /* set master volume and direct control */     
    195248        { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     249        {0}
     250};
     251
     252static struct hda_verb d965_core_init[] = {
     253        /* set master volume and direct control */     
     254        { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    196255        /* unmute node 0x1b */
    197256        { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    198         {0}
    199 };
    200 
    201 static struct hda_verb d965_2112_core_init[] = {
    202         /* set master volume and direct control */
    203         { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    204         /* unmute node 0x1b */
    205         { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    206         /* select node 0x03 as DAC */
     257        /* select node 0x03 as DAC */   
    207258        { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
    208259        {0}
     
    210261
    211262static struct hda_verb stac927x_core_init[] = {
    212     /* set master volume and direct control */
    213     { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    214     {0}
     263        /* set master volume and direct control */     
     264        { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     265        {0}
     266};
     267
     268static struct hda_verb stac9205_core_init[] = {
     269        /* set master volume and direct control */     
     270        { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     271        {0}
    215272};
    216273
     
    263320};
    264321
    265 static snd_kcontrol_new_t stac927x_mixer[] = {
    266     {
    267         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    268         .name = "Input Source",
    269         .count = 1,
    270         .info = stac92xx_mux_enum_info,
    271         .get = stac92xx_mux_enum_get,
    272         .put = stac92xx_mux_enum_put,
    273     },
    274     HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
    275     HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
    276     HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
    277     {0} /* end */
     322static struct snd_kcontrol_new stac927x_mixer[] = {
     323        {
     324                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     325                .name = "Input Source",
     326                .count = 1,
     327                .info = stac92xx_mux_enum_info,
     328                .get = stac92xx_mux_enum_get,
     329                .put = stac92xx_mux_enum_put,
     330        },
     331        HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
     332        HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
     333        HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
     334        {0} /* end */
     335};
     336
     337static struct snd_kcontrol_new stac9205_mixer[] = {
     338        {
     339                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     340                .name = "Digital Input Source",
     341                .count = 1,
     342                .info = stac92xx_dmux_enum_info,
     343                .get = stac92xx_dmux_enum_get,
     344                .put = stac92xx_dmux_enum_put,
     345        },
     346        {
     347                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     348                .name = "Input Source",
     349                .count = 1,
     350                .info = stac92xx_mux_enum_info,
     351                .get = stac92xx_mux_enum_get,
     352                .put = stac92xx_mux_enum_put,
     353        },
     354        HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
     355        HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
     356        HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
     357        {0} /* end */
    278358};
    279359
     
    304384                        return err;
    305385        }
    306         return 0;
     386        return 0;       
    307387}
    308388
     
    312392};
    313393
    314 static unsigned int *stac9200_brd_tbl[] = {
    315         ref9200_pin_configs,
    316 };
    317 
    318 static struct hda_board_config stac9200_cfg_tbl[] = {
    319         { .modelname = "ref",
    320           .pci_subvendor = PCI_VENDOR_ID_INTEL,
    321           .pci_subdevice = 0x2668,      /* DFI LanParty */
    322           .config = STAC_REF },
     394static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
     395        [STAC_REF] = ref9200_pin_configs,
     396};
     397
     398static const char *stac9200_models[STAC_9200_MODELS] = {
     399        [STAC_REF] = "ref",
     400};
     401
     402static struct snd_pci_quirk stac9200_cfg_tbl[] = {
     403        /* SigmaTel reference board */
     404        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
     405                      "DFI LanParty", STAC_REF),
     406        /* Dell laptops have BIOS problem */
     407        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
     408                      "Dell Inspiron 630m", STAC_REF),
     409        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
     410                      "Dell Latitude D620", STAC_REF),
     411        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
     412                      "Dell Latitude 120L", STAC_REF),
    323413        {0} /* terminator */
    324414};
     
    331421
    332422static unsigned int d945gtp3_pin_configs[10] = {
    333     0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
    334     0x40000100, 0x40000100, 0x40000100, 0x40000100,
    335     0x02a19120, 0x40000100,
     423        0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
     424        0x40000100, 0x40000100, 0x40000100, 0x40000100,
     425        0x02a19120, 0x40000100,
    336426};
    337427
    338428static unsigned int d945gtp5_pin_configs[10] = {
    339     0x0221401f, 0x01011012, 0x01813024, 0x01014010,
    340     0x01a19021, 0x01016011, 0x01452130, 0x40000100,
    341     0x02a19320, 0x40000100,
    342 };
    343 
    344 static unsigned int d965_2112_pin_configs[10] = {
    345         0x0221401f, 0x40000100, 0x40000100, 0x01014011,
    346         0x01a19021, 0x01813024, 0x01452130, 0x40000100,
     429        0x0221401f, 0x01011012, 0x01813024, 0x01014010,
     430        0x01a19021, 0x01016011, 0x01452130, 0x40000100,
    347431        0x02a19320, 0x40000100,
    348432};
    349433
    350434static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
    351         [STAC_REF] =    ref922x_pin_configs,
     435        [STAC_D945_REF] = ref922x_pin_configs,
    352436        [STAC_D945GTP3] = d945gtp3_pin_configs,
    353437        [STAC_D945GTP5] = d945gtp5_pin_configs,
    354         [STAC_D965_2112] = d965_2112_pin_configs,
    355 };
    356 
    357 static struct hda_board_config stac922x_cfg_tbl[] = {
    358         { .modelname = "ref",
    359           .pci_subvendor = PCI_VENDOR_ID_INTEL,
    360           .pci_subdevice = 0x2668,      /* DFI LanParty */
    361           .config = STAC_REF },         /* SigmaTel reference board */
    362         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    363           .pci_subdevice = 0x0101,
    364           .config = STAC_D945GTP3 },    /* Intel D945GTP - 3 Stack */
    365           { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    366           .pci_subdevice = 0x0202,
    367           .config = STAC_D945GTP3 },    /* Intel D945GNT - 3 Stack, 9221 A1 */
    368           { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    369           .pci_subdevice = 0x0b0b,
    370           .config = STAC_D945GTP3 },    /* Intel D945PSN - 3 Stack, 9221 A1 */
    371           { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    372           .pci_subdevice = 0x0404,
    373           .config = STAC_D945GTP5 },    /* Intel D945GTP - 5 Stack */
    374         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    375           .pci_subdevice = 0x0303,
    376           .config = STAC_D945GTP5 },    /* Intel D945GNT - 5 Stack */
    377         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    378           .pci_subdevice = 0x0013,
    379           .config = STAC_D945GTP5 },    /* Intel D955XBK - 5 Stack */
    380         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    381           .pci_subdevice = 0x0417,
    382           .config = STAC_D945GTP5 },    /* Intel D975XBK - 5 Stack */
    383           { .pci_subvendor = 0x8384,
    384           .pci_subdevice = 0x7680,
    385           .config = STAC_MACMINI },     /* Apple Mac Mini (early 2006) */
    386           { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    387           .pci_subdevice = 0x2112,
    388           .config = STAC_D965_2112 },
    389         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
    390           .pci_subdevice = 0x284b,
    391           .config = STAC_D965_284B },
     438        [STAC_MACMINI] = d945gtp5_pin_configs,
     439};
     440
     441static const char *stac922x_models[STAC_922X_MODELS] = {
     442        [STAC_D945_REF] = "ref",
     443        [STAC_D945GTP5] = "5stack",
     444        [STAC_D945GTP3] = "3stack",
     445        [STAC_MACMINI]  = "macmini",
     446};
     447
     448static struct snd_pci_quirk stac922x_cfg_tbl[] = {
     449        /* SigmaTel reference board */
     450        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
     451                      "DFI LanParty", STAC_D945_REF),
     452        /* Intel 945G based systems */
     453        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
     454                      "Intel D945G", STAC_D945GTP3),
     455        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
     456                      "Intel D945G", STAC_D945GTP3),
     457        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
     458                      "Intel D945G", STAC_D945GTP3),
     459        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
     460                      "Intel D945G", STAC_D945GTP3),
     461        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
     462                      "Intel D945G", STAC_D945GTP3),
     463        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
     464                      "Intel D945G", STAC_D945GTP3),
     465        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
     466                      "Intel D945G", STAC_D945GTP3),
     467        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
     468                      "Intel D945G", STAC_D945GTP3),
     469        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
     470                      "Intel D945G", STAC_D945GTP3),
     471        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
     472                      "Intel D945G", STAC_D945GTP3),
     473        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
     474                      "Intel D945G", STAC_D945GTP3),
     475        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
     476                      "Intel D945G", STAC_D945GTP3),
     477        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
     478                      "Intel D945G", STAC_D945GTP3),
     479        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
     480                      "Intel D945G", STAC_D945GTP3),
     481        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
     482                      "Intel D945G", STAC_D945GTP3),
     483        /* Intel D945G 5-stack systems */
     484        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
     485                      "Intel D945G", STAC_D945GTP5),
     486        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
     487                      "Intel D945G", STAC_D945GTP5),
     488        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
     489                      "Intel D945G", STAC_D945GTP5),
     490        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
     491                      "Intel D945G", STAC_D945GTP5),
     492        /* Intel 945P based systems */
     493        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
     494                      "Intel D945P", STAC_D945GTP3),
     495        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
     496                      "Intel D945P", STAC_D945GTP3),
     497        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
     498                      "Intel D945P", STAC_D945GTP3),
     499        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
     500                      "Intel D945P", STAC_D945GTP3),
     501        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
     502                      "Intel D945P", STAC_D945GTP3),
     503        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
     504                      "Intel D945P", STAC_D945GTP5),
     505        /* other systems  */
     506        /* Apple Mac Mini (early 2006) */
     507        SND_PCI_QUIRK(0x8384, 0x7680,
     508                      "Mac Mini", STAC_MACMINI),
    392509        {0} /* terminator */
    393510};
    394511
    395512static unsigned int ref927x_pin_configs[14] = {
    396     0x01813122, 0x01a19021, 0x01014010, 0x01016011,
    397     0x01012012, 0x01011014, 0x40000100, 0x40000100,
    398     0x40000100, 0x40000100, 0x40000100, 0x01441030,
    399     0x01c41030, 0x40000100,
    400 };
    401 
    402 static unsigned int *stac927x_brd_tbl[] = {
    403     ref927x_pin_configs,
    404 };
    405 
    406 static struct hda_board_config stac927x_cfg_tbl[] = {
    407     { .modelname = "ref",
    408     .pci_subvendor = PCI_VENDOR_ID_INTEL,
    409     .pci_subdevice = 0x2668,      /* DFI LanParty */
    410     .config = STAC_REF },         /* SigmaTel reference board */
    411     {0} /* terminator */
    412 };
     513        0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
     514        0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
     515        0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
     516        0x01c42190, 0x40000100,
     517};
     518
     519static unsigned int d965_3st_pin_configs[14] = {
     520        0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
     521        0x01a19021, 0x01813024, 0x40000100, 0x40000100,
     522        0x40000100, 0x40000100, 0x40000100, 0x40000100,
     523        0x40000100, 0x40000100
     524};
     525
     526static unsigned int d965_5st_pin_configs[14] = {
     527        0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
     528        0x01a19040, 0x01011012, 0x01016011, 0x40000100,
     529        0x40000100, 0x40000100, 0x40000100, 0x01442070,
     530        0x40000100, 0x40000100
     531};
     532
     533static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
     534        [STAC_D965_REF] = ref927x_pin_configs,
     535        [STAC_D965_3ST] = d965_3st_pin_configs,
     536        [STAC_D965_5ST] = d965_5st_pin_configs,
     537};
     538
     539static const char *stac927x_models[STAC_927X_MODELS] = {
     540        [STAC_D965_REF] = "ref",
     541        [STAC_D965_3ST] = "3stack",
     542        [STAC_D965_5ST] = "5stack",
     543};
     544
     545static struct snd_pci_quirk stac927x_cfg_tbl[] = {
     546        /* SigmaTel reference board */
     547        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
     548                      "DFI LanParty", STAC_D965_REF),
     549         /* Intel 946 based systems */
     550        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
     551        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
     552        /* 965 based 3 stack systems */
     553        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
     554        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
     555        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
     556        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
     557        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
     558        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
     559        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
     560        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
     561        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
     562        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
     563        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
     564        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
     565        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
     566        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
     567        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
     568        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
     569        /* 965 based 5 stack systems */
     570        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
     571        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
     572        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
     573        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
     574        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
     575        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
     576        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
     577        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
     578        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
     579        {0} /* terminator */
     580};
     581
     582static unsigned int ref9205_pin_configs[12] = {
     583        0x40000100, 0x40000100, 0x01016011, 0x01014010,
     584        0x01813122, 0x01a19021, 0x40000100, 0x40000100,
     585        0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
     586};
     587
     588static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
     589        ref9205_pin_configs,
     590};
     591
     592static const char *stac9205_models[STAC_9205_MODELS] = {
     593        [STAC_9205_REF] = "ref",
     594};
     595
     596static struct snd_pci_quirk stac9205_cfg_tbl[] = {
     597        /* SigmaTel reference board */
     598        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
     599                      "DFI LanParty", STAC_9205_REF),
     600        {0} /* terminator */
     601};
     602
     603static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
     604{
     605        int i;
     606        struct sigmatel_spec *spec = codec->spec;
     607       
     608        if (! spec->bios_pin_configs) {
     609                spec->bios_pin_configs = kcalloc(spec->num_pins,
     610                                                 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
     611                if (! spec->bios_pin_configs)
     612                        return -ENOMEM;
     613        }
     614       
     615        for (i = 0; i < spec->num_pins; i++) {
     616                hda_nid_t nid = spec->pin_nids[i];
     617                unsigned int pin_cfg;
     618               
     619                pin_cfg = snd_hda_codec_read(codec, nid, 0,
     620                        AC_VERB_GET_CONFIG_DEFAULT, 0x00);     
     621                snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
     622                                        nid, pin_cfg);
     623                spec->bios_pin_configs[i] = pin_cfg;
     624        }
     625       
     626        return 0;
     627}
    413628
    414629static void stac92xx_set_config_regs(struct hda_codec *codec)
     
    418633        unsigned int pin_cfg;
    419634
    420         for (i=0; i < spec->num_pins; i++) {
     635        if (! spec->pin_nids || ! spec->pin_configs)
     636                return;
     637
     638        for (i = 0; i < spec->num_pins; i++) {
    421639                snd_hda_codec_write(codec, spec->pin_nids[i], 0,
    422640                                    AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
     
    433651                pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
    434652                                             AC_VERB_GET_CONFIG_DEFAULT,
    435                                              0x00);
     653                                             0x00);     
    436654                snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
    437655        }
     
    544762
    545763static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
    546     .substreams = 1,
    547     .channels_min = 2,
    548     .channels_max = 2,
    549     .nid = 0x06, /* NID to query formats and rates */
    550     .ops = {
    551         .open = stac92xx_playback_pcm_open,
    552         .prepare = stac92xx_playback_pcm_prepare,
    553         .cleanup = stac92xx_playback_pcm_cleanup
    554     },
     764        .substreams = 1,
     765        .channels_min = 2,
     766        .channels_max = 2,
     767        .nid = 0x06, /* NID to query formats and rates */
     768        .ops = {
     769                .open = stac92xx_playback_pcm_open,
     770                .prepare = stac92xx_playback_pcm_prepare,
     771                .cleanup = stac92xx_playback_pcm_cleanup
     772        },
    555773};
    556774
     
    558776        .substreams = 2,
    559777        .channels_min = 2,
    560         .channels_max = 2,
    561         /* NID is set in stac92xx_build_pcms */
     778        .channels_max = 2,
     779        /* NID is set in stac92xx_build_pcms */
    562780        .ops = {
    563781                .prepare = stac92xx_capture_pcm_prepare,
     
    577795        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
    578796        info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
    579         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
    580 
    581         if (spec->alt_switch) {
    582             codec->num_pcms++;
    583             info++;
    584             info->name = "STAC92xx Analog Alt";
    585             info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
    586         }
     797        info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
     798
     799        if (spec->alt_switch) {
     800                codec->num_pcms++;
     801                info++;
     802                info->name = "STAC92xx Analog Alt";
     803                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
     804        }
     805
    587806        if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
    588807                codec->num_pcms++;
     
    604823static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
    605824{
    606     unsigned int pincap = snd_hda_param_read(codec, nid,
    607                                             AC_PAR_PIN_CAP);
    608     pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
    609     if (pincap & AC_PINCAP_VREF_100)
    610         return AC_PINCTL_VREF_100;
    611     if (pincap & AC_PINCAP_VREF_80)
    612         return AC_PINCTL_VREF_80;
    613     if (pincap & AC_PINCAP_VREF_50)
    614         return AC_PINCTL_VREF_50;
    615     if (pincap & AC_PINCAP_VREF_GRD)
    616         return AC_PINCTL_VREF_GRD;
    617     return 0;
     825        unsigned int pincap = snd_hda_param_read(codec, nid,
     826                                                AC_PAR_PIN_CAP);
     827        pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
     828        if (pincap & AC_PINCAP_VREF_100)
     829                return AC_PINCTL_VREF_100;
     830        if (pincap & AC_PINCAP_VREF_80)
     831                return AC_PINCTL_VREF_80;
     832        if (pincap & AC_PINCAP_VREF_50)
     833                return AC_PINCTL_VREF_50;
     834        if (pincap & AC_PINCAP_VREF_GRD)
     835                return AC_PINCTL_VREF_GRD;
     836        return 0;
    618837}
    619838
     
    654873
    655874        if (val)
    656             stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    657         else {
    658             unsigned int pinctl = AC_PINCTL_IN_EN;
    659             if (io_idx) /* set VREF for mic */
    660                 pinctl |= stac92xx_get_vref(codec, nid);
    661             stac92xx_auto_set_pinctl(codec, nid, pinctl);
    662         }
    663 
     875                stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
     876        else {
     877                unsigned int pinctl = AC_PINCTL_IN_EN;
     878                if (io_idx) /* set VREF for mic */
     879                        pinctl |= stac92xx_get_vref(codec, nid);
     880                stac92xx_auto_set_pinctl(codec, nid, pinctl);
     881        }
    664882        return 1;
    665883}
     
    773991 */
    774992/* fill in the dac_nids table from the parsed pin configuration */
    775 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
     993static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
     994                                       const struct auto_pin_cfg *cfg)
    776995{
    777996        struct sigmatel_spec *spec = codec->spec;
     
    7861005        }
    7871006
    788         spec->multiout.num_dacs = cfg->line_outs;
    789 
     1007        spec->multiout.num_dacs = cfg->line_outs;
     1008
     1009        return 0;
     1010}
     1011
     1012/* create volume control/switch for the given prefx type */
     1013static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
     1014{
     1015        char name[32];
     1016        int err;
     1017
     1018        sprintf(name, "%s Playback Volume", pfx);
     1019        err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
     1020                                   HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
     1021        if (err < 0)
     1022                return err;
     1023        sprintf(name, "%s Playback Switch", pfx);
     1024        err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
     1025                                   HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
     1026        if (err < 0)
     1027                return err;
    7901028        return 0;
    7911029}
    7921030
    7931031/* add playback controls from the parsed DAC table */
    794 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg)
    795 {
    796         char name[32];
    797         static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
     1032static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
     1033                                               const struct auto_pin_cfg *cfg)
     1034{
     1035        static const char *chname[4] = {
     1036                "Front", "Surround", NULL /*CLFE*/, "Side"
     1037        };
    7981038        hda_nid_t nid;
    7991039        int i, err;
     
    8071047                if (i == 2) {
    8081048                        /* Center/LFE */
    809                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
    810                                                HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
     1049                        err = create_controls(spec, "Center", nid, 1);
     1050                        if (err < 0)
    8111051                                return err;
    812                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
    813                                                HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
    814                                 return err;
    815                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
    816                                                HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
    817                                 return err;
    818                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
    819                                                HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
     1052                        err = create_controls(spec, "LFE", nid, 2);
     1053                        if (err < 0)
    8201054                                return err;
    8211055                } else {
    822                         sprintf(name, "%s Playback Volume", chname[i]);
    823                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
    824                                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    825                                 return err;
    826                         sprintf(name, "%s Playback Switch", chname[i]);
    827                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
    828                                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
     1056                        err = create_controls(spec, chname[i], nid, 3);
     1057                        if (err < 0)
    8291058                                return err;
    8301059                }
     
    8421071}
    8431072
    844 /* add playback controls for HP output */
    845 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
    846 {
    847         struct sigmatel_spec *spec = codec->spec;
    848         hda_nid_t pin = cfg->hp_pin;
     1073static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
     1074{
     1075        int i;
     1076
     1077        for (i = 0; i < spec->multiout.num_dacs; i++) {
     1078                if (spec->multiout.dac_nids[i] == nid)
     1079                        return 1;
     1080        }
     1081        if (spec->multiout.hp_nid == nid)
     1082                return 1;
     1083        return 0;
     1084}
     1085
     1086static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
     1087{
     1088        if (!spec->multiout.hp_nid)
     1089                spec->multiout.hp_nid = nid;
     1090        else if (spec->multiout.num_dacs > 4) {
     1091                printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
     1092                return 1;
     1093        } else {
     1094                spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
     1095                spec->multiout.num_dacs++;
     1096        }
     1097        return 0;
     1098}
     1099
     1100/* add playback controls for Speaker and HP outputs */
     1101static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
     1102                                        struct auto_pin_cfg *cfg)
     1103{
     1104        struct sigmatel_spec *spec = codec->spec;
    8491105        hda_nid_t nid;
    850         int i, err;
    851         unsigned int wid_caps;
    852 
    853         if (! pin)
    854                 return 0;
    855 
    856         wid_caps = get_wcaps(codec, pin);
    857         if (wid_caps & AC_WCAP_UNSOL_CAP) {
    858                 /* Enable unsolicited responses on the HP widget */
    859                 snd_hda_codec_write(codec, pin, 0,
    860                                 AC_VERB_SET_UNSOLICITED_ENABLE,
    861                                     STAC_UNSOL_ENABLE);
    862                 spec->hp_detect = 1;
    863         }
    864 
    865         nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
    866         for (i = 0; i < cfg->line_outs; i++) {
    867                 if (! spec->multiout.dac_nids[i])
     1106        int i, old_num_dacs, err;
     1107
     1108        old_num_dacs = spec->multiout.num_dacs;
     1109        for (i = 0; i < cfg->hp_outs; i++) {
     1110                unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
     1111                if (wid_caps & AC_WCAP_UNSOL_CAP)
     1112                        spec->hp_detect = 1;
     1113                nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
     1114                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     1115                if (check_in_dac_nids(spec, nid))
     1116                        nid = 0;
     1117                if (! nid)
    8681118                        continue;
    869                 if (spec->multiout.dac_nids[i] == nid)
    870                         return 0;
    871         }
    872 
    873         spec->multiout.hp_nid = nid;
    874 
    875         /* control HP volume/switch on the output mixer amp */
    876         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
    877                                         HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    878                 return err;
    879         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
    880                                         HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    881                 return err;
     1119                add_spec_dacs(spec, nid);
     1120        }
     1121        for (i = 0; i < cfg->speaker_outs; i++) {
     1122                nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0,
     1123                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     1124                if (check_in_dac_nids(spec, nid))
     1125                        nid = 0;
     1126                if (check_in_dac_nids(spec, nid))
     1127                        nid = 0;
     1128                if (! nid)
     1129                        continue;
     1130                add_spec_dacs(spec, nid);
     1131        }
     1132
     1133        for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
     1134                static const char *pfxs[] = {
     1135                        "Speaker", "External Speaker", "Speaker2",
     1136                };
     1137                err = create_controls(spec, pfxs[i - old_num_dacs],
     1138                                      spec->multiout.dac_nids[i], 3);
     1139                if (err < 0)
     1140                        return err;
     1141        }
     1142        if (spec->multiout.hp_nid) {
     1143                const char *pfx;
     1144                if (old_num_dacs == spec->multiout.num_dacs)
     1145                        pfx = "Master";
     1146                else
     1147                        pfx = "Headphone";
     1148                err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
     1149                if (err < 0)
     1150                        return err;
     1151        }
     1152
     1153        return 0;
     1154}
     1155
     1156/* labels for dmic mux inputs */
     1157static const char *stac92xx_dmic_labels[5] = {
     1158        "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
     1159        "Digital Mic 3", "Digital Mic 4"
     1160};
     1161
     1162/* create playback/capture controls for input pins on dmic capable codecs */
     1163static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
     1164                                                const struct auto_pin_cfg *cfg)
     1165{
     1166        struct sigmatel_spec *spec = codec->spec;
     1167        struct hda_input_mux *dimux = &spec->private_dimux;
     1168        hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
     1169        int i, j;
     1170
     1171        dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
     1172        dimux->items[dimux->num_items].index = 0;
     1173        dimux->num_items++;
     1174
     1175        for (i = 0; i < spec->num_dmics; i++) {
     1176                int index;
     1177                int num_cons;
     1178                unsigned int def_conf;
     1179
     1180                def_conf = snd_hda_codec_read(codec,
     1181                                              spec->dmic_nids[i],
     1182                                              0,
     1183                                              AC_VERB_GET_CONFIG_DEFAULT,
     1184                                              0);
     1185                if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
     1186                        continue;
     1187
     1188                num_cons = snd_hda_get_connections(codec,
     1189                                spec->dmux_nid,
     1190                                con_lst,
     1191                                HDA_MAX_NUM_INPUTS);
     1192                for (j = 0; j < num_cons; j++)
     1193                        if (con_lst[j] == spec->dmic_nids[i]) {
     1194                                index = j;
     1195                                goto found;
     1196                        }
     1197                continue;
     1198found:
     1199                dimux->items[dimux->num_items].label =
     1200                        stac92xx_dmic_labels[dimux->num_items];
     1201                dimux->items[dimux->num_items].index = index;
     1202                dimux->num_items++;
     1203        }
    8821204
    8831205        return 0;
     
    8931215
    8941216        for (i = 0; i < AUTO_PIN_LAST; i++) {
    895                 int index = -1;
    896                 if (cfg->input_pins[i]) {
    897                         imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
    898 
    899                         for (j=0; j<spec->num_muxes; j++) {
    900                                 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
    901                                 for (k=0; k<num_cons; k++)
    902                                         if (con_lst[k] == cfg->input_pins[i]) {
    903                                                 index = k;
    904                                                 break;
    905                                         }
    906                                 if (index >= 0)
    907                                         break;
    908                         }
    909                         imux->items[imux->num_items].index = index;
    910                         imux->num_items++;
     1217                int index;
     1218
     1219                if (!cfg->input_pins[i])
     1220                        continue;
     1221                index = -1;
     1222                for (j = 0; j < spec->num_muxes; j++) {
     1223                        int num_cons;
     1224                        num_cons = snd_hda_get_connections(codec,
     1225                                                           spec->mux_nids[j],
     1226                                                           con_lst,
     1227                                                           HDA_MAX_NUM_INPUTS);
     1228                        for (k = 0; k < num_cons; k++)
     1229                                if (con_lst[k] == cfg->input_pins[i]) {
     1230                                        index = k;
     1231                                        goto found;
     1232                                }
    9111233                }
    912         }
    913         if (imux->num_items == 1) {
    914             /*
    915              * Set the current input for the muxes.
    916              * The STAC9221 has two input muxes with identical source
    917              * NID lists.  Hopefully this won't get confused.
    918              */
    919             for (i = 0; i < spec->num_muxes; i++) {
    920                 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
    921                                     AC_VERB_SET_CONNECT_SEL,
    922                                     imux->items[0].index);
    923             }
    924         }
     1234                continue;
     1235        found:
     1236                imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
     1237                imux->items[imux->num_items].index = index;
     1238                imux->num_items++;
     1239        }
     1240
     1241        if (imux->num_items == 1) {
     1242                /*
     1243                 * Set the current input for the muxes.
     1244                 * The STAC9221 has two input muxes with identical source
     1245                 * NID lists.  Hopefully this won't get confused.
     1246                 */
     1247                for (i = 0; i < spec->num_muxes; i++) {
     1248                        snd_hda_codec_write(codec, spec->mux_nids[i], 0,
     1249                                            AC_VERB_SET_CONNECT_SEL,
     1250                                            imux->items[0].index);
     1251                }
     1252        }
    9251253
    9261254        return 0;
     
    9411269{
    9421270        struct sigmatel_spec *spec = codec->spec;
    943         hda_nid_t pin;
    944 
    945         pin = spec->autocfg.hp_pin;
    946         if (pin) /* connect to front */
    947                 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
     1271        int i;
     1272
     1273        for (i = 0; i < spec->autocfg.hp_outs; i++) {
     1274                hda_nid_t pin;
     1275                pin = spec->autocfg.hp_pins[i];
     1276                if (pin) /* connect to front */
     1277                        stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
     1278        }
     1279        for (i = 0; i < spec->autocfg.speaker_outs; i++) {
     1280                hda_nid_t pin;
     1281                pin = spec->autocfg.speaker_pins[i];
     1282                if (pin) /* connect to front */
     1283                        stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
     1284        }
    9481285}
    9491286
     
    9531290        int err;
    9541291
    955         if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
    956             return err;
    957         if (! spec->autocfg.line_outs)
    958             return 0; /* can't find valid pin config */
    959 
    960         if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
    961             return err;
    962 
    963         if (spec->multiout.num_dacs == 0)
    964             if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
    965                 return err;
     1292        if ((err = snd_hda_parse_pin_def_config(codec,
     1293                                                &spec->autocfg,
     1294                                                spec->dmic_nids)) < 0)
     1295                return err;
     1296        if (! spec->autocfg.line_outs)
     1297                return 0; /* can't find valid pin config */
     1298
     1299        if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
     1300                return err;
     1301        if (spec->multiout.num_dacs == 0)
     1302                if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
     1303                        return err;
    9661304
    9671305        if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
     
    9701308                return err;
    9711309
     1310        if (spec->num_dmics > 0)
     1311                if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
     1312                                                &spec->autocfg)) < 0)
     1313                        return err;
     1314
    9721315        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    9731316        if (spec->multiout.max_channels > 2)
    9741317                spec->surr_switch = 1;
    9751318
    976         if (spec->autocfg.dig_out_pin)
    977             spec->multiout.dig_out_nid = dig_out;
    978         if (spec->autocfg.dig_in_pin)
    979             spec->dig_in_nid = dig_in;
     1319        if (spec->autocfg.dig_out_pin)
     1320                spec->multiout.dig_out_nid = dig_out;
     1321        if (spec->autocfg.dig_in_pin)
     1322                spec->dig_in_nid = dig_in;
    9801323
    9811324        if (spec->kctl_alloc)
     
    9831326
    9841327        spec->input_mux = &spec->private_imux;
     1328        spec->dinput_mux = &spec->private_dimux;
    9851329
    9861330        return 1;
     
    9891333/* add playback controls for HP output */
    9901334static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
    991                                         struct auto_pin_cfg *cfg)
    992 {
    993     struct sigmatel_spec *spec = codec->spec;
    994     hda_nid_t pin = cfg->hp_pin;
    995     unsigned int wid_caps;
    996 
    997     if (! pin)
    998         return 0;
    999 
    1000     wid_caps = get_wcaps(codec, pin);
    1001     if (wid_caps & AC_WCAP_UNSOL_CAP) {
    1002         /* Enable unsolicited responses on the HP widget */
    1003         snd_hda_codec_write(codec, pin, 0,
    1004                             AC_VERB_SET_UNSOLICITED_ENABLE,
    1005                             STAC_UNSOL_ENABLE);
    1006         spec->hp_detect = 1;
    1007     }
    1008 
    1009     return 0;
     1335                                        struct auto_pin_cfg *cfg)
     1336{
     1337        struct sigmatel_spec *spec = codec->spec;
     1338        hda_nid_t pin = cfg->hp_pins[0];
     1339        unsigned int wid_caps;
     1340
     1341        if (! pin)
     1342                return 0;
     1343
     1344        wid_caps = get_wcaps(codec, pin);
     1345        if (wid_caps & AC_WCAP_UNSOL_CAP)
     1346                spec->hp_detect = 1;
     1347
     1348        return 0;
     1349}
     1350
     1351/* add playback controls for LFE output */
     1352static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
     1353                                        struct auto_pin_cfg *cfg)
     1354{
     1355        struct sigmatel_spec *spec = codec->spec;
     1356        int err;
     1357        hda_nid_t lfe_pin = 0x0;
     1358        int i;
     1359
     1360        /*
     1361         * search speaker outs and line outs for a mono speaker pin
     1362         * with an amp.  If one is found, add LFE controls
     1363         * for it.
     1364         */
     1365        for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
     1366                hda_nid_t pin = spec->autocfg.speaker_pins[i];
     1367                unsigned long wcaps = get_wcaps(codec, pin);
     1368                wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
     1369                if (wcaps == AC_WCAP_OUT_AMP)
     1370                        /* found a mono speaker with an amp, must be lfe */
     1371                        lfe_pin = pin;
     1372        }
     1373
     1374        /* if speaker_outs is 0, then speakers may be in line_outs */
     1375        if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
     1376                for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
     1377                        hda_nid_t pin = spec->autocfg.line_out_pins[i];
     1378                        unsigned long cfg;
     1379                        cfg = snd_hda_codec_read(codec, pin, 0,
     1380                                                 AC_VERB_GET_CONFIG_DEFAULT,
     1381                                                 0x00);
     1382                        if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
     1383                                unsigned long wcaps = get_wcaps(codec, pin);
     1384                                wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
     1385                                if (wcaps == AC_WCAP_OUT_AMP)
     1386                                        /* found a mono speaker with an amp,
     1387                                           must be lfe */
     1388                                        lfe_pin = pin;
     1389                        }
     1390                }
     1391        }
     1392
     1393        if (lfe_pin) {
     1394                err = create_controls(spec, "LFE", lfe_pin, 1);
     1395                if (err < 0)
     1396                        return err;
     1397        }
     1398
     1399        return 0;
    10101400}
    10111401
     
    10211411                return err;
    10221412
    1023         if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
    1024             return err;
    1025 
    1026         if (spec->autocfg.dig_out_pin)
    1027             spec->multiout.dig_out_nid = 0x05;
    1028         if (spec->autocfg.dig_in_pin)
    1029             spec->dig_in_nid = 0x04;
     1413        if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
     1414                return err;
     1415
     1416        if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
     1417                return err;
     1418
     1419        if (spec->autocfg.dig_out_pin)
     1420                spec->multiout.dig_out_nid = 0x05;
     1421        if (spec->autocfg.dig_in_pin)
     1422                spec->dig_in_nid = 0x04;
    10301423
    10311424        if (spec->kctl_alloc)
     
    10331426
    10341427        spec->input_mux = &spec->private_imux;
    1035 
    1036         return 1;
     1428        spec->dinput_mux = &spec->private_dimux;
     1429
     1430        return 1;
    10371431}
    10381432
     
    10761470}
    10771471
     1472static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
     1473                              unsigned int event)
     1474{
     1475        if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
     1476                snd_hda_codec_write(codec, nid, 0,
     1477                                    AC_VERB_SET_UNSOLICITED_ENABLE,
     1478                                    (AC_USRSP_EN | event));
     1479}
     1480
    10781481static int stac92xx_init(struct hda_codec *codec)
    10791482{
    1080     struct sigmatel_spec *spec = codec->spec;
    1081     struct auto_pin_cfg *cfg = &spec->autocfg;
    1082     int i;
    1083 
    1084     snd_hda_sequence_write(codec, spec->init);
    1085 
    1086     /* set up pins */
    1087     if (spec->hp_detect) {
    1088         /* fake event to set up pins */
    1089         codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
    1090     } else {
    1091         stac92xx_auto_init_multi_out(codec);
    1092         stac92xx_auto_init_hp_out(codec);
    1093     }
    1094     for (i = 0; i < AUTO_PIN_LAST; i++) {
    1095         hda_nid_t nid = cfg->input_pins[i];
    1096         if (nid) {
    1097             unsigned int pinctl = AC_PINCTL_IN_EN;
    1098             if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
    1099                 pinctl |= stac92xx_get_vref(codec, nid);
    1100             stac92xx_auto_set_pinctl(codec, nid, pinctl);
    1101         }
    1102     }
    1103     if (cfg->dig_out_pin)
    1104         stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
    1105                                  AC_PINCTL_OUT_EN);
    1106     if (cfg->dig_in_pin)
    1107         stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
    1108                                  AC_PINCTL_IN_EN);
    1109     if (spec->gpio_mute) {
    1110         stac922x_gpio_mute(codec, 0, 0);
    1111         stac922x_gpio_mute(codec, 1, 0);
    1112     }
    1113 
    1114     return 0;
     1483        struct sigmatel_spec *spec = codec->spec;
     1484        struct auto_pin_cfg *cfg = &spec->autocfg;
     1485        int i;
     1486
     1487        snd_hda_sequence_write(codec, spec->init);
     1488
     1489        /* set up pins */
     1490        if (spec->hp_detect) {
     1491                /* Enable unsolicited responses on the HP widget */
     1492                for (i = 0; i < cfg->hp_outs; i++)
     1493                        enable_pin_detect(codec, cfg->hp_pins[i],
     1494                                          STAC_HP_EVENT);
     1495                stac92xx_auto_init_hp_out(codec);
     1496                /* fake event to set up pins */
     1497                codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
     1498        } else {
     1499                stac92xx_auto_init_multi_out(codec);
     1500                stac92xx_auto_init_hp_out(codec);
     1501        }
     1502        for (i = 0; i < AUTO_PIN_LAST; i++) {
     1503                hda_nid_t nid = cfg->input_pins[i];
     1504                if (nid) {
     1505                        unsigned int pinctl = AC_PINCTL_IN_EN;
     1506                        if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
     1507                                pinctl |= stac92xx_get_vref(codec, nid);
     1508                        stac92xx_auto_set_pinctl(codec, nid, pinctl);
     1509                }
     1510        }
     1511        if (spec->num_dmics > 0)
     1512                for (i = 0; i < spec->num_dmics; i++)
     1513                        stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
     1514                                                 AC_PINCTL_IN_EN);
     1515
     1516        if (cfg->dig_out_pin)
     1517                stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
     1518                                         AC_PINCTL_OUT_EN);
     1519        if (cfg->dig_in_pin)
     1520                stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
     1521                                         AC_PINCTL_IN_EN);
     1522
     1523        if (spec->gpio_mute) {
     1524                stac922x_gpio_mute(codec, 0, 0);
     1525                stac922x_gpio_mute(codec, 1, 0);
     1526        }
     1527
     1528        return 0;
    11151529}
    11161530
     
    11291543        }
    11301544
     1545        if (spec->bios_pin_configs)
     1546                kfree(spec->bios_pin_configs);
     1547
    11311548        kfree(spec);
    11321549}
     
    11371554        unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
    11381555                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
     1556        if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN))
     1557                return;
    11391558        snd_hda_codec_write(codec, nid, 0,
    11401559                        AC_VERB_SET_PIN_WIDGET_CONTROL,
     
    11521571}
    11531572
    1154 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
     1573static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
     1574{
     1575        if (!nid)
     1576                return 0;
     1577        if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
     1578            & (1 << 31))
     1579                return 1;
     1580        return 0;
     1581}
     1582
     1583static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
    11551584{
    11561585        struct sigmatel_spec *spec = codec->spec;
     
    11581587        int i, presence;
    11591588
    1160         if ((res >> 26) != STAC_HP_EVENT)
    1161                 return;
    1162 
    1163         presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
    1164                         AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
     1589        presence = 0;
     1590        for (i = 0; i < cfg->hp_outs; i++) {
     1591                presence = get_pin_presence(codec, cfg->hp_pins[i]);
     1592                if (presence)
     1593                        break;
     1594        }
    11651595
    11661596        if (presence) {
     
    11691599                        stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
    11701600                                                AC_PINCTL_OUT_EN);
    1171                 stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
     1601                for (i = 0; i < cfg->speaker_outs; i++)
     1602                        stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
     1603                                                AC_PINCTL_OUT_EN);
    11721604        } else {
    11731605                /* enable lineouts, disable hp */
     
    11751607                        stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
    11761608                                                AC_PINCTL_OUT_EN);
    1177                 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
     1609                for (i = 0; i < cfg->speaker_outs; i++)
     1610                        stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
     1611                                                AC_PINCTL_OUT_EN);
     1612        }
     1613}
     1614
     1615static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
     1616{
     1617        switch (res >> 26) {
     1618        case STAC_HP_EVENT:
     1619                stac92xx_hp_detect(codec, res);
     1620                break;
    11781621        }
    11791622}
     
    11861629
    11871630        stac92xx_init(codec);
     1631        stac92xx_set_config_regs(codec);
    11881632        for (i = 0; i < spec->num_mixers; i++)
    11891633                snd_hda_resume_ctls(codec, spec->mixers[i]);
     
    12181662
    12191663        codec->spec = spec;
    1220         spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
    1221         if (spec->board_config < 0)
    1222                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
    1223         else {
    1224                 spec->num_pins = 8;
    1225                 spec->pin_nids = stac9200_pin_nids;
     1664        spec->num_pins = 8;
     1665        spec->pin_nids = stac9200_pin_nids;
     1666        spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
     1667                                                        stac9200_models,
     1668                                                        stac9200_cfg_tbl);
     1669        if (spec->board_config < 0) {
     1670                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
     1671                err = stac92xx_save_bios_config_regs(codec);
     1672                if (err < 0) {
     1673                        stac92xx_free(codec);
     1674                        return err;
     1675                }
     1676                spec->pin_configs = spec->bios_pin_configs;
     1677        } else {
    12261678                spec->pin_configs = stac9200_brd_tbl[spec->board_config];
    12271679                stac92xx_set_config_regs(codec);
     
    12341686        spec->mux_nids = stac9200_mux_nids;
    12351687        spec->num_muxes = 1;
     1688        spec->num_dmics = 0;
    12361689
    12371690        spec->init = stac9200_core_init;
     
    12591712
    12601713        codec->spec = spec;
    1261         spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
    1262         if (spec->board_config < 0)
    1263             snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n");
    1264         else if (stac922x_brd_tbl[spec->board_config] != NULL) {
    1265                 spec->num_pins = 10;
    1266                 spec->pin_nids = stac922x_pin_nids;
     1714        spec->num_pins = 10;
     1715        spec->pin_nids = stac922x_pin_nids;
     1716        spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
     1717                                                        stac922x_models,
     1718                                                        stac922x_cfg_tbl);
     1719        if (spec->board_config < 0) {
     1720                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
     1721                        "using BIOS defaults\n");
     1722                err = stac92xx_save_bios_config_regs(codec);
     1723                if (err < 0) {
     1724                        stac92xx_free(codec);
     1725                        return err;
     1726                }
     1727                spec->pin_configs = spec->bios_pin_configs;
     1728        } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
    12671729                spec->pin_configs = stac922x_brd_tbl[spec->board_config];
    12681730                stac92xx_set_config_regs(codec);
     
    12721734        spec->mux_nids = stac922x_mux_nids;
    12731735        spec->num_muxes = 2;
     1736        spec->num_dmics = 0;
    12741737
    12751738        spec->init = stac922x_core_init;
     
    12771740
    12781741        spec->multiout.dac_nids = spec->dac_nids;
    1279 
    1280         switch (spec->board_config) {
    1281         case STAC_D965_2112:
    1282                 spec->adc_nids = stac9227_adc_nids;
    1283                 spec->mux_nids = stac9227_mux_nids;
    1284 #if 0
    1285                 spec->multiout.dac_nids = d965_2112_dac_nids;
    1286                 spec->multiout.num_dacs = ARRAY_SIZE(d965_2112_dac_nids);
    1287 #endif
    1288                 spec->init = d965_2112_core_init;
     1742       
     1743        err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
     1744        if (err < 0) {
     1745                stac92xx_free(codec);
     1746                return err;
     1747        }
     1748
     1749        if (spec->board_config == STAC_MACMINI)
     1750                spec->gpio_mute = 1;
     1751
     1752        codec->patch_ops = stac92xx_patch_ops;
     1753
     1754        return 0;
     1755}
     1756
     1757static int patch_stac927x(struct hda_codec *codec)
     1758{
     1759        struct sigmatel_spec *spec;
     1760        int err;
     1761
     1762        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     1763        if (spec == NULL)
     1764                return -ENOMEM;
     1765
     1766        codec->spec = spec;
     1767        spec->num_pins = 14;
     1768        spec->pin_nids = stac927x_pin_nids;
     1769        spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
     1770                                                        stac927x_models,
     1771                                                        stac927x_cfg_tbl);
     1772        if (spec->board_config < 0) {
     1773                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
     1774                err = stac92xx_save_bios_config_regs(codec);
     1775                if (err < 0) {
     1776                        stac92xx_free(codec);
     1777                        return err;
     1778                }
     1779                spec->pin_configs = spec->bios_pin_configs;
     1780        } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
     1781                spec->pin_configs = stac927x_brd_tbl[spec->board_config];
     1782                stac92xx_set_config_regs(codec);
     1783        }
     1784
     1785        switch (spec->board_config) {
     1786        case STAC_D965_3ST:
     1787                spec->adc_nids = stac927x_adc_nids;
     1788                spec->mux_nids = stac927x_mux_nids;
     1789                spec->num_muxes = 3;
     1790                spec->num_dmics = 0;
     1791                spec->init = d965_core_init;
    12891792                spec->mixer = stac9227_mixer;
    12901793                break;
    1291         case STAC_D965_284B:
    1292                 spec->adc_nids = stac9227_adc_nids;
    1293                 spec->mux_nids = stac9227_mux_nids;
    1294                 spec->init = stac9227_core_init;
     1794        case STAC_D965_5ST:
     1795                spec->adc_nids = stac927x_adc_nids;
     1796                spec->mux_nids = stac927x_mux_nids;
     1797                spec->num_muxes = 3;
     1798                spec->num_dmics = 0;
     1799                spec->init = d965_core_init;
    12951800                spec->mixer = stac9227_mixer;
    12961801                break;
    1297         }
    1298         err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
    1299         if (err < 0) {
    1300             stac92xx_free(codec);
    1301             return err;
    1302         }
    1303 
    1304         if (spec->board_config == STAC_MACMINI)
    1305                 spec->gpio_mute = 1;
    1306         codec->patch_ops = stac92xx_patch_ops;
    1307 
    1308         return 0;
    1309 }
    1310 
    1311 static int patch_stac927x(struct hda_codec *codec)
    1312 {
    1313     struct sigmatel_spec *spec;
    1314     int err;
    1315 
    1316     spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
    1317     if (spec == NULL)
    1318         return -ENOMEM;
    1319 
    1320     codec->spec = spec;
    1321     spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
    1322     if (spec->board_config < 0)
    1323         snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
    1324     else {
    1325         spec->num_pins = 14;
    1326         spec->pin_nids = stac927x_pin_nids;
    1327         spec->pin_configs = stac927x_brd_tbl[spec->board_config];
    1328         stac92xx_set_config_regs(codec);
    1329     }
    1330 
    1331     spec->adc_nids = stac927x_adc_nids;
    1332     spec->mux_nids = stac927x_mux_nids;
    1333     spec->num_muxes = 3;
    1334 
    1335     spec->init = stac927x_core_init;
    1336     spec->mixer = stac927x_mixer;
    1337 
    1338     spec->multiout.dac_nids = spec->dac_nids;
    1339 
    1340                  err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
    1341         if (err < 0) {
     1802        default:
     1803                spec->adc_nids = stac927x_adc_nids;
     1804                spec->mux_nids = stac927x_mux_nids;
     1805                spec->num_muxes = 3;
     1806                spec->num_dmics = 0;
     1807                spec->init = stac927x_core_init;
     1808                spec->mixer = stac927x_mixer;
     1809        }
     1810
     1811        spec->multiout.dac_nids = spec->dac_nids;
     1812
     1813        err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
     1814        if (err < 0) {
    13421815                stac92xx_free(codec);
    13431816                return err;
     
    13491822}
    13501823
     1824static int patch_stac9205(struct hda_codec *codec)
     1825{
     1826        struct sigmatel_spec *spec;
     1827        int err;
     1828
     1829        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     1830        if (spec == NULL)
     1831                return -ENOMEM;
     1832
     1833        codec->spec = spec;
     1834        spec->num_pins = 14;
     1835        spec->pin_nids = stac9205_pin_nids;
     1836        spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
     1837                                                        stac9205_models,
     1838                                                        stac9205_cfg_tbl);
     1839        if (spec->board_config < 0) {
     1840                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
     1841                err = stac92xx_save_bios_config_regs(codec);
     1842                if (err < 0) {
     1843                        stac92xx_free(codec);
     1844                        return err;
     1845                }
     1846                spec->pin_configs = spec->bios_pin_configs;
     1847        } else {
     1848                spec->pin_configs = stac9205_brd_tbl[spec->board_config];
     1849                stac92xx_set_config_regs(codec);
     1850        }
     1851
     1852        spec->adc_nids = stac9205_adc_nids;
     1853        spec->mux_nids = stac9205_mux_nids;
     1854        spec->num_muxes = 2;
     1855        spec->dmic_nids = stac9205_dmic_nids;
     1856        spec->num_dmics = 2;
     1857        spec->dmux_nid = 0x1d;
     1858
     1859        spec->init = stac9205_core_init;
     1860        spec->mixer = stac9205_mixer;
     1861
     1862        spec->multiout.dac_nids = spec->dac_nids;
     1863
     1864        err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
     1865        if (err < 0) {
     1866                stac92xx_free(codec);
     1867                return err;
     1868        }
     1869
     1870        codec->patch_ops = stac92xx_patch_ops;
     1871
     1872        return 0;
     1873}
     1874
    13511875/*
    1352  * STAC 7661(?) hack
     1876 * STAC9872 hack
    13531877 */
    13541878
    1355 /* static config for Sony VAIO FE550G */
     1879/* static config for Sony VAIO FE550G and Sony VAIO AR */
    13561880static hda_nid_t vaio_dacs[] = { 0x2 };
    1357 #define VAIO_HP_DAC     0x5
     1881#define VAIO_HP_DAC     0x5
    13581882static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
    13591883static hda_nid_t vaio_mux_nids[] = { 0x15 };
    13601884
    13611885static struct hda_input_mux vaio_mux = {
    1362     .num_items = 2,
    1363     .items = {
    1364         /* { "HP", 0x0 }, */
    1365         { "Line", 0x1 },
    1366         { "Mic", 0x2 },
    1367         { "PCM", 0x3 },
    1368     }
     1886        .num_items = 2,
     1887        .items = {
     1888                /* { "HP", 0x0 }, */
     1889                { "Line", 0x1 },
     1890                { "Mic", 0x2 },
     1891                { "PCM", 0x3 },
     1892        }
    13691893};
    13701894
    13711895static struct hda_verb vaio_init[] = {
    1372     {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
    1373     {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
    1374     {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
    1375     {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
    1376     {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
    1377     {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
    1378     {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
    1379     {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
    1380     {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
    1381     {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
    1382     {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
    1383     {0}
     1896        {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
     1897        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
     1898        {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
     1899        {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
     1900        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
     1901        {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
     1902        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
     1903        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
     1904        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
     1905        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
     1906        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
     1907        {0}
     1908};
     1909
     1910static struct hda_verb vaio_ar_init[] = {
     1911        {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
     1912        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
     1913        {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
     1914        {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
     1915/*      {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
     1916        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
     1917        {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
     1918        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
     1919        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
     1920/*      {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
     1921        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
     1922        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
     1923        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
     1924        {0}
    13841925};
    13851926
    13861927/* bind volumes of both NID 0x02 and 0x05 */
    13871928static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
    1388                                struct snd_ctl_elem_value *ucontrol)
    1389 {
    1390     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1391     long *valp = ucontrol->value.integer.value;
    1392     int change;
    1393 
    1394     change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
    1395                                       0x7f, valp[0] & 0x7f);
    1396     change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
    1397                                        0x7f, valp[1] & 0x7f);
    1398     snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
    1399                             0x7f, valp[0] & 0x7f);
    1400     snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
    1401                             0x7f, valp[1] & 0x7f);
    1402     return change;
     1929                               struct snd_ctl_elem_value *ucontrol)
     1930{
     1931        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     1932        long *valp = ucontrol->value.integer.value;
     1933        int change;
     1934
     1935        change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
     1936                                          0x7f, valp[0] & 0x7f);
     1937        change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
     1938                                           0x7f, valp[1] & 0x7f);
     1939        snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
     1940                                0x7f, valp[0] & 0x7f);
     1941        snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
     1942                                0x7f, valp[1] & 0x7f);
     1943        return change;
    14031944}
    14041945
    14051946/* bind volumes of both NID 0x02 and 0x05 */
    14061947static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
    1407                               struct snd_ctl_elem_value *ucontrol)
    1408 {
    1409     struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1410     long *valp = ucontrol->value.integer.value;
    1411     int change;
    1412 
    1413     change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
    1414                                       0x80, (valp[0] ? 0 : 0x80));
    1415     change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
    1416                                        0x80, (valp[1] ? 0 : 0x80));
    1417     snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
    1418                             0x80, (valp[0] ? 0 : 0x80));
    1419     snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
    1420                             0x80, (valp[1] ? 0 : 0x80));
    1421     return change;
     1948                              struct snd_ctl_elem_value *ucontrol)
     1949{
     1950        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     1951        long *valp = ucontrol->value.integer.value;
     1952        int change;
     1953
     1954        change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
     1955                                          0x80, (valp[0] ? 0 : 0x80));
     1956        change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
     1957                                           0x80, (valp[1] ? 0 : 0x80));
     1958        snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
     1959                                0x80, (valp[0] ? 0 : 0x80));
     1960        snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
     1961                                0x80, (valp[1] ? 0 : 0x80));
     1962        return change;
    14221963}
    14231964
    14241965static struct snd_kcontrol_new vaio_mixer[] = {
    1425     {
    1426         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1427         .name = "Master Playback Volume",
    1428         .info = snd_hda_mixer_amp_volume_info,
    1429         .get = snd_hda_mixer_amp_volume_get,
    1430         .put = vaio_master_vol_put,
    1431         .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
    1432     },
    1433     {
    1434         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1435         .name = "Master Playback Switch",
    1436         .info = snd_hda_mixer_amp_switch_info,
    1437         .get = snd_hda_mixer_amp_switch_get,
    1438         .put = vaio_master_sw_put,
    1439         .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
    1440     },
    1441     /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
    1442     HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
    1443     HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
    1444     {
    1445         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1446         .name = "Capture Source",
    1447         .count = 1,
    1448         .info = stac92xx_mux_enum_info,
    1449         .get = stac92xx_mux_enum_get,
    1450         .put = stac92xx_mux_enum_put,
    1451     },
    1452     {0}
    1453 };
    1454 
    1455 static struct hda_codec_ops stac7661_patch_ops = {
    1456     .build_controls = stac92xx_build_controls,
    1457     .build_pcms = stac92xx_build_pcms,
    1458     .init = stac92xx_init,
    1459     .free = stac92xx_free,
     1966        {
     1967                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1968                .name = "Master Playback Volume",
     1969                .info = snd_hda_mixer_amp_volume_info,
     1970                .get = snd_hda_mixer_amp_volume_get,
     1971                .put = vaio_master_vol_put,
     1972                .tlv = { .c = snd_hda_mixer_amp_tlv },
     1973                .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
     1974        },
     1975        {
     1976                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1977                .name = "Master Playback Switch",
     1978                .info = snd_hda_mixer_amp_switch_info,
     1979                .get = snd_hda_mixer_amp_switch_get,
     1980                .put = vaio_master_sw_put,
     1981                .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
     1982        },
     1983        /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
     1984        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
     1985        HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
     1986        {
     1987                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1988                .name = "Capture Source",
     1989                .count = 1,
     1990                .info = stac92xx_mux_enum_info,
     1991                .get = stac92xx_mux_enum_get,
     1992                .put = stac92xx_mux_enum_put,
     1993        },
     1994        {0}
     1995};
     1996
     1997static struct snd_kcontrol_new vaio_ar_mixer[] = {
     1998        {
     1999                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2000                .name = "Master Playback Volume",
     2001                .info = snd_hda_mixer_amp_volume_info,
     2002                .get = snd_hda_mixer_amp_volume_get,
     2003                .put = vaio_master_vol_put,
     2004                .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
     2005        },
     2006        {
     2007                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2008                .name = "Master Playback Switch",
     2009                .info = snd_hda_mixer_amp_switch_info,
     2010                .get = snd_hda_mixer_amp_switch_get,
     2011                .put = vaio_master_sw_put,
     2012                .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
     2013        },
     2014        /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
     2015        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
     2016        HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
     2017        /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
     2018        HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
     2019        {
     2020                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2021                .name = "Capture Source",
     2022                .count = 1,
     2023                .info = stac92xx_mux_enum_info,
     2024                .get = stac92xx_mux_enum_get,
     2025                .put = stac92xx_mux_enum_put,
     2026        },
     2027        {0}
     2028};
     2029
     2030static struct hda_codec_ops stac9872_patch_ops = {
     2031        .build_controls = stac92xx_build_controls,
     2032        .build_pcms = stac92xx_build_pcms,
     2033        .init = stac92xx_init,
     2034        .free = stac92xx_free,
    14602035#ifdef CONFIG_PM
    1461     .resume = stac92xx_resume,
     2036        .resume = stac92xx_resume,
    14622037#endif
    14632038};
    14642039
    1465 enum { STAC7661_VAIO };
    1466 
    1467 static struct hda_board_config stac7661_cfg_tbl[] = {
    1468     { .modelname = "vaio", .config = STAC7661_VAIO },
    1469     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
    1470     .config = STAC7661_VAIO },
    1471     { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
    1472     .config = STAC7661_VAIO },
    1473     {0}
    1474 };
    1475 
    1476 static int patch_stac7661(struct hda_codec *codec)
    1477 {
    1478     struct sigmatel_spec *spec;
    1479     int board_config;
    1480 
    1481     board_config = snd_hda_check_board_config(codec, stac7661_cfg_tbl);
    1482     if (board_config < 0)
    1483         /* unknown config, let generic-parser do its job... */
    1484         return snd_hda_parse_generic_codec(codec);
    1485 
    1486     spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
    1487     if (spec == NULL)
    1488         return -ENOMEM;
    1489 
    1490     codec->spec = spec;
    1491     switch (board_config) {
    1492     case STAC7661_VAIO:
    1493         spec->mixer = vaio_mixer;
    1494         spec->init = vaio_init;
    1495         spec->multiout.max_channels = 2;
    1496         spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
    1497         spec->multiout.dac_nids = vaio_dacs;
    1498         spec->multiout.hp_nid = VAIO_HP_DAC;
    1499         spec->num_adcs = ARRAY_SIZE(vaio_adcs);
    1500         spec->adc_nids = vaio_adcs;
    1501         spec->input_mux = &vaio_mux;
    1502         spec->mux_nids = vaio_mux_nids;
    1503         break;
    1504     }
    1505 
    1506     codec->patch_ops = stac7661_patch_ops;
    1507     return 0;
    1508 }
    1509 
    1510 
    1511          /*
     2040enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
     2041       CXD9872RD_VAIO,
     2042       /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
     2043       STAC9872AK_VAIO,
     2044       /* Unknown. id=0x83847661 and subsys=0x104D1200. */
     2045       STAC9872K_VAIO,
     2046       /* AR Series. id=0x83847664 and subsys=104D1300 */
     2047       CXD9872AKD_VAIO,
     2048       STAC_9872_MODELS,
     2049};
     2050
     2051static const char *stac9872_models[STAC_9872_MODELS] = {
     2052        [CXD9872RD_VAIO]        = "vaio",
     2053        [CXD9872AKD_VAIO]       = "vaio-ar",
     2054};
     2055
     2056static struct snd_pci_quirk stac9872_cfg_tbl[] = {
     2057        SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
     2058        SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
     2059        SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
     2060        {0}
     2061};
     2062
     2063static int patch_stac9872(struct hda_codec *codec)
     2064{
     2065        struct sigmatel_spec *spec;
     2066        int board_config;
     2067
     2068        board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
     2069                                                  stac9872_models,
     2070                                                  stac9872_cfg_tbl);
     2071        if (board_config < 0)
     2072                /* unknown config, let generic-parser do its job... */
     2073                return snd_hda_parse_generic_codec(codec);
     2074       
     2075        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     2076        if (spec == NULL)
     2077                return -ENOMEM;
     2078
     2079        codec->spec = spec;
     2080        switch (board_config) {
     2081        case CXD9872RD_VAIO:
     2082        case STAC9872AK_VAIO:
     2083        case STAC9872K_VAIO:
     2084                spec->mixer = vaio_mixer;
     2085                spec->init = vaio_init;
     2086                spec->multiout.max_channels = 2;
     2087                spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
     2088                spec->multiout.dac_nids = vaio_dacs;
     2089                spec->multiout.hp_nid = VAIO_HP_DAC;
     2090                spec->num_adcs = ARRAY_SIZE(vaio_adcs);
     2091                spec->adc_nids = vaio_adcs;
     2092                spec->input_mux = &vaio_mux;
     2093                spec->mux_nids = vaio_mux_nids;
     2094                break;
     2095       
     2096        case CXD9872AKD_VAIO:
     2097                spec->mixer = vaio_ar_mixer;
     2098                spec->init = vaio_ar_init;
     2099                spec->multiout.max_channels = 2;
     2100                spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
     2101                spec->multiout.dac_nids = vaio_dacs;
     2102                spec->multiout.hp_nid = VAIO_HP_DAC;
     2103                spec->num_adcs = ARRAY_SIZE(vaio_adcs);
     2104                spec->adc_nids = vaio_adcs;
     2105                spec->input_mux = &vaio_mux;
     2106                spec->mux_nids = vaio_mux_nids;
     2107                break;
     2108        }
     2109
     2110        codec->patch_ops = stac9872_patch_ops;
     2111        return 0;
     2112}
     2113
     2114
     2115/*
    15122116 * patch entries
    15132117 */
     
    15152119        { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
    15162120        { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
    1517         { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
    1518         { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac922x },
    1519         { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac922x },
    1520         { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac922x },
    1521         { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac922x },
    1522         { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac922x },
    1523         { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac922x },
     2121        { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
    15242122        { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
    15252123        { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
    15262124        { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
    1527         { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
    1528         { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
    1529         { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
    1530         { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
    1531         { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
    1532         { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
    1533         { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
    1534         { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
    1535         { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
    1536         { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
    1537         { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
    1538         { .id = 0x83847661, .name = "STAC7661", .patch = patch_stac7661 },
     2125        { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
     2126        { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
     2127        { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
     2128        { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
     2129        { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
     2130        { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
     2131        { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
     2132        { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
     2133        { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
     2134        { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
     2135        { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
     2136        { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
     2137        { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
     2138        { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
     2139        { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
     2140        { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
     2141        { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
     2142        /* The following does not take into account .id=0x83847661 when subsys =
     2143         * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
     2144         * currently not fully supported.
     2145         */
     2146        { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
     2147        { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
     2148        { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
     2149        { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
     2150        { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
     2151        { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
     2152        { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
     2153        { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
     2154        { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
     2155        { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
     2156        { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
    15392157        {0} /* terminator */
    15402158};
  • GPL/trunk/alsa-kernel/pci/intel8x0.c

    r77 r86  
    22942294    /* put logic to right state */
    22952295    /* first clear status bits */
    2296 #if 1 // noone do it. wtf? //vladest 06.10.2003 13:51
    22972296    status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
    22982297    if (chip->device_type == DEVICE_NFORCE)
     
    23002299    cnt = igetdword(chip, ICHREG(GLOB_STA));
    23012300    iputdword(chip, ICHREG(GLOB_STA), cnt & status);
    2302 #endif
    2303     // hmm. at least we should try
    2304     //iputdword(chip, ICHREG(GLOB_CNT), igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD);
    23052301    /* ACLink on, 2 channels */
    23062302    cnt = igetdword(chip, ICHREG(GLOB_CNT));
    2307     // added by vladest
    23082303    //    cnt &= ~ICH_ACLINK;
    23092304    cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
    2310 #ifdef CONFIG_SND_AC97_POWER_SAVE
     2305#if 0
     2306    //def CONFIG_SND_AC97_POWER_SAVE
    23112307    /* do cold reset - the full ac97 powerdown may leave the controller
    23122308     * in a warm state but actually it cannot communicate with the codec.
     
    23192315#else
    23202316    cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM;
    2321 
    2322     //  ??? 25.03.2004 by vladest  cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
    2323     // FIXME!!! cmi drivers didnt uses ICH_PCM_246_MASK
    23242317    /* finish cold or do warm reset */
    23252318#ifdef DEBUG
     
    23272320#endif
    23282321    iputdword(chip, ICHREG(GLOB_CNT), cnt);
    2329 //    mdelay(500); //vladest 06.10.2003 15:08
     2322    mdelay(500); //vladest 06.10.2003 15:08
    23302323    end_time = (jiffies + (HZ / 4)) + 1;
    23312324    i = 0;
Note: See TracChangeset for help on using the changeset viewer.