Changeset 358 for GPL


Ignore:
Timestamp:
Jul 16, 2008, 11:53:49 AM (17 years ago)
Author:
Paul Smedley
Message:

Update uniaud32-2.0 branch to ALSA 1.0.17

Location:
GPL/branches/uniaud32-2.0
Files:
2 added
89 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/control.c

    r318 r358  
    693693}
    694694
    695 int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control)
     695static int snd_ctl_elem_read(struct snd_card *card,
     696                             struct snd_ctl_elem_value *control)
    696697{
    697698        struct snd_kcontrol *kctl;
     
    743744}
    744745
    745 int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
    746                        struct snd_ctl_elem_value *control)
     746static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
     747                              struct snd_ctl_elem_value *control)
    747748{
    748749        struct snd_kcontrol *kctl;
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/info.c

    r305 r358  
    572572        struct proc_dir_entry *p;
    573573
    574         p = snd_create_proc_entry("asound", S_IFDIR | S_IRUGO | S_IXUGO, &proc_root);
     574        p = snd_create_proc_entry("asound", S_IFDIR | S_IRUGO | S_IXUGO, NULL);
    575575        if (p == NULL)
    576576                return -ENOMEM;
     
    622622                snd_info_free_entry(snd_oss_root);
    623623#endif
    624                 snd_remove_proc_entry(&proc_root, snd_proc_root);
     624                snd_remove_proc_entry(NULL, snd_proc_root);
    625625        }
    626626        return 0;
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/init.c

    r318 r358  
    5959MODULE_PARM_DESC(slots, "Module names assigned to the slots.");
    6060
    61 /* return non-zero if the given index is already reserved for another
     61/* return non-zero if the given index is reserved for the given
    6262 * module via slots option
    6363 */
    64 static int module_slot_mismatch(struct module *module, int idx)
     64static int module_slot_match(struct module *module, int idx)
    6565{
    6666#ifndef TARGET_OS2
    6767#ifdef MODULE
    68         char *s1, *s2;
     68        const char *s1, *s2;
     69
     70        int match = 1;
    6971        if (!module || !module->name || !slots[idx])
    7072                return 0;
    71         s1 = slots[idx];
    72         s2 = module->name;
     73        s1 = module->name;
     74        s2 = slots[idx];
     75        if (*s2 == '!') {
     76                match = 0; /* negative match */
     77                s2++;
     78        }
    7379        /* compare module name strings
    7480         * hyphens are handled as equivalent with underscore
     
    8288                        c2 = '_';
    8389                if (c1 != c2)
    84                         return 1;
     90                        return !match;
    8591                if (!c1)
    8692                        break;
    8793        }
    88 #endif
    89 #endif
    90         return 0;
     94
     95#endif /* MODULE */
     96#else
     97        int match = 1;
     98#endif
     99        return match;
    91100}
    92101
     
    144153{
    145154        struct snd_card *card;
    146         int err;
     155        int err, idx2;
    147156
    148157        if (extra_size < 0)
     
    160169        mutex_lock(&snd_card_mutex);
    161170        if (idx < 0) {
    162                 int idx2;
    163171                for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++)
    164172                        /* idx == -1 == 0xffff means: take any free slot */
    165173                        if (~snd_cards_lock & idx & 1<<idx2) {
    166                                 if (module_slot_mismatch(module, idx2))
    167                                         continue;
    168                                 idx = idx2;
    169                                 if (idx >= snd_ecards_limit)
    170                                         snd_ecards_limit = idx + 1;
    171                                 break;
     174                                if (module_slot_match(module, idx2)) {
     175                                        idx = idx2;
     176                                        break;
     177                                }
    172178                        }
    173         } else {
    174                  if (idx < snd_ecards_limit) {
    175                         if (snd_cards_lock & (1 << idx))
    176                                 err = -EBUSY;   /* invalid */
    177                 } else {
    178                         if (idx < SNDRV_CARDS)
    179                                 snd_ecards_limit = idx + 1; /* increase the limit */
    180                         else
    181                                 err = -ENODEV;
    182                 }
    183         }
    184         if (idx < 0 || err < 0) {
     179        }
     180        if (idx < 0) {
     181                for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++)
     182                        /* idx == -1 == 0xffff means: take any free slot */
     183                        if (~snd_cards_lock & idx & 1<<idx2) {
     184                                if (!slots[idx2] || !*slots[idx2]) {
     185                                        idx = idx2;
     186                                        break;
     187                                }
     188                        }
     189        }
     190        if (idx < 0)
     191                err = -ENODEV;
     192        else if (idx < snd_ecards_limit) {
     193                if (snd_cards_lock & (1 << idx))
     194                        err = -EBUSY;   /* invalid */
     195        } else if (idx >= SNDRV_CARDS)
     196                err = -ENODEV;
     197        if (err < 0) {
    185198                mutex_unlock(&snd_card_mutex);
    186199                snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i), error: %d\n",
     
    189202        }
    190203        snd_cards_lock |= 1 << idx;             /* lock it */
     204        if (idx >= snd_ecards_limit)
     205                snd_ecards_limit = idx + 1; /* increase the limit */
    191206        mutex_unlock(&snd_card_mutex);
    192207        card->number = idx;
     
    271286
    272287#ifndef TARGET_OS2
    273         panic("%s(%p, %p) failed!", __FUNCTION__, inode, file);
     288        panic("%s(%p, %p) failed!", __func__, inode, file);
    274289#endif
    275290}
     
    347362        int err;
    348363
     364        if (!card)
     365                return -EINVAL;
     366
    349367        spin_lock(&card->files_lock);
    350368        if (card->shutdown) {
     
    358376        mutex_lock(&snd_card_mutex);
    359377        snd_cards[card->number] = NULL;
     378        snd_cards_lock &= ~(1 << card->number);
    360379        mutex_unlock(&snd_card_mutex);
    361380       
     
    396415
    397416        snd_info_card_disconnect(card);
     417#ifndef CONFIG_SYSFS_DEPRECATED
     418        if (card->card_dev) {
     419                device_unregister(card->card_dev);
     420                card->card_dev = NULL;
     421        }
     422#endif
     423#ifdef CONFIG_PM
     424        wake_up(&card->power_sleep);
     425#endif
    398426        return 0;       
    399427}
     
    437465                /* Not fatal error */
    438466        }
    439 #ifndef CONFIG_SYSFS_DEPRECATED
    440         if (card->card_dev)
    441                 device_unregister(card->card_dev);
    442 #endif
    443467        kfree(card);
    444468        return 0;
    445469}
    446470
    447 static int snd_card_free_prepare(struct snd_card *card)
    448 {
    449         if (card == NULL)
    450                 return -EINVAL;
    451         (void) snd_card_disconnect(card);
    452         mutex_lock(&snd_card_mutex);
    453         snd_cards[card->number] = NULL;
    454         snd_cards_lock &= ~(1 << card->number);
    455         mutex_unlock(&snd_card_mutex);
    456 #ifdef CONFIG_PM
    457         wake_up(&card->power_sleep);
    458 #endif
    459         return 0;
    460 }
    461 
    462471int snd_card_free_when_closed(struct snd_card *card)
    463472{
    464473        int free_now = 0;
    465         int ret = snd_card_free_prepare(card);
     474        int ret = snd_card_disconnect(card);
    466475        if (ret)
    467476                return ret;
     
    483492int snd_card_free(struct snd_card *card)
    484493{
    485         int ret = snd_card_free_prepare(card);
     494        int ret = snd_card_disconnect(card);
    486495        if (ret)
    487496                return ret;
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/makefile.os2

    r333 r358  
    2121FILE6    = timer.obj
    2222FILE7    = rtctimer.obj
    23 FILE8    = hwdep.obj info.obj wrappers.obj misc_driver.obj
     23FILE8    = hwdep.obj info.obj wrappers.obj misc_driver.obj vmaster.obj
    2424FILELAST =
    2525FILES    = $(FILE0) $(FILE1) $(FILE2) $(FILE3) $(FILE4) $(FILE5) $(FILE6) $(FILE7) $(FILE8) $(FILE9) $(FILE10) $(FILE11) $(FILE12)
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/memalloc.c

    r351 r358  
    125125#endif
    126126
    127 #if defined(__i386__)
    128 /*
    129  * A hack to allocate large buffers via dma_alloc_coherent()
    130  *
    131  * since dma_alloc_coherent always tries GFP_DMA when the requested
    132  * pci memory region is below 32bit, it happens quite often that even
    133  * 2 order of pages cannot be allocated.
    134  *
    135  * so in the following, we allocate at first without dma_mask, so that
    136  * allocation will be done without GFP_DMA.  if the area doesn't match
    137  * with the requested region, then realloate with the original dma_mask
    138  * again.
    139  *
    140  * Really, we want to move this type of thing into dma_alloc_coherent()
    141  * so dma_mask doesn't have to be messed with.
    142  */
    143 
    144 static void *snd_dma_hack_alloc_coherent(struct device *dev, size_t size,
    145                                          dma_addr_t *dma_handle,
    146                                          gfp_t flags)
    147 {
    148         void *ret;
    149         u64 dma_mask, coherent_dma_mask;
    150 
    151         if (dev == NULL || !dev->dma_mask)
    152                 return dma_alloc_coherent(dev, size, dma_handle, flags);
    153         dma_mask = *dev->dma_mask;
    154         coherent_dma_mask = dev->coherent_dma_mask;
    155         *dev->dma_mask = 0xffffffff;    /* do without masking */
    156         dev->coherent_dma_mask = 0xffffffff;    /* do without masking */
    157         ret = dma_alloc_coherent(dev, size, dma_handle, flags);
    158         *dev->dma_mask = dma_mask;      /* restore */
    159         dev->coherent_dma_mask = coherent_dma_mask;     /* restore */
    160         if (ret) {
    161                 /* obtained address is out of range? */
    162                 if (((unsigned long)*dma_handle + size - 1) & ~dma_mask) {
    163                         /* reallocate with the proper mask */
    164                         dma_free_coherent(dev, size, ret, *dma_handle);
    165                         ret = dma_alloc_coherent(dev, size, dma_handle, flags);
    166                 }
    167         } else {
    168                 /* wish to success now with the proper mask... */
    169                 if (dma_mask != 0xffffffffUL) {
    170                         /* allocation with GFP_ATOMIC to avoid the long stall */
    171                         flags &= ~GFP_KERNEL;
    172                         flags |= GFP_ATOMIC;
    173                         ret = dma_alloc_coherent(dev, size, dma_handle, flags);
    174                 }
    175         }
    176         return ret;
    177 }
    178 
    179 /* redefine dma_alloc_coherent for some architectures */
    180 #undef dma_alloc_coherent
    181 #define dma_alloc_coherent snd_dma_hack_alloc_coherent
    182 
    183 #endif /* arch */
    184127
    185128/*
     
    687630#ifdef CONFIG_PROC_FS
    688631#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    689         snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL);
    690         if (snd_mem_proc)
    691                 snd_mem_proc->proc_fops = &snd_mem_proc_fops;
     632        snd_mem_proc = proc_create(SND_MEM_PROC_FILE, 0644, NULL,
     633                                   &snd_mem_proc_fops);
    692634#endif
    693635#endif
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/misc.c

    r305 r358  
    4040        va_list args;
    4141       
    42         if (format[0] == '<' && format[1] >= '0' && format[1] <= '9' && format[2] == '>') {
     42        if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
    4343                char tmp[] = "<0>";
    4444                tmp[1] = format[1];
     
    6161        va_list args;
    6262       
    63         if (format[0] == '<' && format[1] >= '0' && format[1] <= '9' && format[2] == '>') {
     63        if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
    6464                char tmp[] = "<0>";
    6565                tmp[1] = format[1];
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/pcm_native.c

    r319 r358  
    2727#include <linux/slab.h>
    2828#include <linux/time.h>
    29 #include <linux/latency.h>
     29#include <linux/pm_qos_params.h>
    3030#include <linux/uio.h>
    3131#include <sound/core.h>
     
    455455        runtime->status->state = SNDRV_PCM_STATE_SETUP;
    456456
    457         remove_acceptable_latency(substream->latency_id);
     457        pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
     458                                substream->latency_id);
    458459        if ((usecs = period_to_usecs(runtime)) >= 0)
    459                 set_acceptable_latency(substream->latency_id, usecs);
     460                pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY,
     461                                        substream->latency_id, usecs);
    460462        return 0;
    461463 _error:
     
    517519                result = substream->ops->hw_free(substream);
    518520        runtime->status->state = SNDRV_PCM_STATE_OPEN;
    519         remove_acceptable_latency(substream->latency_id);
     521        pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
     522                substream->latency_id);
    520523        return result;
    521524}
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/seq/oss/seq_oss_synth.c

    r333 r358  
    250250                if (info->nr_voices > 0) {
    251251                        info->ch = kcalloc(info->nr_voices, sizeof(struct seq_oss_chinfo), GFP_KERNEL);
    252                         if (!info->ch)
    253                                 BUG();
     252                        if (!info->ch) {
     253                                snd_printk(KERN_ERR "Cannot malloc\n");
     254                                rec->oper.close(&info->arg);
     255                                module_put(rec->oper.owner);
     256                                snd_use_lock_free(&rec->use_lock);
     257                                continue;
     258                        }
    254259                        reset_channels(info);
    255260                }
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/seq/seq_clientmgr.c

    r318 r358  
    153153        }
    154154        spin_unlock_irqrestore(&clients_lock, flags);
    155 #ifdef CONFIG_KMOD
    156         if (!in_interrupt() && current->fs->root) {
     155#ifdef CONFIG_MODULES
     156        if (!in_interrupt()) {
    157157                static char client_requested[SNDRV_SEQ_GLOBAL_CLIENTS];
    158158                static char card_requested[SNDRV_CARDS];
     
    160160                        int idx;
    161161                       
    162                         if (! client_requested[clientid] && current->fs->root) {
     162                        if (!client_requested[clientid]) {
    163163                                client_requested[clientid] = 1;
    164164                                for (idx = 0; idx < 15; idx++) {
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/seq/seq_device.c

    r305 r358  
    125125 */
    126126
    127 #ifdef CONFIG_KMOD
     127#ifdef CONFIG_MODULES
    128128/* avoid auto-loading during module_init() */
    129129static int snd_seq_in_init;
     
    141141void snd_seq_device_load_drivers(void)
    142142{
    143 #ifdef CONFIG_KMOD
     143#ifdef CONFIG_MODULES
    144144        struct ops_list *ops;
    145145
     
    148148         */
    149149        if (snd_seq_in_init)
    150                 return;
    151 
    152         if (! current->fs->root)
    153150                return;
    154151
     
    570567EXPORT_SYMBOL(snd_seq_device_register_driver);
    571568EXPORT_SYMBOL(snd_seq_device_unregister_driver);
    572 #ifdef CONFIG_KMOD
    573569EXPORT_SYMBOL(snd_seq_autoload_lock);
    574570EXPORT_SYMBOL(snd_seq_autoload_unlock);
    575 #endif
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/sound.c

    r317 r358  
    6161static DEFINE_MUTEX(sound_mutex);
    6262
    63 #ifdef CONFIG_KMOD
     63#ifdef CONFIG_MODULES
    6464
    6565/**
     
    6868 *
    6969 * Tries to load the module "snd-card-X" for the given card number
    70  * via KMOD.  Returns immediately if already loaded.
     70 * via request_module.  Returns immediately if already loaded.
    7171 */
    7272void snd_request_card(int card)
    7373{
    74         if (! current->fs->root)
    75                 return;
    7674        if (snd_card_locked(card))
    7775                return;
     
    8785        char *str;
    8886
    89         if (! current->fs->root)
    90                 return;
    9187        switch (minor) {
    9288        case SNDRV_MINOR_SEQUENCER:     str = "snd-seq";        break;
     
    9793}
    9894
    99 #endif                          /* request_module support */
     95#endif  /* modular kernel */
    10096
    10197/**
     
    145141        mptr = snd_minors[minor];
    146142        if (mptr == NULL) {
    147 #ifdef CONFIG_KMOD
     143#ifdef CONFIG_MODULES
    148144                int dev = SNDRV_MINOR_DEVICE(minor);
    149145                if (dev == SNDRV_MINOR_CONTROL) {
     
    283279        snd_minors[minor] = preg;
    284280#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
    285         preg->dev = device_create(sound_class, device, MKDEV(major, minor),
    286                                   "%s", name);
     281        preg->dev = device_create_drvdata(sound_class, device,
     282                                          MKDEV(major, minor),
     283                                          private_data, "%s", name);
    287284        if (IS_ERR(preg->dev)) {
    288285                snd_minors[minor] = NULL;
     
    293290        }
    294291
    295         if (preg->dev)
    296                 dev_set_drvdata(preg->dev, private_data);
    297292#elif defined(CONFIG_SND_HAVE_CLASS_SIMPLE)
    298293        class_simple_device_add((struct class_simple *)sound_class,
  • GPL/branches/uniaud32-2.0/alsa-kernel/core/timer.c

    r319 r358  
    151151}
    152152
    153 #ifdef CONFIG_KMOD
     153#ifdef CONFIG_MODULES
    154154
    155155static void snd_timer_request(struct snd_timer_id *tid)
    156156{
    157         if (! current->fs->root)
    158                 return;
    159157        switch (tid->dev_class) {
    160158        case SNDRV_TIMER_CLASS_GLOBAL:
     
    266264        mutex_lock(&register_mutex);
    267265        timer = snd_timer_find(tid);
    268 #ifdef CONFIG_KMOD
    269         if (timer == NULL) {
     266#ifdef CONFIG_MODULES
     267        if (!timer) {
    270268                mutex_unlock(&register_mutex);
    271269                snd_timer_request(tid);
  • GPL/branches/uniaud32-2.0/alsa-kernel/drivers/dummy.c

    r339 r358  
    182182        spinlock_t lock;
    183183        struct timer_list timer;
    184         unsigned int pcm_size;
    185         unsigned int pcm_count;
     184        unsigned int pcm_buffer_size;
     185        unsigned int pcm_period_size;
    186186        unsigned int pcm_bps;           /* bytes per second */
    187         unsigned int pcm_jiffie;        /* bytes per one jiffie */
     187        unsigned int pcm_hz;            /* HZ */
    188188        unsigned int pcm_irq_pos;       /* IRQ position */
    189189        unsigned int pcm_buf_pos;       /* position in buffer */
     
    231231        struct snd_pcm_runtime *runtime = substream->runtime;
    232232        struct snd_dummy_pcm *dpcm = runtime->private_data;
    233         unsigned int bps;
    234 
    235         bps = runtime->rate * runtime->channels;
    236         bps *= snd_pcm_format_width(runtime->format);
    237         bps /= 8;
     233        int bps;
     234
     235        bps = snd_pcm_format_width(runtime->format) * runtime->rate *
     236                runtime->channels / 8;
     237
    238238        if (bps <= 0)
    239239                return -EINVAL;
     240
    240241        dpcm->pcm_bps = bps;
    241         dpcm->pcm_jiffie = bps / HZ;
    242         dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
    243         dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
     242        dpcm->pcm_hz = HZ;
     243        dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
     244        dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
    244245        dpcm->pcm_irq_pos = 0;
    245246        dpcm->pcm_buf_pos = 0;
     247
     248        snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
     249                        bytes_to_samples(runtime, runtime->dma_bytes));
     250
    246251        return 0;
    247252}
     
    255260        dpcm->timer.expires = 1 + jiffies;
    256261        add_timer(&dpcm->timer);
    257         dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
    258         dpcm->pcm_buf_pos += dpcm->pcm_jiffie;
    259         dpcm->pcm_buf_pos %= dpcm->pcm_size;
    260         if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
    261                 dpcm->pcm_irq_pos %= dpcm->pcm_count;
     262        dpcm->pcm_irq_pos += dpcm->pcm_bps;
     263        dpcm->pcm_buf_pos += dpcm->pcm_bps;
     264        dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
     265        if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
     266                dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
    262267                spin_unlock_irqrestore(&dpcm->lock, flags);
    263268                snd_pcm_period_elapsed(dpcm->substream);
     
    271276        struct snd_dummy_pcm *dpcm = runtime->private_data;
    272277
    273         return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
     278        return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
    274279}
    275280
  • GPL/branches/uniaud32-2.0/alsa-kernel/drivers/mpu401/mpu401_uart.c

    r305 r358  
    5050 */
    5151
    52 #define snd_mpu401_input_avail(mpu)     (!(mpu->read(mpu, MPU401C(mpu)) & 0x80))
    53 #define snd_mpu401_output_ready(mpu)    (!(mpu->read(mpu, MPU401C(mpu)) & 0x40))
    54 
    55 #define MPU401_RESET            0xff
    56 #define MPU401_ENTER_UART       0x3f
    57 #define MPU401_ACK              0xfe
     52#define snd_mpu401_input_avail(mpu) \
     53        (!(mpu->read(mpu, MPU401C(mpu)) & MPU401_RX_EMPTY))
     54#define snd_mpu401_output_ready(mpu) \
     55        (!(mpu->read(mpu, MPU401C(mpu)) & MPU401_TX_FULL))
    5856
    5957/* Build in lowlevel io */
     
    246244        }
    247245        mpu->write(mpu, cmd, MPU401C(mpu));
    248         if (ack) {
     246        if (ack && !(mpu->info_flags & MPU401_INFO_NO_ACK)) {
    249247                ok = 0;
    250248                timeout = 10000;
     
    426424{
    427425        unsigned char byte;
    428         int max = 256, timeout;
     426        int max = 256;
    429427
    430428        do {
    431429                if (snd_rawmidi_transmit_peek(mpu->substream_output,
    432430                                              &byte, 1) == 1) {
    433                         for (timeout = 100; timeout > 0; timeout--) {
    434                                 if (snd_mpu401_output_ready(mpu))
    435                                         break;
    436                         }
    437                         if (timeout == 0)
     431                        /*
     432                         * Try twice because there is hardware that insists on
     433                         * setting the output busy bit after each write.
     434                         */
     435                        if (!snd_mpu401_output_ready(mpu) &&
     436                            !snd_mpu401_output_ready(mpu))
    438437                                break;  /* Tx FIFO full - try again later */
    439438                        mpu->write(mpu, byte, MPU401D(mpu));
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/ac97_codec.h

    r305 r358  
    398398#define AC97_HAS_NO_STD_PCM     (1<<17) /* no standard AC97 PCM volume and mute */
    399399#define AC97_HAS_NO_AUX         (1<<18) /* no standard AC97 AUX volume and mute */
     400#define AC97_HAS_8CH            (1<<19) /* supports 8-channel output */
    400401
    401402/* rates indexes */
     
    505506                        unsigned short codec_cfg[3];    // CODEC_CFG bits
    506507                        unsigned char swap_mic_linein;  // AD1986/AD1986A only
     508                        unsigned char lo_as_master;     /* LO as master */
    507509                } ad18xx;
    508510                unsigned int dev_flags;         /* device specific */
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/ak4114.h

    r305 r358  
    183183        unsigned char rcs1;
    184184        struct delayed_work work;
     185        unsigned int check_flags;
    185186        void *change_callback_private;
    186187        void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1);
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/ak4xxx-adda.h

    r305 r358  
    6969                SND_AK4524, SND_AK4528, SND_AK4529,
    7070                SND_AK4355, SND_AK4358, SND_AK4381,
    71                 SND_AK5365, NON_AKM
     71                SND_AK5365
    7272        } type;
    7373
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/asoundef.h

    r305 r358  
    113113#define IEC958_AES3_CON_CLOCK_50PPM     (1<<4)  /* 50 ppm */
    114114#define IEC958_AES3_CON_CLOCK_VARIABLE  (2<<4)  /* variable pitch */
     115#define IEC958_AES4_CON_MAX_WORDLEN_24  (1<<0)  /* 0 = 20-bit, 1 = 24-bit */
     116#define IEC958_AES4_CON_WORDLEN         (7<<1)  /* mask - sample word length */
     117#define IEC958_AES4_CON_WORDLEN_NOTID   (0<<1)  /* not indicated */
     118#define IEC958_AES4_CON_WORDLEN_20_16   (1<<1)  /* 20-bit or 16-bit */
     119#define IEC958_AES4_CON_WORDLEN_22_18   (2<<1)  /* 22-bit or 18-bit */
     120#define IEC958_AES4_CON_WORDLEN_23_19   (4<<1)  /* 23-bit or 19-bit */
     121#define IEC958_AES4_CON_WORDLEN_24_20   (5<<1)  /* 24-bit or 20-bit */
     122#define IEC958_AES4_CON_WORDLEN_21_17   (6<<1)  /* 21-bit or 17-bit */
    115123
    116124/*****************************************************************************
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/config.h

    r351 r358  
    236236typedef enum sndrv_timer_global snd_timer_global_t;
    237237#endif
     238
     239/* redefine INIT_WORK() */
     240static inline void snd_INIT_WORK(struct work_struct *w, void (*f)(struct work_struct *))
     241{
     242        INIT_WORK(w, (void(*)(void*))(f), w);
     243}
     244#undef INIT_WORK
     245#define INIT_WORK(w,f) snd_INIT_WORK(w,f)
    238246
    239247#ifdef CONFIG_SND_DEBUG_MEMORY
     
    598606void pci_iounmap(struct pci_dev *dev, void __iomem * addr);
    599607
     608#ifndef upper_32_bits
     609#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
     610#endif
     611
     612#ifdef __SMP__
     613#define smp_mb()        mb()
     614#define smp_rmb()       rmb()
     615#define smp_wmb()       wmb()
     616#else
     617#define smp_mb()        barrier()
     618#define smp_rmb()       barrier()
     619#define smp_wmb()       barrier()
     620#endif
     621
    600622#endif //__ALSA_CONFIG_H__
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/control.h

    r305 r358  
    137137#endif
    138138
    139 int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control);
    140 int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, struct snd_ctl_elem_value *control);
    141 
    142139static inline unsigned int snd_ctl_get_ioffnum(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
    143140{
     
    177174                                struct snd_ctl_elem_info *uinfo);
    178175
    179 #endif                          /* __CONTROL_H */
     176/*
     177 * virtual master control
     178 */
     179struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
     180                                                 const unsigned int *tlv);
     181int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
     182                     
     183#endif  /* __SOUND_CONTROL_H */
     184
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/core.h

    r351 r358  
    301301int snd_minor_info_oss_done(void);
    302302#else
    303 #define snd_minor_info_oss_init() /*NOP*/
    304 #define snd_minor_info_oss_done() /*NOP*/
     303static inline int snd_minor_info_oss_init(void) { return 0; }
     304static inline int snd_minor_info_oss_done(void) { return 0; }
    305305#endif
    306306
     
    334334
    335335#ifndef snd_card_set_dev
    336 #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr))
     336#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
    337337#endif
    338338
     
    401401 * @fmt: format string
    402402 *
    403  * Compiled only when Works like snd_printk() for debugging purpose.
     403 * Works like snd_printk() for debugging purposes.
    404404 * Ignored when CONFIG_SND_DEBUG is not set.
    405405 */
     
    452452#endif /* CONFIG_SND_DEBUG */
    453453
    454 #ifdef CONFIG_SND_DEBUG_DETECT
     454#ifdef CONFIG_SND_DEBUG_VERBOSE
    455455/**
    456456 * snd_printdd - debug printk
    457457 * @format: format string
    458458 *
    459  * Compiled only when Works like snd_printk() for debugging purpose.
    460  * Ignored when CONFIG_SND_DEBUG_DETECT is not set.
     459 * Works like snd_printk() for debugging purposes.
     460 * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
    461461 */
    462462#ifndef TARGET_OS2
     
    490490        unsigned short subdevice;       /* PCI subdevice ID */
    491491        int value;                      /* value */
    492 #ifdef CONFIG_SND_DEBUG_DETECT
     492#ifdef CONFIG_SND_DEBUG_VERBOSE
    493493        const char *name;               /* name of the device (optional) */
    494494#endif
     
    498498        .subvendor = (vend), .subdevice = (dev)
    499499#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)}
    500 #ifdef CONFIG_SND_DEBUG_DETECT
     500#ifdef CONFIG_SND_DEBUG_VERBOSE
    501501#define SND_PCI_QUIRK(vend,dev,xname,val) \
    502502        {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)}
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/cs4231-regs.h

    r305 r358  
    178178#define CS4236_VERSION          0x9c    /* chip version and ID */
    179179
     180/* definitions for extended registers - OPTI93X */
     181#define OPTi931_AUX_LEFT_INPUT  0x10
     182#define OPTi931_AUX_RIGHT_INPUT 0x11
     183#define OPTi93X_MIC_LEFT_INPUT  0x14
     184#define OPTi93X_MIC_RIGHT_INPUT 0x15
     185#define OPTi93X_OUT_LEFT        0x16
     186#define OPTi93X_OUT_RIGHT       0x17
     187
    180188#endif /* __SOUND_CS4231_REGS_H */
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/cs4231.h

    r305 r358  
    5858#define CS4231_HW_INTERWAVE     0x1000  /* InterWave chip */
    5959#define CS4231_HW_OPL3SA2       0x1101  /* OPL3-SA2 chip, similar to cs4231 */
     60#define CS4231_HW_OPTI93X       0x1102  /* Opti 930/931/933 */
    6061
    6162/* defines for codec.hwshare */
     
    119120void snd_cs4231_mce_up(struct snd_cs4231 *chip);
    120121void snd_cs4231_mce_down(struct snd_cs4231 *chip);
     122
     123void snd_cs4231_overrange(struct snd_cs4231 *chip);
    121124
    122125irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id);
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/emu10k1.h

    r305 r358  
    16711671        unsigned char i2c_adc;      /* I2C interface for ADC */
    16721672        unsigned char adc_1361t;    /* Use Philips 1361T ADC */
     1673        unsigned char invert_shared_spdif; /* analog/digital switch inverted */
    16731674        const char *driver;
    16741675        const char *name;
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/mpu401.h

    r305 r358  
    5151#define MPU401_INFO_MMIO        (1 << 3)        /* MMIO access */
    5252#define MPU401_INFO_TX_IRQ      (1 << 4)        /* independent TX irq */
     53#define MPU401_INFO_NO_ACK      (1 << 6)        /* No ACK cmd needed */
    5354
    5455#define MPU401_MODE_BIT_INPUT           0
     
    104105
    105106/*
     107 * control register bits
     108 */
     109/* read MPU401C() */
     110#define MPU401_RX_EMPTY         0x80
     111#define MPU401_TX_FULL          0x40
     112
     113/* write MPU401C() */
     114#define MPU401_RESET            0xff
     115#define MPU401_ENTER_UART       0x3f
     116
     117/* read MPU401D() */
     118#define MPU401_ACK              0xfe
     119
     120
     121/*
    106122
    107123 */
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/seq_kernel.h

    r305 r358  
    111111int snd_seq_event_port_detach(int client, int port);
    112112
    113 #ifdef CONFIG_KMOD
     113#ifdef CONFIG_MODULES
    114114void snd_seq_autoload_lock(void);
    115115void snd_seq_autoload_unlock(void);
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/soc-dapm.h

    r305 r358  
    130130{       .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \
    131131        .shift = wshift, .invert = winvert}
     132
     133/* generic register modifier widget */
     134#define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \
     135{       .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \
     136        .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \
     137        .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \
     138        .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
    132139
    133140/* dapm kcontrol types */
     
    194201struct snd_soc_dapm_path;
    195202struct snd_soc_dapm_pin;
     203struct snd_soc_dapm_route;
    196204
    197205/* dapm controls */
     
    206214int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
    207215        const struct snd_soc_dapm_widget *widget);
     216int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
     217        const struct snd_soc_dapm_widget *widget,
     218        int num);
    208219
    209220/* dapm path setup */
    210 int snd_soc_dapm_connect_input(struct snd_soc_codec *codec,
     221int  __deprecated snd_soc_dapm_connect_input(struct snd_soc_codec *codec,
    211222        const char *sink_name, const char *control_name, const char *src_name);
    212223int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec);
    213224void snd_soc_dapm_free(struct snd_soc_device *socdev);
     225int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,
     226                            const struct snd_soc_dapm_route *route, int num);
    214227
    215228/* dapm events */
    216229int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream,
    217230        int event);
    218 int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event);
     231int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
     232        enum snd_soc_bias_level level);
    219233
    220234/* dapm sys fs - used by the core */
    221235int snd_soc_dapm_sys_add(struct device *dev);
    222236
    223 /* dapm audio endpoint control */
    224 int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
    225         char *pin, int status);
    226 int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
     237/* dapm audio pin control and status */
     238int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin);
     239int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin);
     240int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin);
     241int snd_soc_dapm_sync(struct snd_soc_codec *codec);
    227242
    228243/* dapm widget types */
     
    246261};
    247262
     263/*
     264 * DAPM audio route definition.
     265 *
     266 * Defines an audio route originating at source via control and finishing
     267 * at sink.
     268 */
     269struct snd_soc_dapm_route {
     270        const char *sink;
     271        const char *control;
     272        const char *source;
     273};
     274
    248275/* dapm audio path between two widgets */
    249276struct snd_soc_dapm_path {
     
    278305        unsigned int saved_value;               /* widget saved value */
    279306        unsigned int value;                             /* widget current value */
     307        unsigned int mask;                      /* non-shifted mask */
     308        unsigned int on_val;                    /* on state value */
     309        unsigned int off_val;                   /* off state value */
    280310        unsigned char power:1;                  /* block power status */
    281311        unsigned char invert:1;                 /* invert the power bit */
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/soc.h

    r305 r358  
    7474        .private_value = (reg_left) | ((shift) << 8)  | \
    7575                ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
     76#define SOC_DOUBLE_S8_TLV(xname, reg, min, max, tlv_array) \
     77{       .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     78        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
     79                  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
     80        .tlv.p  = (tlv_array), \
     81        .info   = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
     82        .put    = snd_soc_put_volsw_s8, \
     83        .private_value = (reg) | (((signed char)max) << 16) | \
     84                         (((signed char)min) << 24) }
    7685#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
    7786{       .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
     
    92101        .get = xhandler_get, .put = xhandler_put, \
    93102        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
     103#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmask, xinvert,\
     104         xhandler_get, xhandler_put, tlv_array) \
     105{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     106        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
     107                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
     108        .tlv.p = (tlv_array), \
     109        .info = snd_soc_info_volsw, \
     110        .get = xhandler_get, .put = xhandler_put, \
     111        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
    94112#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
    95113{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    104122
    105123/*
     124 * Bias levels
     125 *
     126 * @ON:      Bias is fully on for audio playback and capture operations.
     127 * @PREPARE: Prepare for audio operations. Called before DAPM switching for
     128 *           stream start and stop operations.
     129 * @STANDBY: Low power standby state when no playback/capture operations are
     130 *           in progress. NOTE: The transition time between STANDBY and ON
     131 *           should be as fast as possible and no longer than 10ms.
     132 * @OFF:     Power Off. No restrictions on transition times.
     133 */
     134enum snd_soc_bias_level {
     135        SND_SOC_BIAS_ON,
     136        SND_SOC_BIAS_PREPARE,
     137        SND_SOC_BIAS_STANDBY,
     138        SND_SOC_BIAS_OFF,
     139};
     140
     141/*
    106142 * Digital Audio Interface (DAI) types
    107143 */
     
    186222struct snd_soc_dai_mode;
    187223struct snd_soc_pcm_runtime;
    188 struct snd_soc_codec_dai;
    189 struct snd_soc_cpu_dai;
     224struct snd_soc_dai;
    190225struct snd_soc_codec;
    191226struct snd_soc_machine_config;
     
    221256        struct snd_ac97_bus_ops *ops, int num);
    222257void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
     258
     259/* Digital Audio Interface clocking API.*/
     260int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
     261        unsigned int freq, int dir);
     262
     263int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
     264        int div_id, int div);
     265
     266int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
     267        int pll_id, unsigned int freq_in, unsigned int freq_out);
     268
     269/* Digital Audio interface formatting */
     270int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
     271
     272int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
     273        unsigned int mask, int slots);
     274
     275int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
     276
     277/* Digital Audio Interface mute */
     278int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
    223279
    224280/*
     
    239295int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
    240296        struct snd_ctl_elem_info *uinfo);
    241 #define snd_soc_info_bool_ext           snd_ctl_boolean_mono
     297#define snd_soc_info_bool_ext           snd_ctl_boolean_mono_info
    242298int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
    243299        struct snd_ctl_elem_value *ucontrol);
     
    249305        struct snd_ctl_elem_value *ucontrol);
    250306int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
     307        struct snd_ctl_elem_value *ucontrol);
     308int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
     309        struct snd_ctl_elem_info *uinfo);
     310int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
     311        struct snd_ctl_elem_value *ucontrol);
     312int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
    251313        struct snd_ctl_elem_value *ucontrol);
    252314
     
    273335};
    274336
    275 /* ASoC codec DAI ops */
    276 struct snd_soc_codec_ops {
    277         /* codec DAI clocking configuration */
    278         int (*set_sysclk)(struct snd_soc_codec_dai *codec_dai,
     337/* ASoC DAI ops */
     338struct snd_soc_dai_ops {
     339        /* DAI clocking configuration */
     340        int (*set_sysclk)(struct snd_soc_dai *dai,
    279341                int clk_id, unsigned int freq, int dir);
    280         int (*set_pll)(struct snd_soc_codec_dai *codec_dai,
     342        int (*set_pll)(struct snd_soc_dai *dai,
    281343                int pll_id, unsigned int freq_in, unsigned int freq_out);
    282         int (*set_clkdiv)(struct snd_soc_codec_dai *codec_dai,
    283                 int div_id, int div);
    284 
    285         /* CPU DAI format configuration */
    286         int (*set_fmt)(struct snd_soc_codec_dai *codec_dai,
    287                 unsigned int fmt);
    288         int (*set_tdm_slot)(struct snd_soc_codec_dai *codec_dai,
     344        int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
     345
     346        /* DAI format configuration */
     347        int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
     348        int (*set_tdm_slot)(struct snd_soc_dai *dai,
    289349                unsigned int mask, int slots);
    290         int (*set_tristate)(struct snd_soc_codec_dai *, int tristate);
     350        int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
    291351
    292352        /* digital mute */
    293         int (*digital_mute)(struct snd_soc_codec_dai *, int mute);
    294 };
    295 
    296 /* ASoC cpu DAI ops */
    297 struct snd_soc_cpu_ops {
    298         /* CPU DAI clocking configuration */
    299         int (*set_sysclk)(struct snd_soc_cpu_dai *cpu_dai,
    300                 int clk_id, unsigned int freq, int dir);
    301         int (*set_clkdiv)(struct snd_soc_cpu_dai *cpu_dai,
    302                 int div_id, int div);
    303         int (*set_pll)(struct snd_soc_cpu_dai *cpu_dai,
    304                 int pll_id, unsigned int freq_in, unsigned int freq_out);
    305 
    306         /* CPU DAI format configuration */
    307         int (*set_fmt)(struct snd_soc_cpu_dai *cpu_dai,
    308                 unsigned int fmt);
    309         int (*set_tdm_slot)(struct snd_soc_cpu_dai *cpu_dai,
    310                 unsigned int mask, int slots);
    311         int (*set_tristate)(struct snd_soc_cpu_dai *, int tristate);
    312 };
    313 
    314 /* SoC Codec DAI */
    315 struct snd_soc_codec_dai {
    316         char *name;
    317         int id;
    318         unsigned char type;
    319 
    320         /* DAI capabilities */
    321         struct snd_soc_pcm_stream playback;
    322         struct snd_soc_pcm_stream capture;
    323 
    324         /* DAI runtime info */
    325         struct snd_soc_codec *codec;
    326         unsigned int active;
    327         unsigned char pop_wait:1;
    328 
    329         /* ops */
    330         struct snd_soc_ops ops;
    331         struct snd_soc_codec_ops dai_ops;
    332 
    333         /* DAI private data */
    334         void *private_data;
    335 };
    336 
    337 /* SoC CPU DAI */
    338 struct snd_soc_cpu_dai {
    339 
     353        int (*digital_mute)(struct snd_soc_dai *dai, int mute);
     354};
     355
     356/* SoC  DAI (Digital Audio Interface) */
     357struct snd_soc_dai {
    340358        /* DAI description */
    341359        char *name;
     
    344362
    345363        /* DAI callbacks */
    346         int (*probe)(struct platform_device *pdev);
    347         void (*remove)(struct platform_device *pdev);
     364        int (*probe)(struct platform_device *pdev,
     365                     struct snd_soc_dai *dai);
     366        void (*remove)(struct platform_device *pdev,
     367                       struct snd_soc_dai *dai);
    348368        int (*suspend)(struct platform_device *pdev,
    349                 struct snd_soc_cpu_dai *cpu_dai);
     369                struct snd_soc_dai *dai);
    350370        int (*resume)(struct platform_device *pdev,
    351                 struct snd_soc_cpu_dai *cpu_dai);
     371                struct snd_soc_dai *dai);
    352372
    353373        /* ops */
    354374        struct snd_soc_ops ops;
    355         struct snd_soc_cpu_ops dai_ops;
     375        struct snd_soc_dai_ops dai_ops;
    356376
    357377        /* DAI capabilities */
     
    361381        /* DAI runtime info */
    362382        struct snd_pcm_runtime *runtime;
    363         unsigned char active:1;
     383        struct snd_soc_codec *codec;
     384        unsigned int active;
     385        unsigned char pop_wait:1;
    364386        void *dma_data;
    365387
     
    375397
    376398        /* callbacks */
    377         int (*dapm_event)(struct snd_soc_codec *codec, int event);
     399        int (*set_bias_level)(struct snd_soc_codec *,
     400                              enum snd_soc_bias_level level);
    378401
    379402        /* runtime */
     
    397420        struct list_head dapm_widgets;
    398421        struct list_head dapm_paths;
    399         unsigned int dapm_state;
    400         unsigned int suspend_dapm_state;
     422        enum snd_soc_bias_level bias_level;
     423        enum snd_soc_bias_level suspend_bias_level;
    401424        struct delayed_work delayed_work;
    402425
    403426        /* codec DAI's */
    404         struct snd_soc_codec_dai *dai;
     427        struct snd_soc_dai *dai;
    405428        unsigned int num_dai;
    406429};
     
    421444        int (*remove)(struct platform_device *pdev);
    422445        int (*suspend)(struct platform_device *pdev,
    423                 struct snd_soc_cpu_dai *cpu_dai);
     446                struct snd_soc_dai *dai);
    424447        int (*resume)(struct platform_device *pdev,
    425                 struct snd_soc_cpu_dai *cpu_dai);
     448                struct snd_soc_dai *dai);
    426449
    427450        /* pcm creation and destruction */
    428         int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *,
     451        int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
    429452                struct snd_pcm *);
    430453        void (*pcm_free)(struct snd_pcm *);
     
    440463
    441464        /* DAI */
    442         struct snd_soc_codec_dai *codec_dai;
    443         struct snd_soc_cpu_dai *cpu_dai;
     465        struct snd_soc_dai *codec_dai;
     466        struct snd_soc_dai *cpu_dai;
    444467
    445468        /* machine stream operations */
     
    468491
    469492        /* callbacks */
    470         int (*dapm_event)(struct snd_soc_machine *, int event);
     493        int (*set_bias_level)(struct snd_soc_machine *,
     494                              enum snd_soc_bias_level level);
    471495
    472496        /* CPU <--> Codec DAI links  */
     
    483507        struct snd_soc_codec_device *codec_dev;
    484508        struct delayed_work delayed_work;
     509        struct work_struct deferred_resume_work;
    485510        void *codec_data;
    486511};
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/uda1341.h

    r305 r358  
    1515 *                           features support
    1616 */
    17 
    18 /* $Id: uda1341.h,v 1.8 2005/11/17 14:17:21 tiwai Exp $ */
    1917
    2018#define UDA1341_ALSA_NAME "snd-uda1341"
  • GPL/branches/uniaud32-2.0/alsa-kernel/include/sound/version.h

    r305 r358  
    66#define __ALSA_VERSION_H__
    77#define CONFIG_SND_DATE ""
    8 #define CONFIG_SND_VERSION "1.0.16"
     8#define CONFIG_SND_VERSION "1.0.17"
    99#endif //__ALSA_VERSION_H__
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/cs423x/cs4231_lib.c

    r305 r358  
    118118        0x00,                   /* 1e/30 - cbru */
    119119        0x00,                   /* 1f/31 - cbrl */
     120};
     121
     122static unsigned char snd_opti93x_original_image[32] =
     123{
     124        0x00,           /* 00/00 - l_mixout_outctrl */
     125        0x00,           /* 01/01 - r_mixout_outctrl */
     126        0x88,           /* 02/02 - l_cd_inctrl */
     127        0x88,           /* 03/03 - r_cd_inctrl */
     128        0x88,           /* 04/04 - l_a1/fm_inctrl */
     129        0x88,           /* 05/05 - r_a1/fm_inctrl */
     130        0x80,           /* 06/06 - l_dac_inctrl */
     131        0x80,           /* 07/07 - r_dac_inctrl */
     132        0x00,           /* 08/08 - ply_dataform_reg */
     133        0x00,           /* 09/09 - if_conf */
     134        0x00,           /* 0a/10 - pin_ctrl */
     135        0x00,           /* 0b/11 - err_init_reg */
     136        0x0a,           /* 0c/12 - id_reg */
     137        0x00,           /* 0d/13 - reserved */
     138        0x00,           /* 0e/14 - ply_upcount_reg */
     139        0x00,           /* 0f/15 - ply_lowcount_reg */
     140        0x88,           /* 10/16 - reserved/l_a1_inctrl */
     141        0x88,           /* 11/17 - reserved/r_a1_inctrl */
     142        0x88,           /* 12/18 - l_line_inctrl */
     143        0x88,           /* 13/19 - r_line_inctrl */
     144        0x88,           /* 14/20 - l_mic_inctrl */
     145        0x88,           /* 15/21 - r_mic_inctrl */
     146        0x80,           /* 16/22 - l_out_outctrl */
     147        0x80,           /* 17/23 - r_out_outctrl */
     148        0x00,           /* 18/24 - reserved */
     149        0x00,           /* 19/25 - reserved */
     150        0x00,           /* 1a/26 - reserved */
     151        0x00,           /* 1b/27 - reserved */
     152        0x00,           /* 1c/28 - cap_dataform_reg */
     153        0x00,           /* 1d/29 - reserved */
     154        0x00,           /* 1e/30 - cap_upcount_reg */
     155        0x00            /* 1f/31 - cap_lowcount_reg */
    120156};
    121157
     
    896932}
    897933
    898 static void snd_cs4231_overrange(struct snd_cs4231 *chip)
     934void snd_cs4231_overrange(struct snd_cs4231 *chip)
    899935{
    900936        unsigned long flags;
     
    10551091            (chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA) |
    10561092            (chip->single_dma ? CS4231_SINGLE_DMA : 0);
    1057         chip->image[CS4231_ALT_FEATURE_1] = 0x80;
    1058         chip->image[CS4231_ALT_FEATURE_2] = chip->hardware == CS4231_HW_INTERWAVE ? 0xc2 : 0x01;
     1093        if (chip->hardware != CS4231_HW_OPTI93X) {
     1094                chip->image[CS4231_ALT_FEATURE_1] = 0x80;
     1095                chip->image[CS4231_ALT_FEATURE_2] =
     1096                        chip->hardware == CS4231_HW_INTERWAVE ? 0xc2 : 0x01;
     1097        }
    10591098        ptr = (unsigned char *) &chip->image;
    10601099        snd_cs4231_mce_down(chip);
     
    13771416        case CS4231_HW_OPL3SA2: return chip->card->shortname;
    13781417        case CS4231_HW_AD1845: return "AD1845";
     1418        case CS4231_HW_OPTI93X: return "OPTi 93x";
    13791419        default: return "???";
    13801420        }
     
    14021442        chip->set_playback_format = snd_cs4231_playback_format;
    14031443        chip->set_capture_format = snd_cs4231_capture_format;
    1404         memcpy(&chip->image, &snd_cs4231_original_image, sizeof(snd_cs4231_original_image));
    1405        
     1444        if (chip->hardware == CS4231_HW_OPTI93X)
     1445                memcpy(&chip->image, &snd_opti93x_original_image,
     1446                       sizeof(snd_opti93x_original_image));
     1447        else
     1448                memcpy(&chip->image, &snd_cs4231_original_image,
     1449                       sizeof(snd_cs4231_original_image));
     1450
    14061451        *rchip = chip;
    14071452        return 0;
     
    17911836};
    17921837                                       
     1838static struct snd_kcontrol_new snd_opti93x_controls[] = {
     1839CS4231_DOUBLE("Master Playback Switch", 0,
     1840              OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
     1841CS4231_DOUBLE("Master Playback Volume", 0,
     1842              OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
     1843CS4231_DOUBLE("PCM Playback Switch", 0,
     1844              CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
     1845CS4231_DOUBLE("PCM Playback Volume", 0,
     1846              CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1),
     1847CS4231_DOUBLE("FM Playback Switch", 0,
     1848              CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
     1849CS4231_DOUBLE("FM Playback Volume", 0,
     1850              CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1),
     1851CS4231_DOUBLE("Line Playback Switch", 0,
     1852              CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
     1853CS4231_DOUBLE("Line Playback Volume", 0,
     1854              CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1),
     1855CS4231_DOUBLE("Mic Playback Switch", 0,
     1856              OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1),
     1857CS4231_DOUBLE("Mic Playback Volume", 0,
     1858              OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1),
     1859CS4231_DOUBLE("Mic Boost", 0,
     1860              CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0),
     1861CS4231_DOUBLE("CD Playback Switch", 0,
     1862              CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
     1863CS4231_DOUBLE("CD Playback Volume", 0,
     1864              CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1),
     1865CS4231_DOUBLE("Aux Playback Switch", 0,
     1866              OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1),
     1867CS4231_DOUBLE("Aux Playback Volume", 0,
     1868              OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1),
     1869CS4231_DOUBLE("Capture Volume", 0,
     1870              CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0),
     1871{
     1872        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1873        .name = "Capture Source",
     1874        .info = snd_cs4231_info_mux,
     1875        .get = snd_cs4231_get_mux,
     1876        .put = snd_cs4231_put_mux,
     1877}
     1878};
     1879
    17931880int snd_cs4231_mixer(struct snd_cs4231 *chip)
    17941881{
     
    18031890        strcpy(card->mixername, chip->pcm->name);
    18041891
    1805         for (idx = 0; idx < ARRAY_SIZE(snd_cs4231_controls); idx++) {
    1806                 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4231_controls[idx], chip))) < 0)
    1807                         return err;
    1808         }
     1892        if (chip->hardware == CS4231_HW_OPTI93X)
     1893                for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) {
     1894                        err = snd_ctl_add(card,
     1895                                        snd_ctl_new1(&snd_opti93x_controls[idx],
     1896                                                     chip));
     1897                        if (err < 0)
     1898                                return err;
     1899                }
     1900        else
     1901                for (idx = 0; idx < ARRAY_SIZE(snd_cs4231_controls); idx++) {
     1902                        err = snd_ctl_add(card,
     1903                                        snd_ctl_new1(&snd_cs4231_controls[idx],
     1904                                                     chip));
     1905                        if (err < 0)
     1906                                return err;
     1907                }
    18091908        return 0;
    18101909}
     
    18161915EXPORT_SYMBOL(snd_cs4231_mce_up);
    18171916EXPORT_SYMBOL(snd_cs4231_mce_down);
     1917EXPORT_SYMBOL(snd_cs4231_overrange);
    18181918EXPORT_SYMBOL(snd_cs4231_interrupt);
    18191919EXPORT_SYMBOL(snd_cs4231_chip_id);
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/opti9xx/opti92x-ad1848.c

    r305 r358  
    3434#include <asm/dma.h>
    3535#include <sound/core.h>
    36 #ifdef CS4231
     36#if defined(CS4231) || defined(OPTi93X)
    3737#include <sound/cs4231.h>
    3838#else
    39 #ifndef OPTi93X
    4039#include <sound/ad1848.h>
    41 #else
    42 #include <sound/control.h>
    43 #include <sound/pcm.h>
    44 #endif  /* OPTi93X */
    4540#endif  /* CS4231 */
    4641#include <sound/mpu401.h>
     
    110105#endif  /* CS4231 || OPTi93X */
    111106
    112 #define OPTi9XX_HW_DETECT       0
    113107#define OPTi9XX_HW_82C928       1
    114108#define OPTi9XX_HW_82C929       2
     
    124118#ifdef OPTi93X
    125119
    126 #define OPTi93X_INDEX                   0x00
    127 #define OPTi93X_DATA                    0x01
    128120#define OPTi93X_STATUS                  0x02
    129 #define OPTi93X_DDATA                   0x03
    130121#define OPTi93X_PORT(chip, r)           ((chip)->port + OPTi93X_##r)
    131 
    132 #define OPTi93X_MIXOUT_LEFT             0x00
    133 #define OPTi93X_MIXOUT_RIGHT            0x01
    134 #define OPTi93X_CD_LEFT_INPUT           0x02
    135 #define OPTi93X_CD_RIGHT_INPUT          0x03
    136 #define OPTi930_AUX_LEFT_INPUT          0x04
    137 #define OPTi930_AUX_RIGHT_INPUT         0x05
    138 #define OPTi931_FM_LEFT_INPUT           0x04
    139 #define OPTi931_FM_RIGHT_INPUT          0x05
    140 #define OPTi93X_DAC_LEFT                0x06
    141 #define OPTi93X_DAC_RIGHT               0x07
    142 #define OPTi93X_PLAY_FORMAT             0x08
    143 #define OPTi93X_IFACE_CONF              0x09
    144 #define OPTi93X_PIN_CTRL                0x0a
    145 #define OPTi93X_ERR_INIT                0x0b
    146 #define OPTi93X_ID                      0x0c
    147 #define OPTi93X_PLAY_UPR_CNT            0x0e
    148 #define OPTi93X_PLAY_LWR_CNT            0x0f
    149 #define OPTi931_AUX_LEFT_INPUT          0x10
    150 #define OPTi931_AUX_RIGHT_INPUT         0x11
    151 #define OPTi93X_LINE_LEFT_INPUT         0x12
    152 #define OPTi93X_LINE_RIGHT_INPUT        0x13
    153 #define OPTi93X_MIC_LEFT_INPUT          0x14
    154 #define OPTi93X_MIC_RIGHT_INPUT         0x15
    155 #define OPTi93X_OUT_LEFT                0x16
    156 #define OPTi93X_OUT_RIGHT               0x17
    157 #define OPTi93X_CAPT_FORMAT             0x1c
    158 #define OPTi93X_CAPT_UPR_CNT            0x1e
    159 #define OPTi93X_CAPT_LWR_CNT            0x1f
    160 
    161 #define OPTi93X_TRD                     0x20
    162 #define OPTi93X_MCE                     0x40
    163 #define OPTi93X_INIT                    0x80
    164 
    165 #define OPTi93X_MIXOUT_MIC_GAIN         0x20
    166 #define OPTi93X_MIXOUT_LINE             0x00
    167 #define OPTi93X_MIXOUT_CD               0x40
    168 #define OPTi93X_MIXOUT_MIC              0x80
    169 #define OPTi93X_MIXOUT_MIXER            0xc0
    170 
    171 #define OPTi93X_STEREO                  0x10
    172 #define OPTi93X_LINEAR_8                0x00
    173 #define OPTi93X_ULAW_8                  0x20
    174 #define OPTi93X_LINEAR_16_LIT           0x40
    175 #define OPTi93X_ALAW_8                  0x60
    176 #define OPTi93X_ADPCM_16                0xa0
    177 #define OPTi93X_LINEAR_16_BIG           0xc0
    178 
    179 #define OPTi93X_CAPTURE_PIO             0x80
    180 #define OPTi93X_PLAYBACK_PIO            0x40
    181 #define OPTi93X_AUTOCALIB               0x08
    182 #define OPTi93X_SINGLE_DMA              0x04
    183 #define OPTi93X_CAPTURE_ENABLE          0x02
    184 #define OPTi93X_PLAYBACK_ENABLE         0x01
    185 
    186 #define OPTi93X_IRQ_ENABLE              0x02
    187 
    188 #define OPTi93X_DMA_REQUEST             0x10
    189 #define OPTi93X_CALIB_IN_PROGRESS       0x20
    190122
    191123#define OPTi93X_IRQ_PLAYBACK            0x04
    192124#define OPTi93X_IRQ_CAPTURE             0x08
    193 
    194 
    195 struct snd_opti93x {
    196         unsigned long port;
    197         struct resource *res_port;
    198         int irq;
    199         int dma1;
    200         int dma2;
    201 
    202         struct snd_opti9xx *chip;
    203         unsigned short hardware;
    204         unsigned char image[32];
    205 
    206         unsigned char mce_bit;
    207         unsigned short mode;
    208         int mute;
    209 
    210         spinlock_t lock;
    211 
    212         struct snd_card *card;
    213         struct snd_pcm *pcm;
    214         struct snd_pcm_substream *playback_substream;
    215         struct snd_pcm_substream *capture_substream;
    216         unsigned int p_dma_size;
    217         unsigned int c_dma_size;
    218 };
    219 
    220 #define OPTi93X_MODE_NONE       0x00
    221 #define OPTi93X_MODE_PLAY       0x01
    222 #define OPTi93X_MODE_CAPTURE    0x02
    223 #define OPTi93X_MODE_OPEN       (OPTi93X_MODE_PLAY | OPTi93X_MODE_CAPTURE)
    224125
    225126#endif /* OPTi93X */
     
    235136#ifdef OPTi93X
    236137        unsigned long mc_indir_index;
     138        struct snd_cs4231 *codec;
    237139#endif  /* OPTi93X */
    238140        unsigned long pwd_reg;
     
    492394
    493395#else   /* OPTi93X */
    494         case OPTi9XX_HW_82C930:
    495396        case OPTi9XX_HW_82C931:
    496397        case OPTi9XX_HW_82C933:
    497                 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x03);
    498                 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0x00, 0xff);
    499                 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0x10 |
    500                         (chip->hardware == OPTi9XX_HW_82C930 ? 0x00 : 0x04),
    501                         0x34);
    502                 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x20, 0xbf);
    503                 /*
     398                /*
    504399                 * The BTC 1817DW has QS1000 wavetable which is connected
    505400                 * to the serial digital input of the OPTI931.
     
    511406                 */
    512407                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(26), 0x01, 0x01);
     408        case OPTi9XX_HW_82C930: /* FALL THROUGH */
     409                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x03);
     410                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0x00, 0xff);
     411                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0x10 |
     412                        (chip->hardware == OPTi9XX_HW_82C930 ? 0x00 : 0x04),
     413                        0x34);
     414                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x20, 0xbf);
    513415                break;
    514416#endif  /* OPTi93X */
     
    655557#ifdef OPTi93X
    656558
    657 static unsigned char snd_opti93x_default_image[32] =
    658 {
    659         0x00,           /* 00/00 - l_mixout_outctrl */
    660         0x00,           /* 01/01 - r_mixout_outctrl */
    661         0x88,           /* 02/02 - l_cd_inctrl */
    662         0x88,           /* 03/03 - r_cd_inctrl */
    663         0x88,           /* 04/04 - l_a1/fm_inctrl */
    664         0x88,           /* 05/05 - r_a1/fm_inctrl */
    665         0x80,           /* 06/06 - l_dac_inctrl */
    666         0x80,           /* 07/07 - r_dac_inctrl */
    667         0x00,           /* 08/08 - ply_dataform_reg */
    668         0x00,           /* 09/09 - if_conf */
    669         0x00,           /* 0a/10 - pin_ctrl */
    670         0x00,           /* 0b/11 - err_init_reg */
    671         0x0a,           /* 0c/12 - id_reg */
    672         0x00,           /* 0d/13 - reserved */
    673         0x00,           /* 0e/14 - ply_upcount_reg */
    674         0x00,           /* 0f/15 - ply_lowcount_reg */
    675         0x88,           /* 10/16 - reserved/l_a1_inctrl */
    676         0x88,           /* 11/17 - reserved/r_a1_inctrl */
    677         0x88,           /* 12/18 - l_line_inctrl */
    678         0x88,           /* 13/19 - r_line_inctrl */
    679         0x88,           /* 14/20 - l_mic_inctrl */
    680         0x88,           /* 15/21 - r_mic_inctrl */
    681         0x80,           /* 16/22 - l_out_outctrl */
    682         0x80,           /* 17/23 - r_out_outctrl */
    683         0x00,           /* 18/24 - reserved */
    684         0x00,           /* 19/25 - reserved */
    685         0x00,           /* 1a/26 - reserved */
    686         0x00,           /* 1b/27 - reserved */
    687         0x00,           /* 1c/28 - cap_dataform_reg */
    688         0x00,           /* 1d/29 - reserved */
    689         0x00,           /* 1e/30 - cap_upcount_reg */
    690         0x00            /* 1f/31 - cap_lowcount_reg */
    691 };
    692 
    693 
    694 static int snd_opti93x_busy_wait(struct snd_opti93x *chip)
    695 {
    696         int timeout;
    697 
    698         for (timeout = 250; timeout-- > 0; udelay(10))
    699                 if (!(inb(OPTi93X_PORT(chip, INDEX)) & OPTi93X_INIT))
    700                         return 0;
    701 
    702         snd_printk("chip still busy.\n");
    703         return -EBUSY;
    704 }
    705 
    706 static unsigned char snd_opti93x_in(struct snd_opti93x *chip, unsigned char reg)
    707 {
    708         snd_opti93x_busy_wait(chip);
    709         outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX));
    710         return inb(OPTi93X_PORT(chip, DATA));
    711 }
    712 
    713 static void snd_opti93x_out(struct snd_opti93x *chip, unsigned char reg,
    714                             unsigned char value)
    715 {
    716         snd_opti93x_busy_wait(chip);
    717         outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX));
    718         outb(value, OPTi93X_PORT(chip, DATA));
    719 }
    720 
    721 static void snd_opti93x_out_image(struct snd_opti93x *chip, unsigned char reg,
    722                                   unsigned char value)
    723 {
    724         snd_opti93x_out(chip, reg, chip->image[reg] = value);
    725 }
    726 
    727 static void snd_opti93x_out_mask(struct snd_opti93x *chip, unsigned char reg,
    728                                  unsigned char mask, unsigned char value)
    729 {
    730         snd_opti93x_out_image(chip, reg,
    731                 (chip->image[reg] & ~mask) | (value & mask));
    732 }
    733 
    734 
    735 static void snd_opti93x_mce_up(struct snd_opti93x *chip)
    736 {
    737         snd_opti93x_busy_wait(chip);
    738 
    739         chip->mce_bit = OPTi93X_MCE;
    740         if (!(inb(OPTi93X_PORT(chip, INDEX)) & OPTi93X_MCE))
    741                 outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX));
    742 }
    743 
    744 static void snd_opti93x_mce_down(struct snd_opti93x *chip)
    745 {
    746         snd_opti93x_busy_wait(chip);
    747 
    748         chip->mce_bit = 0;
    749         if (inb(OPTi93X_PORT(chip, INDEX)) & OPTi93X_MCE)
    750                 outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX));
    751 }
    752 
    753 #define snd_opti93x_mute_reg(chip, reg, mute)   \
    754         snd_opti93x_out(chip, reg, mute ? 0x80 : chip->image[reg]);
    755 
    756 static void snd_opti93x_mute(struct snd_opti93x *chip, int mute)
    757 {
    758         mute = mute ? 1 : 0;
    759         if (chip->mute == mute)
    760                 return;
    761 
    762         chip->mute = mute;
    763 
    764         snd_opti93x_mute_reg(chip, OPTi93X_CD_LEFT_INPUT, mute);
    765         snd_opti93x_mute_reg(chip, OPTi93X_CD_RIGHT_INPUT, mute);
    766         switch (chip->hardware) {
    767         case OPTi9XX_HW_82C930:
    768                 snd_opti93x_mute_reg(chip, OPTi930_AUX_LEFT_INPUT, mute);
    769                 snd_opti93x_mute_reg(chip, OPTi930_AUX_RIGHT_INPUT, mute);
    770                 break;
    771         case OPTi9XX_HW_82C931:
    772         case OPTi9XX_HW_82C933:
    773                 snd_opti93x_mute_reg(chip, OPTi931_FM_LEFT_INPUT, mute);
    774                 snd_opti93x_mute_reg(chip, OPTi931_FM_RIGHT_INPUT, mute);
    775                 snd_opti93x_mute_reg(chip, OPTi931_AUX_LEFT_INPUT, mute);
    776                 snd_opti93x_mute_reg(chip, OPTi931_AUX_RIGHT_INPUT, mute);
    777         }
    778         snd_opti93x_mute_reg(chip, OPTi93X_DAC_LEFT, mute);
    779         snd_opti93x_mute_reg(chip, OPTi93X_DAC_RIGHT, mute);
    780         snd_opti93x_mute_reg(chip, OPTi93X_LINE_LEFT_INPUT, mute);
    781         snd_opti93x_mute_reg(chip, OPTi93X_LINE_RIGHT_INPUT, mute);
    782         snd_opti93x_mute_reg(chip, OPTi93X_MIC_LEFT_INPUT, mute);
    783         snd_opti93x_mute_reg(chip, OPTi93X_MIC_RIGHT_INPUT, mute);
    784         snd_opti93x_mute_reg(chip, OPTi93X_OUT_LEFT, mute);
    785         snd_opti93x_mute_reg(chip, OPTi93X_OUT_RIGHT, mute);
    786 }
    787 
    788 
    789 static unsigned int snd_opti93x_get_count(unsigned char format,
    790                                           unsigned int size)
    791 {
    792         switch (format & 0xe0) {
    793         case OPTi93X_LINEAR_16_LIT:
    794         case OPTi93X_LINEAR_16_BIG:
    795                 size >>= 1;
    796                 break;
    797         case OPTi93X_ADPCM_16:
    798                 return size >> 2;
    799         }
    800         return (format & OPTi93X_STEREO) ? (size >> 1) : size;
    801 }
    802 
    803 static unsigned int rates[] = {  5512,  6615,  8000,  9600, 11025, 16000,
    804                                 18900, 22050, 27428, 32000, 33075, 37800,
    805                                 44100, 48000 };
    806 #define RATES ARRAY_SIZE(rates)
    807 
    808 static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
    809         .count = RATES,
    810         .list = rates,
    811         .mask = 0,
    812 };
    813 
    814 static unsigned char bits[] = {  0x01,  0x0f,  0x00,  0x0e,  0x03,  0x02,
    815                                  0x05,  0x07,  0x04,  0x06,  0x0d,  0x09,
    816                                  0x0b,  0x0c};
    817 
    818 static unsigned char snd_opti93x_get_freq(unsigned int rate)
    819 {
    820         unsigned int i;
    821 
    822         for (i = 0; i < RATES; i++) {
    823                 if (rate == rates[i])
    824                         return bits[i];
    825         }
    826         snd_BUG();
    827         return bits[RATES-1];
    828 }
    829 
    830 static unsigned char snd_opti93x_get_format(struct snd_opti93x *chip,
    831                                             unsigned int format, int channels)
    832 {
    833         unsigned char retval = OPTi93X_LINEAR_8;
    834 
    835         switch (format) {
    836         case SNDRV_PCM_FORMAT_MU_LAW:
    837                 retval = OPTi93X_ULAW_8;
    838                 break;
    839         case SNDRV_PCM_FORMAT_A_LAW:
    840                 retval = OPTi93X_ALAW_8;
    841                 break;
    842         case SNDRV_PCM_FORMAT_S16_LE:
    843                 retval = OPTi93X_LINEAR_16_LIT;
    844                 break;
    845         case SNDRV_PCM_FORMAT_S16_BE:
    846                 retval = OPTi93X_LINEAR_16_BIG;
    847                 break;
    848         case SNDRV_PCM_FORMAT_IMA_ADPCM:
    849                 retval = OPTi93X_ADPCM_16;
    850         }
    851         return (channels > 1) ? (retval | OPTi93X_STEREO) : retval;
    852 }
    853 
    854 
    855 static void snd_opti93x_playback_format(struct snd_opti93x *chip, unsigned char fmt)
    856 {
    857         unsigned char mask;
    858 
    859         snd_opti93x_mute(chip, 1);
    860 
    861         snd_opti93x_mce_up(chip);
    862         mask = (chip->mode & OPTi93X_MODE_CAPTURE) ? 0xf0 : 0xff;
    863         snd_opti93x_out_mask(chip, OPTi93X_PLAY_FORMAT, mask, fmt);
    864         snd_opti93x_mce_down(chip);
    865 
    866         snd_opti93x_mute(chip, 0);
    867 }
    868 
    869 static void snd_opti93x_capture_format(struct snd_opti93x *chip, unsigned char fmt)
    870 {
    871         snd_opti93x_mute(chip, 1);
    872 
    873         snd_opti93x_mce_up(chip);
    874         if (!(chip->mode & OPTi93X_MODE_PLAY))
    875                 snd_opti93x_out_mask(chip, OPTi93X_PLAY_FORMAT, 0x0f, fmt);
    876         else
    877                 fmt = chip->image[OPTi93X_PLAY_FORMAT] & 0xf0;
    878         snd_opti93x_out_image(chip, OPTi93X_CAPT_FORMAT, fmt);
    879         snd_opti93x_mce_down(chip);
    880 
    881         snd_opti93x_mute(chip, 0);
    882 }
    883 
    884 
    885 static int snd_opti93x_open(struct snd_opti93x *chip, unsigned int mode)
    886 {
    887         unsigned long flags;
    888 
    889         spin_lock_irqsave(&chip->lock, flags);
    890 
    891         if (chip->mode & mode) {
    892                 spin_unlock_irqrestore(&chip->lock, flags);
    893                 return -EAGAIN;
    894         }
    895 
    896         if (!(chip->mode & OPTi93X_MODE_OPEN)) {
    897                 outb(0x00, OPTi93X_PORT(chip, STATUS));
    898                 snd_opti93x_out_mask(chip, OPTi93X_PIN_CTRL,
    899                         OPTi93X_IRQ_ENABLE, OPTi93X_IRQ_ENABLE);
    900                 chip->mode = mode;
    901         }
    902         else
    903                 chip->mode |= mode;
    904 
    905         spin_unlock_irqrestore(&chip->lock, flags);
    906         return 0;
    907 }
    908 
    909 static void snd_opti93x_close(struct snd_opti93x *chip, unsigned int mode)
    910 {
    911         unsigned long flags;
    912 
    913         spin_lock_irqsave(&chip->lock, flags);
    914 
    915         chip->mode &= ~mode;
    916         if (chip->mode & OPTi93X_MODE_OPEN) {
    917                 spin_unlock_irqrestore(&chip->lock, flags);
    918                 return;
    919         }
    920 
    921         snd_opti93x_mute(chip, 1);
    922 
    923         outb(0, OPTi93X_PORT(chip, STATUS));
    924         snd_opti93x_out_mask(chip, OPTi93X_PIN_CTRL, OPTi93X_IRQ_ENABLE,
    925                 ~OPTi93X_IRQ_ENABLE);
    926 
    927         snd_opti93x_mce_up(chip);
    928         snd_opti93x_out_image(chip, OPTi93X_IFACE_CONF, 0x00);
    929         snd_opti93x_mce_down(chip);
    930         chip->mode = 0;
    931 
    932         snd_opti93x_mute(chip, 0);
    933         spin_unlock_irqrestore(&chip->lock, flags);
    934 }
    935 
    936 static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
    937                                unsigned char what, int cmd)
    938 {
    939         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    940 
    941         switch (cmd) {
    942         case SNDRV_PCM_TRIGGER_START:
    943         case SNDRV_PCM_TRIGGER_STOP:
    944         {
    945                 unsigned int what = 0;
    946                 struct snd_pcm_substream *s;
    947                 snd_pcm_group_for_each_entry(s, substream) {
    948                         if (s == chip->playback_substream) {
    949                                 what |= OPTi93X_PLAYBACK_ENABLE;
    950                                 snd_pcm_trigger_done(s, substream);
    951                         } else if (s == chip->capture_substream) {
    952                                 what |= OPTi93X_CAPTURE_ENABLE;
    953                                 snd_pcm_trigger_done(s, substream);
    954                         }
    955                 }
    956                 spin_lock(&chip->lock);
    957                 if (cmd == SNDRV_PCM_TRIGGER_START) {
    958                         snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF, what, what);
    959                         if (what & OPTi93X_CAPTURE_ENABLE)
    960                                 udelay(50);
    961                 } else
    962                         snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF, what, 0x00);
    963                 spin_unlock(&chip->lock);
    964                 break;
    965         }
    966         default:
    967                 return -EINVAL;
    968         }
    969         return 0;
    970 }
    971 
    972 static int snd_opti93x_playback_trigger(struct snd_pcm_substream *substream, int cmd)
    973 {
    974         return snd_opti93x_trigger(substream,
    975                                    OPTi93X_PLAYBACK_ENABLE, cmd);
    976 }
    977 
    978 static int snd_opti93x_capture_trigger(struct snd_pcm_substream *substream, int cmd)
    979 {
    980         return snd_opti93x_trigger(substream,
    981                                    OPTi93X_CAPTURE_ENABLE, cmd);
    982 }
    983 
    984 static int snd_opti93x_hw_params(struct snd_pcm_substream *substream,
    985                                  struct snd_pcm_hw_params *hw_params)
    986 {
    987         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    988 }
    989 
    990 
    991 static int snd_opti93x_hw_free(struct snd_pcm_substream *substream)
    992 {
    993         snd_pcm_lib_free_pages(substream);
    994         return 0;
    995 }
    996 
    997 
    998 static int snd_opti93x_playback_prepare(struct snd_pcm_substream *substream)
    999 {
    1000         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1001         struct snd_pcm_runtime *runtime = substream->runtime;
    1002         unsigned long flags;
    1003         unsigned char format;
    1004         unsigned int count = snd_pcm_lib_period_bytes(substream);
    1005         unsigned int size = snd_pcm_lib_buffer_bytes(substream);
    1006 
    1007         spin_lock_irqsave(&chip->lock, flags);
    1008 
    1009         chip->p_dma_size = size;
    1010         snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF,
    1011                 OPTi93X_PLAYBACK_ENABLE | OPTi93X_PLAYBACK_PIO,
    1012                 ~(OPTi93X_PLAYBACK_ENABLE | OPTi93X_PLAYBACK_PIO));
    1013 
    1014         snd_dma_program(chip->dma1, runtime->dma_addr, size,
    1015                 DMA_MODE_WRITE | DMA_AUTOINIT);
    1016 
    1017         format = snd_opti93x_get_freq(runtime->rate);
    1018         format |= snd_opti93x_get_format(chip, runtime->format,
    1019                 runtime->channels);
    1020         snd_opti93x_playback_format(chip, format);
    1021         format = chip->image[OPTi93X_PLAY_FORMAT];
    1022 
    1023         count = snd_opti93x_get_count(format, count) - 1;
    1024         snd_opti93x_out_image(chip, OPTi93X_PLAY_LWR_CNT, count);
    1025         snd_opti93x_out_image(chip, OPTi93X_PLAY_UPR_CNT, count >> 8);
    1026 
    1027         spin_unlock_irqrestore(&chip->lock, flags);
    1028         return 0;
    1029 }
    1030 
    1031 static int snd_opti93x_capture_prepare(struct snd_pcm_substream *substream)
    1032 {
    1033         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1034         struct snd_pcm_runtime *runtime = substream->runtime;
    1035         unsigned long flags;
    1036         unsigned char format;
    1037         unsigned int count = snd_pcm_lib_period_bytes(substream);
    1038         unsigned int size = snd_pcm_lib_buffer_bytes(substream);
    1039 
    1040         spin_lock_irqsave(&chip->lock, flags);
    1041 
    1042         chip->c_dma_size = size;
    1043         snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF,
    1044                 OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO, 0);
    1045 
    1046         snd_dma_program(chip->dma2, runtime->dma_addr, size,
    1047                 DMA_MODE_READ | DMA_AUTOINIT);
    1048 
    1049         format = snd_opti93x_get_freq(runtime->rate);
    1050         format |= snd_opti93x_get_format(chip, runtime->format,
    1051                 runtime->channels);
    1052         snd_opti93x_capture_format(chip, format);
    1053         format = chip->image[OPTi93X_CAPT_FORMAT];
    1054 
    1055         count = snd_opti93x_get_count(format, count) - 1;
    1056         snd_opti93x_out_image(chip, OPTi93X_CAPT_LWR_CNT, count);
    1057         snd_opti93x_out_image(chip, OPTi93X_CAPT_UPR_CNT, count >> 8);
    1058 
    1059         spin_unlock_irqrestore(&chip->lock, flags);
    1060         return 0;
    1061 }
    1062 
    1063 static snd_pcm_uframes_t snd_opti93x_playback_pointer(struct snd_pcm_substream *substream)
    1064 {
    1065         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1066         size_t ptr;
    1067 
    1068         if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE))
    1069                 return 0;
    1070 
    1071         ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size);
    1072         return bytes_to_frames(substream->runtime, ptr);
    1073 }
    1074 
    1075 static snd_pcm_uframes_t snd_opti93x_capture_pointer(struct snd_pcm_substream *substream)
    1076 {
    1077         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1078         size_t ptr;
    1079        
    1080         if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE))
    1081                 return 0;
    1082 
    1083         ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
    1084         return bytes_to_frames(substream->runtime, ptr);
    1085 }
    1086 
    1087 
    1088 static void snd_opti93x_overrange(struct snd_opti93x *chip)
    1089 {
    1090         unsigned long flags;
    1091 
    1092         spin_lock_irqsave(&chip->lock, flags);
    1093 
    1094         if (snd_opti93x_in(chip, OPTi93X_ERR_INIT) & (0x08 | 0x02))
    1095                 chip->capture_substream->runtime->overrange++;
    1096 
    1097         spin_unlock_irqrestore(&chip->lock, flags);
    1098 }
    1099 
    1100559static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id)
    1101560{
    1102         struct snd_opti93x *codec = dev_id;
     561        struct snd_cs4231 *codec = dev_id;
     562        struct snd_opti9xx *chip = codec->card->private_data;
    1103563        unsigned char status;
    1104564
    1105         status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11));
     565        status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11));
    1106566        if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream)
    1107567                snd_pcm_period_elapsed(codec->playback_substream);
    1108568        if ((status & OPTi93X_IRQ_CAPTURE) && codec->capture_substream) {
    1109                 snd_opti93x_overrange(codec);
     569                snd_cs4231_overrange(codec);
    1110570                snd_pcm_period_elapsed(codec->capture_substream);
    1111571        }
    1112572        outb(0x00, OPTi93X_PORT(codec, STATUS));
    1113573        return IRQ_HANDLED;
    1114 }
    1115 
    1116 
    1117 static struct snd_pcm_hardware snd_opti93x_playback = {
    1118         .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
    1119                                  SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
    1120         .formats =              (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
    1121                                  SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE),
    1122         .rates =                SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000,
    1123         .rate_min =             5512,
    1124         .rate_max =             48000,
    1125         .channels_min =         1,
    1126         .channels_max =         2,
    1127         .buffer_bytes_max =     (128*1024),
    1128         .period_bytes_min =     64,
    1129         .period_bytes_max =     (128*1024),
    1130         .periods_min =          1,
    1131         .periods_max =          1024,
    1132         .fifo_size =            0,
    1133 };
    1134 
    1135 static struct snd_pcm_hardware snd_opti93x_capture = {
    1136         .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
    1137                                  SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
    1138         .formats =              (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
    1139                                  SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE),
    1140         .rates =                SNDRV_PCM_RATE_8000_48000,
    1141         .rate_min =             5512,
    1142         .rate_max =             48000,
    1143         .channels_min =         1,
    1144         .channels_max =         2,
    1145         .buffer_bytes_max =     (128*1024),
    1146         .period_bytes_min =     64,
    1147         .period_bytes_max =     (128*1024),
    1148         .periods_min =          1,
    1149         .periods_max =          1024,
    1150         .fifo_size =            0,
    1151 };
    1152 
    1153 static int snd_opti93x_playback_open(struct snd_pcm_substream *substream)
    1154 {
    1155         int error;
    1156         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1157         struct snd_pcm_runtime *runtime = substream->runtime;
    1158 
    1159         if ((error = snd_opti93x_open(chip, OPTi93X_MODE_PLAY)) < 0)
    1160                 return error;
    1161         snd_pcm_set_sync(substream);
    1162         chip->playback_substream = substream;
    1163         runtime->hw = snd_opti93x_playback;
    1164         snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max);
    1165         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
    1166         return error;
    1167 }
    1168 
    1169 static int snd_opti93x_capture_open(struct snd_pcm_substream *substream)
    1170 {
    1171         int error;
    1172         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1173         struct snd_pcm_runtime *runtime = substream->runtime;
    1174 
    1175         if ((error = snd_opti93x_open(chip, OPTi93X_MODE_CAPTURE)) < 0)
    1176                 return error;
    1177         runtime->hw = snd_opti93x_capture;
    1178         snd_pcm_set_sync(substream);
    1179         chip->capture_substream = substream;
    1180         snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max);
    1181         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
    1182         return error;
    1183 }
    1184 
    1185 static int snd_opti93x_playback_close(struct snd_pcm_substream *substream)
    1186 {
    1187         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1188 
    1189         chip->playback_substream = NULL;
    1190         snd_opti93x_close(chip, OPTi93X_MODE_PLAY);
    1191         return 0;
    1192 }
    1193 
    1194 static int snd_opti93x_capture_close(struct snd_pcm_substream *substream)
    1195 {
    1196         struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
    1197 
    1198         chip->capture_substream = NULL;
    1199         snd_opti93x_close(chip, OPTi93X_MODE_CAPTURE);
    1200         return 0;
    1201 }
    1202 
    1203 
    1204 static void snd_opti93x_init(struct snd_opti93x *chip)
    1205 {
    1206         unsigned long flags;
    1207         int i;
    1208 
    1209         spin_lock_irqsave(&chip->lock, flags);
    1210         snd_opti93x_mce_up(chip);
    1211 
    1212         for (i = 0; i < 32; i++)
    1213                 snd_opti93x_out_image(chip, i, snd_opti93x_default_image[i]);
    1214 
    1215         snd_opti93x_mce_down(chip);
    1216         spin_unlock_irqrestore(&chip->lock, flags);
    1217 }
    1218 
    1219 static int snd_opti93x_probe(struct snd_opti93x *chip)
    1220 {
    1221         unsigned long flags;
    1222         unsigned char val;
    1223 
    1224         spin_lock_irqsave(&chip->lock, flags);
    1225         val = snd_opti93x_in(chip, OPTi93X_ID) & 0x0f;
    1226         spin_unlock_irqrestore(&chip->lock, flags);
    1227 
    1228         return (val == 0x0a) ? 0 : -ENODEV;
    1229 }
    1230 
    1231 static int snd_opti93x_free(struct snd_opti93x *chip)
    1232 {
    1233         release_and_free_resource(chip->res_port);
    1234         if (chip->dma1 >= 0) {
    1235                 disable_dma(chip->dma1);
    1236                 free_dma(chip->dma1);
    1237         }
    1238         if (chip->dma2 >= 0) {
    1239                 disable_dma(chip->dma2);
    1240                 free_dma(chip->dma2);
    1241         }
    1242         if (chip->irq >= 0) {
    1243           free_irq(chip->irq, chip);
    1244         }
    1245         kfree(chip);
    1246         return 0;
    1247 }
    1248 
    1249 static int snd_opti93x_dev_free(struct snd_device *device)
    1250 {
    1251         struct snd_opti93x *chip = device->device_data;
    1252         return snd_opti93x_free(chip);
    1253 }
    1254 
    1255 static const char *snd_opti93x_chip_id(struct snd_opti93x *codec)
    1256 {
    1257         switch (codec->hardware) {
    1258         case OPTi9XX_HW_82C930: return "82C930";
    1259         case OPTi9XX_HW_82C931: return "82C931";
    1260         case OPTi9XX_HW_82C933: return "82C933";
    1261         default:                return "???";
    1262         }
    1263 }
    1264 
    1265 static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip,
    1266                               int dma1, int dma2,
    1267                               struct snd_opti93x **rcodec)
    1268 {
    1269         static struct snd_device_ops ops = {
    1270                 .dev_free =     snd_opti93x_dev_free,
    1271         };
    1272         int error;
    1273         struct snd_opti93x *codec;
    1274 
    1275         *rcodec = NULL;
    1276         codec = kzalloc(sizeof(*codec), GFP_KERNEL);
    1277         if (codec == NULL)
    1278                 return -ENOMEM;
    1279         codec->irq = -1;
    1280         codec->dma1 = -1;
    1281         codec->dma2 = -1;
    1282 
    1283         if ((codec->res_port = request_region(chip->wss_base + 4, 4, "OPTI93x CODEC")) == NULL) {
    1284                 snd_printk(KERN_ERR "opti9xx: can't grab port 0x%lx\n", chip->wss_base + 4);
    1285                 snd_opti93x_free(codec);
    1286                 return -EBUSY;
    1287         }
    1288         if (request_dma(dma1, "OPTI93x - 1")) {
    1289                 snd_printk(KERN_ERR "opti9xx: can't grab DMA1 %d\n", dma1);
    1290                 snd_opti93x_free(codec);
    1291                 return -EBUSY;
    1292         }
    1293         codec->dma1 = chip->dma1;
    1294         if (request_dma(dma2, "OPTI93x - 2")) {
    1295                 snd_printk(KERN_ERR "opti9xx: can't grab DMA2 %d\n", dma2);
    1296                 snd_opti93x_free(codec);
    1297                 return -EBUSY;
    1298         }
    1299         codec->dma2 = chip->dma2;
    1300 
    1301         if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DEV_NAME" - WSS", codec)) {
    1302                 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq);
    1303                 snd_opti93x_free(codec);
    1304                 return -EBUSY;
    1305         }
    1306 
    1307         codec->card = card;
    1308         codec->port = chip->wss_base + 4;
    1309         codec->irq = chip->irq;
    1310 
    1311         spin_lock_init(&codec->lock);
    1312         codec->hardware = chip->hardware;
    1313         codec->chip = chip;
    1314 
    1315         if ((error = snd_opti93x_probe(codec))) {
    1316                 snd_opti93x_free(codec);
    1317                 return error;
    1318         }
    1319 
    1320         snd_opti93x_init(codec);
    1321 
    1322         /* Register device */
    1323         if ((error = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops)) < 0) {
    1324                 snd_opti93x_free(codec);
    1325                 return error;
    1326         }
    1327 
    1328         *rcodec = codec;
    1329         return 0;
    1330 }
    1331 
    1332 static struct snd_pcm_ops snd_opti93x_playback_ops = {
    1333         .open =         snd_opti93x_playback_open,
    1334         .close =        snd_opti93x_playback_close,
    1335         .ioctl =        snd_pcm_lib_ioctl,
    1336         .hw_params =    snd_opti93x_hw_params,
    1337         .hw_free =      snd_opti93x_hw_free,
    1338         .prepare =      snd_opti93x_playback_prepare,
    1339         .trigger =      snd_opti93x_playback_trigger,
    1340         .pointer =      snd_opti93x_playback_pointer,
    1341 };
    1342 
    1343 static struct snd_pcm_ops snd_opti93x_capture_ops = {
    1344         .open =         snd_opti93x_capture_open,
    1345         .close =        snd_opti93x_capture_close,
    1346         .ioctl =        snd_pcm_lib_ioctl,
    1347         .hw_params =    snd_opti93x_hw_params,
    1348         .hw_free =      snd_opti93x_hw_free,
    1349         .prepare =      snd_opti93x_capture_prepare,
    1350         .trigger =      snd_opti93x_capture_trigger,
    1351         .pointer =      snd_opti93x_capture_pointer,
    1352 };
    1353 
    1354 static int snd_opti93x_pcm(struct snd_opti93x *codec, int device, struct snd_pcm **rpcm)
    1355 {
    1356         int error;
    1357         struct snd_pcm *pcm;
    1358 
    1359         if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm)) < 0)
    1360                 return error;
    1361 
    1362         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_opti93x_playback_ops);
    1363         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_opti93x_capture_ops);
    1364 
    1365         pcm->private_data = codec;
    1366         pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
    1367 
    1368         strcpy(pcm->name, snd_opti93x_chip_id(codec));
    1369 
    1370         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1371                                               snd_dma_isa_data(),
    1372                                               64*1024, codec->dma1 > 3 || codec->dma2 > 3 ? 128*1024 : 64*1024);
    1373 
    1374         codec->pcm = pcm;
    1375         if (rpcm)
    1376                 *rpcm = pcm;
    1377         return 0;
    1378 }
    1379 
    1380 /*
    1381  *  MIXER part
    1382  */
    1383 
    1384 static int snd_opti93x_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    1385 {
    1386         static char *texts[4] = {
    1387                 "Line1", "Aux", "Mic", "Mix"
    1388         };
    1389 
    1390         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    1391         uinfo->count = 2;
    1392         uinfo->value.enumerated.items = 4;
    1393         if (uinfo->value.enumerated.item > 3)
    1394                 uinfo->value.enumerated.item = 3;
    1395         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    1396         return 0;
    1397 }
    1398 
    1399 static int snd_opti93x_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1400 {
    1401         struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
    1402         unsigned long flags;
    1403        
    1404         spin_lock_irqsave(&chip->lock, flags);
    1405         ucontrol->value.enumerated.item[0] = (chip->image[OPTi93X_MIXOUT_LEFT] & OPTi93X_MIXOUT_MIXER) >> 6;
    1406         ucontrol->value.enumerated.item[1] = (chip->image[OPTi93X_MIXOUT_RIGHT] & OPTi93X_MIXOUT_MIXER) >> 6;
    1407         spin_unlock_irqrestore(&chip->lock, flags);
    1408         return 0;
    1409 }
    1410 
    1411 static int snd_opti93x_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1412 {
    1413         struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
    1414         unsigned long flags;
    1415         unsigned short left, right;
    1416         int change;
    1417        
    1418         if (ucontrol->value.enumerated.item[0] > 3 ||
    1419             ucontrol->value.enumerated.item[1] > 3)
    1420                 return -EINVAL;
    1421         left = ucontrol->value.enumerated.item[0] << 6;
    1422         right = ucontrol->value.enumerated.item[1] << 6;
    1423         spin_lock_irqsave(&chip->lock, flags);
    1424         left = (chip->image[OPTi93X_MIXOUT_LEFT] & ~OPTi93X_MIXOUT_MIXER) | left;
    1425         right = (chip->image[OPTi93X_MIXOUT_RIGHT] & ~OPTi93X_MIXOUT_MIXER) | right;
    1426         change = left != chip->image[OPTi93X_MIXOUT_LEFT] ||
    1427                  right != chip->image[OPTi93X_MIXOUT_RIGHT];
    1428         snd_opti93x_out_image(chip, OPTi93X_MIXOUT_LEFT, left);
    1429         snd_opti93x_out_image(chip, OPTi93X_MIXOUT_RIGHT, right);
    1430         spin_unlock_irqrestore(&chip->lock, flags);
    1431         return change;
    1432 }
    1433 
    1434 #if 0
    1435 
    1436 #define OPTi93X_SINGLE(xname, xindex, reg, shift, mask, invert) \
    1437 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
    1438   .info = snd_opti93x_info_single, \
    1439   .get = snd_opti93x_get_single, .put = snd_opti93x_put_single, \
    1440   .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
    1441 
    1442 static int snd_opti93x_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    1443 {
    1444         int mask = (kcontrol->private_value >> 16) & 0xff;
    1445 
    1446         uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
    1447         uinfo->count = 1;
    1448         uinfo->value.integer.min = 0;
    1449         uinfo->value.integer.max = mask;
    1450         return 0;
    1451 }
    1452 
    1453 static int snd_opti93x_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1454 {
    1455         struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
    1456         unsigned long flags;
    1457         int reg = kcontrol->private_value & 0xff;
    1458         int shift = (kcontrol->private_value >> 8) & 0xff;
    1459         int mask = (kcontrol->private_value >> 16) & 0xff;
    1460         int invert = (kcontrol->private_value >> 24) & 0xff;
    1461        
    1462         spin_lock_irqsave(&chip->lock, flags);
    1463         ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask;
    1464         spin_unlock_irqrestore(&chip->lock, flags);
    1465         if (invert)
    1466                 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
    1467         return 0;
    1468 }
    1469 
    1470 static int snd_opti93x_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1471 {
    1472         struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
    1473         unsigned long flags;
    1474         int reg = kcontrol->private_value & 0xff;
    1475         int shift = (kcontrol->private_value >> 8) & 0xff;
    1476         int mask = (kcontrol->private_value >> 16) & 0xff;
    1477         int invert = (kcontrol->private_value >> 24) & 0xff;
    1478         int change;
    1479         unsigned short val;
    1480        
    1481         val = (ucontrol->value.integer.value[0] & mask);
    1482         if (invert)
    1483                 val = mask - val;
    1484         val <<= shift;
    1485         spin_lock_irqsave(&chip->lock, flags);
    1486         val = (chip->image[reg] & ~(mask << shift)) | val;
    1487         change = val != chip->image[reg];
    1488         snd_opti93x_out(chip, reg, val);
    1489         spin_unlock_irqrestore(&chip->lock, flags);
    1490         return change;
    1491 }
    1492 
    1493 #endif /* single */
    1494 
    1495 #define OPTi93X_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
    1496 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
    1497   .info = snd_opti93x_info_double, \
    1498   .get = snd_opti93x_get_double, .put = snd_opti93x_put_double, \
    1499   .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
    1500 
    1501 #define OPTi93X_DOUBLE_INVERT_INVERT(xctl) \
    1502         do { xctl.private_value ^= 22; } while (0)
    1503 #define OPTi93X_DOUBLE_CHANGE_REGS(xctl, left_reg, right_reg) \
    1504         do { xctl.private_value &= ~0x0000ffff; \
    1505              xctl.private_value |= left_reg | (right_reg << 8); } while (0)
    1506 
    1507 static int snd_opti93x_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    1508 {
    1509         int mask = (kcontrol->private_value >> 24) & 0xff;
    1510 
    1511         uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
    1512         uinfo->count = 2;
    1513         uinfo->value.integer.min = 0;
    1514         uinfo->value.integer.max = mask;
    1515         return 0;
    1516 }
    1517 
    1518 static int snd_opti93x_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1519 {
    1520         struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
    1521         unsigned long flags;
    1522         int left_reg = kcontrol->private_value & 0xff;
    1523         int right_reg = (kcontrol->private_value >> 8) & 0xff;
    1524         int shift_left = (kcontrol->private_value >> 16) & 0x07;
    1525         int shift_right = (kcontrol->private_value >> 19) & 0x07;
    1526         int mask = (kcontrol->private_value >> 24) & 0xff;
    1527         int invert = (kcontrol->private_value >> 22) & 1;
    1528        
    1529         spin_lock_irqsave(&chip->lock, flags);
    1530         ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask;
    1531         ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask;
    1532         spin_unlock_irqrestore(&chip->lock, flags);
    1533         if (invert) {
    1534                 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
    1535                 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
    1536         }
    1537         return 0;
    1538 }
    1539 
    1540 static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1541 {
    1542         struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
    1543         unsigned long flags;
    1544         int left_reg = kcontrol->private_value & 0xff;
    1545         int right_reg = (kcontrol->private_value >> 8) & 0xff;
    1546         int shift_left = (kcontrol->private_value >> 16) & 0x07;
    1547         int shift_right = (kcontrol->private_value >> 19) & 0x07;
    1548         int mask = (kcontrol->private_value >> 24) & 0xff;
    1549         int invert = (kcontrol->private_value >> 22) & 1;
    1550         int change;
    1551         unsigned short val1, val2;
    1552        
    1553         val1 = ucontrol->value.integer.value[0] & mask;
    1554         val2 = ucontrol->value.integer.value[1] & mask;
    1555         if (invert) {
    1556                 val1 = mask - val1;
    1557                 val2 = mask - val2;
    1558         }
    1559         val1 <<= shift_left;
    1560         val2 <<= shift_right;
    1561         spin_lock_irqsave(&chip->lock, flags);
    1562         val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1;
    1563         val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2;
    1564         change = val1 != chip->image[left_reg] || val2 != chip->image[right_reg];
    1565         snd_opti93x_out_image(chip, left_reg, val1);
    1566         snd_opti93x_out_image(chip, right_reg, val2);
    1567         spin_unlock_irqrestore(&chip->lock, flags);
    1568         return change;
    1569 }
    1570 
    1571 static struct snd_kcontrol_new snd_opti93x_controls[] __devinitdata = {
    1572 OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
    1573 OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
    1574 OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1),
    1575 OPTi93X_DOUBLE("PCM Playback Volume", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 0, 0, 31, 1),
    1576 OPTi93X_DOUBLE("FM Playback Switch", 0, OPTi931_FM_LEFT_INPUT, OPTi931_FM_RIGHT_INPUT, 7, 7, 1, 1),
    1577 OPTi93X_DOUBLE("FM Playback Volume", 0, OPTi931_FM_LEFT_INPUT, OPTi931_FM_RIGHT_INPUT, 1, 1, 15, 1),
    1578 OPTi93X_DOUBLE("Line Playback Switch", 0, OPTi93X_LINE_LEFT_INPUT, OPTi93X_LINE_RIGHT_INPUT, 7, 7, 1, 1),
    1579 OPTi93X_DOUBLE("Line Playback Volume", 0, OPTi93X_LINE_LEFT_INPUT, OPTi93X_LINE_RIGHT_INPUT, 1, 1, 15, 1),
    1580 OPTi93X_DOUBLE("Mic Playback Switch", 0, OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1),
    1581 OPTi93X_DOUBLE("Mic Playback Volume", 0, OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1),
    1582 OPTi93X_DOUBLE("Mic Boost", 0, OPTi93X_MIXOUT_LEFT, OPTi93X_MIXOUT_RIGHT, 5, 5, 1, 1),
    1583 OPTi93X_DOUBLE("CD Playback Switch", 0, OPTi93X_CD_LEFT_INPUT, OPTi93X_CD_RIGHT_INPUT, 7, 7, 1, 1),
    1584 OPTi93X_DOUBLE("CD Playback Volume", 0, OPTi93X_CD_LEFT_INPUT, OPTi93X_CD_RIGHT_INPUT, 1, 1, 15, 1),
    1585 OPTi93X_DOUBLE("Aux Playback Switch", 0, OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1),
    1586 OPTi93X_DOUBLE("Aux Playback Volume", 0, OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1),
    1587 OPTi93X_DOUBLE("Capture Volume", 0, OPTi93X_MIXOUT_LEFT, OPTi93X_MIXOUT_RIGHT, 0, 0, 15, 0),
    1588 {
    1589         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1590         .name = "Capture Source",
    1591         .info = snd_opti93x_info_mux,
    1592         .get = snd_opti93x_get_mux,
    1593         .put = snd_opti93x_put_mux,
    1594 }
    1595 };
    1596                                        
    1597 static int __devinit snd_opti93x_mixer(struct snd_opti93x *chip)
    1598 {
    1599         struct snd_card *card;
    1600         struct snd_kcontrol_new knew;
    1601         int err;
    1602         unsigned int idx;
    1603 
    1604         snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
    1605 
    1606         card = chip->card;
    1607 
    1608         strcpy(card->mixername, snd_opti93x_chip_id(chip));
    1609 
    1610         for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) {
    1611                 knew = snd_opti93x_controls[idx];
    1612                 if (chip->hardware == OPTi9XX_HW_82C930) {
    1613                         if (strstr(knew.name, "FM"))    /* skip FM controls */
    1614                                 continue;
    1615                         else if (strcmp(knew.name, "Mic Playback Volume"))
    1616                                 OPTi93X_DOUBLE_INVERT_INVERT(knew);
    1617                         else if (strstr(knew.name, "Aux"))
    1618                                 OPTi93X_DOUBLE_CHANGE_REGS(knew, OPTi930_AUX_LEFT_INPUT, OPTi930_AUX_RIGHT_INPUT);
    1619                         else if (strcmp(knew.name, "PCM Playback Volume"))
    1620                                 OPTi93X_DOUBLE_INVERT_INVERT(knew);
    1621                         else if (strcmp(knew.name, "Master Playback Volume"))
    1622                                 OPTi93X_DOUBLE_INVERT_INVERT(knew);
    1623                 }
    1624                 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_opti93x_controls[idx], chip))) < 0)
    1625                         return err;
    1626         }
    1627         return 0;
    1628574}
    1629575
     
    1740686        struct snd_opti9xx *chip = card->private_data;
    1741687       
    1742         if (chip)
     688        if (chip) {
     689#ifdef OPTi93X
     690                struct snd_cs4231 *codec = chip->codec;
     691                if (codec->irq > 0) {
     692                        disable_irq(codec->irq);
     693                        free_irq(codec->irq, codec);
     694                }
     695#endif
    1743696                release_and_free_resource(chip->res_mc_base);
     697        }
    1744698}
    1745699
     
    1749703        int error;
    1750704        struct snd_opti9xx *chip = card->private_data;
    1751 #if defined(OPTi93X)
    1752         struct snd_opti93x *codec;
    1753 #elif defined(CS4231)
     705#if defined(CS4231) || defined(OPTi93X)
    1754706        struct snd_cs4231 *codec;
     707#ifdef CS4231
    1755708        struct snd_timer *timer;
     709#endif
    1756710#else
    1757711        struct snd_ad1848 *codec;
     
    1785739                return error;
    1786740
    1787 #if defined(OPTi93X)
    1788         if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec)))
    1789                 return error;
    1790         if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0)
    1791                 return error;
    1792         if ((error = snd_opti93x_mixer(codec)) < 0)
    1793                 return error;
    1794 #elif defined(CS4231)
     741#if defined(CS4231) || defined(OPTi93X)
    1795742        if ((error = snd_cs4231_create(card, chip->wss_base + 4, -1,
    1796743                                       chip->irq, chip->dma1, chip->dma2,
    1797                                        CS4231_HW_DETECT,
    1798                                        0,
     744#ifdef CS4231
     745                                       CS4231_HW_DETECT, 0,
     746#else /* OPTi93x */
     747                                       CS4231_HW_OPTI93X, CS4231_HWSHARE_IRQ,
     748#endif
    1799749                                       &codec)) < 0)
    1800750                return error;
     751#ifdef OPTi93X
     752        chip->codec = codec;
     753#endif
    1801754        if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0)
    1802755                return error;
    1803756        if ((error = snd_cs4231_mixer(codec)) < 0)
    1804757                return error;
     758#ifdef CS4231
    1805759        if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0)
    1806760                return error;
     761#else /* OPTI93X */
     762        error = request_irq(chip->irq, snd_opti93x_interrupt,
     763                            IRQF_DISABLED, DEV_NAME" - WSS", codec);
     764        if (error < 0) {
     765                snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq);
     766                return error;
     767        }
     768#endif
    1807769#else
    1808770        if ((error = snd_ad1848_create(card, chip->wss_base + 4,
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/sb/sb16_csp.c

    r305 r358  
    332332        if ((file_h.name != RIFF_HEADER) ||
    333333            (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {
    334                 snd_printd("%s: Invalid RIFF header\n", __FUNCTION__);
     334                snd_printd("%s: Invalid RIFF header\n", __func__);
    335335                return -EINVAL;
    336336        }
     
    341341                return -EFAULT;
    342342        if (item_type != CSP__HEADER) {
    343                 snd_printd("%s: Invalid RIFF file type\n", __FUNCTION__);
     343                snd_printd("%s: Invalid RIFF file type\n", __func__);
    344344                return -EINVAL;
    345345        }
     
    396396
    397397                        if (code_h.name != MAIN_HEADER) {
    398                                 snd_printd("%s: Missing 'main' microcode\n", __FUNCTION__);
     398                                snd_printd("%s: Missing 'main' microcode\n", __func__);
    399399                                return -EINVAL;
    400400                        }
     
    440440                                p->mode = 0;
    441441                                snd_printd("%s: Unsupported CSP codec type: 0x%04x\n",
    442                                            __FUNCTION__,
     442                                           __func__,
    443443                                           le16_to_cpu(funcdesc_h.VOC_type));
    444444                                return -EINVAL;
     
    459459                }
    460460        }
    461         snd_printd("%s: Function #%d not found\n", __FUNCTION__, info.func_req);
     461        snd_printd("%s: Function #%d not found\n", __func__, info.func_req);
    462462        return -EINVAL;
    463463}
     
    613613{
    614614        if (p->version < 0x10 || p->version > 0x1f) {
    615                 snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version);
     615                snd_printd("%s: Invalid CSP version: 0x%x\n", __func__, p->version);
    616616                return 1;
    617617        }
     
    632632        snd_sbdsp_command(p->chip, 0x01);       /* CSP download command */
    633633        if (snd_sbdsp_get_byte(p->chip)) {
    634                 snd_printd("%s: Download command failed\n", __FUNCTION__);
     634                snd_printd("%s: Download command failed\n", __func__);
    635635                goto __fail;
    636636        }
     
    659659                }
    660660                if (status != 0x55) {
    661                         snd_printd("%s: Microcode initialization failed\n", __FUNCTION__);
     661                        snd_printd("%s: Microcode initialization failed\n", __func__);
    662662                        goto __fail;
    663663                }
     
    825825
    826826        if (!(p->running & (SNDRV_SB_CSP_ST_LOADED | SNDRV_SB_CSP_ST_AUTO))) {
    827                 snd_printd("%s: Microcode not loaded\n", __FUNCTION__);
     827                snd_printd("%s: Microcode not loaded\n", __func__);
    828828                return -ENXIO;
    829829        }
    830830        if (p->running & SNDRV_SB_CSP_ST_RUNNING) {
    831                 snd_printd("%s: CSP already running\n", __FUNCTION__);
     831                snd_printd("%s: CSP already running\n", __func__);
    832832                return -EBUSY;
    833833        }
    834834        if (!(sample_width & p->acc_width)) {
    835                 snd_printd("%s: Unsupported PCM sample width\n", __FUNCTION__);
     835                snd_printd("%s: Unsupported PCM sample width\n", __func__);
    836836                return -EINVAL;
    837837        }
    838838        if (!(channels & p->acc_channels)) {
    839                 snd_printd("%s: Invalid number of channels\n", __FUNCTION__);
     839                snd_printd("%s: Invalid number of channels\n", __func__);
    840840                return -EINVAL;
    841841        }
     
    859859
    860860        if (set_codec_parameter(p->chip, 0x81, s_type)) {
    861                 snd_printd("%s: Set sample type command failed\n", __FUNCTION__);
     861                snd_printd("%s: Set sample type command failed\n", __func__);
    862862                goto __fail;
    863863        }
    864864        if (set_codec_parameter(p->chip, 0x80, 0x00)) {
    865                 snd_printd("%s: Codec start command failed\n", __FUNCTION__);
     865                snd_printd("%s: Codec start command failed\n", __func__);
    866866                goto __fail;
    867867        }
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/sb/sb8_main.c

    r305 r358  
    278278                snd_sbdsp_command(chip, 256 - runtime->rate_den);
    279279        }
    280         if (chip->capture_format != SB_DSP_OUTPUT) {
     280        if (chip->capture_format != SB_DSP_INPUT) {
    281281                count--;
    282282                snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE);
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/sb/sb_common.c

    r305 r358  
    5252                        return 1;
    5353                }
    54         snd_printd("%s [0x%lx]: timeout (0x%x)\n", __FUNCTION__, chip->port, val);
     54        snd_printd("%s [0x%lx]: timeout (0x%x)\n", __func__, chip->port, val);
    5555        return 0;
    5656}
     
    6969                }
    7070        }
    71         snd_printd("%s [0x%lx]: timeout\n", __FUNCTION__, chip->port);
     71        snd_printd("%s [0x%lx]: timeout\n", __func__, chip->port);
    7272        return -ENODEV;
    7373}
     
    8888                                break;
    8989                }
    90         snd_printdd("%s [0x%lx] failed...\n", __FUNCTION__, chip->port);
     90        snd_printdd("%s [0x%lx] failed...\n", __func__, chip->port);
    9191        return -ENODEV;
    9292}
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/sb/sb_mixer.c

    r305 r358  
    926926{
    927927        unsigned char *val = chip->saved_regs;
    928         snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return);
     928        snd_assert(num_regs <= ARRAY_SIZE(chip->saved_regs), return);
    929929        for (; num_regs; num_regs--)
    930930                *val++ = snd_sbmixer_read(chip, *regs++);
     
    934934{
    935935        unsigned char *val = chip->saved_regs;
    936         snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return);
     936        snd_assert(num_regs <= ARRAY_SIZE(chip->saved_regs), return);
    937937        for (; num_regs; num_regs--)
    938938                snd_sbmixer_write(chip, *regs++, *val++);
  • GPL/branches/uniaud32-2.0/alsa-kernel/isa/wavefront/wavefront_synth.c

    r305 r358  
    19441944
    19451945{
    1946         unsigned char *buf;
     1946        const unsigned char *buf;
    19471947        int len, err;
    19481948        int section_cnt_downloaded = 0;
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ac97/ac97_codec.c

    r339 r358  
    5050#ifdef CONFIG_SND_AC97_POWER_SAVE
    5151static int power_save = CONFIG_SND_AC97_POWER_SAVE_DEFAULT;
    52 module_param(power_save, bool, 0644);
    53 MODULE_PARM_DESC(power_save, "Enable AC97 power-saving control");
     52module_param(power_save, int, 0644);
     53MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
     54                 "(in second, 0 = disable).");
    5455#endif
    5556/*
     
    23382339        snd_ac97_write(ac97, AC97_POWERDOWN, power);
    23392340        udelay(100);
    2340         power |= AC97_PD_PR2 | AC97_PD_PR3;     /* Analog Mixer powerdown */
     2341        power |= AC97_PD_PR2;   /* Analog Mixer powerdown (Vref on) */
    23412342        snd_ac97_write(ac97, AC97_POWERDOWN, power);
    23422343        if (ac97_is_power_save_mode(ac97)) {
     2344                power |= AC97_PD_PR3;   /* Analog Mixer powerdown */
     2345                snd_ac97_write(ac97, AC97_POWERDOWN, power);
    23432346                udelay(100);
    23442347                /* AC-link powerdown, internal Clk disable */
     
    24062409                 */
    24072410                schedule_delayed_work(&ac97->power_work,
    2408                                       msecs_to_jiffies(2000));
     2411                                      msecs_to_jiffies(power_save * 1000));
    24092412        else {
    24102413                cancel_delayed_work(&ac97->power_work);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ac97/ac97_patch.c

    r305 r358  
    115115static int ac97_channel_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    116116{
    117         static const char *texts[] = { "2ch", "4ch", "6ch" };
    118         if (kcontrol->private_value)
    119                 return ac97_enum_text_info(kcontrol, uinfo, texts, 2); /* 4ch only */
    120         return ac97_enum_text_info(kcontrol, uinfo, texts, 3);
     117        static const char *texts[] = { "2ch", "4ch", "6ch", "8ch" };
     118        return ac97_enum_text_info(kcontrol, uinfo, texts,
     119                kcontrol->private_value);
    121120}
    122121
     
    134133        unsigned char mode = ucontrol->value.enumerated.item[0];
    135134
    136         if (kcontrol->private_value) {
    137                 if (mode >= 2)
    138                         return -EINVAL;
    139         } else {
    140                 if (mode >= 3)
    141                         return -EINVAL;
    142         }
     135        if (mode >= kcontrol->private_value)
     136                return -EINVAL;
    143137
    144138        if (mode != ac97->channel_mode) {
     
    159153                .put = ac97_surround_jack_mode_put, \
    160154        }
     155/* 6ch */
    161156#define AC97_CHANNEL_MODE_CTL \
    162157        { \
     
    166161                .get = ac97_channel_mode_get, \
    167162                .put = ac97_channel_mode_put, \
     163                .private_value = 3, \
    168164        }
     165/* 4ch */
    169166#define AC97_CHANNEL_MODE_4CH_CTL \
    170167        { \
     
    174171                .get = ac97_channel_mode_get, \
    175172                .put = ac97_channel_mode_put, \
    176                 .private_value = 1, \
     173                .private_value = 2, \
     174        }
     175/* 8ch */
     176#define AC97_CHANNEL_MODE_8CH_CTL \
     177        { \
     178                .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, \
     179                .name   = "Channel Mode", \
     180                .info = ac97_channel_mode_info, \
     181                .get = ac97_channel_mode_get, \
     182                .put = ac97_channel_mode_put, \
     183                .private_value = 4, \
    177184        }
    178185
     
    211218}
    212219
     220static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
     221{
     222        return is_surround_on(ac97);
     223}
    213224
    214225/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
     
    659670AC97_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0),
    660671
     672AC97_SINGLE("Master Left Inv Switch", AC97_MASTER, 6, 1, 0),
    661673AC97_SINGLE("Master ZC Switch", AC97_MASTER, 7, 1, 0),
    662674AC97_SINGLE("Headphone ZC Switch", AC97_HEADPHONE, 7, 1, 0),
     
    19611973        val = ac97->regs[AC97_AD_MISC];
    19621974        ucontrol->value.integer.value[0] = !(val & AC97_AD198X_LOSEL);
     1975        if (ac97->spec.ad18xx.lo_as_master)
     1976                ucontrol->value.integer.value[0] =
     1977                        !ucontrol->value.integer.value[0];
    19631978        return 0;
    19641979}
     
    19691984        unsigned short val;
    19701985
    1971         val = !ucontrol->value.integer.value[0]
    1972                 ? (AC97_AD198X_LOSEL | AC97_AD198X_HPSEL) : 0;
     1986        val = !ucontrol->value.integer.value[0];
     1987        if (ac97->spec.ad18xx.lo_as_master)
     1988                val = !val;
     1989        val = val ? (AC97_AD198X_LOSEL | AC97_AD198X_HPSEL) : 0;
    19731990        return snd_ac97_update_bits(ac97, AC97_AD_MISC,
    19741991                                    AC97_AD198X_LOSEL | AC97_AD198X_HPSEL, val);
     
    20212038        unsigned short val = 0;
    20222039        /* clear LODIS if shared jack is to be used for Surround out */
    2023         if (is_shared_linein(ac97))
     2040        if (!ac97->spec.ad18xx.lo_as_master && is_shared_linein(ac97))
    20242041                val |= (1 << 12);
    20252042        /* clear CLDIS if shared jack is to be used for C/LFE out */
     
    20572074static int patch_ad1888_specific(struct snd_ac97 *ac97)
    20582075{
    2059         /* rename 0x04 as "Master" and 0x02 as "Master Surround" */
    2060         snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Master Surround Playback");
    2061         snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
     2076        if (!ac97->spec.ad18xx.lo_as_master) {
     2077                /* rename 0x04 as "Master" and 0x02 as "Master Surround" */
     2078                snd_ac97_rename_vol_ctl(ac97, "Master Playback",
     2079                                        "Master Surround Playback");
     2080                snd_ac97_rename_vol_ctl(ac97, "Headphone Playback",
     2081                                        "Master Playback");
     2082        }
    20622083        return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
    20632084}
     
    20782099        patch_ad1881(ac97);
    20792100        ac97->build_ops = &patch_ad1888_build_ops;
    2080         /* Switch FRONT/SURROUND LINE-OUT/HP-OUT default connection */
    2081         /* it seems that most vendors connect line-out connector to headphone out of AC'97 */
     2101
     2102        /*
     2103         * LO can be used as a real line-out on some devices,
     2104         * and we need to revert the front/surround mixer switches
     2105         */
     2106        if (ac97->subsystem_vendor == 0x1043 &&
     2107            ac97->subsystem_device == 0x1193) /* ASUS A9T laptop */
     2108                ac97->spec.ad18xx.lo_as_master = 1;
     2109
     2110        misc = snd_ac97_read(ac97, AC97_AD_MISC);
    20822111        /* AD-compatible mode */
    20832112        /* Stereo mutes enabled */
    2084         misc = snd_ac97_read(ac97, AC97_AD_MISC);
    2085         snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
    2086                              AC97_AD198X_LOSEL |
    2087                              AC97_AD198X_HPSEL |
    2088                              AC97_AD198X_MSPLT |
    2089                              AC97_AD198X_AC97NC);
     2113        misc |= AC97_AD198X_MSPLT | AC97_AD198X_AC97NC;
     2114        if (!ac97->spec.ad18xx.lo_as_master)
     2115                /* Switch FRONT/SURROUND LINE-OUT/HP-OUT default connection */
     2116                /* it seems that most vendors connect line-out connector to
     2117                 * headphone out of AC'97
     2118                 */
     2119                misc |= AC97_AD198X_LOSEL | AC97_AD198X_HPSEL;
     2120
     2121        snd_ac97_write_cache(ac97, AC97_AD_MISC, misc);
    20902122        ac97->flags |= AC97_STEREO_MUTES;
    20912123        return 0;
     
    28172849#define AC97_ALC850_JACK_SELECT 0x76
    28182850#define AC97_ALC850_MISC1       0x7a
     2851#define AC97_ALC850_MULTICH    0x6a
    28192852
    28202853static void alc850_update_jacks(struct snd_ac97 *ac97)
    28212854{
    28222855        int shared;
     2856        int aux_is_back_surround;
    28232857       
    28242858        /* shared Line-In / Surround Out */
     
    28382872        snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
    28392873                             shared ? (5<<4) : (1<<4));
     2874
     2875        aux_is_back_surround = alc850_is_aux_back_surround(ac97);
     2876        /* Aux is Back Surround */
     2877        snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
     2878                                 aux_is_back_surround ? (1<<10) : (0<<10));
    28402879}
    28412880
     
    28442883        AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1),
    28452884        AC97_SURROUND_JACK_MODE_CTL,
    2846         AC97_CHANNEL_MODE_CTL,
     2885        AC97_CHANNEL_MODE_8CH_CTL,
    28472886};
    28482887
     
    28702909
    28712910        ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
     2911        ac97->flags |= AC97_HAS_8CH;
    28722912
    28732913        /* assume only page 0 for writing cache */
     
    28792919           center on mic off, surround on line-in off
    28802920           duplicate front off
     2921           NB default bit 10=0 = Aux is Capture, not Back Surround
    28812922        */
    28822923        snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
     
    33133354};
    33143355
     3356static const char *slave_vols_vt1616[] = {
     3357        "Front Playback Volume",
     3358        "Surround Playback Volume",
     3359        "Center Playback Volume",
     3360        "LFE Playback Volume",
     3361        NULL
     3362};
     3363
     3364static const char *slave_sws_vt1616[] = {
     3365        "Front Playback Switch",
     3366        "Surround Playback Switch",
     3367        "Center Playback Switch",
     3368        "LFE Playback Switch",
     3369        NULL
     3370};
     3371
     3372/* find a mixer control element with the given name */
     3373static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
     3374                                                    const char *name)
     3375{
     3376        struct snd_ctl_elem_id id;
     3377        memset(&id, 0, sizeof(id));
     3378        id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     3379        strcpy(id.name, name);
     3380        return snd_ctl_find_id(ac97->bus->card, &id);
     3381}
     3382
     3383/* create a virtual master control and add slaves */
     3384int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
     3385                         const unsigned int *tlv, const char **slaves)
     3386{
     3387        struct snd_kcontrol *kctl;
     3388        const char **s;
     3389        int err;
     3390
     3391        kctl = snd_ctl_make_virtual_master(name, tlv);
     3392        if (!kctl)
     3393                return -ENOMEM;
     3394        err = snd_ctl_add(ac97->bus->card, kctl);
     3395        if (err < 0)
     3396                return err;
     3397
     3398        for (s = slaves; *s; s++) {
     3399                struct snd_kcontrol *sctl;
     3400
     3401                sctl = snd_ac97_find_mixer_ctl(ac97, *s);
     3402                if (!sctl) {
     3403                        snd_printdd("Cannot find slave %s, skipped\n", *s);
     3404                        continue;
     3405                }
     3406                err = snd_ctl_add_slave(kctl, sctl);
     3407                if (err < 0)
     3408                        return err;
     3409        }
     3410        return 0;
     3411}
     3412
    33153413static int patch_vt1616_specific(struct snd_ac97 * ac97)
    33163414{
     3415        struct snd_kcontrol *kctl;
    33173416        int err;
    33183417
     
    33223421        if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1)) < 0)
    33233422                return err;
     3423
     3424        /* There is already a misnamed master switch.  Rename it.  */
     3425        kctl = snd_ac97_find_mixer_ctl(ac97, "Master Playback Volume");
     3426        if (!kctl)
     3427                return -EINVAL;
     3428
     3429        snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
     3430
     3431        err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
     3432                                   kctl->tlv.p, slave_vols_vt1616);
     3433        if (err < 0)
     3434                return err;
     3435
     3436        err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
     3437                                   NULL, slave_sws_vt1616);
     3438        if (err < 0)
     3439                return err;
     3440
    33243441        return 0;
    33253442}
     
    34273544{
    34283545        int err = 0;
     3546        int val;
    34293547
    34303548        /* we choose to not fail out at this point, but we tell the
     
    34373555         * headphone amplifier, like WinXP driver for EPIA SP
    34383556         */
    3439         snd_ac97_write_cache(ac97, 0x5c, 0x20);
     3557        /* We need to check the bit before writing it.
     3558         * On some (many?) hardwares, setting bit actually clears it!
     3559         */
     3560        val = snd_ac97_read(ac97, 0x5c);
     3561        if (!(val & 0x20))
     3562                snd_ac97_write_cache(ac97, 0x5c, 0x20);
     3563
    34403564        ac97->ext_id |= AC97_EI_SPDIF;  /* force the detection of spdif */
    34413565        ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
     
    35873711        ac97->build_ops = &patch_ucb1400_ops;
    35883712        /* enable headphone driver and smart low power mode by default */
    3589         snd_ac97_write(ac97, 0x6a, 0x0050);
    3590         snd_ac97_write(ac97, 0x6c, 0x0030);
    3591         return 0;
    3592 }
     3713        snd_ac97_write_cache(ac97, 0x6a, 0x0050);
     3714        snd_ac97_write_cache(ac97, 0x6c, 0x0030);
     3715        return 0;
     3716}
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ac97/ac97_pcm.c

    r305 r358  
    575575        bus = pcm->bus;
    576576        if (cfg == AC97_PCM_CFG_SPDIF) {
    577                 int err;
    578577                for (cidx = 0; cidx < 4; cidx++)
    579578                        if (bus->codec[cidx] && (bus->codec[cidx]->ext_id & AC97_EI_SPDIF)) {
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ali5451/ali5451.c

    r325 r358  
    18201820{
    18211821        struct snd_ali *codec = kcontrol->private_data;
    1822         unsigned int enable;
    1823 
    1824         enable = ucontrol->value.integer.value[0] ? 1 : 0;
     1822        unsigned int spdif_enable;
     1823
     1824        spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
    18251825
    18261826        spin_lock_irq(&codec->reg_lock);
    18271827        switch (kcontrol->private_value) {
    18281828        case 0:
    1829                 enable = (codec->spdif_mask & 0x02) ? 1 : 0;
     1829                spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
    18301830                break;
    18311831        case 1:
    1832                 enable = ((codec->spdif_mask & 0x02) &&
     1832                spdif_enable = ((codec->spdif_mask & 0x02) &&
    18331833                          (codec->spdif_mask & 0x04)) ? 1 : 0;
    18341834                break;
    18351835        case 2:
    1836                 enable = (codec->spdif_mask & 0x01) ? 1 : 0;
     1836                spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0;
    18371837                break;
    18381838        default:
    18391839                break;
    18401840        }
    1841         ucontrol->value.integer.value[0] = enable;
     1841        ucontrol->value.integer.value[0] = spdif_enable;
    18421842        spin_unlock_irq(&codec->reg_lock);
    18431843        return 0;
     
    18481848{
    18491849        struct snd_ali *codec = kcontrol->private_data;
    1850         unsigned int change = 0, enable = 0;
    1851 
    1852         enable = ucontrol->value.integer.value[0] ? 1 : 0;
     1850        unsigned int change = 0, spdif_enable = 0;
     1851
     1852        spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
    18531853
    18541854        spin_lock_irq(&codec->reg_lock);
     
    18561856        case 0:
    18571857                change = (codec->spdif_mask & 0x02) ? 1 : 0;
    1858                 change = change ^ enable;
     1858                change = change ^ spdif_enable;
    18591859                if (change) {
    1860                         if (enable) {
     1860                        if (spdif_enable) {
    18611861                                codec->spdif_mask |= 0x02;
    18621862                                snd_ali_enable_spdif_out(codec);
     
    18701870        case 1:
    18711871                change = (codec->spdif_mask & 0x04) ? 1 : 0;
    1872                 change = change ^ enable;
     1872                change = change ^ spdif_enable;
    18731873                if (change && (codec->spdif_mask & 0x02)) {
    1874                         if (enable) {
     1874                        if (spdif_enable) {
    18751875                                codec->spdif_mask |= 0x04;
    18761876                                snd_ali_enable_spdif_chnout(codec);
     
    18831883        case 2:
    18841884                change = (codec->spdif_mask & 0x01) ? 1 : 0;
    1885                 change = change ^ enable;
     1885                change = change ^ spdif_enable;
    18861886                if (change) {
    1887                         if (enable) {
     1887                        if (spdif_enable) {
    18881888                                codec->spdif_mask |= 0x01;
    18891889                                snd_ali_enable_spdif_in(codec);
     
    20582058        if (codec->hw_initialized)
    20592059                snd_ali_disable_address_interrupt(codec);
    2060         if (codec->irq >= 0) {
    2061                 synchronize_irq(codec->irq);
     2060        if (codec->irq >= 0)
    20622061                free_irq(codec->irq, codec);
    2063         }
    20642062        if (codec->port)
    20652063                pci_release_regions(codec->pci);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/atiixp.c

    r305 r358  
    15561556                goto __hw_end;
    15571557        snd_atiixp_chip_stop(chip);
    1558         synchronize_irq(chip->irq);
     1558
    15591559      __hw_end:
    15601560        if (chip->irq >= 0)
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/au88x0/au88x0.c

    r305 r358  
    127127        vortex_core_shutdown(vortex);
    128128        // Take down PCI interface.
    129         synchronize_irq(vortex->irq);
    130129        free_irq(vortex->irq, vortex);
    131130        iounmap(vortex->mmio);
     
    221220
    222221      alloc_out:
    223         synchronize_irq(chip->irq);
    224222        free_irq(chip->irq, chip);
    225223      irq_out:
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/au88x0/au88x0_game.c

    r305 r358  
    11/*
    2  * $Id: au88x0_game.c,v 1.9 2003/09/22 03:51:28 mjander Exp $
    3  *
    42 *  Manuel Jander.
    53 *
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/au88x0/au88x0_pcm.c

    r305 r358  
    499499
    500500/* create a pcm device */
    501 static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr)
     501static int __devinit snd_vortex_new_pcm(vortex_t *chip, int idx, int nr)
    502502{
    503503        struct snd_pcm *pcm;
     
    506506        int err, nr_capt;
    507507
    508         if ((chip == 0) || (idx < 0) || (idx >= VORTEX_PCM_LAST))
     508        if (!chip || idx < 0 || idx >= VORTEX_PCM_LAST)
    509509                return -ENODEV;
    510510
     
    515515        else
    516516                nr_capt = 0;
    517         if ((err =
    518              snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr,
    519                          nr_capt, &pcm)) < 0)
     517        err = snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr,
     518                          nr_capt, &pcm);
     519        if (err < 0)
    520520                return err;
    521521        strcpy(pcm->name, vortex_pcm_name[idx]);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/bt87x.c

    r319 r358  
    690690static int snd_bt87x_free(struct snd_bt87x *chip)
    691691{
    692         if (chip->mmio) {
     692        if (chip->mmio)
    693693                snd_bt87x_stop(chip);
    694                 if (chip->irq >= 0)
    695                         synchronize_irq(chip->irq);
    696 
    697                 iounmap(chip->mmio);
    698         }
    699694        if (chip->irq >= 0)
    700695                free_irq(chip->irq, chip);
     696        if (chip->mmio)
     697                iounmap(chip->mmio);
    701698        pci_release_regions(chip->pci);
    702699        pci_disable_device(chip->pci);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ca0106/ca0106_main.c

    r325 r358  
    250250           .gpio_type = 2,
    251251           .i2c_adc = 1 } ,
     252         /* Another MSI K8N Diamond MB, which has apprently a different SSID */
     253         { .serial = 0x10091102,
     254           .name   = "MSI K8N Diamond MB",
     255           .gpio_type = 2,
     256           .i2c_adc = 1 } ,
    252257         /* Shuttle XPC SD31P which has an onboard Creative Labs
    253258          * Sound Blaster Live! 24-bit EAX
     
    436441{
    437442        unsigned long flags;
    438         unsigned int enable;
    439  
     443        unsigned int intr_enable;
     444
    440445        spin_lock_irqsave(&emu->emu_lock, flags);
    441         enable = inl(emu->port + INTE) | intrenb;
    442         outl(enable, emu->port + INTE);
     446        intr_enable = inl(emu->port + INTE) | intrenb;
     447        outl(intr_enable, emu->port + INTE);
    443448        spin_unlock_irqrestore(&emu->emu_lock, flags);
    444449}
     
    447452{
    448453        unsigned long flags;
    449         unsigned int enable;
    450  
     454        unsigned int intr_enable;
     455
    451456        spin_lock_irqsave(&emu->emu_lock, flags);
    452         enable = inl(emu->port + INTE) & ~intrenb;
    453         outl(enable, emu->port + INTE);
     457        intr_enable = inl(emu->port + INTE) & ~intrenb;
     458        outl(intr_enable, emu->port + INTE);
    454459        spin_unlock_irqrestore(&emu->emu_lock, flags);
    455460}
     
    11151120                 */
    11161121        }
     1122        if (chip->irq >= 0)
     1123                free_irq(chip->irq, chip);
    11171124        // release the data
    11181125#if 1
     
    11241131        release_and_free_resource(chip->res_port);
    11251132
    1126         // release the irq
    1127         if (chip->irq >= 0)
    1128                 free_irq(chip->irq, chip);
    11291133        pci_disable_device(chip->pci);
    11301134        kfree(chip);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ca0106/ca0106_mixer.c

    r305 r358  
    651651#define ADD_CTLS(emu, ctls)                                             \
    652652        do {                                                            \
    653                 int i, err;                                             \
     653                int i, _err;                                            \
    654654                for (i = 0; i < ARRAY_SIZE(ctls); i++) {                \
    655                         err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \
    656                         if (err < 0)                                    \
    657                                 return err;                             \
     655                        _err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \
     656                        if (_err < 0)                                   \
     657                                return _err;                            \
    658658                }                                                       \
    659659        } while (0)
     660
     661static __devinitdata
     662DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 50, 1);
     663
     664static char *slave_vols[] __devinitdata = {
     665        "Analog Front Playback Volume",
     666        "Analog Rear Playback Volume",
     667        "Analog Center/LFE Playback Volume",
     668        "Analog Side Playback Volume",
     669        "IEC958 Front Playback Volume",
     670        "IEC958 Rear Playback Volume",
     671        "IEC958 Center/LFE Playback Volume",
     672        "IEC958 Unknown Playback Volume",
     673        "CAPTURE feedback Playback Volume",
     674        NULL
     675};
     676
     677static char *slave_sws[] __devinitdata = {
     678        "Analog Front Playback Switch",
     679        "Analog Rear Playback Switch",
     680        "Analog Center/LFE Playback Switch",
     681        "Analog Side Playback Switch",
     682        "IEC958 Playback Switch",
     683        NULL
     684};
     685
     686static void __devinit add_slaves(struct snd_card *card,
     687                                 struct snd_kcontrol *master, char **list)
     688{
     689        for (; *list; list++) {
     690                struct snd_kcontrol *slave = ctl_find(card, *list);
     691                if (slave)
     692                        snd_ctl_add_slave(master, slave);
     693        }
     694}
    660695
    661696int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
     
    664699        struct snd_card *card = emu->card;
    665700        char **c;
     701        struct snd_kcontrol *vmaster;
    666702        static char *ca0106_remove_ctls[] = {
    667703                "Master Mono Playback Switch",
     
    720756        if (emu->details->spi_dac == 1)
    721757                ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls);
     758
     759        /* Create virtual master controls */
     760        vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
     761                                              snd_ca0106_master_db_scale);
     762        if (!vmaster)
     763                return -ENOMEM;
     764        add_slaves(card, vmaster, slave_vols);
     765
     766        if (emu->details->spi_dac == 1) {
     767                vmaster = snd_ctl_make_virtual_master("Master Playback Switch",
     768                                                      NULL);
     769                if (!vmaster)
     770                        return -ENOMEM;
     771                add_slaves(card, vmaster, slave_sws);
     772        }
    722773        return 0;
    723774}
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/cmipci.c

    r310 r358  
    27612761
    27622762        for (idx = 0; idx < CM_SAVED_MIXERS; idx++) {
    2763                 struct snd_ctl_elem_id id;
     2763                struct snd_ctl_elem_id elem_id;
    27642764                struct snd_kcontrol *ctl;
    2765                 memset(&id, 0, sizeof(id));
    2766                 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    2767                 strcpy(id.name, cm_saved_mixer[idx].name);
    2768                 if ((ctl = snd_ctl_find_id(cm->card, &id)) != NULL)
     2765                memset(&elem_id, 0, sizeof(elem_id));
     2766                elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     2767                strcpy(elem_id.name, cm_saved_mixer[idx].name);
     2768                ctl = snd_ctl_find_id(cm->card, &elem_id);
     2769                if (ctl)
    27692770                        cm->mixer_res_ctl[idx] = ctl;
    27702771        }
     
    29492950                snd_cmipci_mixer_write(cm, 0, 0);
    29502951
    2951                 synchronize_irq(cm->irq);
    2952 
    29532952                free_irq(cm->irq, cm);
    29542953        }
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/cs46xx/cs46xx_lib.c

    r305 r358  
    27732773                free_irq(chip->irq, chip);
    27742774
     2775        if (chip->active_ctrl)
     2776                chip->active_ctrl(chip, -chip->amplifier);
     2777
    27752778        for (idx = 0; idx < 5; idx++) {
    27762779                struct snd_cs46xx_region *region = &chip->region.idx[idx];
     
    27802783        }
    27812784
    2782         if (chip->active_ctrl)
    2783                 chip->active_ctrl(chip, -chip->amplifier);
    2784        
    27852785#ifdef CONFIG_SND_CS46XX_NEW_DSP
    27862786        if (chip->dsp_spos_instance) {
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/emu10k1/emu10k1_main.c

    r325 r358  
    12531253                snd_emu10k1_fx8010_tram_setup(emu, 0);
    12541254                snd_emu10k1_done(emu);
    1255                 /* remove reserved page */
    1256                 if (emu->reserved_page) {
    1257                         snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page);
    1258                         emu->reserved_page = NULL;
    1259                 }
    12601255                snd_emu10k1_free_efx(emu);
    12611256        }
     
    12661261        if (emu->emu1010.firmware_thread)
    12671262                kthread_stop(emu->emu1010.firmware_thread);
     1263        if (emu->irq >= 0)
     1264                free_irq(emu->irq, emu);
     1265        /* remove reserved page */
     1266        if (emu->reserved_page) {
     1267                snd_emu10k1_synth_free(emu,
     1268                        (struct snd_util_memblk *)emu->reserved_page);
     1269                emu->reserved_page = NULL;
     1270        }
    12681271        if (emu->memhdr)
    12691272                snd_util_memhdr_free(emu->memhdr);
     
    12771280        free_pm_buffer(emu);
    12781281#endif
    1279         if (emu->irq >= 0)
    1280                 free_irq(emu->irq, emu);
    12811282        if (emu->port)
    12821283                pci_release_regions(emu->pci);
     
    15311532         .spk71 = 1,
    15321533         .spdif_bug = 1,
     1534         .invert_shared_spdif = 1,      /* digital/analog switch swapped */
    15331535         .adc_1361t = 1,  /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */
    15341536         .ac97_chip = 1} ,
     
    18251827        emu->port = pci_resource_start(pci, 0);
    18261828
    1827         if (request_irq(pci->irq, snd_emu10k1_interrupt, IRQF_SHARED,
    1828                         "EMU10K1", emu)) {
    1829                 err = -EBUSY;
    1830                 goto error;
    1831         }
    1832         emu->irq = pci->irq;
    1833 
    18341829        emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT;
    18351830        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
     
    18931888        emu->fx8010.etram_pages.area = NULL;
    18941889        emu->fx8010.etram_pages.bytes = 0;
     1890
     1891        /* irq handler must be registered after I/O ports are activated */
     1892        if (request_irq(pci->irq, snd_emu10k1_interrupt, IRQF_SHARED,
     1893                        "EMU10K1", emu)) {
     1894                err = -EBUSY;
     1895                goto error;
     1896        }
     1897        emu->irq = pci->irq;
    18951898
    18961899        /*
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/emu10k1/emu10k1x.c

    r325 r358  
    328328{
    329329        unsigned long flags;
    330         unsigned int enable;
    331  
     330        unsigned int intr_enable;
     331
    332332        spin_lock_irqsave(&emu->emu_lock, flags);
    333         enable = inl(emu->port + INTE) | intrenb;
    334         outl(enable, emu->port + INTE);
     333        intr_enable = inl(emu->port + INTE) | intrenb;
     334        outl(intr_enable, emu->port + INTE);
    335335        spin_unlock_irqrestore(&emu->emu_lock, flags);
    336336}
     
    339339{
    340340        unsigned long flags;
    341         unsigned int enable;
    342  
     341        unsigned int intr_enable;
     342
    343343        spin_lock_irqsave(&emu->emu_lock, flags);
    344         enable = inl(emu->port + INTE) & ~intrenb;
    345         outl(enable, emu->port + INTE);
     344        intr_enable = inl(emu->port + INTE) & ~intrenb;
     345        outl(intr_enable, emu->port + INTE);
    346346        spin_unlock_irqrestore(&emu->emu_lock, flags);
    347347}
     
    755755        outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
    756756
     757        /* release the irq */
     758        if (chip->irq >= 0)
     759                free_irq(chip->irq, chip);
     760
    757761        // release the i/o port
    758762        release_and_free_resource(chip->res_port);
    759 
    760         // release the irq
    761         if (chip->irq >= 0)
    762                 free_irq(chip->irq, chip);
    763763
    764764        // release the DMA
     
    796796        // capture interrupt
    797797        if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) {
    798                 struct emu10k1x_voice *pvoice = &chip->capture_voice;
    799                 if (pvoice->use)
    800                         snd_emu10k1x_pcm_interrupt(chip, pvoice);
     798                struct emu10k1x_voice *cap_voice = &chip->capture_voice;
     799                if (cap_voice->use)
     800                        snd_emu10k1x_pcm_interrupt(chip, cap_voice);
    801801                else
    802802                        snd_emu10k1x_intr_disable(chip,
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/emu10k1/emumixer.c

    r305 r358  
    15791579        else
    15801580                ucontrol->value.integer.value[0] = inl(emu->port + HCFG) & HCFG_GPOUT0 ? 1 : 0;
     1581        if (emu->card_capabilities->invert_shared_spdif)
     1582                ucontrol->value.integer.value[0] =
     1583                        !ucontrol->value.integer.value[0];
     1584               
    15811585        return 0;
    15821586}
     
    15871591        unsigned long flags;
    15881592        struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
    1589         unsigned int reg, val;
     1593        unsigned int reg, val, sw;
    15901594        int change = 0;
    15911595
     1596        sw = ucontrol->value.integer.value[0];
     1597        if (emu->card_capabilities->invert_shared_spdif)
     1598                sw = !sw;
    15921599        spin_lock_irqsave(&emu->reg_lock, flags);
    15931600        if ( emu->card_capabilities->i2c_adc) {
     
    15951602        } else if (emu->audigy) {
    15961603                reg = inl(emu->port + A_IOCFG);
    1597                 val = ucontrol->value.integer.value[0] ? A_IOCFG_GPOUT0 : 0;
     1604                val = sw ? A_IOCFG_GPOUT0 : 0;
    15981605                change = (reg & A_IOCFG_GPOUT0) != val;
    15991606                if (change) {
     
    16041611        }
    16051612        reg = inl(emu->port + HCFG);
    1606         val = ucontrol->value.integer.value[0] ? HCFG_GPOUT0 : 0;
     1613        val = sw ? HCFG_GPOUT0 : 0;
    16071614        change |= (reg & HCFG_GPOUT0) != val;
    16081615        if (change) {
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/emu10k1/emuproc.c

    r305 r358  
    413413{
    414414        struct snd_emu10k1 *emu = entry->private_data;
    415         int value;
     415        u32 value;
    416416        unsigned long flags;
    417417        int i;
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/emu10k1/memory.c

    r305 r358  
    438438}
    439439
     440/* release allocated pages */
     441static void __synth_free_pages(struct snd_emu10k1 *emu, int first_page,
     442                               int last_page)
     443{
     444        int page;
     445
     446        for (page = first_page; page <= last_page; page++) {
     447                free_page((unsigned long)emu->page_ptr_table[page]);
     448                emu->page_addr_table[page] = 0;
     449                emu->page_ptr_table[page] = NULL;
     450        }
     451}
     452
    440453/*
    441454 * allocate kernel pages
     
    444457{
    445458        int page, first_page, last_page;
    446         struct snd_dma_buffer dmab;
    447459
    448460        emu10k1_memblk_init(blk);
     
    450462        /* allocate kernel pages */
    451463        for (page = first_page; page <= last_page; page++) {
    452                 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),
    453                                         PAGE_SIZE, &dmab) < 0)
    454                         goto __fail;
    455                 if (! is_valid_page(emu, dmab.addr)) {
    456                         snd_dma_free_pages(&dmab);
    457                         goto __fail;
    458                 }
    459                 emu->page_addr_table[page] = dmab.addr;
    460                 emu->page_ptr_table[page] = dmab.area;
     464                /* first try to allocate from <4GB zone */
     465                struct page *p = alloc_page(GFP_KERNEL | GFP_DMA32 |
     466                                            __GFP_NOWARN);
     467                if (!p || (page_to_pfn(p) & ~(emu->dma_mask >> PAGE_SHIFT))) {
     468                        if (p)
     469                                __free_page(p);
     470                        /* try to allocate from <16MB zone */
     471                        p = alloc_page(GFP_ATOMIC | GFP_DMA |
     472                                       __GFP_NORETRY | /* no OOM-killer */
     473                                       __GFP_NOWARN);
     474                }
     475                if (!p) {
     476                        __synth_free_pages(emu, first_page, page - 1);
     477                        return -ENOMEM;
     478                }
     479                emu->page_addr_table[page] = page_to_phys(p);
     480                emu->page_ptr_table[page] = page_address(p);
    461481        }
    462482        return 0;
    463 
    464 __fail:
    465         /* release allocated pages */
    466         last_page = page - 1;
    467         for (page = first_page; page <= last_page; page++) {
    468                 dmab.area = emu->page_ptr_table[page];
    469                 dmab.addr = emu->page_addr_table[page];
    470                 dmab.bytes = PAGE_SIZE;
    471                 snd_dma_free_pages(&dmab);
    472                 emu->page_addr_table[page] = 0;
    473                 emu->page_ptr_table[page] = NULL;
    474         }
    475 
    476         return -ENOMEM;
    477483}
    478484
     
    482488static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk)
    483489{
    484         int page, first_page, last_page;
    485         struct snd_dma_buffer dmab;
     490        int first_page, last_page;
    486491
    487492        get_single_page_range(emu->memhdr, blk, &first_page, &last_page);
    488         dmab.dev.type = SNDRV_DMA_TYPE_DEV;
    489         dmab.dev.dev = snd_dma_pci_data(emu->pci);
    490         for (page = first_page; page <= last_page; page++) {
    491                 if (emu->page_ptr_table[page] == NULL)
    492                         continue;
    493                 dmab.area = emu->page_ptr_table[page];
    494                 dmab.addr = emu->page_addr_table[page];
    495                 dmab.bytes = PAGE_SIZE;
    496                 snd_dma_free_pages(&dmab);
    497                 emu->page_addr_table[page] = 0;
    498                 emu->page_ptr_table[page] = NULL;
    499         }
    500 
     493        __synth_free_pages(emu, first_page, last_page);
    501494        return 0;
    502495}
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ens1370.c

    r305 r358  
    16361636            (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) {
    16371637                struct snd_kcontrol *kctl;
    1638                 int i, index = 0;
     1638                int i, is_spdif = 0;
    16391639
    16401640                ensoniq->spdif_default = ensoniq->spdif_stream =
     
    16431643
    16441644                if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF)
    1645                         index++;
     1645                        is_spdif++;
    16461646
    16471647                for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) {
     
    16491649                        if (!kctl)
    16501650                                return -ENOMEM;
    1651                         kctl->id.index = index;
     1651                        kctl->id.index = is_spdif;
    16521652                        err = snd_ctl_add(card, kctl);
    16531653                        if (err < 0)
     
    19111911        outl(0, ES_REG(ensoniq, SERIAL));       /* clear serial interface */
    19121912#endif
    1913         synchronize_irq(ensoniq->irq);
     1913        if (ensoniq->irq >= 0)
     1914                synchronize_irq(ensoniq->irq);
    19141915        pci_set_power_state(ensoniq->pci, 3);
    19151916      __hw_end:
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/es1938.c

    r325 r358  
    14891489        outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
    14901490        if (chip->irq >= 0) {
    1491                 synchronize_irq(chip->irq);
    14921491                free_irq(chip->irq, chip);
    14931492                chip->irq = -1;
     
    15791578        snd_es1938_free_gameport(chip);
    15801579
    1581         if (chip->irq >= 0) {
    1582                 synchronize_irq(chip->irq);
     1580        if (chip->irq >= 0)
    15831581                free_irq(chip->irq, chip);
    1584         }
    15851582        pci_release_regions(chip->pci);
    15861583        pci_disable_device(chip->pci);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/es1968.c

    r325 r358  
    627627}
    628628
     629static int snd_es1968_ac97_wait_poll(struct es1968 *chip)
     630{
     631        int timeout = 100000;
     632
     633        while (timeout-- > 0) {
     634                if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1))
     635                        return 0;
     636        }
     637        snd_printd("es1968: ac97 timeout\n");
     638        return 1; /* timeout */
     639}
     640
    629641static void snd_es1968_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
    630642{
     
    655667        /*msleep(1);*/
    656668
    657         if (! snd_es1968_ac97_wait(chip)) {
     669        if (!snd_es1968_ac97_wait_poll(chip)) {
    658670                data = inw(chip->io_port + ESM_AC97_DATA);
    659671                /*msleep(1);*/
     
    18241836
    18251837        return 0;
     1838}
     1839/*
     1840 * suppress jitter on some maestros when playing stereo
     1841 */
     1842static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es)
     1843{
     1844        unsigned int cp1;
     1845        unsigned int cp2;
     1846        unsigned int diff;
     1847
     1848        cp1 = __apu_get_register(chip, 0, 5);
     1849        cp2 = __apu_get_register(chip, 1, 5);
     1850        diff = (cp1 > cp2 ? cp1 - cp2 : cp2 - cp1);
     1851
     1852        if (diff > 1)
     1853                __maestro_write(chip, IDR0_DATA_PORT, cp1);
    18261854}
    18271855
     
    19461974                spin_lock(&chip->substream_lock);
    19471975                list_for_each_entry(es, &chip->substream_list, list, struct esschan) {
    1948                         if (es->running)
     1976                        if (es->running) {
    19491977                                snd_es1968_update_pcm(chip, es);
     1978                                if (es->fmt & ESS_FMT_STEREO)
     1979                                        snd_es1968_suppress_jitter(chip, es);
     1980                        }
    19501981                }
    19511982                spin_unlock(&chip->substream_lock);
     
    19702001        struct snd_ac97_bus *pbus;
    19712002        struct snd_ac97_template ac97;
    1972         struct snd_ctl_elem_id id;
     2003        struct snd_ctl_elem_id elem_id;
    19732004        int err;
    19742005        static struct snd_ac97_bus_ops ops = {
     
    19872018
    19882019        /* attach master switch / volumes for h/w volume control */
    1989         memset(&id, 0, sizeof(id));
    1990         id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    1991         strcpy(id.name, "Master Playback Switch");
    1992         chip->master_switch = snd_ctl_find_id(chip->card, &id);
    1993         memset(&id, 0, sizeof(id));
    1994         id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    1995         strcpy(id.name, "Master Playback Volume");
    1996         chip->master_volume = snd_ctl_find_id(chip->card, &id);
     2020        memset(&elem_id, 0, sizeof(elem_id));
     2021        elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     2022        strcpy(elem_id.name, "Master Playback Switch");
     2023        chip->master_switch = snd_ctl_find_id(chip->card, &elem_id);
     2024        memset(&elem_id, 0, sizeof(elem_id));
     2025        elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     2026        strcpy(elem_id.name, "Master Playback Volume");
     2027        chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
    19972028
    19982029        return 0;
     
    24542485{
    24552486        if (chip->io_port) {
    2456                 synchronize_irq(chip->irq);
     2487                if (chip->irq >= 0)
     2488                        synchronize_irq(chip->irq);
    24572489                outw(1, chip->io_port + 0x04); /* clear WP interrupts */
    24582490                outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/fm801.c

    r305 r358  
    12861286static int snd_fm801_chip_init(struct fm801 *chip, int resume)
    12871287{
    1288         int id;
    12891288        unsigned short cmdw;
    12901289
     
    13111310                        /* my card has the secondary codec */
    13121311                        /* at address #3, so the loop is inverted */
    1313                         for (id = 3; id > 0; id--) {
    1314                                 if (! wait_for_codec(chip, id, AC97_VENDOR_ID1,
     1312                        int i;
     1313                        for (i = 3; i > 0; i--) {
     1314                                if (!wait_for_codec(chip, i, AC97_VENDOR_ID1,
    13151315                                                     msecs_to_jiffies(50))) {
    13161316                                        cmdw = inw(FM801_REG(chip, AC97_DATA));
    13171317                                        if (cmdw != 0xffff && cmdw != 0) {
    13181318                                                chip->secondary = 1;
    1319                                                 chip->secondary_addr = id;
     1319                                                chip->secondary_addr = i;
    13201320                                                break;
    13211321                                        }
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_codec.c

    r339 r358  
    3232#include "hda_local.h"
    3333#include <sound/hda_hwdep.h>
     34#include "hda_patch.h"  /* codec presets */
    3435
    3536#ifdef CONFIG_SND_HDA_POWER_SAVE
     
    5253/* codec vendor labels */
    5354static struct hda_vendor_id hda_vendor_ids[] = {
     55        { 0x1002, "ATI" },
     56        { 0x1057, "Motorola" },
     57        { 0x1095, "Silicon Image" },
    5458        { 0x10ec, "Realtek" },
    55         { 0x1057, "Motorola" },
    5659        { 0x1106, "VIA" },
    5760        { 0x111d, "IDT" },
     61        { 0x11c1, "LSI" },
    5862        { 0x11d4, "Analog Devices" },
    5963        { 0x13f6, "C-Media" },
    6064        { 0x14f1, "Conexant" },
     65        { 0x17e8, "Chrontel" },
     66        { 0x1854, "LG" },
    6167        { 0x434d, "C-Media" },
    6268        { 0x8384, "SigmaTel" },
     
    6470};
    6571
    66 /* codec presets */
    67 #include "hda_patch.h"
    68 
     72static const struct hda_codec_preset *hda_preset_tables[] = {
     73#ifdef CONFIG_SND_HDA_CODEC_REALTEK
     74        snd_hda_preset_realtek,
     75#endif
     76#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
     77        snd_hda_preset_cmedia,
     78#endif
     79#ifdef CONFIG_SND_HDA_CODEC_ANALOG
     80        snd_hda_preset_analog,
     81#endif
     82#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
     83        snd_hda_preset_sigmatel,
     84#endif
     85#ifdef CONFIG_SND_HDA_CODEC_SI3054
     86        snd_hda_preset_si3054,
     87#endif
     88#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
     89        snd_hda_preset_atihdmi,
     90#endif
     91#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
     92        snd_hda_preset_conexant,
     93#endif
     94#ifdef CONFIG_SND_HDA_CODEC_VIA
     95        snd_hda_preset_via,
     96#endif
     97        NULL
     98};
    6999
    70100#ifdef CONFIG_SND_HDA_POWER_SAVE
     
    282312        schedule_work(&unsol->work);
    283313#endif
    284 
    285314        return 0;
    286315}
     
    696725        msleep(1);
    697726        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
     727}
     728
     729void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
     730{
     731        if (!nid)
     732                return;
     733
     734        snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid);
     735        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
     736#if 0 /* keep the format */
     737        msleep(1);
     738        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0);
     739#endif
    698740}
    699741
     
    10711113        int err;
    10721114
     1115        for (s = slaves; *s && !snd_hda_find_mixer_ctl(codec, *s); s++)
     1116                ;
     1117        if (!*s) {
     1118                snd_printdd("No slave found for %s\n", name);
     1119                return 0;
     1120        }
    10731121        kctl = snd_ctl_make_virtual_master(name, tlv);
    10741122        if (!kctl)
     
    12131261        int err;
    12141262
     1263        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12151264        c = (struct hda_bind_ctls *)kcontrol->private_value;
    1216         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12171265        kcontrol->private_value = *c->values;
    12181266        err = c->ops->info(kcontrol, uinfo);
     
    12291277        int err;
    12301278
     1279        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12311280        c = (struct hda_bind_ctls *)kcontrol->private_value;
    1232         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12331281        kcontrol->private_value = *c->values;
    12341282        err = c->ops->get(kcontrol, ucontrol);
     
    12461294        int err = 0, change = 0;
    12471295
     1296        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12481297        c = (struct hda_bind_ctls *)kcontrol->private_value;
    1249         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12501298        for (vals = c->values; *vals; vals++) {
    12511299                kcontrol->private_value = *vals;
     
    12671315        int err;
    12681316
     1317        mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12691318        c = (struct hda_bind_ctls *)kcontrol->private_value;
    1270         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
    12711319        kcontrol->private_value = *c->values;
    12721320        err = c->ops->tlv(kcontrol, op_flag, size, tlv);
     
    15321580        codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
    15331581        return 0;
     1582}
     1583
     1584/*
     1585 * SPDIF sharing with analog output
     1586 */
     1587static int spdif_share_sw_get(struct snd_kcontrol *kcontrol,
     1588                              struct snd_ctl_elem_value *ucontrol)
     1589{
     1590        struct hda_multi_out *mout = snd_kcontrol_chip(kcontrol);
     1591        ucontrol->value.integer.value[0] = mout->share_spdif;
     1592        return 0;
     1593}
     1594
     1595static int spdif_share_sw_put(struct snd_kcontrol *kcontrol,
     1596                              struct snd_ctl_elem_value *ucontrol)
     1597{
     1598        struct hda_multi_out *mout = snd_kcontrol_chip(kcontrol);
     1599        mout->share_spdif = !!ucontrol->value.integer.value[0];
     1600        return 0;
     1601}
     1602
     1603static struct snd_kcontrol_new spdif_share_sw = {
     1604        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1605        .name = "IEC958 Default PCM Playback Switch",
     1606        .info = snd_ctl_boolean_mono_info,
     1607        .get = spdif_share_sw_get,
     1608        .put = spdif_share_sw_put,
     1609};
     1610
     1611int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
     1612                                  struct hda_multi_out *mout)
     1613{
     1614        if (!mout->dig_out_nid)
     1615                return 0;
     1616        /* ATTENTION: here mout is passed as private_data, instead of codec */
     1617        return snd_ctl_add(codec->bus->card,
     1618                           snd_ctl_new1(&spdif_share_sw, mout));
    15341619}
    15351620
     
    21392224                                   struct snd_pcm_substream *substream)
    21402225{
    2141         snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0);
     2226        snd_hda_codec_cleanup_stream(codec, hinfo->nid);
    21422227        return 0;
    21432228}
     
    22572342                return -1;
    22582343        if (tbl->value >= 0 && tbl->value < num_configs) {
    2259 #ifdef CONFIG_SND_DEBUG_DETECT
     2344#ifdef CONFIG_SND_DEBUG_VERBOSE
    22602345                char tmp[10];
    22612346                const char *model = NULL;
     
    25242609        if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
    25252610                /* already opened as analog dup; reset it once */
    2526                 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
     2611                snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
    25272612        mout->dig_out_used = HDA_DIG_EXCLUSIVE;
    25282613        mutex_unlock(&codec->spdif_mutex);
     
    25592644int snd_hda_multi_out_analog_open(struct hda_codec *codec,
    25602645                                  struct hda_multi_out *mout,
    2561                                   struct snd_pcm_substream *substream)
    2562 {
    2563         substream->runtime->hw.channels_max = mout->max_channels;
     2646                                  struct snd_pcm_substream *substream,
     2647                                  struct hda_pcm_stream *hinfo)
     2648{
     2649        struct snd_pcm_runtime *runtime = substream->runtime;
     2650        runtime->hw.channels_max = mout->max_channels;
     2651        if (mout->dig_out_nid) {
     2652                if (!mout->analog_rates) {
     2653                        mout->analog_rates = hinfo->rates;
     2654                        mout->analog_formats = hinfo->formats;
     2655                        mout->analog_maxbps = hinfo->maxbps;
     2656                } else {
     2657                        runtime->hw.rates = mout->analog_rates;
     2658                        runtime->hw.formats = mout->analog_formats;
     2659                        hinfo->maxbps = mout->analog_maxbps;
     2660                }
     2661                if (!mout->spdif_rates) {
     2662                        snd_hda_query_supported_pcm(codec, mout->dig_out_nid,
     2663                                                    &mout->spdif_rates,
     2664                                                    &mout->spdif_formats,
     2665                                                    &mout->spdif_maxbps);
     2666                }
     2667                mutex_lock(&codec->spdif_mutex);
     2668                if (mout->share_spdif) {
     2669                        runtime->hw.rates &= mout->spdif_rates;
     2670                        runtime->hw.formats &= mout->spdif_formats;
     2671                        if (mout->spdif_maxbps < hinfo->maxbps)
     2672                                hinfo->maxbps = mout->spdif_maxbps;
     2673                }
     2674                mutex_unlock(&codec->spdif_mutex);
     2675        }
    25642676        return snd_pcm_hw_constraint_step(substream->runtime, 0,
    25652677                                          SNDRV_PCM_HW_PARAM_CHANNELS, 2);
     
    25812693
    25822694        mutex_lock(&codec->spdif_mutex);
    2583         if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
     2695        if (mout->dig_out_nid && mout->share_spdif &&
     2696            mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
    25842697                if (chs == 2 &&
    25852698                    snd_hda_is_supported_format(codec, mout->dig_out_nid,
     
    25912704                } else {
    25922705                        mout->dig_out_used = 0;
    2593                         snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
    2594                                                    0, 0, 0);
     2706                        snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
    25952707                }
    25962708        }
     
    26342746
    26352747        for (i = 0; i < mout->num_dacs; i++)
    2636                 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0);
     2748                snd_hda_codec_cleanup_stream(codec, nids[i]);
    26372749        if (mout->hp_nid)
    2638                 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0);
     2750                snd_hda_codec_cleanup_stream(codec, mout->hp_nid);
    26392751        for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
    26402752                if (mout->extra_out_nid[i])
    2641                         snd_hda_codec_setup_stream(codec,
    2642                                                    mout->extra_out_nid[i],
    2643                                                    0, 0, 0);
     2753                        snd_hda_codec_cleanup_stream(codec,
     2754                                                     mout->extra_out_nid[i]);
    26442755        mutex_lock(&codec->spdif_mutex);
    26452756        if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
    2646                 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
     2757                snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
    26472758                mout->dig_out_used = 0;
    26482759        }
     
    28232934        }
    28242935
     2936        /* FIX-UP:
     2937         * If no line-out is defined but multiple HPs are found,
     2938         * some of them might be the real line-outs.
     2939         */
     2940        if (!cfg->line_outs && cfg->hp_outs > 1) {
     2941                int i = 0;
     2942                while (i < cfg->hp_outs) {
     2943                        /* The real HPs should have the sequence 0x0f */
     2944                        if ((sequences_hp[i] & 0x0f) == 0x0f) {
     2945                                i++;
     2946                                continue;
     2947                        }
     2948                        /* Move it to the line-out table */
     2949                        cfg->line_out_pins[cfg->line_outs] = cfg->hp_pins[i];
     2950                        sequences_line_out[cfg->line_outs] = sequences_hp[i];
     2951                        cfg->line_outs++;
     2952                        cfg->hp_outs--;
     2953                        memmove(cfg->hp_pins + i, cfg->hp_pins + i + 1,
     2954                                sizeof(cfg->hp_pins[0]) * (cfg->hp_outs - i));
     2955                        memmove(sequences_hp + i - 1, sequences_hp + i,
     2956                                sizeof(sequences_hp[0]) * (cfg->hp_outs - i));
     2957                }
     2958        }
     2959
    28252960        /* sort by sequence */
    28262961        sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_codec.h

    r305 r358  
    7979#define AC_VERB_GET_EAPD_BTLENABLE              0x0f0c
    8080#define AC_VERB_GET_DIGI_CONVERT_1              0x0f0d
    81 #define AC_VERB_GET_DIGI_CONVERT_2              0x0f0e
     81#define AC_VERB_GET_DIGI_CONVERT_2              0x0f0e /* unused */
    8282#define AC_VERB_GET_VOLUME_KNOB_CONTROL         0x0f0f
    8383/* f10-f1a: GPIO */
     
    501501        struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1];
    502502
     503#ifndef TARGET_OS2
     504        struct mutex cmd_mutex;
     505#else
    503506        struct semaphore cmd_mutex;
     507#endif
    504508
    505509        /* unsolicited event queue */
     
    591595};
    592596
     597/* PCM types */
     598enum {
     599        HDA_PCM_TYPE_AUDIO,
     600        HDA_PCM_TYPE_SPDIF,
     601        HDA_PCM_TYPE_HDMI,
     602        HDA_PCM_TYPE_MODEM,
     603        HDA_PCM_NTYPES
     604};
     605
    593606/* for PCM creation */
    594607struct hda_pcm {
    595608        char *name;
    596609        struct hda_pcm_stream stream[2];
    597         unsigned int is_modem;  /* modem codec? */
     610        unsigned int pcm_type;  /* HDA_PCM_TYPE_XXX */
     611        int device;     /* assigned device number */
    598612};
    599613
     
    633647        struct hda_cache_rec cmd_cache; /* cache for other commands */
    634648
     649#ifndef TARGET_OS2
     650        struct mutex spdif_mutex;
     651#else
    635652        struct semaphore spdif_mutex;
     653#endif
    636654        unsigned int spdif_status;      /* IEC958 status bits */
    637655        unsigned short spdif_ctls;      /* SPDIF control bits */
     
    713731                                u32 stream_tag,
    714732                                int channel_id, int format);
     733void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid);
    715734unsigned int snd_hda_calc_stream_format(unsigned int rate,
    716735                                        unsigned int channels,
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_generic.c

    r305 r358  
    481481                return "Aux";
    482482        case AC_JACK_MIC_IN:
    483         if (pinctl &&
    484             (node->pin_caps &
    485              (AC_PINCAP_VREF_80 << AC_PINCAP_VREF_SHIFT)))
    486                 *pinctl |= AC_PINCTL_VREF_80;
    487         if ((location & 0x0f) == AC_JACK_LOC_FRONT)
    488                 return "Front Mic";
    489         return "Mic";
     483                if (pinctl &&
     484                    (node->pin_caps &
     485                     (AC_PINCAP_VREF_80 << AC_PINCAP_VREF_SHIFT)))
     486                        *pinctl |= AC_PINCTL_VREF_80;
     487                if ((location & 0x0f) == AC_JACK_LOC_FRONT)
     488                        return "Front Mic";
     489                return "Mic";
    490490        case AC_JACK_SPDIF_IN:
    491491                return "SPDIF";
     
    680680}
    681681
    682 
    683682#ifdef CONFIG_SND_HDA_POWER_SAVE
    684683static void add_input_loopback(struct hda_codec *codec, hda_nid_t nid,
     
    728727                knew.put = snd_hda_mixer_amp_switch_put;
    729728                knew.private_value = (node->nid | (3 << 16) | (HDA_INPUT << 18) | (index << 19));
    730 
    731729                if (is_loopback)
    732730                        add_input_loopback(codec, node->nid, HDA_INPUT, index);
     
    773771                   (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) {
    774772                /*knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);*/
    775         knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    776         knew.name = name;
    777         knew.info = snd_hda_mixer_amp_volume_info;
    778         knew.get = snd_hda_mixer_amp_volume_get;
    779         knew.put = snd_hda_mixer_amp_volume_put;
    780         knew.private_value = (node->nid | (3 << 16) | (HDA_OUTPUT << 18) | (0 << 19));
     773                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     774                knew.name = name;
     775                knew.info = snd_hda_mixer_amp_volume_info;
     776                knew.get = snd_hda_mixer_amp_volume_get;
     777                knew.put = snd_hda_mixer_amp_volume_put;
     778                knew.private_value = (node->nid | (3 << 16) | (HDA_OUTPUT << 18) | (0 << 19));
    781779                snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
    782780                if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)
     
    891889                sprintf(name, "%s Capture Volume",
    892890                        spec->input_mux.items[i].label);
    893                 /*knew = (struct snd_kcontrol_new)
     891/*              knew = (struct snd_kcontrol_new)
    894892                        HDA_CODEC_VOLUME(name, adc_node->nid,
    895893                                         spec->input_mux.items[i].index,
    896                                         HDA_INPUT);*/
     894                                        HDA_INPUT);*/
    897895                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    898896                knew.name = name;
     
    905903                knew.tlv.c = snd_hda_mixer_amp_tlv,
    906904                knew.private_value = (adc_node->nid | (3 << 16) | (HDA_INPUT << 18) | (spec->input_mux.items[i].index << 19));
    907 
    908905                if ((err = snd_ctl_add(codec->bus->card,
    909906                                       snd_ctl_new1(&knew, codec))) < 0)
     
    10471044        struct hda_gspec *spec = codec->spec;
    10481045
    1049         snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0);
    1050         snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 0, 0, 0);
     1046        snd_hda_codec_cleanup_stream(codec, hinfo->nid);
     1047        snd_hda_codec_cleanup_stream(codec, spec->dac_node[1]->nid);
    10511048        return 0;
    10521049}
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_hwdep.c

    r305 r358  
    2222#include <linux/slab.h>
    2323#include <linux/pci.h>
     24#include <linux/compat.h>
    2425#include <linux/mutex.h>
    2526#include <sound/core.h>
     
    8889static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
    8990{
    90 #ifndef CONFIG_SND_DEBUG_DETECT
     91#ifndef CONFIG_SND_DEBUG_VERBOSE
    9192        if (!capable(CAP_SYS_RAWIO))
    9293                return -EACCES;
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_intel.c

    r339 r358  
    4040#include <linux/kernel.h>
    4141#include <linux/module.h>
     42#include <linux/dma-mapping.h>
    4243#include <linux/moduleparam.h>
    4344#include <linux/init.h>
     
    5657static int position_fix[SNDRV_CARDS];
    5758#ifndef TARGET_OS2
     59static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
    5860static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
    5961#else
     62static int bdl_pos_adj[SNDRV_CARDS] = {-1};
    6063static int probe_mask[SNDRV_CARDS] = {-1};
    6164#endif
     
    7376module_param_array(position_fix, int, NULL, 0444);
    7477MODULE_PARM_DESC(position_fix, "Fix DMA pointer "
    75                  "(0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size).");
     78                 "(0 = auto, 1 = none, 2 = POSBUF).");
     79module_param_array(bdl_pos_adj, int, NULL, 0644);
     80MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset.");
    7681module_param_array(probe_mask, int, NULL, 0444);
    7782MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
     
    190195/* max number of SDs */
    191196/* ICH, ATI and VIA have 4 playback and 4 capture */
    192 #define ICH6_CAPTURE_INDEX      0
    193197#define ICH6_NUM_CAPTURE        4
    194 #define ICH6_PLAYBACK_INDEX     4
    195198#define ICH6_NUM_PLAYBACK       4
    196199
    197200/* ULI has 6 playback and 5 capture */
    198 #define ULI_CAPTURE_INDEX       0
    199201#define ULI_NUM_CAPTURE         5
    200 #define ULI_PLAYBACK_INDEX      5
    201202#define ULI_NUM_PLAYBACK        6
    202203
    203204/* ATI HDMI has 1 playback and 0 capture */
    204 #define ATIHDMI_CAPTURE_INDEX   0
    205205#define ATIHDMI_NUM_CAPTURE     0
    206 #define ATIHDMI_PLAYBACK_INDEX  0
    207206#define ATIHDMI_NUM_PLAYBACK    1
     207
     208/* TERA has 4 playback and 3 capture */
     209#define TERA_NUM_CAPTURE        3
     210#define TERA_NUM_PLAYBACK       4
    208211
    209212/* this number is statically defined for simplicity */
     
    211214
    212215/* max number of fragments - we may use more if allocating more pages for BDL */
    213 #define BDL_SIZE                PAGE_ALIGN(8192)
    214 #define AZX_MAX_FRAG            (BDL_SIZE / (MAX_AZX_DEV * 16))
     216#define BDL_SIZE                4096
     217#define AZX_MAX_BDL_ENTRIES     (BDL_SIZE / 16)
     218#define AZX_MAX_FRAG            32
    215219/* max buffer size - no h/w limit, you can increase as you like */
    216220#define AZX_MAX_BUF_SIZE        (1024*1024*1024)
    217221/* max number of PCM devics per card */
    218 #define AZX_MAX_AUDIO_PCMS      6
    219 #define AZX_MAX_MODEM_PCMS      2
    220 #define AZX_MAX_PCMS            (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS)
     222#define AZX_MAX_PCMS            8
    221223
    222224/* RIRB int mask: overrun[2], response[0] */
     
    232234#define SD_CTL_STREAM_RESET     0x01    /* stream reset bit */
    233235#define SD_CTL_DMA_START        0x02    /* stream DMA start bit */
     236#define SD_CTL_STRIPE           (3 << 16)       /* stripe control */
     237#define SD_CTL_TRAFFIC_PRIO     (1 << 18)       /* traffic priority */
     238#define SD_CTL_DIR              (1 << 19)       /* bi-directional stream */
    234239#define SD_CTL_STREAM_TAG_MASK  (0xf << 20)
    235240#define SD_CTL_STREAM_TAG_SHIFT 20
     
    267272enum {
    268273        POS_FIX_AUTO,
    269         POS_FIX_NONE,
     274        POS_FIX_LPIB,
    270275        POS_FIX_POSBUF,
    271         POS_FIX_FIFO,
    272276};
    273277
     
    289293
    290294struct azx_dev {
     295        struct snd_dma_buffer bdl; /* BDL buffer */
    291296#ifdef TARGET_OS2
    292         volatile u32 *bdl;              /* virtual address of the BDL */
    293         dma_addr_t bdl_addr;            /* physical address of the BDL */
    294297        volatile u32 *posbuf;           /* position buffer pointer */
    295298#else
    296         u32 *bdl;               /* virtual address of the BDL */
    297         dma_addr_t bdl_addr;    /* physical address of the BDL */
    298299        u32 *posbuf;            /* position buffer pointer */
    299300#endif
    300 
    301301        unsigned int bufsize;   /* size of the play buffer in bytes */
    302         unsigned int fragsize;  /* size of each period in bytes */
     302        unsigned int period_bytes; /* size of the period in bytes */
    303303        unsigned int frags;     /* number for period in the play buffer */
    304304        unsigned int fifo_size; /* FIFO size */
     
    306306#ifdef TARGET_OS2
    307307        volatile void __iomem *sd_addr;         /* stream descriptor pointer */
    308 #else /* !TARGET_OS2 */
     308#else
    309309        void __iomem *sd_addr;  /* stream descriptor pointer */
    310 #endif /* !TARGET_OS2 */
     310#endif
    311311
    312312        u32 sd_int_sta_mask;    /* stream int status mask */
     
    321321        unsigned char stream_tag;       /* assigned stream */
    322322        unsigned char index;            /* stream index */
    323         /* for sanity check of position buffer */
    324         unsigned int period_intr;
    325323
    326324        unsigned int opened :1;
    327325        unsigned int running :1;
     326        unsigned int irq_pending :1;
     327        unsigned int irq_ignore :1;
    328328};
    329329
    330330/* CORB/RIRB */
    331331struct azx_rb {
    332         volatile u32 *buf;      /* CORB/RIRB buffer
    333                                  * Each CORB entry is 4byte, RIRB is 8byte
     332#ifdef TARGET_OS2
     333        volatile u32 *buf;              /* CORB/RIRB buffer */
     334#else
     335        u32 *buf;               /* CORB/RIRB buffer */
     336#endif
     337                                /* Each CORB entry is 4byte, RIRB is 8byte
    334338                                 */
    335339        dma_addr_t addr;        /* physical address of CORB/RIRB buffer */
     
    343347        struct snd_card *card;
    344348        struct pci_dev *pci;
     349        int dev_index;
    345350
    346351        /* chip type specific */
     
    369374
    370375        /* PCM */
    371         unsigned int pcm_devs;
    372376        struct snd_pcm *pcm[AZX_MAX_PCMS];
    373377
     
    380384        struct azx_rb rirb;
    381385
    382         /* BDL, CORB/RIRB and position buffers */
    383         struct snd_dma_buffer bdl;
     386        /* CORB/RIRB and position buffers */
    384387        struct snd_dma_buffer rb;
    385388        struct snd_dma_buffer posbuf;
     
    392395        unsigned int polling_mode :1;
    393396        unsigned int msi :1;
     397        unsigned int irq_pending_warned :1;
    394398
    395399        /* for debugging */
    396400        unsigned int last_cmd;  /* last issued command (to sync) */
     401
     402        /* for pending irqs */
     403        struct work_struct irq_pending_work;
    397404};
    398405
     
    407414        AZX_DRIVER_ULI,
    408415        AZX_DRIVER_NVIDIA,
     416        AZX_DRIVER_TERA,
    409417};
    410418
     
    418426        [AZX_DRIVER_ULI] = "HDA ULI M5461",
    419427        [AZX_DRIVER_NVIDIA] = "HDA NVidia",
     428        [AZX_DRIVER_TERA] = "HDA Teradici",
    420429};
    421430
     
    452461#define get_azx_dev(substream) (substream->runtime->private_data)
    453462
    454 /* Get the upper 32bit of the given dma_addr_t
    455  * Compiler should optimize and eliminate the code if dma_addr_t is 32bit
    456  */
    457 #define upper_32bit(addr) (sizeof(addr) > 4 ? (u32)(((unsigned long long)addr) >> 32) : (u32)0)
    458 
    459463static int azx_acquire_irq(struct azx *chip, int do_disconnect);
    460464
     
    487491        chip->corb.buf = (u32 *)chip->rb.area;
    488492        azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
    489         azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr));
     493        azx_writel(chip, CORBUBASE, upper_32_bits(chip->corb.addr));
    490494
    491495        /* set the corb size to 256 entries (ULI requires explicitly) */
     
    502506        chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
    503507        azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
    504         azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr));
     508        azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
    505509
    506510        /* set the rirb size to 256 entries (ULI requires explicitly) */
     
    565569                        snd_hda_queue_unsol_event(chip->bus, res, res_ex);
    566570                else if (chip->rirb.cmds) {
     571                        chip->rirb.res = res;
     572                        smp_wmb();
    567573                        chip->rirb.cmds--;
    568                         chip->rirb.res = res;
    569574                }
    570575        }
     
    585590                        spin_unlock_irq(&chip->reg_lock);
    586591                }
    587                 if (!chip->rirb.cmds)
     592                if (!chip->rirb.cmds) {
     593                        smp_rmb();
    588594                        return chip->rirb.res; /* the last value */
     595                }
    589596                if (time_after(jiffies, timeout))
    590597                        break;
     
    870877        /* program the position buffer */
    871878        azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
    872         azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr));
     879        azx_writel(chip, DPUBASE, upper_32_bits(chip->posbuf.addr));
    873880
    874881        chip->initialized = 1;
     
    931938
    932939
     940static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev);
     941
    933942/*
    934943 * interrupt handler
     
    953962                if (status & azx_dev->sd_int_sta_mask) {
    954963                        azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
    955                         if (azx_dev->substream && azx_dev->running) {
    956                                 azx_dev->period_intr++;
     964                        if (!azx_dev->substream || !azx_dev->running)
     965                                continue;
     966                        /* ignore the first dummy IRQ (due to pos_adj) */
     967                        if (azx_dev->irq_ignore) {
     968                                azx_dev->irq_ignore = 0;
     969                                continue;
     970                        }
     971                        /* check whether this IRQ is really acceptable */
     972                        if (azx_position_ok(chip, azx_dev)) {
     973                                azx_dev->irq_pending = 0;
    957974                                spin_unlock(&chip->reg_lock);
    958975                                snd_pcm_period_elapsed(azx_dev->substream);
    959976                                spin_lock(&chip->reg_lock);
     977                        } else {
     978                                /* bogus IRQ, process it later */
     979                                azx_dev->irq_pending = 1;
     980#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     981                                schedule_work(&chip->irq_pending_work);
     982#endif
    960983                        }
    961984                }
     
    9821005
    9831006/*
     1007 * set up a BDL entry
     1008 */
     1009static int setup_bdle(struct snd_pcm_substream *substream,
     1010                      struct azx_dev *azx_dev, u32 **bdlp,
     1011                      int ofs, int size, int with_ioc)
     1012{
     1013        struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
     1014        u32 *bdl = *bdlp;
     1015
     1016        while (size > 0) {
     1017                dma_addr_t addr;
     1018                int chunk;
     1019
     1020                if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
     1021                        return -EINVAL;
     1022
     1023                addr = snd_pcm_sgbuf_get_addr(sgbuf, ofs);
     1024                /* program the address field of the BDL entry */
     1025                bdl[0] = cpu_to_le32((u32)addr);
     1026                bdl[1] = cpu_to_le32(upper_32_bits(addr));
     1027                /* program the size field of the BDL entry */
     1028                chunk = PAGE_SIZE - (ofs % PAGE_SIZE);
     1029                if (size < chunk)
     1030                        chunk = size;
     1031                bdl[2] = cpu_to_le32(chunk);
     1032                /* program the IOC to enable interrupt
     1033                 * only when the whole fragment is processed
     1034                 */
     1035                size -= chunk;
     1036                bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
     1037                bdl += 4;
     1038                azx_dev->frags++;
     1039                ofs += chunk;
     1040        }
     1041        *bdlp = bdl;
     1042        return ofs;
     1043}
     1044
     1045/*
    9841046 * set up BDL entries
    9851047 */
    986 static void azx_setup_periods(struct azx_dev *azx_dev)
     1048static int azx_setup_periods(struct azx *chip,
     1049                             struct snd_pcm_substream *substream,
     1050                             struct azx_dev *azx_dev)
    9871051{
    9881052#ifdef TARGET_OS2
    989         volatile u32 *bdl = azx_dev->bdl;
    990 #else /* !TARGET_OS2 */
    991         u32 *bdl = azx_dev->bdl;
    992 #endif /* !TARGET_OS2 */
    993         dma_addr_t dma_addr = azx_dev->substream->runtime->dma_addr;
    994         int idx;
     1053        volatile u32 *bdl;
     1054#else
     1055        u32 *bdl;
     1056#endif
     1057        int i, ofs, periods, period_bytes;
     1058        int pos_adj;
    9951059
    9961060        /* reset BDL address */
     
    9981062        azx_sd_writel(azx_dev, SD_BDLPU, 0);
    9991063
     1064        period_bytes = snd_pcm_lib_period_bytes(substream);
     1065        azx_dev->period_bytes = period_bytes;
     1066        periods = azx_dev->bufsize / period_bytes;
     1067
    10001068        /* program the initial BDL entries */
    1001         for (idx = 0; idx < azx_dev->frags; idx++) {
    1002                 unsigned int off = idx << 2; /* 4 dword step */
    1003                 dma_addr_t addr = dma_addr + idx * azx_dev->fragsize;
    1004                 /* program the address field of the BDL entry */
    1005                 bdl[off] = cpu_to_le32((u32)addr);
    1006                 bdl[off+1] = cpu_to_le32(upper_32bit(addr));
    1007 
    1008                 /* program the size field of the BDL entry */
    1009                 bdl[off+2] = cpu_to_le32(azx_dev->fragsize);
    1010 
    1011                 /* program the IOC to enable interrupt when buffer completes */
    1012                 bdl[off+3] = cpu_to_le32(0x01);
    1013         }
     1069        bdl = (u32 *)azx_dev->bdl.area;
     1070        ofs = 0;
     1071        azx_dev->frags = 0;
     1072        azx_dev->irq_ignore = 0;
     1073        pos_adj = bdl_pos_adj[chip->dev_index];
     1074        if (pos_adj > 0) {
     1075                struct snd_pcm_runtime *runtime = substream->runtime;
     1076                pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
     1077                if (!pos_adj)
     1078                        pos_adj = 1;
     1079                pos_adj = frames_to_bytes(runtime, pos_adj);
     1080                if (pos_adj >= period_bytes) {
     1081                        snd_printk(KERN_WARNING "Too big adjustment %d\n",
     1082                                   bdl_pos_adj[chip->dev_index]);
     1083                        pos_adj = 0;
     1084                } else {
     1085                        ofs = setup_bdle(substream, azx_dev,
     1086                                         &bdl, ofs, pos_adj, 1);
     1087                        if (ofs < 0)
     1088                                goto error;
     1089                        azx_dev->irq_ignore = 1;
     1090                }
     1091        } else
     1092                pos_adj = 0;
     1093        for (i = 0; i < periods; i++) {
     1094                if (i == periods - 1 && pos_adj)
     1095                        ofs = setup_bdle(substream, azx_dev, &bdl, ofs,
     1096                                         period_bytes - pos_adj, 0);
     1097                else
     1098                        ofs = setup_bdle(substream, azx_dev, &bdl, ofs,
     1099                                         period_bytes, 1);
     1100                if (ofs < 0)
     1101                        goto error;
     1102        }
     1103        return 0;
     1104
     1105 error:
     1106        snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n",
     1107                   azx_dev->bufsize, period_bytes);
     1108        /* reset */
     1109        azx_sd_writel(azx_dev, SD_BDLPL, 0);
     1110        azx_sd_writel(azx_dev, SD_BDLPU, 0);
     1111        return -EINVAL;
    10141112}
    10151113
     
    10601158        /* program the BDL address */
    10611159        /* lower BDL address */
    1062         azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl_addr);
     1160        azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
    10631161        /* upper BDL address */
    1064         azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr));
     1162        azx_sd_writel(azx_dev, SD_BDLPU, upper_32_bits(azx_dev->bdl.addr));
    10651163
    10661164        /* enable the position buffer */
    1067         if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
    1068                 azx_writel(chip, DPLBASE,
    1069                            (u32)chip->posbuf.addr |ICH6_DPLBASE_ENABLE);
     1165        if (chip->position_fix == POS_FIX_POSBUF ||
     1166            chip->position_fix == POS_FIX_AUTO) {
     1167                if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
     1168                        azx_writel(chip, DPLBASE,
     1169                                (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
     1170        }
    10701171
    10711172        /* set the interrupt enable bits in the descriptor control register */
     
    10821183
    10831184static unsigned int azx_max_codecs[] __devinitdata = {
    1084         [AZX_DRIVER_ICH] = 3,
     1185        [AZX_DRIVER_ICH] = 4,           /* Some ICH9 boards use SD3 */
    10851186        [AZX_DRIVER_SCH] = 3,
    10861187        [AZX_DRIVER_ATI] = 4,
     
    10901191        [AZX_DRIVER_ULI] = 3,           /* FIXME: correct? */
    10911192        [AZX_DRIVER_NVIDIA] = 3,        /* FIXME: correct? */
     1193        [AZX_DRIVER_TERA] = 1,
    10921194};
    10931195
     
    11801282                                 /* No full-resume yet implemented */
    11811283                                 /* SNDRV_PCM_INFO_RESUME |*/
    1182                                  SNDRV_PCM_INFO_PAUSE),
     1284                                 SNDRV_PCM_INFO_PAUSE |
     1285                                 SNDRV_PCM_INFO_SYNC_START),
    11831286        .formats =              SNDRV_PCM_FMTBIT_S16_LE,
    11841287        .rates =                SNDRV_PCM_RATE_48000,
     
    12421345
    12431346        runtime->private_data = azx_dev;
     1347        snd_pcm_set_sync(substream);
    12441348        mutex_unlock(&chip->open_mutex);
    12451349        return 0;
     
    12981402
    12991403        azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream);
    1300         azx_dev->fragsize = snd_pcm_lib_period_bytes(substream);
    1301         azx_dev->frags = azx_dev->bufsize / azx_dev->fragsize;
    13021404        azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate,
    13031405                                                         runtime->channels,
     
    13111413        }
    13121414
    1313         snd_printdd("azx_pcm_prepare: bufsize=0x%x, fragsize=0x%x, "
    1314                     "format=0x%x\n",
    1315                     azx_dev->bufsize, azx_dev->fragsize, azx_dev->format_val);
    1316         azx_setup_periods(azx_dev);
     1415        snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
     1416                    azx_dev->bufsize, azx_dev->format_val);
     1417        if (azx_setup_periods(chip, substream, azx_dev) < 0)
     1418                return -EINVAL;
    13171419        azx_setup_controller(chip, azx_dev);
    13181420        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
     
    13281430{
    13291431        struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
    1330         struct azx_dev *azx_dev = get_azx_dev(substream);
    13311432        struct azx *chip = apcm->chip;
    1332         int err = 0;
    1333 
    1334         spin_lock(&chip->reg_lock);
     1433        struct azx_dev *azx_dev;
     1434        struct snd_pcm_substream *s;
     1435        int start, nsync = 0, sbits = 0;
     1436        int nwait, timeout;
     1437
    13351438        switch (cmd) {
    13361439        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
    13371440        case SNDRV_PCM_TRIGGER_RESUME:
    13381441        case SNDRV_PCM_TRIGGER_START:
    1339                 azx_stream_start(chip, azx_dev);
    1340                 azx_dev->running = 1;
     1442                start = 1;
    13411443                break;
    13421444        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
    13431445        case SNDRV_PCM_TRIGGER_SUSPEND:
    13441446        case SNDRV_PCM_TRIGGER_STOP:
    1345                 azx_stream_stop(chip, azx_dev);
    1346                 azx_dev->running = 0;
     1447                start = 0;
    13471448                break;
    13481449        default:
    1349                 err = -EINVAL;
     1450                return -EINVAL;
     1451        }
     1452
     1453        snd_pcm_group_for_each_entry(s, substream) {
     1454                if (s->pcm->card != substream->pcm->card)
     1455                        continue;
     1456                azx_dev = get_azx_dev(s);
     1457                sbits |= 1 << azx_dev->index;
     1458                nsync++;
     1459                snd_pcm_trigger_done(s, substream);
     1460        }
     1461
     1462        spin_lock(&chip->reg_lock);
     1463        if (nsync > 1) {
     1464                /* first, set SYNC bits of corresponding streams */
     1465                azx_writel(chip, SYNC, azx_readl(chip, SYNC) | sbits);
     1466        }
     1467        snd_pcm_group_for_each_entry(s, substream) {
     1468                if (s->pcm->card != substream->pcm->card)
     1469                        continue;
     1470                azx_dev = get_azx_dev(s);
     1471                if (start)
     1472                        azx_stream_start(chip, azx_dev);
     1473                else
     1474                        azx_stream_stop(chip, azx_dev);
     1475                azx_dev->running = start;
    13501476        }
    13511477        spin_unlock(&chip->reg_lock);
    1352         if (cmd == SNDRV_PCM_TRIGGER_PAUSE_PUSH ||
    1353             cmd == SNDRV_PCM_TRIGGER_SUSPEND ||
    1354             cmd == SNDRV_PCM_TRIGGER_STOP) {
    1355 #ifndef TARGET_OS2
    1356                 int timeout = 5000;
    1357 #else /* TARGET_OS2 */
    1358                 int timeout = 100000;
    1359 #endif /* TARGET_OS2 */
    1360                 while ((azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START) &&
    1361                        --timeout)
    1362                         ;
    1363         }
    1364         return err;
    1365 }
    1366 
    1367 static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
    1368 {
    1369         struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
    1370         struct azx *chip = apcm->chip;
    1371         struct azx_dev *azx_dev = get_azx_dev(substream);
     1478        if (start) {
     1479                if (nsync == 1)
     1480                        return 0;
     1481                /* wait until all FIFOs get ready */
     1482                for (timeout = 5000; timeout; timeout--) {
     1483                        nwait = 0;
     1484                        snd_pcm_group_for_each_entry(s, substream) {
     1485                                if (s->pcm->card != substream->pcm->card)
     1486                                        continue;
     1487                                azx_dev = get_azx_dev(s);
     1488                                if (!(azx_sd_readb(azx_dev, SD_STS) &
     1489                                      SD_STS_FIFO_READY))
     1490                                        nwait++;
     1491                        }
     1492                        if (!nwait)
     1493                                break;
     1494                        cpu_relax();
     1495                }
     1496        } else {
     1497                /* wait until all RUN bits are cleared */
     1498                for (timeout = 5000; timeout; timeout--) {
     1499                        nwait = 0;
     1500                        snd_pcm_group_for_each_entry(s, substream) {
     1501                                if (s->pcm->card != substream->pcm->card)
     1502                                        continue;
     1503                                azx_dev = get_azx_dev(s);
     1504                                if (azx_sd_readb(azx_dev, SD_CTL) &
     1505                                    SD_CTL_DMA_START)
     1506                                        nwait++;
     1507                        }
     1508                        if (!nwait)
     1509                                break;
     1510                        cpu_relax();
     1511                }
     1512        }
     1513        if (nsync > 1) {
     1514                spin_lock(&chip->reg_lock);
     1515                /* reset SYNC bits */
     1516                azx_writel(chip, SYNC, azx_readl(chip, SYNC) & ~sbits);
     1517                spin_unlock(&chip->reg_lock);
     1518        }
     1519        return 0;
     1520}
     1521
     1522static unsigned int azx_get_position(struct azx *chip,
     1523                                     struct azx_dev *azx_dev)
     1524{
    13721525        unsigned int pos;
    13731526
     
    13761529                /* use the position buffer */
    13771530                pos = le32_to_cpu(*azx_dev->posbuf);
    1378                 if (chip->position_fix == POS_FIX_AUTO &&
    1379                     azx_dev->period_intr == 1 && !pos) {
     1531        } else {
     1532                /* read LPIB */
     1533                pos = azx_sd_readl(azx_dev, SD_LPIB);
     1534        }
     1535        if (pos >= azx_dev->bufsize)
     1536                pos = 0;
     1537        return pos;
     1538}
     1539
     1540static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
     1541{
     1542        struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
     1543        struct azx *chip = apcm->chip;
     1544        struct azx_dev *azx_dev = get_azx_dev(substream);
     1545        return bytes_to_frames(substream->runtime,
     1546                               azx_get_position(chip, azx_dev));
     1547}
     1548
     1549/*
     1550 * Check whether the current DMA position is acceptable for updating
     1551 * periods.  Returns non-zero if it's OK.
     1552 *
     1553 * Many HD-audio controllers appear pretty inaccurate about
     1554 * the update-IRQ timing.  The IRQ is issued before actually the
     1555 * data is processed.  So, we need to process it afterwords in a
     1556 * workqueue.
     1557 */
     1558static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
     1559{
     1560        unsigned int pos;
     1561
     1562        pos = azx_get_position(chip, azx_dev);
     1563        if (chip->position_fix == POS_FIX_AUTO) {
     1564                if (!pos) {
    13801565                        printk(KERN_WARNING
    13811566                               "hda-intel: Invalid position buffer, "
    13821567                               "using LPIB read method instead.\n");
    1383                         chip->position_fix = POS_FIX_NONE;
    1384                         goto read_lpib;
     1568                        chip->position_fix = POS_FIX_LPIB;
     1569                        pos = azx_get_position(chip, azx_dev);
     1570                } else
     1571                        chip->position_fix = POS_FIX_POSBUF;
     1572        }
     1573
     1574        if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2)
     1575                return 0; /* NG - it's below the period boundary */
     1576        return 1; /* OK, it's fine */
     1577}
     1578
     1579/*
     1580 * The work for pending PCM period updates.
     1581 */
     1582static void azx_irq_pending_work(struct work_struct *work)
     1583{
     1584        struct azx *chip = container_of(work, struct azx, irq_pending_work);
     1585        int i, pending;
     1586
     1587        if (!chip->irq_pending_warned) {
     1588                printk(KERN_WARNING
     1589                       "hda-intel: IRQ timing workaround is activated "
     1590                       "for card #%d. Suggest a bigger bdl_pos_adj.\n",
     1591                       chip->card->number);
     1592                chip->irq_pending_warned = 1;
     1593        }
     1594
     1595        for (;;) {
     1596                pending = 0;
     1597                spin_lock_irq(&chip->reg_lock);
     1598                for (i = 0; i < chip->num_streams; i++) {
     1599                        struct azx_dev *azx_dev = &chip->azx_dev[i];
     1600                        if (!azx_dev->irq_pending ||
     1601                            !azx_dev->substream ||
     1602                            !azx_dev->running)
     1603                                continue;
     1604                        if (azx_position_ok(chip, azx_dev)) {
     1605                                azx_dev->irq_pending = 0;
     1606                                spin_unlock(&chip->reg_lock);
     1607                                snd_pcm_period_elapsed(azx_dev->substream);
     1608                                spin_lock(&chip->reg_lock);
     1609                        } else
     1610                                pending++;
    13851611                }
    1386         } else {
    1387         read_lpib:
    1388                 /* read LPIB */
    1389                 pos = azx_sd_readl(azx_dev, SD_LPIB);
    1390                 if (chip->position_fix == POS_FIX_FIFO)
    1391                         pos += azx_dev->fifo_size;
    1392         }
    1393         if (pos >= azx_dev->bufsize)
    1394                 pos = 0;
    1395         return bytes_to_frames(substream->runtime, pos);
     1612                spin_unlock_irq(&chip->reg_lock);
     1613                if (!pending)
     1614                        return;
     1615                cond_resched();
     1616        }
     1617}
     1618
     1619/* clear irq_pending flags and assure no on-going workq */
     1620static void azx_clear_irq_pending(struct azx *chip)
     1621{
     1622        int i;
     1623
     1624        spin_lock_irq(&chip->reg_lock);
     1625        for (i = 0; i < chip->num_streams; i++)
     1626                chip->azx_dev[i].irq_pending = 0;
     1627        spin_unlock_irq(&chip->reg_lock);
     1628        flush_scheduled_work();
    13961629}
    13971630
     
    14051638        .trigger = azx_pcm_trigger,
    14061639        .pointer = azx_pcm_pointer,
     1640        .page = snd_pcm_sgbuf_ops_page,
    14071641};
    14081642
     
    14131647
    14141648static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
    1415                                       struct hda_pcm *cpcm, int pcm_dev)
     1649                                      struct hda_pcm *cpcm)
    14161650{
    14171651        int err;
     
    14271661        snd_assert(cpcm->name, return -EINVAL);
    14281662
    1429         err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
     1663        err = snd_pcm_new(chip->card, cpcm->name, cpcm->device,
    14301664                          cpcm->stream[0].substreams,
    14311665                          cpcm->stream[1].substreams,
     
    14471681        if (cpcm->stream[1].substreams)
    14481682                snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops);
    1449         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
     1683        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
    14501684                                              snd_dma_pci_data(chip->pci),
    14511685                                              1024 * 64, 1024 * 1024);
    1452         chip->pcm[pcm_dev] = pcm;
    1453         if (chip->pcm_devs < pcm_dev + 1)
    1454                 chip->pcm_devs = pcm_dev + 1;
    1455 
     1686        chip->pcm[cpcm->device] = pcm;
    14561687        return 0;
    14571688}
     
    14591690static int __devinit azx_pcm_create(struct azx *chip)
    14601691{
     1692        static const char *dev_name[HDA_PCM_NTYPES] = {
     1693                "Audio", "SPDIF", "HDMI", "Modem"
     1694        };
     1695        /* starting device index for each PCM type */
     1696        static int dev_idx[HDA_PCM_NTYPES] = {
     1697                [HDA_PCM_TYPE_AUDIO] = 0,
     1698                [HDA_PCM_TYPE_SPDIF] = 1,
     1699                [HDA_PCM_TYPE_HDMI] = 3,
     1700                [HDA_PCM_TYPE_MODEM] = 6
     1701        };
     1702        /* normal audio device indices; not linear to keep compatibility */
     1703        static int audio_idx[4] = { 0, 2, 4, 5 };
    14611704        struct hda_codec *codec;
    14621705        int c, err;
    1463         int pcm_dev;
     1706        int num_devs[HDA_PCM_NTYPES];
    14641707
    14651708        err = snd_hda_build_pcms(chip->bus);
     
    14681711
    14691712        /* create audio PCMs */
    1470         pcm_dev = 0;
     1713        memset(num_devs, 0, sizeof(num_devs));
    14711714        list_for_each_entry(codec, &chip->bus->codec_list, list, struct hda_codec) {
    14721715                for (c = 0; c < codec->num_pcms; c++) {
    1473                         if (codec->pcm_info[c].is_modem)
    1474                                 continue; /* create later */
    1475                         if (pcm_dev >= AZX_MAX_AUDIO_PCMS) {
    1476                                 snd_printk(KERN_ERR SFX
    1477                                            "Too many audio PCMs\n");
    1478                                 return -EINVAL;
     1716                        struct hda_pcm *cpcm = &codec->pcm_info[c];
     1717                        int type = cpcm->pcm_type;
     1718                        switch (type) {
     1719                        case HDA_PCM_TYPE_AUDIO:
     1720                                if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
     1721                                        snd_printk(KERN_WARNING
     1722                                                   "Too many audio devices\n");
     1723                                        continue;
     1724                                }
     1725                                cpcm->device = audio_idx[num_devs[type]];
     1726                                break;
     1727                        case HDA_PCM_TYPE_SPDIF:
     1728                        case HDA_PCM_TYPE_HDMI:
     1729                        case HDA_PCM_TYPE_MODEM:
     1730                                if (num_devs[type]) {
     1731                                        snd_printk(KERN_WARNING
     1732                                                   "%s already defined\n",
     1733                                                   dev_name[type]);
     1734                                        continue;
     1735                                }
     1736                                cpcm->device = dev_idx[type];
     1737                                break;
     1738                        default:
     1739                                snd_printk(KERN_WARNING
     1740                                           "Invalid PCM type %d\n", type);
     1741                                continue;
    14791742                        }
    1480                         err = create_codec_pcm(chip, codec,
    1481                                                &codec->pcm_info[c], pcm_dev);
     1743                        num_devs[type]++;
     1744                        err = create_codec_pcm(chip, codec, cpcm);
    14821745                        if (err < 0)
    14831746                                return err;
    1484                         pcm_dev++;
    1485                 }
    1486         }
    1487 
    1488         /* create modem PCMs */
    1489         pcm_dev = AZX_MAX_AUDIO_PCMS;
    1490         list_for_each_entry(codec, &chip->bus->codec_list, list, struct hda_codec) {
    1491                 for (c = 0; c < codec->num_pcms; c++) {
    1492                         if (!codec->pcm_info[c].is_modem)
    1493                                 continue; /* already created */
    1494                         if (pcm_dev >= AZX_MAX_PCMS) {
    1495                                 snd_printk(KERN_ERR SFX
    1496                                            "Too many modem PCMs\n");
    1497                                 return -EINVAL;
    1498                         }
    1499                         err = create_codec_pcm(chip, codec,
    1500                                                &codec->pcm_info[c], pcm_dev);
    1501                         if (err < 0)
    1502                                 return err;
    1503                         chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM;
    1504                         pcm_dev++;
    15051747                }
    15061748        }
     
    15291771         */
    15301772        for (i = 0; i < chip->num_streams; i++) {
    1531                 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4);
    15321773                struct azx_dev *azx_dev = &chip->azx_dev[i];
    1533                 azx_dev->bdl = (u32 *)(chip->bdl.area + off);
    1534                 azx_dev->bdl_addr = chip->bdl.addr + off;
    15351774                azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
    15361775                /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
     
    15531792                printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
    15541793                       "disabling device\n", chip->pci->irq);
    1555 #ifndef TARGET_OS2
     1794#ifndef TARGEt_OS2
    15561795                if (do_disconnect)
    15571796                        snd_card_disconnect(chip->card);
     
    15631802        return 0;
    15641803}
     1804
    15651805
    15661806static void azx_stop_chip(struct azx *chip)
     
    16151855
    16161856        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    1617         for (i = 0; i < chip->pcm_devs; i++)
     1857        azx_clear_irq_pending(chip);
     1858        for (i = 0; i < AZX_MAX_PCMS; i++)
    16181859                snd_pcm_suspend_all(chip->pcm[i]);
    16191860        if (chip->initialized)
     
    16211862        azx_stop_chip(chip);
    16221863        if (chip->irq >= 0) {
    1623                 synchronize_irq(chip->irq);
    16241864                free_irq(chip->irq, chip);
    16251865                chip->irq = -1;
     
    16691909static int azx_free(struct azx *chip)
    16701910{
     1911        int i;
     1912
    16711913        if (chip->initialized) {
    1672                 int i;
     1914                azx_clear_irq_pending(chip);
    16731915                for (i = 0; i < chip->num_streams; i++)
    16741916                        azx_stream_stop(chip, &chip->azx_dev[i]);
     
    16761918        }
    16771919
    1678         if (chip->irq >= 0) {
    1679                 synchronize_irq(chip->irq);
     1920        if (chip->irq >= 0)
    16801921                free_irq(chip->irq, (void*)chip);
    1681         }
    16821922        if (chip->msi)
    16831923                pci_disable_msi(chip->pci);
     
    16851925#ifdef TARGET_OS2
    16861926                iounmap((void *)chip->remap_addr);
    1687 #else /* !TARGET_OS2 */
     1927#else
    16881928                iounmap(chip->remap_addr);
    1689 #endif /* !TARGET_OS2 */
    1690 
    1691         if (chip->bdl.area)
    1692                 snd_dma_free_pages(&chip->bdl);
     1929#endif
     1930        if (chip->azx_dev) {
     1931                for (i = 0; i < chip->num_streams; i++)
     1932                        if (chip->azx_dev[i].bdl.area)
     1933                                snd_dma_free_pages(&chip->azx_dev[i].bdl);
     1934        }
    16931935        if (chip->rb.area)
    16941936                snd_dma_free_pages(&chip->rb);
     
    17121954 */
    17131955static struct snd_pci_quirk position_fix_list[] __devinitdata = {
    1714         SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
    1715         SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_NONE),
     1956        SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB),
     1957        SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB),
     1958        SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
    17161959        {0}
    17171960};
     
    17722015{
    17732016        struct azx *chip;
    1774         int err;
     2017        int i, err;
    17752018        unsigned short gcap;
    17762019        static struct snd_device_ops ops = {
     
    17982041        chip->driver_type = driver_type;
    17992042        chip->msi = enable_msi;
     2043        chip->dev_index = dev;
     2044        INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work);
    18002045
    18012046        chip->position_fix = check_position_fix(chip, position_fix[dev]);
     
    18032048
    18042049        chip->single_cmd = single_cmd;
     2050
     2051        if (bdl_pos_adj[dev] < 0) {
     2052                switch (chip->driver_type) {
     2053                case AZX_DRIVER_ICH:
     2054                        bdl_pos_adj[dev] = 1;
     2055                        break;
     2056                default:
     2057                        bdl_pos_adj[dev] = 32;
     2058                        break;
     2059                }
     2060        }
    18052061
    18062062#if BITS_PER_LONG != 64
     
    18442100        snd_printdd("chipset global capabilities = 0x%x\n", gcap);
    18452101
    1846         if (gcap) {
    1847                 /* read number of streams from GCAP register instead of using
    1848                  * hardcoded value
    1849                  */
    1850                 chip->playback_streams = (gcap & (0xF << 12)) >> 12;
    1851                 chip->capture_streams = (gcap & (0xF << 8)) >> 8;
    1852                 chip->playback_index_offset = (gcap & (0xF << 12)) >> 12;
    1853                 chip->capture_index_offset = 0;
    1854         } else {
     2102        /* allow 64bit DMA address if supported by H/W */
     2103        if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_64BIT_MASK))
     2104                pci_set_consistent_dma_mask(pci, DMA_64BIT_MASK);
     2105
     2106        /* read number of streams from GCAP register instead of using
     2107         * hardcoded value
     2108         */
     2109        chip->capture_streams = (gcap >> 8) & 0x0f;
     2110        chip->playback_streams = (gcap >> 12) & 0x0f;
     2111        if (!chip->playback_streams && !chip->capture_streams) {
    18552112                /* gcap didn't give any info, switching to old method */
    18562113
     
    18592116                        chip->playback_streams = ULI_NUM_PLAYBACK;
    18602117                        chip->capture_streams = ULI_NUM_CAPTURE;
    1861                         chip->playback_index_offset = ULI_PLAYBACK_INDEX;
    1862                         chip->capture_index_offset = ULI_CAPTURE_INDEX;
    18632118                        break;
    18642119                case AZX_DRIVER_ATIHDMI:
    18652120                        chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
    18662121                        chip->capture_streams = ATIHDMI_NUM_CAPTURE;
    1867                         chip->playback_index_offset = ATIHDMI_PLAYBACK_INDEX;
    1868                         chip->capture_index_offset = ATIHDMI_CAPTURE_INDEX;
    18692122                        break;
    18702123                default:
    18712124                        chip->playback_streams = ICH6_NUM_PLAYBACK;
    18722125                        chip->capture_streams = ICH6_NUM_CAPTURE;
    1873                         chip->playback_index_offset = ICH6_PLAYBACK_INDEX;
    1874                         chip->capture_index_offset = ICH6_CAPTURE_INDEX;
    18752126                        break;
    18762127                }
    18772128        }
     2129        chip->capture_index_offset = 0;
     2130        chip->playback_index_offset = chip->capture_streams;
    18782131        chip->num_streams = chip->playback_streams + chip->capture_streams;
    18792132        chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
     
    18842137        }
    18852138
    1886         /* allocate memory for the BDL for each stream */
    1887         err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
    1888                                   snd_dma_pci_data(chip->pci),
    1889                                   BDL_SIZE, &chip->bdl);
    1890         if (err < 0) {
    1891                 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
    1892                 goto errout;
     2139        for (i = 0; i < chip->num_streams; i++) {
     2140                /* allocate memory for the BDL for each stream */
     2141                err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
     2142                                          snd_dma_pci_data(chip->pci),
     2143                                          BDL_SIZE, &chip->azx_dev[i].bdl);
     2144                if (err < 0) {
     2145                        snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
     2146                        goto errout;
     2147                }
    18932148        }
    18942149        /* allocate memory for the position buffer */
     
    20262281/* PCI IDs */
    20272282static struct pci_device_id azx_ids[] = {
    2028         { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */
    2029         { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */
    2030         { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */
    2031         { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */
    2032         { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */
    2033         { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */
    2034         { 0x8086, 0x3a3e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */
    2035         { 0x8086, 0x3a6e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */
    2036         { 0x8086, 0x811b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SCH }, /* SCH*/
    2037         { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
    2038         { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
    2039         { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
    2040         { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
    2041         { 0x1002, 0x960f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */
    2042         { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */
    2043         { 0x1002, 0xaa08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV630 HDMI */
    2044         { 0x1002, 0xaa10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV610 HDMI */
    2045         { 0x1002, 0xaa18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV670 HDMI */
    2046         { 0x1002, 0xaa20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV635 HDMI */
    2047         { 0x1002, 0xaa28, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV620 HDMI */
    2048         { 0x1002, 0xaa30, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV770 HDMI */
    2049         { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
    2050         { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
    2051         { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
    2052         { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP51 */
    2053         { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP55 */
    2054         { 0x10de, 0x03e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */
    2055         { 0x10de, 0x03f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */
    2056         { 0x10de, 0x044a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */
    2057         { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */
    2058         { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
    2059         { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
    2060         { 0x10de, 0x07fc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */
    2061         { 0x10de, 0x07fd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */
    2062         { 0x10de, 0x0774, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
    2063         { 0x10de, 0x0775, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
    2064         { 0x10de, 0x0776, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
    2065         { 0x10de, 0x0777, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
    2066         { 0x10de, 0x0ac0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */
    2067         { 0x10de, 0x0ac1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */
    2068         { 0x10de, 0x0ac2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */
    2069         { 0x10de, 0x0ac3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */
     2283        /* ICH 6..10 */
     2284        { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH },
     2285        { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH },
     2286        { PCI_DEVICE(0x8086, 0x269a), .driver_data = AZX_DRIVER_ICH },
     2287        { PCI_DEVICE(0x8086, 0x284b), .driver_data = AZX_DRIVER_ICH },
     2288        { PCI_DEVICE(0x8086, 0x2911), .driver_data = AZX_DRIVER_ICH },
     2289        { PCI_DEVICE(0x8086, 0x293e), .driver_data = AZX_DRIVER_ICH },
     2290        { PCI_DEVICE(0x8086, 0x293f), .driver_data = AZX_DRIVER_ICH },
     2291        { PCI_DEVICE(0x8086, 0x3a3e), .driver_data = AZX_DRIVER_ICH },
     2292        { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH },
     2293        /* SCH */
     2294        { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH },
     2295        /* ATI SB 450/600 */
     2296        { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI },
     2297        { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI },
     2298        /* ATI HDMI */
     2299        { PCI_DEVICE(0x1002, 0x793b), .driver_data = AZX_DRIVER_ATIHDMI },
     2300        { PCI_DEVICE(0x1002, 0x7919), .driver_data = AZX_DRIVER_ATIHDMI },
     2301        { PCI_DEVICE(0x1002, 0x960f), .driver_data = AZX_DRIVER_ATIHDMI },
     2302        { PCI_DEVICE(0x1002, 0xaa00), .driver_data = AZX_DRIVER_ATIHDMI },
     2303        { PCI_DEVICE(0x1002, 0xaa08), .driver_data = AZX_DRIVER_ATIHDMI },
     2304        { PCI_DEVICE(0x1002, 0xaa10), .driver_data = AZX_DRIVER_ATIHDMI },
     2305        { PCI_DEVICE(0x1002, 0xaa18), .driver_data = AZX_DRIVER_ATIHDMI },
     2306        { PCI_DEVICE(0x1002, 0xaa20), .driver_data = AZX_DRIVER_ATIHDMI },
     2307        { PCI_DEVICE(0x1002, 0xaa28), .driver_data = AZX_DRIVER_ATIHDMI },
     2308        { PCI_DEVICE(0x1002, 0xaa30), .driver_data = AZX_DRIVER_ATIHDMI },
     2309        { PCI_DEVICE(0x1002, 0xaa38), .driver_data = AZX_DRIVER_ATIHDMI },
     2310        { PCI_DEVICE(0x1002, 0xaa40), .driver_data = AZX_DRIVER_ATIHDMI },
     2311        { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI },
     2312        /* VIA VT8251/VT8237A */
     2313        { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
     2314        /* SIS966 */
     2315        { PCI_DEVICE(0x1039, 0x7502), .driver_data = AZX_DRIVER_SIS },
     2316        /* ULI M5461 */
     2317        { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI },
     2318        /* NVIDIA MCP */
     2319        { PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA },
     2320        { PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA },
     2321        { PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA },
     2322        { PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA },
     2323        { PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA },
     2324        { PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA },
     2325        { PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA },
     2326        { PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA },
     2327        { PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA },
     2328        { PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA },
     2329        { PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA },
     2330        { PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA },
     2331        { PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA },
     2332        { PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA },
     2333        { PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA },
     2334        { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
     2335        { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
     2336        { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
     2337        { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA },
     2338        { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA },
     2339        { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA },
     2340        { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA },
     2341        /* Teradici */
     2342        { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
    20702343        { 0, }
    20712344};
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_local.h

    r315 r358  
    233233        int dig_out_used;       /* current usage of digital out (HDA_DIG_XXX) */
    234234        int no_share_stream;    /* don't share a stream with multiple pins */
    235 };
    236 
     235        int share_spdif;        /* share SPDIF pin */
     236        /* PCM information for both analog and SPDIF DACs */
     237        unsigned int analog_rates;
     238        unsigned int analog_maxbps;
     239        u64 analog_formats;
     240        unsigned int spdif_rates;
     241        unsigned int spdif_maxbps;
     242        u64 spdif_formats;
     243};
     244
     245int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
     246                                  struct hda_multi_out *mout);
    237247int snd_hda_multi_out_dig_open(struct hda_codec *codec,
    238248                               struct hda_multi_out *mout);
     
    246256int snd_hda_multi_out_analog_open(struct hda_codec *codec,
    247257                                  struct hda_multi_out *mout,
    248                                   struct snd_pcm_substream *substream);
     258                                  struct snd_pcm_substream *substream,
     259                                  struct hda_pcm_stream *hinfo);
    249260int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
    250261                                     struct hda_multi_out *mout,
     
    412423#endif /* CONFIG_SND_HDA_POWER_SAVE */
    413424
    414 /*
    415  * virtual master control
    416  */
    417 struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
    418                                                  const unsigned int *tlv);
    419 int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
    420                      
    421425#endif /* __SOUND_HDA_LOCAL_H */
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_patch.h

    r305 r358  
    1919/* VIA codecs */
    2020extern struct hda_codec_preset snd_hda_preset_via[];
    21 
    22 static const struct hda_codec_preset *hda_preset_tables[] = {
    23 #ifdef CONFIG_SND_HDA_CODEC_REALTEK
    24         snd_hda_preset_realtek,
    25 #endif
    26 #ifdef CONFIG_SND_HDA_CODEC_CMEDIA
    27         snd_hda_preset_cmedia,
    28 #endif
    29 #ifdef CONFIG_SND_HDA_CODEC_ANALOG
    30         snd_hda_preset_analog,
    31 #endif
    32 #ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
    33         snd_hda_preset_sigmatel,
    34 #endif
    35 #ifdef CONFIG_SND_HDA_CODEC_SI3054
    36         snd_hda_preset_si3054,
    37 #endif
    38 #ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
    39         snd_hda_preset_atihdmi,
    40 #endif
    41 #ifdef CONFIG_SND_HDA_CODEC_CONEXANT
    42         snd_hda_preset_conexant,
    43 #endif
    44 #ifdef CONFIG_SND_HDA_CODEC_VIA
    45         snd_hda_preset_via,
    46 #endif
    47         NULL
    48 };
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/hda_proc.c

    r305 r358  
    367367        unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
    368368                                                AC_VERB_GET_DIGI_CONVERT_1, 0);
    369         unsigned int digi2 = snd_hda_codec_read(codec, nid, 0,
    370                                                 AC_VERB_GET_DIGI_CONVERT_2, 0);
    371369        snd_iprintf(buffer, "  Digital:");
    372370        if (digi1 & AC_DIG1_ENABLE)
     
    387385                snd_iprintf(buffer, " GenLevel");
    388386        snd_iprintf(buffer, "\n");
    389         snd_iprintf(buffer, "  Digital category: 0x%x\n", digi2 & AC_DIG2_CC);
     387        snd_iprintf(buffer, "  Digital category: 0x%x\n",
     388                    (digi1 >> 8) & AC_DIG2_CC);
    390389}
    391390
     
    585584                        snd_iprintf(buffer, "  Amp-In vals: ");
    586585                        print_amp_vals(buffer, codec, nid, HDA_INPUT,
    587                                        wid_caps & AC_WCAP_STEREO, conn_len);
     586                                       wid_caps & AC_WCAP_STEREO,
     587                                       wid_type == AC_WID_PIN ? 1 : conn_len);
    588588                }
    589589                if (wid_caps & AC_WCAP_OUT_AMP) {
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/makefile.os2

    r313 r358  
    22AINCLUDES = $(DDK_BASE)\H
    33
    4 CDEFINES = -D__KERNEL__ -DMODULE -dTARGET_OS2 -dALSA_BUILD -D__ISAPNP__ -DCONFIG_ISAPNP -D__i386_ 
     4CDEFINES = -D__KERNEL__ -DMODULE -dTARGET_OS2 -dALSA_BUILD -D__ISAPNP__ -DCONFIG_ISAPNP -D__i386_
    55
    6632BIT=1
     
    1313#
    1414#===================================================================
    15 FILE1    = hda_intel.obj hda_codec.obj vmaster.obj hda_proc.obj hda_hwdep.obj hda_generic.obj patch_realtek.obj
    16 FILE2    = patch_cmedia.obj patch_analog.obj patch_sigmatel.obj
    17 FILE3    = patch_si3054.obj patch_atihdmi.obj patch_conexant.obj
    18 FILE4    = patch_via.obj
    19 FILE5    = 
    20 FILE6    = 
    21 FILE7    = 
    22 FILE8    = 
     15FILE1    = hda_intel.obj hda_codec.obj hda_proc.obj hda_hwdep.obj hda_generic.obj
     16FILE2    = patch_realtek.obj patch_cmedia.obj patch_analog.obj patch_sigmatel.obj
     17FILE3    = patch_si3054.obj patch_atihdmi.obj patch_conexant.obj patch_via.obj
     18FILE4    =
     19FILE5    =
     20FILE6    =
     21FILE7    =
     22FILE8    =
    2323FILELAST =
    2424FILES    = $(FILE0) $(FILE1) $(FILE2) $(FILE3) $(FILE4) $(FILE5) $(FILE6) $(FILE7) $(FILE8) $(FILE9) $(FILE10) $(FILE11) $(FILE12)
     
    3434#
    3535#===================================================================
    36 all: $(OBJDIR)\$(TARGET).lib 
     36all: $(OBJDIR)\$(TARGET).lib
    3737
    3838
     
    4343$(OBJDIR)\$(TARGET).lib: $(LNKFILE) $(FILES)
    4444    $(LIB) $(OBJDIR)\$(TARGET).lib @$(LNKFILE)
    45     copy $(OBJDIR)\$(TARGET).lib $(ALSA_LIB) 
     45    copy $(OBJDIR)\$(TARGET).lib $(ALSA_LIB)
    4646
    4747clean: .SYMBOLIC
     
    4949    @cd $(OBJDIR)
    5050    -rm *.obj *.lnk *.sys *.sym *.lst *.map *.wmap *.lib 2>nul
    51     @cd ..\..
     51    @cd ../..
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_analog.c

    r305 r358  
    2424#include <linux/slab.h>
    2525#include <linux/pci.h>
    26 #include <linux/mutex.h>
    2726
    2827#include <sound/core.h>
    2928#include "hda_codec.h"
    3029#include "hda_local.h"
     30#include "hda_patch.h"
    3131
    3232struct ad198x_spec {
     
    6464        struct hda_pcm pcm_rec[3];      /* used in alc_build_pcms() */
    6565
    66         struct mutex amp_mutex; /* PCM volume/mute control mutex */
    6766        unsigned int spdif_route;
    6867
     
    8180        /* for virtual master */
    8281        hda_nid_t vmaster_nid;
    83         u32 vmaster_tlv[4];
    8482        const char **slave_vols;
    8583        const char **slave_sws;
     
    172170                if (err < 0)
    173171                        return err;
     172                err = snd_hda_create_spdif_share_sw(codec,
     173                                                    &spec->multiout);
     174                if (err < 0)
     175                        return err;
     176                spec->multiout.share_spdif = 1;
    174177        }
    175178        if (spec->dig_in_nid) {
     
    181184        /* if we have no master control, let's create it */
    182185        if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
     186                unsigned int vmaster_tlv[4];
    183187                snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
    184                                         HDA_OUTPUT, spec->vmaster_tlv);
     188                                        HDA_OUTPUT, vmaster_tlv);
    185189                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
    186                                           spec->vmaster_tlv,
     190                                          vmaster_tlv,
    187191                                          (spec->slave_vols ?
    188192                                           spec->slave_vols : ad_slave_vols));
     
    218222{
    219223        struct ad198x_spec *spec = codec->spec;
    220         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     224        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
     225                                             hinfo);
    221226}
    222227
     
    290295{
    291296        struct ad198x_spec *spec = codec->spec;
    292         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
    293                                    0, 0, 0);
     297        snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
    294298        return 0;
    295299}
     
    360364                codec->num_pcms++;
    361365                info->name = "AD198x Digital";
     366                info->pcm_type = HDA_PCM_TYPE_SPDIF;
    362367                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
    363368                info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
     
    612617};
    613618
     619static struct hda_input_mux ad1986a_automic_capture_source = {
     620        .num_items = 2,
     621        .items = {
     622                { "Mic", 0x0 },
     623                { "Mix", 0x5 },
     624        },
     625};
     626
    614627static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
    615628        HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
     
    617630        HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    618631        HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
    619         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
    620         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
    621632        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
    622633        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
     
    641652        {0} /* end */
    642653};
     654
     655/* re-connect the mic boost input according to the jack sensing */
     656static void ad1986a_automic(struct hda_codec *codec)
     657{
     658        unsigned int present;
     659        present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0);
     660        /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
     661        snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
     662                            (present & AC_PINSENSE_PRESENCE) ? 0 : 2);
     663}
     664
     665#define AD1986A_MIC_EVENT               0x36
     666
     667static void ad1986a_automic_unsol_event(struct hda_codec *codec,
     668                                            unsigned int res)
     669{
     670        if ((res >> 26) != AD1986A_MIC_EVENT)
     671                return;
     672        ad1986a_automic(codec);
     673}
     674
     675static int ad1986a_automic_init(struct hda_codec *codec)
     676{
     677        ad198x_init(codec);
     678        ad1986a_automic(codec);
     679        return 0;
     680}
    643681
    644682/* laptop-automute - 2ch only */
     
    810848        /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
    811849        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
    812         { 0 } /* end */
     850        {0} /* end */
    813851};
    814852
     
    820858        { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
    821859        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
    822         { 0 } /* end */
     860        {0} /* end */
    823861};
    824862
     
    830868        { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    831869        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
    832         { 0 } /* end */
    833 };
    834 
     870        {0} /* end */
     871};
    835872
    836873static struct hda_channel_mode ad1986a_modes[3] = {
     
    843880static struct hda_verb ad1986a_eapd_init_verbs[] = {
    844881        {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
     882        {0}
     883};
     884
     885static struct hda_verb ad1986a_automic_verbs[] = {
     886        {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     887        {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     888        /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
     889        {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
     890        {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
    845891        {0}
    846892};
     
    869915        AD1986A_3STACK,
    870916        AD1986A_LAPTOP,
    871         AD1986A_LAPTOP_EAPD,
     917        AD1986A_LAPTOP_EAPD,
    872918        AD1986A_LAPTOP_AUTOMUTE,
    873         AD1986A_ULTRA,
     919        AD1986A_ULTRA,
    874920        AD1986A_MODELS
    875921};
     
    879925        [AD1986A_3STACK]        = "3stack",
    880926        [AD1986A_LAPTOP]        = "laptop",
    881         [AD1986A_LAPTOP_EAPD]   = "laptop-eapd",
     927        [AD1986A_LAPTOP_EAPD]   = "laptop-eapd",
    882928        [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
    883         [AD1986A_ULTRA]         = "ultra",
     929        [AD1986A_ULTRA]         = "ultra",
    884930};
    885931
     
    9881034        case AD1986A_LAPTOP_EAPD:
    9891035                spec->mixers[0] = ad1986a_laptop_eapd_mixers;
    990                 spec->num_init_verbs = 2;
     1036                spec->num_init_verbs = 3;
    9911037                spec->init_verbs[1] = ad1986a_eapd_init_verbs;
     1038                spec->init_verbs[2] = ad1986a_automic_verbs;
    9921039                spec->multiout.max_channels = 2;
    9931040                spec->multiout.num_dacs = 1;
     
    9951042                if (!is_jack_available(codec, 0x25))
    9961043                        spec->multiout.dig_out_nid = 0;
    997                 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
     1044                spec->input_mux = &ad1986a_automic_capture_source;
     1045                codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
     1046                codec->patch_ops.init = ad1986a_automic_init;
    9981047                break;
    9991048        case AD1986A_LAPTOP_AUTOMUTE:
     
    10221071        }
    10231072
    1024         return 0;
     1073        /* AD1986A has a hardware problem that it can't share a stream
     1074         * with multiple output pins.  The copy of front to surrounds
     1075         * causes noisy or silent outputs at a certain timing, e.g.
     1076         * changing the volume.
     1077         * So, let's disable the shared stream.
     1078         */
     1079        spec->multiout.no_share_stream = 1;
     1080
     1081        return 0;
    10251082}
    10261083
     
    11971254        spec->loopback.amplist = ad1983_loopbacks;
    11981255#endif
     1256        spec->vmaster_nid = 0x05;
    11991257
    12001258        codec->patch_ops = ad198x_patch_ops;
    1201 
    1202         /* AD1986A has a hardware problem that it can't share a stream
    1203          * with multiple output pins.  The copy of front to surrounds
    1204          * causes noisy or silent outputs at a certain timing, e.g.
    1205          * changing the volume.
    1206          * So, let's disable the shared stream.
    1207          */
    1208         spec->multiout.no_share_stream = 1;
    12091259
    12101260        return 0;
     
    13661416        if (! ad198x_eapd_put(kcontrol, ucontrol))
    13671417                return 0;
    1368 
     1418        /* change speaker pin appropriately */
     1419        snd_hda_codec_write(codec, 0x05, 0,
     1420                            AC_VERB_SET_PIN_WIDGET_CONTROL,
     1421                            spec->cur_eapd ? PIN_OUT : 0);
    13691422        /* toggle HP mute appropriately */
    13701423        snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
     
    14971550        {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
    14981551        {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
    1499         { 0 }
     1552        {0}
    15001553};
    15011554
     
    15031556        HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
    15041557        HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
    1505         { 0 }
     1558        {0}
    15061559};
    15071560
     
    15641617static struct snd_pci_quirk ad1981_cfg_tbl[] = {
    15651618        SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
    1566         /* All HP models */
    1567         SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
     1619        SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
     1620        /* All HP models */
     1621        SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
    15681622        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
    1569         /* Lenovo Thinkpad T60/X60/Z6xx */
    1570         SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
     1623        /* Lenovo Thinkpad T60/X60/Z6xx */
     1624        SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
    15711625        /* HP nx6320 (reversed SSID, H/W bug) */
    15721626        SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
     
    17791833        .num_items = 5,
    17801834        .items = {
    1781                 { "Front Mic", 0x0 },
    1782                 { "Line", 0x1 },
    1783                 { "Mic", 0x4 },
     1835                { "Front Mic", 0x1 },   /* port-B */
     1836                { "Line", 0x2 },        /* port-C */
     1837                { "Mic", 0x4 },         /* port-E */
    17841838                { "CD", 0x5 },
    17851839                { "Mix", 0x9 },
     
    17901844        .num_items = 3,
    17911845        .items = {
    1792                 { "Mic/Line", 0x0 },
     1846                { "Mic/Line", 0x1 },    /* port-B */
    17931847                { "CD", 0x5 },
    17941848                { "Mix", 0x9 },
     
    20882142};
    20892143
     2144static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = {
     2145        HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
     2146        {0} /* end */
     2147};
    20902148
    20912149/*
     
    21882246};
    21892247
     2248/* AD1989 has no ADC -> SPDIF route */
     2249static struct hda_verb ad1989_spdif_init_verbs[] = {
     2250        /* SPDIF out pin */
     2251        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
     2252        {0}
     2253};
     2254
    21902255/*
    21912256 * verbs for 3stack (+dig)
     
    25582623        struct ad198x_spec *spec = codec->spec;
    25592624        hda_nid_t nid;
    2560         int idx, err;
     2625        int i, idx, err;
    25612626        char name[32];
    25622627
     
    25662631        idx = ad1988_pin_idx(pin);
    25672632        nid = ad1988_idx_to_dac(codec, idx);
    2568         /* specify the DAC as the extra output */
    2569         if (! spec->multiout.hp_nid)
    2570                 spec->multiout.hp_nid = nid;
    2571         else
    2572                 spec->multiout.extra_out_nid[0] = nid;
    2573         /* control HP volume/switch on the output mixer amp */
    2574         sprintf(name, "%s Playback Volume", pfx);
    2575         if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
    2576                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
    2577                 return err;
     2633        /* check whether the corresponding DAC was already taken */
     2634        for (i = 0; i < spec->autocfg.line_outs; i++) {
     2635                hda_nid_t pin = spec->autocfg.line_out_pins[i];
     2636                hda_nid_t dac = ad1988_idx_to_dac(codec, ad1988_pin_idx(pin));
     2637                if (dac == nid)
     2638                        break;
     2639        }
     2640        if (i >= spec->autocfg.line_outs) {
     2641                /* specify the DAC as the extra output */
     2642                if (!spec->multiout.hp_nid)
     2643                        spec->multiout.hp_nid = nid;
     2644                else
     2645                        spec->multiout.extra_out_nid[0] = nid;
     2646                /* control HP volume/switch on the output mixer amp */
     2647                sprintf(name, "%s Playback Volume", pfx);
     2648                err = add_control(spec, AD_CTL_WIDGET_VOL, name,
     2649                                  HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
     2650                if (err < 0)
     2651                        return err;
     2652        }
    25782653        nid = ad1988_mixer_nids[idx];
    25792654        sprintf(name, "%s Playback Switch", pfx);
     
    27922867static struct snd_pci_quirk ad1988_cfg_tbl[] = {
    27932868        SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
    2794         SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
     2869        SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
     2870        SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG),
    27952871        {0}
    27962872};
     
    28952971        spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
    28962972        if (spec->multiout.dig_out_nid) {
    2897                 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
    2898                 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
     2973                if (codec->vendor_id >= 0x11d4989a) {
     2974                        spec->mixers[spec->num_mixers++] =
     2975                                ad1989_spdif_out_mixers;
     2976                        spec->init_verbs[spec->num_init_verbs++] =
     2977                                ad1989_spdif_init_verbs;
     2978                } else {
     2979                        spec->mixers[spec->num_mixers++] =
     2980                                ad1988_spdif_out_mixers;
     2981                        spec->init_verbs[spec->num_init_verbs++] =
     2982                                ad1988_spdif_init_verbs;
     2983                }
    28992984        }
    2900         if (spec->dig_in_nid)
     2985        if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a)
    29012986                spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
    29022987
     
    30093094                .put = ad1983_spdif_route_put,
    30103095        },
    3011         { 0 } /* end */
     3096        {0} /* end */
    30123097};
    30133098
     
    30193104        HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
    30203105                           HDA_INPUT),
    3021         { 0 } /* end */
     3106        {0} /* end */
    30223107};
    30233108
     
    30673152        {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
    30683153        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
    3069         { 0 } /* end */
     3154        {0} /* end */
    30703155};
    30713156
     
    31023187                return -ENOMEM;
    31033188
    3104         mutex_init(&spec->amp_mutex);
    31053189        codec->spec = spec;
    31063190
     
    31343218 */
    31353219static struct hda_input_mux ad1984_thinkpad_capture_source = {
    3136         .num_items = 3,
     3220        .num_items = 4,
    31373221        .items = {
    31383222                { "Mic", 0x0 },
    31393223                { "Internal Mic", 0x1 },
    31403224                { "Mix", 0x3 },
     3225                { "Docking-Station", 0x4 },
    31413226        },
    31423227};
     
    31983283                .put = ad1983_spdif_route_put,
    31993284        },
    3200         { 0 } /* end */
     3285        {0} /* end */
    32013286};
    32023287
     
    32123297        /* enable EAPD bit */
    32133298        {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
    3214         { 0 } /* end */
     3299        {0} /* end */
    32153300};
    32163301
     
    32693354                                   struct snd_pcm_substream *substream)
    32703355{
    3271         snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
    3272                                    0, 0, 0);
     3356        snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number);
    32733357        return 0;
    32743358}
     
    33063390        AD1984_BASIC,
    33073391        AD1984_THINKPAD,
    3308         AD1984_DELL_DESKTOP,
     3392        AD1984_DELL_DESKTOP,
    33093393        AD1984_MODELS
    33103394};
     
    33133397        [AD1984_BASIC]          = "basic",
    33143398        [AD1984_THINKPAD]       = "thinkpad",
    3315         [AD1984_DELL_DESKTOP]   = "dell_desktop",
     3399        [AD1984_DELL_DESKTOP]   = "dell_desktop",
    33163400};
    33173401
     
    33193403        /* Lenovo Thinkpad T61/X61 */
    33203404        SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
    3321         SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
    3322         { 0 }
     3405        SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
     3406        {0}
    33233407};
    33243408
     
    33523436                break;
    33533437        }
     3438        return 0;
     3439}
     3440
     3441
     3442/*
     3443 * AD1883 / AD1884A / AD1984A / AD1984B
     3444 *
     3445 * port-B (0x14) - front mic-in
     3446 * port-E (0x1c) - rear mic-in
     3447 * port-F (0x16) - CD / ext out
     3448 * port-C (0x15) - rear line-in
     3449 * port-D (0x12) - rear line-out
     3450 * port-A (0x11) - front hp-out
     3451 *
     3452 * AD1984A = AD1884A + digital-mic
     3453 * AD1883 = equivalent with AD1984A
     3454 * AD1984B = AD1984A + extra SPDIF-out
     3455 *
     3456 * FIXME:
     3457 * We share the single DAC for both HP and line-outs (see AD1884/1984).
     3458 */
     3459
     3460static hda_nid_t ad1884a_dac_nids[1] = {
     3461        0x03,
     3462};
     3463
     3464#define ad1884a_adc_nids        ad1884_adc_nids
     3465#define ad1884a_capsrc_nids     ad1884_capsrc_nids
     3466
     3467#define AD1884A_SPDIF_OUT       0x02
     3468
     3469static struct hda_input_mux ad1884a_capture_source = {
     3470        .num_items = 5,
     3471        .items = {
     3472                { "Front Mic", 0x0 },
     3473                { "Mic", 0x4 },
     3474                { "Line", 0x1 },
     3475                { "CD", 0x2 },
     3476                { "Mix", 0x3 },
     3477        },
     3478};
     3479
     3480static struct snd_kcontrol_new ad1884a_base_mixers[] = {
     3481        HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
     3482        HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     3483        HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
     3484        HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
     3485        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
     3486        HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
     3487        HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
     3488        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
     3489        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
     3490        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
     3491        HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
     3492        HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
     3493        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
     3494        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
     3495        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
     3496        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
     3497        HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
     3498        HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
     3499        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
     3500        HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
     3501        HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
     3502        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
     3503        HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
     3504        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
     3505        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
     3506        {
     3507                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3508                /* The multiple "Capture Source" controls confuse alsamixer
     3509                 * So call somewhat different..
     3510                 */
     3511                /* .name = "Capture Source", */
     3512                .name = "Input Source",
     3513                .count = 2,
     3514                .info = ad198x_mux_enum_info,
     3515                .get = ad198x_mux_enum_get,
     3516                .put = ad198x_mux_enum_put,
     3517        },
     3518        /* SPDIF controls */
     3519        HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
     3520        {
     3521                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3522                .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
     3523                /* identical with ad1983 */
     3524                .info = ad1983_spdif_route_info,
     3525                .get = ad1983_spdif_route_get,
     3526                .put = ad1983_spdif_route_put,
     3527        },
     3528        {0} /* end */
     3529};
     3530
     3531/*
     3532 * initialization verbs
     3533 */
     3534static struct hda_verb ad1884a_init_verbs[] = {
     3535        /* DACs; unmute as default */
     3536        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
     3537        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
     3538        /* Port-A (HP) mixer - route only from analog mixer */
     3539        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3540        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     3541        /* Port-A pin */
     3542        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3543        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3544        /* Port-D (Line-out) mixer - route only from analog mixer */
     3545        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3546        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     3547        /* Port-D pin */
     3548        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3549        {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3550        /* Mono-out mixer - route only from analog mixer */
     3551        {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3552        {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     3553        /* Mono-out pin */
     3554        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3555        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3556        /* Port-B (front mic) pin */
     3557        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3558        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3559        /* Port-C (rear line-in) pin */
     3560        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3561        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3562        /* Port-E (rear mic) pin */
     3563        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3564        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3565        {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
     3566        /* Port-F (CD) pin */
     3567        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3568        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3569        /* Analog mixer; mute as default */
     3570        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3571        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3572        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     3573        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     3574        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
     3575        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
     3576        /* Analog Mix output amp */
     3577        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3578        /* capture sources */
     3579        {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
     3580        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3581        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
     3582        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3583        /* SPDIF output amp */
     3584        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
     3585        {0} /* end */
     3586};
     3587
     3588#ifdef CONFIG_SND_HDA_POWER_SAVE
     3589static struct hda_amp_list ad1884a_loopbacks[] = {
     3590        { 0x20, HDA_INPUT, 0 }, /* Front Mic */
     3591        { 0x20, HDA_INPUT, 1 }, /* Mic */
     3592        { 0x20, HDA_INPUT, 2 }, /* CD */
     3593        { 0x20, HDA_INPUT, 4 }, /* Docking */
     3594        {0} /* end */
     3595};
     3596#endif
     3597
     3598/*
     3599 * Laptop model
     3600 *
     3601 * Port A: Headphone jack
     3602 * Port B: MIC jack
     3603 * Port C: Internal MIC
     3604 * Port D: Dock Line Out (if enabled)
     3605 * Port E: Dock Line In (if enabled)
     3606 * Port F: Internal speakers
     3607 */
     3608
     3609static struct hda_input_mux ad1884a_laptop_capture_source = {
     3610        .num_items = 4,
     3611        .items = {
     3612                { "Mic", 0x0 },         /* port-B */
     3613                { "Internal Mic", 0x1 }, /* port-C */
     3614                { "Dock Mic", 0x4 },    /* port-E */
     3615                { "Mix", 0x3 },
     3616        },
     3617};
     3618
     3619static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
     3620        HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
     3621        HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     3622        HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
     3623        HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
     3624        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
     3625        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
     3626        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
     3627        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
     3628        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
     3629        HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
     3630        HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
     3631        HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
     3632        HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
     3633        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
     3634        HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
     3635        HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
     3636        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
     3637        HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
     3638        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
     3639        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
     3640        {
     3641                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3642                /* The multiple "Capture Source" controls confuse alsamixer
     3643                 * So call somewhat different..
     3644                 */
     3645                /* .name = "Capture Source", */
     3646                .name = "Input Source",
     3647                .count = 2,
     3648                .info = ad198x_mux_enum_info,
     3649                .get = ad198x_mux_enum_get,
     3650                .put = ad198x_mux_enum_put,
     3651        },
     3652        {0} /* end */
     3653};
     3654
     3655static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
     3656        HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
     3657        HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     3658        HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
     3659        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
     3660        HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
     3661        HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
     3662        HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
     3663        HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
     3664        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
     3665        HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
     3666        {0} /* end */
     3667};
     3668
     3669/* mute internal speaker if HP is plugged */
     3670static void ad1884a_hp_automute(struct hda_codec *codec)
     3671{
     3672        unsigned int present;
     3673
     3674        present = snd_hda_codec_read(codec, 0x11, 0,
     3675                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     3676        snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
     3677                                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
     3678        snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
     3679                            present ? 0x00 : 0x02);
     3680}
     3681
     3682/* switch to external mic if plugged */
     3683static void ad1884a_hp_automic(struct hda_codec *codec)
     3684{
     3685        unsigned int present;
     3686
     3687        present = snd_hda_codec_read(codec, 0x14, 0,
     3688                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     3689        snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL,
     3690                            present ? 0 : 1);
     3691}
     3692
     3693#define AD1884A_HP_EVENT                0x37
     3694#define AD1884A_MIC_EVENT               0x36
     3695
     3696/* unsolicited event for HP jack sensing */
     3697static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
     3698{
     3699        switch (res >> 26) {
     3700        case AD1884A_HP_EVENT:
     3701                ad1884a_hp_automute(codec);
     3702                break;
     3703        case AD1884A_MIC_EVENT:
     3704                ad1884a_hp_automic(codec);
     3705                break;
     3706        }
     3707}
     3708
     3709/* initialize jack-sensing, too */
     3710static int ad1884a_hp_init(struct hda_codec *codec)
     3711{
     3712        ad198x_init(codec);
     3713        ad1884a_hp_automute(codec);
     3714        ad1884a_hp_automic(codec);
     3715        return 0;
     3716}
     3717
     3718/* additional verbs for laptop model */
     3719static struct hda_verb ad1884a_laptop_verbs[] = {
     3720        /* Port-A (HP) pin - always unmuted */
     3721        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3722        /* Port-F (int speaker) mixer - route only from analog mixer */
     3723        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3724        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     3725        /* Port-F pin */
     3726        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3727        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3728        /* Port-C pin - internal mic-in */
     3729        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3730        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
     3731        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
     3732        /* analog mix */
     3733        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     3734        /* unsolicited event for pin-sense */
     3735        {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
     3736        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
     3737        {0} /* end */
     3738};
     3739
     3740/*
     3741 * Thinkpad X300
     3742 * 0x11 - HP
     3743 * 0x12 - speaker
     3744 * 0x14 - mic-in
     3745 * 0x17 - built-in mic
     3746 */
     3747
     3748static struct hda_verb ad1984a_thinkpad_verbs[] = {
     3749        /* HP unmute */
     3750        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3751        /* analog mix */
     3752        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     3753        /* turn on EAPD */
     3754        {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
     3755        /* unsolicited event for pin-sense */
     3756        {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
     3757        /* internal mic - dmic */
     3758        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     3759        /* set magic COEFs for dmic */
     3760        {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
     3761        {0x01, AC_VERB_SET_PROC_COEF, 0x08},
     3762        {0} /* end */
     3763};
     3764
     3765static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
     3766        HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
     3767        HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     3768        HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
     3769        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
     3770        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
     3771        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
     3772        HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
     3773        HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
     3774        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
     3775        HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
     3776        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
     3777        HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
     3778        {
     3779                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3780                .name = "Capture Source",
     3781                .info = ad198x_mux_enum_info,
     3782                .get = ad198x_mux_enum_get,
     3783                .put = ad198x_mux_enum_put,
     3784        },
     3785        {0} /* end */
     3786};
     3787
     3788static struct hda_input_mux ad1984a_thinkpad_capture_source = {
     3789        .num_items = 3,
     3790        .items = {
     3791                { "Mic", 0x0 },
     3792                { "Internal Mic", 0x5 },
     3793                { "Mix", 0x3 },
     3794        },
     3795};
     3796
     3797/* mute internal speaker if HP is plugged */
     3798static void ad1984a_thinkpad_automute(struct hda_codec *codec)
     3799{
     3800        unsigned int present;
     3801
     3802        present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0)
     3803                & AC_PINSENSE_PRESENCE;
     3804        snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
     3805                                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
     3806}
     3807
     3808/* unsolicited event for HP jack sensing */
     3809static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec,
     3810                                         unsigned int res)
     3811{
     3812        if ((res >> 26) != AD1884A_HP_EVENT)
     3813                return;
     3814        ad1984a_thinkpad_automute(codec);
     3815}
     3816
     3817/* initialize jack-sensing, too */
     3818static int ad1984a_thinkpad_init(struct hda_codec *codec)
     3819{
     3820        ad198x_init(codec);
     3821        ad1984a_thinkpad_automute(codec);
     3822        return 0;
     3823}
     3824
     3825/*
     3826 */
     3827
     3828enum {
     3829        AD1884A_DESKTOP,
     3830        AD1884A_LAPTOP,
     3831        AD1884A_MOBILE,
     3832        AD1884A_THINKPAD,
     3833        AD1884A_MODELS
     3834};
     3835
     3836static const char *ad1884a_models[AD1884A_MODELS] = {
     3837        [AD1884A_DESKTOP]       = "desktop",
     3838        [AD1884A_LAPTOP]        = "laptop",
     3839        [AD1884A_MOBILE]        = "mobile",
     3840        [AD1884A_THINKPAD]      = "thinkpad",
     3841};
     3842
     3843static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
     3844        SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
     3845        SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
     3846        {0}
     3847};
     3848
     3849static int patch_ad1884a(struct hda_codec *codec)
     3850{
     3851        struct ad198x_spec *spec;
     3852        int board_config;
     3853
     3854        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     3855        if (spec == NULL)
     3856                return -ENOMEM;
     3857
     3858        codec->spec = spec;
     3859
     3860        spec->multiout.max_channels = 2;
     3861        spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
     3862        spec->multiout.dac_nids = ad1884a_dac_nids;
     3863        spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
     3864        spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
     3865        spec->adc_nids = ad1884a_adc_nids;
     3866        spec->capsrc_nids = ad1884a_capsrc_nids;
     3867        spec->input_mux = &ad1884a_capture_source;
     3868        spec->num_mixers = 1;
     3869        spec->mixers[0] = ad1884a_base_mixers;
     3870        spec->num_init_verbs = 1;
     3871        spec->init_verbs[0] = ad1884a_init_verbs;
     3872        spec->spdif_route = 0;
     3873#ifdef CONFIG_SND_HDA_POWER_SAVE
     3874        spec->loopback.amplist = ad1884a_loopbacks;
     3875#endif
     3876        codec->patch_ops = ad198x_patch_ops;
     3877
     3878        /* override some parameters */
     3879        board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
     3880                                                  ad1884a_models,
     3881                                                  ad1884a_cfg_tbl);
     3882        switch (board_config) {
     3883        case AD1884A_LAPTOP:
     3884                spec->mixers[0] = ad1884a_laptop_mixers;
     3885                spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
     3886                spec->multiout.dig_out_nid = 0;
     3887                spec->input_mux = &ad1884a_laptop_capture_source;
     3888                codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
     3889                codec->patch_ops.init = ad1884a_hp_init;
     3890                break;
     3891        case AD1884A_MOBILE:
     3892                spec->mixers[0] = ad1884a_mobile_mixers;
     3893                spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
     3894                spec->multiout.dig_out_nid = 0;
     3895                codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
     3896                codec->patch_ops.init = ad1884a_hp_init;
     3897                break;
     3898        case AD1884A_THINKPAD:
     3899                spec->mixers[0] = ad1984a_thinkpad_mixers;
     3900                spec->init_verbs[spec->num_init_verbs++] =
     3901                        ad1984a_thinkpad_verbs;
     3902                spec->multiout.dig_out_nid = 0;
     3903                spec->input_mux = &ad1984a_thinkpad_capture_source;
     3904                codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
     3905                codec->patch_ops.init = ad1984a_thinkpad_init;
     3906                break;
     3907        }
     3908
    33543909        return 0;
    33553910}
     
    36054160                return -ENOMEM;
    36064161
    3607         mutex_init(&spec->amp_mutex);
    36084162        codec->spec = spec;
    36094163
     
    36554209 */
    36564210struct hda_codec_preset snd_hda_preset_analog[] = {
     4211        { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
    36574212        { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
     4213        { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
    36584214        { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
     4215        { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
     4216        { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
    36594217        { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
    36604218        { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
     
    36634221        { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
    36644222        { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
     4223        { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
     4224        { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
    36654225        {0} /* terminator */
    36664226};
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_atihdmi.c

    r305 r358  
    2828#include "hda_codec.h"
    2929#include "hda_local.h"
     30#include "hda_patch.h"
    3031
    3132struct atihdmi_spec {
     
    117118
    118119        info->name = "ATI HDMI";
     120        info->pcm_type = HDA_PCM_TYPE_HDMI;
    119121        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback;
    120122
     
    163165        { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
    164166        { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi },
    165         { .id = 0x10951392, .name = "SI HDMI", .patch = patch_atihdmi },
     167        { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_atihdmi },
     168        { .id = 0x17e80047, .name = "Chrontel HDMI",  .patch = patch_atihdmi },
    166169        {0} /* terminator */
    167170};
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_cmedia.c

    r305 r358  
    2929#include "hda_codec.h"
    3030#include "hda_local.h"
     31#include "hda_patch.h"
    3132#define NUM_PINS        11
    3233
     
    330331                if (err < 0)
    331332                        return err;
     333                err = snd_hda_create_spdif_share_sw(codec,
     334                                                    &spec->multiout);
     335                if (err < 0)
     336                        return err;
     337                spec->multiout.share_spdif = 1;
    332338        }
    333339        if (spec->dig_in_nid) {
     
    433439{
    434440        struct cmi_spec *spec = codec->spec;
    435         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     441        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
     442                                             hinfo);
    436443}
    437444
     
    507514        struct cmi_spec *spec = codec->spec;
    508515
    509         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
     516        snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
    510517        return 0;
    511518}
     
    572579                info++;
    573580                info->name = "CMI9880 Digital";
     581                info->pcm_type = HDA_PCM_TYPE_SPDIF;
    574582                if (spec->multiout.dig_out_nid) {
    575583                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback;
     
    604612static struct snd_pci_quirk cmi9880_cfg_tbl[] = {
    605613        SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG),
     614        SND_PCI_QUIRK(0x1854, 0x002b, "LG LS75", CMI_MINIMAL),
     615        SND_PCI_QUIRK(0x1854, 0x0032, "LG", CMI_FULL_DIG),
    606616        {0} /* terminator */
    607617};
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_conexant.c

    r305 r358  
    2525#include <linux/slab.h>
    2626#include <linux/pci.h>
    27 #include <linux/mutex.h>
    2827#include <sound/core.h>
    2928#include "hda_codec.h"
    3029#include "hda_local.h"
     30#include "hda_patch.h"
    3131
    3232#define CXT_PIN_DIR_IN              0x00
     
    8383        struct hda_pcm pcm_rec[2];      /* used in build_pcms() */
    8484
    85         struct mutex amp_mutex; /* PCM volume/mute control mutex */
    8685        unsigned int spdif_route;
    8786
     
    10099{
    101100        struct conexant_spec *spec = codec->spec;
    102         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     101        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
     102                                             hinfo);
    103103}
    104104
     
    174174{
    175175        struct conexant_spec *spec = codec->spec;
    176         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
    177                                    0, 0, 0);
     176        snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
    178177        return 0;
    179178}
     
    243242{
    244243        struct conexant_spec *spec = codec->spec;
    245         snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
     244        snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
    246245        spec->cur_adc = 0;
    247246        return 0;
     
    286285                codec->num_pcms++;
    287286                info->name = "Conexant Digital";
     287                info->pcm_type = HDA_PCM_TYPE_SPDIF;
    288288                info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
    289289                        conexant_pcm_digital_playback;
     
    373373                if (err < 0)
    374374                        return err;
     375                err = snd_hda_create_spdif_share_sw(codec,
     376                                                    &spec->multiout);
     377                if (err < 0)
     378                        return err;
     379                spec->multiout.share_spdif = 1;
    375380        }
    376381        if (spec->dig_in_nid) {
     
    510515                { "ExtMic", 0x2 },
    511516                { "LineIn", 0x3 },
     517        }
     518};
     519
     520static struct hda_input_mux cxt5045_capture_source_hp530 = {
     521        .num_items = 2,
     522        .items = {
     523                { "ExtMic", 0x1 },
     524                { "IntMic", 0x2 },
    512525        }
    513526};
     
    641654};
    642655
     656static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
     657        {
     658                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     659                .name = "Capture Source",
     660                .info = conexant_mux_enum_info,
     661                .get = conexant_mux_enum_get,
     662                .put = conexant_mux_enum_put
     663        },
     664        HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
     665        HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
     666        HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
     667        HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
     668        HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
     669        HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
     670        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
     671        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
     672        HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
     673        HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
     674        HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
     675        {
     676                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     677                .name = "Master Playback Switch",
     678                .info = cxt_eapd_info,
     679                .get = cxt_eapd_get,
     680                .put = cxt5045_hp_master_sw_put,
     681                .private_value = 0x10,
     682        },
     683
     684        {0}
     685};
     686
    643687static struct hda_verb cxt5045_init_verbs[] = {
    644688        /* Line in, Mic */
    645         {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     689        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
    646690        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
    647691        /* HP, Amp  */
     
    660704         AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
    661705        /* SPDIF route: PCM */
    662         {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     706        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    663707        { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
    664708        /* EAPD */
     
    703747        {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
    704748        {0} /* end */
    705 
    706749};
    707750
     
    836879        CXT5045_LAPTOP_HPMICSENSE,
    837880        CXT5045_BENQ,
     881        CXT5045_LAPTOP_HP530,
    838882#ifdef CONFIG_SND_DEBUG
    839883        CXT5045_TEST,
     
    847891        [CXT5045_LAPTOP_HPMICSENSE]     = "laptop-hpmicsense",
    848892        [CXT5045_BENQ]                  = "benq",
     893        [CXT5045_LAPTOP_HP530]          = "laptop-hp530",
    849894#ifdef CONFIG_SND_DEBUG
    850895        [CXT5045_TEST]          = "test",
     
    860905        SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
    861906        SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
    862         SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE),
     907        SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
    863908        SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
     909        SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
    864910        SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
    865911        SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
    866912        SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
    867         SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP_HPSENSE),
     913        SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
     914                      CXT5045_LAPTOP_HPMICSENSE),
    868915        SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
    869916        SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
     
    883930        if (!spec)
    884931                return -ENOMEM;
    885         mutex_init(&spec->amp_mutex);
    886932        codec->spec = spec;
    887933
     
    918964                break;
    919965        case CXT5045_LAPTOP_MICSENSE:
     966                codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
    920967                spec->input_mux = &cxt5045_capture_source;
    921968                spec->num_init_verbs = 2;
     
    944991                codec->patch_ops.init = cxt5045_init;
    945992                break;
     993        case CXT5045_LAPTOP_HP530:
     994                codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
     995                spec->input_mux = &cxt5045_capture_source_hp530;
     996                spec->num_init_verbs = 2;
     997                spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
     998                spec->mixers[0] = cxt5045_mixers_hp530;
     999                codec->patch_ops.init = cxt5045_init;
     1000                break;
    9461001#ifdef CONFIG_SND_DEBUG
    9471002        case CXT5045_TEST:
     
    9541009        }
    9551010
    956         /*
    957          * Fix max PCM level to 0 dB
    958          * (originall it has 0x2b steps with 0dB offset 0x14)
    959          */
    960         snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
    961                                   (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
    962                                   (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
    963                                   (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
    964                                   (1 << AC_AMPCAP_MUTE_SHIFT));
     1011        switch (codec->subsystem_id >> 16) {
     1012        case 0x103c:
     1013                /* HP laptop has a really bad sound over 0dB on NID 0x17.
     1014                 * Fix max PCM level to 0 dB
     1015                 * (originall it has 0x2b steps with 0dB offset 0x14)
     1016                 */
     1017                snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
     1018                                          (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
     1019                                          (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
     1020                                          (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
     1021                                          (1 << AC_AMPCAP_MUTE_SHIFT));
     1022                break;
     1023        }
    9651024
    9661025        return 0;
     
    12331292        /* pin sensing on HP jack */
    12341293        {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
     1294        /* 0x13 is actually shared by both HP and speaker;
     1295         * setting the connection to 0 (=0x19) makes the master volume control
     1296         * working mysteriouslly...
     1297         */
     1298        {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
    12351299        /* Record selector: Ext Mic */
    12361300        {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
     
    14191483        if (!spec)
    14201484                return -ENOMEM;
    1421         mutex_init(&spec->amp_mutex);
    14221485        codec->spec = spec;
    14231486
     
    15351598        if (spec->cur_adc && spec->cur_adc != new_adc) {
    15361599                /* stream is running, let's swap the current ADC */
    1537                 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
     1600                snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
    15381601                spec->cur_adc = new_adc;
    15391602                snd_hda_codec_setup_stream(codec, new_adc,
     
    16781741        if (!spec)
    16791742                return -ENOMEM;
    1680         mutex_init(&spec->amp_mutex);
    16811743        codec->spec = spec;
    16821744
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_realtek.c

    r305 r358  
    3131#include "hda_codec.h"
    3232#include "hda_local.h"
     33#include "hda_patch.h"
    3334
    3435#define ALC880_FRONT_EVENT              0x01
     
    6061        ALC880_LG,
    6162        ALC880_LG_LW,
     63        ALC880_MEDION_RIM,
    6264#ifdef CONFIG_SND_DEBUG
    6365        ALC880_TEST,
     
    98100        ALC262_BENQ_T31,
    99101        ALC262_ULTRA,
     102        ALC262_LENOVO_3000,
    100103        ALC262_AUTO,
    101104        ALC262_MODEL_LAST /* last tag */
     
    104107/* ALC268 models */
    105108enum {
     109        ALC267_QUANTA_IL1,
    106110        ALC268_3ST,
    107111        ALC268_TOSHIBA,
     
    160164        ALC662_ASUS_EEEPC_P701,
    161165        ALC662_ASUS_EEEPC_EP20,
     166        ALC663_ASUS_M51VA,
     167        ALC663_ASUS_G71V,
     168        ALC663_ASUS_H13,
     169        ALC663_ASUS_G50V,
    162170        ALC662_AUTO,
    163171        ALC662_MODEL_LAST,
     
    197205        ALC888_LENOVO_MS7195_DIG,
    198206        ALC883_HAIER_W66,               
    199         ALC888_6ST_HP,
    200207        ALC888_3ST_HP,
    201208        ALC888_6ST_DELL,
    202209        ALC883_MITAC,
     210        ALC883_CLEVO_M720,
     211        ALC883_FUJITSU_PI2515,
     212        ALC883_3ST_6ch_INTEL,
    203213        ALC883_AUTO,
    204214        ALC883_MODEL_LAST,
     
    239249        unsigned int num_adc_nids;
    240250        hda_nid_t *adc_nids;
     251        hda_nid_t *capsrc_nids;
    241252        hda_nid_t dig_in_nid;           /* digital-in NID; optional */
    242253
     
    272283        /* for virtual master */
    273284        hda_nid_t vmaster_nid;
    274         u32 vmaster_tlv[4];
    275285#ifdef CONFIG_SND_HDA_POWER_SAVE
    276286        struct hda_loopback_check loopback;
    277287#endif
     288
     289        /* for PLL fix */
     290        hda_nid_t pll_nid;
     291        unsigned int pll_coef_idx, pll_coef_bit;
    278292};
    279293
     
    292306        unsigned int num_adc_nids;
    293307        hda_nid_t *adc_nids;
     308        hda_nid_t *capsrc_nids;
    294309        hda_nid_t dig_in_nid;
    295310        unsigned int num_channel_mode;
     
    338353        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    339354        unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
     355        hda_nid_t nid = spec->capsrc_nids ?
     356                spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
    340357        return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
    341                                      spec->adc_nids[adc_idx],
    342                                      &spec->cur_mux[adc_idx]);
     358                                     nid, &spec->cur_mux[adc_idx]);
    343359}
    344360
     
    709725        spec->num_adc_nids = preset->num_adc_nids;
    710726        spec->adc_nids = preset->adc_nids;
     727        spec->capsrc_nids = preset->capsrc_nids;
    711728        spec->dig_in_nid = preset->dig_in_nid;
    712729
     
    740757};
    741758
     759/*
     760 * Fix hardware PLL issue
     761 * On some codecs, the analog PLL gating control must be off while
     762 * the default value is 1.
     763 */
     764static void alc_fix_pll(struct hda_codec *codec)
     765{
     766        struct alc_spec *spec = codec->spec;
     767        unsigned int val;
     768
     769        if (!spec->pll_nid)
     770                return;
     771        snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
     772                            spec->pll_coef_idx);
     773        val = snd_hda_codec_read(codec, spec->pll_nid, 0,
     774                                 AC_VERB_GET_PROC_COEF, 0);
     775        snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
     776                            spec->pll_coef_idx);
     777        snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
     778                            val & ~(1 << spec->pll_coef_bit));
     779}
     780
     781static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
     782                             unsigned int coef_idx, unsigned int coef_bit)
     783{
     784        struct alc_spec *spec = codec->spec;
     785        spec->pll_nid = nid;
     786        spec->pll_coef_idx = coef_idx;
     787        spec->pll_coef_bit = coef_bit;
     788        alc_fix_pll(codec);
     789}
     790
    742791static void alc_sku_automute(struct hda_codec *codec)
    743792{
    744793        struct alc_spec *spec = codec->spec;
    745         unsigned int mute;
    746794        unsigned int present;
    747795        unsigned int hp_nid = spec->autocfg.hp_pins[0];
     
    753801                                     AC_VERB_GET_PIN_SENSE, 0);
    754802        spec->jack_present = (present & 0x80000000) != 0;
    755         if (spec->jack_present) {
    756                 /* mute internal speaker */
    757                 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
    758                                          HDA_AMP_MUTE, HDA_AMP_MUTE);
    759         } else {
    760                 /* unmute internal speaker if necessary */
    761                 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
    762                 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
    763                                          HDA_AMP_MUTE, mute);
    764         }
     803        snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     804                            spec->jack_present ? 0 : PIN_OUT);
    765805}
    766806
     
    776816
    777817        alc_sku_automute(codec);
     818}
     819
     820/* additional initialization for ALC888 variants */
     821static void alc888_coef_init(struct hda_codec *codec)
     822{
     823        unsigned int tmp;
     824
     825        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
     826        tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
     827        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
     828        if ((tmp & 0xf0) == 2)
     829                /* alc888S-VC */
     830                snd_hda_codec_read(codec, 0x20, 0,
     831                                   AC_VERB_SET_PROC_COEF, 0x830);
     832         else
     833                 /* alc888-VB */
     834                 snd_hda_codec_read(codec, 0x20, 0,
     835                                    AC_VERB_SET_PROC_COEF, 0x3030);
    778836}
    779837
     
    853911                case 0x10ec0268:
    854912                case 0x10ec0269:
     913                case 0x10ec0660:
     914                case 0x10ec0662:
     915                case 0x10ec0663:
    855916                case 0x10ec0862:
    856                 case 0x10ec0662:       
     917                case 0x10ec0889:
    857918                        snd_hda_codec_write(codec, 0x14, 0,
    858919                                            AC_VERB_SET_EAPD_BTLENABLE, 2);
     
    878939                case 0x10ec0883:
    879940                case 0x10ec0885:
    880                 case 0x10ec0888:
     941                case 0x10ec0889:
    881942                        snd_hda_codec_write(codec, 0x20, 0,
    882943                                            AC_VERB_SET_COEF_INDEX, 7);
     
    888949                                            AC_VERB_SET_PROC_COEF,
    889950                                            tmp | 0x2010);
     951                        break;
     952                case 0x10ec0888:
     953                        alc888_coef_init(codec);
    890954                        break;
    891955                case 0x10ec0267:
     
    9421006                            AC_USRSP_EN | ALC880_HP_EVENT);
    9431007        spec->unsol_event = alc_sku_unsol_event;
    944         spec->init_hook = alc_sku_automute;     
    9451008}
    9461009
     
    13211384        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    13221385        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    1323         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    1324         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     1386        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     1387        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    13251388        {0} /* end */
     1389};
     1390
     1391static struct hda_input_mux alc880_f1734_capture_source = {
     1392        .num_items = 2,
     1393        .items = {
     1394                { "Mic", 0x1 },
     1395                { "CD", 0x4 },
     1396        },
    13261397};
    13271398
     
    15181589                if (err < 0)
    15191590                        return err;
     1591                err = snd_hda_create_spdif_share_sw(codec,
     1592                                                    &spec->multiout);
     1593                if (err < 0)
     1594                        return err;
     1595                spec->multiout.share_spdif = 1;
    15201596        }
    15211597        if (spec->dig_in_nid) {
     
    15271603        /* if we have no master control, let's create it */
    15281604        if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
     1605                unsigned int vmaster_tlv[4];
    15291606                snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
    1530                                         HDA_OUTPUT, spec->vmaster_tlv);
     1607                                        HDA_OUTPUT, vmaster_tlv);
    15311608                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
    1532                                           spec->vmaster_tlv, alc_slave_vols);
     1609                                          vmaster_tlv, alc_slave_vols);
    15331610                if (err < 0)
    15341611                        return err;
     
    18841961                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    18851962        bits = present ? HDA_AMP_MUTE : 0;
    1886         snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
     1963        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
    18871964}
    18881965
     
    19171994 */
    19181995static struct hda_verb alc880_pin_f1734_init_verbs[] = {
     1996        {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
    19191997        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
    19201998        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
     
    19292007        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    19302008        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1931         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     2009        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
    19322010        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    19332011        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     
    19362014        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
    19372015        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     2016
     2017        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
     2018        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
    19382019
    19392020        {0}
     
    22602341}
    22612342
     2343static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
     2344        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     2345        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
     2346        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     2347        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     2348        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     2349        HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
     2350        {0} /* end */
     2351};
     2352
     2353static struct hda_input_mux alc880_medion_rim_capture_source = {
     2354        .num_items = 2,
     2355        .items = {
     2356                { "Mic", 0x0 },
     2357                { "Internal Mic", 0x1 },
     2358        },
     2359};
     2360
     2361static struct hda_verb alc880_medion_rim_init_verbs[] = {
     2362        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
     2363
     2364        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     2365        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     2366
     2367        /* Mic1 (rear panel) pin widget for input and vref at 80% */
     2368        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     2369        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     2370        /* Mic2 (as headphone out) for HP output */
     2371        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     2372        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     2373        /* Internal Speaker */
     2374        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     2375        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     2376
     2377        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
     2378        {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
     2379
     2380        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     2381        {0}
     2382};
     2383
     2384/* toggle speaker-output according to the hp-jack state */
     2385static void alc880_medion_rim_automute(struct hda_codec *codec)
     2386{
     2387        unsigned int present;
     2388        unsigned char bits;
     2389
     2390        present = snd_hda_codec_read(codec, 0x14, 0,
     2391                                     AC_VERB_GET_PIN_SENSE, 0)
     2392                & AC_PINSENSE_PRESENCE;
     2393        bits = present ? HDA_AMP_MUTE : 0;
     2394        snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
     2395                                 HDA_AMP_MUTE, bits);
     2396        if (present)
     2397                snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
     2398        else
     2399                snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
     2400}
     2401
     2402static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
     2403                                          unsigned int res)
     2404{
     2405        /* Looks like the unsol event is incompatible with the standard
     2406         * definition.  4bit tag is placed at 28 bit!
     2407         */
     2408        if ((res >> 28) == ALC880_HP_EVENT)
     2409                alc880_medion_rim_automute(codec);
     2410}
     2411
    22622412#ifdef CONFIG_SND_HDA_POWER_SAVE
    22632413static struct hda_amp_list alc880_loopbacks[] = {
     
    22872437        unsigned int i;
    22882438
     2439        alc_fix_pll(codec);
     2440
    22892441        for (i = 0; i < spec->num_init_verbs; i++)
    22902442                snd_hda_sequence_write(codec, spec->init_verbs[i]);
     
    23202472{
    23212473        struct alc_spec *spec = codec->spec;
    2322         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     2474        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
     2475                                             hinfo);
    23232476}
    23242477
     
    23942547        struct alc_spec *spec = codec->spec;
    23952548
    2396         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
    2397                                    0, 0, 0);
     2549        snd_hda_codec_cleanup_stream(codec,
     2550                                     spec->adc_nids[substream->number + 1]);
    23982551        return 0;
    23992552}
     
    25002653                info = spec->pcm_rec + 1;
    25012654                info->name = spec->stream_name_digital;
     2655                info->pcm_type = HDA_PCM_TYPE_SPDIF;
    25022656                if (spec->multiout.dig_out_nid &&
    25032657                    spec->stream_digital_playback) {
     
    25622716        }
    25632717        kfree(spec);
     2718        codec->spec = NULL; /* to be sure */
    25642719}
    25652720
     
    28643019        [ALC880_LG]             = "lg",
    28653020        [ALC880_LG_LW]          = "lg-lw",
     3021        [ALC880_MEDION_RIM]     = "medion",
    28663022#ifdef CONFIG_SND_DEBUG
    28673023        [ALC880_TEST]           = "test",
     
    28923048        SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
    28933049        SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
    2894         SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
     3050        SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
    28953051        SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
    28963052        SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
     
    29153071        SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
    29163072        SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
     3073        SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
    29173074        SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
    29183075        SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
    29193076        SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
     3077        SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
    29203078        SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
    29213079        SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
     
    30593217                .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
    30603218                .channel_mode = alc880_2_jack_modes,
    3061                 .input_mux = &alc880_capture_source,
     3219                .input_mux = &alc880_f1734_capture_source,
     3220                .unsol_event = alc880_uniwill_p53_unsol_event,
     3221                .init_hook = alc880_uniwill_p53_hp_automute,
    30623222        },
    30633223        [ALC880_ASUS] = {
     
    32063366                .unsol_event = alc880_lg_lw_unsol_event,
    32073367                .init_hook = alc880_lg_lw_automute,
     3368        },
     3369        [ALC880_MEDION_RIM] = {
     3370                .mixers = { alc880_medion_rim_mixer },
     3371                .init_verbs = { alc880_volume_init_verbs,
     3372                                alc880_medion_rim_init_verbs,
     3373                                alc_gpio2_init_verbs },
     3374                .num_dacs = ARRAY_SIZE(alc880_dac_nids),
     3375                .dac_nids = alc880_dac_nids,
     3376                .dig_out_nid = ALC880_DIGOUT_NID,
     3377                .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
     3378                .channel_mode = alc880_2_jack_modes,
     3379                .input_mux = &alc880_medion_rim_capture_source,
     3380                .unsol_event = alc880_medion_rim_unsol_event,
     3381                .init_hook = alc880_medion_rim_automute,
    32083382        },
    32093383#ifdef CONFIG_SND_DEBUG
     
    34693643}
    34703644
     3645static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
     3646                               unsigned int pin_type)
     3647{
     3648        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     3649                            pin_type);
     3650        /* unmute pin */
     3651        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     3652                            AMP_OUT_UNMUTE);
     3653}
     3654
    34713655static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
    34723656                                              hda_nid_t nid, int pin_type,
    34733657                                              int dac_idx)
    34743658{
    3475         /* set as output */
    3476         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    3477                             pin_type);
    3478         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    3479                             AMP_OUT_UNMUTE);
     3659        alc_set_pin_output(codec, nid, pin_type);
    34803660        /* need the manual connection? */
    34813661        if (alc880_is_multi_pin(nid)) {
     
    35993779static void alc880_auto_init(struct hda_codec *codec)
    36003780{
     3781        struct alc_spec *spec = codec->spec;
    36013782        alc880_auto_init_multi_out(codec);
    36023783        alc880_auto_init_extra_out(codec);
    36033784        alc880_auto_init_analog_input(codec);
     3785        if (spec->unsol_event)
     3786                alc_sku_automute(codec);
    36043787}
    36053788
     
    39754158        HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    39764159        HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    3977         HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
    3978         HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
     4160        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
     4161        HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
    39794162        {0} /* end */
    39804163};
     
    40074190        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
    40084191        ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
    4009         HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
     4192        HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
    40104193                              HDA_OUTPUT),
    4011         HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
     4194        HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
    40124195                           HDA_INPUT),
    40134196        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
     
    47974980                                              int sel_idx)
    47984981{
    4799         /* set as output */
    4800         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    4801                             pin_type);
    4802         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    4803                             AMP_OUT_UNMUTE);
     4982        alc_set_pin_output(codec, nid, pin_type);
    48044983        /* need the manual connection? */
    48054984        if (nid >= 0x12) {
     
    49315110        wcap = get_wcaps(codec, 0x04);
    49325111        wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
    4933         if (wcap != AC_WID_AUD_IN) {
     5112        if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
    49345113                spec->adc_nids = alc260_adc_nids_alt;
    49355114                spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
     
    49485127static void alc260_auto_init(struct hda_codec *codec)
    49495128{
     5129        struct alc_spec *spec = codec->spec;
    49505130        alc260_auto_init_multi_out(codec);
    49515131        alc260_auto_init_analog_input(codec);
     5132        if (spec->unsol_event)
     5133                alc_sku_automute(codec);
    49525134}
    49535135
     
    49865168        SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
    49875169        SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
    4988         SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
     5170        SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
    49895171        SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
    49905172        SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
     
    52065388#define alc882_adc_nids_alt     alc880_adc_nids_alt
    52075389
     5390static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
     5391static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
     5392
    52085393/* input MUX */
    52095394/* FIXME: should be a matrix-type input source selection */
     
    52285413        const struct hda_input_mux *imux = spec->input_mux;
    52295414        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    5230         static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
    5231         hda_nid_t nid = capture_mixers[adc_idx];
     5415        hda_nid_t nid = spec->capsrc_nids ?
     5416                spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
    52325417        unsigned int *cur_val = &spec->cur_mux[adc_idx];
    52335418        unsigned int i, idx;
     
    60096194        SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
    60106195        SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
     6196        SND_PCI_QUIRK(0x106b, 0x00a0, "Apple iMac 24''", ALC885_IMAC24),
    60116197        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
    60126198        SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8  */
     
    61096295                .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
    61106296                .adc_nids = alc882_adc_nids,
     6297                .capsrc_nids = alc882_capsrc_nids,
    61116298                .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
    61126299                .channel_mode = alc882_3ST_6ch_modes,
     
    61256312                .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
    61266313                .adc_nids = alc882_adc_nids,
     6314                .capsrc_nids = alc882_capsrc_nids,
    61276315                .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
    61286316                .channel_mode = alc882_3ST_6ch_modes,
     
    61806368        int idx;
    61816369
     6370        alc_set_pin_output(codec, nid, pin_type);
    61826371        if (spec->multiout.dac_nids[dac_idx] == 0x25)
    61836372                idx = 4;
    61846373        else
    61856374                idx = spec->multiout.dac_nids[dac_idx] - 2;
    6186 
    6187         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    6188                             pin_type);
    6189         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    6190                             AMP_OUT_UNMUTE);
    61916375        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
    61926376
     
    62176401                /* use dac 0 */
    62186402                alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     6403        pin = spec->autocfg.speaker_pins[0];
     6404        if (pin)
     6405                alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    62196406}
    62206407
     
    62296416        for (i = 0; i < AUTO_PIN_LAST; i++) {
    62306417                hda_nid_t nid = spec->autocfg.input_pins[i];
    6231                 if (alc882_is_input_pin(nid)) {
     6418                unsigned int vref;
     6419                if (!nid)
     6420                        continue;
     6421                vref = PIN_IN;
     6422                if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
     6423                        unsigned int pincap;
     6424                        pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
     6425                        if ((pincap >> AC_PINCAP_VREF_SHIFT) &
     6426                            AC_PINCAP_VREF_80)
     6427                                vref = PIN_VREF80;
     6428                }
     6429                snd_hda_codec_write(codec, nid, 0,
     6430                                    AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
     6431                if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
    62326432                        snd_hda_codec_write(codec, nid, 0,
    6233                                             AC_VERB_SET_PIN_WIDGET_CONTROL,
    6234                                             i <= AUTO_PIN_FRONT_MIC ?
    6235                                             PIN_VREF80 : PIN_IN);
    6236                         if (nid != ALC882_PIN_CD_NID)
    6237                                 snd_hda_codec_write(codec, nid, 0,
    6238                                                     AC_VERB_SET_AMP_GAIN_MUTE,
    6239                                                     AMP_OUT_MUTE);
    6240                 }
     6433                                            AC_VERB_SET_AMP_GAIN_MUTE,
     6434                                            AMP_OUT_MUTE);
    62416435        }
    62426436}
     
    62926486static void alc882_auto_init(struct hda_codec *codec)
    62936487{
     6488        struct alc_spec *spec = codec->spec;
    62946489        alc882_auto_init_multi_out(codec);
    62956490        alc882_auto_init_hp_out(codec);
    62966491        alc882_auto_init_analog_input(codec);
    6297 }
     6492        if (spec->unsol_event)
     6493                alc_sku_automute(codec);
     6494}
     6495
     6496static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
    62986497
    62996498static int patch_alc882(struct hda_codec *codec)
     
    63216520                        board_config = ALC885_IMAC24;
    63226521                        break;
    6323                 case 0x106b00a1: /* Macbook */
     6522                case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
    63246523                case 0x106b2c00: /* Macbook Pro rev3 */
     6524                case 0x106b3600: /* Macbook 3.1 */
    63256525                        board_config = ALC885_MBP3;
    63266526                        break;
    63276527                default:
     6528                        /* ALC889A is handled better as ALC888-compatible */
     6529                        if (codec->revision_id == 0x100103) {
     6530                                alc_free(codec);
     6531                                return patch_alc883(codec);
     6532                        }
    63286533                        printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
    63296534                                         "trying auto-probe from BIOS...\n");
     
    63516556                setup_preset(spec, &alc882_presets[board_config]);
    63526557
    6353         spec->stream_name_analog = "ALC882 Analog";
     6558        if (codec->vendor_id == 0x10ec0885) {
     6559                spec->stream_name_analog = "ALC885 Analog";
     6560                spec->stream_name_digital = "ALC885 Digital";
     6561        } else {
     6562                spec->stream_name_analog = "ALC882 Analog";
     6563                spec->stream_name_digital = "ALC882 Digital";
     6564        }
     6565
    63546566        spec->stream_analog_playback = &alc882_pcm_analog_playback;
    63556567        spec->stream_analog_capture = &alc882_pcm_analog_capture;
     
    63586570        spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
    63596571
    6360         spec->stream_name_digital = "ALC882 Digital";
    63616572        spec->stream_digital_playback = &alc882_pcm_digital_playback;
    63626573        spec->stream_digital_capture = &alc882_pcm_digital_capture;
     
    63706581                        spec->adc_nids = alc882_adc_nids_alt;
    63716582                        spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
     6583                        spec->capsrc_nids = alc882_capsrc_nids_alt;
    63726584                        spec->mixers[spec->num_mixers] =
    63736585                                alc882_capture_alt_mixer;
     
    63766588                        spec->adc_nids = alc882_adc_nids;
    63776589                        spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
     6590                        spec->capsrc_nids = alc882_capsrc_nids;
    63786591                        spec->mixers[spec->num_mixers] = alc882_capture_mixer;
    63796592                        spec->num_mixers++;
     
    64106623static hda_nid_t alc883_dac_nids[4] = {
    64116624        /* front, rear, clfe, rear_surr */
    6412         0x02, 0x04, 0x03, 0x05
     6625        0x02, 0x03, 0x04, 0x05
    64136626};
    64146627
     
    64176630        0x08, 0x09,
    64186631};
     6632
     6633static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
    64196634
    64206635/* input MUX */
     
    64316646};
    64326647
     6648static struct hda_input_mux alc883_3stack_6ch_intel = {
     6649        .num_items = 4,
     6650        .items = {
     6651                { "Mic", 0x1 },
     6652                { "Front Mic", 0x0 },
     6653                { "Line", 0x2 },
     6654                { "CD", 0x4 },
     6655        },
     6656};
     6657
    64336658static struct hda_input_mux alc883_lenovo_101e_capture_source = {
    64346659        .num_items = 2,
     
    64496674};
    64506675
     6676static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
     6677        .num_items = 2,
     6678        .items = {
     6679                { "Mic", 0x0 },
     6680                { "Int Mic", 0x1 },
     6681        },
     6682};
     6683
    64516684#define alc883_mux_enum_info alc_mux_enum_info
    64526685#define alc883_mux_enum_get alc_mux_enum_get
    6453 
    6454 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
    6455                                struct snd_ctl_elem_value *ucontrol)
    6456 {
    6457         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    6458         struct alc_spec *spec = codec->spec;
    6459         const struct hda_input_mux *imux = spec->input_mux;
    6460         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    6461         static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
    6462         hda_nid_t nid = capture_mixers[adc_idx];
    6463         unsigned int *cur_val = &spec->cur_mux[adc_idx];
    6464         unsigned int i, idx;
    6465 
    6466         idx = ucontrol->value.enumerated.item[0];
    6467         if (idx >= imux->num_items)
    6468                 idx = imux->num_items - 1;
    6469         if (*cur_val == idx)
    6470                 return 0;
    6471         for (i = 0; i < imux->num_items; i++) {
    6472                 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
    6473                 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
    6474                                          imux->items[i].index,
    6475                                          HDA_AMP_MUTE, v);
    6476         }
    6477         *cur_val = idx;
    6478         return 1;
    6479 }
     6686/* ALC883 has the ALC882-type input selection */
     6687#define alc883_mux_enum_put alc882_mux_enum_put
    64806688
    64816689/*
     
    65266734        { 4, alc883_3ST_ch4_init },
    65276735        { 6, alc883_3ST_ch6_init },
     6736};
     6737
     6738/*
     6739 * 2ch mode
     6740 */
     6741static struct hda_verb alc883_3ST_ch2_intel_init[] = {
     6742        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     6743        { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     6744        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     6745        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     6746        {0} /* end */
     6747};
     6748
     6749/*
     6750 * 4ch mode
     6751 */
     6752static struct hda_verb alc883_3ST_ch4_intel_init[] = {
     6753        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     6754        { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     6755        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     6756        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     6757        { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
     6758        {0} /* end */
     6759};
     6760
     6761/*
     6762 * 6ch mode
     6763 */
     6764static struct hda_verb alc883_3ST_ch6_intel_init[] = {
     6765        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     6766        { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     6767        { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
     6768        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     6769        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     6770        { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
     6771        {0} /* end */
     6772};
     6773
     6774static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
     6775        { 2, alc883_3ST_ch2_intel_init },
     6776        { 4, alc883_3ST_ch4_intel_init },
     6777        { 6, alc883_3ST_ch6_intel_init },
    65286778};
    65296779
     
    66366886};
    66376887
     6888static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
     6889        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     6890        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
     6891        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     6892        HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
     6893        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     6894        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
     6895        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     6896        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     6897        HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
     6898        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     6899        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6900        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6901        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     6902        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     6903        {
     6904                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6905                /* .name = "Capture Source", */
     6906                .name = "Input Source",
     6907                .count = 2,
     6908                .info = alc883_mux_enum_info,
     6909                .get = alc883_mux_enum_get,
     6910                .put = alc883_mux_enum_put,
     6911        },
     6912        {0} /* end */
     6913};
     6914
     6915static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
     6916        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     6917        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
     6918        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     6919        HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
     6920        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     6921        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
     6922        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     6923        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     6924        HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
     6925        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     6926        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     6927        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     6928        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     6929        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     6930        {
     6931                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     6932                /* .name = "Capture Source", */
     6933                .name = "Input Source",
     6934                .count = 2,
     6935                .info = alc883_mux_enum_info,
     6936                .get = alc883_mux_enum_get,
     6937                .put = alc883_mux_enum_put,
     6938        },
     6939        {0} /* end */
     6940};
     6941
    66386942static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
    66396943        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     
    67067010};
    67077011
     7012static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
     7013        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     7014        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     7015        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     7016        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     7017        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
     7018                              HDA_OUTPUT),
     7019        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     7020        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     7021        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     7022        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     7023        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     7024        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     7025        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     7026        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     7027        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     7028        HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
     7029        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     7030        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     7031        HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
     7032        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     7033        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
     7034        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
     7035        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     7036        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     7037        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
     7038        HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
     7039        {
     7040                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     7041                /* .name = "Capture Source", */
     7042                .name = "Input Source",
     7043                .count = 2,
     7044                .info = alc883_mux_enum_info,
     7045                .get = alc883_mux_enum_get,
     7046                .put = alc883_mux_enum_put,
     7047        },
     7048        {0} /* end */
     7049};
     7050
    67087051static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
    67097052        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    6710         HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     7053        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    67117054        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
    6712         HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     7055        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
    67137056        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
    67147057        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
    6715         HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
    6716         HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
     7058        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     7059        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
    67177060        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    67187061        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     
    67857128        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    67867129        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     7130        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     7131        HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
     7132        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    67877133        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    67887134        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
     
    68757221        {0} /* end */
    68767222};     
    6877 
    6878 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
    6879         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    6880         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    6881         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
    6882         HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
    6883         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
    6884         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
    6885         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
    6886         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
    6887         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    6888         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    6889         HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    6890         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    6891         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    6892         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    6893         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    6894         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    6895         HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    6896         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    6897         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    6898         HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    6899         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    6900         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    6901         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    6902         HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    6903         HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    6904         HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    6905         HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    6906         {
    6907                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    6908                 /* .name = "Capture Source", */
    6909                 .name = "Input Source",
    6910                 .count = 2,
    6911                 .info = alc883_mux_enum_info,
    6912                 .get = alc883_mux_enum_get,
    6913                 .put = alc883_mux_enum_put,
    6914         },
    6915         {0} /* end */
    6916 };
    6917 
    6918 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
    6919         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    6920         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    6921         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
    6922         HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
    6923         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
    6924         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
    6925         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
    6926         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
    6927         HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    6928         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    6929         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    6930         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    6931         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    6932         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    6933         HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    6934         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    6935         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    6936         HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    6937         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    6938         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    6939         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    6940         HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    6941         HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    6942         HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    6943         HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    6944         {
    6945                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    6946                 /* .name = "Capture Source", */
    6947                 .name = "Input Source",
    6948                 .count = 2,
    6949                 .info = alc883_mux_enum_info,
    6950                 .get = alc883_mux_enum_get,
    6951                 .put = alc883_mux_enum_put,
    6952         },
    6953         {0} /* end */
    6954 };
    6955 
    6956 static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
    6957         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    6958         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
    6959         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
    6960         HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
    6961         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
    6962         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
    6963         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
    6964         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
    6965         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
    6966         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
    6967         HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    6968         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    6969         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    6970         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
    6971         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    6972         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    6973         HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    6974         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    6975         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    6976         HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    6977         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    6978         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    6979         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    6980         HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
    6981         HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    6982         HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
    6983         HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
    6984         {
    6985                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    6986                 /* .name = "Capture Source", */
    6987                 .name = "Input Source",
    6988                 .count = 2,
    6989                 .info = alc883_mux_enum_info,
    6990                 .get = alc883_mux_enum_get,
    6991                 .put = alc883_mux_enum_put,
    6992         },
    6993         {0} /* end */
    6994 };
    69957223
    69967224static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
     
    71697397};
    71707398
     7399static struct hda_verb alc883_clevo_m720_verbs[] = {
     7400        /* HP */
     7401        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
     7402        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     7403        /* Int speaker */
     7404        {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
     7405        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     7406
     7407        /* enable unsolicited event */
     7408        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     7409        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
     7410
     7411        {0} /* end */
     7412};
     7413
     7414static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
     7415        /* HP */
     7416        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     7417        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     7418        /* Subwoofer */
     7419        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
     7420        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     7421
     7422        /* enable unsolicited event */
     7423        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     7424
     7425        {0} /* end */
     7426};
     7427
    71717428static struct hda_verb alc883_tagra_verbs[] = {
    71727429        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     
    72257482};
    72267483
    7227 static struct hda_verb alc888_6st_hp_verbs[] = {
    7228         {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Front: output 0 (0x0c) */
    7229         {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},  /* Rear : output 2 (0x0e) */
    7230         {0x16, AC_VERB_SET_CONNECT_SEL, 0x01},  /* CLFE : output 1 (0x0d) */
    7231         {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},  /* Side : output 3 (0x0f) */
    7232         {0}
    7233 };
    7234 
    72357484static struct hda_verb alc888_3st_hp_verbs[] = {
    72367485        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Front: output 0 (0x0c) */
    7237         {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Rear : output 1 (0x0d) */
    7238         {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},  /* CLFE : output 2 (0x0e) */
     7486        {0x16, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Rear : output 1 (0x0d) */
     7487        {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},  /* CLFE : output 2 (0x0e) */
    72397488        {0}
    72407489};
    72417490
    72427491static struct hda_verb alc888_6st_dell_verbs[] = {
    7243         {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Front: output 0 (0x0c) */
    7244         {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},  /* Rear : output 1 (0x0e) */
    7245         {0x16, AC_VERB_SET_CONNECT_SEL, 0x01},  /* CLFE : output 2 (0x0d) */
    7246         {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},  /* Side : output 3 (0x0f) */
    72477492        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
    72487493        {0}
     
    73507595        if ((res >> 26) == ALC880_HP_EVENT)
    73517596                alc883_tagra_automute(codec);
     7597}
     7598
     7599/* toggle speaker-output according to the hp-jack state */
     7600static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
     7601{
     7602        unsigned int present;
     7603        unsigned char bits;
     7604
     7605        present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
     7606                & AC_PINSENSE_PRESENCE;
     7607        bits = present ? HDA_AMP_MUTE : 0;
     7608        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     7609                                 HDA_AMP_MUTE, bits);
     7610}
     7611
     7612static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
     7613{
     7614        unsigned int present;
     7615
     7616        present = snd_hda_codec_read(codec, 0x18, 0,
     7617                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     7618        snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
     7619                                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
     7620}
     7621
     7622static void alc883_clevo_m720_automute(struct hda_codec *codec)
     7623{
     7624        alc883_clevo_m720_hp_automute(codec);
     7625        alc883_clevo_m720_mic_automute(codec);
     7626}
     7627
     7628static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
     7629                                           unsigned int res)
     7630{
     7631        switch (res >> 26) {
     7632        case ALC880_HP_EVENT:
     7633                alc883_clevo_m720_hp_automute(codec);
     7634                break;
     7635        case ALC880_MIC_EVENT:
     7636                alc883_clevo_m720_mic_automute(codec);
     7637                break;
     7638        }
     7639}
     7640
     7641/* toggle speaker-output according to the hp-jack state */
     7642static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
     7643{
     7644        unsigned int present;
     7645        unsigned char bits;
     7646
     7647        present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
     7648                & AC_PINSENSE_PRESENCE;
     7649        bits = present ? HDA_AMP_MUTE : 0;
     7650        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     7651                                 HDA_AMP_MUTE, bits);
     7652}
     7653
     7654static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
     7655                                                  unsigned int res)
     7656{
     7657        if ((res >> 26) == ALC880_HP_EVENT)
     7658                alc883_2ch_fujitsu_pi2515_automute(codec);
    73527659}
    73537660
     
    75857892        [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
    75867893        [ALC883_HAIER_W66]      = "haier-w66",
    7587         [ALC888_6ST_HP]         = "6stack-hp",
    75887894        [ALC888_3ST_HP]         = "3stack-hp",
    75897895        [ALC888_6ST_DELL]       = "6stack-dell",
    75907896        [ALC883_MITAC]          = "mitac",
     7897        [ALC883_CLEVO_M720]     = "clevo-m720",
     7898        [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
     7899        [ALC883_3ST_6ch_INTEL]  = "3stack-6ch-intel",
    75917900        [ALC883_AUTO]           = "auto",
    75927901};
     
    76027911        SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
    76037912        SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
    7604         SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
     7913        SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
    76057914        SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
     7915        SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
    76067916        SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
    76077917        SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
     
    76127922        SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
    76137923        SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
     7924        SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
    76147925        SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
     7926        SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
    76157927        SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
    76167928        SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
     
    76257937        SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
    76267938        SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
     7939        SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
    76277940        SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
    76287941        SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
    76297942        SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
    76307943        SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
     7944        SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
     7945        SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
    76317946        SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
    76327947        SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
    76337948        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
     7949        SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
    76347950        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
    76357951        SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
     
    76397955        SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
    76407956        SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
     7957        SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
     7958        SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
    76417959        SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
    76427960        {0}
     
    76507968                .dac_nids = alc883_dac_nids,
    76517969                .dig_out_nid = ALC883_DIGOUT_NID,
    7652                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7653                 .adc_nids = alc883_adc_nids,
    76547970                .dig_in_nid = ALC883_DIGIN_NID,
    76557971                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     
    76637979                .dac_nids = alc883_dac_nids,
    76647980                .dig_out_nid = ALC883_DIGOUT_NID,
    7665                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7666                 .adc_nids = alc883_adc_nids,
    76677981                .dig_in_nid = ALC883_DIGIN_NID,
    76687982                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
     
    76767990                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    76777991                .dac_nids = alc883_dac_nids,
    7678                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7679                 .adc_nids = alc883_adc_nids,
    76807992                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
    76817993                .channel_mode = alc883_3ST_6ch_modes,
    76827994                .need_dac_fix = 1,
    76837995                .input_mux = &alc883_capture_source,
     7996        },
     7997        [ALC883_3ST_6ch_INTEL] = {
     7998                .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
     7999                .init_verbs = { alc883_init_verbs },
     8000                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     8001                .dac_nids = alc883_dac_nids,
     8002                .dig_out_nid = ALC883_DIGOUT_NID,
     8003                .dig_in_nid = ALC883_DIGIN_NID,
     8004                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
     8005                .channel_mode = alc883_3ST_6ch_intel_modes,
     8006                .need_dac_fix = 1,
     8007                .input_mux = &alc883_3stack_6ch_intel,
    76848008        },
    76858009        [ALC883_6ST_DIG] = {
     
    76898013                .dac_nids = alc883_dac_nids,
    76908014                .dig_out_nid = ALC883_DIGOUT_NID,
    7691                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7692                 .adc_nids = alc883_adc_nids,
    76938015                .dig_in_nid = ALC883_DIGIN_NID,
    76948016                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
     
    77028024                .dac_nids = alc883_dac_nids,
    77038025                .dig_out_nid = ALC883_DIGOUT_NID,
    7704                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7705                 .adc_nids = alc883_adc_nids,
    77068026                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
    77078027                .channel_mode = alc883_3ST_6ch_modes,
     
    77178037                .dac_nids = alc883_dac_nids,
    77188038                .dig_out_nid = ALC883_DIGOUT_NID,
    7719                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7720                 .adc_nids = alc883_adc_nids,
    77218039                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    77228040                .channel_mode = alc883_3ST_2ch_modes,
     
    77358053                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    77368054                .dac_nids = alc883_dac_nids,
    7737                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7738                 .adc_nids = alc883_adc_nids,
    77398055                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    77408056                .channel_mode = alc883_3ST_2ch_modes,
     
    77478063                .dac_nids = alc883_dac_nids,
    77488064                .dig_out_nid = ALC883_DIGOUT_NID,
    7749                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7750                 .adc_nids = alc883_adc_nids,
    77518065                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    77528066                .channel_mode = alc883_3ST_2ch_modes,
     
    77628076                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    77638077                .dac_nids = alc883_dac_nids,
    7764                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7765                 .adc_nids = alc883_adc_nids,
    77668078                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
    77678079                .channel_mode = alc883_sixstack_modes,
     
    77748086                .dac_nids = alc883_dac_nids,
    77758087                .dig_out_nid = ALC883_DIGOUT_NID,
    7776                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7777                 .adc_nids = alc883_adc_nids,
    77788088                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    77798089                .channel_mode = alc883_3ST_2ch_modes,
     
    77878097                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    77888098                .dac_nids = alc883_dac_nids,
    7789                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7790                 .adc_nids = alc883_adc_nids,
    77918099                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    77928100                .channel_mode = alc883_3ST_2ch_modes,
    77938101                .input_mux = &alc883_capture_source,
     8102        },
     8103        [ALC883_CLEVO_M720] = {
     8104                .mixers = { alc883_clevo_m720_mixer },
     8105                .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
     8106                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     8107                .dac_nids = alc883_dac_nids,
     8108                .dig_out_nid = ALC883_DIGOUT_NID,
     8109                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     8110                .channel_mode = alc883_3ST_2ch_modes,
     8111                .input_mux = &alc883_capture_source,
     8112                .unsol_event = alc883_clevo_m720_unsol_event,
     8113                .init_hook = alc883_clevo_m720_automute,
    77948114        },
    77958115        [ALC883_LENOVO_101E_2ch] = {
     
    77988118                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    77998119                .dac_nids = alc883_dac_nids,
    7800                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7801                 .adc_nids = alc883_adc_nids,
    78028120                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    78038121                .channel_mode = alc883_3ST_2ch_modes,
     
    78118129                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    78128130                .dac_nids = alc883_dac_nids,
    7813                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7814                 .adc_nids = alc883_adc_nids,
    78158131                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    78168132                .channel_mode = alc883_3ST_2ch_modes,
     
    78268142                .dac_nids = alc883_dac_nids,
    78278143                .dig_out_nid = ALC883_DIGOUT_NID,
    7828                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7829                 .adc_nids = alc883_adc_nids,
    78308144                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
    78318145                .channel_mode = alc883_3ST_6ch_modes,
     
    78418155                .dac_nids = alc883_dac_nids,
    78428156                .dig_out_nid = ALC883_DIGOUT_NID,
    7843                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7844                 .adc_nids = alc883_adc_nids,
    78458157                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    78468158                .channel_mode = alc883_3ST_2ch_modes,
     
    78488160                .unsol_event = alc883_haier_w66_unsol_event,
    78498161                .init_hook = alc883_haier_w66_automute,
    7850         },     
    7851         [ALC888_6ST_HP] = {
    7852                 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
    7853                 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
    7854                 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    7855                 .dac_nids = alc883_dac_nids,
    7856                 .dig_out_nid = ALC883_DIGOUT_NID,
    7857                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7858                 .adc_nids = alc883_adc_nids,
    7859                 .dig_in_nid = ALC883_DIGIN_NID,
    7860                 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
    7861                 .channel_mode = alc883_sixstack_modes,
    7862                 .input_mux = &alc883_capture_source,
    78638162        },
    78648163        [ALC888_3ST_HP] = {
    7865                 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
     8164                .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
    78668165                .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
    78678166                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    78688167                .dac_nids = alc883_dac_nids,
    7869                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7870                 .adc_nids = alc883_adc_nids,
    78718168                .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
    78728169                .channel_mode = alc888_3st_hp_modes,
     
    78758172        },
    78768173        [ALC888_6ST_DELL] = {
    7877                 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
     8174                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
    78788175                .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
    78798176                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    78808177                .dac_nids = alc883_dac_nids,
    78818178                .dig_out_nid = ALC883_DIGOUT_NID,
    7882                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7883                 .adc_nids = alc883_adc_nids,
    78848179                .dig_in_nid = ALC883_DIGIN_NID,
    78858180                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
     
    78948189                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
    78958190                .dac_nids = alc883_dac_nids,
    7896                 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
    7897                 .adc_nids = alc883_adc_nids,
    78988191                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
    78998192                .channel_mode = alc883_3ST_2ch_modes,
     
    79018194                .unsol_event = alc883_mitac_unsol_event,
    79028195                .init_hook = alc883_mitac_automute,
     8196        },
     8197        [ALC883_FUJITSU_PI2515] = {
     8198                .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
     8199                .init_verbs = { alc883_init_verbs,
     8200                                alc883_2ch_fujitsu_pi2515_verbs},
     8201                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     8202                .dac_nids = alc883_dac_nids,
     8203                .dig_out_nid = ALC883_DIGOUT_NID,
     8204                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
     8205                .channel_mode = alc883_3ST_2ch_modes,
     8206                .input_mux = &alc883_fujitsu_pi2515_capture_source,
     8207                .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
     8208                .init_hook = alc883_2ch_fujitsu_pi2515_automute,
    79038209        },
    79048210};
     
    79168222        int idx;
    79178223
     8224        alc_set_pin_output(codec, nid, pin_type);
    79188225        if (spec->multiout.dac_nids[dac_idx] == 0x25)
    79198226                idx = 4;
    79208227        else
    79218228                idx = spec->multiout.dac_nids[dac_idx] - 2;
    7922 
    7923         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    7924                             pin_type);
    7925         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    7926                             AMP_OUT_UNMUTE);
    79278229        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
    79288230
     
    79538255                /* use dac 0 */
    79548256                alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     8257        pin = spec->autocfg.speaker_pins[0];
     8258        if (pin)
     8259                alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    79558260}
    79568261
     
    80048309static void alc883_auto_init(struct hda_codec *codec)
    80058310{
     8311        struct alc_spec *spec = codec->spec;
    80068312        alc883_auto_init_multi_out(codec);
    80078313        alc883_auto_init_hp_out(codec);
    80088314        alc883_auto_init_analog_input(codec);
     8315        if (spec->unsol_event)
     8316                alc_sku_automute(codec);
    80098317}
    80108318
     
    80198327
    80208328        codec->spec = spec;
     8329
     8330        alc_fix_pll_init(codec, 0x20, 0x0a, 10);
    80218331
    80228332        board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
     
    80468356                setup_preset(spec, &alc883_presets[board_config]);
    80478357
    8048         spec->stream_name_analog = "ALC883 Analog";
     8358        switch (codec->vendor_id) {
     8359        case 0x10ec0888:
     8360                spec->stream_name_analog = "ALC888 Analog";
     8361                spec->stream_name_digital = "ALC888 Digital";
     8362                break;
     8363        case 0x10ec0889:
     8364                spec->stream_name_analog = "ALC889 Analog";
     8365                spec->stream_name_digital = "ALC889 Digital";
     8366                break;
     8367        default:
     8368                spec->stream_name_analog = "ALC883 Analog";
     8369                spec->stream_name_digital = "ALC883 Digital";
     8370                break;
     8371        }
     8372
    80498373        spec->stream_analog_playback = &alc883_pcm_analog_playback;
    80508374        spec->stream_analog_capture = &alc883_pcm_analog_capture;
    80518375        spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
    80528376
    8053         spec->stream_name_digital = "ALC883 Digital";
    80548377        spec->stream_digital_playback = &alc883_pcm_digital_playback;
    80558378        spec->stream_digital_capture = &alc883_pcm_digital_capture;
    80568379
    8057         if (!spec->adc_nids && spec->input_mux) {
    8058                 spec->adc_nids = alc883_adc_nids;
    8059                 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
    8060         }
     8380        spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
     8381        spec->adc_nids = alc883_adc_nids;
     8382        spec->capsrc_nids = alc883_capsrc_nids;
    80618383
    80628384        spec->vmaster_nid = 0x0c;
     
    80658387        if (board_config == ALC883_AUTO)
    80668388                spec->init_hook = alc883_auto_init;
     8389        else if (codec->vendor_id == 0x10ec0888)
     8390                spec->init_hook = alc888_coef_init;
     8391
    80678392#ifdef CONFIG_SND_HDA_POWER_SAVE
    80688393        if (!spec->loopback.amplist)
     
    80838408#define alc262_adc_nids         alc882_adc_nids
    80848409#define alc262_adc_nids_alt     alc882_adc_nids_alt
     8410#define alc262_capsrc_nids      alc882_capsrc_nids
     8411#define alc262_capsrc_nids_alt  alc882_capsrc_nids_alt
    80858412
    80868413#define alc262_modes            alc260_modes
     
    81018428        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    81028429        /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    8103            HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
     8430           HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
    81048431        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
    81058432        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     
    81238450        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    81248451        /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    8125            HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
     8452           HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
    81268453        /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
    81278454        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     
    85168843        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
    85178844        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     8845        {0}
    85188846};
    85198847
     
    85838911/*
    85848912 * fujitsu model
    8585  *  0x14 = headphone/spdif-out, 0x15 = internal speaker
     8913 *  0x14 = headphone/spdif-out, 0x15 = internal speaker,
     8914 *  0x1b = port replicator headphone out
    85868915 */
    85878916
     
    85918920        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
    85928921        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     8922        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
     8923        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     8924        {0}
     8925};
     8926
     8927static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
     8928        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
     8929        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    85938930        {0}
    85948931};
     
    86248961};
    86258962
    8626 /* mute/unmute internal speaker according to the hp jack and mute state */
     8963/* mute/unmute internal speaker according to the hp jacks and mute state */
    86278964static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
    86288965{
     
    86348971                /* need to execute and sync at first */
    86358972                snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
     8973                /* check laptop HP jack */
    86368974                present = snd_hda_codec_read(codec, 0x14, 0,
    8637                                          AC_VERB_GET_PIN_SENSE, 0);
    8638                 spec->jack_present = (present & 0x80000000) != 0;
     8975                                             AC_VERB_GET_PIN_SENSE, 0);
     8976                /* need to execute and sync at first */
     8977                snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
     8978                /* check docking HP jack */
     8979                present |= snd_hda_codec_read(codec, 0x1b, 0,
     8980                                              AC_VERB_GET_PIN_SENSE, 0);
     8981                if (present & AC_PINSENSE_PRESENCE)
     8982                        spec->jack_present = 1;
     8983                else
     8984                        spec->jack_present = 0;
    86398985                spec->sense_updated = 1;
    86408986        }
    8641         if (spec->jack_present) {
    8642                 /* mute internal speaker */
    8643                 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
    8644                                          HDA_AMP_MUTE, HDA_AMP_MUTE);
    8645         } else {
    8646                 /* unmute internal speaker if necessary */
     8987        /* unmute internal speaker only if both HPs are unplugged and
     8988         * master switch is on
     8989         */
     8990        if (spec->jack_present)
     8991                mute = HDA_AMP_MUTE;
     8992        else
    86478993                mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
    8648                 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
    8649                                          HDA_AMP_MUTE, mute);
    8650         }
     8994        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     8995                                 HDA_AMP_MUTE, mute);
    86518996}
    86528997
     
    86579002        if ((res >> 26) != ALC_HP_EVENT)
    86589003                return;
     9004        alc262_fujitsu_automute(codec, 1);
     9005}
     9006
     9007static void alc262_fujitsu_init_hook(struct hda_codec *codec)
     9008{
    86599009        alc262_fujitsu_automute(codec, 1);
    86609010}
     
    86709020};
    86719021
     9022/* mute/unmute internal speaker according to the hp jack and mute state */
     9023static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
     9024{
     9025        struct alc_spec *spec = codec->spec;
     9026        unsigned int mute;
     9027
     9028        if (force || !spec->sense_updated) {
     9029                unsigned int present_int_hp;
     9030                /* need to execute and sync at first */
     9031                snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
     9032                present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
     9033                                        AC_VERB_GET_PIN_SENSE, 0);
     9034                spec->jack_present = (present_int_hp & 0x80000000) != 0;
     9035                spec->sense_updated = 1;
     9036        }
     9037        if (spec->jack_present) {
     9038                /* mute internal speaker */
     9039                snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     9040                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
     9041                snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
     9042                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
     9043        } else {
     9044                /* unmute internal speaker if necessary */
     9045                mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
     9046                snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     9047                                         HDA_AMP_MUTE, mute);
     9048                snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
     9049                                         HDA_AMP_MUTE, mute);
     9050        }
     9051}
     9052
     9053/* unsolicited event for HP jack sensing */
     9054static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
     9055                                       unsigned int res)
     9056{
     9057        if ((res >> 26) != ALC_HP_EVENT)
     9058                return;
     9059        alc262_lenovo_3000_automute(codec, 1);
     9060}
     9061
    86729062/* bind hp and internal speaker mute (with plug check) */
    86739063static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
     
    86789068        int change;
    86799069
    8680         change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
    8681                                           HDA_AMP_MUTE,
    8682                                           valp[0] ? 0 : HDA_AMP_MUTE);
    8683         change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
    8684                                            HDA_AMP_MUTE,
    8685                                            valp[1] ? 0 : HDA_AMP_MUTE);
     9070        change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     9071                                                 HDA_AMP_MUTE,
     9072                                                 valp ? 0 : HDA_AMP_MUTE);
     9073        change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
     9074                                                 HDA_AMP_MUTE,
     9075                                                 valp ? 0 : HDA_AMP_MUTE);
     9076
    86869077        if (change)
    86879078                alc262_fujitsu_automute(codec, 0);
     
    87019092        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    87029093        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     9094        HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
     9095        HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
    87039096        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    87049097        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     
    87109103};
    87119104
     9105/* bind hp and internal speaker mute (with plug check) */
     9106static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
     9107                                         struct snd_ctl_elem_value *ucontrol)
     9108{
     9109        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     9110        long *valp = ucontrol->value.integer.value;
     9111        int change;
     9112
     9113        change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
     9114                                                 HDA_AMP_MUTE,
     9115                                                 valp ? 0 : HDA_AMP_MUTE);
     9116
     9117        if (change)
     9118                alc262_lenovo_3000_automute(codec, 0);
     9119        return change;
     9120}
     9121
     9122static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
     9123        HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
     9124        {
     9125                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     9126                .name = "Master Playback Switch",
     9127                .info = snd_hda_mixer_amp_switch_info,
     9128                .get = snd_hda_mixer_amp_switch_get,
     9129                .put = alc262_lenovo_3000_master_sw_put,
     9130                .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
     9131        },
     9132        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     9133        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     9134        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
     9135        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     9136        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     9137        HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
     9138        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     9139        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     9140        {0} /* end */
     9141};
     9142
    87129143/* additional init verbs for Benq laptops */
    87139144static struct hda_verb alc262_EAPD_verbs[] = {
     
    87289159/* Samsung Q1 Ultra Vista model setup */
    87299160static struct snd_kcontrol_new alc262_ultra_mixer[] = {
    8730         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
    8731         HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
    8732         HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     9161        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     9162        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
    87339163        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
    87349164        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    87359165        HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
     9166        HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
    87369167        {0} /* end */
    87379168};
    87389169
    87399170static struct hda_verb alc262_ultra_verbs[] = {
     9171        /* output mixer */
     9172        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     9173        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     9174        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     9175        /* speaker */
     9176        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     9177        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     9178        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     9179        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     9180        /* HP */
     9181        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     9182        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     9183        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     9184        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
    87409185        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
    8741         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    8742         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
    8743         /* Mic is on Node 0x19 */
    8744         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
    8745         {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
    8746         {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    8747         {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
    8748         {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
    8749         {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
    8750         {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
     9186        /* internal mic */
     9187        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     9188        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     9189        /* ADC, choose mic */
     9190        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     9191        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     9192        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     9193        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     9194        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     9195        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     9196        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
     9197        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
     9198        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
     9199        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
    87519200        {0}
    8752 };
    8753 
    8754 static struct hda_input_mux alc262_ultra_capture_source = {
    8755         .num_items = 1,
    8756         .items = {
    8757                 { "Mic", 0x1 },
    8758         },
    87599201};
    87609202
     
    87649206        struct alc_spec *spec = codec->spec;
    87659207        unsigned int mute;
    8766         unsigned int present;
    8767 
    8768         /* need to execute and sync at first */
    8769         snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
    8770         present = snd_hda_codec_read(codec, 0x15, 0,
    8771                                      AC_VERB_GET_PIN_SENSE, 0);
    8772         spec->jack_present = (present & 0x80000000) != 0;
    8773         if (spec->jack_present) {
    8774                 /* mute internal speaker */
    8775                 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
    8776                                          HDA_AMP_MUTE, HDA_AMP_MUTE);
    8777         } else {
    8778                 /* unmute internal speaker if necessary */
    8779                 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
    8780                 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
    8781                                          HDA_AMP_MUTE, mute);
     9208
     9209        mute = 0;
     9210        /* auto-mute only when HP is used as HP */
     9211        if (!spec->cur_mux[0]) {
     9212                unsigned int present;
     9213                /* need to execute and sync at first */
     9214                snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
     9215                present = snd_hda_codec_read(codec, 0x15, 0,
     9216                                             AC_VERB_GET_PIN_SENSE, 0);
     9217                spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
     9218                if (spec->jack_present)
     9219                        mute = HDA_AMP_MUTE;
    87829220        }
     9221        /* mute/unmute internal speaker */
     9222        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     9223                                 HDA_AMP_MUTE, mute);
     9224        /* mute/unmute HP */
     9225        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     9226                                 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
    87839227}
    87849228
     
    87919235        alc262_ultra_automute(codec);
    87929236}
     9237
     9238static struct hda_input_mux alc262_ultra_capture_source = {
     9239        .num_items = 2,
     9240        .items = {
     9241                { "Mic", 0x1 },
     9242                { "Headphone", 0x7 },
     9243        },
     9244};
     9245
     9246static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
     9247                                     struct snd_ctl_elem_value *ucontrol)
     9248{
     9249        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     9250        struct alc_spec *spec = codec->spec;
     9251        int ret;
     9252
     9253        ret = alc882_mux_enum_put(kcontrol, ucontrol);
     9254        if (!ret)
     9255                return 0;
     9256        /* reprogram the HP pin as mic or HP according to the input source */
     9257        snd_hda_codec_write_cache(codec, 0x15, 0,
     9258                                  AC_VERB_SET_PIN_WIDGET_CONTROL,
     9259                                  spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
     9260        alc262_ultra_automute(codec); /* mute/unmute HP */
     9261        return ret;
     9262}
     9263
     9264static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
     9265        HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
     9266        HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
     9267        {
     9268                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     9269                .name = "Capture Source",
     9270                .info = alc882_mux_enum_info,
     9271                .get = alc882_mux_enum_get,
     9272                .put = alc262_ultra_mux_enum_put,
     9273        },
     9274        {0} /* end */
     9275};
    87939276
    87949277/* add playback controls from the parsed DAC table */
     
    91839666static void alc262_auto_init(struct hda_codec *codec)
    91849667{
     9668        struct alc_spec *spec = codec->spec;
    91859669        alc262_auto_init_multi_out(codec);
    91869670        alc262_auto_init_hp_out(codec);
    91879671        alc262_auto_init_analog_input(codec);
     9672        if (spec->unsol_event)
     9673                alc_sku_automute(codec);
    91889674}
    91899675
     
    92049690        [ALC262_SONY_ASSAMD]    = "sony-assamd",
    92059691        [ALC262_ULTRA]          = "ultra",
     9692        [ALC262_LENOVO_3000]    = "lenovo-3000",
    92069693        [ALC262_AUTO]           = "auto",
    92079694};
     
    92369723        SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
    92379724        SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
     9725        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
     9726                      ALC262_SONY_ASSAMD),
    92389727        SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
     9728        SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
    92399729        SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
     9730        SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
     9731        SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
    92409732        SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
    92419733        SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
     
    92939785                .input_mux = &alc262_fujitsu_capture_source,
    92949786                .unsol_event = alc262_fujitsu_unsol_event,
     9787                .init_hook = alc262_fujitsu_init_hook,
    92959788        },
    92969789        [ALC262_HP_BPC] = {
     
    93879880        },     
    93889881        [ALC262_ULTRA] = {
    9389                 .mixers = { alc262_ultra_mixer },
    9390                 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
     9882                .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
     9883                .init_verbs = { alc262_ultra_verbs },
     9884                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     9885                .dac_nids = alc262_dac_nids,
     9886                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     9887                .channel_mode = alc262_modes,
     9888                .input_mux = &alc262_ultra_capture_source,
     9889                .adc_nids = alc262_adc_nids, /* ADC0 */
     9890                .capsrc_nids = alc262_capsrc_nids,
     9891                .num_adc_nids = 1, /* single ADC */
     9892                .unsol_event = alc262_ultra_unsol_event,
     9893                .init_hook = alc262_ultra_automute,
     9894        },
     9895        [ALC262_LENOVO_3000] = {
     9896                .mixers = { alc262_lenovo_3000_mixer },
     9897                .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
     9898                                alc262_lenovo_3000_unsol_verbs },
    93919899                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
    93929900                .dac_nids = alc262_dac_nids,
     
    93959903                .num_channel_mode = ARRAY_SIZE(alc262_modes),
    93969904                .channel_mode = alc262_modes,
    9397                 .input_mux = &alc262_ultra_capture_source,
    9398                 .unsol_event = alc262_ultra_unsol_event,
    9399                 .init_hook = alc262_ultra_automute,
     9905                .input_mux = &alc262_fujitsu_capture_source,
     9906                .unsol_event = alc262_lenovo_3000_unsol_event,
    94009907        },
    94019908};
     
    94259932#endif
    94269933
     9934        alc_fix_pll_init(codec, 0x20, 0x0a, 10);
     9935
    94279936        board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
    94289937                                                  alc262_models,
     
    94699978                        spec->adc_nids = alc262_adc_nids_alt;
    94709979                        spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
     9980                        spec->capsrc_nids = alc262_capsrc_nids_alt;
    94719981                        spec->mixers[spec->num_mixers] =
    94729982                                alc262_capture_alt_mixer;
     
    94759985                        spec->adc_nids = alc262_adc_nids;
    94769986                        spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
     9987                        spec->capsrc_nids = alc262_capsrc_nids;
    94779988                        spec->mixers[spec->num_mixers] = alc262_capture_mixer;
    94789989                        spec->num_mixers++;
     
    951410025};
    951510026
     10027static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
     10028
    951610029static struct snd_kcontrol_new alc268_base_mixer[] = {
    951710030        /* output mixer control */
     
    952310036        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    952410037        HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
     10038        {0}
     10039};
     10040
     10041/* bind Beep switches of both NID 0x0f and 0x10 */
     10042static struct hda_bind_ctls alc268_bind_beep_sw = {
     10043        .ops = &snd_hda_bind_sw,
     10044        .values = {
     10045                HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
     10046                HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
     10047                0
     10048        },
     10049};
     10050
     10051static struct snd_kcontrol_new alc268_beep_mixer[] = {
     10052        HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
     10053        HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
    952510054        {0}
    952610055};
     
    961010139
    961110140static struct hda_verb alc268_acer_verbs[] = {
     10141        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
     10142        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    961210143        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
    961310144        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     10145        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     10146        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    961410147
    961510148        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     
    968110214
    968210215#define alc268_dell_init_hook   alc268_dell_automute
     10216
     10217static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
     10218        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
     10219        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     10220        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
     10221        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     10222        HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
     10223        HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
     10224        HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
     10225        HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
     10226        {0}
     10227};
     10228
     10229static struct hda_verb alc267_quanta_il1_verbs[] = {
     10230        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     10231        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
     10232        {0}
     10233};
     10234
     10235static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
     10236{
     10237        unsigned int present;
     10238
     10239        present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
     10240                & AC_PINSENSE_PRESENCE;
     10241        snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     10242                            present ? 0 : PIN_OUT);
     10243}
     10244
     10245static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
     10246{
     10247        unsigned int present;
     10248
     10249        present = snd_hda_codec_read(codec, 0x18, 0,
     10250                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     10251        snd_hda_codec_write(codec, 0x23, 0,
     10252                            AC_VERB_SET_CONNECT_SEL,
     10253                            present ? 0x00 : 0x01);
     10254}
     10255
     10256static void alc267_quanta_il1_automute(struct hda_codec *codec)
     10257{
     10258        alc267_quanta_il1_hp_automute(codec);
     10259        alc267_quanta_il1_mic_automute(codec);
     10260}
     10261
     10262static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
     10263                                           unsigned int res)
     10264{
     10265        switch (res >> 26) {
     10266        case ALC880_HP_EVENT:
     10267                alc267_quanta_il1_hp_automute(codec);
     10268                break;
     10269        case ALC880_MIC_EVENT:
     10270                alc267_quanta_il1_mic_automute(codec);
     10271                break;
     10272        }
     10273}
    968310274
    968410275/*
     
    972210313        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    972310314        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    9724         {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
     10315
     10316        /* set PCBEEP vol = 0, mute connections */
     10317        {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     10318        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     10319        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    972510320
    972610321        /* Unmute Selector 23h,24h and set the default input to mic-in */
     
    976110356        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    976210357
    9763         /* set PCBEEP vol = 0 */
    9764         {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
     10358        /* set PCBEEP vol = 0, mute connections */
     10359        {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     10360        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     10361        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
    976510362
    976610363        {0}
     
    976910366#define alc268_mux_enum_info alc_mux_enum_info
    977010367#define alc268_mux_enum_get alc_mux_enum_get
    9771 
    9772 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
    9773                                struct snd_ctl_elem_value *ucontrol)
    9774 {
    9775         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    9776         struct alc_spec *spec = codec->spec;
    9777 
    9778         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    9779         static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
    9780         hda_nid_t nid = capture_mixers[adc_idx];
    9781 
    9782         return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
    9783                                      nid,
    9784                                      &spec->cur_mux[adc_idx]);
    9785 }
     10368#define alc268_mux_enum_put alc_mux_enum_put
    978610369
    978710370static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
     
    983310416};
    983410417
     10418static struct hda_input_mux alc268_acer_capture_source = {
     10419        .num_items = 3,
     10420        .items = {
     10421                { "Mic", 0x0 },
     10422                { "Internal Mic", 0x6 },
     10423                { "Line", 0x2 },
     10424        },
     10425};
     10426
    983510427#ifdef CONFIG_SND_DEBUG
    983610428static struct snd_kcontrol_new alc268_test_mixer[] = {
    9837         HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
    9838         HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
    9839         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
    9840         HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
    9841 
    984210429        /* Volume widgets */
    984310430        HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     
    997810565                        idx1 = 3;       /* CD */
    997910566                        break;
     10567                case 0x12:
     10568                case 0x13:
     10569                        idx1 = 6;       /* digital mics */
     10570                        break;
    998010571                default:
    998110572                        continue;
     
    1007010661                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
    1007110662
     10663        if (spec->autocfg.speaker_pins[0] != 0x1d)
     10664                spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
     10665
    1007210666        spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
    1007310667        spec->num_mux_defs = 1;
     
    1008810682static void alc268_auto_init(struct hda_codec *codec)
    1008910683{
     10684        struct alc_spec *spec = codec->spec;
    1009010685        alc268_auto_init_multi_out(codec);
    1009110686        alc268_auto_init_hp_out(codec);
    1009210687        alc268_auto_init_mono_speaker_out(codec);
    1009310688        alc268_auto_init_analog_input(codec);
     10689        if (spec->unsol_event)
     10690                alc_sku_automute(codec);
    1009410691}
    1009510692
     
    1009810695 */
    1009910696static const char *alc268_models[ALC268_MODEL_LAST] = {
     10697        [ALC267_QUANTA_IL1]     = "quanta-il1",
    1010010698        [ALC268_3ST]            = "3stack",
    1010110699        [ALC268_TOSHIBA]        = "toshiba",
     
    1011010708
    1011110709static struct snd_pci_quirk alc268_cfg_tbl[] = {
     10710        SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
    1011210711        SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
    1011310712        SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
     
    1011910718        SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
    1012010719        SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
     10720        SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
    1012110721        SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
     10722        SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
    1012210723        SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
    1012310724        {0}
     
    1012510726
    1012610727static struct alc_config_preset alc268_presets[] = {
    10127         [ALC268_3ST] = {
    10128                 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
    10129                 .init_verbs = { alc268_base_init_verbs },
    10130                 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
    10131                 .dac_nids = alc268_dac_nids,
    10132                 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
    10133                 .adc_nids = alc268_adc_nids_alt,
    10134                 .hp_nid = 0x03,
    10135                 .dig_out_nid = ALC268_DIGOUT_NID,
    10136                 .num_channel_mode = ARRAY_SIZE(alc268_modes),
    10137                 .channel_mode = alc268_modes,
    10138                 .input_mux = &alc268_capture_source,
    10139         },
    10140         [ALC268_TOSHIBA] = {
    10141                 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
     10728        [ALC267_QUANTA_IL1] = {
     10729                .mixers = { alc267_quanta_il1_mixer },
    1014210730                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
    10143                                 alc268_toshiba_verbs },
     10731                                alc267_quanta_il1_verbs },
    1014410732                .num_dacs = ARRAY_SIZE(alc268_dac_nids),
    1014510733                .dac_nids = alc268_dac_nids,
     
    1015010738                .channel_mode = alc268_modes,
    1015110739                .input_mux = &alc268_capture_source,
     10740                .unsol_event = alc267_quanta_il1_unsol_event,
     10741                .init_hook = alc267_quanta_il1_automute,
     10742        },
     10743        [ALC268_3ST] = {
     10744                .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
     10745                            alc268_beep_mixer },
     10746                .init_verbs = { alc268_base_init_verbs },
     10747                .num_dacs = ARRAY_SIZE(alc268_dac_nids),
     10748                .dac_nids = alc268_dac_nids,
     10749                .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
     10750                .adc_nids = alc268_adc_nids_alt,
     10751                .capsrc_nids = alc268_capsrc_nids,
     10752                .hp_nid = 0x03,
     10753                .dig_out_nid = ALC268_DIGOUT_NID,
     10754                .num_channel_mode = ARRAY_SIZE(alc268_modes),
     10755                .channel_mode = alc268_modes,
     10756                .input_mux = &alc268_capture_source,
     10757        },
     10758        [ALC268_TOSHIBA] = {
     10759                .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
     10760                            alc268_beep_mixer },
     10761                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
     10762                                alc268_toshiba_verbs },
     10763                .num_dacs = ARRAY_SIZE(alc268_dac_nids),
     10764                .dac_nids = alc268_dac_nids,
     10765                .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
     10766                .adc_nids = alc268_adc_nids_alt,
     10767                .capsrc_nids = alc268_capsrc_nids,
     10768                .hp_nid = 0x03,
     10769                .num_channel_mode = ARRAY_SIZE(alc268_modes),
     10770                .channel_mode = alc268_modes,
     10771                .input_mux = &alc268_capture_source,
    1015210772                .unsol_event = alc268_toshiba_unsol_event,
    1015310773                .init_hook = alc268_toshiba_automute,
    1015410774        },
    1015510775        [ALC268_ACER] = {
    10156                 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
     10776                .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
     10777                            alc268_beep_mixer },
    1015710778                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
    1015810779                                alc268_acer_verbs },
     
    1016110782                .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
    1016210783                .adc_nids = alc268_adc_nids_alt,
     10784                .capsrc_nids = alc268_capsrc_nids,
    1016310785                .hp_nid = 0x02,
    1016410786                .num_channel_mode = ARRAY_SIZE(alc268_modes),
    1016510787                .channel_mode = alc268_modes,
    10166                 .input_mux = &alc268_capture_source,
     10788                .input_mux = &alc268_acer_capture_source,
    1016710789                .unsol_event = alc268_acer_unsol_event,
    1016810790                .init_hook = alc268_acer_init_hook,
    1016910791        },
    1017010792        [ALC268_DELL] = {
    10171                 .mixers = { alc268_dell_mixer },
     10793                .mixers = { alc268_dell_mixer, alc268_beep_mixer },
    1017210794                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
    1017310795                                alc268_dell_verbs },
     
    1018210804        },
    1018310805        [ALC268_ZEPTO] = {
    10184                 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
     10806                .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
     10807                            alc268_beep_mixer },
    1018510808                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
    1018610809                                alc268_toshiba_verbs },
     
    1018910812                .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
    1019010813                .adc_nids = alc268_adc_nids_alt,
     10814                .capsrc_nids = alc268_capsrc_nids,
    1019110815                .hp_nid = 0x03,
    1019210816                .dig_out_nid = ALC268_DIGOUT_NID,
     
    1020610830                .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
    1020710831                .adc_nids = alc268_adc_nids_alt,
     10832                .capsrc_nids = alc268_capsrc_nids,
    1020810833                .hp_nid = 0x03,
    1020910834                .dig_out_nid = ALC268_DIGOUT_NID,
     
    1025410879                setup_preset(spec, &alc268_presets[board_config]);
    1025510880
    10256         spec->stream_name_analog = "ALC268 Analog";
     10881        if (codec->vendor_id == 0x10ec0267) {
     10882                spec->stream_name_analog = "ALC267 Analog";
     10883                spec->stream_name_digital = "ALC267 Digital";
     10884        } else {
     10885                spec->stream_name_analog = "ALC268 Analog";
     10886                spec->stream_name_digital = "ALC268 Digital";
     10887        }
     10888
    1025710889        spec->stream_analog_playback = &alc268_pcm_analog_playback;
    1025810890        spec->stream_analog_capture = &alc268_pcm_analog_capture;
    1025910891        spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
    1026010892
    10261         spec->stream_name_digital = "ALC268 Digital";
    1026210893        spec->stream_digital_playback = &alc268_pcm_digital_playback;
     10894
     10895        if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
     10896                /* override the amp caps for beep generator */
     10897                snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
     10898                                          (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
     10899                                          (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
     10900                                          (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
     10901                                          (0 << AC_AMPCAP_MUTE_SHIFT));
    1026310902
    1026410903        if (!spec->adc_nids && spec->input_mux) {
    1026510904                /* check whether NID 0x07 is valid */
    1026610905                unsigned int wcap = get_wcaps(codec, 0x07);
     10906                int i;
    1026710907
    1026810908                /* get type */
    1026910909                wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
    10270                 if (wcap != AC_WID_AUD_IN) {
     10910                if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
    1027110911                        spec->adc_nids = alc268_adc_nids_alt;
    1027210912                        spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
     
    1028110921                        spec->num_mixers++;
    1028210922                }
     10923                spec->capsrc_nids = alc268_capsrc_nids;
     10924                /* set default input source */
     10925                for (i = 0; i < spec->num_adc_nids; i++)
     10926                        snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
     10927                                0, AC_VERB_SET_CONNECT_SEL,
     10928                                spec->input_mux->items[0].index);
    1028310929        }
    1028410930
     
    1055411200static void alc269_auto_init(struct hda_codec *codec)
    1055511201{
     11202        struct alc_spec *spec = codec->spec;
    1055611203        alc269_auto_init_multi_out(codec);
    1055711204        alc269_auto_init_hp_out(codec);
    1055811205        alc269_auto_init_analog_input(codec);
     11206        if (spec->unsol_event)
     11207                alc_sku_automute(codec);
    1055911208}
    1056011209
     
    1059411243
    1059511244        codec->spec = spec;
     11245
     11246        alc_fix_pll_init(codec, 0x20, 0x04, 15);
    1059611247
    1059711248        board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
     
    1147812129                                              int pin_type, int dac_idx)
    1147912130{
    11480         /* set as output */
    11481 
    1148212131        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
    1148312132                            pin_type);
    1148412133        snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
    1148512134                            AMP_OUT_UNMUTE);
    11486 
    1148712135}
    1148812136
     
    1151112159                alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
    1151212160                                                  spec->multiout.dac_nids[0]);
     12161        pin = spec->autocfg.speaker_pins[0];
     12162        if (pin)
     12163                alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    1151312164}
    1151412165
     
    1158312234static void alc861_auto_init(struct hda_codec *codec)
    1158412235{
     12236        struct alc_spec *spec = codec->spec;
    1158512237        alc861_auto_init_multi_out(codec);
    1158612238        alc861_auto_init_hp_out(codec);
    1158712239        alc861_auto_init_analog_input(codec);
     12240        if (spec->unsol_event)
     12241                alc_sku_automute(codec);
    1158812242}
    1158912243
     
    1183712491};
    1183812492
     12493static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
     12494
    1183912495/* input MUX */
    1184012496/* FIXME: should be a matrix-type input source selection */
     
    1185012506
    1185112507static struct hda_input_mux alc861vd_dallas_capture_source = {
    11852         .num_items = 3,
     12508        .num_items = 2,
    1185312509        .items = {
    11854                 { "Front Mic", 0x0 },
    11855                 { "ATAPI Mic", 0x1 },
    11856                 { "Line In", 0x5 },
     12510                { "Ext Mic", 0x0 },
     12511                { "Int Mic", 0x1 },
    1185712512        },
    1185812513};
     
    1186812523#define alc861vd_mux_enum_info alc_mux_enum_info
    1186912524#define alc861vd_mux_enum_get alc_mux_enum_get
    11870 
    11871 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
    11872                                 struct snd_ctl_elem_value *ucontrol)
    11873 {
    11874         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    11875         struct alc_spec *spec = codec->spec;
    11876         const struct hda_input_mux *imux = spec->input_mux;
    11877         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    11878         static hda_nid_t capture_mixers[1] = { 0x22 };
    11879         hda_nid_t nid = capture_mixers[adc_idx];
    11880         unsigned int *cur_val = &spec->cur_mux[adc_idx];
    11881         unsigned int i, idx;
    11882 
    11883         idx = ucontrol->value.enumerated.item[0];
    11884         if (idx >= imux->num_items)
    11885                 idx = imux->num_items - 1;
    11886         if (*cur_val == idx)
    11887                 return 0;
    11888         for (i = 0; i < imux->num_items; i++) {
    11889                 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
    11890                 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
    11891                                          imux->items[i].index,
    11892                                          HDA_AMP_MUTE, v);
    11893         }
    11894         *cur_val = idx;
    11895         return 1;
    11896 }
     12525/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
     12526#define alc861vd_mux_enum_put alc882_mux_enum_put
    1189712527
    1189812528/*
     
    1204912679};
    1205012680
    12051 /* Pin assignment: Front=0x14, HP = 0x15,
    12052  *                 Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
     12681/* Pin assignment: Speaker=0x14, HP = 0x15,
     12682 *                 Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
    1205312683 */
    1205412684static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
    12055         HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
    12056         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     12685        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     12686        HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
    1205712687        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    1205812688        HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
    12059         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    12060         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    12061         HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    12062         HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    12063         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
    12064         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
     12689        HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
     12690        HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     12691        HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     12692        HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
     12693        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     12694        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     12695        HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
     12696        HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
    1206512697        {0} /* end */
    1206612698};
     
    1220912841static struct hda_verb alc861vd_eapd_verbs[] = {
    1221012842        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
     12843        {0}
     12844};
     12845
     12846static struct hda_verb alc660vd_eapd_verbs[] = {
     12847        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
     12848        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
    1221112849        {0}
    1221212850};
     
    1236313001        SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
    1236413002        SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
     13003        SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
    1236513004        SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
    1236613005        SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
    1236713006        SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
     13007        SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
    1236813008        SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
    1236913009        {0}
     
    1237713017                .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
    1237813018                .dac_nids = alc660vd_dac_nids,
    12379                 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
    12380                 .adc_nids = alc861vd_adc_nids,
    1238113019                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
    1238213020                .channel_mode = alc861vd_3stack_2ch_modes,
     
    1239013028                .dac_nids = alc660vd_dac_nids,
    1239113029                .dig_out_nid = ALC861VD_DIGOUT_NID,
    12392                 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
    12393                 .adc_nids = alc861vd_adc_nids,
    1239413030                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
    1239513031                .channel_mode = alc861vd_3stack_2ch_modes,
     
    1243613072                .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
    1243713073                .dac_nids = alc660vd_dac_nids,
    12438                 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
    12439                 .adc_nids = alc861vd_adc_nids,
    1244013074                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
    1244113075                .channel_mode = alc861vd_3stack_2ch_modes,
     
    1244913083                .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
    1245013084                .dac_nids = alc861vd_dac_nids,
    12451                 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
    12452                 .adc_nids = alc861vd_adc_nids,
    1245313085                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
    1245413086                .channel_mode = alc861vd_3stack_2ch_modes,
     
    1246213094                .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
    1246313095                .dac_nids = alc861vd_dac_nids,
    12464                 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
    1246513096                .dig_out_nid = ALC861VD_DIGOUT_NID,
    12466                 .adc_nids = alc861vd_adc_nids,
    1246713097                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
    1246813098                .channel_mode = alc861vd_3stack_2ch_modes,
     
    1247913109                                hda_nid_t nid, int pin_type, int dac_idx)
    1248013110{
    12481         /* set as output */
    12482         snd_hda_codec_write(codec, nid, 0,
    12483                                 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
    12484         snd_hda_codec_write(codec, nid, 0,
    12485                                 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
     13111        alc_set_pin_output(codec, nid, pin_type);
    1248613112}
    1248713113
     
    1251013136        if (pin) /* connect to front and  use dac 0 */
    1251113137                alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     13138        pin = spec->autocfg.speaker_pins[0];
     13139        if (pin)
     13140                alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    1251213141}
    1251313142
     
    1271313342static void alc861vd_auto_init(struct hda_codec *codec)
    1271413343{
     13344        struct alc_spec *spec = codec->spec;
    1271513345        alc861vd_auto_init_multi_out(codec);
    1271613346        alc861vd_auto_init_hp_out(codec);
    1271713347        alc861vd_auto_init_analog_input(codec);
     13348        if (spec->unsol_event)
     13349                alc_sku_automute(codec);
    1271813350}
    1271913351
     
    1275613388                setup_preset(spec, &alc861vd_presets[board_config]);
    1275713389
    12758         spec->stream_name_analog = "ALC861VD Analog";
     13390        if (codec->vendor_id == 0x10ec0660) {
     13391                spec->stream_name_analog = "ALC660-VD Analog";
     13392                spec->stream_name_digital = "ALC660-VD Digital";
     13393                /* always turn on EAPD */
     13394                spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
     13395        } else {
     13396                spec->stream_name_analog = "ALC861VD Analog";
     13397                spec->stream_name_digital = "ALC861VD Digital";
     13398        }
     13399
    1275913400        spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
    1276013401        spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
    1276113402
    12762         spec->stream_name_digital = "ALC861VD Digital";
    1276313403        spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
    1276413404        spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
     
    1276613406        spec->adc_nids = alc861vd_adc_nids;
    1276713407        spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
     13408        spec->capsrc_nids = alc861vd_capsrc_nids;
    1276813409
    1276913410        spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
     
    1280713448        0x09,
    1280813449};
     13450
     13451static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
     13452
    1280913453/* input MUX */
    1281013454/* FIXME: should be a matrix-type input source selection */
    12811 
    1281213455static struct hda_input_mux alc662_capture_source = {
    1281313456        .num_items = 4,
     
    1283613479};
    1283713480
     13481static struct hda_input_mux alc663_capture_source = {
     13482        .num_items = 3,
     13483        .items = {
     13484                { "Mic", 0x0 },
     13485                { "Front Mic", 0x1 },
     13486                { "Line", 0x2 },
     13487        },
     13488};
     13489
     13490static struct hda_input_mux alc663_m51va_capture_source = {
     13491        .num_items = 2,
     13492        .items = {
     13493                { "Ext-Mic", 0x0 },
     13494                { "D-Mic", 0x9 },
     13495        },
     13496};
     13497
    1283813498#define alc662_mux_enum_info alc_mux_enum_info
    1283913499#define alc662_mux_enum_get alc_mux_enum_get
    12840 
    12841 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
    12842                                struct snd_ctl_elem_value *ucontrol)
    12843 {
    12844         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    12845         struct alc_spec *spec = codec->spec;
    12846         const struct hda_input_mux *imux = spec->input_mux;
    12847         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    12848         static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
    12849         hda_nid_t nid = capture_mixers[adc_idx];
    12850         unsigned int *cur_val = &spec->cur_mux[adc_idx];
    12851         unsigned int i, idx;
    12852 
    12853         idx = ucontrol->value.enumerated.item[0];
    12854         if (idx >= imux->num_items)
    12855                 idx = imux->num_items - 1;
    12856         if (*cur_val == idx)
    12857                 return 0;
    12858         for (i = 0; i < imux->num_items; i++) {
    12859                 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
    12860                 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
    12861                                          imux->items[i].index,
    12862                                          HDA_AMP_MUTE, v);
    12863         }
    12864         *cur_val = idx;
    12865         return 1;
    12866 }
     13500#define alc662_mux_enum_put alc882_mux_enum_put
     13501
    1286713502/*
    1286813503 * 2ch mode
     
    1293313568        /* output mixer control */
    1293413569        HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
    12935         HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
     13570        HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
    1293613571        HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
    12937         HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     13572        HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
    1293813573        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
    1293913574        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
    12940         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
    12941         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
     13575        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
     13576        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
    1294213577        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    1294313578
     
    1295613591static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
    1295713592        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
    12958         HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
     13593        HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
    1295913594        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    1296013595        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     
    1297313608static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
    1297413609        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
    12975         HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
     13610        HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
    1297613611        HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    12977         HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
     13612        HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
    1297813613        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
    1297913614        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
    12980         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
    12981         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
     13615        HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
     13616        HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
    1298213617        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    1298313618        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     
    1301013645        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
    1301113646
    13012         HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
    13013         HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     13647        HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     13648        HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
    1301413649
    1301513650        HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
     
    1302413659
    1302513660static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
    13026         HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
    13027         HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     13661        HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     13662        HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
    1302813663        HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
    1302913664        HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
     
    1303813673        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    1303913674        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     13675        {0} /* end */
     13676};
     13677
     13678static struct snd_kcontrol_new alc663_m51va_mixer[] = {
     13679        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     13680        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     13681        HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     13682        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     13683        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     13684        HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
     13685        {0} /* end */
     13686};
     13687
     13688static struct snd_kcontrol_new alc663_g71v_mixer[] = {
     13689        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     13690        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     13691        HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
     13692        HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     13693        HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     13694
     13695        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     13696        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     13697        HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     13698        HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     13699        {0} /* end */
     13700};
     13701
     13702static struct snd_kcontrol_new alc663_g50v_mixer[] = {
     13703        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
     13704        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
     13705        HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     13706
     13707        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     13708        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     13709        HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
     13710        HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
     13711        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     13712        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
    1304013713        {0} /* end */
    1304113714};
     
    1311113784        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    1311213785        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
     13786
     13787        /* always trun on EAPD */
     13788        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
     13789        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
     13790
    1311313791        {0}
    1311413792};
     
    1317813856        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1317913857        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     13858        {0}
     13859};
     13860
     13861static struct hda_verb alc663_m51va_init_verbs[] = {
     13862        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     13863        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     13864        {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Headphone */
     13865
     13866        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
     13867
     13868        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
     13869        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     13870        {0}
     13871};
     13872
     13873static struct hda_verb alc663_g71v_init_verbs[] = {
     13874        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     13875        /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
     13876        /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
     13877
     13878        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     13879        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     13880        {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Headphone */
     13881
     13882        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
     13883        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
     13884        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
     13885        {0}
     13886};
     13887
     13888static struct hda_verb alc663_g50v_init_verbs[] = {
     13889        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     13890        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     13891        {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Headphone */
     13892
     13893        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
     13894        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
    1318013895        {0}
    1318113896};
     
    1330214017}
    1330314018
     14019static void alc663_m51va_speaker_automute(struct hda_codec *codec)
     14020{
     14021        unsigned int present;
     14022        unsigned char bits;
     14023
     14024        present = snd_hda_codec_read(codec, 0x21, 0,
     14025                                     AC_VERB_GET_PIN_SENSE, 0)
     14026                & AC_PINSENSE_PRESENCE;
     14027        bits = present ? HDA_AMP_MUTE : 0;
     14028        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     14029                                 HDA_AMP_MUTE, bits);
     14030}
     14031
     14032static void alc663_m51va_mic_automute(struct hda_codec *codec)
     14033{
     14034        unsigned int present;
     14035
     14036        present = snd_hda_codec_read(codec, 0x18, 0,
     14037                                     AC_VERB_GET_PIN_SENSE, 0)
     14038                & AC_PINSENSE_PRESENCE;
     14039        snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     14040                            0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
     14041        snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     14042                            0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
     14043        snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     14044                            0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
     14045        snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
     14046                            0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
     14047}
     14048
     14049static void alc663_m51va_unsol_event(struct hda_codec *codec,
     14050                                           unsigned int res)
     14051{
     14052        switch (res >> 26) {
     14053        case ALC880_HP_EVENT:
     14054                alc663_m51va_speaker_automute(codec);
     14055                break;
     14056        case ALC880_MIC_EVENT:
     14057                alc663_m51va_mic_automute(codec);
     14058                break;
     14059        }
     14060}
     14061
     14062static void alc663_m51va_inithook(struct hda_codec *codec)
     14063{
     14064        alc663_m51va_speaker_automute(codec);
     14065        alc663_m51va_mic_automute(codec);
     14066}
     14067
     14068static void alc663_g71v_hp_automute(struct hda_codec *codec)
     14069{
     14070        unsigned int present;
     14071        unsigned char bits;
     14072
     14073        present = snd_hda_codec_read(codec, 0x21, 0,
     14074                                     AC_VERB_GET_PIN_SENSE, 0)
     14075                & AC_PINSENSE_PRESENCE;
     14076        bits = present ? HDA_AMP_MUTE : 0;
     14077        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     14078                                 HDA_AMP_MUTE, bits);
     14079        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     14080                                 HDA_AMP_MUTE, bits);
     14081}
     14082
     14083static void alc663_g71v_front_automute(struct hda_codec *codec)
     14084{
     14085        unsigned int present;
     14086        unsigned char bits;
     14087
     14088        present = snd_hda_codec_read(codec, 0x15, 0,
     14089                                     AC_VERB_GET_PIN_SENSE, 0)
     14090                & AC_PINSENSE_PRESENCE;
     14091        bits = present ? HDA_AMP_MUTE : 0;
     14092        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     14093                                 HDA_AMP_MUTE, bits);
     14094}
     14095
     14096static void alc663_g71v_unsol_event(struct hda_codec *codec,
     14097                                           unsigned int res)
     14098{
     14099        switch (res >> 26) {
     14100        case ALC880_HP_EVENT:
     14101                alc663_g71v_hp_automute(codec);
     14102                break;
     14103        case ALC880_FRONT_EVENT:
     14104                alc663_g71v_front_automute(codec);
     14105                break;
     14106        case ALC880_MIC_EVENT:
     14107                alc662_eeepc_mic_automute(codec);
     14108                break;
     14109        }
     14110}
     14111
     14112static void alc663_g71v_inithook(struct hda_codec *codec)
     14113{
     14114        alc663_g71v_front_automute(codec);
     14115        alc663_g71v_hp_automute(codec);
     14116        alc662_eeepc_mic_automute(codec);
     14117}
     14118
     14119static void alc663_g50v_unsol_event(struct hda_codec *codec,
     14120                                           unsigned int res)
     14121{
     14122        switch (res >> 26) {
     14123        case ALC880_HP_EVENT:
     14124                alc663_m51va_speaker_automute(codec);
     14125                break;
     14126        case ALC880_MIC_EVENT:
     14127                alc662_eeepc_mic_automute(codec);
     14128                break;
     14129        }
     14130}
     14131
     14132static void alc663_g50v_inithook(struct hda_codec *codec)
     14133{
     14134        alc663_m51va_speaker_automute(codec);
     14135        alc662_eeepc_mic_automute(codec);
     14136}
     14137
    1330414138#ifdef CONFIG_SND_HDA_POWER_SAVE
    1330514139#define alc662_loopbacks        alc880_loopbacks
     
    1332414158        [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
    1332514159        [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
     14160        [ALC663_ASUS_M51VA] = "m51va",
     14161        [ALC663_ASUS_G71V] = "g71v",
     14162        [ALC663_ASUS_H13] = "h13",
     14163        [ALC663_ASUS_G50V] = "g50v",
    1332614164        [ALC662_AUTO]           = "auto",
    1332714165};
    1332814166
    1332914167static struct snd_pci_quirk alc662_cfg_tbl[] = {
     14168        SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
     14169        SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
     14170        SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
     14171        SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
    1333014172        SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
    1333114173        SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
    1333214174        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
     14175        SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
     14176        SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
     14177        SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
    1333314178        {0}
    1333414179};
     
    1334114186                .dac_nids = alc662_dac_nids,
    1334214187                .dig_out_nid = ALC662_DIGOUT_NID,
    13343                 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
    13344                 .adc_nids = alc662_adc_nids,
    1334514188                .dig_in_nid = ALC662_DIGIN_NID,
    1334614189                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
     
    1335514198                .dac_nids = alc662_dac_nids,
    1335614199                .dig_out_nid = ALC662_DIGOUT_NID,
    13357                 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
    13358                 .adc_nids = alc662_adc_nids,
    1335914200                .dig_in_nid = ALC662_DIGIN_NID,
    1336014201                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
     
    1336914210                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
    1337014211                .dac_nids = alc662_dac_nids,
    13371                 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
    13372                 .adc_nids = alc662_adc_nids,
    1337314212                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
    1337414213                .channel_mode = alc662_3ST_6ch_modes,
     
    1338314222                .dac_nids = alc662_dac_nids,
    1338414223                .dig_out_nid = ALC662_DIGOUT_NID,
    13385                 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
    13386                 .adc_nids = alc662_adc_nids,
    1338714224                .dig_in_nid = ALC662_DIGIN_NID,
    1338814225                .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
     
    1339514232                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
    1339614233                .dac_nids = alc662_dac_nids,
    13397                 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
    13398                 .adc_nids = alc662_adc_nids,
    1339914234                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
    1340014235                .channel_mode = alc662_3ST_2ch_modes,
     
    1340914244                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
    1341014245                .dac_nids = alc662_dac_nids,
    13411                 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
    13412                 .adc_nids = alc662_adc_nids,
    1341314246                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
    1341414247                .channel_mode = alc662_3ST_2ch_modes,
     
    1342414257                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
    1342514258                .dac_nids = alc662_dac_nids,
    13426                 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
    13427                 .adc_nids = alc662_adc_nids,
    1342814259                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
    1342914260                .channel_mode = alc662_3ST_6ch_modes,
     
    1343214263                .init_hook = alc662_eeepc_ep20_inithook,
    1343314264        },
    13434 
     14265        [ALC663_ASUS_M51VA] = {
     14266                .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
     14267                .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
     14268                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
     14269                .dac_nids = alc662_dac_nids,
     14270                .dig_out_nid = ALC662_DIGOUT_NID,
     14271                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
     14272                .channel_mode = alc662_3ST_2ch_modes,
     14273                .input_mux = &alc663_m51va_capture_source,
     14274                .unsol_event = alc663_m51va_unsol_event,
     14275                .init_hook = alc663_m51va_inithook,
     14276        },
     14277        [ALC663_ASUS_G71V] = {
     14278                .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
     14279                .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
     14280                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
     14281                .dac_nids = alc662_dac_nids,
     14282                .dig_out_nid = ALC662_DIGOUT_NID,
     14283                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
     14284                .channel_mode = alc662_3ST_2ch_modes,
     14285                .input_mux = &alc662_eeepc_capture_source,
     14286                .unsol_event = alc663_g71v_unsol_event,
     14287                .init_hook = alc663_g71v_inithook,
     14288        },
     14289        [ALC663_ASUS_H13] = {
     14290                .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
     14291                .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
     14292                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
     14293                .dac_nids = alc662_dac_nids,
     14294                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
     14295                .channel_mode = alc662_3ST_2ch_modes,
     14296                .input_mux = &alc663_m51va_capture_source,
     14297                .unsol_event = alc663_m51va_unsol_event,
     14298                .init_hook = alc663_m51va_inithook,
     14299        },
     14300        [ALC663_ASUS_G50V] = {
     14301                .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
     14302                .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
     14303                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
     14304                .dac_nids = alc662_dac_nids,
     14305                .dig_out_nid = ALC662_DIGOUT_NID,
     14306                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
     14307                .channel_mode = alc662_3ST_6ch_modes,
     14308                .input_mux = &alc663_capture_source,
     14309                .unsol_event = alc663_g50v_unsol_event,
     14310                .init_hook = alc663_g50v_inithook,
     14311        },
    1343514312};
    1343614313
     
    1357114448                                              int dac_idx)
    1357214449{
    13573         /* set as output */
    13574         snd_hda_codec_write(codec, nid, 0,
    13575                             AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
    13576         snd_hda_codec_write(codec, nid, 0,
    13577                             AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
     14450        alc_set_pin_output(codec, nid, pin_type);
    1357814451        /* need the manual connection? */
    1357914452        if (alc880_is_multi_pin(nid)) {
     
    1361014483                /* use dac 0 */
    1361114484                alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
     14485        pin = spec->autocfg.speaker_pins[0];
     14486        if (pin)
     14487                alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
    1361214488}
    1361314489
     
    1368714563static void alc662_auto_init(struct hda_codec *codec)
    1368814564{
     14565        struct alc_spec *spec = codec->spec;
    1368914566        alc662_auto_init_multi_out(codec);
    1369014567        alc662_auto_init_hp_out(codec);
    1369114568        alc662_auto_init_analog_input(codec);
     14569        if (spec->unsol_event)
     14570                alc_sku_automute(codec);
    1369214571}
    1369314572
     
    1370214581
    1370314582        codec->spec = spec;
     14583
     14584        alc_fix_pll_init(codec, 0x20, 0x04, 15);
    1370414585
    1370514586        board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
     
    1372914610                setup_preset(spec, &alc662_presets[board_config]);
    1373014611
    13731         spec->stream_name_analog = "ALC662 Analog";
     14612        if (codec->vendor_id == 0x10ec0663) {
     14613                spec->stream_name_analog = "ALC663 Analog";
     14614                spec->stream_name_digital = "ALC663 Digital";
     14615        } else {
     14616                spec->stream_name_analog = "ALC662 Analog";
     14617                spec->stream_name_digital = "ALC662 Digital";
     14618        }
     14619
    1373214620        spec->stream_analog_playback = &alc662_pcm_analog_playback;
    1373314621        spec->stream_analog_capture = &alc662_pcm_analog_capture;
    1373414622
    13735         spec->stream_name_digital = "ALC662 Digital";
    1373614623        spec->stream_digital_playback = &alc662_pcm_digital_playback;
    1373714624        spec->stream_digital_capture = &alc662_pcm_digital_capture;
    1373814625
    13739         if (!spec->adc_nids && spec->input_mux) {
    13740                 spec->adc_nids = alc662_adc_nids;
    13741                 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
    13742         }
     14626        spec->adc_nids = alc662_adc_nids;
     14627        spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
     14628        spec->capsrc_nids = alc662_capsrc_nids;
    1374314629
    1374414630        spec->vmaster_nid = 0x02;
     
    1377314659        { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
    1377414660          .patch = patch_alc662 },
     14661        { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
    1377514662        { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
    1377614663        { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
    1377714664        { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
     14665        { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
     14666          .patch = patch_alc882 }, /* should be patch_alc883() in future */
    1377814667        { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
    1377914668        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_si3054.c

    r305 r358  
    2929#include "hda_codec.h"
    3030#include "hda_local.h"
    31 
     31#include "hda_patch.h"
    3232
    3333/* si3054 verbs */
     
    207207        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm;
    208208        info->stream[SNDRV_PCM_STREAM_CAPTURE]  = si3054_pcm;
    209         info->is_modem = 1;
     209        info->pcm_type = HDA_PCM_TYPE_MODEM;
    210210        return 0;
    211211}
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_sigmatel.c

    r305 r358  
    3333#include "hda_codec.h"
    3434#include "hda_local.h"
     35#include "hda_patch.h"
    3536
    3637#define NUM_CONTROL_ALLOC       32
     
    5253        STAC_9200_DELL_M27,
    5354        STAC_9200_GATEWAY,
     55        STAC_9200_PANASONIC,
    5456        STAC_9200_MODELS
    5557};
     
    6567enum {
    6668        STAC_92HD73XX_REF,
     69        STAC_DELL_M6,
    6770        STAC_92HD73XX_MODELS
    6871};
     
    7073enum {
    7174        STAC_92HD71BXX_REF,
     75        STAC_DELL_M4_1,
     76        STAC_DELL_M4_2,
    7277        STAC_92HD71BXX_MODELS
    7378};
     
    125130
    126131        /* gpio lines */
     132        unsigned int eapd_mask;
    127133        unsigned int gpio_mask;
    128134        unsigned int gpio_dir;
     
    137143        unsigned int num_pwrs;
    138144        hda_nid_t *pwr_nids;
     145        hda_nid_t *dac_list;
    139146
    140147        /* playback */
     
    175182        unsigned int io_switch[2];
    176183        unsigned int clfe_swap;
     184        unsigned int hp_switch;
    177185        unsigned int aloopback;
    178186
     
    186194        struct hda_input_mux private_imux;
    187195        struct hda_input_mux private_mono_mux;
    188 
    189         /* virtual master */
    190         unsigned int vmaster_tlv[4];
    191196};
    192197
     
    246251};
    247252
    248 static hda_nid_t stac92hd71bxx_dac_nids[2] = {
     253static hda_nid_t stac92hd71bxx_dac_nids[1] = {
    249254        0x10, /*0x11, */
    250255};
     
    292297};
    293298
     299static hda_nid_t stac927x_dac_nids[6] = {
     300        0x02, 0x03, 0x04, 0x05, 0x06, 0
     301};
     302
    294303static hda_nid_t stac927x_dmux_nids[1] = {
    295304        0x1b,
     
    333342};
    334343
    335 static hda_nid_t stac92hd73xx_pin_nids[12] = {
     344static hda_nid_t stac92hd73xx_pin_nids[13] = {
    336345        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
    337346        0x0f, 0x10, 0x11, 0x12, 0x13,
    338         0x14, 0x22
     347        0x14, 0x1e, 0x22
    339348};
    340349
     
    521530        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
    522531        { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     532        /* setup import muxs */
     533        { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
     534        { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
     535        { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
     536        { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
     537        {0}
     538};
     539
     540static struct hda_verb dell_eq_core_init[] = {
     541        /* set master volume to max value without distortion
     542         * and direct control */
     543        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
     544        /* setup audio connections */
     545        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
     546        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
     547        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
     548        /* setup adcs to point to mixer */
     549        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     550        { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
     551        /* setup import muxs */
     552        { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
     553        { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
     554        { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
     555        { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
     556        {0}
     557};
     558
     559static struct hda_verb dell_m6_core_init[] = {
     560        /* set master volume and direct control */
     561        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
     562        /* setup audio connections */
     563        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
     564        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
     565        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
     566        /* setup adcs to point to mixer */
     567        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     568        { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
    523569        /* setup import muxs */
    524570        { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
     
    591637};
    592638
     639#define HD_DISABLE_PORTF 3
    593640static struct hda_verb stac92hd71bxx_analog_core_init[] = {
     641        /* start of config #1 */
     642
     643        /* connect port 0f to audio mixer */
     644        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
     645        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
     646        /* unmute right and left channels for node 0x0f */
     647        { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     648        /* start of config #2 */
     649
    594650        /* set master volume and direct control */
    595651        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    596652        /* connect headphone jack to dac1 */
    597653        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
    598         /* connect ports 0d and 0f to audio mixer */
     654        /* connect port 0d to audio mixer */
    599655        { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
    600         { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
    601         { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
    602656        /* unmute dac0 input in audio mixer */
    603657        { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
    604         /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
     658        /* unmute right and left channels for nodes 0x0a, 0xd */
    605659        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    606660        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    607         { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    608661        {0}
    609662};
     
    773826        HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
    774827
     828        HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
     829        HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
     830
    775831        HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
    776832        HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
     
    795851        STAC_INPUT_SOURCE(1),
    796852        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
    797         HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
     853        HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
    798854        HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
    799855        {0} /* end */
     
    912968                if (err < 0)
    913969                        return err;
     970                err = snd_hda_create_spdif_share_sw(codec,
     971                                                    &spec->multiout);
     972                if (err < 0)
     973                        return err;
     974                spec->multiout.share_spdif = 1;
    914975        }
    915976        if (spec->dig_in_nid) {
     
    921982        /* if we have no master control, let's create it */
    922983        if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
     984                unsigned int vmaster_tlv[4];
    923985                snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
    924                                         HDA_OUTPUT, spec->vmaster_tlv);
     986                                        HDA_OUTPUT, vmaster_tlv);
    925987                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
    926                                           spec->vmaster_tlv, slave_vols);
     988                                          vmaster_tlv, slave_vols);
    927989                if (err < 0)
    928990                        return err;
     
    10731135        [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
    10741136        [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
     1137        [STAC_9200_PANASONIC] = ref9200_pin_configs,
    10751138};
    10761139
     
    10891152        [STAC_9200_DELL_M27] = "dell-m27",
    10901153        [STAC_9200_GATEWAY] = "gateway",
     1154        [STAC_9200_PANASONIC] = "panasonic",
    10911155};
    10921156
     
    11551219                      "unknown Dell", STAC_9200_DELL_M26),
    11561220        /* Panasonic */
    1157         SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
     1221        SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
    11581222        /* Gateway machines needs EAPD to be set on resume */
    11591223        SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
     
    12131277};
    12141278
    1215 static unsigned int ref92hd73xx_pin_configs[12] = {
     1279static unsigned int ref92hd73xx_pin_configs[13] = {
    12161280        0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
    12171281        0x0181302e, 0x01014010, 0x01014020, 0x01014030,
    12181282        0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
     1283        0x01452050,
     1284};
     1285
     1286static unsigned int dell_m6_pin_configs[13] = {
     1287        0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
     1288        0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
     1289        0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
     1290        0x4f0000f0,
    12191291};
    12201292
    12211293static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
    1222         [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
     1294        [STAC_92HD73XX_REF]     = ref92hd73xx_pin_configs,
     1295        [STAC_DELL_M6]  = dell_m6_pin_configs,
    12231296};
    12241297
    12251298static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
    12261299        [STAC_92HD73XX_REF] = "ref",
     1300        [STAC_DELL_M6] = "dell-m6",
    12271301};
    12281302
     
    12301304        /* SigmaTel reference board */
    12311305        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    1232                       "DFI LanParty", STAC_92HD73XX_REF),
     1306                                "DFI LanParty", STAC_92HD73XX_REF),
     1307        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
     1308                                "unknown Dell", STAC_DELL_M6),
     1309        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
     1310                                "unknown Dell", STAC_DELL_M6),
     1311        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
     1312                                "unknown Dell", STAC_DELL_M6),
     1313        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
     1314                                "unknown Dell", STAC_DELL_M6),
     1315        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
     1316                                "unknown Dell", STAC_DELL_M6),
     1317        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
     1318                                "unknown Dell", STAC_DELL_M6),
     1319        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
     1320                                "unknown Dell", STAC_DELL_M6),
    12331321        {0} /* terminator */
    12341322};
     
    12401328};
    12411329
     1330static unsigned int dell_m4_1_pin_configs[10] = {
     1331        0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
     1332        0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
     1333        0x40f000f0, 0x4f0000f0,
     1334};
     1335
     1336static unsigned int dell_m4_2_pin_configs[10] = {
     1337        0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
     1338        0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
     1339        0x40f000f0, 0x044413b0,
     1340};
     1341
    12421342static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
    12431343        [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
     1344        [STAC_DELL_M4_1]        = dell_m4_1_pin_configs,
     1345        [STAC_DELL_M4_2]        = dell_m4_2_pin_configs,
    12441346};
    12451347
    12461348static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
    12471349        [STAC_92HD71BXX_REF] = "ref",
     1350        [STAC_DELL_M4_1] = "dell-m4-1",
     1351        [STAC_DELL_M4_2] = "dell-m4-2",
    12481352};
    12491353
     
    12521356        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    12531357                      "DFI LanParty", STAC_92HD71BXX_REF),
     1358        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
     1359                                "unknown Dell", STAC_DELL_M4_1),
     1360        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
     1361                                "unknown Dell", STAC_DELL_M4_1),
     1362        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
     1363                                "unknown Dell", STAC_DELL_M4_1),
     1364        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
     1365                                "unknown Dell", STAC_DELL_M4_1),
     1366        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
     1367                                "unknown Dell", STAC_DELL_M4_1),
     1368        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
     1369                                "unknown Dell", STAC_DELL_M4_1),
     1370        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
     1371                                "unknown Dell", STAC_DELL_M4_1),
     1372        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
     1373                                "unknown Dell", STAC_DELL_M4_2),
     1374        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
     1375                                "unknown Dell", STAC_DELL_M4_2),
     1376        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
     1377                                "unknown Dell", STAC_DELL_M4_2),
     1378        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
     1379                                "unknown Dell", STAC_DELL_M4_2),
    12541380        {0} /* terminator */
    12551381};
     
    16391765        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
    16401766                      "Dell Precision", STAC_9205_DELL_M43),
    1641         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
    1642                           "Dell Precision", STAC_9205_DELL_M43),
    16431767        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
    1644                       "Dell Precision", STAC_9205_DELL_M43),
    1645         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
    16461768                      "Dell Precision", STAC_9205_DELL_M43),
    16471769        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
     
    16551777        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
    16561778                      "Dell Precision M4300", STAC_9205_DELL_M43),
     1779        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
     1780                      "unknown Dell", STAC_9205_DELL_M42),
    16571781        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
    16581782                      "Dell Precision", STAC_9205_DELL_M43),
    1659         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
    1660                       "Dell Inspiron", STAC_9205_DELL_M44),
    1661         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
    1662                       "Dell Inspiron", STAC_9205_DELL_M44),
    1663         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
    1664                       "Dell Inspiron", STAC_9205_DELL_M44),
    1665         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
    1666                       "Dell Inspiron", STAC_9205_DELL_M44),
    1667         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
    1668                       "unknown Dell", STAC_9205_DELL_M42),
     1783        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
     1784                      "Dell Precision", STAC_9205_DELL_M43),
     1785        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
     1786                      "Dell Precision", STAC_9205_DELL_M43),
    16691787        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
    16701788                      "Dell Inspiron", STAC_9205_DELL_M44),
     
    17441862{
    17451863        struct sigmatel_spec *spec = codec->spec;
    1746         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     1864        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
     1865                                             hinfo);
    17471866}
    17481867
     
    18181937        struct sigmatel_spec *spec = codec->spec;
    18191938
    1820         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
     1939        snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
    18211940        return 0;
    18221941}
     
    19002019                info++;
    19012020                info->name = "STAC92xx Digital";
     2021                info->pcm_type = HDA_PCM_TYPE_SPDIF;
    19022022                if (spec->multiout.dig_out_nid) {
    19032023                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
     
    19362056}
    19372057
     2058#define stac92xx_hp_switch_info         snd_ctl_boolean_mono_info
     2059
     2060static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
     2061                        struct snd_ctl_elem_value *ucontrol)
     2062{
     2063        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     2064        struct sigmatel_spec *spec = codec->spec;
     2065
     2066        ucontrol->value.integer.value[0] = spec->hp_switch;
     2067        return 0;
     2068}
     2069
     2070static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
     2071                        struct snd_ctl_elem_value *ucontrol)
     2072{
     2073        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     2074        struct sigmatel_spec *spec = codec->spec;
     2075
     2076        spec->hp_switch = ucontrol->value.integer.value[0];
     2077
     2078        /* check to be sure that the ports are upto date with
     2079         * switch changes
     2080         */
     2081        codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
     2082
     2083        return 1;
     2084}
     2085
    19382086#define stac92xx_io_switch_info         snd_ctl_boolean_mono_info
    19392087
     
    20062154        return 1;
    20072155}
     2156
     2157#define STAC_CODEC_HP_SWITCH(xname) \
     2158        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
     2159          .name = xname, \
     2160          .index = 0, \
     2161          .info = stac92xx_hp_switch_info, \
     2162          .get = stac92xx_hp_switch_get, \
     2163          .put = stac92xx_hp_switch_put, \
     2164        }
    20082165
    20092166#define STAC_CODEC_IO_SWITCH(xname, xpval) \
     
    20312188        STAC_CTL_WIDGET_MUTE,
    20322189        STAC_CTL_WIDGET_MONO_MUX,
     2190        STAC_CTL_WIDGET_HP_SWITCH,
    20332191        STAC_CTL_WIDGET_IO_SWITCH,
    20342192        STAC_CTL_WIDGET_CLFE_SWITCH
     
    20392197        HDA_CODEC_MUTE(NULL, 0, 0, 0),
    20402198        STAC_MONO_MUX,
     2199        STAC_CODEC_HP_SWITCH(NULL),
    20412200        STAC_CODEC_IO_SWITCH(NULL, 0),
    20422201        STAC_CODEC_CLFE_SWITCH(NULL, 0),
     
    22332392}
    22342393
     2394static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
     2395{
     2396        if (!spec->multiout.hp_nid)
     2397                spec->multiout.hp_nid = nid;
     2398        else if (spec->multiout.num_dacs > 4) {
     2399                printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
     2400                return 1;
     2401        } else {
     2402                spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
     2403                spec->multiout.num_dacs++;
     2404        }
     2405        return 0;
     2406}
     2407
     2408static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
     2409{
     2410        if (is_in_dac_nids(spec, nid))
     2411                return 1;
     2412        if (spec->multiout.hp_nid == nid)
     2413                return 1;
     2414        return 0;
     2415}
     2416
    22352417/* add playback controls from the parsed DAC table */
    22362418static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
     
    22472429
    22482430
    2249         for (i = 0; i < cfg->line_outs; i++) {
     2431        for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
    22502432                if (!spec->multiout.dac_nids[i])
    22512433                        continue;
     
    22782460                                return err;
    22792461                }
     2462        }
     2463
     2464        if (cfg->hp_outs > 1) {
     2465                err = stac92xx_add_control(spec,
     2466                        STAC_CTL_WIDGET_HP_SWITCH,
     2467                        "Headphone as Line Out Switch", 0);
     2468                if (err < 0)
     2469                        return err;
    22802470        }
    22812471
     
    22952485        if (spec->mic_switch) {
    22962486                unsigned int def_conf;
    2297                 nid = cfg->input_pins[AUTO_PIN_MIC];
     2487                unsigned int mic_pin = AUTO_PIN_MIC;
     2488again:
     2489                nid = cfg->input_pins[mic_pin];
    22982490                def_conf = snd_hda_codec_read(codec, nid, 0,
    22992491                                                AC_VERB_GET_CONFIG_DEFAULT, 0);
    2300 
    23012492                /* some laptops have an internal analog microphone
    23022493                 * which can't be used as a output */
     
    23082499                                        STAC_CTL_WIDGET_IO_SWITCH,
    23092500                                        "Mic as Output Switch", (nid << 8) | 1);
     2501                                nid = snd_hda_codec_read(codec, nid, 0,
     2502                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
     2503                                if (!check_in_dac_nids(spec, nid))
     2504                                        add_spec_dacs(spec, nid);
    23102505                                if (err < 0)
    23112506                                        return err;
    23122507                        }
     2508                } else if (mic_pin == AUTO_PIN_MIC) {
     2509                        mic_pin = AUTO_PIN_FRONT_MIC;
     2510                        goto again;
    23132511                }
    23142512        }
    23152513
    2316         return 0;
    2317 }
    2318 
    2319 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
    2320 {
    2321         if (is_in_dac_nids(spec, nid))
    2322                 return 1;
    2323         if (spec->multiout.hp_nid == nid)
    2324                 return 1;
    2325         return 0;
    2326 }
    2327 
    2328 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
    2329 {
    2330         if (!spec->multiout.hp_nid)
    2331                 spec->multiout.hp_nid = nid;
    2332         else if (spec->multiout.num_dacs > 4) {
    2333                 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
    2334                 return 1;
    2335         } else {
    2336                 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
    2337                 spec->multiout.num_dacs++;
    2338         }
    23392514        return 0;
    23402515}
     
    23892564        }
    23902565        if (spec->multiout.hp_nid) {
    2391                 const char *pfx;
    2392                 if (old_num_dacs == spec->multiout.num_dacs)
    2393                         pfx = "Master";
    2394                 else
    2395                         pfx = "Headphone";
    2396                 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
     2566                err = create_controls(spec, "Headphone",
     2567                                      spec->multiout.hp_nid, 3);
    23972568                if (err < 0)
    23982569                        return err;
     
    25022673        return 0;
    25032674}
    2504 
    25052675
    25062676/* create playback/capture controls for input pins */
     
    27572927        for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
    27582928                hda_nid_t pin = spec->autocfg.speaker_pins[i];
    2759                 unsigned long wcaps = get_wcaps(codec, pin);
     2929                unsigned int wcaps = get_wcaps(codec, pin);
    27602930                wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
    27612931                if (wcaps == AC_WCAP_OUT_AMP)
     
    27682938                for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
    27692939                        hda_nid_t pin = spec->autocfg.line_out_pins[i];
    2770                         unsigned long cfg;
    2771                         cfg = snd_hda_codec_read(codec, pin, 0,
     2940                        unsigned int defcfg;
     2941                        defcfg = snd_hda_codec_read(codec, pin, 0,
    27722942                                                 AC_VERB_GET_CONFIG_DEFAULT,
    27732943                                                 0x00);
    2774                         if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
    2775                                 unsigned long wcaps = get_wcaps(codec, pin);
     2944                        if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
     2945                                unsigned int wcaps = get_wcaps(codec, pin);
    27762946                                wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
    27772947                                if (wcaps == AC_WCAP_OUT_AMP)
     
    28773047        return 0; /* nid is not a HP-Out */
    28783048};
     3049
     3050static void stac92xx_power_down(struct hda_codec *codec)
     3051{
     3052        struct sigmatel_spec *spec = codec->spec;
     3053
     3054        /* power down inactive DACs */
     3055        hda_nid_t *dac;
     3056        for (dac = spec->dac_list; *dac; dac++)
     3057                if (!is_in_dac_nids(spec, *dac) &&
     3058                        spec->multiout.hp_nid != *dac)
     3059                        snd_hda_codec_write_cache(codec, *dac, 0,
     3060                                        AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
     3061}
    28793062
    28803063static int stac92xx_init(struct hda_codec *codec)
     
    29213104                int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
    29223105                                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     3106                int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
     3107                                        0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     3108                def_conf = get_defcfg_connect(def_conf);
    29233109                /* outputs are only ports capable of power management
    29243110                 * any attempts on powering down a input port cause the
     
    29273113                if (pinctl & AC_PINCTL_IN_EN)
    29283114                        continue;
     3115                /* skip any ports that don't have jacks since presence
     3116                 * detection is useless */
     3117                if (def_conf && def_conf != AC_JACK_PORT_FIXED)
     3118                        continue;
    29293119                enable_pin_detect(codec, spec->pwr_nids[i], event | i);
    29303120                codec->patch_ops.unsol_event(codec, (event | i) << 26);
    29313121        }
    2932 
     3122        if (spec->dac_list)
     3123                stac92xx_power_down(codec);
    29333124        if (cfg->dig_out_pin)
    29343125                stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
     
    30263217        struct sigmatel_spec *spec = codec->spec;
    30273218        struct auto_pin_cfg *cfg = &spec->autocfg;
     3219        int nid = cfg->hp_pins[cfg->hp_outs - 1];
    30283220        int i, presence;
    30293221
     
    30363228                if (presence)
    30373229                        break;
     3230                if (spec->hp_switch && cfg->hp_pins[i] == nid)
     3231                        break;
    30383232                presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
    30393233        }
     
    30413235        if (presence) {
    30423236                /* disable lineouts, enable hp */
     3237                if (spec->hp_switch)
     3238                        stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    30433239                for (i = 0; i < cfg->line_outs; i++)
    30443240                        stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
     
    30473243                        stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
    30483244                                                AC_PINCTL_OUT_EN);
     3245                if (spec->eapd_mask)
     3246                        stac_gpio_set(codec, spec->gpio_mask,
     3247                                spec->gpio_dir, spec->gpio_data &
     3248                                ~spec->eapd_mask);
    30493249        } else {
    30503250                /* enable lineouts, disable hp */
     3251                if (spec->hp_switch)
     3252                        stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    30513253                for (i = 0; i < cfg->line_outs; i++)
    30523254                        stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
     
    30553257                        stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
    30563258                                                AC_PINCTL_OUT_EN);
    3057         }
     3259                if (spec->eapd_mask)
     3260                        stac_gpio_set(codec, spec->gpio_mask,
     3261                                spec->gpio_dir, spec->gpio_data |
     3262                                spec->eapd_mask);
     3263        }
     3264        if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
     3265                stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
    30583266}
    30593267
     
    31033311        snd_hda_codec_resume_amp(codec);
    31043312        snd_hda_codec_resume_cache(codec);
     3313        /* power down inactive DACs */
     3314        if (spec->dac_list)
     3315                stac92xx_power_down(codec);
    31053316        /* invoke unsolicited event to reset the HP state */
    31063317        if (spec->hp_detect)
     
    31663377        spec->mixer = stac9200_mixer;
    31673378
     3379        if (spec->board_config == STAC_9200_PANASONIC) {
     3380                spec->gpio_mask = spec->gpio_dir = 0x09;
     3381                spec->gpio_data = 0x00;
     3382        }
     3383
    31683384        err = stac9200_parse_auto_config(codec);
    31693385        if (err < 0) {
     
    31923408                                                        stac925x_models,
    31933409                                                        stac925x_cfg_tbl);
    3194 again:
     3410 again:
    31953411        if (spec->board_config < 0) {
    31963412                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
     
    33063522        switch (spec->multiout.num_dacs) {
    33073523        case 0x3: /* 6 Channel */
     3524                spec->multiout.hp_nid = 0x17;
    33083525                spec->mixer = stac92hd73xx_6ch_mixer;
    33093526                spec->init = stac92hd73xx_6ch_core_init;
     
    33313548        spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
    33323549        spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
    3333         spec->num_dmics = STAC92HD73XX_NUM_DMICS;
    33343550        spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
    33353551        spec->dinput_mux = &stac92hd73xx_dmux;
    33363552        /* GPIO0 High = Enable EAPD */
    3337         spec->gpio_mask = spec->gpio_dir = 0x1;
     3553        spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
    33383554        spec->gpio_data = 0x01;
     3555
     3556        switch (spec->board_config) {
     3557        case STAC_DELL_M6:
     3558                spec->init = dell_eq_core_init;
     3559                switch (codec->subsystem_id) {
     3560                case 0x1028025e: /* Analog Mics */
     3561                case 0x1028025f:
     3562                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
     3563                        spec->num_dmics = 0;
     3564                        break;
     3565                case 0x10280271: /* Digital Mics */
     3566                case 0x10280272:
     3567                        spec->init = dell_m6_core_init;
     3568                        /* fall-through */
     3569                case 0x10280254:
     3570                case 0x10280255:
     3571                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
     3572                        spec->num_dmics = 1;
     3573                        break;
     3574                case 0x10280256: /* Both */
     3575                case 0x10280057:
     3576                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
     3577                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
     3578                        spec->num_dmics = 1;
     3579                        break;
     3580                }
     3581                break;
     3582        default:
     3583                spec->num_dmics = STAC92HD73XX_NUM_DMICS;
     3584        }
    33393585
    33403586        spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
     
    33743620        codec->spec = spec;
    33753621        spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
     3622        spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
    33763623        spec->pin_nids = stac92hd71bxx_pin_nids;
    33773624        spec->board_config = snd_hda_check_board_config(codec,
     
    34023649                spec->init = stac92hd71bxx_core_init;
    34033650                break;
     3651        case 0x111d7608: /* 5 Port with Analog Mixer */
     3652                /* no output amps */
     3653                spec->num_pwrs = 0;
     3654                spec->mixer = stac92hd71bxx_analog_mixer;
     3655
     3656                /* disable VSW */
     3657                spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
     3658                stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
     3659                break;
     3660        case 0x111d7603: /* 6 Port with Analog Mixer */
     3661                /* no output amps */
     3662                spec->num_pwrs = 0;
     3663                /* fallthru */
    34043664        default:
    34053665                spec->mixer = stac92hd71bxx_analog_mixer;
     
    34113671
    34123672        /* GPIO0 High = EAPD */
    3413         spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
     3673        spec->gpio_mask = 0x01;
     3674        spec->gpio_dir = 0x01;
     3675        spec->gpio_data = 0x01;
    34143676
    34153677        spec->mux_nids = stac92hd71bxx_mux_nids;
     
    34173679        spec->dmic_nids = stac92hd71bxx_dmic_nids;
    34183680        spec->dmux_nids = stac92hd71bxx_dmux_nids;
     3681        spec->pwr_nids = stac92hd71bxx_pwr_nids;
    34193682
    34203683        spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
     
    34233686        spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
    34243687
    3425         spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
    3426         spec->pwr_nids = stac92hd71bxx_pwr_nids;
    3427 
    3428         spec->multiout.num_dacs = 2;
     3688        spec->multiout.num_dacs = 1;
    34293689        spec->multiout.hp_nid = 0x11;
    34303690        spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
     
    35013761        }
    35023762
    3503 again:
     3763 again:
    35043764        if (spec->board_config < 0) {
    35053765                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
     
    35903850        spec->mux_nids = stac927x_mux_nids;
    35913851        spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
     3852        spec->dac_list = stac927x_dac_nids;
    35923853        spec->multiout.dac_nids = spec->dac_nids;
    35933854
     
    35963857        case STAC_D965_5ST:
    35973858                /* GPIO0 High = Enable EAPD */
    3598                 spec->gpio_mask = spec->gpio_dir = 0x01;
     3859                spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
    35993860                spec->gpio_data = 0x01;
    36003861                spec->num_dmics = 0;
     
    36043865                break;
    36053866        case STAC_DELL_BIOS:
     3867                switch (codec->subsystem_id) {
     3868                case 0x10280209:
     3869                case 0x1028022e:
     3870                        /* correct the device field to SPDIF out */
     3871                        stac92xx_set_config_reg(codec, 0x21, 0x01442070);
     3872                        break;
     3873                };
     3874                /* configure the analog microphone on some laptops */
     3875                stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
    36063876                /* correct the front output jack as a hp out */
    3607                 stac92xx_set_config_reg(codec, 0x0f, 0x02270110);
     3877                stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
    36083878                /* correct the front input jack as a mic */
    36093879                stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
     
    36113881        case STAC_DELL_3ST:
    36123882                /* GPIO2 High = Enable EAPD */
    3613                 spec->gpio_mask = spec->gpio_dir = 0x04;
     3883                spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
    36143884                spec->gpio_data = 0x04;
    36153885                spec->dmic_nids = stac927x_dmic_nids;
     
    36233893        default:
    36243894                /* GPIO0 High = Enable EAPD */
    3625                 spec->gpio_mask = spec->gpio_dir = 0x1;
     3895                spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
    36263896                spec->gpio_data = 0x01;
    36273897                spec->num_dmics = 0;
     
    36823952                                                        stac9205_models,
    36833953                                                        stac9205_cfg_tbl);
    3684 again:
     3954 again:
    36853955        if (spec->board_config < 0) {
    36863956                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
     
    37273997
    37283998                spec->gpio_dir = 0x0b;
     3999                spec->eapd_mask = 0x01;
    37294000                spec->gpio_mask = 0x1b;
    37304001                spec->gpio_mute = 0x10;
     
    37364007        default:
    37374008                /* GPIO0 High = EAPD */
    3738                 spec->gpio_mask = spec->gpio_dir = 0x1;
     4009                spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
    37394010                spec->gpio_data = 0x01;
    37404011                break;
     
    40284299        { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
    40294300        { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
    4030         { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
     4301        { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
    40314302        { .id = 0x83847632, .name = "STAC9202",  .patch = patch_stac925x },
    40324303        { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
     
    40354306        { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
    40364307        { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
     4308        { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
     4309        { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
    40374310        /* The following does not take into account .id=0x83847661 when subsys =
    40384311         * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
     
    40504323        { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
    40514324        { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
     4325        { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
     4326        { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
    40524327        { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
    40534328        { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
    40544329        { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
    4055         { .id = 0x111d7608, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },
    40564330        { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
    40574331        { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/hda/patch_via.c

    r305 r358  
    4040#include "hda_codec.h"
    4141#include "hda_local.h"
    42 
     42#include "hda_patch.h"
    4343
    4444/* amp values */
     
    358358{
    359359        struct via_spec *spec = codec->spec;
    360         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
     360        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
     361                                             hinfo);
    361362}
    362363
     
    431432{
    432433        struct via_spec *spec = codec->spec;
    433         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
    434                                    0, 0, 0);
     434        snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
    435435        return 0;
    436436}
     
    448448};
    449449
     450static struct hda_pcm_stream vt1708_pcm_analog_s16_playback = {
     451        .substreams = 1,
     452        .channels_min = 2,
     453        .channels_max = 8,
     454        .nid = 0x10, /* NID to query formats and rates */
     455        /* We got noisy outputs on the right channel on VT1708 when
     456         * 24bit samples are used.  Until any workaround is found,
     457         * disable the 24bit format, so far.
     458         */
     459        .formats = SNDRV_PCM_FMTBIT_S16_LE,
     460        .ops = {
     461                .open = via_playback_pcm_open,
     462                .prepare = via_playback_pcm_prepare,
     463                .cleanup = via_playback_pcm_cleanup
     464        },
     465};
     466
    450467static struct hda_pcm_stream vt1708_pcm_analog_capture = {
    451468        .substreams = 2,
     
    494511                if (err < 0)
    495512                        return err;
     513                err = snd_hda_create_spdif_share_sw(codec,
     514                                                    &spec->multiout);
     515                if (err < 0)
     516                        return err;
     517                spec->multiout.share_spdif = 1;
    496518        }
    497519        if (spec->dig_in_nid) {
     
    524546                info++;
    525547                info->name = spec->stream_name_digital;
     548                info->pcm_type = HDA_PCM_TYPE_SPDIF;
    526549                if (spec->multiout.dig_out_nid) {
    527550                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
     
    894917        spec->stream_name_analog = "VT1708 Analog";
    895918        spec->stream_analog_playback = &vt1708_pcm_analog_playback;
     919        /* disable 32bit format on VT1708 */
     920        if (codec->vendor_id == 0x11061708)
     921                spec->stream_analog_playback = &vt1708_pcm_analog_s16_playback;
    896922        spec->stream_analog_capture = &vt1708_pcm_analog_capture;
    897923
     
    10261052        .ops = {
    10271053                .open = via_dig_playback_pcm_open,
    1028                 .close = via_dig_playback_pcm_close,
    1029                 .prepare = via_dig_playback_pcm_prepare
     1054                .close = via_dig_playback_pcm_close
    10301055        },
    10311056};
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/intel8x0.c

    r305 r358  
    158158#define   ICH_PCM_SPDIF_1011    0xc0000000      /* s/pdif pcm on slots 10&11 */
    159159#define   ICH_PCM_20BIT         0x00400000      /* 20-bit samples (ICH4) */
    160 #define   ICH_PCM_246_MASK      0x00300000      /* 6 channels (not all chips) */
     160#define   ICH_PCM_246_MASK      0x00300000      /* chan mask (not all chips) */
     161#define   ICH_PCM_8             0x00300000      /* 8 channels (not all chips) */
    161162#define   ICH_PCM_6             0x00200000      /* 6 channels (not all chips) */
    162163#define   ICH_PCM_4             0x00100000      /* 4 channels (not all chips) */
     
    385386        unsigned multi4: 1,
    386387                 multi6: 1,
     388                 multi8 :1,
    387389                 dra: 1,
    388390                 smp20bit: 1;
     
    713715{
    714716        size = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
    715         change_page_attr(virt_to_page(buf), size, nocache ? PAGE_KERNEL_NOCACHE : PAGE_KERNEL);
    716         global_flush_tlb();
     717        if (nocache)
     718                set_pages_uc(virt_to_page(buf), size);
     719        else
     720                set_pages_wb(virt_to_page(buf), size);
    717721}
    718722#else
    719 #define fill_nocache(buf,size,nocache)
     723#define fill_nocache(buf, size, nocache) do { ; } while (0)
    720724#endif
    721725
     
    9981002                else if (runtime->channels == 6)
    9991003                        cnt |= ICH_PCM_6;
     1004                else if (runtime->channels == 8)
     1005                        cnt |= ICH_PCM_8;
    10001006                if (chip->device_type == DEVICE_NFORCE) {
    10011007                        /* reset to 2ch once to keep the 6 channel data in alignment,
     
    11071113};
    11081114
     1115static unsigned int channels8[] = {
     1116        2, 4, 6, 8,
     1117};
     1118
     1119static struct snd_pcm_hw_constraint_list hw_constraints_channels8 = {
     1120        .count = ARRAY_SIZE(channels8),
     1121        .list = channels8,
     1122        .mask = 0,
     1123};
     1124
    11091125static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev)
    11101126{
     
    11371153                return err;
    11381154
    1139         if (chip->multi6) {
     1155        if (chip->multi8) {
     1156                runtime->hw.channels_max = 8;
     1157                snd_pcm_hw_constraint_list(runtime, 0,
     1158                                                SNDRV_PCM_HW_PARAM_CHANNELS,
     1159                                                &hw_constraints_channels8);
     1160        } else if (chip->multi6) {
    11401161                runtime->hw.channels_max = 6;
    11411162                snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
     
    17111732
    17121733static struct ac97_quirk ac97_quirks[] __devinitdata = {
     1734        {
     1735                .subvendor = 0x0e11,
     1736                .subdevice = 0x000e,
     1737                .name = "Compaq Deskpro EN",    /* AD1885 */
     1738                .type = AC97_TUNE_HP_ONLY
     1739        },
    17131740        {
    17141741                .subvendor = 0x0e11,
     
    22002227        if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) {
    22012228                chip->multi4 = 1;
    2202                 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE))
     2229                if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) {
    22032230                        chip->multi6 = 1;
     2231                        if (chip->ac97[0]->flags & AC97_HAS_8CH)
     2232                                chip->multi8 = 1;
     2233                }
    22042234        }
    22052235        if (pbus->pcms[0].r[1].rslots[0]) {
     
    24432473        }
    24442474        /* --- */
    2445         synchronize_irq(chip->irq);
     2475
    24462476      __hw_end:
    24472477        if (chip->irq >= 0)
     
    24922522
    24932523        if (chip->irq >= 0) {
    2494                 synchronize_irq(chip->irq);
    24952524                free_irq(chip->irq, chip);
    24962525                chip->irq = -1;
     
    26452674        t *= 1000000;
    26462675        t += stop_time.tv_usec - start_time.tv_usec;
    2647         printk(KERN_INFO "%s: measured %lu usecs\n", __FUNCTION__, t);
     2676        printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t);
    26482677        if (t == 0) {
    26492678                snd_printk(KERN_ERR "?? calculation error..\n");
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/korg1212/korg1212.c

    r305 r358  
    21032103
    21042104        if (korg1212->irq >= 0) {
    2105                 synchronize_irq(korg1212->irq);               
    21062105                snd_korg1212_DisableCardInterrupts(korg1212);
    21072106                free_irq(korg1212->irq, korg1212);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/maestro3.c

    r325 r358  
    20732073        struct snd_ac97_bus *pbus;
    20742074        struct snd_ac97_template ac97;
    2075         struct snd_ctl_elem_id id;
     2075        struct snd_ctl_elem_id elem_id;
    20762076        int err;
    20772077        static struct snd_ac97_bus_ops ops = {
     
    20932093        snd_ac97_write(chip->ac97, AC97_PCM, 0);
    20942094
    2095         memset(&id, 0, sizeof(id));
    2096         id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    2097         strcpy(id.name, "Master Playback Switch");
    2098         chip->master_switch = snd_ctl_find_id(chip->card, &id);
    2099         memset(&id, 0, sizeof(id));
    2100         id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    2101         strcpy(id.name, "Master Playback Volume");
    2102         chip->master_volume = snd_ctl_find_id(chip->card, &id);
     2095        memset(&elem_id, 0, sizeof(elem_id));
     2096        elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     2097        strcpy(elem_id.name, "Master Playback Switch");
     2098        chip->master_switch = snd_ctl_find_id(chip->card, &elem_id);
     2099        memset(&elem_id, 0, sizeof(elem_id));
     2100        elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     2101        strcpy(elem_id.name, "Master Playback Volume");
     2102        chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
    21032103
    21042104        return 0;
     
    24322432}
    24332433
     2434static void
     2435snd_m3_hv_init(struct snd_m3 *chip)
     2436{
     2437        unsigned long io = chip->iobase;
     2438        u16 val = GPI_VOL_DOWN | GPI_VOL_UP;
     2439
     2440        if (!chip->is_omnibook)
     2441                return;
     2442
     2443        /*
     2444         * Volume buttons on some HP OmniBook laptops
     2445         * require some GPIO magic to work correctly.
     2446         */
     2447        outw(0xffff, io + GPIO_MASK);
     2448        outw(0x0000, io + GPIO_DATA);
     2449
     2450        outw(~val, io + GPIO_MASK);
     2451        outw(inw(io + GPIO_DIRECTION) & ~val, io + GPIO_DIRECTION);
     2452        outw(val, io + GPIO_MASK);
     2453
     2454        outw(0xffff, io + GPIO_MASK);
     2455}
     2456
    24342457static int
    24352458snd_m3_chip_init(struct snd_m3 *chip)
     
    24472470        pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w);
    24482471
    2449         if (chip->is_omnibook) {
    2450                 /*
    2451                  * Volume buttons on some HP OmniBook laptops don't work
    2452                  * correctly. This makes them work for the most part.
    2453                  *
    2454                  * Volume up and down buttons on the laptop side work.
    2455                  * Fn+cursor_up (volme up) works.
    2456                  * Fn+cursor_down (volume down) doesn't work.
    2457                  * Fn+F7 (mute) works acts as volume up.
    2458                  */
    2459                 outw(~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_MASK);
    2460                 outw(inw(io + GPIO_DIRECTION) & ~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DIRECTION);
    2461                 outw((GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DATA);
    2462                 outw(0xffff, io + GPIO_MASK);
    2463         }
    24642472        pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n);
    24652473        n &= ~(HV_CTRL_ENABLE | REDUCED_DEBOUNCE | HV_BUTTON_FROM_GD);
     
    25472555#endif
    25482556
    2549         if (chip->irq >= 0) {
    2550                 synchronize_irq(chip->irq);
     2557        if (chip->irq >= 0)
    25512558                free_irq(chip->irq, chip);
    2552         }
    25532559
    25542560        if (chip->iobase)
     
    25742580        struct snd_card *card = pci_get_drvdata(pci);
    25752581        struct snd_m3 *chip = card->private_data;
    2576         int i, index;
     2582        int i, dsp_index;
    25772583
    25782584        if (chip->suspend_mem == NULL)
     
    25882594
    25892595        /* save dsp image */
    2590         index = 0;
     2596        dsp_index = 0;
    25912597        for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++)
    2592                 chip->suspend_mem[index++] =
     2598                chip->suspend_mem[dsp_index++] =
    25932599                        snd_m3_assp_read(chip, MEMTYPE_INTERNAL_CODE, i);
    25942600        for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++)
    2595                 chip->suspend_mem[index++] =
     2601                chip->suspend_mem[dsp_index++] =
    25962602                        snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i);
    25972603
     
    26062612        struct snd_card *card = pci_get_drvdata(pci);
    26072613        struct snd_m3 *chip = card->private_data;
    2608         int i, index;
     2614        int i, dsp_index;
    26092615
    26102616        if (chip->suspend_mem == NULL)
     
    26302636
    26312637        /* restore dsp image */
    2632         index = 0;
     2638        dsp_index = 0;
    26332639        for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++)
    26342640                snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, i,
    2635                                   chip->suspend_mem[index++]);
     2641                                  chip->suspend_mem[dsp_index++]);
    26362642        for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++)
    26372643                snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, i,
    2638                                   chip->suspend_mem[index++]);
     2644                                  chip->suspend_mem[dsp_index++]);
    26392645
    26402646        /* tell the dma engine to restart itself */
     
    26482654        snd_m3_enable_ints(chip);
    26492655        snd_m3_amp_enable(chip, 1);
     2656
     2657        snd_m3_hv_init(chip);
    26502658
    26512659        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     
    27922800        snd_m3_amp_enable(chip, 1);
    27932801
     2802        snd_m3_hv_init(chip);
     2803
    27942804        tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip);
    27952805
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/nm256/nm256.c

    r305 r358  
    13031303        };
    13041304
    1305         chip->ac97_regs = kcalloc(sizeof(short),
    1306                                   ARRAY_SIZE(nm256_ac97_init_val), GFP_KERNEL);
     1305        chip->ac97_regs = kcalloc(ARRAY_SIZE(nm256_ac97_init_val),
     1306                                  sizeof(short), GFP_KERNEL);
    13071307        if (! chip->ac97_regs)
    13081308                return -ENOMEM;
     
    14401440
    14411441        if (chip->irq >= 0)
    1442                 synchronize_irq(chip->irq);
     1442                free_irq(chip->irq, chip);
    14431443
    14441444        if (chip->cport)
     
    14481448        release_and_free_resource(chip->res_cport);
    14491449        release_and_free_resource(chip->res_buffer);
    1450         if (chip->irq >= 0)
    1451                 free_irq(chip->irq, chip);
    14521450
    14531451        pci_disable_device(chip->pci);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/rme96.c

    r305 r358  
    15601560        rme96->port = pci_resource_start(rme96->pci, 0);
    15611561
    1562         if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
     1562        rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
     1563        if (!rme96->iobase) {
    15631564                snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
    15641565                return -ENOMEM;
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/rme9652/hdsp.c

    r305 r358  
    319319
    320320#define HDSP_spdifFrequencyMask    (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2)
     321#define HDSP_spdifFrequencyMask_9632 (HDSP_spdifFrequency0|\
     322                                      HDSP_spdifFrequency1|\
     323                                      HDSP_spdifFrequency2|\
     324                                      HDSP_spdifFrequency3)
    321325
    322326#define HDSP_spdifFrequency32KHz   (HDSP_spdifFrequency0)
     
    329333
    330334/* This is for H9632 cards */
    331 #define HDSP_spdifFrequency128KHz   HDSP_spdifFrequencyMask
     335#define HDSP_spdifFrequency128KHz   (HDSP_spdifFrequency0|\
     336                                     HDSP_spdifFrequency1|\
     337                                     HDSP_spdifFrequency2)
    332338#define HDSP_spdifFrequency176_4KHz HDSP_spdifFrequency3
    333339#define HDSP_spdifFrequency192KHz   (HDSP_spdifFrequency3|HDSP_spdifFrequency0)
     
    886892}
    887893
    888 static int hdsp_external_sample_rate (struct hdsp *hdsp)
     894static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
     895{
     896        unsigned int status = hdsp_read(hdsp, HDSP_statusRegister);
     897        unsigned int rate_bits = (status & HDSP_spdifFrequencyMask);
     898
     899        /* For the 9632, the mask is different */
     900        if (hdsp->io_type == H9632)
     901                 rate_bits = (status & HDSP_spdifFrequencyMask_9632);
     902
     903        if (status & HDSP_SPDIFErrorFlag)
     904                return 0;
     905       
     906        switch (rate_bits) {
     907        case HDSP_spdifFrequency32KHz: return 32000;
     908        case HDSP_spdifFrequency44_1KHz: return 44100;
     909        case HDSP_spdifFrequency48KHz: return 48000;
     910        case HDSP_spdifFrequency64KHz: return 64000;
     911        case HDSP_spdifFrequency88_2KHz: return 88200;
     912        case HDSP_spdifFrequency96KHz: return 96000;
     913        case HDSP_spdifFrequency128KHz:
     914                if (hdsp->io_type == H9632) return 128000;
     915                break;
     916        case HDSP_spdifFrequency176_4KHz:
     917                if (hdsp->io_type == H9632) return 176400;
     918                break;
     919        case HDSP_spdifFrequency192KHz:
     920                if (hdsp->io_type == H9632) return 192000;
     921                break;
     922        default:
     923                break;
     924        }
     925        snd_printk ("Hammerfall-DSP: unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
     926        return 0;
     927}
     928
     929static int hdsp_external_sample_rate(struct hdsp *hdsp)
    889930{
    890931        unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
    891932        unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
     933
     934        /* For the 9632 card, there seems to be no bit for indicating external
     935         * sample rate greater than 96kHz. The card reports the corresponding
     936         * single speed. So the best means seems to get spdif rate when
     937         * autosync reference is spdif */
     938        if (hdsp->io_type == H9632 &&
     939            hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF)
     940                 return hdsp_spdif_sample_rate(hdsp);
    892941
    893942        switch (rate_bits) {
     
    901950                return 0;
    902951        }
    903 }
    904 
    905 static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
    906 {
    907         unsigned int status = hdsp_read(hdsp, HDSP_statusRegister);
    908         unsigned int rate_bits = (status & HDSP_spdifFrequencyMask);
    909 
    910         if (status & HDSP_SPDIFErrorFlag)
    911                 return 0;
    912        
    913         switch (rate_bits) {
    914         case HDSP_spdifFrequency32KHz: return 32000;
    915         case HDSP_spdifFrequency44_1KHz: return 44100;
    916         case HDSP_spdifFrequency48KHz: return 48000;
    917         case HDSP_spdifFrequency64KHz: return 64000;
    918         case HDSP_spdifFrequency88_2KHz: return 88200;
    919         case HDSP_spdifFrequency96KHz: return 96000;
    920         case HDSP_spdifFrequency128KHz:
    921                 if (hdsp->io_type == H9632) return 128000;
    922                 break;
    923         case HDSP_spdifFrequency176_4KHz:
    924                 if (hdsp->io_type == H9632) return 176400;
    925                 break;
    926         case HDSP_spdifFrequency192KHz:
    927                 if (hdsp->io_type == H9632) return 192000;
    928                 break;
    929         default:
    930                 break;
    931         }
    932         snd_printk ("Hammerfall-DSP: unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
    933         return 0;
    934952}
    935953
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/rme9652/hdspm.c

    r305 r358  
    541541static inline int HDSPM_bit2freq(int n)
    542542{
    543         static int bit2freq_tab[] = { 0, 32000, 44100, 48000, 64000, 88200,
     543        static const int bit2freq_tab[] = {
     544                0, 32000, 44100, 48000, 64000, 88200,
    544545                96000, 128000, 176400, 192000 };
    545546        if (n < 1 || n > 9)
     
    583584}
    584585
    585 static inline int hdspm_write_in_gain(struct hdspm * hdspm, unsigned int chan,
     586static int hdspm_write_in_gain(struct hdspm *hdspm, unsigned int chan,
    586587                                      unsigned int in, unsigned short data)
    587588{
     
    596597}
    597598
    598 static inline int hdspm_write_pb_gain(struct hdspm * hdspm, unsigned int chan,
     599static int hdspm_write_pb_gain(struct hdspm *hdspm, unsigned int chan,
    599600                                      unsigned int pb, unsigned short data)
    600601{
     
    622623
    623624/* check if same process is writing and reading */
    624 static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm)
     625static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm)
    625626{
    626627        unsigned long flags;
     
    637638
    638639/* check for external sample rate */
    639 static inline int hdspm_external_sample_rate(struct hdspm * hdspm)
     640static int hdspm_external_sample_rate(struct hdspm *hdspm)
    640641{
    641642        if (hdspm->is_aes32) {
     
    788789
    789790/* should I silence all or only opened ones ? doit all for first even is 4MB*/
    790 static inline void hdspm_silence_playback(struct hdspm * hdspm)
     791static void hdspm_silence_playback(struct hdspm *hdspm)
    791792{
    792793        int i;
     
    10291030        /* the hardware already does the relevant bit-mask with 0xff */
    10301031        if (id)
    1031                 return hdspm_write(hdspm, HDSPM_midiDataOut1, val);
     1032                hdspm_write(hdspm, HDSPM_midiDataOut1, val);
    10321033        else
    1033                 return hdspm_write(hdspm, HDSPM_midiDataOut0, val);
     1034                hdspm_write(hdspm, HDSPM_midiDataOut0, val);
    10341035}
    10351036
     
    10581059}
    10591060
    1060 static inline void snd_hdspm_flush_midi_input (struct hdspm *hdspm, int id)
     1061static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id)
    10611062{
    10621063        while (snd_hdspm_midi_input_available (hdspm, id))
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/trident/trident_main.c

    r325 r358  
    15911591                if (trident->device != TRIDENT_DEVICE_ID_SI7018) {
    15921592                        outl(trident->spdif_pcm_bits, TRID_REG(trident, NX_SPCSTATUS));
    1593                         outb(trident->spdif_pcm_ctrl, TRID_REG(trident, NX_SPCTRL_SPCSO + 3));
     1593                        val = trident->spdif_pcm_ctrl;
     1594                        if (!go)
     1595                                val &= ~(0x28);
     1596                        outb(val, TRID_REG(trident, NX_SPCTRL_SPCSO + 3));
    15941597                } else {
    15951598                        outl(trident->spdif_pcm_bits, TRID_REG(trident, SI_SPDIF_CS));
     
    36773680                outl(0, TRID_REG(trident, SI_SERIAL_INTF_CTRL));
    36783681        }
     3682        if (trident->irq >= 0)
     3683                free_irq(trident->irq, trident);
    36793684        if (trident->tlb.buffer.area) {
    36803685                outl(0, TRID_REG(trident, NX_TLBC));
     
    36863691                snd_dma_free_pages(&trident->tlb.buffer);
    36873692        }
    3688         if (trident->irq >= 0)
    3689                 free_irq(trident->irq, trident);
    36903693        pci_release_regions(trident->pci);
    36913694        pci_disable_device(trident->pci);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/trident/trident_memory.c

    r305 r358  
    311311        return 0;
    312312}
    313 
    314 
    315 /*----------------------------------------------------------------
    316  * memory allocation using multiple pages (for synth)
    317  *----------------------------------------------------------------
    318  * Unlike the DMA allocation above, non-contiguous pages are
    319  * assigned to TLB.
    320  *----------------------------------------------------------------*/
    321 
    322 /*
    323  */
    324 static int synth_alloc_pages(struct snd_trident *hw, struct snd_util_memblk *blk);
    325 static int synth_free_pages(struct snd_trident *hw, struct snd_util_memblk *blk);
    326 
    327 /*
    328  * allocate a synth sample area
    329  */
    330 struct snd_util_memblk *
    331 snd_trident_synth_alloc(struct snd_trident *hw, unsigned int size)
    332 {
    333         struct snd_util_memblk *blk;
    334         struct snd_util_memhdr *hdr = hw->tlb.memhdr;
    335 
    336         mutex_lock(&hdr->block_mutex);
    337         blk = __snd_util_mem_alloc(hdr, size);
    338         if (blk == NULL) {
    339                 mutex_unlock(&hdr->block_mutex);
    340                 return NULL;
    341         }
    342         if (synth_alloc_pages(hw, blk)) {
    343                 __snd_util_mem_free(hdr, blk);
    344                 mutex_unlock(&hdr->block_mutex);
    345                 return NULL;
    346         }
    347         mutex_unlock(&hdr->block_mutex);
    348         return blk;
    349 }
    350 
    351 EXPORT_SYMBOL(snd_trident_synth_alloc);
    352 
    353 /*
    354  * free a synth sample area
    355  */
    356 int
    357 snd_trident_synth_free(struct snd_trident *hw, struct snd_util_memblk *blk)
    358 {
    359         struct snd_util_memhdr *hdr = hw->tlb.memhdr;
    360 
    361         mutex_lock(&hdr->block_mutex);
    362         synth_free_pages(hw, blk);
    363          __snd_util_mem_free(hdr, blk);
    364         mutex_unlock(&hdr->block_mutex);
    365         return 0;
    366 }
    367 
    368 EXPORT_SYMBOL(snd_trident_synth_free);
    369 
    370 /*
    371  * reset TLB entry and free kernel page
    372  */
    373 static void clear_tlb(struct snd_trident *trident, int page)
    374 {
    375         void *ptr = page_to_ptr(trident, page);
    376         dma_addr_t addr = page_to_addr(trident, page);
    377         set_silent_tlb(trident, page);
    378         if (ptr) {
    379                 struct snd_dma_buffer dmab;
    380                 dmab.dev.type = SNDRV_DMA_TYPE_DEV;
    381                 dmab.dev.dev = snd_dma_pci_data(trident->pci);
    382                 dmab.area = ptr;
    383                 dmab.addr = addr;
    384                 dmab.bytes = ALIGN_PAGE_SIZE;
    385                 snd_dma_free_pages(&dmab);
    386         }
    387 }
    388 
    389 /* check new allocation range */
    390 static void get_single_page_range(struct snd_util_memhdr *hdr,
    391                                   struct snd_util_memblk *blk,
    392                                   int *first_page_ret, int *last_page_ret)
    393 {
    394         struct list_head *p;
    395         struct snd_util_memblk *q;
    396         int first_page, last_page;
    397         first_page = firstpg(blk);
    398         if ((p = blk->list.prev) != &hdr->block) {
    399                 q = list_entry(p, struct snd_util_memblk, list);
    400                 if (lastpg(q) == first_page)
    401                         first_page++;  /* first page was already allocated */
    402         }
    403         last_page = lastpg(blk);
    404         if ((p = blk->list.next) != &hdr->block) {
    405                 q = list_entry(p, struct snd_util_memblk, list);
    406                 if (firstpg(q) == last_page)
    407                         last_page--; /* last page was already allocated */
    408         }
    409         *first_page_ret = first_page;
    410         *last_page_ret = last_page;
    411 }
    412 
    413 /*
    414  * allocate kernel pages and assign them to TLB
    415  */
    416 static int synth_alloc_pages(struct snd_trident *hw, struct snd_util_memblk *blk)
    417 {
    418         int page, first_page, last_page;
    419         struct snd_dma_buffer dmab;
    420 
    421         firstpg(blk) = get_aligned_page(blk->offset);
    422         lastpg(blk) = get_aligned_page(blk->offset + blk->size - 1);
    423         get_single_page_range(hw->tlb.memhdr, blk, &first_page, &last_page);
    424 
    425         /* allocate a kernel page for each Trident page -
    426          * fortunately Trident page size and kernel PAGE_SIZE is identical!
    427          */
    428         for (page = first_page; page <= last_page; page++) {
    429                 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(hw->pci),
    430                                         ALIGN_PAGE_SIZE, &dmab) < 0)
    431                         goto __fail;
    432                 if (! is_valid_page(dmab.addr)) {
    433                         snd_dma_free_pages(&dmab);
    434                         goto __fail;
    435                 }
    436                 set_tlb_bus(hw, page, (unsigned long)dmab.area, dmab.addr);
    437         }
    438         return 0;
    439 
    440 __fail:
    441         /* release allocated pages */
    442         last_page = page - 1;
    443         for (page = first_page; page <= last_page; page++)
    444                 clear_tlb(hw, page);
    445 
    446         return -ENOMEM;
    447 }
    448 
    449 /*
    450  * free pages
    451  */
    452 static int synth_free_pages(struct snd_trident *trident, struct snd_util_memblk *blk)
    453 {
    454         int page, first_page, last_page;
    455 
    456         get_single_page_range(trident->tlb.memhdr, blk, &first_page, &last_page);
    457         for (page = first_page; page <= last_page; page++)
    458                 clear_tlb(trident, page);
    459 
    460         return 0;
    461 }
    462 
    463 /*
    464  * copy_from_user(blk + offset, data, size)
    465  */
    466 int snd_trident_synth_copy_from_user(struct snd_trident *trident,
    467                                      struct snd_util_memblk *blk,
    468                                      int offset, const char __user *data, int size)
    469 {
    470         int page, nextofs, end_offset, temp, temp1;
    471 
    472         offset += blk->offset;
    473         end_offset = offset + size;
    474         page = get_aligned_page(offset) + 1;
    475         do {
    476                 nextofs = aligned_page_offset(page);
    477                 temp = nextofs - offset;
    478                 temp1 = end_offset - offset;
    479                 if (temp1 < temp)
    480                         temp = temp1;
    481                 if (copy_from_user(offset_ptr(trident, offset), data, temp))
    482                         return -EFAULT;
    483                 offset = nextofs;
    484                 data += temp;
    485                 page++;
    486         } while (offset < end_offset);
    487         return 0;
    488 }
    489 
    490 EXPORT_SYMBOL(snd_trident_synth_copy_from_user);
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/via82xx.c

    r351 r358  
    17551755                .subdevice = 0x0a85,
    17561756                .name = "ECS L7VMM2",
     1757                .type = AC97_TUNE_HP_ONLY
     1758        },
     1759        {
     1760                .subvendor = 0x1019,
     1761                .subdevice = 0x1841,
     1762                .name = "ECS K7VTA3",
    17571763                .type = AC97_TUNE_HP_ONLY
    17581764        },
     
    22372243        for (i = 0; i < chip->num_devs; i++)
    22382244                snd_via82xx_channel_reset(chip, &chip->devs[i]);
    2239         synchronize_irq(chip->irq);
     2245
    22402246        if (chip->irq >= 0)
    22412247                free_irq(chip->irq, chip);
     
    24062412        w = snd_pci_quirk_lookup(pci, dxs_whitelist);
    24072413        if (w) {
     2414#ifndef TARGET_OS2
    24082415                snd_printdd(KERN_INFO "via82xx: DXS white list for %s found\n",
    24092416                            w->name);
     2417#endif
    24102418                return w->value;
    24112419        }
  • GPL/branches/uniaud32-2.0/alsa-kernel/pci/ymfpci/ymfpci_main.c

    r305 r358  
    22172217                snd_ymfpci_writel(chip, reg, 0);
    22182218        snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x3fff3fff);
     2219        snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0x3fff3fff);
    22192220        snd_ymfpci_writel(chip, YDSXGR_ZVOUTVOL, 0x3fff3fff);
    22202221        snd_ymfpci_writel(chip, YDSXGR_SPDIFOUTVOL, 0x3fff3fff);
     
    22612262        vfree(chip->saved_regs);
    22622263#endif
     2264        if (chip->irq >= 0)
     2265                free_irq(chip->irq, chip);
    22632266        release_and_free_resource(chip->mpu_res);
    22642267        release_and_free_resource(chip->fm_res);
     
    22692272                snd_dma_free_pages(&chip->work_ptr);
    22702273       
    2271         if (chip->irq >= 0)
    2272                 free_irq(chip->irq, chip);
    22732274        release_and_free_resource(chip->res_reg_area);
    22742275
     
    23362337        chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE);
    23372338        snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);
     2339        snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0);
    23382340        snd_ymfpci_disable_dsp(chip);
    23392341        pci_disable_device(pci);
  • GPL/branches/uniaud32-2.0/alsa-kernel/synth/emux/emux_synth.c

    r305 r358  
    342342#ifdef SNDRV_EMUX_USE_RAW_EFFECT
    343343                /* FIXME: this is an emulation */
    344                 snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, -160,
     344                if (chan->control[type] >= 64)
     345                        snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, -160,
    345346                                     EMUX_FX_FLAG_ADD);
     347                else
     348                        snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, 0,
     349                                     EMUX_FX_FLAG_OFF);
    346350#endif
    347351                break;
  • GPL/branches/uniaud32-2.0/uniaud.inc

    r357 r358  
    77# BUILDVERSION must be 3 parts, and only numbers like 5.44.108
    88# It is best that 2'nd number is always 2 digits, eg at least 10
    9 BUILDVERSION = 1.9.4
     9BUILDVERSION = 1.9.5
    1010
    1111# Fixpack version
     
    1313# ex RC3  GA  FIXPACK2 beta_47
    1414# Comment out to avoid a fixpack line in bldlevel
    15 FIXPACK = SVN r357
     15FIXPACK = SVN r358
    1616
    1717# ALSA BUILD VERSION
     
    2020# Leave empty or use MIXED
    2121# STRING must be max X chars
    22 ALSAVERSION = 1.0.16
     22ALSAVERSION = 1.0.17
    2323
Note: See TracChangeset for help on using the changeset viewer.