Changeset 417


Ignore:
Timestamp:
Mar 23, 2009, 12:06:21 AM (16 years ago)
Author:
Paul Smedley
Message:

Revert alsa-kernel/hda/* to 1.0.18a level to fix traps

Location:
GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_beep.h

    r410 r417  
    3232        int tone;
    3333        int nid;
    34         int enabled;
    3534        struct work_struct beep_work; /* scheduled task for beep event */
    3635};
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_codec.c

    r410 r417  
    3232#include "hda_local.h"
    3333#include <sound/hda_hwdep.h>
     34#include "hda_patch.h"  /* codec presets */
     35
     36#ifdef CONFIG_SND_HDA_POWER_SAVE
     37/* define this option here to hide as static */
     38static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
     39module_param(power_save, int, 0644);
     40MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
     41                 "(in second, 0 = disable).");
     42#endif
    3443
    3544/*
     
    4756        { 0x1057, "Motorola" },
    4857        { 0x1095, "Silicon Image" },
    49         { 0x10de, "Nvidia" },
    5058        { 0x10ec, "Realtek" },
    5159        { 0x1106, "VIA" },
     
    5967        { 0x1aec, "Wolfson Microelectronics" },
    6068        { 0x434d, "C-Media" },
    61         { 0x8086, "Intel" },
    6269        { 0x8384, "SigmaTel" },
    6370        {0} /* terminator */
    6471};
    6572
    66 static DEFINE_MUTEX(preset_mutex);
    67 static LIST_HEAD(hda_preset_tables);
    68 
    69 int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset)
    70 {
    71         mutex_lock(&preset_mutex);
    72         list_add_tail(&preset->list, &hda_preset_tables);
    73         mutex_unlock(&preset_mutex);
    74         return 0;
    75 }
    76 EXPORT_SYMBOL_HDA(snd_hda_add_codec_preset);
    77 
    78 int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset)
    79 {
    80         mutex_lock(&preset_mutex);
    81         list_del(&preset->list);
    82         mutex_unlock(&preset_mutex);
    83         return 0;
    84 }
    85 EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset);
     73static const struct hda_codec_preset *hda_preset_tables[] = {
     74#ifdef CONFIG_SND_HDA_CODEC_REALTEK
     75        snd_hda_preset_realtek,
     76#endif
     77#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
     78        snd_hda_preset_cmedia,
     79#endif
     80#ifdef CONFIG_SND_HDA_CODEC_ANALOG
     81        snd_hda_preset_analog,
     82#endif
     83#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
     84        snd_hda_preset_sigmatel,
     85#endif
     86#ifdef CONFIG_SND_HDA_CODEC_SI3054
     87        snd_hda_preset_si3054,
     88#endif
     89#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
     90        snd_hda_preset_atihdmi,
     91#endif
     92#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
     93        snd_hda_preset_conexant,
     94#endif
     95#ifdef CONFIG_SND_HDA_CODEC_VIA
     96        snd_hda_preset_via,
     97#endif
     98#ifdef CONFIG_SND_HDA_CODEC_NVHDMI
     99        snd_hda_preset_nvhdmi,
     100#endif
     101#ifdef CONFIG_SND_HDA_CODEC_INTELHDMI
     102        snd_hda_preset_intelhdmi,
     103#endif
     104        NULL
     105};
    86106
    87107#ifdef CONFIG_SND_HDA_POWER_SAVE
     
    117137        return "UNKNOWN";
    118138}
    119 EXPORT_SYMBOL_HDA(snd_hda_get_jack_location);
    120139
    121140const char *snd_hda_get_jack_connectivity(u32 cfg)
     
    125144        return jack_locations[(cfg >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3];
    126145}
    127 EXPORT_SYMBOL_HDA(snd_hda_get_jack_connectivity);
    128146
    129147const char *snd_hda_get_jack_type(u32 cfg)
     
    139157                                >> AC_DEFCFG_DEVICE_SHIFT];
    140158}
    141 EXPORT_SYMBOL_HDA(snd_hda_get_jack_type);
    142159
    143160/*
     
    188205        return res;
    189206}
    190 EXPORT_SYMBOL_HDA(snd_hda_codec_read);
    191207
    192208/**
     
    217233        return err;
    218234}
    219 EXPORT_SYMBOL_HDA(snd_hda_codec_write);
    220235
    221236/**
     
    232247                snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
    233248}
    234 EXPORT_SYMBOL_HDA(snd_hda_sequence_write);
    235249
    236250/**
     
    254268        return (int)(parm & 0x7fff);
    255269}
    256 EXPORT_SYMBOL_HDA(snd_hda_get_sub_nodes);
    257270
    258271/**
     
    343356        return conns;
    344357}
    345 EXPORT_SYMBOL_HDA(snd_hda_get_connections);
    346358
    347359
     
    374386        unsol->queue[wp + 1] = res_ex;
    375387
    376         queue_work(bus->workq, &unsol->work);
    377 
    378         return 0;
    379 }
    380 EXPORT_SYMBOL_HDA(snd_hda_queue_unsol_event);
     388/* 2.4 kernels seem to have a problem with workq wrapper... */
     389#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     390        schedule_work(&unsol->work);
     391#endif
     392        return 0;
     393}
    381394
    382395/*
     
    440453        if (!bus)
    441454                return 0;
    442         if (bus->workq)
    443                 flush_workqueue(bus->workq);
    444         if (bus->unsol)
     455        if (bus->unsol) {
     456#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     457                flush_scheduled_work();
     458#endif
    445459                kfree(bus->unsol);
     460        }
    446461        list_for_each_entry_safe(codec, n, &bus->codec_list, list, struct hda_codec) {
    447462                snd_hda_codec_free(codec);
     
    449464        if (bus->ops.private_free)
    450465                bus->ops.private_free(bus);
    451         if (bus->workq)
    452                 destroy_workqueue(bus->workq);
    453466        kfree(bus);
    454467        return 0;
     
    458471{
    459472        struct hda_bus *bus = device->device_data;
    460         bus->shutdown = 1;
    461473        return snd_hda_bus_free(bus);
    462474}
     
    484496 * Returns 0 if successful, or a negative error code.
    485497 */
    486 int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
     498int __devinit snd_hda_bus_new(struct snd_card *card,
    487499                              const struct hda_bus_template *temp,
    488500                              struct hda_bus **busp)
     
    490502        struct hda_bus *bus;
    491503        int err;
    492         char qname[8];
    493504        static struct snd_device_ops dev_ops = {
    494505                .dev_register = snd_hda_bus_dev_register,
     
    514525        bus->pci = temp->pci;
    515526        bus->modelname = temp->modelname;
    516         bus->power_save = temp->power_save;
    517527        bus->ops = temp->ops;
    518528
    519529        mutex_init(&bus->cmd_mutex);
    520530        INIT_LIST_HEAD(&bus->codec_list);
    521 
    522         snprintf(qname, sizeof(qname), "hda%d", card->number);
    523         bus->workq = create_workqueue(qname);
    524         if (!bus->workq) {
    525                 snd_printk(KERN_ERR "cannot create workqueue %s\n", qname);
    526                 kfree(bus);
    527                 return -ENOMEM;
    528         }
    529531
    530532        err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
     
    537539        return 0;
    538540}
    539 EXPORT_SYMBOL_HDA(snd_hda_bus_new);
    540541
    541542#ifdef CONFIG_SND_HDA_GENERIC
     
    546547#endif
    547548
    548 #ifdef MODULE
    549 #define HDA_MODREQ_MAX_COUNT    2       /* two request_modules()'s */
    550 #else
    551 #define HDA_MODREQ_MAX_COUNT    0       /* all presets are statically linked */
    552 #endif
    553 
    554549/*
    555550 * find a matching codec preset
     
    558553find_codec_preset(struct hda_codec *codec)
    559554{
    560         struct hda_codec_preset_list *tbl;
    561         const struct hda_codec_preset *preset;
    562         int mod_requested = 0;
     555        const struct hda_codec_preset **tbl, *preset;
    563556
    564557        if (is_generic_config(codec))
    565558                return NULL; /* use the generic parser */
    566559
    567  again:
    568         mutex_lock(&preset_mutex);
    569         list_for_each_entry(tbl, &hda_preset_tables, list, struct hda_codec_preset_list) {
    570                 if (!try_module_get(tbl->owner)) {
    571                         snd_printk(KERN_ERR "hda_codec: cannot module_get\n");
    572                         continue;
    573                 }
    574                 for (preset = tbl->preset; preset->id; preset++) {
     560        for (tbl = hda_preset_tables; *tbl; tbl++) {
     561                for (preset = *tbl; preset->id; preset++) {
    575562                        u32 mask = preset->mask;
    576563                        if (preset->afg && preset->afg != codec->afg)
     
    582569                        if (preset->id == (codec->vendor_id & mask) &&
    583570                            (!preset->rev ||
    584                              preset->rev == codec->revision_id)) {
    585                                 mutex_unlock(&preset_mutex);
    586                                 codec->owner = tbl->owner;
     571                             preset->rev == codec->revision_id))
    587572                                return preset;
    588                         }
    589573                }
    590                 module_put(tbl->owner);
    591         }
    592         mutex_unlock(&preset_mutex);
    593 
    594 #ifndef TARGET_OS2
    595         if (mod_requested < HDA_MODREQ_MAX_COUNT) {
    596                 char name[32];
    597                 if (!mod_requested)
    598                         snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
    599                                  codec->vendor_id);
    600                 else
    601                         snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
    602                                  (codec->vendor_id >> 16) & 0xffff);
    603                 request_module(name);
    604                 mod_requested++;
    605                 goto again;
    606         }
    607 #endif
     574        }
    608575        return NULL;
    609576}
     
    644611 * look for an AFG and MFG nodes
    645612 */
    646 static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec)
     613static void __devinit setup_fg_nodes(struct hda_codec *codec)
    647614{
    648615        int i, total_nodes;
     
    700667#ifdef CONFIG_SND_HDA_POWER_SAVE
    701668        cancel_delayed_work(&codec->power_work);
    702         flush_workqueue(codec->bus->workq);
     669        flush_scheduled_work();
    703670#endif
    704671        list_del(&codec->list);
     
    707674        if (codec->patch_ops.free)
    708675                codec->patch_ops.free(codec);
    709         module_put(codec->owner);
    710676        free_hda_cache(&codec->amp_cache);
    711677        free_hda_cache(&codec->cmd_cache);
     
    724690 * Returns 0 if successful, or a negative error code.
    725691 */
    726 int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
    727                                     int do_init, struct hda_codec **codecp)
     692int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
     693                                struct hda_codec **codecp)
    728694{
    729695        struct hda_codec *codec;
     
    751717        codec->addr = codec_addr;
    752718        mutex_init(&codec->spdif_mutex);
    753         mutex_init(&codec->control_mutex);
    754719        init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
    755720        init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
     
    810775                codec->modelname = kstrdup(bus->modelname, GFP_KERNEL);
    811776
    812         if (do_init) {
    813                 err = snd_hda_codec_configure(codec);
    814                 if (err < 0) {
    815                         snd_hda_codec_free(codec);
    816                         return err;
    817                 }
     777        err = snd_hda_codec_configure(codec);
     778        if (err < 0) {
     779                snd_hda_codec_free(codec);
     780                return err;
    818781        }
    819782        snd_hda_codec_proc_new(codec);
     
    829792        return 0;
    830793}
    831 EXPORT_SYMBOL_HDA(snd_hda_codec_new);
    832794
    833795int snd_hda_codec_configure(struct hda_codec *codec)
     
    889851        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
    890852}
    891 EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream);
    892853
    893854void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
     
    903864#endif
    904865}
    905 EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream);
    906866
    907867/*
     
    915875
    916876/* initialize the hash table */
    917 static void /*__devinit*/ init_hda_cache(struct hda_cache_rec *cache,
     877static void __devinit init_hda_cache(struct hda_cache_rec *cache,
    918878                                     unsigned int record_size)
    919879{
     
    985945        return info->amp_caps;
    986946}
    987 EXPORT_SYMBOL_HDA(query_amp_caps);
    988947
    989948int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
     
    999958        return 0;
    1000959}
    1001 EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps);
    1002960
    1003961/*
     
    10531011        return get_vol_mute(codec, info, nid, ch, direction, index);
    10541012}
    1055 EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read);
    10561013
    10571014/*
     
    10731030        return 1;
    10741031}
    1075 EXPORT_SYMBOL_HDA(snd_hda_codec_amp_update);
    10761032
    10771033/*
     
    10871043        return ret;
    10881044}
    1089 EXPORT_SYMBOL_HDA(snd_hda_codec_amp_stereo);
    10901045
    10911046#ifdef SND_HDA_NEEDS_RESUME
     
    11131068        }
    11141069}
    1115 EXPORT_SYMBOL_HDA(snd_hda_codec_resume_amp);
    11161070#endif /* SND_HDA_NEEDS_RESUME */
    11171071
     
    11411095        return 0;
    11421096}
    1143 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info);
    11441097
    11451098int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
     
    11611114        return 0;
    11621115}
    1163 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get);
    11641116
    11651117int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
     
    11861138        return change;
    11871139}
    1188 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_put);
    11891140
    11901141int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
     
    12131164        return 0;
    12141165}
    1215 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_tlv);
    12161166
    12171167/*
     
    12331183        tlv[3] = step;
    12341184}
    1235 EXPORT_SYMBOL_HDA(snd_hda_set_vmaster_tlv);
    12361185
    12371186/* find a mixer control element with the given name */
     
    12531202        return _snd_hda_find_mixer_ctl(codec, name, 0);
    12541203}
    1255 EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl);
    12561204
    12571205/* Add a control element and assign to the codec */
     
    12701218        return 0;
    12711219}
    1272 EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
    1273 
    1274 #ifdef CONFIG_SND_HDA_RECONFIG
     1220
    12751221/* Clear all controls assigned to the given codec */
    12761222void snd_hda_ctls_clear(struct hda_codec *codec)
     
    12891235#ifdef CONFIG_SND_HDA_POWER_SAVE
    12901236        cancel_delayed_work(&codec->power_work);
    1291         flush_workqueue(codec->bus->workq);
     1237        flush_scheduled_work();
    12921238#endif
    12931239        snd_hda_ctls_clear(codec);
    12941240        /* relase PCMs */
    12951241        for (i = 0; i < codec->num_pcms; i++) {
    1296                 if (codec->pcm_info[i].pcm) {
     1242                if (codec->pcm_info[i].pcm)
    12971243                        snd_device_free(codec->bus->card,
    12981244                                        codec->pcm_info[i].pcm);
    1299                         clear_bit(codec->pcm_info[i].device,
    1300                                   codec->bus->pcm_dev_bits);
    1301                 }
    13021245        }
    13031246        if (codec->patch_ops.free)
    13041247                codec->patch_ops.free(codec);
    1305         codec->proc_widget_hook = NULL;
    13061248        codec->spec = NULL;
    13071249        free_hda_cache(&codec->amp_cache);
    13081250        free_hda_cache(&codec->cmd_cache);
    1309         init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
    1310         init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
    13111251        codec->num_pcms = 0;
    13121252        codec->pcm_info = NULL;
    13131253        codec->preset = NULL;
    1314         module_put(codec->owner);
    1315         codec->owner = NULL;
    1316 }
    1317 #endif /* CONFIG_SND_HDA_RECONFIG */
     1254}
    13181255
    13191256/* create a virtual master control and add slaves */
     
    13521289        return 0;
    13531290}
    1354 EXPORT_SYMBOL_HDA(snd_hda_add_vmaster);
    13551291
    13561292/* switch */
     
    13661302        return 0;
    13671303}
    1368 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_info);
    13691304
    13701305int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
     
    13861321        return 0;
    13871322}
    1388 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_get);
    13891323
    13901324int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
     
    14171351        return change;
    14181352}
    1419 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put);
    14201353
    14211354/*
     
    14351368        int err;
    14361369
    1437         mutex_lock(&codec->control_mutex);
     1370        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    14381371        pval = kcontrol->private_value;
    14391372        kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
    14401373        err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
    14411374        kcontrol->private_value = pval;
    1442         mutex_unlock(&codec->control_mutex);
     1375        mutex_unlock(&codec->spdif_mutex);
    14431376        return err;
    14441377}
    1445 EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get);
    14461378
    14471379int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
     
    14521384        int i, indices, err = 0, change = 0;
    14531385
    1454         mutex_lock(&codec->control_mutex);
     1386        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    14551387        pval = kcontrol->private_value;
    14561388        indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
     
    14641396        }
    14651397        kcontrol->private_value = pval;
    1466         mutex_unlock(&codec->control_mutex);
     1398        mutex_unlock(&codec->spdif_mutex);
    14671399        return err < 0 ? err : change;
    14681400}
    1469 EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put);
    14701401
    14711402/*
     
    14791410        int err;
    14801411
    1481         mutex_lock(&codec->control_mutex);
     1412        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    14821413        c = (struct hda_bind_ctls *)kcontrol->private_value;
    14831414        kcontrol->private_value = *c->values;
    14841415        err = c->ops->info(kcontrol, uinfo);
    14851416        kcontrol->private_value = (long)c;
    1486         mutex_unlock(&codec->control_mutex);
     1417        mutex_unlock(&codec->spdif_mutex);
    14871418        return err;
    14881419}
    1489 EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info);
    14901420
    14911421int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
     
    14961426        int err;
    14971427
    1498         mutex_lock(&codec->control_mutex);
     1428        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    14991429        c = (struct hda_bind_ctls *)kcontrol->private_value;
    15001430        kcontrol->private_value = *c->values;
    15011431        err = c->ops->get(kcontrol, ucontrol);
    15021432        kcontrol->private_value = (long)c;
    1503         mutex_unlock(&codec->control_mutex);
     1433        mutex_unlock(&codec->spdif_mutex);
    15041434        return err;
    15051435}
    1506 EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get);
    15071436
    15081437int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
     
    15141443        int err = 0, change = 0;
    15151444
    1516         mutex_lock(&codec->control_mutex);
     1445        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15171446        c = (struct hda_bind_ctls *)kcontrol->private_value;
    15181447        for (vals = c->values; *vals; vals++) {
     
    15241453        }
    15251454        kcontrol->private_value = (long)c;
    1526         mutex_unlock(&codec->control_mutex);
     1455        mutex_unlock(&codec->spdif_mutex);
    15271456        return err < 0 ? err : change;
    15281457}
    1529 EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put);
    15301458
    15311459int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
     
    15361464        int err;
    15371465
    1538         mutex_lock(&codec->control_mutex);
     1466        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15391467        c = (struct hda_bind_ctls *)kcontrol->private_value;
    15401468        kcontrol->private_value = *c->values;
    15411469        err = c->ops->tlv(kcontrol, op_flag, size, tlv);
    15421470        kcontrol->private_value = (long)c;
    1543         mutex_unlock(&codec->control_mutex);
     1471        mutex_unlock(&codec->spdif_mutex);
    15441472        return err;
    15451473}
    1546 EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv);
    15471474
    15481475struct hda_ctl_ops snd_hda_bind_vol = {
     
    15521479        .tlv = snd_hda_mixer_amp_tlv
    15531480};
    1554 EXPORT_SYMBOL_HDA(snd_hda_bind_vol);
    15551481
    15561482struct hda_ctl_ops snd_hda_bind_sw = {
     
    15601486        .tlv = snd_hda_mixer_amp_tlv
    15611487};
    1562 EXPORT_SYMBOL_HDA(snd_hda_bind_sw);
    15631488
    15641489/*
     
    16671592        hda_nid_t *d;
    16681593
    1669         snd_hda_codec_write_cache(codec, nid, 0, verb, val);
     1594        snd_hda_codec_write(codec, nid, 0, verb, val);
    16701595        d = codec->slave_dig_outs;
    16711596        if (!d)
    16721597                return;
    16731598        for (; *d; d++)
    1674                 snd_hda_codec_write_cache(codec, *d, 0, verb, val);
     1599                snd_hda_codec_write(codec, *d, 0, verb, val);
    16751600}
    16761601
     
    18221747        return 0;
    18231748}
    1824 EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls);
    18251749
    18261750/*
     
    18601784                           snd_ctl_new1(&spdif_share_sw, mout));
    18611785}
    1862 EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw);
    18631786
    18641787/*
     
    19701893        return 0;
    19711894}
    1972 EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls);
    19731895
    19741896#ifdef SND_HDA_NEEDS_RESUME
     
    20161938        return err;
    20171939}
    2018 EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache);
    20191940
    20201941/* resume the all commands from the cache */
     
    20321953        }
    20331954}
    2034 EXPORT_SYMBOL_HDA(snd_hda_codec_resume_cache);
    20351955
    20361956/**
     
    20501970                                          seq->param);
    20511971}
    2052 EXPORT_SYMBOL_HDA(snd_hda_sequence_write_cache);
    20531972#endif /* SND_HDA_NEEDS_RESUME */
    20541973
     
    21692088 * Returns 0 if successful, otherwise a negative error code.
    21702089 */
    2171 int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
     2090int __devinit snd_hda_build_controls(struct hda_bus *bus)
    21722091{
    21732092        struct hda_codec *codec;
     
    21812100        return 0;
    21822101}
    2183 EXPORT_SYMBOL_HDA(snd_hda_build_controls);
    21842102
    21852103int snd_hda_codec_build_controls(struct hda_codec *codec)
     
    22932211        return val;
    22942212}
    2295 EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format);
    22962213
    22972214/**
     
    23082225 * Returns 0 if successful, otherwise a negative error code.
    23092226 */
    2310 static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
     2227int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
    23112228                                u32 *ratesp, u64 *formatsp, unsigned int *bpsp)
    23122229{
     
    24732390        return 1;
    24742391}
    2475 EXPORT_SYMBOL_HDA(snd_hda_is_supported_format);
    24762392
    24772393/*
     
    25312447
    25322448/*
    2533  * get the empty PCM device number to assign
    2534  */
    2535 static int get_empty_pcm_device(struct hda_bus *bus, int type)
     2449 * attach a new PCM stream
     2450 */
     2451static int __devinit
     2452snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm)
     2453{
     2454        struct hda_bus *bus = codec->bus;
     2455        struct hda_pcm_stream *info;
     2456        int stream, err;
     2457
     2458        if (snd_BUG_ON(!pcm->name))
     2459                return -EINVAL;
     2460        for (stream = 0; stream < 2; stream++) {
     2461                info = &pcm->stream[stream];
     2462                if (info->substreams) {
     2463                        err = set_pcm_default_values(codec, info);
     2464                        if (err < 0)
     2465                                return err;
     2466                }
     2467        }
     2468        return bus->ops.attach_pcm(bus, codec, pcm);
     2469}
     2470
     2471/**
     2472 * snd_hda_build_pcms - build PCM information
     2473 * @bus: the BUS
     2474 *
     2475 * Create PCM information for each codec included in the bus.
     2476 *
     2477 * The build_pcms codec patch is requested to set up codec->num_pcms and
     2478 * codec->pcm_info properly.  The array is referred by the top-level driver
     2479 * to create its PCM instances.
     2480 * The allocated codec->pcm_info should be released in codec->patch_ops.free
     2481 * callback.
     2482 *
     2483 * At least, substreams, channels_min and channels_max must be filled for
     2484 * each stream.  substreams = 0 indicates that the stream doesn't exist.
     2485 * When rates and/or formats are zero, the supported values are queried
     2486 * from the given nid.  The nid is used also by the default ops.prepare
     2487 * and ops.cleanup callbacks.
     2488 *
     2489 * The driver needs to call ops.open in its open callback.  Similarly,
     2490 * ops.close is supposed to be called in the close callback.
     2491 * ops.prepare should be called in the prepare or hw_params callback
     2492 * with the proper parameters for set up.
     2493 * ops.cleanup should be called in hw_free for clean up of streams.
     2494 *
     2495 * This function returns 0 if successfull, or a negative error code.
     2496 */
     2497int snd_hda_build_pcms(struct hda_bus *bus)
    25362498{
    25372499        static const char *dev_name[HDA_PCM_NTYPES] = {
     
    25472509        /* normal audio device indices; not linear to keep compatibility */
    25482510        static int audio_idx[4] = { 0, 2, 4, 5 };
    2549         int i, dev;
    2550 
    2551         switch (type) {
    2552         case HDA_PCM_TYPE_AUDIO:
    2553                 for (i = 0; i < ARRAY_SIZE(audio_idx); i++) {
    2554                         dev = audio_idx[i];
    2555                         if (!test_bit(dev, bus->pcm_dev_bits))
    2556                                 break;
    2557                 }
    2558                 if (i >= ARRAY_SIZE(audio_idx)) {
    2559                         snd_printk(KERN_WARNING "Too many audio devices\n");
    2560                         return -EAGAIN;
    2561                 }
    2562                 break;
    2563         case HDA_PCM_TYPE_SPDIF:
    2564         case HDA_PCM_TYPE_HDMI:
    2565         case HDA_PCM_TYPE_MODEM:
    2566                 dev = dev_idx[type];
    2567                 if (test_bit(dev, bus->pcm_dev_bits)) {
    2568                         snd_printk(KERN_WARNING "%s already defined\n",
    2569                                    dev_name[type]);
    2570                         return -EAGAIN;
    2571                 }
    2572                 break;
    2573         default:
    2574                 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
    2575                 return -EINVAL;
    2576         }
    2577         set_bit(dev, bus->pcm_dev_bits);
    2578         return dev;
    2579 }
    2580 
    2581 /*
    2582  * attach a new PCM stream
    2583  */
    2584 static int snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm)
    2585 {
    2586         struct hda_bus *bus = codec->bus;
    2587         struct hda_pcm_stream *info;
    2588         int stream, err;
    2589 
    2590         if (snd_BUG_ON(!pcm->name))
    2591                 return -EINVAL;
    2592         for (stream = 0; stream < 2; stream++) {
    2593                 info = &pcm->stream[stream];
    2594                 if (info->substreams) {
    2595                         err = set_pcm_default_values(codec, info);
     2511        struct hda_codec *codec;
     2512        int num_devs[HDA_PCM_NTYPES];
     2513
     2514        memset(num_devs, 0, sizeof(num_devs));
     2515        list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
     2516                unsigned int pcm;
     2517                int err;
     2518                if (!codec->num_pcms) {
     2519                        if (!codec->patch_ops.build_pcms)
     2520                                continue;
     2521                        err = codec->patch_ops.build_pcms(codec);
    25962522                        if (err < 0)
    25972523                                return err;
    25982524                }
    2599         }
    2600         return bus->ops.attach_pcm(bus, codec, pcm);
    2601 }
    2602 
    2603 /* assign all PCMs of the given codec */
    2604 int snd_hda_codec_build_pcms(struct hda_codec *codec)
    2605 {
    2606         unsigned int pcm;
    2607         int err;
    2608 
    2609         if (!codec->num_pcms) {
    2610                 if (!codec->patch_ops.build_pcms)
    2611                         return 0;
    2612                 err = codec->patch_ops.build_pcms(codec);
    2613                 if (err < 0)
    2614                         return err;
    2615         }
    2616         for (pcm = 0; pcm < codec->num_pcms; pcm++) {
    2617                 struct hda_pcm *cpcm = &codec->pcm_info[pcm];
    2618                 int dev;
    2619 
    2620                 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
    2621                         return 0; /* no substreams assigned */
    2622 
    2623                 if (!cpcm->pcm) {
    2624                         dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type);
    2625                         if (dev < 0)
    2626                                 return 0;
    2627                         cpcm->device = dev;
    2628                         err = snd_hda_attach_pcm(codec, cpcm);
    2629                         if (err < 0)
    2630                                 return err;
     2525                for (pcm = 0; pcm < codec->num_pcms; pcm++) {
     2526                        struct hda_pcm *cpcm = &codec->pcm_info[pcm];
     2527                        int type = cpcm->pcm_type;
     2528                        int dev;
     2529
     2530                        if (!cpcm->stream[0].substreams &&
     2531                            !cpcm->stream[1].substreams)
     2532                                continue; /* no substreams assigned */
     2533
     2534                        switch (type) {
     2535                        case HDA_PCM_TYPE_AUDIO:
     2536                                if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
     2537                                        snd_printk(KERN_WARNING
     2538                                                   "Too many audio devices\n");
     2539                                        continue;
     2540                                }
     2541                                dev = audio_idx[num_devs[type]];
     2542                                break;
     2543                        case HDA_PCM_TYPE_SPDIF:
     2544                        case HDA_PCM_TYPE_HDMI:
     2545                        case HDA_PCM_TYPE_MODEM:
     2546                                if (num_devs[type]) {
     2547                                        snd_printk(KERN_WARNING
     2548                                                   "%s already defined\n",
     2549                                                   dev_name[type]);
     2550                                        continue;
     2551                                }
     2552                                dev = dev_idx[type];
     2553                                break;
     2554                        default:
     2555                                snd_printk(KERN_WARNING
     2556                                           "Invalid PCM type %d\n", type);
     2557                                continue;
     2558                        }
     2559                        num_devs[type]++;
     2560                        if (!cpcm->pcm) {
     2561                                cpcm->device = dev;
     2562                                err = snd_hda_attach_pcm(codec, cpcm);
     2563                                if (err < 0)
     2564                                        return err;
     2565                        }
    26312566                }
    26322567        }
    26332568        return 0;
    26342569}
    2635 
    2636 /**
    2637  * snd_hda_build_pcms - build PCM information
    2638  * @bus: the BUS
    2639  *
    2640  * Create PCM information for each codec included in the bus.
    2641  *
    2642  * The build_pcms codec patch is requested to set up codec->num_pcms and
    2643  * codec->pcm_info properly.  The array is referred by the top-level driver
    2644  * to create its PCM instances.
    2645  * The allocated codec->pcm_info should be released in codec->patch_ops.free
    2646  * callback.
    2647  *
    2648  * At least, substreams, channels_min and channels_max must be filled for
    2649  * each stream.  substreams = 0 indicates that the stream doesn't exist.
    2650  * When rates and/or formats are zero, the supported values are queried
    2651  * from the given nid.  The nid is used also by the default ops.prepare
    2652  * and ops.cleanup callbacks.
    2653  *
    2654  * The driver needs to call ops.open in its open callback.  Similarly,
    2655  * ops.close is supposed to be called in the close callback.
    2656  * ops.prepare should be called in the prepare or hw_params callback
    2657  * with the proper parameters for set up.
    2658  * ops.cleanup should be called in hw_free for clean up of streams.
    2659  *
    2660  * This function returns 0 if successfull, or a negative error code.
    2661  */
    2662 int __devinit snd_hda_build_pcms(struct hda_bus *bus)
    2663 {
    2664         struct hda_codec *codec;
    2665 
    2666         list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
    2667                 int err = snd_hda_codec_build_pcms(codec);
    2668                 if (err < 0)
    2669                         return err;
    2670         }
    2671         return 0;
    2672 }
    2673 EXPORT_SYMBOL_HDA(snd_hda_build_pcms);
    26742570
    26752571/**
     
    27272623        return -1;
    27282624}
    2729 EXPORT_SYMBOL_HDA(snd_hda_check_board_config);
    2730 
    2731 /**
    2732  * snd_hda_check_board_codec_sid_config - compare the current codec
    2733                                           subsystem ID with the
    2734                                           config table
    2735 
    2736            This is important for Gateway notebooks with SB450 HDA Audio
    2737            where the vendor ID of the PCI device is:
    2738                 ATI Technologies Inc SB450 HDA Audio [1002:437b]
    2739            and the vendor/subvendor are found only at the codec.
    2740 
    2741  * @codec: the HDA codec
    2742  * @num_configs: number of config enums
    2743  * @models: array of model name strings
    2744  * @tbl: configuration table, terminated by null entries
    2745  *
    2746  * Compares the modelname or PCI subsystem id of the current codec with the
    2747  * given configuration table.  If a matching entry is found, returns its
    2748  * config value (supposed to be 0 or positive).
    2749  *
    2750  * If no entries are matching, the function returns a negative value.
    2751  */
    2752 int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
    2753                                int num_configs, const char **models,
    2754                                const struct snd_pci_quirk *tbl)
    2755 {
    2756         const struct snd_pci_quirk *q;
    2757 
    2758         /* Search for codec ID */
    2759         for (q = tbl; q->subvendor; q++) {
    2760                 unsigned long vendorid = (q->subdevice) | (q->subvendor << 16);
    2761 
    2762                 if (vendorid == codec->subsystem_id)
    2763                         break;
    2764         }
    2765 
    2766         if (!q->subvendor)
    2767                 return -1;
    2768 
    2769         tbl = q;
    2770 
    2771         if (tbl->value >= 0 && tbl->value < num_configs) {
    2772 #ifdef CONFIG_SND_DEBUG_DETECT
    2773                 char tmp[10];
    2774                 const char *model = NULL;
    2775                 if (models)
    2776                         model = models[tbl->value];
    2777                 if (!model) {
    2778                         sprintf(tmp, "#%d", tbl->value);
    2779                         model = tmp;
    2780                 }
    2781                 snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
    2782                             "for config %x:%x (%s)\n",
    2783                             model, tbl->subvendor, tbl->subdevice,
    2784                             (tbl->name ? tbl->name : "Unknown device"));
    2785 #endif
    2786                 return tbl->value;
    2787         }
    2788         return -1;
    2789 }
    2790 EXPORT_SYMBOL_HDA(snd_hda_check_board_codec_sid_config);
    27912625
    27922626/**
     
    28242658        return 0;
    28252659}
    2826 EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls);
    28272660
    28282661#ifdef CONFIG_SND_HDA_POWER_SAVE
     
    28672700        codec->power_transition = 0;
    28682701}
    2869 EXPORT_SYMBOL_HDA(snd_hda_power_up);
    2870 
    2871 #define power_save(codec)       \
    2872         ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
    2873 
    2874 #define power_save(codec)       \
    2875         ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
    28762702
    28772703void snd_hda_power_down(struct hda_codec *codec)
     
    28802706        if (!codec->power_on || codec->power_count || codec->power_transition)
    28812707                return;
    2882         if (power_save(codec)) {
     2708        if (power_save) {
    28832709                codec->power_transition = 1; /* avoid reentrance */
    2884                 queue_delayed_work(codec->bus->workq, &codec->power_work,
    2885                                 msecs_to_jiffies(power_save(codec) * 1000));
    2886         }
    2887 }
    2888 EXPORT_SYMBOL_HDA(snd_hda_power_down);
     2710                schedule_delayed_work(&codec->power_work,
     2711                                      msecs_to_jiffies(power_save * 1000));
     2712        }
     2713}
    28892714
    28902715int snd_hda_check_amp_list_power(struct hda_codec *codec,
     
    29232748        return 0;
    29242749}
    2925 EXPORT_SYMBOL_HDA(snd_hda_check_amp_list_power);
    29262750#endif
    29272751
     
    29432767        return 0;
    29442768}
    2945 EXPORT_SYMBOL_HDA(snd_hda_ch_mode_info);
    29462769
    29472770int snd_hda_ch_mode_get(struct hda_codec *codec,
     
    29612784        return 0;
    29622785}
    2963 EXPORT_SYMBOL_HDA(snd_hda_ch_mode_get);
    29642786
    29652787int snd_hda_ch_mode_put(struct hda_codec *codec,
     
    29822804        return 1;
    29832805}
    2984 EXPORT_SYMBOL_HDA(snd_hda_ch_mode_put);
    29852806
    29862807/*
     
    30032824        return 0;
    30042825}
    3005 EXPORT_SYMBOL_HDA(snd_hda_input_mux_info);
    30062826
    30072827int snd_hda_input_mux_put(struct hda_codec *codec,
     
    30252845        return 1;
    30262846}
    3027 EXPORT_SYMBOL_HDA(snd_hda_input_mux_put);
    30282847
    30292848
     
    30782897        return 0;
    30792898}
    3080 EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_open);
    30812899
    30822900int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
     
    30912909        return 0;
    30922910}
    3093 EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare);
    30942911
    30952912/*
     
    31042921        return 0;
    31052922}
    3106 EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_close);
    31072923
    31082924/*
     
    31442960                                          SNDRV_PCM_HW_PARAM_CHANNELS, 2);
    31452961}
    3146 EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_open);
    31472962
    31482963/*
     
    32033018        return 0;
    32043019}
    3205 EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare);
    32063020
    32073021/*
     
    32303044        return 0;
    32313045}
    3232 EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup);
    32333046
    32343047/*
     
    35163329        return 0;
    35173330}
    3518 EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config);
    35193331
    35203332/* labels for input pins */
     
    35223334        "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
    35233335};
    3524 EXPORT_SYMBOL_HDA(auto_pin_cfg_labels);
    35253336
    35263337
     
    35503361        return 0;
    35513362}
    3552 EXPORT_SYMBOL_HDA(snd_hda_suspend);
    35533363
    35543364/**
    35553365 * snd_hda_resume - resume the codecs
    35563366 * @bus: the HDA bus
     3367 * @state: resume state
    35573368 *
    35583369 * Returns 0 if successful.
     
    35713382        return 0;
    35723383}
    3573 EXPORT_SYMBOL_HDA(snd_hda_resume);
    3574 #endif /* CONFIG_PM */
     3384#ifdef CONFIG_SND_HDA_POWER_SAVE
     3385int snd_hda_codecs_inuse(struct hda_bus *bus)
     3386{
     3387        struct hda_codec *codec;
     3388
     3389        list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
     3390                if (snd_hda_codec_needs_resume(codec))
     3391                        return 1;
     3392        }
     3393        return 0;
     3394}
     3395#endif
     3396#endif
    35753397
    35763398/*
     
    36013423        return snd_array_elem(array, array->used++);
    36023424}
    3603 EXPORT_SYMBOL_HDA(snd_array_new);
    36043425
    36053426/* free the given array elements */
     
    36113432        array->list = NULL;
    36123433}
    3613 EXPORT_SYMBOL_HDA(snd_array_free);
    3614 
    3615 /*
    3616  * used by hda_proc.c and hda_eld.c
    3617  */
    3618 void snd_print_pcm_rates(int pcm, char *buf, int buflen)
    3619 {
    3620         static unsigned int rates[] = {
    3621                 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
    3622                 96000, 176400, 192000, 384000
    3623         };
    3624         int i, j;
    3625 
    3626         for (i = 0, j = 0; i < ARRAY_SIZE(rates); i++)
    3627                 if (pcm & (1 << i))
    3628                         j += snprintf(buf + j, buflen - j,  " %d", rates[i]);
    3629 
    3630         buf[j] = '\0'; /* necessary when j == 0 */
    3631 }
    3632 EXPORT_SYMBOL_HDA(snd_print_pcm_rates);
    3633 
    3634 void snd_print_pcm_bits(int pcm, char *buf, int buflen)
    3635 {
    3636         static unsigned int bits[] = { 8, 16, 20, 24, 32 };
    3637         int i, j;
    3638 
    3639         for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
    3640                 if (pcm & (AC_SUPPCM_BITS_8 << i))
    3641                         j += snprintf(buf + j, buflen - j,  " %d", bits[i]);
    3642 
    3643         buf[j] = '\0'; /* necessary when j == 0 */
    3644 }
    3645 EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
    3646 
    3647 MODULE_DESCRIPTION("HDA codec core");
    3648 MODULE_LICENSE("GPL");
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_codec.h

    r410 r417  
    586586        struct pci_dev *pci;
    587587        const char *modelname;
    588         int *power_save;
    589588        struct hda_bus_ops ops;
    590589};
     
    603602        struct pci_dev *pci;
    604603        const char *modelname;
    605         int *power_save;
    606604        struct hda_bus_ops ops;
    607605
     
    619617        /* unsolicited event queue */
    620618        struct hda_bus_unsolicited *unsol;
    621         struct workqueue_struct *workq; /* common workqueue for codecs */
    622 
    623         /* assigned PCMs */
    624         DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
     619
     620        struct snd_info_entry *proc;
    625621
    626622        /* misc op flags */
    627623        unsigned int needs_damn_long_delay :1;
    628         unsigned int shutdown :1;       /* being unloaded */
    629624};
    630625
     
    646641};
    647642       
    648 struct hda_codec_preset_list {
    649         const struct hda_codec_preset *preset;
    650         struct module *owner;
    651         struct list_head list;
    652 };
    653 
    654 /* initial hook */
    655 int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset);
    656 int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset);
    657 
    658643/* ops set by the preset patch */
    659644struct hda_codec_ops {
     
    749734        /* detected preset */
    750735        const struct hda_codec_preset *preset;
    751         struct module *owner;
    752736        const char *name;       /* codec name */
    753737        const char *modelname;  /* model name for preset */
     
    781765        struct semaphore spdif_mutex;
    782766#endif
    783         struct mutex control_mutex;
    784767        unsigned int spdif_status;      /* IEC958 status bits */
    785768        unsigned short spdif_ctls;      /* SPDIF control bits */
     
    804787        struct delayed_work power_work; /* delayed task for powerdown */
    805788#endif
    806 
    807         /* codec-specific additional proc output */
    808         void (*proc_widget_hook)(struct snd_info_buffer *buffer,
    809                                  struct hda_codec *codec, hda_nid_t nid);
    810789};
    811790
     
    822801                    struct hda_bus **busp);
    823802int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
    824                       int do_init, struct hda_codec **codecp);
     803                      struct hda_codec **codecp);
    825804
    826805/*
     
    873852 */
    874853int snd_hda_build_pcms(struct hda_bus *bus);
    875 int snd_hda_codec_build_pcms(struct hda_codec *codec);
    876854void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
    877855                                u32 stream_tag,
     
    882860                                        unsigned int format,
    883861                                        unsigned int maxbps);
     862int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
     863                                u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
    884864int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
    885865                                unsigned int format);
     
    912892void snd_hda_power_down(struct hda_codec *codec);
    913893#define snd_hda_codec_needs_resume(codec) codec->power_count
     894int snd_hda_codecs_inuse(struct hda_bus *bus);
    914895#else
    915896static inline void snd_hda_power_up(struct hda_codec *codec) {}
    916897static inline void snd_hda_power_down(struct hda_codec *codec) {}
    917898#define snd_hda_codec_needs_resume(codec) 1
    918 #endif
    919 
    920 /*
    921  * Codec modularization
    922  */
    923 
    924 /* Export symbols only for communication with codec drivers;
    925  * When built in kernel, all HD-audio drivers are supposed to be statically
    926  * linked to the kernel.  Thus, the symbols don't have to (or shouldn't) be
    927  * exported unless it's built as a module.
    928  */
    929 #if defined(MODULE) && !defined(TARGET_OS2)
    930 #define EXPORT_SYMBOL_HDA(sym) EXPORT_SYMBOL_GPL(sym)
    931 #else
    932 #define EXPORT_SYMBOL_HDA(sym)
     899#define snd_hda_codecs_inuse(bus) 1
    933900#endif
    934901
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_generic.c

    r411 r417  
    732732                snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
    733733                err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
    734 #ifndef TARGET_OS2
    735734                if (err < 0)
    736735                        return err;
    737 #else
    738                 if (err < 0)
    739                         snd_printdd("Failed here\n");
    740 #endif
    741736                created = 1;
    742737        } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
     
    744739                /*knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT);*/
    745740                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    746                 knew.index = 0;
     741                knew.index = index;
    747742                knew.name = name;
    748743                knew.info = snd_hda_mixer_amp_switch_info;
     
    752747                if (is_loopback)
    753748                        add_input_loopback(codec, node->nid, HDA_OUTPUT, 0);
    754                 snd_printdd("[%s] NID=0x%x, DIR=OUT1\n", name, node->nid);
     749                snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
    755750                err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
    756 #ifndef TARGET_OS2
    757751                if (err < 0)
    758752                        return err;
    759 #else
    760                 if (err < 0)
    761                         snd_printdd("Failed here1\n");
    762 #endif
    763753                created = 1;
    764754        }
     
    779769                snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
    780770                err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
    781 #ifndef TARGET_OS2
    782771                if (err < 0)
    783772                        return err;
    784 #else
    785                 if (err < 0)
    786                         snd_printdd("Failed here2\n");
    787 #endif
    788773                created = 1;
    789774        } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
     
    798783                snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
    799784                err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
    800 #ifndef TARGET_OS2
    801785                if (err < 0)
    802786                        return err;
    803 #else
    804                 if (err < 0)
    805                         snd_printdd("Failed here3\n");
    806 #endif
    807787                created = 1;
    808788        }
     
    11581138        return err;
    11591139}
    1160 EXPORT_SYMBOL(snd_hda_parse_generic_codec);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_hwdep.c

    r410 r417  
    117117}
    118118
    119 int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
     119int __devinit snd_hda_create_hwdep(struct hda_codec *codec)
    120120{
    121121        char hwname[16];
     
    146146}
    147147
    148 #ifdef CONFIG_SND_HDA_RECONFIG
    149 
    150148/*
    151149 * sysfs interface
     
    169167                return err;
    170168        /* rebuild PCMs */
    171         err = snd_hda_codec_build_pcms(codec);
     169        err = snd_hda_build_pcms(codec->bus);
    172170        if (err < 0)
    173171                return err;
     
    316314}
    317315
     316#ifndef TARGET_OS2
    318317#define CODEC_ATTR_RW(type) \
    319318        __ATTR(type, 0644, type##_show, type##_store)
     
    350349        return 0;
    351350}
    352 
    353 #endif /* CONFIG_SND_HDA_RECONFIG */
     351#endif /* TARGET_OS2 */
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_intel.c

    r412 r417  
    5151#include "hda_codec.h"
    5252
    53 
    5453static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
    5554static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
     
    6463static int probe_mask[SNDRV_CARDS] = {-1};
    6564#endif
    66 static int probe_only[SNDRV_CARDS];
    6765static int single_cmd;
    6866static int enable_msi;
     
    8381module_param_array(probe_mask, int, NULL, 0444);
    8482MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
    85 module_param_array(probe_only, bool, NULL, 0444);
    86 MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization.");
    8783module_param(single_cmd, bool, 0444);
    8884MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
     
    9288
    9389#ifdef CONFIG_SND_HDA_POWER_SAVE
    94 static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
    95 module_param(power_save, int, 0644);
    96 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
    97                  "(in second, 0 = disable).");
     90/* power_save option is defined in hda_codec.c */
    9891
    9992/* reset the HD-audio controller in power save mode.
     
    304297#define VIA_HDAC_DEVICE_ID              0x3288
    305298
    306 /* HD Audio class code */
    307 #define PCI_CLASS_MULTIMEDIA_HD_AUDIO   0x0403
    308299
    309300/*
     
    444435        AZX_DRIVER_NVIDIA,
    445436        AZX_DRIVER_TERA,
    446         AZX_DRIVER_GENERIC,
    447437        AZX_NUM_DRIVERS, /* keep this as last entry */
    448438};
     
    458448        [AZX_DRIVER_NVIDIA] = "HDA NVidia",
    459449        [AZX_DRIVER_TERA] = "HDA Teradici",
    460         [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
    461450};
    462451
     
    10231012                                snd_pcm_period_elapsed(azx_dev->substream);
    10241013                                spin_lock(&chip->reg_lock);
    1025                         } else if (chip->bus && chip->bus->workq) {
     1014                        } else {
    10261015                                /* bogus IRQ, process it later */
    10271016                                azx_dev->irq_pending = 1;
    1028                                 queue_work(chip->bus->workq,
    1029                                            &chip->irq_pending_work);
     1017#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     1018                                schedule_work(&chip->irq_pending_work);
     1019#endif
    10301020                        }
    10311021                }
     
    11001090                             struct azx_dev *azx_dev)
    11011091{
     1092#ifdef TARGET_OS2
     1093        volatile u32 *bdl;
     1094#else
    11021095        u32 *bdl;
    1103 
     1096#endif
    11041097        int i, ofs, periods, period_bytes;
    11051098        int pos_adj;
     
    12621255
    12631256static int __devinit azx_codec_create(struct azx *chip, const char *model,
    1264                                       unsigned int codec_probe_mask,
    1265                                       int no_init)
     1257                                      unsigned int codec_probe_mask)
    12661258{
    12671259        struct hda_bus_template bus_temp;
     
    12771269        bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
    12781270#ifdef CONFIG_SND_HDA_POWER_SAVE
    1279         bus_temp.power_save = &power_save;
    12801271        bus_temp.ops.pm_notify = azx_power_notify;
    12811272#endif
     
    13211312                if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
    13221313                        struct hda_codec *codec;
    1323                         err = snd_hda_codec_new(chip->bus, c, !no_init, &codec);
     1314                        err = snd_hda_codec_new(chip->bus, c, &codec);
    13241315                        if (err < 0)
    13251316                                continue;
     
    17761767                chip->azx_dev[i].irq_pending = 0;
    17771768        spin_unlock_irq(&chip->reg_lock);
     1769        flush_scheduled_work();
    17781770}
    17791771
     
    19461938 * power management
    19471939 */
    1948 
    1949 static int snd_hda_codecs_inuse(struct hda_bus *bus)
    1950 {
    1951         struct hda_codec *codec;
    1952 
    1953         list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
    1954                 if (snd_hda_codec_needs_resume(codec))
    1955                         return 1;
    1956         }
    1957         return 0;
    1958 }
    1959 
    19601940static int azx_suspend(struct pci_dev *pci, pm_message_t state)
    19611941{
     
    19831963}
    19841964
    1985 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
    1986 static int azx_resume_early(struct pci_dev *pci)
    1987 {
    1988         return pci_restore_state(pci);
    1989 }
    1990 #endif
    1991 
    19921965static int azx_resume(struct pci_dev *pci)
    19931966{
     
    19951968        struct azx *chip = card->private_data;
    19961969
    1997 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
     1970        pci_set_power_state(pci, PCI_D0);
    19981971        pci_restore_state(pci);
    1999 #endif
    2000 
    20011972        if (pci_enable_device(pci) < 0) {
    20021973                printk(KERN_ERR "hda-intel: pci_enable_device failed, "
     
    21392110        SND_PCI_QUIRK(0x17aa, 0x2010, "Thinkpad X/T/R60", 0x01),
    21402111        SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X/T/R61", 0x01),
    2141         /* broken BIOS */
    2142         SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
    2143         /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
    2144         SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
     2112        /* broken BIOS */
     2113        SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
    21452114        {0}
    21462115};
     
    22772246                        chip->capture_streams = ATIHDMI_NUM_CAPTURE;
    22782247                        break;
    2279                 case AZX_DRIVER_GENERIC:
    22802248                default:
    22812249                        chip->playback_streams = ICH6_NUM_PLAYBACK;
     
    23802348        }
    23812349
    2382         err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     2350        card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
     2351        if (!card) {
     2352                snd_printk(KERN_ERR SFX "Error creating card!\n");
     2353                return -ENOMEM;
     2354        }
     2355
     2356        err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
    23832357        if (err < 0) {
    2384                 snd_printk(KERN_ERR SFX "Error creating card!\n");
     2358                snd_card_free(card);
    23852359                return err;
    23862360        }
    2387 
    2388         err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
    2389         if (err < 0)
    2390                 goto out_free;
    23912361        card->private_data = chip;
    23922362
    23932363        /* create codec instances */
    2394         err = azx_codec_create(chip, model[dev], probe_mask[dev],
    2395                                probe_only[dev]);
    2396         if (err < 0)
    2397                 goto out_free;
     2364        err = azx_codec_create(chip, model[dev], probe_mask[dev]);
     2365        if (err < 0) {
     2366                snd_card_free(card);
     2367                return err;
     2368        }
    23982369
    23992370        /* create PCM streams */
    24002371        err = snd_hda_build_pcms(chip->bus);
    2401         if (err < 0)
    2402                 goto out_free;
     2372        if (err < 0) {
     2373                snd_card_free(card);
     2374                return err;
     2375        }
    24032376
    24042377        /* create mixer controls */
    24052378        err = azx_mixer_create(chip);
    2406         if (err < 0)
    2407                 goto out_free;
     2379        if (err < 0) {
     2380                snd_card_free(card);
     2381                return err;
     2382        }
    24082383
    24092384        snd_card_set_dev(card, &pci->dev);
    24102385
    24112386        err = snd_card_register(card);
    2412         if (err < 0)
    2413                 goto out_free;
     2387        if (err < 0) {
     2388                snd_card_free(card);
     2389                return err;
     2390        }
    24142391
    24152392        pci_set_drvdata(pci, card);
     
    24192396
    24202397        dev++;
    2421         return err;
    2422 out_free:
    2423         snd_card_free(card);
    24242398        return err;
    24252399}
     
    24962470        /* Teradici */
    24972471        { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
    2498         /* AMD Generic, PCI class code and Vendor ID for HD Audio */
    2499         { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID),
    2500           .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
    2501           .class_mask = 0xffffff,
    2502           .driver_data = AZX_DRIVER_GENERIC },
    25032472        { 0, }
    25042473};
     
    25132482#ifdef CONFIG_PM
    25142483        .suspend = azx_suspend,
    2515 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
    2516         .resume_early = azx_resume_early,
    2517 #endif
    25182484        .resume = azx_resume,
    25192485#endif
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_local.h

    r410 r417  
    289289#endif
    290290
    291 #define SND_PRINT_RATES_ADVISED_BUFSIZE 80
    292 void snd_print_pcm_rates(int pcm, char *buf, int buflen);
    293 
    294 #define SND_PRINT_BITS_ADVISED_BUFSIZE  16
    295 void snd_print_pcm_bits(int pcm, char *buf, int buflen);
    296 
    297291/*
    298292 * Misc
     
    301295                               const char **modelnames,
    302296                               const struct snd_pci_quirk *pci_list);
    303 int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
    304                                int num_configs, const char **models,
    305                                const struct snd_pci_quirk *tbl);
    306297int snd_hda_add_new_ctls(struct hda_codec *codec,
    307298                         struct snd_kcontrol_new *knew);
     
    417408#ifdef CONFIG_SND_HDA_HWDEP
    418409int snd_hda_create_hwdep(struct hda_codec *codec);
     410int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
    419411#else
    420412static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
    421 #endif
    422 
    423 #ifdef CONFIG_SND_HDA_RECONFIG
    424 int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
    425 #else
    426 static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
    427 {
    428         return 0;
    429 }
    430413#endif
    431414
     
    462445#define get_amp_index(kc)       (((kc)->private_value >> 19) & 0xf)
    463446
    464 /*
    465  * CEA Short Audio Descriptor data
    466  */
    467 struct cea_sad {
    468         int     channels;
    469         int     format;         /* (format == 0) indicates invalid SAD */
    470         int     rates;
    471         int     sample_bits;    /* for LPCM */
    472         int     max_bitrate;    /* for AC3...ATRAC */
    473         int     profile;        /* for WMAPRO */
    474 };
    475 
    476 #define ELD_FIXED_BYTES 20
    477 #define ELD_MAX_MNL     16
    478 #define ELD_MAX_SAD     16
    479 
    480 /*
    481  * ELD: EDID Like Data
    482  */
    483 struct hdmi_eld {
    484         int     eld_size;
    485         int     baseline_len;
    486         int     eld_ver;        /* (eld_ver == 0) indicates invalid ELD */
    487         int     cea_edid_ver;
    488         char    monitor_name[ELD_MAX_MNL + 1];
    489         int     manufacture_id;
    490         int     product_id;
    491         u64     port_id;
    492         int     support_hdcp;
    493         int     support_ai;
    494         int     conn_type;
    495         int     aud_synch_delay;
    496         int     spk_alloc;
    497         int     sad_count;
    498         struct cea_sad sad[ELD_MAX_SAD];
    499 #ifdef CONFIG_PROC_FS
    500         struct snd_info_entry *proc_entry;
    501 #endif
    502 };
    503 
    504 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
    505 int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t);
    506 void snd_hdmi_show_eld(struct hdmi_eld *eld);
    507 
    508 #ifdef CONFIG_PROC_FS
    509 int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld);
    510 void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld);
    511 #else
    512 static inline int snd_hda_eld_proc_new(struct hda_codec *codec,
    513                                        struct hdmi_eld *eld)
    514 {
    515         return 0;
    516 }
    517 static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
    518                                          struct hdmi_eld *eld)
    519 {
    520 }
    521 #endif
    522 
    523 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
    524 void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
    525 
    526447#endif /* __SOUND_HDA_LOCAL_H */
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_proc.c

    r410 r417  
    9292static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
    9393{
    94         char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
     94        static unsigned int rates[] = {
     95                8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
     96                96000, 176400, 192000, 384000
     97        };
     98        int i;
    9599
    96100        pcm &= AC_SUPPCM_RATES;
    97101        snd_iprintf(buffer, "    rates [0x%x]:", pcm);
    98         snd_print_pcm_rates(pcm, buf, sizeof(buf));
    99         snd_iprintf(buffer, "%s\n", buf);
     102        for (i = 0; i < ARRAY_SIZE(rates); i++)
     103                if (pcm & (1 << i))
     104                        snd_iprintf(buffer, " %d", rates[i]);
     105        snd_iprintf(buffer, "\n");
    100106}
    101107
    102108static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
    103109{
    104         char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
    105 
    106         snd_iprintf(buffer, "    bits [0x%x]:", (pcm >> 16) & 0xff);
    107         snd_print_pcm_bits(pcm, buf, sizeof(buf));
    108         snd_iprintf(buffer, "%s\n", buf);
     110        static unsigned int bits[] = { 8, 16, 20, 24, 32 };
     111        int i;
     112
     113        pcm = (pcm >> 16) & 0xff;
     114        snd_iprintf(buffer, "    bits [0x%x]:", pcm);
     115        for (i = 0; i < ARRAY_SIZE(bits); i++)
     116                if (pcm & (1 << i))
     117                        snd_iprintf(buffer, " %d", bits[i]);
     118        snd_iprintf(buffer, "\n");
    109119}
    110120
     
    415425}
    416426
     427static void print_realtek_coef(struct snd_info_buffer *buffer,
     428                               struct hda_codec *codec, hda_nid_t nid)
     429{
     430        int coeff = snd_hda_codec_read(codec, nid, 0,
     431                                       AC_VERB_GET_PROC_COEF, 0);
     432        snd_iprintf(buffer, "  Processing Coefficient: 0x%02x\n", coeff);
     433        coeff = snd_hda_codec_read(codec, nid, 0,
     434                                   AC_VERB_GET_COEF_INDEX, 0);
     435        snd_iprintf(buffer, "  Coefficient Index: 0x%02x\n", coeff);
     436}
     437
    417438static void print_gpio(struct snd_info_buffer *buffer,
    418439                       struct hda_codec *codec, hda_nid_t nid)
     
    447468                snd_iprintf(buffer,
    448469                            "  IO[%d]: enable=%d, dir=%d, wake=%d, "
    449                             "sticky=%d, data=%d, unsol=%d\n", i,
     470                            "sticky=%d, data=%d\n", i,
    450471                            (enable & (1<<i)) ? 1 : 0,
    451472                            (direction & (1<<i)) ? 1 : 0,
    452473                            (wake & (1<<i)) ? 1 : 0,
    453474                            (sticky & (1<<i)) ? 1 : 0,
    454                             (data & (1<<i)) ? 1 : 0,
    455                             (unsol & (1<<i)) ? 1 : 0);
     475                            (data & (1<<i)) ? 1 : 0);
    456476        /* FIXME: add GPO and GPI pin information */
    457477}
     
    494514
    495515        print_gpio(buffer, codec, codec->afg);
    496         if (codec->proc_widget_hook)
    497                 codec->proc_widget_hook(buffer, codec, codec->afg);
    498516
    499517        for (i = 0; i < nodes; i++, nid++) {
     
    598616                        print_proc_caps(buffer, codec, nid);
    599617
    600                 if (codec->proc_widget_hook)
    601                         codec->proc_widget_hook(buffer, codec, nid);
     618                /* NID 0x20 == Realtek Define Registers */
     619                if (codec->vendor_id == 0x10ec && nid == 0x20)
     620                        print_realtek_coef(buffer, codec, nid);
    602621        }
    603622        snd_hda_power_down(codec);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_analog.c

    r410 r417  
    2828#include "hda_codec.h"
    2929#include "hda_local.h"
     30#include "hda_patch.h"
    3031
    3132struct ad198x_spec {
     
    638639
    639640static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
    640         HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
    641         HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
    642         HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    643         HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
    644         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
    645         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
    646         HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
    647         HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    648         HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
    649         HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
    650         HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
    651         {
    652                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    653                 .name = "Capture Source",
    654                 .info = ad198x_mux_enum_info,
    655                 .get = ad198x_mux_enum_get,
    656                 .put = ad198x_mux_enum_put,
    657         },
    658         {
    659                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    660                 .name = "External Amplifier",
    661                 .info = ad198x_eapd_info,
    662                 .get = ad198x_eapd_get,
    663                 .put = ad198x_eapd_put,
    664                 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
    665         },
    666         {0} /* end */
    667 };
    668 
    669 static struct snd_kcontrol_new ad1986a_samsung_mixers[] = {
    670641        HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
    671642        HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
     
    960931        AD1986A_LAPTOP_AUTOMUTE,
    961932        AD1986A_ULTRA,
    962         AD1986A_SAMSUNG,
    963933        AD1986A_MODELS
    964934};
     
    971941        [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
    972942        [AD1986A_ULTRA]         = "ultra",
    973         [AD1986A_SAMSUNG]       = "samsung",
    974943};
    975944
     
    994963        SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
    995964        SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
    996         SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_SAMSUNG),
    997         SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_SAMSUNG),
    998         SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_SAMSUNG),
     965        SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
     966        SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
     967        SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
    999968        SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
    1000969        SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
     
    10781047        case AD1986A_LAPTOP_EAPD:
    10791048                spec->mixers[0] = ad1986a_laptop_eapd_mixers;
    1080                 spec->num_init_verbs = 2;
    1081                 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
    1082                 spec->multiout.max_channels = 2;
    1083                 spec->multiout.num_dacs = 1;
    1084                 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
    1085                 if (!is_jack_available(codec, 0x25))
    1086                         spec->multiout.dig_out_nid = 0;
    1087                 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
    1088                 break;
    1089         case AD1986A_SAMSUNG:
    1090                 spec->mixers[0] = ad1986a_samsung_mixers;
    10911049                spec->num_init_verbs = 3;
    10921050                spec->init_verbs[1] = ad1986a_eapd_init_verbs;
     
    39013859static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
    39023860        SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
    3903         SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
    39043861        SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
    3905         SND_PCI_QUIRK(0x103c, 0x30e6, "HP 6730b", AD1884A_LAPTOP),
    39063862        SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP),
    39073863        SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP),
     
    42644220        spec->adc_nids = ad1882_adc_nids;
    42654221        spec->capsrc_nids = ad1882_capsrc_nids;
    4266         if (codec->vendor_id == 0x11d41882)
     4222        if (codec->vendor_id == 0x11d1882)
    42674223                spec->input_mux = &ad1882_capture_source;
    42684224        else
     
    42704226        spec->num_mixers = 2;
    42714227        spec->mixers[0] = ad1882_base_mixers;
    4272         if (codec->vendor_id == 0x11d41882)
     4228        if (codec->vendor_id == 0x11d1882)
    42734229                spec->mixers[1] = ad1882_loopback_mixers;
    42744230        else
     
    43104266 * patch entries
    43114267 */
    4312 static struct hda_codec_preset snd_hda_preset_analog[] = {
     4268struct hda_codec_preset snd_hda_preset_analog[] = {
    43134269        { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
    43144270        { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
     
    43284284        {0} /* terminator */
    43294285};
    4330 
    4331 MODULE_ALIAS("snd-hda-codec-id:11d4*");
    4332 
    4333 MODULE_LICENSE("GPL");
    4334 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
    4335 
    4336 static struct hda_codec_preset_list analog_list = {
    4337         .preset = snd_hda_preset_analog,
    4338         .owner = THIS_MODULE,
    4339 };
    4340 
    4341 static int __init patch_analog_init(void)
    4342 {
    4343         return snd_hda_add_codec_preset(&analog_list);
    4344 }
    4345 
    4346 static void __exit patch_analog_exit(void)
    4347 {
    4348         snd_hda_delete_codec_preset(&analog_list);
    4349 }
    4350 
    4351 module_init(patch_analog_init)
    4352 module_exit(patch_analog_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_atihdmi.c

    r410 r417  
    2828#include "hda_codec.h"
    2929#include "hda_local.h"
     30#include "hda_patch.h"
    3031
    3132struct atihdmi_spec {
     
    187188 * patch entries
    188189 */
    189 static struct hda_codec_preset snd_hda_preset_atihdmi[] = {
    190         { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi },
    191         { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi },
    192         { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi },
    193         { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi },
     190struct hda_codec_preset snd_hda_preset_atihdmi[] = {
     191        { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
     192        { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
     193        { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
     194        { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi },
    194195        { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi },
     196        { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_atihdmi },
    195197        { .id = 0x17e80047, .name = "Chrontel HDMI",  .patch = patch_atihdmi },
    196198        {0} /* terminator */
    197199};
    198 
    199 MODULE_ALIAS("snd-hda-codec-id:1002793c");
    200 MODULE_ALIAS("snd-hda-codec-id:10027919");
    201 MODULE_ALIAS("snd-hda-codec-id:1002791a");
    202 MODULE_ALIAS("snd-hda-codec-id:1002aa01");
    203 MODULE_ALIAS("snd-hda-codec-id:10951390");
    204 MODULE_ALIAS("snd-hda-codec-id:17e80047");
    205 
    206 MODULE_LICENSE("GPL");
    207 MODULE_DESCRIPTION("ATI HDMI HD-audio codec");
    208 
    209 static struct hda_codec_preset_list atihdmi_list = {
    210         .preset = snd_hda_preset_atihdmi,
    211         .owner = THIS_MODULE,
    212 };
    213 
    214 static int __init patch_atihdmi_init(void)
    215 {
    216         return snd_hda_add_codec_preset(&atihdmi_list);
    217 }
    218 
    219 static void __exit patch_atihdmi_exit(void)
    220 {
    221         snd_hda_delete_codec_preset(&atihdmi_list);
    222 }
    223 
    224 module_init(patch_atihdmi_init)
    225 module_exit(patch_atihdmi_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_cmedia.c

    r410 r417  
    2929#include "hda_codec.h"
    3030#include "hda_local.h"
     31#include "hda_patch.h"
    3132#define NUM_PINS        11
    3233
     
    736737 * patch entries
    737738 */
    738 static struct hda_codec_preset snd_hda_preset_cmedia[] = {
     739struct hda_codec_preset snd_hda_preset_cmedia[] = {
    739740        { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 },
    740741        { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 },
    741742        {0} /* terminator */
    742743};
    743 
    744 MODULE_ALIAS("snd-hda-codec-id:13f69880");
    745 MODULE_ALIAS("snd-hda-codec-id:434d4980");
    746 
    747 MODULE_LICENSE("GPL");
    748 MODULE_DESCRIPTION("C-Media HD-audio codec");
    749 
    750 static struct hda_codec_preset_list cmedia_list = {
    751         .preset = snd_hda_preset_cmedia,
    752         .owner = THIS_MODULE,
    753 };
    754 
    755 static int __init patch_cmedia_init(void)
    756 {
    757         return snd_hda_add_codec_preset(&cmedia_list);
    758 }
    759 
    760 static void __exit patch_cmedia_exit(void)
    761 {
    762         snd_hda_delete_codec_preset(&cmedia_list);
    763 }
    764 
    765 module_init(patch_cmedia_init)
    766 module_exit(patch_cmedia_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_conexant.c

    r410 r417  
    2626#include <linux/pci.h>
    2727#include <sound/core.h>
    28 #include <sound/jack.h>
    29 
    3028#include "hda_codec.h"
    3129#include "hda_local.h"
     30#include "hda_patch.h"
    3231
    3332#define CXT_PIN_DIR_IN              0x00
     
    4039#define CONEXANT_MIC_EVENT      0x38
    4140
    42 /* Conexant 5051 specific */
    43 
    44 #define CXT5051_SPDIF_OUT       0x1C
    45 #define CXT5051_PORTB_EVENT     0x38
    46 #define CXT5051_PORTC_EVENT     0x39
    47 
    48 
    49 struct conexant_jack {
    50 
    51         hda_nid_t nid;
    52         int type;
    53         struct snd_jack *jack;
    54 
    55 };
     41
    5642
    5743struct conexant_spec {
     
    9884
    9985        unsigned int spdif_route;
    100 
    101         /* jack detection */
    102         struct snd_array jacks;
    10386
    10487        /* dynamic controls, init_verbs and input_mux */
     
    348331}
    349332
    350 static int conexant_add_jack(struct hda_codec *codec,
    351                 hda_nid_t nid, int type)
    352 {
    353         struct conexant_spec *spec;
    354         struct conexant_jack *jack;
    355         const char *name;
    356 
    357         spec = codec->spec;
    358         snd_array_init(&spec->jacks, sizeof(*jack), 32);
    359         jack = snd_array_new(&spec->jacks);
    360         name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
    361 
    362         if (!jack)
    363                 return -ENOMEM;
    364 
    365         jack->nid = nid;
    366         jack->type = type;
    367 
    368         return snd_jack_new(codec->bus->card, name, type, &jack->jack);
    369 }
    370 
    371 static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
    372 {
    373         struct conexant_spec *spec = codec->spec;
    374         struct conexant_jack *jacks = spec->jacks.list;
    375 
    376         if (jacks) {
    377                 int i;
    378                 for (i = 0; i < spec->jacks.used; i++) {
    379                         if (jacks->nid == nid) {
    380                                 unsigned int present;
    381                                 present = snd_hda_codec_read(codec, nid, 0,
    382                                                 AC_VERB_GET_PIN_SENSE, 0) &
    383                                         AC_PINSENSE_PRESENCE;
    384 
    385                                 present = (present) ? jacks->type : 0 ;
    386 
    387                                 snd_jack_report(jacks->jack,
    388                                                 present);
    389                         }
    390                         jacks++;
    391                 }
    392         }
    393 }
    394 
    395 static int conexant_init_jacks(struct hda_codec *codec)
    396 {
    397 #ifdef CONFIG_SND_JACK
    398         struct conexant_spec *spec = codec->spec;
    399         int i;
    400 
    401         for (i = 0; i < spec->num_init_verbs; i++) {
    402                 const struct hda_verb *hv;
    403 
    404                 hv = spec->init_verbs[i];
    405                 while (hv->nid) {
    406                         int err = 0;
    407                         switch (hv->param ^ AC_USRSP_EN) {
    408                         case CONEXANT_HP_EVENT:
    409                                 err = conexant_add_jack(codec, hv->nid,
    410                                                 SND_JACK_HEADPHONE);
    411                                 conexant_report_jack(codec, hv->nid);
    412                                 break;
    413                         case CXT5051_PORTC_EVENT:
    414                         case CONEXANT_MIC_EVENT:
    415                                 err = conexant_add_jack(codec, hv->nid,
    416                                                 SND_JACK_MICROPHONE);
    417                                 conexant_report_jack(codec, hv->nid);
    418                                 break;
    419                         }
    420                         if (err < 0)
    421                                 return err;
    422                         ++hv;
    423                 }
    424         }
    425 #endif
    426         return 0;
    427 
    428 }
    429 
    430333static int conexant_init(struct hda_codec *codec)
    431334{
     
    440343static void conexant_free(struct hda_codec *codec)
    441344{
    442 #ifdef CONFIG_SND_JACK
    443         struct conexant_spec *spec = codec->spec;
    444         if (spec->jacks.list) {
    445                 struct conexant_jack *jacks = spec->jacks.list;
    446                 int i;
    447                 for (i = 0; i < spec->jacks.used; i++)
    448                         snd_device_free(codec->bus->card, &jacks[i].jack);
    449                 snd_array_free(&spec->jacks);
    450         }
    451 #endif
    452345        kfree(codec->spec);
    453346}
     
    16351528static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
    16361529static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
     1530#define CXT5051_SPDIF_OUT       0x1C
     1531#define CXT5051_PORTB_EVENT     0x38
     1532#define CXT5051_PORTC_EVENT     0x39
    16371533
    16381534static struct hda_channel_mode cxt5051_modes[1] = {
     
    17141610                                   unsigned int res)
    17151611{
    1716         int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
    17171612        switch (res >> 26) {
    17181613        case CONEXANT_HP_EVENT:
     
    17261621                break;
    17271622        }
    1728         conexant_report_jack(codec, nid);
    17291623}
    17301624
     
    18011695{
    18021696        conexant_init(codec);
    1803         conexant_init_jacks(codec);
    18041697        if (codec->patch_ops.unsol_event) {
    18051698                cxt5051_hp_automute(codec);
     
    18791772 */
    18801773
    1881 static struct hda_codec_preset snd_hda_preset_conexant[] = {
     1774struct hda_codec_preset snd_hda_preset_conexant[] = {
    18821775        { .id = 0x14f15045, .name = "CX20549 (Venice)",
    18831776          .patch = patch_cxt5045 },
     
    18881781        {0} /* terminator */
    18891782};
    1890 
    1891 MODULE_ALIAS("snd-hda-codec-id:14f15045");
    1892 MODULE_ALIAS("snd-hda-codec-id:14f15047");
    1893 MODULE_ALIAS("snd-hda-codec-id:14f15051");
    1894 
    1895 MODULE_LICENSE("GPL");
    1896 MODULE_DESCRIPTION("Conexant HD-audio codec");
    1897 
    1898 static struct hda_codec_preset_list conexant_list = {
    1899         .preset = snd_hda_preset_conexant,
    1900         .owner = THIS_MODULE,
    1901 };
    1902 
    1903 static int __init patch_conexant_init(void)
    1904 {
    1905         return snd_hda_add_codec_preset(&conexant_list);
    1906 }
    1907 
    1908 static void __exit patch_conexant_exit(void)
    1909 {
    1910         snd_hda_delete_codec_preset(&conexant_list);
    1911 }
    1912 
    1913 module_init(patch_conexant_init)
    1914 module_exit(patch_conexant_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_realtek.c

    r410 r417  
    3131#include "hda_codec.h"
    3232#include "hda_local.h"
     33#include "hda_patch.h"
    3334
    3435#define ALC880_FRONT_EVENT              0x01
     
    216217        ALC883_ACER,
    217218        ALC883_ACER_ASPIRE,
    218         ALC888_ACER_ASPIRE_4930G,
    219219        ALC883_MEDION,
    220220        ALC883_MEDION_MD2,
     
    230230        ALC883_CLEVO_M720,
    231231        ALC883_FUJITSU_PI2515,
    232         ALC888_FUJITSU_XA3530,
    233232        ALC883_3ST_6ch_INTEL,
    234233        ALC888_ASUS_M90V,
    235234        ALC888_ASUS_EEE1601,
    236         ALC1200_ASUS_P5Q,
    237235        ALC883_AUTO,
    238236        ALC883_MODEL_LAST,
     
    384382        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    385383        struct alc_spec *spec = codec->spec;
    386         const struct hda_input_mux *imux;
     384        const struct hda_input_mux *imux = spec->input_mux;
    387385        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    388         unsigned int mux_idx;
    389386        hda_nid_t nid = spec->capsrc_nids ?
    390387                spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
    391 
    392         mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
    393         imux = &spec->input_mux[mux_idx];
    394388
    395389        if (spec->is_mix_capture) {
     
    413407        } else {
    414408                /* MUX style (e.g. ALC880) */
    415                 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
     409                unsigned int mux_idx;
     410                mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
     411                return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx],
     412                                             ucontrol, nid,
    416413                                             &spec->cur_mux[adc_idx]);
    417414        }
     
    765762        spec->init_verbs[spec->num_init_verbs++] = verb;
    766763}
    767 
    768 #ifdef CONFIG_PROC_FS
    769 /*
    770  * hook for proc
    771  */
    772 static void print_realtek_coef(struct snd_info_buffer *buffer,
    773                                struct hda_codec *codec, hda_nid_t nid)
    774 {
    775         int coeff;
    776 
    777         if (nid != 0x20)
    778                 return;
    779         coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
    780         snd_iprintf(buffer, "  Processing Coefficient: 0x%02x\n", coeff);
    781         coeff = snd_hda_codec_read(codec, nid, 0,
    782                                    AC_VERB_GET_COEF_INDEX, 0);
    783         snd_iprintf(buffer, "  Coefficient Index: 0x%02x\n", coeff);
    784 }
    785 #else
    786 #define print_realtek_coef      NULL
    787 #endif
    788764
    789765/*
     
    11781154
    11791155/*
    1180  * ALC888
    1181  */
    1182 
    1183 /*
    1184  * 2ch mode
    1185  */
    1186 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
    1187 /* Mic-in jack as mic in */
    1188         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    1189         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    1190 /* Line-in jack as Line in */
    1191         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
    1192         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    1193 /* Line-Out as Front */
    1194         { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
    1195         {0} /* end */
    1196 };
    1197 
    1198 /*
    1199  * 4ch mode
    1200  */
    1201 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
    1202 /* Mic-in jack as mic in */
    1203         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    1204         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    1205 /* Line-in jack as Surround */
    1206         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    1207         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    1208 /* Line-Out as Front */
    1209         { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
    1210         {0} /* end */
    1211 };
    1212 
    1213 /*
    1214  * 6ch mode
    1215  */
    1216 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
    1217 /* Mic-in jack as CLFE */
    1218         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    1219         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    1220 /* Line-in jack as Surround */
    1221         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    1222         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    1223 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
    1224         { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
    1225         {0} /* end */
    1226 };
    1227 
    1228 /*
    1229  * 8ch mode
    1230  */
    1231 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
    1232 /* Mic-in jack as CLFE */
    1233         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    1234         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    1235 /* Line-in jack as Surround */
    1236         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    1237         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    1238 /* Line-Out as Side */
    1239         { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
    1240         {0} /* end */
    1241 };
    1242 
    1243 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
    1244         { 2, alc888_4ST_ch2_intel_init },
    1245         { 4, alc888_4ST_ch4_intel_init },
    1246         { 6, alc888_4ST_ch6_intel_init },
    1247         { 8, alc888_4ST_ch8_intel_init },
    1248 };
    1249 
    1250 /*
    1251  * ALC888 Fujitsu Siemens Amillo xa3530
    1252  */
    1253 
    1254 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
    1255 /* Front Mic: set to PIN_IN (empty by default) */
    1256         {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1257 /* Connect Internal HP to Front */
    1258         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1259         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1260         {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
    1261 /* Connect Bass HP to Front */
    1262         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1263         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1264         {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
    1265 /* Connect Line-Out side jack (SPDIF) to Side */
    1266         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1267         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1268         {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
    1269 /* Connect Mic jack to CLFE */
    1270         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1271         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1272         {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
    1273 /* Connect Line-in jack to Surround */
    1274         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1275         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1276         {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
    1277 /* Connect HP out jack to Front */
    1278         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1279         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1280         {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
    1281 /* Enable unsolicited event for HP jack and Line-out jack */
    1282         {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
    1283         {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
    1284         {0}
    1285 };
    1286 
    1287 static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
    1288 {
    1289         unsigned int present;
    1290         unsigned int bits;
    1291         /* Line out presence */
    1292         present = snd_hda_codec_read(codec, 0x17, 0,
    1293                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1294         /* HP out presence */
    1295         present = present || snd_hda_codec_read(codec, 0x1b, 0,
    1296                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1297         bits = present ? HDA_AMP_MUTE : 0;
    1298         /* Toggle internal speakers muting */
    1299         snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
    1300                                  HDA_AMP_MUTE, bits);
    1301         /* Toggle internal bass muting */
    1302         snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
    1303                                  HDA_AMP_MUTE, bits);
    1304 }
    1305 
    1306 static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
    1307                 unsigned int res)
    1308 {
    1309         if (res >> 26 == ALC880_HP_EVENT)
    1310                 alc888_fujitsu_xa3530_automute(codec);
    1311 }
    1312 
    1313 
    1314 /*
    1315  * ALC888 Acer Aspire 4930G model
    1316  */
    1317 
    1318 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
    1319 /* Front Mic: set to PIN_IN (empty by default) */
    1320         {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    1321 /* Unselect Front Mic by default in input mixer 3 */
    1322         {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
    1323 /* Enable unsolicited event for HP jack */
    1324         {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
    1325 /* Connect Internal HP to front */
    1326         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1327         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1328         {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
    1329 /* Connect HP out to front */
    1330         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    1331         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    1332         {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
    1333         {0}
    1334 };
    1335 
    1336 static struct hda_input_mux alc888_2_capture_sources[2] = {
    1337         /* Front mic only available on one ADC */
    1338         {
    1339                 .num_items = 4,
    1340                 .items = {
    1341                         { "Mic", 0x0 },
    1342                         { "Line", 0x2 },
    1343                         { "CD", 0x4 },
    1344                         { "Front Mic", 0xb },
    1345                 },
    1346         },
    1347         {
    1348                 .num_items = 3,
    1349                 .items = {
    1350                         { "Mic", 0x0 },
    1351                         { "Line", 0x2 },
    1352                         { "CD", 0x4 },
    1353                 },
    1354         }
    1355 };
    1356 
    1357 static struct snd_kcontrol_new alc888_base_mixer[] = {
    1358         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    1359         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    1360         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    1361         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    1362         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
    1363                 HDA_OUTPUT),
    1364         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    1365         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
    1366         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    1367         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    1368         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    1369         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    1370         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    1371         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    1372         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    1373         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    1374         HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    1375         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    1376         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    1377         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    1378         {0} /* end */
    1379 };
    1380 
    1381 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
    1382 {
    1383         unsigned int present;
    1384         unsigned int bits;
    1385         present = snd_hda_codec_read(codec, 0x15, 0,
    1386                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1387         bits = present ? HDA_AMP_MUTE : 0;
    1388         snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
    1389                                  HDA_AMP_MUTE, bits);
    1390 }
    1391 
    1392 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
    1393                 unsigned int res)
    1394 {
    1395         if (res >> 26 == ALC880_HP_EVENT)
    1396                 alc888_acer_aspire_4930g_automute(codec);
    1397 }
    1398 
    1399 /*
    14001156 * ALC880 3-stack model
    14011157 *
     
    15021258        int err;
    15031259
    1504         mutex_lock(&codec->control_mutex);
     1260        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15051261        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
    15061262                                                      HDA_INPUT);
    15071263        err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
    1508         mutex_unlock(&codec->control_mutex);
     1264        mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15091265        return err;
    15101266}
     
    15171273        int err;
    15181274
    1519         mutex_lock(&codec->control_mutex);
     1275        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15201276        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
    15211277                                                      HDA_INPUT);
    15221278        err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
    1523         mutex_unlock(&codec->control_mutex);
     1279        mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15241280        return err;
    15251281}
     
    15371293        int err;
    15381294
    1539         mutex_lock(&codec->control_mutex);
     1295        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15401296        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
    15411297                                                      3, 0, HDA_INPUT);
    15421298        err = func(kcontrol, ucontrol);
    1543         mutex_unlock(&codec->control_mutex);
     1299        mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
    15441300        return err;
    15451301}
     
    42904046                alc_capture_mixer3,
    42914047        };
    4292         if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
     4048        if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
    42934049                spec->cap_mixer = caps[spec->num_adc_nids - 1];
    42944050}
     
    43654121                spec->loopback.amplist = alc880_loopbacks;
    43664122#endif
    4367         codec->proc_widget_hook = print_realtek_coef;
    43684123
    43694124        return 0;
     
    58915646                spec->loopback.amplist = alc260_loopbacks;
    58925647#endif
    5893         codec->proc_widget_hook = print_realtek_coef;
    58945648
    58955649        return 0;
     
    70976851                spec->loopback.amplist = alc882_loopbacks;
    70986852#endif
    7099         codec->proc_widget_hook = print_realtek_coef;
    71006853
    71016854        return 0;
     
    71166869#define ALC883_DIGIN_NID        0x0a
    71176870
    7118 #define ALC1200_DIGOUT_NID      0x10
    7119 
    71206871static hda_nid_t alc883_dac_nids[4] = {
    71216872        /* front, rear, clfe, rear_surr */
     
    71336884};
    71346885
    7135 static hda_nid_t alc883_adc_nids_rev[2] = {
    7136         /* ADC2-1 */
    7137         0x09, 0x08
    7138 };
    7139 
    71406886static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
    7141 
    7142 static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
    71436887
    71446888/* input MUX */
     
    84338177        [ALC883_ACER]           = "acer",
    84348178        [ALC883_ACER_ASPIRE]    = "acer-aspire",
    8435         [ALC888_ACER_ASPIRE_4930G]      = "acer-aspire-4930g",
    84368179        [ALC883_MEDION]         = "medion",
    84378180        [ALC883_MEDION_MD2]     = "medion-md2",
     
    84478190        [ALC883_CLEVO_M720]     = "clevo-m720",
    84488191        [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
    8449         [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
    84508192        [ALC883_3ST_6ch_INTEL]  = "3stack-6ch-intel",
    8451         [ALC1200_ASUS_P5Q]      = "asus-p5q",
    84528193        [ALC883_AUTO]           = "auto",
    84538194};
     
    84608201        SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
    84618202        SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
    8462         SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
    8463                 ALC888_ACER_ASPIRE_4930G),
    8464         SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
    8465                 ALC888_ACER_ASPIRE_4930G),
    8466         SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
    8467                 ALC888_ACER_ASPIRE_4930G),
    84688203        SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
    84698204        SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
     
    84728207        SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
    84738208        SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
    8474         SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
    84758209        SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
    84768210        SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
    8477         SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
    84788211        SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
    84798212        SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
    84808213        SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
    8481         SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
    84828214        SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
    84838215        SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
     
    85038235        SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
    85048236        SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
    8505         SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
    85068237        SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
    85078238        SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
     
    85158246        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
    85168247        SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
    8517         SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
    8518                 ALC888_FUJITSU_XA3530),
    85198248        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
    85208249        SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
     
    85288257        SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
    85298258        SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
    8530         SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
    8531         SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
    85328259        SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
    85338260        {0}
     
    86448371                .init_hook = alc883_acer_aspire_automute,
    86458372        },
    8646         [ALC888_ACER_ASPIRE_4930G] = {
    8647                 .mixers = { alc888_base_mixer,
    8648                                 alc883_chmode_mixer },
    8649                 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
    8650                                 alc888_acer_aspire_4930g_verbs },
    8651                 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    8652                 .dac_nids = alc883_dac_nids,
    8653                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
    8654                 .adc_nids = alc883_adc_nids_rev,
    8655                 .capsrc_nids = alc883_capsrc_nids_rev,
    8656                 .dig_out_nid = ALC883_DIGOUT_NID,
    8657                 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
    8658                 .channel_mode = alc883_3ST_6ch_modes,
    8659                 .need_dac_fix = 1,
    8660                 .num_mux_defs =
    8661                         ARRAY_SIZE(alc888_2_capture_sources),
    8662                 .input_mux = alc888_2_capture_sources,
    8663                 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
    8664                 .init_hook = alc888_acer_aspire_4930g_automute,
    8665         },
    86668373        [ALC883_MEDION] = {
    86678374                .mixers = { alc883_fivestack_mixer,
     
    88068513                .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
    88078514                .init_hook = alc883_2ch_fujitsu_pi2515_automute,
    8808         },
    8809         [ALC888_FUJITSU_XA3530] = {
    8810                 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
    8811                 .init_verbs = { alc883_init_verbs,
    8812                         alc888_fujitsu_xa3530_verbs },
    8813                 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    8814                 .dac_nids = alc883_dac_nids,
    8815                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
    8816                 .adc_nids = alc883_adc_nids_rev,
    8817                 .capsrc_nids = alc883_capsrc_nids_rev,
    8818                 .dig_out_nid = ALC883_DIGOUT_NID,
    8819                 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
    8820                 .channel_mode = alc888_4ST_8ch_intel_modes,
    8821                 .num_mux_defs =
    8822                         ARRAY_SIZE(alc888_2_capture_sources),
    8823                 .input_mux = alc888_2_capture_sources,
    8824                 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
    8825                 .init_hook = alc888_fujitsu_xa3530_automute,
    88268515        },
    88278516        [ALC888_LENOVO_SKY] = {
     
    88668555                .unsol_event = alc883_eee1601_unsol_event,
    88678556                .init_hook = alc883_eee1601_inithook,
    8868         },
    8869         [ALC1200_ASUS_P5Q] = {
    8870                 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
    8871                 .init_verbs = { alc883_init_verbs },
    8872                 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    8873                 .dac_nids = alc883_dac_nids,
    8874                 .dig_out_nid = ALC1200_DIGOUT_NID,
    8875                 .dig_in_nid = ALC883_DIGIN_NID,
    8876                 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
    8877                 .channel_mode = alc883_sixstack_modes,
    8878                 .input_mux = &alc883_capture_source,
    88798557        },
    88808558};
     
    90748752                spec->loopback.amplist = alc883_loopbacks;
    90758753#endif
    9076         codec->proc_widget_hook = print_realtek_coef;
    90778754
    90788755        return 0;
     
    1056710244        SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
    1056810245        SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
    10569         SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
    10570                       ALC262_SONY_ASSAMD),
    1057110246        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
    1057210247                      ALC262_TOSHIBA_RX1),
     
    1057610251        SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
    1057710252        SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
    10578         SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
    1057910253        SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
    1058010254        SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
     
    1088410558                spec->loopback.amplist = alc262_loopbacks;
    1088510559#endif
    10886         codec->proc_widget_hook = print_realtek_coef;
    1088710560
    1088810561        return 0;
     
    1169811371                                                ALC268_ACER_ASPIRE_ONE),
    1169911372        SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
    11700         SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
    1170111373        SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
    1170211374        SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
     
    1195011622        if (board_config == ALC268_AUTO)
    1195111623                spec->init_hook = alc268_auto_init;
    11952 
    11953         codec->proc_widget_hook = print_realtek_coef;
    1195411624
    1195511625        return 0;
     
    1275412424                spec->loopback.amplist = alc269_loopbacks;
    1275512425#endif
    12756         codec->proc_widget_hook = print_realtek_coef;
    1275712426
    1275812427        return 0;
     
    1384213511                spec->loopback.amplist = alc861_loopbacks;
    1384313512#endif
    13844         codec->proc_widget_hook = print_realtek_coef;
    1384513513
    1384613514        return 0;
     
    1480414472                spec->loopback.amplist = alc861vd_loopbacks;
    1480514473#endif
    14806         codec->proc_widget_hook = print_realtek_coef;
    1480714474
    1480814475        return 0;
     
    1661416281                spec->loopback.amplist = alc662_loopbacks;
    1661516282#endif
    16616         codec->proc_widget_hook = print_realtek_coef;
    1661716283
    1661816284        return 0;
     
    1662216288 * patch entries
    1662316289 */
    16624 static struct hda_codec_preset snd_hda_preset_realtek[] = {
     16290struct hda_codec_preset snd_hda_preset_realtek[] = {
    1662516291        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
    1662616292        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
     
    1664816314        { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
    1664916315        { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
     16316        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
    1665016317        { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
    1665116318          .patch = patch_alc883 },
    16652         { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
    1665316319        { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
    1665416320        {0} /* terminator */
    1665516321};
    16656 
    16657 MODULE_ALIAS("snd-hda-codec-id:10ec*");
    16658 
    16659 MODULE_LICENSE("GPL");
    16660 MODULE_DESCRIPTION("Realtek HD-audio codec");
    16661 
    16662 static struct hda_codec_preset_list realtek_list = {
    16663         .preset = snd_hda_preset_realtek,
    16664         .owner = THIS_MODULE,
    16665 };
    16666 
    16667 static int __init patch_realtek_init(void)
    16668 {
    16669         return snd_hda_add_codec_preset(&realtek_list);
    16670 }
    16671 
    16672 static void __exit patch_realtek_exit(void)
    16673 {
    16674         snd_hda_delete_codec_preset(&realtek_list);
    16675 }
    16676 
    16677 module_init(patch_realtek_init)
    16678 module_exit(patch_realtek_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_si3054.c

    r410 r417  
    2929#include "hda_codec.h"
    3030#include "hda_local.h"
     31#include "hda_patch.h"
    3132
    3233/* si3054 verbs */
     
    283284 * patch entries
    284285 */
    285 static struct hda_codec_preset snd_hda_preset_si3054[] = {
     286struct hda_codec_preset snd_hda_preset_si3054[] = {
    286287        { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 },
    287288        { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 },
     
    301302};
    302303
    303 MODULE_ALIAS("snd-hda-codec-id:163c3055");
    304 MODULE_ALIAS("snd-hda-codec-id:163c3155");
    305 MODULE_ALIAS("snd-hda-codec-id:11c13026");
    306 MODULE_ALIAS("snd-hda-codec-id:11c13055");
    307 MODULE_ALIAS("snd-hda-codec-id:11c13155");
    308 MODULE_ALIAS("snd-hda-codec-id:10573055");
    309 MODULE_ALIAS("snd-hda-codec-id:10573057");
    310 MODULE_ALIAS("snd-hda-codec-id:10573155");
    311 MODULE_ALIAS("snd-hda-codec-id:11063288");
    312 MODULE_ALIAS("snd-hda-codec-id:15433155");
    313 MODULE_ALIAS("snd-hda-codec-id:18540018");
    314 
    315 MODULE_LICENSE("GPL");
    316 MODULE_DESCRIPTION("Si3054 HD-audio modem codec");
    317 
    318 static struct hda_codec_preset_list si3054_list = {
    319         .preset = snd_hda_preset_si3054,
    320         .owner = THIS_MODULE,
    321 };
    322 
    323 static int __init patch_si3054_init(void)
    324 {
    325         return snd_hda_add_codec_preset(&si3054_list);
    326 }
    327 
    328 static void __exit patch_si3054_exit(void)
    329 {
    330         snd_hda_delete_codec_preset(&si3054_list);
    331 }
    332 
    333 module_init(patch_si3054_init)
    334 module_exit(patch_si3054_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_sigmatel.c

    r410 r417  
    3434#include "hda_codec.h"
    3535#include "hda_local.h"
     36#include "hda_patch.h"
    3637#include "hda_beep.h"
    3738
    38 enum {
    39         STAC_VREF_EVENT = 1,
    40         STAC_INSERT_EVENT,
    41         STAC_PWR_EVENT,
    42         STAC_HP_EVENT,
    43 };
     39#define STAC_INSERT_EVENT       0x10
     40#define STAC_PWR_EVENT          0x20
     41#define STAC_HP_EVENT           0x30
     42#define STAC_VREF_EVENT         0x40
    4443
    4544enum {
     
    5655        STAC_9200_DELL_M26,
    5756        STAC_9200_DELL_M27,
    58         STAC_9200_M4,
    59         STAC_9200_M4_2,
     57        STAC_9200_GATEWAY,
    6058        STAC_9200_PANASONIC,
    6159        STAC_9200_MODELS
     
    7169
    7270enum {
    73         STAC_92HD73XX_NO_JD, /* no jack-detection */
    7471        STAC_92HD73XX_REF,
    75         STAC_DELL_M6_AMIC,
    76         STAC_DELL_M6_DMIC,
    77         STAC_DELL_M6_BOTH,
     72        STAC_DELL_M6,
    7873        STAC_DELL_EQ,
    7974        STAC_92HD73XX_MODELS
     
    8984        STAC_DELL_M4_1,
    9085        STAC_DELL_M4_2,
    91         STAC_DELL_M4_3,
    9286        STAC_HP_M4,
    93         STAC_HP_DV5,
    9487        STAC_92HD71BXX_MODELS
    9588};
     
    9790enum {
    9891        STAC_925x_REF,
    99         STAC_M1,
    100         STAC_M1_2,
    101         STAC_M2,
    10292        STAC_M2_2,
    103         STAC_M3,
    104         STAC_M5,
    105         STAC_M6,
     93        STAC_MA6,
     94        STAC_PA6,
    10695        STAC_925x_MODELS
    10796};
     
    135124
    136125enum {
    137         STAC_D965_REF_NO_JD, /* no jack-detection */
    138126        STAC_D965_REF,
    139127        STAC_D965_3ST,
     
    146134struct sigmatel_event {
    147135        hda_nid_t nid;
    148         unsigned char type;
    149         unsigned char tag;
    150136        int data;
    151137};
     
    162148
    163149        int board_config;
    164         unsigned int eapd_switch: 1;
    165150        unsigned int surr_switch: 1;
     151        unsigned int line_switch: 1;
     152        unsigned int mic_switch: 1;
    166153        unsigned int alt_switch: 1;
    167154        unsigned int hp_detect: 1;
     
    200187        struct hda_multi_out multiout;
    201188        hda_nid_t dac_nids[5];
    202         hda_nid_t hp_dacs[5];
    203         hda_nid_t speaker_dacs[5];
    204189
    205190        /* capture */
     
    225210        unsigned int num_pins;
    226211        unsigned int *pin_configs;
     212        unsigned int *bios_pin_configs;
    227213
    228214        /* codec specific stuff */
     
    245231        unsigned int io_switch[2];
    246232        unsigned int clfe_swap;
    247         hda_nid_t line_switch;  /* shared line-in for input and output */
    248         hda_nid_t mic_switch;   /* shared mic-in for input and output */
    249         hda_nid_t hp_switch; /* NID of HP as line-out */
     233        unsigned int hp_switch;
    250234        unsigned int aloopback;
    251235
     
    298282
    299283#define STAC92HD73_DAC_COUNT 5
     284static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
     285        0x15, 0x16, 0x17, 0x18, 0x19,
     286};
    300287
    301288static hda_nid_t stac92hd73xx_mux_nids[4] = {
     
    316303};
    317304
     305#define STAC92HD81_DAC_COUNT 2
    318306#define STAC92HD83_DAC_COUNT 3
     307static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
     308        0x13, 0x14, 0x22,
     309};
    319310
    320311static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
     
    335326
    336327static unsigned int stac92hd83xxx_pwr_mapping[4] = {
    337         0x03, 0x0c, 0x20, 0x80,
    338 };
    339 
    340 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
    341         0xc,
     328        0x03, 0x0c, 0x10, 0x40,
    342329};
    343330
     
    360347static hda_nid_t stac92hd71bxx_smux_nids[2] = {
    361348        0x24, 0x25,
     349};
     350
     351static hda_nid_t stac92hd71bxx_dac_nids[1] = {
     352        0x10, /*0x11, */
    362353};
    363354
     
    593584                        nid = codec->slave_dig_outs[smux_idx - 1];
    594585                if (spec->cur_smux[smux_idx] == smux->num_items - 1)
    595                         val = HDA_AMP_MUTE;
     586                        val = AMP_OUT_MUTE;
    596587                else
    597                         val = 0;
     588                        val = AMP_OUT_UNMUTE;
    598589                /* un/mute SPDIF out */
    599                 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
    600                                          HDA_AMP_MUTE, val);
     590                snd_hda_codec_write_cache(codec, nid, 0,
     591                        AC_VERB_SET_AMP_GAIN_MUTE, val);
    601592        }
    602593        return 0;
     
    763754        /* set master volume and direct control */
    764755        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     756        /* setup audio connections */
     757        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
     758        { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
     759        { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
    765760        /* setup adcs to point to mixer */
    766761        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    781776         * and direct control */
    782777        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
     778        /* setup audio connections */
     779        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
     780        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
     781        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
    783782        /* setup adcs to point to mixer */
    784783        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    794793static struct hda_verb dell_m6_core_init[] = {
    795794        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     795        /* setup audio connections */
     796        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
     797        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
     798        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
    796799        /* setup adcs to point to mixer */
    797800        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    808811        /* set master volume and direct control */
    809812        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     813        /* setup audio connections */
     814        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
     815        { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
     816        { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
     817        /* connect hp ports to dac3 */
     818        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
     819        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
    810820        /* setup adcs to point to mixer */
    811821        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    825835        /* set master volume and direct control */
    826836        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     837        /* setup audio connections */
     838        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
     839        { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
     840        { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
    827841        /* dac3 is connected to import3 mux */
    828842        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
     843        /* connect hp ports to dac4 */
     844        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
     845        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
    829846        /* setup adcs to point to mixer */
    830847        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    852869        /* power state controls amps */
    853870        { 0x01, AC_VERB_SET_EAPD, 1 << 2},
    854         {0}
    855871};
    856872
     
    858874        /* set master volume and direct control */
    859875        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     876        /* connect headphone jack to dac1 */
     877        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
    860878        /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
    861879        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    862880        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    863881        { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    864         {0}
    865882};
    866883
     
    877894        /* set master volume and direct control */
    878895        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     896        /* connect headphone jack to dac1 */
     897        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
    879898        /* unmute right and left channels for nodes 0x0a, 0xd */
    880899        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     
    886905        /* set dac0mux for dac converter */
    887906        { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
    888         /* mute the master volume */
    889         { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    890907        {0}
    891908};
     
    10781095        HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
    10791096
    1080         HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
    1081         HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
    1082 
    1083         HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
    1084         HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
    1085 
    1086         HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
    1087         HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
    1088 
    1089         HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
    1090         HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
     1097        HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
     1098        HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
     1099
     1100        HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
     1101        HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
     1102
     1103        HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
     1104        HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
     1105
     1106        HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
     1107        HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
    10911108
    10921109        /*
    1093         HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
    1094         HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
     1110        HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
     1111        HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
    10951112        */
    10961113        {0} /* end */
     
    11391156
    11401157static struct snd_kcontrol_new stac925x_mixer[] = {
    1141         HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
    1142         HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
    11431158        STAC_INPUT_SOURCE(1),
    11441159        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
     
    12341249
    12351250static void stac92xx_free_kctls(struct hda_codec *codec);
    1236 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
    12371251
    12381252static int stac92xx_build_controls(struct hda_codec *codec)
    12391253{
    12401254        struct sigmatel_spec *spec = codec->spec;
    1241         struct auto_pin_cfg *cfg = &spec->autocfg;
    1242         hda_nid_t nid;
    12431255        int err;
    12441256        int i;
     
    12711283                }
    12721284                stac_smux_mixer.count = spec->num_smuxes;
    1273                 err = snd_hda_ctl_add(codec,
     1285                err = snd_ctl_add(codec->bus->card,
    12741286                                  snd_ctl_new1(&stac_smux_mixer, codec));
    12751287                if (err < 0)
     
    13111323
    13121324        stac92xx_free_kctls(codec); /* no longer needed */
    1313 
    1314         /* create jack input elements */
    1315         if (spec->hp_detect) {
    1316                 for (i = 0; i < cfg->hp_outs; i++) {
    1317                         int type = SND_JACK_HEADPHONE;
    1318                         nid = cfg->hp_pins[i];
    1319                         /* jack detection */
    1320                         if (cfg->hp_outs == i)
    1321                                 type |= SND_JACK_LINEOUT;
    1322                         err = stac92xx_add_jack(codec, nid, type);
    1323                         if (err < 0)
    1324                                 return err;
    1325                 }
    1326         }
    1327         for (i = 0; i < cfg->line_outs; i++) {
    1328                 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
    1329                                         SND_JACK_LINEOUT);
    1330                 if (err < 0)
    1331                         return err;
    1332         }
    1333         for (i = 0; i < AUTO_PIN_LAST; i++) {
    1334                 nid = cfg->input_pins[i];
    1335                 if (nid) {
    1336                         err = stac92xx_add_jack(codec, nid,
    1337                                                 SND_JACK_MICROPHONE);
    1338                         if (err < 0)
    1339                                 return err;
    1340                 }
    1341         }
    1342 
    13431325        return 0;       
    13441326}
     
    13491331};
    13501332
    1351 static unsigned int gateway9200_m4_pin_configs[8] = {
    1352         0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
    1353         0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
    1354 };
    1355 static unsigned int gateway9200_m4_2_pin_configs[8] = {
    1356         0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
    1357         0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
    1358 };
    1359 
    1360 /*
     1333/*
    13611334    STAC 9200 pin configs for
    13621335    102801A8
     
    14881461        [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
    14891462        [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
    1490         [STAC_9200_M4] = gateway9200_m4_pin_configs,
    1491         [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
    14921463        [STAC_9200_PANASONIC] = ref9200_pin_configs,
    14931464};
     
    15061477        [STAC_9200_DELL_M26] = "dell-m26",
    15071478        [STAC_9200_DELL_M27] = "dell-m27",
    1508         [STAC_9200_M4] = "gateway-m4",
    1509         [STAC_9200_M4_2] = "gateway-m4-2",
     1479        [STAC_9200_GATEWAY] = "gateway",
    15101480        [STAC_9200_PANASONIC] = "panasonic",
    15111481};
     
    15771547        SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
    15781548        /* Gateway machines needs EAPD to be set on resume */
    1579         SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
    1580         SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
    1581         SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
     1549        SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
     1550        SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
     1551                      STAC_9200_GATEWAY),
     1552        SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
     1553                      STAC_9200_GATEWAY),
    15821554        /* OQO Mobile */
    15831555        SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
     
    15901562};
    15911563
    1592 static unsigned int stac925xM1_pin_configs[8] = {
    1593         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1594         0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
    1595 };
    1596 
    1597 static unsigned int stac925xM1_2_pin_configs[8] = {
    1598         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1599         0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
    1600 };
    1601 
    1602 static unsigned int stac925xM2_pin_configs[8] = {
    1603         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1604         0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
     1564static unsigned int stac925x_MA6_pin_configs[8] = {
     1565        0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
     1566        0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
     1567};
     1568
     1569static unsigned int stac925x_PA6_pin_configs[8] = {
     1570        0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
     1571        0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
    16051572};
    16061573
    16071574static unsigned int stac925xM2_2_pin_configs[8] = {
    1608         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1609         0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
    1610 };
    1611 
    1612 static unsigned int stac925xM3_pin_configs[8] = {
    1613         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1614         0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
    1615 };
    1616 
    1617 static unsigned int stac925xM5_pin_configs[8] = {
    1618         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1619         0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
    1620 };
    1621 
    1622 static unsigned int stac925xM6_pin_configs[8] = {
    1623         0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
    1624         0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
     1575        0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
     1576        0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
    16251577};
    16261578
    16271579static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
    16281580        [STAC_REF] = ref925x_pin_configs,
    1629         [STAC_M1] = stac925xM1_pin_configs,
    1630         [STAC_M1_2] = stac925xM1_2_pin_configs,
    1631         [STAC_M2] = stac925xM2_pin_configs,
    16321581        [STAC_M2_2] = stac925xM2_2_pin_configs,
    1633         [STAC_M3] = stac925xM3_pin_configs,
    1634         [STAC_M5] = stac925xM5_pin_configs,
    1635         [STAC_M6] = stac925xM6_pin_configs,
     1582        [STAC_MA6] = stac925x_MA6_pin_configs,
     1583        [STAC_PA6] = stac925x_PA6_pin_configs,
    16361584};
    16371585
    16381586static const char *stac925x_models[STAC_925x_MODELS] = {
    16391587        [STAC_REF] = "ref",
    1640         [STAC_M1] = "m1",
    1641         [STAC_M1_2] = "m1-2",
    1642         [STAC_M2] = "m2",
    16431588        [STAC_M2_2] = "m2-2",
    1644         [STAC_M3] = "m3",
    1645         [STAC_M5] = "m5",
    1646         [STAC_M6] = "m6",
    1647 };
    1648 
    1649 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
    1650         SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
    1651         SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
    1652         SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
    1653         SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
    1654         SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
    1655         /* Not sure about the brand name for those */
    1656         SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
    1657         SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
    1658         SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
    1659         SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
    1660         {0} /* terminator */
     1589        [STAC_MA6] = "m6",
     1590        [STAC_PA6] = "pa6",
    16611591};
    16621592
     
    16651595        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
    16661596        SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
    1667 
    1668         /* Default table for unknown ID */
    1669         SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
    1670 
     1597        SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
     1598        SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
     1599        SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
     1600        SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
     1601        SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
    16711602        {0} /* terminator */
    16721603};
     
    16881619static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
    16891620        [STAC_92HD73XX_REF]     = ref92hd73xx_pin_configs,
    1690         [STAC_DELL_M6_AMIC]     = dell_m6_pin_configs,
    1691         [STAC_DELL_M6_DMIC]     = dell_m6_pin_configs,
    1692         [STAC_DELL_M6_BOTH]     = dell_m6_pin_configs,
     1621        [STAC_DELL_M6]  = dell_m6_pin_configs,
    16931622        [STAC_DELL_EQ]  = dell_m6_pin_configs,
    16941623};
    16951624
    16961625static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
    1697         [STAC_92HD73XX_NO_JD] = "no-jd",
    16981626        [STAC_92HD73XX_REF] = "ref",
    1699         [STAC_DELL_M6_AMIC] = "dell-m6-amic",
    1700         [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
    1701         [STAC_DELL_M6_BOTH] = "dell-m6",
     1627        [STAC_DELL_M6] = "dell-m6",
    17021628        [STAC_DELL_EQ] = "dell-eq",
    17031629};
     
    17081634                                "DFI LanParty", STAC_92HD73XX_REF),
    17091635        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
    1710                                 "Dell Studio 1535", STAC_DELL_M6_DMIC),
     1636                                "unknown Dell", STAC_DELL_M6),
    17111637        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
    1712                                 "unknown Dell", STAC_DELL_M6_DMIC),
     1638                                "unknown Dell", STAC_DELL_M6),
    17131639        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
    1714                                 "unknown Dell", STAC_DELL_M6_BOTH),
     1640                                "unknown Dell", STAC_DELL_M6),
    17151641        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
    1716                                 "unknown Dell", STAC_DELL_M6_BOTH),
     1642                                "unknown Dell", STAC_DELL_M6),
    17171643        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
    1718                                 "unknown Dell", STAC_DELL_M6_AMIC),
     1644                                "unknown Dell", STAC_DELL_M6),
    17191645        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
    1720                                 "unknown Dell", STAC_DELL_M6_AMIC),
     1646                                "unknown Dell", STAC_DELL_M6),
    17211647        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
    1722                                 "unknown Dell", STAC_DELL_M6_DMIC),
    1723         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
    1724                                 "unknown Dell", STAC_DELL_M6_DMIC),
    1725         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
    1726                                 "Dell Studio 1537", STAC_DELL_M6_DMIC),
    1727         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
    1728                                 "Dell Studio 17", STAC_DELL_M6_DMIC),
     1648                                "unknown Dell", STAC_DELL_M6),
    17291649        {0} /* terminator */
    17301650};
     
    17481668        /* SigmaTel reference board */
    17491669        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    1750                       "DFI LanParty", STAC_92HD83XXX_REF),
    1751         {0} /* terminator */
     1670                      "DFI LanParty", STAC_92HD71BXX_REF),
    17521671};
    17531672
     
    17701689};
    17711690
    1772 static unsigned int dell_m4_3_pin_configs[11] = {
    1773         0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
    1774         0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
    1775         0x40f000f0, 0x044413b0, 0x044413b0,
    1776 };
    1777 
    17781691static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
    17791692        [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
    17801693        [STAC_DELL_M4_1]        = dell_m4_1_pin_configs,
    17811694        [STAC_DELL_M4_2]        = dell_m4_2_pin_configs,
    1782         [STAC_DELL_M4_3]        = dell_m4_3_pin_configs,
    17831695        [STAC_HP_M4]            = NULL,
    1784         [STAC_HP_DV5]           = NULL,
    17851696};
    17861697
     
    17891700        [STAC_DELL_M4_1] = "dell-m4-1",
    17901701        [STAC_DELL_M4_2] = "dell-m4-2",
    1791         [STAC_DELL_M4_3] = "dell-m4-3",
    17921702        [STAC_HP_M4] = "hp-m4",
    1793         [STAC_HP_DV5] = "hp-dv5",
    17941703};
    17951704
     
    17981707        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    17991708                      "DFI LanParty", STAC_92HD71BXX_REF),
    1800         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
    1801                       "HP dv5", STAC_HP_M4),
    1802         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
    1803                       "HP dv7", STAC_HP_M4),
    1804         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
    1805                       "HP dv7", STAC_HP_M4),
    1806         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
    1807                       "HP dv5", STAC_HP_DV5),
    18081709        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
    18091710                                "unknown HP", STAC_HP_M4),
     
    18301731        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
    18311732                                "unknown Dell", STAC_DELL_M4_2),
    1832         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
    1833                                 "unknown Dell", STAC_DELL_M4_3),
    18341733        {0} /* terminator */
    18351734};
     
    21212020
    21222021static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
    2123         [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
    21242022        [STAC_D965_REF]  = ref927x_pin_configs,
    21252023        [STAC_D965_3ST]  = d965_3st_pin_configs,
     
    21302028
    21312029static const char *stac927x_models[STAC_927X_MODELS] = {
    2132         [STAC_D965_REF_NO_JD]   = "ref-no-jd",
    21332030        [STAC_D965_REF]         = "ref",
    21342031        [STAC_D965_3ST]         = "3stack",
     
    22892186        struct sigmatel_spec *spec = codec->spec;
    22902187       
    2291         kfree(spec->pin_configs);
    2292         spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
    2293                                     GFP_KERNEL);
    2294         if (!spec->pin_configs)
    2295                 return -ENOMEM;
     2188        if (! spec->bios_pin_configs) {
     2189                spec->bios_pin_configs = kcalloc(spec->num_pins,
     2190                                                 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
     2191                if (! spec->bios_pin_configs)
     2192                        return -ENOMEM;
     2193        }
    22962194       
    22972195        for (i = 0; i < spec->num_pins; i++) {
     
    23032201                snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
    23042202                                        nid, pin_cfg);
    2305                 spec->pin_configs[i] = pin_cfg;
     2203                spec->bios_pin_configs[i] = pin_cfg;
    23062204        }
    23072205       
     
    23452243}
    23462244
    2347 static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
    2348 {
    2349         struct sigmatel_spec *spec = codec->spec;
    2350 
    2351         if (!pins)
    2352                 return stac92xx_save_bios_config_regs(codec);
    2353 
    2354         kfree(spec->pin_configs);
    2355         spec->pin_configs = kmemdup(pins,
    2356                                     spec->num_pins * sizeof(*pins),
    2357                                     GFP_KERNEL);
    2358         if (!spec->pin_configs)
    2359                 return -ENOMEM;
    2360 
    2361         stac92xx_set_config_regs(codec);
    2362         return 0;
    2363 }
    2364 
    2365 static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
    2366                                    unsigned int cfg)
    2367 {
    2368         struct sigmatel_spec *spec = codec->spec;
    2369         int i;
    2370 
    2371         for (i = 0; i < spec->num_pins; i++) {
    2372                 if (spec->pin_nids[i] == nid) {
    2373                         spec->pin_configs[i] = cfg;
    2374                         stac92xx_set_config_reg(codec, nid, cfg);
    2375                         break;
    2376                 }
    2377         }
    2378 }
    2379 
    23802245/*
    23812246 * Analog playback callbacks
     
    24552320        if (spec->powerdown_adcs) {
    24562321                msleep(40);
    2457                 snd_hda_codec_write(codec, nid, 0,
     2322                snd_hda_codec_write_cache(codec, nid, 0,
    24582323                        AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
    24592324        }
     
    24712336        snd_hda_codec_cleanup_stream(codec, nid);
    24722337        if (spec->powerdown_adcs)
    2473                 snd_hda_codec_write(codec, nid, 0,
     2338                snd_hda_codec_write_cache(codec, nid, 0,
    24742339                        AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
    24752340        return 0;
     
    25992464        struct sigmatel_spec *spec = codec->spec;
    26002465
    2601         ucontrol->value.integer.value[0] = !!spec->hp_switch;
     2466        ucontrol->value.integer.value[0] = spec->hp_switch;
    26022467        return 0;
    26032468}
    2604 
    2605 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
    2606                                    unsigned char type);
    26072469
    26082470static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
     
    26112473        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    26122474        struct sigmatel_spec *spec = codec->spec;
    2613         int nid = kcontrol->private_value;
    2614  
    2615         spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
     2475        struct auto_pin_cfg *cfg = &spec->autocfg;
     2476        int nid = cfg->hp_pins[cfg->hp_outs - 1];
     2477
     2478        spec->hp_switch = ucontrol->value.integer.value[0];
    26162479
    26172480        /* check to be sure that the ports are upto date with
    26182481         * switch changes
    26192482         */
    2620         stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
     2483        codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
    26212484
    26222485        return 1;
     
    26582521         */
    26592522        if (spec->hp_detect)
    2660                 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
     2523                codec->patch_ops.unsol_event(codec,
     2524                        (STAC_HP_EVENT | nid) << 26);
    26612525
    26622526        return 1;
     
    27462610
    27472611/* add dynamic controls */
    2748 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
    2749                                      struct snd_kcontrol_new *ktemp,
    2750                                      int idx, const char *name,
    2751                                      unsigned long val)
     2612static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
     2613                int idx, const char *name, unsigned long val)
    27522614{
    27532615        struct snd_kcontrol_new *knew;
     
    27572619        if (!knew)
    27582620                return -ENOMEM;
    2759         *knew = *ktemp;
     2621        *knew = stac92xx_control_templates[type];
    27602622        knew->index = idx;
    27612623        knew->name = kstrdup(name, GFP_KERNEL);
    2762         if (!knew->name)
     2624        if (! knew->name)
    27632625                return -ENOMEM;
    27642626        knew->private_value = val;
     
    27662628}
    27672629
    2768 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
    2769                                            int type, int idx, const char *name,
    2770                                            unsigned long val)
    2771 {
    2772         return stac92xx_add_control_temp(spec,
    2773                                          &stac92xx_control_templates[type],
    2774                                          idx, name, val);
    2775 }
    2776 
    27772630
    27782631/* add dynamic controls */
    2779 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
    2780                                        const char *name, unsigned long val)
     2632static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
     2633                const char *name, unsigned long val)
    27812634{
    27822635        return stac92xx_add_control_idx(spec, type, 0, name, val);
    27832636}
    27842637
    2785 /* check whether the line-input can be used as line-out */
    2786 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
    2787 {
    2788         struct sigmatel_spec *spec = codec->spec;
    2789         struct auto_pin_cfg *cfg = &spec->autocfg;
    2790         hda_nid_t nid;
    2791         unsigned int pincap;
    2792 
    2793         if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
    2794                 return 0;
    2795         nid = cfg->input_pins[AUTO_PIN_LINE];
    2796         pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
    2797         if (pincap & AC_PINCAP_OUT)
    2798                 return nid;
     2638/* flag inputs as additional dynamic lineouts */
     2639static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
     2640{
     2641        struct sigmatel_spec *spec = codec->spec;
     2642        unsigned int wcaps, wtype;
     2643        int i, num_dacs = 0;
     2644       
     2645        /* use the wcaps cache to count all DACs available for line-outs */
     2646        for (i = 0; i < codec->num_nodes; i++) {
     2647                wcaps = codec->wcaps[i];
     2648                wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
     2649
     2650                if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
     2651                        num_dacs++;
     2652        }
     2653
     2654        snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
     2655       
     2656        switch (cfg->line_outs) {
     2657        case 3:
     2658                /* add line-in as side */
     2659                if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
     2660                        cfg->line_out_pins[cfg->line_outs] =
     2661                                cfg->input_pins[AUTO_PIN_LINE];
     2662                        spec->line_switch = 1;
     2663                        cfg->line_outs++;
     2664                }
     2665                break;
     2666        case 2:
     2667                /* add line-in as clfe and mic as side */
     2668                if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
     2669                        cfg->line_out_pins[cfg->line_outs] =
     2670                                cfg->input_pins[AUTO_PIN_LINE];
     2671                        spec->line_switch = 1;
     2672                        cfg->line_outs++;
     2673                }
     2674                if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
     2675                        cfg->line_out_pins[cfg->line_outs] =
     2676                                cfg->input_pins[AUTO_PIN_MIC];
     2677                        spec->mic_switch = 1;
     2678                        cfg->line_outs++;
     2679                }
     2680                break;
     2681        case 1:
     2682                /* add line-in as surr and mic as clfe */
     2683                if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
     2684                        cfg->line_out_pins[cfg->line_outs] =
     2685                                cfg->input_pins[AUTO_PIN_LINE];
     2686                        spec->line_switch = 1;
     2687                        cfg->line_outs++;
     2688                }
     2689                if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
     2690                        cfg->line_out_pins[cfg->line_outs] =
     2691                                cfg->input_pins[AUTO_PIN_MIC];
     2692                        spec->mic_switch = 1;
     2693                        cfg->line_outs++;
     2694                }
     2695                break;
     2696        }
     2697
    27992698        return 0;
    28002699}
    28012700
    2802 /* check whether the mic-input can be used as line-out */
    2803 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
    2804 {
    2805         struct sigmatel_spec *spec = codec->spec;
    2806         struct auto_pin_cfg *cfg = &spec->autocfg;
    2807         unsigned int def_conf, pincap;
    2808         unsigned int mic_pin;
    2809 
    2810         if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
    2811                 return 0;
    2812         mic_pin = AUTO_PIN_MIC;
    2813         for (;;) {
    2814                 hda_nid_t nid = cfg->input_pins[mic_pin];
    2815                 def_conf = snd_hda_codec_read(codec, nid, 0,
    2816                                               AC_VERB_GET_CONFIG_DEFAULT, 0);
    2817                 /* some laptops have an internal analog microphone
    2818                  * which can't be used as a output */
    2819                 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
    2820                         pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
    2821                         if (pincap & AC_PINCAP_OUT)
    2822                                 return nid;
    2823                 }
    2824                 if (mic_pin == AUTO_PIN_MIC)
    2825                         mic_pin = AUTO_PIN_FRONT_MIC;
    2826                 else
    2827                         break;
    2828         }
    2829         return 0;
    2830 }
    28312701
    28322702static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
     
    28412711        return 0;
    28422712}
    2843 
    2844 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
    2845 {
    2846         int i;
    2847         if (is_in_dac_nids(spec, nid))
    2848                 return 1;
    2849         for (i = 0; i < spec->autocfg.hp_outs; i++)
    2850                 if (spec->hp_dacs[i] == nid)
    2851                         return 1;
    2852         for (i = 0; i < spec->autocfg.speaker_outs; i++)
    2853                 if (spec->speaker_dacs[i] == nid)
    2854                         return 1;
    2855         return 0;
    2856 }
    2857 
    2858 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
    2859 {
    2860         struct sigmatel_spec *spec = codec->spec;
    2861         int j, conn_len;
    2862         hda_nid_t conn[HDA_MAX_CONNECTIONS];
    2863         unsigned int wcaps, wtype;
    2864 
    2865         conn_len = snd_hda_get_connections(codec, nid, conn,
    2866                                            HDA_MAX_CONNECTIONS);
    2867         for (j = 0; j < conn_len; j++) {
    2868                 wcaps = snd_hda_param_read(codec, conn[j],
    2869                                            AC_PAR_AUDIO_WIDGET_CAP);
    2870                 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
    2871                 /* we check only analog outputs */
    2872                 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
    2873                         continue;
    2874                 /* if this route has a free DAC, assign it */
    2875                 if (!check_all_dac_nids(spec, conn[j])) {
    2876                         if (conn_len > 1) {
    2877                                 /* select this DAC in the pin's input mux */
    2878                                 snd_hda_codec_write_cache(codec, nid, 0,
    2879                                                   AC_VERB_SET_CONNECT_SEL, j);
    2880                         }
    2881                         return conn[j];
    2882                 }
    2883         }
    2884         return 0;
    2885 }
    2886 
    2887 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
    2888 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
    28892713
    28902714/*
     
    28952719 * and 9202/925x. For those, dac_nids[] must be hard-coded.
    28962720 */
    2897 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
    2898 {
    2899         struct sigmatel_spec *spec = codec->spec;
    2900         struct auto_pin_cfg *cfg = &spec->autocfg;
    2901         int i;
    2902         hda_nid_t nid, dac;
     2721static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
     2722                                       struct auto_pin_cfg *cfg)
     2723{
     2724        struct sigmatel_spec *spec = codec->spec;
     2725        int i, j, conn_len = 0;
     2726        hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
     2727        unsigned int wcaps, wtype;
    29032728       
    29042729        for (i = 0; i < cfg->line_outs; i++) {
    29052730                nid = cfg->line_out_pins[i];
    2906                 dac = get_unassigned_dac(codec, nid);
    2907                 if (!dac) {
     2731                conn_len = snd_hda_get_connections(codec, nid, conn,
     2732                                                   HDA_MAX_CONNECTIONS);
     2733                for (j = 0; j < conn_len; j++) {
     2734                        wcaps = snd_hda_param_read(codec, conn[j],
     2735                                                   AC_PAR_AUDIO_WIDGET_CAP);
     2736                        wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
     2737                        if (wtype != AC_WID_AUD_OUT ||
     2738                            (wcaps & AC_WCAP_DIGITAL))
     2739                                continue;
     2740                        /* conn[j] is a DAC routed to this line-out */
     2741                        if (!is_in_dac_nids(spec, conn[j]))
     2742                                break;
     2743                }
     2744
     2745                if (j == conn_len) {
    29082746                        if (spec->multiout.num_dacs > 0) {
    29092747                                /* we have already working output pins,
     
    29192757                        return -ENODEV;
    29202758                }
    2921                 add_spec_dacs(spec, dac);
    2922         }
    2923 
    2924         /* add line-in as output */
    2925         nid = check_line_out_switch(codec);
    2926         if (nid) {
    2927                 dac = get_unassigned_dac(codec, nid);
    2928                 if (dac) {
    2929                         snd_printdd("STAC: Add line-in 0x%x as output %d\n",
    2930                                     nid, cfg->line_outs);
    2931                         cfg->line_out_pins[cfg->line_outs] = nid;
    2932                         cfg->line_outs++;
    2933                         spec->line_switch = nid;
    2934                         add_spec_dacs(spec, dac);
     2759
     2760                spec->multiout.dac_nids[i] = conn[j];
     2761                spec->multiout.num_dacs++;
     2762                if (conn_len > 1) {
     2763                        /* select this DAC in the pin's input mux */
     2764                        snd_hda_codec_write_cache(codec, nid, 0,
     2765                                                  AC_VERB_SET_CONNECT_SEL, j);
     2766
    29352767                }
    29362768        }
    2937         /* add mic as output */
    2938         nid = check_mic_out_switch(codec);
    2939         if (nid) {
    2940                 dac = get_unassigned_dac(codec, nid);
    2941                 if (dac) {
    2942                         snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
    2943                                     nid, cfg->line_outs);
    2944                         cfg->line_out_pins[cfg->line_outs] = nid;
    2945                         cfg->line_outs++;
    2946                         spec->mic_switch = nid;
    2947                         add_spec_dacs(spec, dac);
    2948                 }
    2949         }
    2950 
    2951         for (i = 0; i < cfg->hp_outs; i++) {
    2952                 nid = cfg->hp_pins[i];
    2953                 dac = get_unassigned_dac(codec, nid);
    2954                 if (dac) {
    2955                         if (!spec->multiout.hp_nid)
    2956                                 spec->multiout.hp_nid = dac;
    2957                         else
    2958                                 add_spec_extra_dacs(spec, dac);
    2959                 }
    2960                 spec->hp_dacs[i] = dac;
    2961         }
    2962 
    2963         for (i = 0; i < cfg->speaker_outs; i++) {
    2964                 nid = cfg->speaker_pins[i];
    2965                 dac = get_unassigned_dac(codec, nid);
    2966                 if (dac)
    2967                         add_spec_extra_dacs(spec, dac);
    2968                 spec->speaker_dacs[i] = dac;
    2969         }
    2970 
    2971         snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
     2769
     2770        snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
    29722771                   spec->multiout.num_dacs,
    29732772                   spec->multiout.dac_nids[0],
     
    29762775                   spec->multiout.dac_nids[3],
    29772776                   spec->multiout.dac_nids[4]);
    2978 
    29792777        return 0;
    29802778}
     
    30012799static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
    30022800{
    3003         if (spec->multiout.num_dacs > 4) {
     2801        if (!spec->multiout.hp_nid)
     2802                spec->multiout.hp_nid = nid;
     2803        else if (spec->multiout.num_dacs > 4) {
    30042804                printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
    30052805                return 1;
     
    30112811}
    30122812
    3013 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
    3014 {
    3015         int i;
    3016         for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
    3017                 if (!spec->multiout.extra_out_nid[i]) {
    3018                         spec->multiout.extra_out_nid[i] = nid;
    3019                         return 0;
    3020                 }
    3021         }
    3022         printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
    3023         return 1;
    3024 }
    3025 
    3026 static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
    3027 {
    3028         int i;
    3029 
    3030         if (spec->autocfg.line_outs != 1)
    3031                 return 0;
     2813static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
     2814{
     2815        if (is_in_dac_nids(spec, nid))
     2816                return 1;
    30322817        if (spec->multiout.hp_nid == nid)
    3033                 return 0;
    3034         for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
    3035                 if (spec->multiout.extra_out_nid[i] == nid)
    3036                         return 0;
    3037         return 1;
     2818                return 1;
     2819        return 0;
    30382820}
    30392821
     
    30422824                                               const struct auto_pin_cfg *cfg)
    30432825{
    3044         struct sigmatel_spec *spec = codec->spec;
    30452826        static const char *chname[4] = {
    30462827                "Front", "Surround", NULL /*CLFE*/, "Side"
     
    30482829        hda_nid_t nid = 0;
    30492830        int i, err;
    3050         unsigned int wid_caps;
    3051 
    3052         for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
     2831
     2832        struct sigmatel_spec *spec = codec->spec;
     2833        unsigned int wid_caps, pincap;
     2834
     2835
     2836        for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
     2837                if (!spec->multiout.dac_nids[i])
     2838                        continue;
     2839
    30532840                nid = spec->multiout.dac_nids[i];
     2841
    30542842                if (i == 2) {
    30552843                        /* Center/LFE */
     
    30732861
    30742862                } else {
    3075                         const char *name = chname[i];
    3076                         /* if it's a single DAC, assign a better name */
    3077                         if (!i && is_unique_dac(spec, nid)) {
    3078                                 switch (cfg->line_out_type) {
    3079                                 case AUTO_PIN_HP_OUT:
    3080                                         name = "Headphone";
    3081                                         break;
    3082                                 case AUTO_PIN_SPEAKER_OUT:
    3083                                         name = "Speaker";
    3084                                         break;
    3085                                 }
    3086                         }
    3087                         err = create_controls(spec, name, nid, 3);
     2863                        err = create_controls(spec, chname[i], nid, 3);
    30882864                        if (err < 0)
    30892865                                return err;
     
    30912867        }
    30922868
    3093         if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
     2869        if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
     2870                        cfg->hp_outs && !spec->multiout.hp_nid)
     2871                spec->multiout.hp_nid = nid;
     2872
     2873        if (cfg->hp_outs > 1) {
    30942874                err = stac92xx_add_control(spec,
    30952875                        STAC_CTL_WIDGET_HP_SWITCH,
    3096                         "Headphone as Line Out Switch",
    3097                         cfg->hp_pins[cfg->hp_outs - 1]);
     2876                        "Headphone as Line Out Switch", 0);
    30982877                if (err < 0)
    30992878                        return err;
     
    31012880
    31022881        if (spec->line_switch) {
    3103                 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
    3104                                            "Line In as Output Switch",
    3105                                            spec->line_switch << 8);
    3106                 if (err < 0)
    3107                         return err;
     2882                nid = cfg->input_pins[AUTO_PIN_LINE];
     2883                pincap = snd_hda_param_read(codec, nid,
     2884                                                AC_PAR_PIN_CAP);
     2885                if (pincap & AC_PINCAP_OUT) {
     2886                        err = stac92xx_add_control(spec,
     2887                                STAC_CTL_WIDGET_IO_SWITCH,
     2888                                "Line In as Output Switch", nid << 8);
     2889                        if (err < 0)
     2890                                return err;
     2891                }
    31082892        }
    31092893
    31102894        if (spec->mic_switch) {
    3111                 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
    3112                                            "Mic as Output Switch",
    3113                                            (spec->mic_switch << 8) | 1);
    3114                 if (err < 0)
    3115                         return err;
     2895                unsigned int def_conf;
     2896                unsigned int mic_pin = AUTO_PIN_MIC;
     2897again:
     2898                nid = cfg->input_pins[mic_pin];
     2899                def_conf = snd_hda_codec_read(codec, nid, 0,
     2900                                                AC_VERB_GET_CONFIG_DEFAULT, 0);
     2901                /* some laptops have an internal analog microphone
     2902                 * which can't be used as a output */
     2903                if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
     2904                        pincap = snd_hda_param_read(codec, nid,
     2905                                                        AC_PAR_PIN_CAP);
     2906                        if (pincap & AC_PINCAP_OUT) {
     2907                                err = stac92xx_add_control(spec,
     2908                                        STAC_CTL_WIDGET_IO_SWITCH,
     2909                                        "Mic as Output Switch", (nid << 8) | 1);
     2910                                nid = snd_hda_codec_read(codec, nid, 0,
     2911                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     2912                                if (!check_in_dac_nids(spec, nid))
     2913                                        add_spec_dacs(spec, nid);
     2914                                if (err < 0)
     2915                                        return err;
     2916                        }
     2917                } else if (mic_pin == AUTO_PIN_MIC) {
     2918                        mic_pin = AUTO_PIN_FRONT_MIC;
     2919                        goto again;
     2920                }
    31162921        }
    31172922
     
    31252930        struct sigmatel_spec *spec = codec->spec;
    31262931        hda_nid_t nid;
    3127         int i, err, nums;
    3128 
    3129         nums = 0;
     2932        int i, old_num_dacs, err;
     2933
     2934        old_num_dacs = spec->multiout.num_dacs;
    31302935        for (i = 0; i < cfg->hp_outs; i++) {
    3131                 static const char *pfxs[] = {
    3132                         "Headphone", "Headphone2", "Headphone3",
    3133                 };
    31342936                unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
    31352937                if (wid_caps & AC_WCAP_UNSOL_CAP)
    31362938                        spec->hp_detect = 1;
    3137                 if (nums >= ARRAY_SIZE(pfxs))
     2939                nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
     2940                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     2941                if (check_in_dac_nids(spec, nid))
     2942                        nid = 0;
     2943                if (! nid)
    31382944                        continue;
    3139                 nid = spec->hp_dacs[i];
    3140                 if (!nid)
     2945                add_spec_dacs(spec, nid);
     2946        }
     2947        for (i = 0; i < cfg->speaker_outs; i++) {
     2948                nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
     2949                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     2950                if (check_in_dac_nids(spec, nid))
     2951                        nid = 0;
     2952                if (! nid)
    31412953                        continue;
    3142                 err = create_controls(spec, pfxs[nums++], nid, 3);
    3143                 if (err < 0)
    3144                         return err;
    3145         }
    3146         nums = 0;
    3147         for (i = 0; i < cfg->speaker_outs; i++) {
     2954                add_spec_dacs(spec, nid);
     2955        }
     2956        for (i = 0; i < cfg->line_outs; i++) {
     2957                nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
     2958                                        AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     2959                if (check_in_dac_nids(spec, nid))
     2960                        nid = 0;
     2961                if (! nid)
     2962                        continue;
     2963                add_spec_dacs(spec, nid);
     2964        }
     2965        for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
    31482966                static const char *pfxs[] = {
    31492967                        "Speaker", "External Speaker", "Speaker2",
    31502968                };
    3151                 if (nums >= ARRAY_SIZE(pfxs))
    3152                         continue;
    3153                 nid = spec->speaker_dacs[i];
    3154                 if (!nid)
    3155                         continue;
    3156                 err = create_controls(spec, pfxs[nums++], nid, 3);
     2969                err = create_controls(spec, pfxs[i - old_num_dacs],
     2970                                      spec->multiout.dac_nids[i], 3);
    31572971                if (err < 0)
    31582972                        return err;
    31592973        }
     2974        if (spec->multiout.hp_nid) {
     2975                err = create_controls(spec, "Headphone",
     2976                                      spec->multiout.hp_nid, 3);
     2977                if (err < 0)
     2978                        return err;
     2979        }
     2980
    31602981        return 0;
    31612982}
     
    32503071        return 0;
    32513072}
    3252 
    3253 #ifdef CONFIG_SND_HDA_INPUT_BEEP
    3254 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
    3255 
    3256 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
    3257                                         struct snd_ctl_elem_value *ucontrol)
    3258 {
    3259         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    3260         ucontrol->value.integer.value[0] = codec->beep->enabled;
    3261         return 0;
    3262 }
    3263 
    3264 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
    3265                                         struct snd_ctl_elem_value *ucontrol)
    3266 {
    3267         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    3268         int enabled = !!ucontrol->value.integer.value[0];
    3269         if (codec->beep->enabled != enabled) {
    3270                 codec->beep->enabled = enabled;
    3271                 return 1;
    3272         }
    3273         return 0;
    3274 }
    3275 
    3276 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
    3277         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    3278         .info = stac92xx_dig_beep_switch_info,
    3279         .get = stac92xx_dig_beep_switch_get,
    3280         .put = stac92xx_dig_beep_switch_put,
    3281 };
    3282 
    3283 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
    3284 {
    3285         return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
    3286                                          0, "PC Beep Playback Switch", 0);
    3287 }
    3288 #endif
    32893073
    32903074static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
     
    34953279        struct sigmatel_spec *spec = codec->spec;
    34963280        int err;
     3281        int hp_speaker_swap = 0;
    34973282
    34983283        if ((err = snd_hda_parse_pin_def_config(codec,
     
    35123297                 * HP pins as primary outputs.
    35133298                 */
    3514                 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
    35153299                memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
    35163300                       sizeof(spec->autocfg.line_out_pins));
     
    35193303                       sizeof(spec->autocfg.hp_pins));
    35203304                spec->autocfg.line_outs = spec->autocfg.hp_outs;
    3521                 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
    3522                 spec->autocfg.hp_outs = 0;
     3305                hp_speaker_swap = 1;
    35233306        }
    35243307        if (spec->autocfg.mono_out_pin) {
     
    35723355        }
    35733356
    3574         if (!spec->multiout.num_dacs) {
    3575                 err = stac92xx_auto_fill_dac_nids(codec);
    3576                 if (err < 0)
     3357        if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
     3358                return err;
     3359        if (spec->multiout.num_dacs == 0)
     3360                if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
    35773361                        return err;
    3578                 err = stac92xx_auto_create_multi_out_ctls(codec,
    3579                                                           &spec->autocfg);
    3580                 if (err < 0)
    3581                         return err;
    3582         }
     3362
     3363        err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
     3364
     3365        if (err < 0)
     3366                return err;
    35833367
    35843368        /* setup analog beep controls */
     
    35943378        if (spec->digbeep_nid > 0) {
    35953379                hda_nid_t nid = spec->digbeep_nid;
    3596                 unsigned int caps;
    35973380
    35983381                err = stac92xx_auto_create_beep_ctls(codec, nid);
     
    36023385                if (err < 0)
    36033386                        return err;
    3604                 /* if no beep switch is available, make its own one */
    3605                 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
    3606                 if (codec->beep &&
    3607                     !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
    3608                         err = stac92xx_beep_switch_ctl(codec);
    3609                         if (err < 0)
    3610                                 return err;
    3611                 }
    36123387        }
    36133388#endif
     3389
     3390        if (hp_speaker_swap == 1) {
     3391                /* Restore the hp_outs and line_outs */
     3392                memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
     3393                       sizeof(spec->autocfg.line_out_pins));
     3394                spec->autocfg.hp_outs = spec->autocfg.line_outs;
     3395                memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
     3396                       sizeof(spec->autocfg.speaker_pins));
     3397                spec->autocfg.line_outs = spec->autocfg.speaker_outs;
     3398                memset(spec->autocfg.speaker_pins, 0,
     3399                       sizeof(spec->autocfg.speaker_pins));
     3400                spec->autocfg.speaker_outs = 0;
     3401        }
    36143402
    36153403        err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
     
    36613449
    36623450        spec->input_mux = &spec->private_imux;
    3663         if (!spec->dinput_mux)
    3664                 spec->dinput_mux = &spec->private_dimux;
     3451        spec->dinput_mux = &spec->private_dimux;
    36653452        spec->sinput_mux = &spec->private_smux;
    36663453        spec->mono_mux = &spec->private_mono_mux;
     
    37553542                return err;
    37563543
    3757         if (spec->num_muxes > 0) {
    3758                 err = stac92xx_auto_create_mux_input_ctls(codec);
    3759                 if (err < 0)
    3760                         return err;
    3761         }
    3762 
    37633544        if (spec->autocfg.dig_out_pin)
    37643545                spec->multiout.dig_out_nid = 0x05;
     
    38143595                hda_nid_t nid, int type)
    38153596{
    3816 #ifdef CONFIG_SND_JACK
    38173597        struct sigmatel_spec *spec = codec->spec;
    38183598        struct sigmatel_jack *jack;
     
    38383618
    38393619        return snd_jack_new(codec->bus->card, name, type, &jack->jack);
    3840 #else
    3841         return 0;
    3842 #endif
    3843 }
    3844 
    3845 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
    3846                           unsigned char type, int data)
     3620}
     3621
     3622static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
     3623                             int data)
    38473624{
    38483625        struct sigmatel_event *event;
     
    38533630                return -ENOMEM;
    38543631        event->nid = nid;
    3855         event->type = type;
    3856         event->tag = spec->events.used;
    38573632        event->data = data;
    38583633
    3859         return event->tag;
    3860 }
    3861 
    3862 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
    3863                                              hda_nid_t nid, unsigned char type)
    3864 {
    3865         struct sigmatel_spec *spec = codec->spec;
    3866         struct sigmatel_event *event = spec->events.list;
    3867         int i;
    3868 
    3869         for (i = 0; i < spec->events.used; i++, event++) {
    3870                 if (event->nid == nid && event->type == type)
    3871                         return event;
    3872         }
    3873         return NULL;
    3874 }
    3875 
    3876 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
    3877                                                       unsigned char tag)
    3878 {
    3879         struct sigmatel_spec *spec = codec->spec;
    3880         struct sigmatel_event *event = spec->events.list;
    3881         int i;
    3882 
    3883         for (i = 0; i < spec->events.used; i++, event++) {
    3884                 if (event->tag == tag)
    3885                         return event;
    3886         }
    3887         return NULL;
     3634        return 0;
     3635}
     3636
     3637static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
     3638{
     3639        struct sigmatel_spec *spec = codec->spec;
     3640        struct sigmatel_event *events = spec->events.list;
     3641        if (events) {
     3642                int i;
     3643                for (i = 0; i < spec->events.used; i++)
     3644                        if (events[i].nid == nid)
     3645                                return events[i].data;
     3646        }
     3647        return 0;
    38883648}
    38893649
    38903650static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
    3891                               unsigned int type)
    3892 {
    3893         struct sigmatel_event *event;
    3894         int tag;
    3895 
    3896         if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
    3897                 return;
    3898         event = stac_get_event(codec, nid, type);
    3899         if (event)
    3900                 tag = event->tag;
    3901         else
    3902                 tag = stac_add_event(codec->spec, nid, type, 0);
    3903         if (tag < 0)
    3904                 return;
    3905         snd_hda_codec_write_cache(codec, nid, 0,
    3906                                   AC_VERB_SET_UNSOLICITED_ENABLE,
    3907                                   AC_USRSP_EN | tag);
     3651                              unsigned int event)
     3652{
     3653        if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
     3654                snd_hda_codec_write_cache(codec, nid, 0,
     3655                                          AC_VERB_SET_UNSOLICITED_ENABLE,
     3656                                          (AC_USRSP_EN | event | nid));
     3657        }
    39083658}
    39093659
     
    39253675        hda_nid_t *dac;
    39263676        for (dac = spec->dac_list; *dac; dac++)
    3927                 if (!check_all_dac_nids(spec, *dac))
    3928                         snd_hda_codec_write(codec, *dac, 0,
     3677                if (!is_in_dac_nids(spec, *dac) &&
     3678                        spec->multiout.hp_nid != *dac)
     3679                        snd_hda_codec_write_cache(codec, *dac, 0,
    39293680                                        AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
    39303681}
    39313682
    3932 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
    3933                                   int enable);
    3934 
    39353683static int stac92xx_init(struct hda_codec *codec)
    39363684{
    39373685        struct sigmatel_spec *spec = codec->spec;
    39383686        struct auto_pin_cfg *cfg = &spec->autocfg;
    3939         unsigned int gpio;
    3940         int i;
     3687        int i, err;
    39413688
    39423689        snd_hda_sequence_write(codec, spec->init);
     
    39453692        if (spec->powerdown_adcs)
    39463693                for (i = 0; i < spec->num_adcs; i++)
    3947                         snd_hda_codec_write(codec,
     3694                        snd_hda_codec_write_cache(codec,
    39483695                                spec->adc_nids[i], 0,
    39493696                                AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
    3950 
    3951         /* set up GPIO */
    3952         gpio = spec->gpio_data;
    3953         /* turn on EAPD statically when spec->eapd_switch isn't set.
    3954          * otherwise, unsol event will turn it on/off dynamically
    3955          */
    3956         if (!spec->eapd_switch)
    3957                 gpio |= spec->eapd_mask;
    3958         stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
    3959 
    39603697        /* set up pins */
    39613698        if (spec->hp_detect) {
    39623699                /* Enable unsolicited responses on the HP widget */
    39633700                for (i = 0; i < cfg->hp_outs; i++) {
     3701                        int type = SND_JACK_HEADPHONE;
    39643702                        hda_nid_t nid = cfg->hp_pins[i];
    3965                         enable_pin_detect(codec, nid, STAC_HP_EVENT);
     3703                        enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
     3704                        /* jack detection */
     3705                        if (cfg->hp_outs == i)
     3706                                type |= SND_JACK_LINEOUT;
     3707                        err = stac92xx_add_jack(codec, nid, type);
     3708                        if (err < 0)
     3709                                return err;
     3710
    39663711                }
    39673712                /* force to enable the first line-out; the others are set up
     
    39713716                                AC_PINCTL_OUT_EN);
    39723717                /* fake event to set up pins */
    3973                 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
    3974                                        STAC_HP_EVENT);
     3718                codec->patch_ops.unsol_event(codec,
     3719                        (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
    39753720        } else {
    39763721                stac92xx_auto_init_multi_out(codec);
    39773722                stac92xx_auto_init_hp_out(codec);
    3978                 for (i = 0; i < cfg->hp_outs; i++)
    3979                         stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
     3723        }
     3724        for (i = 0; i < cfg->line_outs; i++) {
     3725                err = stac92xx_add_jack(codec,
     3726                                cfg->line_out_pins[i], SND_JACK_LINEOUT);
     3727                if (err < 0)
     3728                        return err;
    39803729        }
    39813730        for (i = 0; i < AUTO_PIN_LAST; i++) {
    39823731                hda_nid_t nid = cfg->input_pins[i];
    39833732                if (nid) {
    3984                         unsigned int pinctl, conf;
    3985                         if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
    3986                                 /* for mic pins, force to initialize */
    3987                                 pinctl = stac92xx_get_vref(codec, nid);
    3988                                 pinctl |= AC_PINCTL_IN_EN;
    3989                                 stac92xx_auto_set_pinctl(codec, nid, pinctl);
    3990                         } else {
    3991                                 pinctl = snd_hda_codec_read(codec, nid, 0,
    3992                                         AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    3993                                 /* if PINCTL already set then skip */
    3994                                 if (!(pinctl & AC_PINCTL_IN_EN)) {
    3995                                         pinctl |= AC_PINCTL_IN_EN;
    3996                                         stac92xx_auto_set_pinctl(codec, nid,
    3997                                                                  pinctl);
    3998                                 }
    3999                         }
    4000                         conf = snd_hda_codec_read(codec, nid, 0,
    4001                                               AC_VERB_GET_CONFIG_DEFAULT, 0);
    4002                         if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
    4003                                 enable_pin_detect(codec, nid,
    4004                                                   STAC_INSERT_EVENT);
    4005                                 stac_issue_unsol_event(codec, nid,
    4006                                                        STAC_INSERT_EVENT);
    4007                         }
     3733                        unsigned int pinctl = snd_hda_codec_read(codec, nid,
     3734                                0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     3735                        /* if PINCTL already set then skip */
     3736                        if (pinctl & AC_PINCAP_IN)
     3737                                continue;
     3738                        pinctl = AC_PINCTL_IN_EN;
     3739                        if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
     3740                                pinctl |= stac92xx_get_vref(codec, nid);
     3741                        stac92xx_auto_set_pinctl(codec, nid, pinctl);
     3742                        err = stac92xx_add_jack(codec, nid,
     3743                                SND_JACK_MICROPHONE);
     3744                        if (err < 0)
     3745                                return err;
     3746                        enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
    40083747                }
    40093748        }
     
    40113750                stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
    40123751                                        AC_PINCTL_IN_EN);
     3752        for (i = 0; i < spec->num_pwrs; i++)  {
     3753                int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
     3754                                        ? STAC_HP_EVENT : STAC_PWR_EVENT;
     3755                int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
     3756                                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     3757                int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
     3758                                        0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     3759                def_conf = get_defcfg_connect(def_conf);
     3760                /* outputs are only ports capable of power management
     3761                 * any attempts on powering down a input port cause the
     3762                 * referenced VREF to act quirky.
     3763                 */
     3764                if (pinctl & AC_PINCTL_IN_EN)
     3765                        continue;
     3766                /* skip any ports that don't have jacks since presence
     3767                 * detection is useless */
     3768                if (def_conf && def_conf != AC_JACK_PORT_FIXED)
     3769                        continue;
     3770                enable_pin_detect(codec, spec->pwr_nids[i], event | i);
     3771                codec->patch_ops.unsol_event(codec, (event | i) << 26);
     3772        }
     3773        if (spec->dac_list)
     3774                stac92xx_power_down(codec);
    40133775        if (cfg->dig_out_pin)
    40143776                stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
     
    40173779                stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
    40183780                                         AC_PINCTL_IN_EN);
    4019         for (i = 0; i < spec->num_pwrs; i++)  {
    4020                 hda_nid_t nid = spec->pwr_nids[i];
    4021                 int pinctl, def_conf;
    4022 
    4023                 /* power on when no jack detection is available */
    4024                 if (!spec->hp_detect) {
    4025                         stac_toggle_power_map(codec, nid, 1);
    4026                         continue;
    4027                 }
    4028 
    4029                 if (is_nid_hp_pin(cfg, nid))
    4030                         continue; /* already has an unsol event */
    4031 
    4032                 pinctl = snd_hda_codec_read(codec, nid, 0,
    4033                                             AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    4034                 /* outputs are only ports capable of power management
    4035                  * any attempts on powering down a input port cause the
    4036                  * referenced VREF to act quirky.
    4037                  */
    4038                 if (pinctl & AC_PINCTL_IN_EN) {
    4039                         stac_toggle_power_map(codec, nid, 1);
    4040                         continue;
    4041                 }
    4042                 def_conf = snd_hda_codec_read(codec, nid, 0,
    4043                                               AC_VERB_GET_CONFIG_DEFAULT, 0);
    4044                 def_conf = get_defcfg_connect(def_conf);
    4045                 /* skip any ports that don't have jacks since presence
    4046                  * detection is useless */
    4047                 if (def_conf != AC_JACK_PORT_COMPLEX) {
    4048                         if (def_conf != AC_JACK_PORT_NONE)
    4049                                 stac_toggle_power_map(codec, nid, 1);
    4050                         continue;
    4051                 }
    4052                 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
    4053                         enable_pin_detect(codec, nid, STAC_PWR_EVENT);
    4054                         stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
    4055                 }
    4056         }
    4057         if (spec->dac_list)
    4058                 stac92xx_power_down(codec);
     3781
     3782        stac_gpio_set(codec, spec->gpio_mask,
     3783                                        spec->gpio_dir, spec->gpio_data);
     3784
    40593785        return 0;
    40603786}
     
    40623788static void stac92xx_free_jacks(struct hda_codec *codec)
    40633789{
    4064 #ifdef CONFIG_SND_JACK
    4065         /* free jack instances manually when clearing/reconfiguring */
    4066         struct sigmatel_spec *spec = codec->spec;
    4067         if (!codec->bus->shutdown && spec->jacks.list) {
     3790        struct sigmatel_spec *spec = codec->spec;
     3791        if (spec->jacks.list) {
    40683792                struct sigmatel_jack *jacks = spec->jacks.list;
    40693793                int i;
     
    40723796        }
    40733797        snd_array_free(&spec->jacks);
    4074 #endif
    40753798}
    40763799
     
    40953818                return;
    40963819
    4097         kfree(spec->pin_configs);
     3820        if (spec->bios_pin_configs)
     3821                kfree(spec->bios_pin_configs);
    40983822        stac92xx_free_jacks(codec);
    40993823        snd_array_free(&spec->events);
     
    41163840                 */
    41173841                struct sigmatel_spec *spec = codec->spec;
    4118                 if (nid == spec->line_switch || nid == spec->mic_switch)
     3842                struct auto_pin_cfg *cfg = &spec->autocfg;
     3843                if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
     3844                     spec->line_switch) ||
     3845                    (nid == cfg->input_pins[AUTO_PIN_MIC] &&
     3846                     spec->mic_switch))
    41193847                        return;
    41203848        }
     
    41403868}
    41413869
    4142 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
     3870static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
    41433871{
    41443872        if (!nid)
    41453873                return 0;
    41463874        if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
    4147             & (1 << 31))
    4148                 return 1;
     3875            & (1 << 31)) {
     3876                unsigned int pinctl;
     3877                pinctl = snd_hda_codec_read(codec, nid, 0,
     3878                                            AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     3879                if (pinctl & AC_PINCTL_IN_EN)
     3880                        return 0; /* mic- or line-input */
     3881                else
     3882                        return 1; /* HP-output */
     3883        }
    41493884        return 0;
    41503885}
    41513886
    4152 /* return non-zero if the hp-pin of the given array index isn't
    4153  * a jack-detection target
    4154  */
    4155 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
    4156 {
     3887static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
     3888{
     3889        struct sigmatel_spec *spec = codec->spec;
    41573890        struct auto_pin_cfg *cfg = &spec->autocfg;
    4158 
    4159         /* ignore sensing of shared line and mic jacks */
    4160         if (cfg->hp_pins[i] == spec->line_switch)
    4161                 return 1;
    4162         if (cfg->hp_pins[i] == spec->mic_switch)
    4163                 return 1;
    4164         /* ignore if the pin is set as line-out */
    4165         if (cfg->hp_pins[i] == spec->hp_switch)
    4166                 return 1;
    4167         return 0;
    4168 }
    4169 
    4170 static void stac92xx_hp_detect(struct hda_codec *codec)
    4171 {
    4172         struct sigmatel_spec *spec = codec->spec;
    4173         struct auto_pin_cfg *cfg = &spec->autocfg;
     3891        int nid = cfg->hp_pins[cfg->hp_outs - 1];
    41743892        int i, presence;
    41753893
     
    41823900                if (presence)
    41833901                        break;
    4184                 if (no_hp_sensing(spec, i))
    4185                         continue;
    4186                 presence = get_pin_presence(codec, cfg->hp_pins[i]);
    4187                 if (presence) {
    4188                         unsigned int pinctl;
    4189                         pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
    4190                                             AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    4191                         if (pinctl & AC_PINCTL_IN_EN)
    4192                                 presence = 0; /* mic- or line-input */
    4193                 }
     3902                if (spec->hp_switch && cfg->hp_pins[i] == nid)
     3903                        break;
     3904                presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
    41943905        }
    41953906
    41963907        if (presence) {
    4197                 /* disable lineouts */
     3908                /* disable lineouts, enable hp */
    41983909                if (spec->hp_switch)
    4199                         stac92xx_reset_pinctl(codec, spec->hp_switch,
    4200                                               AC_PINCTL_OUT_EN);
     3910                        stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    42013911                for (i = 0; i < cfg->line_outs; i++)
    42023912                        stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
     
    42053915                        stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
    42063916                                                AC_PINCTL_OUT_EN);
    4207                 if (spec->eapd_mask && spec->eapd_switch)
     3917                if (spec->eapd_mask)
    42083918                        stac_gpio_set(codec, spec->gpio_mask,
    42093919                                spec->gpio_dir, spec->gpio_data &
    42103920                                ~spec->eapd_mask);
    42113921        } else {
    4212                 /* enable lineouts */
     3922                /* enable lineouts, disable hp */
    42133923                if (spec->hp_switch)
    4214                         stac92xx_set_pinctl(codec, spec->hp_switch,
    4215                                             AC_PINCTL_OUT_EN);
     3924                        stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    42163925                for (i = 0; i < cfg->line_outs; i++)
    42173926                        stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
     
    42203929                        stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
    42213930                                                AC_PINCTL_OUT_EN);
    4222                 if (spec->eapd_mask && spec->eapd_switch)
     3931                if (spec->eapd_mask)
    42233932                        stac_gpio_set(codec, spec->gpio_mask,
    42243933                                spec->gpio_dir, spec->gpio_data |
    42253934                                spec->eapd_mask);
    42263935        }
    4227         /* toggle hp outs */
    4228         for (i = 0; i < cfg->hp_outs; i++) {
    4229                 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
    4230                 if (no_hp_sensing(spec, i))
    4231                         continue;
    4232                 if (presence)
    4233                         stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
    4234 #if 0 /* FIXME */
    4235 /* Resetting the pinctl like below may lead to (a sort of) regressions
    4236  * on some devices since they use the HP pin actually for line/speaker
    4237  * outs although the default pin config shows a different pin (that is
    4238  * wrong and useless).
    4239  *
    4240  * So, it's basically a problem of default pin configs, likely a BIOS issue.
    4241  * But, disabling the code below just works around it, and I'm too tired of
    4242  * bug reports with such devices...
    4243  */
    4244                 else
    4245                         stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
    4246 #endif /* FIXME */
    4247         }
     3936        if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
     3937                stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    42483938}
    42493939
    4250 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
    4251                                   int enable)
    4252 {
    4253         struct sigmatel_spec *spec = codec->spec;
    4254         unsigned int idx, val;
    4255 
    4256         for (idx = 0; idx < spec->num_pwrs; idx++) {
    4257                 if (spec->pwr_nids[idx] == nid)
    4258                         break;
    4259         }
    4260         if (idx >= spec->num_pwrs)
    4261                 return;
     3940static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
     3941{
     3942        struct sigmatel_spec *spec = codec->spec;
     3943        hda_nid_t nid = spec->pwr_nids[idx];
     3944        int presence, val;
     3945        val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
     3946                                                        & 0x000000ff;
     3947        presence = get_hp_pin_presence(codec, nid);
    42623948
    42633949        /* several codecs have two power down bits */
     
    42673953                idx = 1 << idx;
    42683954
    4269         val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
    4270         if (enable)
     3955        if (presence)
    42713956                val &= ~idx;
    42723957        else
     
    42753960        /* power down unused output ports */
    42763961        snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
    4277 }
    4278 
    4279 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
    4280 {
    4281         stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
    42823962}
    42833963
     
    43013981                                        ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
    43023982                                snd_jack_report(jacks->jack,
    4303                                         get_pin_presence(codec, nid)
     3983                                        get_hp_pin_presence(codec, nid)
    43043984                                        ? type : 0);
    43053985                        }
     
    43093989}
    43103990
    4311 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
    4312                                    unsigned char type)
    4313 {
    4314         struct sigmatel_event *event = stac_get_event(codec, nid, type);
    4315         if (!event)
    4316                 return;
    4317         codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
    4318 }
    4319 
    43203991static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
    43213992{
    43223993        struct sigmatel_spec *spec = codec->spec;
    4323         struct sigmatel_event *event;
    4324         int tag, data;
    4325 
    4326         tag = (res >> 26) & 0x7f;
    4327         event = stac_get_event_from_tag(codec, tag);
    4328         if (!event)
    4329                 return;
    4330 
    4331         switch (event->type) {
     3994        int event = (res >> 26) & 0x70;
     3995        int nid = res >> 26 & 0x0f;
     3996
     3997        switch (event) {
    43323998        case STAC_HP_EVENT:
    4333                 stac92xx_hp_detect(codec);
     3999                stac92xx_hp_detect(codec, res);
    43344000                /* fallthru */
    43354001        case STAC_INSERT_EVENT:
    43364002        case STAC_PWR_EVENT:
    4337                 if (spec->num_pwrs > 0)
    4338                         stac92xx_pin_sense(codec, event->nid);
    4339                 stac92xx_report_jack(codec, event->nid);
     4003                if (nid) {
     4004                        if (spec->num_pwrs > 0)
     4005                                stac92xx_pin_sense(codec, nid);
     4006                        stac92xx_report_jack(codec, nid);
     4007                }
    43404008                break;
    4341         case STAC_VREF_EVENT:
    4342                 data = snd_hda_codec_read(codec, codec->afg, 0,
    4343                                           AC_VERB_GET_GPIO_DATA, 0);
     4009        case STAC_VREF_EVENT: {
     4010                int data = snd_hda_codec_read(codec, codec->afg, 0,
     4011                        AC_VERB_GET_GPIO_DATA, 0);
     4012                int idx = stac92xx_event_data(codec, nid);
    43444013                /* toggle VREF state based on GPIOx status */
    43454014                snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
    4346                                     !!(data & (1 << event->data)));
     4015                        !!(data & (1 << idx)));
    43474016                break;
    4348         }
    4349 }
    4350 
    4351 #ifdef CONFIG_PROC_FS
    4352 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
    4353                                struct hda_codec *codec, hda_nid_t nid)
    4354 {
    4355         if (nid == codec->afg)
    4356                 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
    4357                             snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
    4358 }
    4359 
    4360 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
    4361                                   struct hda_codec *codec,
    4362                                   unsigned int verb)
    4363 {
    4364         snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
    4365                     snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
    4366 }
    4367 
    4368 /* stac92hd71bxx, stac92hd73xx */
    4369 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
    4370                                  struct hda_codec *codec, hda_nid_t nid)
    4371 {
    4372         stac92hd_proc_hook(buffer, codec, nid);
    4373         if (nid == codec->afg)
    4374                 analog_loop_proc_hook(buffer, codec, 0xfa0);
    4375 }
    4376 
    4377 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
    4378                                struct hda_codec *codec, hda_nid_t nid)
    4379 {
    4380         if (nid == codec->afg)
    4381                 analog_loop_proc_hook(buffer, codec, 0xfe0);
    4382 }
    4383 
    4384 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
    4385                                struct hda_codec *codec, hda_nid_t nid)
    4386 {
    4387         if (nid == codec->afg)
    4388                 analog_loop_proc_hook(buffer, codec, 0xfeb);
    4389 }
    4390 #else
    4391 #define stac92hd_proc_hook      NULL
    4392 #define stac92hd7x_proc_hook    NULL
    4393 #define stac9205_proc_hook      NULL
    4394 #define stac927x_proc_hook      NULL
    4395 #endif
     4017                }
     4018        }
     4019}
    43964020
    43974021#ifdef SND_HDA_NEEDS_RESUME
     
    44014025
    44024026        stac92xx_set_config_regs(codec);
    4403         stac92xx_init(codec);
     4027        snd_hda_sequence_write(codec, spec->init);
     4028        stac_gpio_set(codec, spec->gpio_mask,
     4029                spec->gpio_dir, spec->gpio_data);
    44044030        snd_hda_codec_resume_amp(codec);
    44054031        snd_hda_codec_resume_cache(codec);
    4406         /* fake event to set up pins again to override cached values */
     4032        /* power down inactive DACs */
     4033        if (spec->dac_list)
     4034                stac92xx_power_down(codec);
     4035        /* invoke unsolicited event to reset the HP state */
    44074036        if (spec->hp_detect)
    4408                 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
    4409                                        STAC_HP_EVENT);
    4410         return 0;
    4411 }
    4412 
    4413 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
    4414 {
    4415         struct sigmatel_spec *spec = codec->spec;
    4416         if (spec->eapd_mask)
    4417                 stac_gpio_set(codec, spec->gpio_mask,
    4418                                 spec->gpio_dir, spec->gpio_data &
    4419                                 ~spec->eapd_mask);
     4037                codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
    44204038        return 0;
    44214039}
     
    44294047        .unsol_event = stac92xx_unsol_event,
    44304048#ifdef SND_HDA_NEEDS_RESUME
    4431         .suspend = stac92xx_suspend,
    44324049        .resume = stac92xx_resume,
    44334050#endif
     
    44524069                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
    44534070                err = stac92xx_save_bios_config_regs(codec);
    4454         } else
    4455                 err = stac_save_pin_cfgs(codec,
    4456                                          stac9200_brd_tbl[spec->board_config]);
    4457         if (err < 0) {
    4458                 stac92xx_free(codec);
    4459                 return err;
     4071                if (err < 0) {
     4072                        stac92xx_free(codec);
     4073                        return err;
     4074                }
     4075                spec->pin_configs = spec->bios_pin_configs;
     4076        } else {
     4077                spec->pin_configs = stac9200_brd_tbl[spec->board_config];
     4078                stac92xx_set_config_regs(codec);
    44604079        }
    44614080
     
    44704089        spec->num_pwrs = 0;
    44714090
    4472         if (spec->board_config == STAC_9200_M4 ||
    4473             spec->board_config == STAC_9200_M4_2 ||
     4091        if (spec->board_config == STAC_9200_GATEWAY ||
    44744092            spec->board_config == STAC_9200_OQO)
    44754093                spec->init = stac9200_eapd_init;
     
    44894107        }
    44904108
    4491         /* CF-74 has no headphone detection, and the driver should *NOT*
    4492          * do detection and HP/speaker toggle because the hardware does it.
    4493          */
    4494         if (spec->board_config == STAC_9200_PANASONIC)
    4495                 spec->hp_detect = 0;
    4496 
    44974109        codec->patch_ops = stac92xx_patch_ops;
    44984110
     
    45124124        spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
    45134125        spec->pin_nids = stac925x_pin_nids;
    4514 
    4515         /* Check first for codec ID */
    4516         spec->board_config = snd_hda_check_board_codec_sid_config(codec,
    4517                                                         STAC_925x_MODELS,
    4518                                                         stac925x_models,
    4519                                                         stac925x_codec_id_cfg_tbl);
    4520 
    4521         /* Now checks for PCI ID, if codec ID is not found */
    4522         if (spec->board_config < 0)
    4523                 spec->board_config = snd_hda_check_board_config(codec,
    4524                                                         STAC_925x_MODELS,
     4126        spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
    45254127                                                        stac925x_models,
    45264128                                                        stac925x_cfg_tbl);
    45274129 again:
    45284130        if (spec->board_config < 0) {
    4529                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
     4131                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 
    45304132                                      "using BIOS defaults\n");
    45314133                err = stac92xx_save_bios_config_regs(codec);
    4532         } else
    4533                 err = stac_save_pin_cfgs(codec,
    4534                                          stac925x_brd_tbl[spec->board_config]);
    4535         if (err < 0) {
    4536                 stac92xx_free(codec);
    4537                 return err;
     4134                if (err < 0) {
     4135                        stac92xx_free(codec);
     4136                        return err;
     4137                }
     4138                spec->pin_configs = spec->bios_pin_configs;
     4139        } else if (stac925x_brd_tbl[spec->board_config] != NULL){
     4140                spec->pin_configs = stac925x_brd_tbl[spec->board_config];
     4141                stac92xx_set_config_regs(codec);
    45384142        }
    45394143
     
    45994203        hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
    46004204        int err = 0;
    4601         int num_dacs;
    46024205
    46034206        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    46184221                        " STAC92HD73XX, using BIOS defaults\n");
    46194222                err = stac92xx_save_bios_config_regs(codec);
    4620         } else
    4621                 err = stac_save_pin_cfgs(codec,
    4622                                 stac92hd73xx_brd_tbl[spec->board_config]);
    4623         if (err < 0) {
    4624                 stac92xx_free(codec);
    4625                 return err;
    4626         }
    4627 
    4628         num_dacs = snd_hda_get_connections(codec, 0x0a,
     4223                if (err < 0) {
     4224                        stac92xx_free(codec);
     4225                        return err;
     4226                }
     4227                spec->pin_configs = spec->bios_pin_configs;
     4228        } else {
     4229                spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
     4230                stac92xx_set_config_regs(codec);
     4231        }
     4232
     4233        spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
    46294234                        conn, STAC92HD73_DAC_COUNT + 2) - 1;
    46304235
    4631         if (num_dacs < 3 || num_dacs > 5) {
     4236        if (spec->multiout.num_dacs < 0) {
    46324237                printk(KERN_WARNING "hda_codec: Could not determine "
    46334238                       "number of channels defaulting to DAC count\n");
    4634                 num_dacs = STAC92HD73_DAC_COUNT;
    4635         }
    4636         switch (num_dacs) {
     4239                spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
     4240        }
     4241
     4242        switch (spec->multiout.num_dacs) {
    46374243        case 0x3: /* 6 Channel */
    46384244                spec->mixer = stac92hd73xx_6ch_mixer;
     
    46464252                spec->mixer = stac92hd73xx_10ch_mixer;
    46474253                spec->init = stac92hd73xx_10ch_core_init;
    4648         }
    4649         spec->multiout.dac_nids = spec->dac_nids;
    4650 
     4254        };
     4255
     4256        spec->multiout.dac_nids = stac92hd73xx_dac_nids;
    46514257        spec->aloopback_mask = 0x01;
    46524258        spec->aloopback_shift = 8;
     
    46714277                spec->init = dell_eq_core_init;
    46724278                /* fallthru */
    4673         case STAC_DELL_M6_AMIC:
    4674         case STAC_DELL_M6_DMIC:
    4675         case STAC_DELL_M6_BOTH:
     4279        case STAC_DELL_M6:
    46764280                spec->num_smuxes = 0;
    46774281                spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
    46784282                spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
    4679                 spec->eapd_switch = 0;
    46804283                spec->num_amps = 1;
    46814284
    4682                 if (spec->board_config != STAC_DELL_EQ)
     4285                if (!spec->init)
    46834286                        spec->init = dell_m6_core_init;
    4684                 switch (spec->board_config) {
    4685                 case STAC_DELL_M6_AMIC: /* Analog Mics */
     4287                switch (codec->subsystem_id) {
     4288                case 0x1028025e: /* Analog Mics */
     4289                case 0x1028025f:
    46864290                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
    46874291                        spec->num_dmics = 0;
    46884292                        spec->private_dimux.num_items = 1;
    46894293                        break;
    4690                 case STAC_DELL_M6_DMIC: /* Digital Mics */
     4294                case 0x10280271: /* Digital Mics */
     4295                case 0x10280272:
     4296                case 0x10280254:
     4297                case 0x10280255:
    46914298                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
    46924299                        spec->num_dmics = 1;
    46934300                        spec->private_dimux.num_items = 2;
    46944301                        break;
    4695                 case STAC_DELL_M6_BOTH: /* Both */
     4302                case 0x10280256: /* Both */
     4303                case 0x10280057:
    46964304                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
    46974305                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
     
    47044312                spec->num_dmics = STAC92HD73XX_NUM_DMICS;
    47054313                spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
    4706                 spec->eapd_switch = 1;
    47074314        }
    47084315        if (spec->board_config > STAC_92HD73XX_REF) {
     
    47334340        }
    47344341
    4735         if (spec->board_config == STAC_92HD73XX_NO_JD)
    4736                 spec->hp_detect = 0;
    4737 
    47384342        codec->patch_ops = stac92xx_patch_ops;
    4739 
    4740         codec->proc_widget_hook = stac92hd7x_proc_hook;
    47414343
    47424344        return 0;
     
    47694371        spec->adc_nids = stac92hd83xxx_adc_nids;
    47704372        spec->pwr_nids = stac92hd83xxx_pwr_nids;
    4771         spec->amp_nids = stac92hd83xxx_amp_nids;
    47724373        spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
    47734374        spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
    4774         spec->multiout.dac_nids = spec->dac_nids;
     4375        spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
    47754376
    47764377        spec->init = stac92hd83xxx_core_init;
    47774378        switch (codec->vendor_id) {
    47784379        case 0x111d7605:
     4380                spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
    47794381                break;
    47804382        default:
    47814383                spec->num_pwrs--;
    47824384                spec->init++; /* switch to config #2 */
     4385                spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
    47834386        }
    47844387
     
    47874390        spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
    47884391        spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
    4789         spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
    47904392        spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
    47914393        spec->dinput_mux = &stac92hd83xxx_dmux;
     
    48004402                        " STAC92HD83XXX, using BIOS defaults\n");
    48014403                err = stac92xx_save_bios_config_regs(codec);
    4802         } else
    4803                 err = stac_save_pin_cfgs(codec,
    4804                                 stac92hd83xxx_brd_tbl[spec->board_config]);
    4805         if (err < 0) {
    4806                 stac92xx_free(codec);
    4807                 return err;
     4404                if (err < 0) {
     4405                        stac92xx_free(codec);
     4406                        return err;
     4407                }
     4408                spec->pin_configs = spec->bios_pin_configs;
     4409        } else {
     4410                spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
     4411                stac92xx_set_config_regs(codec);
    48084412        }
    48094413
     
    48264430        codec->patch_ops = stac92xx_patch_ops;
    48274431
    4828         codec->proc_widget_hook = stac92hd_proc_hook;
    4829 
    48304432        return 0;
    48314433}
     4434
     4435#ifdef SND_HDA_NEEDS_RESUME
     4436static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
     4437{
     4438        struct sigmatel_spec *spec = codec->spec;
     4439        int i;
     4440        snd_hda_codec_write_cache(codec, codec->afg, 0,
     4441                AC_VERB_SET_POWER_STATE, pwr);
     4442
     4443        msleep(1);
     4444        for (i = 0; i < spec->num_adcs; i++) {
     4445                snd_hda_codec_write_cache(codec,
     4446                        spec->adc_nids[i], 0,
     4447                        AC_VERB_SET_POWER_STATE, pwr);
     4448        }
     4449};
     4450
     4451static int stac92hd71xx_resume(struct hda_codec *codec)
     4452{
     4453        stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
     4454        return stac92xx_resume(codec);
     4455}
     4456
     4457static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
     4458{
     4459        stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
     4460        return 0;
     4461};
     4462
     4463#endif
     4464
     4465static struct hda_codec_ops stac92hd71bxx_patch_ops = {
     4466        .build_controls = stac92xx_build_controls,
     4467        .build_pcms = stac92xx_build_pcms,
     4468        .init = stac92xx_init,
     4469        .free = stac92xx_free,
     4470        .unsol_event = stac92xx_unsol_event,
     4471#ifdef SND_HDA_NEEDS_RESUME
     4472        .resume = stac92hd71xx_resume,
     4473        .suspend = stac92hd71xx_suspend,
     4474#endif
     4475};
    48324476
    48334477static struct hda_input_mux stac92hd71bxx_dmux = {
     
    48664510                        " STAC92HD71BXX, using BIOS defaults\n");
    48674511                err = stac92xx_save_bios_config_regs(codec);
    4868         } else
    4869                 err = stac_save_pin_cfgs(codec,
    4870                                 stac92hd71bxx_brd_tbl[spec->board_config]);
    4871         if (err < 0) {
    4872                 stac92xx_free(codec);
    4873                 return err;
    4874         }
    4875 
    4876         if (spec->board_config > STAC_92HD71BXX_REF) {
    4877                 /* GPIO0 = EAPD */
    4878                 spec->gpio_mask = 0x01;
    4879                 spec->gpio_dir = 0x01;
    4880                 spec->gpio_data = 0x01;
     4512                if (err < 0) {
     4513                        stac92xx_free(codec);
     4514                        return err;
     4515                }
     4516                spec->pin_configs = spec->bios_pin_configs;
     4517        } else {
     4518                spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
     4519                stac92xx_set_config_regs(codec);
    48814520        }
    48824521
     
    48914530                break;
    48924531        case 0x111d7608: /* 5 Port with Analog Mixer */
    4893                 switch (spec->board_config) {
    4894                 case STAC_HP_M4:
     4532                switch (codec->subsystem_id) {
     4533                case 0x103c361a:
    48954534                        /* Enable VREF power saving on GPIO1 detect */
    4896                         err = stac_add_event(spec, codec->afg,
    4897                                              STAC_VREF_EVENT, 0x02);
    4898                         if (err < 0)
    4899                                 return err;
    4900                         snd_hda_codec_write_cache(codec, codec->afg, 0,
     4535                        snd_hda_codec_write(codec, codec->afg, 0,
    49014536                                AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
    49024537                        snd_hda_codec_write_cache(codec, codec->afg, 0,
    49034538                                AC_VERB_SET_UNSOLICITED_ENABLE,
    4904                                 AC_USRSP_EN | err);
     4539                                (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
     4540                        err = stac92xx_add_event(spec, codec->afg, 0x02);
     4541                        if (err < 0)
     4542                                return err;
    49054543                        spec->gpio_mask |= 0x02;
    49064544                        break;
    49074545                }
    49084546                if ((codec->revision_id & 0xf) == 0 ||
    4909                     (codec->revision_id & 0xf) == 1)
     4547                                (codec->revision_id & 0xf) == 1) {
     4548#ifdef SND_HDA_NEEDS_RESUME
     4549                        codec->patch_ops = stac92hd71bxx_patch_ops;
     4550#endif
    49104551                        spec->stream_delay = 40; /* 40 milliseconds */
     4552                }
    49114553
    49124554                /* no output amps */
     
    49174559                /* disable VSW */
    49184560                spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
    4919                 stac_change_pin_config(codec, 0xf, 0x40f000f0);
     4561                stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
    49204562                break;
    49214563        case 0x111d7603: /* 6 Port with Analog Mixer */
    4922                 if ((codec->revision_id & 0xf) == 1)
     4564                if ((codec->revision_id & 0xf) == 1) {
     4565#ifdef SND_HDA_NEEDS_RESUME
     4566                        codec->patch_ops = stac92hd71bxx_patch_ops;
     4567#endif
    49234568                        spec->stream_delay = 40; /* 40 milliseconds */
     4569                }
    49244570
    49254571                /* no output amps */
     
    49364582        spec->aloopback_shift = 0;
    49374583
     4584        if (spec->board_config > STAC_92HD71BXX_REF) {
     4585                /* GPIO0 = EAPD */
     4586                spec->gpio_mask = 0x01;
     4587                spec->gpio_dir = 0x01;
     4588                spec->gpio_data = 0x01;
     4589        }
     4590
    49384591        spec->powerdown_adcs = 1;
    49394592        spec->digbeep_nid = 0x26;
     
    49504603        switch (spec->board_config) {
    49514604        case STAC_HP_M4:
    4952                 /* enable internal microphone */
    4953                 stac_change_pin_config(codec, 0x0e, 0x01813040);
    4954                 stac92xx_auto_set_pinctl(codec, 0x0e,
    4955                         AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
    4956                 /* fallthru */
    4957         case STAC_DELL_M4_2:
    49584605                spec->num_dmics = 0;
    49594606                spec->num_smuxes = 0;
    49604607                spec->num_dmuxes = 0;
    4961                 break;
    4962         case STAC_DELL_M4_1:
    4963         case STAC_DELL_M4_3:
    4964                 spec->num_dmics = 1;
    4965                 spec->num_smuxes = 0;
    4966                 spec->num_dmuxes = 0;
     4608
     4609                /* enable internal microphone */
     4610                stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
     4611                stac92xx_auto_set_pinctl(codec, 0x0e,
     4612                        AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
    49674613                break;
    49684614        default:
     
    49724618        };
    49734619
    4974         spec->multiout.dac_nids = spec->dac_nids;
     4620        spec->multiout.num_dacs = 1;
     4621        spec->multiout.hp_nid = 0x11;
     4622        spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
    49754623        if (spec->dinput_mux)
    49764624                spec->private_dimux.num_items +=
     
    49934641                return err;
    49944642        }
    4995 
    4996         codec->proc_widget_hook = stac92hd7x_proc_hook;
    49974643
    49984644        return 0;
     
    50574703                        "using BIOS defaults\n");
    50584704                err = stac92xx_save_bios_config_regs(codec);
    5059         } else
    5060                 err = stac_save_pin_cfgs(codec,
    5061                                 stac922x_brd_tbl[spec->board_config]);
    5062         if (err < 0) {
    5063                 stac92xx_free(codec);
    5064                 return err;
     4705                if (err < 0) {
     4706                        stac92xx_free(codec);
     4707                        return err;
     4708                }
     4709                spec->pin_configs = spec->bios_pin_configs;
     4710        } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
     4711                spec->pin_configs = stac922x_brd_tbl[spec->board_config];
     4712                stac92xx_set_config_regs(codec);
    50654713        }
    50664714
     
    51254773                                    "STAC927x, using BIOS defaults\n");
    51264774                err = stac92xx_save_bios_config_regs(codec);
    5127         } else
    5128                 err = stac_save_pin_cfgs(codec,
    5129                                 stac927x_brd_tbl[spec->board_config]);
    5130         if (err < 0) {
    5131                 stac92xx_free(codec);
    5132                 return err;
     4775                if (err < 0) {
     4776                        stac92xx_free(codec);
     4777                        return err;
     4778                }
     4779                spec->pin_configs = spec->bios_pin_configs;
     4780        } else {
     4781                spec->pin_configs = stac927x_brd_tbl[spec->board_config];
     4782                stac92xx_set_config_regs(codec);
    51334783        }
    51344784
     
    51604810                case 0x1028022e:
    51614811                        /* correct the device field to SPDIF out */
    5162                         stac_change_pin_config(codec, 0x21, 0x01442070);
     4812                        stac92xx_set_config_reg(codec, 0x21, 0x01442070);
    51634813                        break;
    51644814                };
    51654815                /* configure the analog microphone on some laptops */
    5166                 stac_change_pin_config(codec, 0x0c, 0x90a79130);
     4816                stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
    51674817                /* correct the front output jack as a hp out */
    5168                 stac_change_pin_config(codec, 0x0f, 0x0227011f);
     4818                stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
    51694819                /* correct the front input jack as a mic */
    5170                 stac_change_pin_config(codec, 0x0e, 0x02a79130);
     4820                stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
    51714821                /* fallthru */
    51724822        case STAC_DELL_3ST:
     
    51974847        spec->aloopback_mask = 0x40;
    51984848        spec->aloopback_shift = 0;
    5199         spec->eapd_switch = 1;
    52004849
    52014850        err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
     
    52154864
    52164865        codec->patch_ops = stac92xx_patch_ops;
    5217 
    5218         codec->proc_widget_hook = stac927x_proc_hook;
    52194866
    52204867        /*
     
    52304877        codec->bus->needs_damn_long_delay = 1;
    52314878
    5232         /* no jack detecion for ref-no-jd model */
    5233         if (spec->board_config == STAC_D965_REF_NO_JD)
    5234                 spec->hp_detect = 0;
    5235 
    52364879        return 0;
    52374880}
     
    52564899                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
    52574900                err = stac92xx_save_bios_config_regs(codec);
    5258         } else
    5259                 err = stac_save_pin_cfgs(codec,
    5260                                          stac9205_brd_tbl[spec->board_config]);
    5261         if (err < 0) {
    5262                 stac92xx_free(codec);
    5263                 return err;
     4901                if (err < 0) {
     4902                        stac92xx_free(codec);
     4903                        return err;
     4904                }
     4905                spec->pin_configs = spec->bios_pin_configs;
     4906        } else {
     4907                spec->pin_configs = stac9205_brd_tbl[spec->board_config];
     4908                stac92xx_set_config_regs(codec);
    52644909        }
    52654910
     
    52824927        spec->aloopback_mask = 0x40;
    52834928        spec->aloopback_shift = 0;
    5284         spec->eapd_switch = 1;
    52854929        spec->multiout.dac_nids = spec->dac_nids;
    52864930       
     
    52884932        case STAC_9205_DELL_M43:
    52894933                /* Enable SPDIF in/out */
    5290                 stac_change_pin_config(codec, 0x1f, 0x01441030);
    5291                 stac_change_pin_config(codec, 0x20, 0x1c410030);
     4934                stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
     4935                stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
    52924936
    52934937                /* Enable unsol response for GPIO4/Dock HP connection */
    5294                 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
     4938                snd_hda_codec_write(codec, codec->afg, 0,
     4939                        AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
     4940                snd_hda_codec_write_cache(codec, codec->afg, 0,
     4941                        AC_VERB_SET_UNSOLICITED_ENABLE,
     4942                        (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
     4943                err = stac92xx_add_event(spec, codec->afg, 0x01);
    52954944                if (err < 0)
    52964945                        return err;
    5297                 snd_hda_codec_write_cache(codec, codec->afg, 0,
    5298                         AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
    5299                 snd_hda_codec_write_cache(codec, codec->afg, 0,
    5300                                           AC_VERB_SET_UNSOLICITED_ENABLE,
    5301                                           AC_USRSP_EN | err);
    53024946
    53034947                spec->gpio_dir = 0x0b;
     
    53374981        codec->patch_ops = stac92xx_patch_ops;
    53384982
    5339         codec->proc_widget_hook = stac9205_proc_hook;
    5340 
    53414983        return 0;
    53424984}
     
    53955037};
    53965038
     5039/* bind volumes of both NID 0x02 and 0x05 */
     5040static struct hda_bind_ctls vaio_bind_master_vol = {
     5041        .ops = &snd_hda_bind_vol,
     5042        .values = {
     5043                HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
     5044                HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
     5045                0
     5046        },
     5047};
     5048
     5049/* bind volumes of both NID 0x02 and 0x05 */
     5050static struct hda_bind_ctls vaio_bind_master_sw = {
     5051        .ops = &snd_hda_bind_sw,
     5052        .values = {
     5053                HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
     5054                HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
     5055                0,
     5056        },
     5057};
     5058
    53975059static struct snd_kcontrol_new vaio_mixer[] = {
    5398         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
    5399         HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
    5400         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
    5401         HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
     5060        HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
     5061        HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
    54025062        /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
    54035063        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
     
    54155075
    54165076static struct snd_kcontrol_new vaio_ar_mixer[] = {
    5417         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
    5418         HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
    5419         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
    5420         HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
     5077        HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
     5078        HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
    54215079        /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
    54225080        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
     
    54595117static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
    54605118{
    5461         if (get_pin_presence(codec, 0x0a)) {
     5119        if (get_hp_pin_presence(codec, 0x0a)) {
    54625120                stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
    54635121                stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
     
    55705228 * patch entries
    55715229 */
    5572 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
     5230struct hda_codec_preset snd_hda_preset_sigmatel[] = {
    55735231        { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
    55745232        { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
     
    56345292        {0} /* terminator */
    56355293};
    5636 
    5637 MODULE_ALIAS("snd-hda-codec-id:8384*");
    5638 MODULE_ALIAS("snd-hda-codec-id:111d*");
    5639 
    5640 MODULE_LICENSE("GPL");
    5641 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
    5642 
    5643 static struct hda_codec_preset_list sigmatel_list = {
    5644         .preset = snd_hda_preset_sigmatel,
    5645         .owner = THIS_MODULE,
    5646 };
    5647 
    5648 static int __init patch_sigmatel_init(void)
    5649 {
    5650         return snd_hda_add_codec_preset(&sigmatel_list);
    5651 }
    5652 
    5653 static void __exit patch_sigmatel_exit(void)
    5654 {
    5655         snd_hda_delete_codec_preset(&sigmatel_list);
    5656 }
    5657 
    5658 module_init(patch_sigmatel_init)
    5659 module_exit(patch_sigmatel_exit)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_via.c

    r410 r417  
    4848#include "hda_codec.h"
    4949#include "hda_local.h"
     50#include "hda_patch.h"
    5051
    5152/* amp values */
     
    141142        AUTO_SEQ_SIDE
    142143};
     144
     145#define get_amp_nid(kc) ((kc)->private_value & 0xffff)
    143146
    144147/* Some VT1708S based boards gets the micboost setting wrong, so we have
     
    32503253 * patch entries
    32513254 */
    3252 static struct hda_codec_preset snd_hda_preset_via[] = {
    3253         { .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708},
    3254         { .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708},
    3255         { .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708},
    3256         { .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708},
    3257         { .id = 0x1106e710, .name = "VT1709 10-Ch",
     3255struct hda_codec_preset snd_hda_preset_via[] = {
     3256        { .id = 0x11061708, .name = "VIA VT1708", .patch = patch_vt1708},
     3257        { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708},
     3258        { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708},
     3259        { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708},
     3260        { .id = 0x1106E710, .name = "VIA VT1709 10-Ch",
    32583261          .patch = patch_vt1709_10ch},
    3259         { .id = 0x1106e711, .name = "VT1709 10-Ch",
     3262        { .id = 0x1106E711, .name = "VIA VT1709 10-Ch",
    32603263          .patch = patch_vt1709_10ch},
    3261         { .id = 0x1106e712, .name = "VT1709 10-Ch",
     3264        { .id = 0x1106E712, .name = "VIA VT1709 10-Ch",
    32623265          .patch = patch_vt1709_10ch},
    3263         { .id = 0x1106e713, .name = "VT1709 10-Ch",
     3266        { .id = 0x1106E713, .name = "VIA VT1709 10-Ch",
    32643267          .patch = patch_vt1709_10ch},
    3265         { .id = 0x1106e714, .name = "VT1709 6-Ch",
     3268        { .id = 0x1106E714, .name = "VIA VT1709 6-Ch",
    32663269          .patch = patch_vt1709_6ch},
    3267         { .id = 0x1106e715, .name = "VT1709 6-Ch",
     3270        { .id = 0x1106E715, .name = "VIA VT1709 6-Ch",
    32683271          .patch = patch_vt1709_6ch},
    3269         { .id = 0x1106e716, .name = "VT1709 6-Ch",
     3272        { .id = 0x1106E716, .name = "VIA VT1709 6-Ch",
    32703273          .patch = patch_vt1709_6ch},
    3271         { .id = 0x1106e717, .name = "VT1709 6-Ch",
     3274        { .id = 0x1106E717, .name = "VIA VT1709 6-Ch",
    32723275          .patch = patch_vt1709_6ch},
    3273         { .id = 0x1106e720, .name = "VT1708B 8-Ch",
     3276        { .id = 0x1106E720, .name = "VIA VT1708B 8-Ch",
    32743277          .patch = patch_vt1708B_8ch},
    3275         { .id = 0x1106e721, .name = "VT1708B 8-Ch",
     3278        { .id = 0x1106E721, .name = "VIA VT1708B 8-Ch",
    32763279          .patch = patch_vt1708B_8ch},
    3277         { .id = 0x1106e722, .name = "VT1708B 8-Ch",
     3280        { .id = 0x1106E722, .name = "VIA VT1708B 8-Ch",
    32783281          .patch = patch_vt1708B_8ch},
    3279         { .id = 0x1106e723, .name = "VT1708B 8-Ch",
     3282        { .id = 0x1106E723, .name = "VIA VT1708B 8-Ch",
    32803283          .patch = patch_vt1708B_8ch},
    3281         { .id = 0x1106e724, .name = "VT1708B 4-Ch",
     3284        { .id = 0x1106E724, .name = "VIA VT1708B 4-Ch",
    32823285          .patch = patch_vt1708B_4ch},
    3283         { .id = 0x1106e725, .name = "VT1708B 4-Ch",
     3286        { .id = 0x1106E725, .name = "VIA VT1708B 4-Ch",
    32843287          .patch = patch_vt1708B_4ch},
    3285         { .id = 0x1106e726, .name = "VT1708B 4-Ch",
     3288        { .id = 0x1106E726, .name = "VIA VT1708B 4-Ch",
    32863289          .patch = patch_vt1708B_4ch},
    3287         { .id = 0x1106e727, .name = "VT1708B 4-Ch",
     3290        { .id = 0x1106E727, .name = "VIA VT1708B 4-Ch",
    32883291          .patch = patch_vt1708B_4ch},
    3289         { .id = 0x11060397, .name = "VT1708S",
     3292        { .id = 0x11060397, .name = "VIA VT1708S",
    32903293          .patch = patch_vt1708S},
    3291         { .id = 0x11061397, .name = "VT1708S",
     3294        { .id = 0x11061397, .name = "VIA VT1708S",
    32923295          .patch = patch_vt1708S},
    3293         { .id = 0x11062397, .name = "VT1708S",
     3296        { .id = 0x11062397, .name = "VIA VT1708S",
    32943297          .patch = patch_vt1708S},
    3295         { .id = 0x11063397, .name = "VT1708S",
     3298        { .id = 0x11063397, .name = "VIA VT1708S",
    32963299          .patch = patch_vt1708S},
    3297         { .id = 0x11064397, .name = "VT1708S",
     3300        { .id = 0x11064397, .name = "VIA VT1708S",
    32983301          .patch = patch_vt1708S},
    3299         { .id = 0x11065397, .name = "VT1708S",
     3302        { .id = 0x11065397, .name = "VIA VT1708S",
    33003303          .patch = patch_vt1708S},
    3301         { .id = 0x11066397, .name = "VT1708S",
     3304        { .id = 0x11066397, .name = "VIA VT1708S",
    33023305          .patch = patch_vt1708S},
    3303         { .id = 0x11067397, .name = "VT1708S",
     3306        { .id = 0x11067397, .name = "VIA VT1708S",
    33043307          .patch = patch_vt1708S},
    3305         { .id = 0x11060398, .name = "VT1702",
     3308        { .id = 0x11060398, .name = "VIA VT1702",
    33063309          .patch = patch_vt1702},
    3307         { .id = 0x11061398, .name = "VT1702",
     3310        { .id = 0x11061398, .name = "VIA VT1702",
    33083311          .patch = patch_vt1702},
    3309         { .id = 0x11062398, .name = "VT1702",
     3312        { .id = 0x11062398, .name = "VIA VT1702",
    33103313          .patch = patch_vt1702},
    3311         { .id = 0x11063398, .name = "VT1702",
     3314        { .id = 0x11063398, .name = "VIA VT1702",
    33123315          .patch = patch_vt1702},
    3313         { .id = 0x11064398, .name = "VT1702",
     3316        { .id = 0x11064398, .name = "VIA VT1702",
    33143317          .patch = patch_vt1702},
    3315         { .id = 0x11065398, .name = "VT1702",
     3318        { .id = 0x11065398, .name = "VIA VT1702",
    33163319          .patch = patch_vt1702},
    3317         { .id = 0x11066398, .name = "VT1702",
     3320        { .id = 0x11066398, .name = "VIA VT1702",
    33183321          .patch = patch_vt1702},
    3319         { .id = 0x11067398, .name = "VT1702",
     3322        { .id = 0x11067398, .name = "VIA VT1702",
    33203323          .patch = patch_vt1702},
    33213324        {0} /* terminator */
    33223325};
    3323 
    3324 MODULE_ALIAS("snd-hda-codec-id:1106*");
    3325 
    3326 static struct hda_codec_preset_list via_list = {
    3327         .preset = snd_hda_preset_via,
    3328         .owner = THIS_MODULE,
    3329 };
    3330 
    3331 MODULE_LICENSE("GPL");
    3332 MODULE_DESCRIPTION("VIA HD-audio codec");
    3333 
    3334 static int __init patch_via_init(void)
    3335 {
    3336         return snd_hda_add_codec_preset(&via_list);
    3337 }
    3338 
    3339 static void __exit patch_via_exit(void)
    3340 {
    3341         snd_hda_delete_codec_preset(&via_list);
    3342 }
    3343 
    3344 module_init(patch_via_init)
    3345 module_exit(patch_via_exit)
Note: See TracChangeset for help on using the changeset viewer.