Ignore:
Timestamp:
May 9, 2009, 11:45:26 AM (17 years ago)
Author:
Paul Smedley
Message:

Update alsa-kernel to ALSA 1.0.20 level

Location:
GPL/trunk/alsa-kernel/pci
Files:
50 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_codec.c

    r410 r426  
    144144{ 0x43585421, 0xffffffff, "HSD11246",           NULL,           NULL }, // SmartMC II
    145145{ 0x43585428, 0xfffffff8, "Cx20468",            patch_conexant, NULL }, // SmartAMC fixme: the mask might be different
     146{ 0x43585430, 0xffffffff, "Cx20468-31",         patch_conexant, NULL },
    146147{ 0x43585431, 0xffffffff, "Cx20551",           patch_cx20551,  NULL },
    147148{ 0x44543031, 0xfffffff0, "DT0398",             NULL,           NULL },
     
    384385EXPORT_SYMBOL(snd_ac97_update_bits);
    385386
    386 /* no lock version - see snd_ac97_updat_bits() */
     387/* no lock version - see snd_ac97_update_bits() */
    387388int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
    388389                                unsigned short mask, unsigned short value)
     
    16821683        int err, idx;
    16831684
    1684         //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG));
     1685        /*
     1686        printk(KERN_DEBUG "AC97_GPIO_CFG = %x\n",
     1687               snd_ac97_read(ac97,AC97_GPIO_CFG));
     1688        */
    16851689        snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH));
    16861690        snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH));
     
    21622166                /* nothing should be in powerdown mode */
    21632167                snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0);
    2164                 end_time = jiffies + msecs_to_jiffies(100);
     2168                end_time = jiffies + msecs_to_jiffies(120);
    21652169                do {
    21662170                        if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f)
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_proc.c

    r305 r426  
    125125        snd_iprintf(buffer, "PCI Subsys Device: 0x%04x\n\n",
    126126                    ac97->subsystem_device);
     127
     128        snd_iprintf(buffer, "Flags: %x\n", ac97->flags);
    127129
    128130        if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
  • GPL/trunk/alsa-kernel/pci/ak4531_codec.c

    r399 r426  
    5252       
    5353        for (idx = 0; idx < 0x19; idx++)
    54                 printk("ak4531 0x%x: 0x%x\n", idx, ak4531->regs[idx]);
     54                printk(KERN_DEBUG "ak4531 0x%x: 0x%x\n",
     55                       idx, ak4531->regs[idx]);
    5556}
    5657
  • GPL/trunk/alsa-kernel/pci/ali5451/ali5451.c

    r410 r426  
    21532153        int err;
    21542154
    2155         snd_ali_printk("resouces allocation ...\n");
     2155        snd_ali_printk("resources allocation ...\n");
    21562156        err = pci_request_regions(codec->pci, "ALI 5451");
    21572157        if (err < 0)
     
    21652165        }
    21662166        codec->irq = codec->pci->irq;
    2167         snd_ali_printk("resouces allocated.\n");
     2167        snd_ali_printk("resources allocated.\n");
    21682168        return 0;
    21692169}
     
    21972197                return err;
    21982198        /* check, if we can restrict PCI DMA transfers to 31 bits */
    2199         if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 ||
    2200             pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) {
     2199        if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 ||
     2200            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) {
    22012201                snd_printk(KERN_ERR "architecture does not support "
    22022202                           "31bit PCI busmaster DMA\n");
  • GPL/trunk/alsa-kernel/pci/als4000.c

    r410 r426  
    873873        }
    874874        /* check, if we can restrict PCI DMA transfers to 24 bits */
    875         if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 ||
    876             pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) {
     875        if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
     876            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
    877877                snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
    878878                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/atiixp.c

    r410 r426  
    13961396                .type = AC97_TUNE_MUTE_LED
    13971397        },
     1398        {
     1399                .subvendor = 0x103c,
     1400                .subdevice = 0x3091,
     1401                .name = "unknown HP",
     1402                .type = AC97_TUNE_MUTE_LED
     1403        },
    13981404        {0} /* terminator */
    13991405};
  • GPL/trunk/alsa-kernel/pci/au88x0/au88x0.c

    r410 r426  
    152152        if ((err = pci_enable_device(pci)) < 0)
    153153                return err;
    154         if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
    155             pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
     154        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
     155            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
    156156                printk(KERN_ERR "error to set DMA mask\n");
    157157                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/au88x0/au88x0_a3d.c

    r305 r426  
    463463static void a3dsrc_ZeroState(a3dsrc_t * a)
    464464{
    465 
    466         //printk("vortex: ZeroState slice: %d, source %d\n", a->slice, a->source);
    467 
     465        /*
     466        printk(KERN_DEBUG "vortex: ZeroState slice: %d, source %d\n",
     467               a->slice, a->source);
     468        */
    468469        a3dsrc_SetAtmosState(a, 0, 0, 0, 0);
    469470        a3dsrc_SetHrtfState(a, A3dHrirZeros, A3dHrirZeros);
  • GPL/trunk/alsa-kernel/pci/au88x0/au88x0_core.c

    r399 r426  
    11361136                break;
    11371137        }
    1138         //printk("vortex: cfg0 = 0x%x\nvortex: cfg1=0x%x\n", dma->cfg0, dma->cfg1);
     1138        /*
     1139        printk(KERN_DEBUG "vortex: cfg0 = 0x%x\nvortex: cfg1=0x%x\n",
     1140               dma->cfg0, dma->cfg1);
     1141        */
    11391142        hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG0 + (adbdma << 3), dma->cfg0);
    11401143        hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG1 + (adbdma << 3), dma->cfg1);
     
    19601963                vortex_connection_mix_adb(vortex, en, 0x11, mixers[3],
    19611964                                          ADB_CODECOUT(1 + 4));
    1962                 //printk("SDAC detected ");
     1965                /* printk(KERN_DEBUG "SDAC detected "); */
    19631966        }
    19641967#else
     
    20142017                                else
    20152018                                        vortex->dma_adb[i].resources[restype] |= (1 << i);
    2016                                 //printk("vortex: ResManager: type %d out %d\n", restype, i);
     2019                                /*
     2020                                printk(KERN_DEBUG
     2021                                       "vortex: ResManager: type %d out %d\n",
     2022                                       restype, i);
     2023                                */
    20172024                                return i;
    20182025                        }
     
    20252032                        if (resmap[restype] & (1 << i)) {
    20262033                                resmap[restype] &= ~(1 << i);
    2027                                 //printk("vortex: ResManager: type %d in %d\n",restype, i);
     2034                                /*
     2035                                printk(KERN_DEBUG
     2036                                       "vortex: ResManager: type %d in %d\n",
     2037                                       restype, i);
     2038                                */
    20282039                                return i;
    20292040                        }
     
    27902801        int a, this_194;
    27912802
    2792         if ((bits != 8) || (bits != 16))
     2803        if ((bits != 8) && (bits != 16))
    27932804                return -1;
    27942805
  • GPL/trunk/alsa-kernel/pci/au88x0/au88x0_synth.c

    r305 r426  
    214214                /* Voice specific parameters */
    215215        case 0:         /* running */
    216                 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_RUN(wt), (int)val);
     216                /*
     217                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     218                       WT_RUN(wt), (int)val);
     219                */
    217220                hwwrite(vortex->mmio, WT_RUN(wt), val);
    218221                return 0xc;
    219222                break;
    220223        case 1:         /* param 0 */
    221                 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,0), (int)val);
     224                /*
     225                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     226                       WT_PARM(wt,0), (int)val);
     227                */
    222228                hwwrite(vortex->mmio, WT_PARM(wt, 0), val);
    223229                return 0xc;
    224230                break;
    225231        case 2:         /* param 1 */
    226                 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,1), (int)val);
     232                /*
     233                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     234                       WT_PARM(wt,1), (int)val);
     235                */
    227236                hwwrite(vortex->mmio, WT_PARM(wt, 1), val);
    228237                return 0xc;
    229238                break;
    230239        case 3:         /* param 2 */
    231                 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,2), (int)val);
     240                /*
     241                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     242                       WT_PARM(wt,2), (int)val);
     243                */
    232244                hwwrite(vortex->mmio, WT_PARM(wt, 2), val);
    233245                return 0xc;
    234246                break;
    235247        case 4:         /* param 3 */
    236                 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,3), (int)val);
     248                /*
     249                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     250                       WT_PARM(wt,3), (int)val);
     251                */
    237252                hwwrite(vortex->mmio, WT_PARM(wt, 3), val);
    238253                return 0xc;
    239254                break;
    240255        case 6:         /* mute */
    241                 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_MUTE(wt), (int)val);
     256                /*
     257                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     258                       WT_MUTE(wt), (int)val);
     259                */
    242260                hwwrite(vortex->mmio, WT_MUTE(wt), val);
    243261                return 0xc;
     
    245263        case 0xb:
    246264                {               /* delay */
    247                         //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_DELAY(wt,0), (int)val);
     265                        /*
     266                        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
     267                               WT_DELAY(wt,0), (int)val);
     268                        */
    248269                        hwwrite(vortex->mmio, WT_DELAY(wt, 3), val);
    249270                        hwwrite(vortex->mmio, WT_DELAY(wt, 2), val);
     
    273294                break;
    274295        }
    275         //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val);
     296        /*
     297        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val);
     298        */
    276299        hwwrite(vortex->mmio, ecx, val);
    277300        return 1;
  • GPL/trunk/alsa-kernel/pci/ca0106/ca0106_main.c

    r410 r426  
    256256           .i2c_adc = 1,
    257257           .spi_dac = 1 } ,
     258        /* Giga-byte GA-G1975X mobo
     259         * Novell bnc#395807
     260         */
     261        /* FIXME: the GPIO and I2C setting aren't tested well */
     262        { .serial = 0x1458a006,
     263          .name = "Giga-byte GA-G1975X",
     264          .gpio_type = 1,
     265          .i2c_adc = 1 },
    258266         /* Shuttle XPC SD31P which has an onboard Creative Labs
    259267          * Sound Blaster Live! 24-bit EAX
     
    405413
    406414        tmp = reg << 25 | value << 16;
    407         // snd_printk("I2C-write:reg=0x%x, value=0x%x\n", reg, value);
     415        /*
     416        snd_printk(KERN_DEBUG "I2C-write:reg=0x%x, value=0x%x\n", reg, value);
     417        */
    408418        /* Not sure what this I2C channel controls. */
    409419        /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */
     
    423433                while (1) {
    424434                        status = snd_ca0106_ptr_read(emu, I2C_A, 0);
    425                         //snd_printk("I2C:status=0x%x\n", status);
     435                        /*snd_printk(KERN_DEBUG "I2C:status=0x%x\n", status);*/
    426436                        timeout++;
    427437                        if ((status & I2C_A_ADC_START) == 0)
     
    522532
    523533        channel->use = 1;
    524         //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel);
     534        /*
     535        printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
     536               channel_id, chip, channel);
     537        */
    525538        //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
    526539        channel->epcm = epcm;
     
    615628
    616629        channel->use = 1;
    617         //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel);
     630        /*
     631        printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
     632               channel_id, chip, channel);
     633        */
    618634        //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
    619635        channel->epcm = epcm;
     
    706722        int i;
    707723       
    708         //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1));
    709         //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base);
    710         //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
     724#if 0 /* debug */
     725        snd_printk(KERN_DEBUG
     726                   "prepare:channel_number=%d, rate=%d, format=0x%x, "
     727                   "channels=%d, buffer_size=%ld, period_size=%ld, "
     728                   "periods=%u, frames_to_bytes=%d\n",
     729                   channel, runtime->rate, runtime->format,
     730                   runtime->channels, runtime->buffer_size,
     731                   runtime->period_size, runtime->periods,
     732                   frames_to_bytes(runtime, 1));
     733        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
     734                   runtime->dma_addr, runtime->dma_area, table_base);
     735        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
     736                   emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
     737#endif /* debug */
    711738        /* Rate can be set per channel. */
    712739        /* reg40 control host to fifo */
     
    800827        u32 reg71;
    801828       
    802         //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1));
    803         //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base);
    804         //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
     829#if 0 /* debug */
     830        snd_printk(KERN_DEBUG
     831                   "prepare:channel_number=%d, rate=%d, format=0x%x, "
     832                   "channels=%d, buffer_size=%ld, period_size=%ld, "
     833                   "periods=%u, frames_to_bytes=%d\n",
     834                   channel, runtime->rate, runtime->format,
     835                   runtime->channels, runtime->buffer_size,
     836                   runtime->period_size, runtime->periods,
     837                   frames_to_bytes(runtime, 1));
     838        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
     839                   runtime->dma_addr, runtime->dma_area, table_base);
     840        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
     841                   emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
     842#endif /* debug */
    805843        /* reg71 controls ADC rate. */
    806844        switch (runtime->rate) {
     
    847885
    848886
    849         //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size,  frames_to_bytes(runtime, 1));
     887        /*
     888        printk(KERN_DEBUG
     889               "prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, "
     890               "buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",
     891               channel, runtime->rate, runtime->format, runtime->channels,
     892               runtime->buffer_size, runtime->period_size,
     893               frames_to_bytes(runtime, 1));
     894        */
    850895        snd_ca0106_ptr_write(emu, 0x13, channel, 0);
    851896        snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
     
    889934                epcm = runtime->private_data;
    890935                channel = epcm->channel_id;
    891                 /* snd_printk("channel=%d\n",channel); */
     936                /* snd_printk(KERN_DEBUG "channel=%d\n", channel); */
    892937                epcm->running = running;
    893938                basic |= (0x1 << channel);
     
    895940                snd_pcm_trigger_done(s, substream);
    896941        }
    897         /* snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); */
     942        /* snd_printk(KERN_DEBUG "basic=0x%x, extended=0x%x\n",basic, extended); */
    898943
    899944        switch (cmd) {
     
    9731018        if (ptr >= runtime->buffer_size)
    9741019                ptr -= runtime->buffer_size;
    975         //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate);
    976 
     1020        /*
     1021        printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
     1022               "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
     1023               ptr1, ptr2, ptr, (int)runtime->buffer_size,
     1024               (int)runtime->period_size, (int)runtime->frame_bits,
     1025               (int)runtime->rate);
     1026        */
    9771027        return ptr;
    9781028}
     
    9961046        if (ptr >= runtime->buffer_size)
    9971047                ptr -= runtime->buffer_size;
    998         //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate);
    999 
     1048        /*
     1049        printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
     1050               "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
     1051               ptr1, ptr2, ptr, (int)runtime->buffer_size,
     1052               (int)runtime->period_size, (int)runtime->frame_bits,
     1053               (int)runtime->rate);
     1054        */
    10001055        return ptr;
    10011056}
     
    11821237
    11831238        stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0);
    1184         //snd_printk("interrupt status = 0x%08x, stat76=0x%08x\n", status, stat76);
    1185         //snd_printk("ptr=0x%08x\n",snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0));
     1239        /*
     1240        snd_printk(KERN_DEBUG "interrupt status = 0x%08x, stat76=0x%08x\n",
     1241                   status, stat76);
     1242        snd_printk(KERN_DEBUG "ptr=0x%08x\n",
     1243                   snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0));
     1244        */
    11861245        mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */
    11871246        for(i = 0; i < 4; i++) {
     
    14711530
    14721531                size = ARRAY_SIZE(i2c_adc_init);
    1473                 /* snd_printk("I2C:array size=0x%x\n", size); */
     1532                /* snd_printk(KERN_DEBUG "I2C:array size=0x%x\n", size); */
    14741533                for (n = 0; n < size; n++)
    14751534                        snd_ca0106_i2c_write(chip, i2c_adc_init[n][0],
     
    15311590        if (err < 0)
    15321591                return err;
    1533         if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
    1534             pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
     1592        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
     1593            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
    15351594                printk(KERN_ERR "error to set 32bit mask DMA\n");
    15361595                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/cmipci.c

    r410 r426  
    30313031        };
    30323032        unsigned int val;
    3033         long iomidi;
     3033        long iomidi = 0;
    30343034        int integrated_midi = 0;
    30353035        char modelstr[16];
  • GPL/trunk/alsa-kernel/pci/cs4281.c

    r410 r426  
    835835        struct cs4281 *chip = snd_pcm_substream_chip(substream);
    836836
    837         // printk("DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n", snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size, jiffies);
     837        /*
     838        printk(KERN_DEBUG "DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n",
     839               snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size,
     840               jiffies);
     841        */
    838842        return runtime->buffer_size -
    839843               snd_cs4281_peekBA0(chip, dma->regDCC) - 1;
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c

    r410 r426  
    195195         */
    196196#if 0
    197         printk("e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
     197        printk(KERN_DEBUG "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
    198198                        snd_cs46xx_peekBA0(chip, BA0_ACSDA),
    199199                        snd_cs46xx_peekBA0(chip, BA0_ACCAD));
     
    429429 
    430430        if(status & SERBST_WBSY) {
    431                 snd_printk( KERN_ERR "cs46xx: failure waiting for FIFO command to complete\n");
    432 
     431                snd_printk(KERN_ERR "cs46xx: failure waiting for "
     432                           "FIFO command to complete\n");
    433433                return -EINVAL;
    434434        }
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.h

    r305 r426  
    6363        unsigned int offset = reg & 0xffff;
    6464
    65         /*if (bank == 0) printk("snd_cs46xx_poke: %04X - %08X\n",reg >> 2,val); */
     65        /*
     66        if (bank == 0)
     67                printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
     68                       reg >> 2,val);
     69        */
    6670        writel(val, chip->region.idx[bank+1].remap_addr + offset);
    6771}
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_callback.c

    r399 r426  
    104104                        vp = &emu->voices[best[i].voice];
    105105                        if ((ch = vp->ch) < 0) {
    106                                 //printk("synth_get_voice: ch < 0 (%d) ??", i);
     106                                /*
     107                                printk(KERN_WARNING
     108                                       "synth_get_voice: ch < 0 (%d) ??", i);
     109                                */
    107110                                continue;
    108111                        }
     
    336339        emem->map_locked++;
    337340        if (snd_emu10k1_memblk_map(hw, emem) < 0) {
    338                 // printk("emu: cannot map!\n");
     341                /* printk(KERN_ERR "emu: cannot map!\n"); */
    339342                return -ENOMEM;
    340343        }
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_main.c

    r402 r426  
    715715{
    716716        struct snd_emu10k1 *emu = data;
    717         int tmp, tmp2;
    718         int reg;
     717        u32 tmp, tmp2, reg;
    719718        int err;
    720719
     
    762761                        snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp);
    763762                        snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2);
    764                         snd_printk("Audio Dock ver:%d.%d\n", tmp, tmp2);
     763                        snd_printk(KERN_INFO "Audio Dock ver: %u.%u\n",
     764                                   tmp, tmp2);
    765765                        /* Sync clocking between 1010 and Dock */
    766766                        /* Allow DLL to settle */
     
    808808{
    809809        unsigned int i;
    810         int tmp, tmp2;
    811         int reg;
     810        u32 tmp, tmp2, reg;
    812811        int err;
    813812        const char *filename = NULL;
     
    891890        snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp);
    892891        snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2);
    893         snd_printk("emu1010: Hana version: %d.%d\n", tmp, tmp2);
     892        snd_printk(KERN_INFO "emu1010: Hana version: %u.%u\n", tmp, tmp2);
    894893        /* Enable 48Volt power to Audio Dock */
    895894        snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON);
     
    15321531         .spk71 = 1,
    15331532         .spdif_bug = 1,
     1533         .invert_shared_spdif = 1,      /* digital/analog switch swapped */
    15341534         .ac97_chip = 1} ,
    15351535        {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c

    r410 r426  
    898898        if ((err = pci_enable_device(pci)) < 0)
    899899                return err;
    900         if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
    901             pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
     900        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
     901            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
    902902                snd_printk(KERN_ERR "error to set 28bit mask DMA\n");
    903903                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/emu10k1/emufx.c

    r399 r426  
    15201520        if (emu->card_capabilities->emu_model) {
    15211521                /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */
    1522                 snd_printk("EMU outputs on\n");
     1522                snd_printk(KERN_INFO "EMU outputs on\n");
    15231523                for (z = 0; z < 8; z++) {
    15241524                        if (emu->card_capabilities->ca0108_chip) {
     
    15681568        if (emu->card_capabilities->emu_model) {
    15691569                if (emu->card_capabilities->ca0108_chip) {
    1570                         snd_printk("EMU2 inputs on\n");
     1570                        snd_printk(KERN_INFO "EMU2 inputs on\n");
    15711571                        for (z = 0; z < 0x10; z++) {
    15721572                                snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp,
     
    15761576                        }
    15771577                } else {
    1578                         snd_printk("EMU inputs on\n");
     1578                        snd_printk(KERN_INFO "EMU inputs on\n");
    15791579                        /* Capture 16 (originally 8) channels of S32_LE sound */
    15801580
    1581                         /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */
     1581                        /*
     1582                        printk(KERN_DEBUG "emufx.c: gpr=0x%x, tmp=0x%x\n",
     1583                               gpr, tmp);
     1584                        */
    15821585                        /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
    15831586                        /* A_P16VIN(0) is delayed by one sample,
     
    24912494                if (!capable(CAP_SYS_ADMIN))
    24922495                        return -EPERM;
    2493                 icode = kmalloc(sizeof(*icode), GFP_KERNEL);
    2494                 if (icode == NULL)
    2495                         return -ENOMEM;
    2496                 if (copy_from_user(icode, argp, sizeof(*icode))) {
    2497                         kfree(icode);
    2498                         return -EFAULT;
    2499                 }
     2496
     2497                icode = memdup_user(argp, sizeof(*icode));
     2498                if (IS_ERR(icode))
     2499                        return PTR_ERR(icode);
    25002500                res = snd_emu10k1_icode_poke(emu, icode);
    25012501                kfree(icode);
    25022502                return res;
    25032503        case SNDRV_EMU10K1_IOCTL_CODE_PEEK:
    2504                 icode = kmalloc(sizeof(*icode), GFP_KERNEL);
    2505                 if (icode == NULL)
    2506                         return -ENOMEM;
    2507                 if (copy_from_user(icode, argp, sizeof(*icode))) {
    2508                         kfree(icode);
    2509                         return -EFAULT;
    2510                 }
     2504                icode = memdup_user(argp, sizeof(*icode));
     2505                if (IS_ERR(icode))
     2506                        return PTR_ERR(icode);
    25112507                res = snd_emu10k1_icode_peek(emu, icode);
    25122508                if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) {
     
    25172513                return res;
    25182514        case SNDRV_EMU10K1_IOCTL_PCM_POKE:
    2519                 ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL);
    2520                 if (ipcm == NULL)
    2521                         return -ENOMEM;
    2522                 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
    2523                         kfree(ipcm);
    2524                         return -EFAULT;
    2525                 }
     2515                ipcm = memdup_user(argp, sizeof(*ipcm));
     2516                if (IS_ERR(ipcm))
     2517                        return PTR_ERR(ipcm);
    25262518                res = snd_emu10k1_ipcm_poke(emu, ipcm);
    25272519                kfree(ipcm);
    25282520                return res;
    25292521        case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
    2530                 ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
    2531                 if (ipcm == NULL)
    2532                         return -ENOMEM;
    2533                 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
    2534                         kfree(ipcm);
    2535                         return -EFAULT;
    2536                 }
     2522                ipcm = memdup_user(argp, sizeof(*ipcm));
     2523                if (IS_ERR(ipcm))
     2524                        return PTR_ERR(ipcm);
    25372525                res = snd_emu10k1_ipcm_peek(emu, ipcm);
    25382526                if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) {
  • GPL/trunk/alsa-kernel/pci/emu10k1/emupcm.c

    r305 r426  
    4545                return;
    4646#if 0
    47         printk("IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
     47        printk(KERN_DEBUG "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
    4848                        epcm->substream->runtime->hw->pointer(emu, epcm->substream),
    4949                        snd_pcm_lib_period_bytes(epcm->substream),
     
    147147                                              &epcm->extra);
    148148                if (err < 0) {
    149                         /* printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); */
     149                        /*
     150                        printk(KERN_DEBUG "pcm_channel_alloc: "
     151                               "failed extra: voices=%d, frame=%d\n",
     152                               voices, frame);
     153                        */
    150154                        for (i = 0; i < voices; i++) {
    151155                                snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]);
     
    738742        int result = 0;
    739743
    740         /* printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); */
     744        /*
     745        printk(KERN_DEBUG "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n",
     746               (int)emu, cmd, substream->ops->pointer(substream))
     747        */
    741748        spin_lock(&emu->reg_lock);
    742749        switch (cmd) {
     
    787794                outl(epcm->capture_ipr, emu->port + IPR);
    788795                snd_emu10k1_intr_enable(emu, epcm->capture_inte);
    789                 /* printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); */
     796                /*
     797                printk(KERN_DEBUG "adccr = 0x%x, adcbs = 0x%x\n",
     798                       epcm->adccr, epcm->adcbs);
     799                */
    790800                switch (epcm->type) {
    791801                case CAPTURE_AC97ADC:
     
    858868        }
    859869#endif
    860         /* printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); */
     870        /*
     871        printk(KERN_DEBUG
     872               "ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n",
     873               ptr, runtime->buffer_size, runtime->period_size);
     874        */
    861875        return ptr;
    862876}
     
    15471561                                                   unsigned int tram_shift)
    15481562{
    1549         /* printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); */
     1563        /*
     1564        printk(KERN_DEBUG "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, "
     1565               "src = 0x%p, count = 0x%x\n",
     1566               dst_left, dst_right, src, count);
     1567        */
    15501568        if ((tram_shift & 1) == 0) {
    15511569                while (count--) {
     
    16241642        unsigned int i;
    16251643       
    1626         /* printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); */
     1644        /*
     1645        printk(KERN_DEBUG "prepare: etram_pages = 0x%p, dma_area = 0x%x, "
     1646               "buffer_size = 0x%x (0x%x)\n",
     1647               emu->fx8010.etram_pages, runtime->dma_area,
     1648               runtime->buffer_size, runtime->buffer_size << 2);
     1649        */
    16271650        memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec));
    16281651        pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */
  • GPL/trunk/alsa-kernel/pci/emu10k1/io.c

    r305 r426  
    227227
    228228                        if (timeout > 1000) {
    229                                 snd_printk("emu10k1:I2C:timeout status=0x%x\n", status);
     229                                snd_printk(KERN_WARNING
     230                                           "emu10k1:I2C:timeout status=0x%x\n",
     231                                           status);
    230232                                break;
    231233                        }
     
    489491                                break;
    490492                }
    491                 if (count >= 16384)
     493                if (count > 16384)
    492494                        break;
    493495                curtime = newtime;
  • GPL/trunk/alsa-kernel/pci/emu10k1/p16v.c

    r305 r426  
    169169 
    170170        if (epcm) {
    171                 //snd_printk("epcm free: %p\n", epcm);
     171                /* snd_printk(KERN_DEBUG "epcm free: %p\n", epcm); */
    172172                kfree(epcm);
    173173        }
     
    184184
    185185        epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
    186         //snd_printk("epcm kcalloc: %p\n", epcm);
     186        /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */
    187187
    188188        if (epcm == NULL)
     
    190190        epcm->emu = emu;
    191191        epcm->substream = substream;
    192         //snd_printk("epcm device=%d, channel_id=%d\n", substream->pcm->device, channel_id);
    193  
     192        /*
     193        snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n",
     194                   substream->pcm->device, channel_id);
     195        */
    194196        runtime->private_data = epcm;
    195197        runtime->private_free = snd_p16v_pcm_free_substream;
     
    201203
    202204        channel->use=1;
    203         //snd_printk("p16v: open channel_id=%d, channel=%p, use=0x%x\n", channel_id, channel, channel->use);
    204         //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel);
    205         //channel->interrupt = snd_p16v_pcm_channel_interrupt;
    206         channel->epcm=epcm;
     205#if 0 /* debug */
     206        snd_printk(KERN_DEBUG
     207                   "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
     208                   channel_id, channel, channel->use);
     209        printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
     210               channel_id, chip, channel);
     211#endif /* debug */
     212        /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
     213        channel->epcm = epcm;
    207214        if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
    208215                return err;
     
    225232
    226233        epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
    227         //snd_printk("epcm kcalloc: %p\n", epcm);
     234        /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */
    228235
    229236        if (epcm == NULL)
     
    231238        epcm->emu = emu;
    232239        epcm->substream = substream;
    233         //snd_printk("epcm device=%d, channel_id=%d\n", substream->pcm->device, channel_id);
    234 
     240        /*
     241        snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n",
     242                   substream->pcm->device, channel_id);
     243        */
    235244        runtime->private_data = epcm;
    236245        runtime->private_free = snd_p16v_pcm_free_substream;
     
    242251
    243252        channel->use=1;
    244         //snd_printk("p16v: open channel_id=%d, channel=%p, use=0x%x\n", channel_id, channel, channel->use);
    245         //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel);
    246         //channel->interrupt = snd_p16v_pcm_channel_interrupt;
    247         channel->epcm=epcm;
     253#if 0 /* debug */
     254        snd_printk(KERN_DEBUG
     255                   "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
     256                   channel_id, channel, channel->use);
     257        printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
     258               channel_id, chip, channel);
     259#endif /* debug */
     260        /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
     261        channel->epcm = epcm;
    248262        if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
    249263                return err;
     
    335349        u32 tmp;
    336350       
    337         //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1));
    338         //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base);
    339         //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->p16v_buffer.addr, emu->p16v_buffer.area, emu->p16v_buffer.bytes);
     351#if 0 /* debug */
     352        snd_printk(KERN_DEBUG "prepare:channel_number=%d, rate=%d, "
     353                   "format=0x%x, channels=%d, buffer_size=%ld, "
     354                   "period_size=%ld, periods=%u, frames_to_bytes=%d\n",
     355                   channel, runtime->rate, runtime->format, runtime->channels,
     356                   runtime->buffer_size, runtime->period_size,
     357                   runtime->periods, frames_to_bytes(runtime, 1));
     358        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
     359                   runtime->dma_addr, runtime->dma_area, table_base);
     360        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
     361                   emu->p16v_buffer.addr, emu->p16v_buffer.area,
     362                   emu->p16v_buffer.bytes);
     363#endif /* debug */
    340364        tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel);
    341365        switch (runtime->rate) {
     
    380404        int channel = substream->pcm->device - emu->p16v_device_offset;
    381405        u32 tmp;
    382         //printk("prepare capture:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size,  frames_to_bytes(runtime, 1));
     406
     407        /*
     408        printk(KERN_DEBUG "prepare capture:channel_number=%d, rate=%d, "
     409               "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, "
     410               "frames_to_bytes=%d\n",
     411               channel, runtime->rate, runtime->format, runtime->channels,
     412               runtime->buffer_size, runtime->period_size,
     413               frames_to_bytes(runtime, 1));
     414        */
    383415        tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel);
    384416        switch (runtime->rate) {
     
    460492                epcm = runtime->private_data;
    461493                channel = substream->pcm->device-emu->p16v_device_offset;
    462                 //snd_printk("p16v channel=%d\n",channel);
     494                /* snd_printk(KERN_DEBUG "p16v channel=%d\n", channel); */
    463495                epcm->running = running;
    464496                basic |= (0x1<<channel);
     
    466498                snd_pcm_trigger_done(s, substream);
    467499        }
    468         //snd_printk("basic=0x%x, inte=0x%x\n",basic, inte);
     500        /* snd_printk(KERN_DEBUG "basic=0x%x, inte=0x%x\n", basic, inte); */
    469501
    470502        switch (cmd) {
     
    559591                printk(KERN_WARNING "buffer capture limited!\n");
    560592        }
    561         //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate);
    562 
     593        /*
     594        printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
     595               "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
     596               ptr1, ptr2, ptr, (int)runtime->buffer_size,
     597               (int)runtime->period_size, (int)runtime->frame_bits,
     598               (int)runtime->rate);
     599        */
    563600        return ptr;
    564601}
     
    593630        if (chip->p16v_buffer.area) {
    594631                snd_dma_free_pages(&chip->p16v_buffer);
    595                 //snd_printk("period lables free: %p\n", &chip->p16v_buffer);
     632                /*
     633                snd_printk(KERN_DEBUG "period lables free: %p\n",
     634                           &chip->p16v_buffer);
     635                */
    596636        }
    597637        return 0;
     
    605645        int capture=1;
    606646 
    607         //snd_printk("snd_p16v_pcm called. device=%d\n", device);
     647        /* snd_printk("KERN_DEBUG snd_p16v_pcm called. device=%d\n", device); */
    608648        emu->p16v_device_offset = device;
    609649        if (rpcm)
     
    632672                                                         ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0)
    633673                        return err;
    634                 //snd_printk("preallocate playback substream: err=%d\n", err);
     674                /*
     675                snd_printk(KERN_DEBUG
     676                           "preallocate playback substream: err=%d\n", err);
     677                */
    635678        }
    636679
     
    643686                                                   65536 - 64, 65536 - 64)) < 0)
    644687                        return err;
    645                 //snd_printk("preallocate capture substream: err=%d\n", err);
     688                /*
     689                snd_printk(KERN_DEBUG
     690                           "preallocate capture substream: err=%d\n", err);
     691                */
    646692        }
    647693 
  • GPL/trunk/alsa-kernel/pci/emu10k1/voice.c

    r399 r426  
    5454        first_voice = last_voice = 0;
    5555        for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) {
    56                 // printk("i %d j %d next free %d!\n", i, j, emu->next_free_voice);
     56                /*
     57                printk(KERN_DEBUG "i %d j %d next free %d!\n",
     58                       i, j, emu->next_free_voice);
     59                */
    5760                i %= NUM_G;
    5861
     
    7275                }
    7376                if (!skip) {
    74                         // printk("allocated voice %d\n", i);
     77                        /* printk(KERN_DEBUG "allocated voice %d\n", i); */
    7578                        first_voice = i;
    7679                        last_voice = (i + number) % NUM_G;
     
    8588        for (i = 0; i < number; i++) {
    8689                voice = &emu->voices[(first_voice + i) % NUM_G];
    87                 // printk("voice alloc - %i, %i of %i\n", voice->number, idx-first_voice+1, number);
     90                /*
     91                printk(kERN_DEBUG "voice alloc - %i, %i of %i\n",
     92                       voice->number, idx-first_voice+1, number);
     93                */
    8894                voice->use = 1;
    8995                switch (type) {
  • GPL/trunk/alsa-kernel/pci/ens1370.c

    r410 r426  
    585585
    586586#if 0
    587         printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n",
     587        printk(KERN_DEBUG
     588               "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n",
    588589               reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
    589590#endif
  • GPL/trunk/alsa-kernel/pci/es1938.c

    r410 r426  
    16091609                return err;
    16101610        /* check, if we can restrict PCI DMA transfers to 24 bits */
    1611         if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 ||
    1612             pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) {
     1611        if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
     1612            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
    16131613                snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
    16141614                pci_disable_device(pci);
     
    16741674        status = inb(SLIO_REG(chip, IRQCONTROL));
    16751675#if 0
    1676         printk("Es1938debug - interrupt status: =0x%x\n", status);
     1676        printk(KERN_DEBUG "Es1938debug - interrupt status: =0x%x\n", status);
    16771677#endif
    16781678       
     
    16801680        if (status & 0x10) {
    16811681#if 0
    1682                 printk("Es1938debug - AUDIO channel 1 interrupt\n");
    1683                 printk("Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n",
     1682                printk(KERN_DEBUG
     1683                       "Es1938debug - AUDIO channel 1 interrupt\n");
     1684                printk(KERN_DEBUG
     1685                       "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n",
    16841686                       inw(SLDM_REG(chip, DMACOUNT)));
    1685                 printk("Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n",
     1687                printk(KERN_DEBUG
     1688                       "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n",
    16861689                       inl(SLDM_REG(chip, DMAADDR)));
    1687                 printk("Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n",
     1690                printk(KERN_DEBUG
     1691                       "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n",
    16881692                       inl(SLDM_REG(chip, DMASTATUS)));
    16891693#endif
     
    17001704        if (status & 0x20) {
    17011705#if 0
    1702                 printk("Es1938debug - AUDIO channel 2 interrupt\n");
    1703                 printk("Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n",
     1706                printk(KERN_DEBUG
     1707                       "Es1938debug - AUDIO channel 2 interrupt\n");
     1708                printk(KERN_DEBUG
     1709                       "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n",
    17041710                       inw(SLIO_REG(chip, AUDIO2DMACOUNT)));
    1705                 printk("Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n",
     1711                printk(KERN_DEBUG
     1712                       "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n",
    17061713                       inl(SLIO_REG(chip, AUDIO2DMAADDR)));
    17071714
  • GPL/trunk/alsa-kernel/pci/es1968.c

    r410 r426  
    25492549                return err;
    25502550        /* check, if we can restrict PCI DMA transfers to 28 bits */
    2551         if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
    2552             pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
     2551        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
     2552            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
    25532553                snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
    25542554                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/hda/hda_beep.h

    r417 r426  
    3232        int tone;
    3333        int nid;
     34        int enabled;
    3435        struct work_struct beep_work; /* scheduled task for beep event */
    3536};
     
    3940void snd_hda_detach_beep_device(struct hda_codec *codec);
    4041#else
    41 #define snd_hda_attach_beep_device(...)
     42#define snd_hda_attach_beep_device(...)         0
    4243#define snd_hda_detach_beep_device(...)
    4344#endif
  • GPL/trunk/alsa-kernel/pci/hda/hda_codec.c

    r417 r426  
    3232#include "hda_local.h"
    3333#include <sound/hda_hwdep.h>
    34 #include "hda_patch.h"  /* codec presets */
    35 
    36 #ifdef CONFIG_SND_HDA_POWER_SAVE
    37 /* define this option here to hide as static */
    38 static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
    39 module_param(power_save, int, 0644);
    40 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
    41                  "(in second, 0 = disable).");
    42 #endif
    4334
    4435/*
     
    5647        { 0x1057, "Motorola" },
    5748        { 0x1095, "Silicon Image" },
     49        { 0x10de, "Nvidia" },
    5850        { 0x10ec, "Realtek" },
    5951        { 0x1106, "VIA" },
     
    6759        { 0x1aec, "Wolfson Microelectronics" },
    6860        { 0x434d, "C-Media" },
     61        { 0x8086, "Intel" },
    6962        { 0x8384, "SigmaTel" },
    7063        {0} /* terminator */
    7164};
    7265
    73 static const struct hda_codec_preset *hda_preset_tables[] = {
    74 #ifdef CONFIG_SND_HDA_CODEC_REALTEK
    75         snd_hda_preset_realtek,
    76 #endif
    77 #ifdef CONFIG_SND_HDA_CODEC_CMEDIA
    78         snd_hda_preset_cmedia,
    79 #endif
    80 #ifdef CONFIG_SND_HDA_CODEC_ANALOG
    81         snd_hda_preset_analog,
    82 #endif
    83 #ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
    84         snd_hda_preset_sigmatel,
    85 #endif
    86 #ifdef CONFIG_SND_HDA_CODEC_SI3054
    87         snd_hda_preset_si3054,
    88 #endif
    89 #ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
    90         snd_hda_preset_atihdmi,
    91 #endif
    92 #ifdef CONFIG_SND_HDA_CODEC_CONEXANT
    93         snd_hda_preset_conexant,
    94 #endif
    95 #ifdef CONFIG_SND_HDA_CODEC_VIA
    96         snd_hda_preset_via,
    97 #endif
    98 #ifdef CONFIG_SND_HDA_CODEC_NVHDMI
    99         snd_hda_preset_nvhdmi,
    100 #endif
    101 #ifdef CONFIG_SND_HDA_CODEC_INTELHDMI
    102         snd_hda_preset_intelhdmi,
    103 #endif
    104         NULL
    105 };
     66static DEFINE_MUTEX(preset_mutex);
     67static LIST_HEAD(hda_preset_tables);
     68
     69int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset)
     70{
     71        mutex_lock(&preset_mutex);
     72        list_add_tail(&preset->list, &hda_preset_tables);
     73        mutex_unlock(&preset_mutex);
     74        return 0;
     75}
     76EXPORT_SYMBOL_HDA(snd_hda_add_codec_preset);
     77
     78int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset)
     79{
     80        mutex_lock(&preset_mutex);
     81        list_del(&preset->list);
     82        mutex_unlock(&preset_mutex);
     83        return 0;
     84}
     85EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset);
    10686
    10787#ifdef CONFIG_SND_HDA_POWER_SAVE
     
    137117        return "UNKNOWN";
    138118}
     119EXPORT_SYMBOL_HDA(snd_hda_get_jack_location);
    139120
    140121const char *snd_hda_get_jack_connectivity(u32 cfg)
     
    144125        return jack_locations[(cfg >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3];
    145126}
     127EXPORT_SYMBOL_HDA(snd_hda_get_jack_connectivity);
    146128
    147129const char *snd_hda_get_jack_type(u32 cfg)
     
    157139                                >> AC_DEFCFG_DEVICE_SHIFT];
    158140}
     141EXPORT_SYMBOL_HDA(snd_hda_get_jack_type);
    159142
    160143/*
     
    205188        return res;
    206189}
     190EXPORT_SYMBOL_HDA(snd_hda_codec_read);
    207191
    208192/**
     
    233217        return err;
    234218}
     219EXPORT_SYMBOL_HDA(snd_hda_codec_write);
    235220
    236221/**
     
    247232                snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
    248233}
     234EXPORT_SYMBOL_HDA(snd_hda_sequence_write);
    249235
    250236/**
     
    268254        return (int)(parm & 0x7fff);
    269255}
     256EXPORT_SYMBOL_HDA(snd_hda_get_sub_nodes);
    270257
    271258/**
     
    356343        return conns;
    357344}
     345EXPORT_SYMBOL_HDA(snd_hda_get_connections);
    358346
    359347
     
    386374        unsol->queue[wp + 1] = res_ex;
    387375
    388 /* 2.4 kernels seem to have a problem with workq wrapper... */
    389 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    390         schedule_work(&unsol->work);
    391 #endif
    392         return 0;
    393 }
     376        queue_work(bus->workq, &unsol->work);
     377
     378        return 0;
     379}
     380EXPORT_SYMBOL_HDA(snd_hda_queue_unsol_event);
    394381
    395382/*
     
    453440        if (!bus)
    454441                return 0;
    455         if (bus->unsol) {
    456 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    457                 flush_scheduled_work();
    458 #endif
     442        if (bus->workq)
     443                flush_workqueue(bus->workq);
     444        if (bus->unsol)
    459445                kfree(bus->unsol);
    460         }
    461446        list_for_each_entry_safe(codec, n, &bus->codec_list, list, struct hda_codec) {
    462447                snd_hda_codec_free(codec);
     
    464449        if (bus->ops.private_free)
    465450                bus->ops.private_free(bus);
     451        if (bus->workq)
     452                destroy_workqueue(bus->workq);
    466453        kfree(bus);
    467454        return 0;
     
    471458{
    472459        struct hda_bus *bus = device->device_data;
     460        bus->shutdown = 1;
    473461        return snd_hda_bus_free(bus);
    474462}
     
    496484 * Returns 0 if successful, or a negative error code.
    497485 */
    498 int __devinit snd_hda_bus_new(struct snd_card *card,
     486int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
    499487                              const struct hda_bus_template *temp,
    500488                              struct hda_bus **busp)
     
    525513        bus->pci = temp->pci;
    526514        bus->modelname = temp->modelname;
     515        bus->power_save = temp->power_save;
    527516        bus->ops = temp->ops;
    528517
    529518        mutex_init(&bus->cmd_mutex);
    530519        INIT_LIST_HEAD(&bus->codec_list);
     520
     521        snprintf(bus->workq_name, sizeof(bus->workq_name),
     522                 "hd-audio%d", card->number);
     523        bus->workq = create_singlethread_workqueue(bus->workq_name);
     524        if (!bus->workq) {
     525                snd_printk(KERN_ERR "cannot create workqueue %s\n",
     526                           bus->workq_name);
     527                kfree(bus);
     528                return -ENOMEM;
     529        }
    531530
    532531        err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
     
    539538        return 0;
    540539}
     540EXPORT_SYMBOL_HDA(snd_hda_bus_new);
    541541
    542542#ifdef CONFIG_SND_HDA_GENERIC
     
    547547#endif
    548548
     549#if defined(MODULE) && !defined(TARGET_OS2)
     550#define HDA_MODREQ_MAX_COUNT    2       /* two request_modules()'s */
     551#else
     552#define HDA_MODREQ_MAX_COUNT    0       /* all presets are statically linked */
     553#endif
     554
    549555/*
    550556 * find a matching codec preset
     
    553559find_codec_preset(struct hda_codec *codec)
    554560{
    555         const struct hda_codec_preset **tbl, *preset;
     561        struct hda_codec_preset_list *tbl;
     562        const struct hda_codec_preset *preset;
     563        int mod_requested = 0;
    556564
    557565        if (is_generic_config(codec))
    558566                return NULL; /* use the generic parser */
    559567
    560         for (tbl = hda_preset_tables; *tbl; tbl++) {
    561                 for (preset = *tbl; preset->id; preset++) {
     568 again:
     569        mutex_lock(&preset_mutex);
     570        list_for_each_entry(tbl, &hda_preset_tables, list, struct hda_codec_preset_list) {
     571                if (!try_module_get(tbl->owner)) {
     572                        snd_printk(KERN_ERR "hda_codec: cannot module_get\n");
     573                        continue;
     574                }
     575                for (preset = tbl->preset; preset->id; preset++) {
    562576                        u32 mask = preset->mask;
    563577                        if (preset->afg && preset->afg != codec->afg)
     
    569583                        if (preset->id == (codec->vendor_id & mask) &&
    570584                            (!preset->rev ||
    571                              preset->rev == codec->revision_id))
     585                             preset->rev == codec->revision_id)) {
     586                                mutex_unlock(&preset_mutex);
     587                                codec->owner = tbl->owner;
    572588                                return preset;
    573                 }
    574         }
     589                        }
     590                }
     591                module_put(tbl->owner);
     592        }
     593        mutex_unlock(&preset_mutex);
     594
     595#ifndef TARGET_OS2
     596        if (mod_requested < HDA_MODREQ_MAX_COUNT) {
     597                char name[32];
     598                if (!mod_requested)
     599                        snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
     600                                 codec->vendor_id);
     601                else
     602                        snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
     603                                 (codec->vendor_id >> 16) & 0xffff);
     604                request_module(name);
     605                mod_requested++;
     606                goto again;
     607        }
     608#endif
    575609        return NULL;
    576610}
     
    611645 * look for an AFG and MFG nodes
    612646 */
    613 static void __devinit setup_fg_nodes(struct hda_codec *codec)
    614 {
    615         int i, total_nodes;
     647static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec)
     648{
     649        int i, total_nodes, function_id;
    616650        hda_nid_t nid;
    617651
    618652        total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
    619653        for (i = 0; i < total_nodes; i++, nid++) {
    620                 unsigned int func;
    621                 func = snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE);
    622                 switch (func & 0xff) {
     654                function_id = snd_hda_param_read(codec, nid,
     655                                                AC_PAR_FUNCTION_TYPE) & 0xff;
     656                switch (function_id) {
    623657                case AC_GRP_AUDIO_FUNCTION:
    624658                        codec->afg = nid;
     659                        codec->function_id = function_id;
    625660                        break;
    626661                case AC_GRP_MODEM_FUNCTION:
    627662                        codec->mfg = nid;
     663                        codec->function_id = function_id;
    628664                        break;
    629665                default:
     
    653689}
    654690
     691/* read all pin default configurations and save codec->init_pins */
     692static int read_pin_defaults(struct hda_codec *codec)
     693{
     694        int i;
     695        hda_nid_t nid = codec->start_nid;
     696
     697        for (i = 0; i < codec->num_nodes; i++, nid++) {
     698                struct hda_pincfg *pin;
     699                unsigned int wcaps = get_wcaps(codec, nid);
     700                unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >>
     701                                AC_WCAP_TYPE_SHIFT;
     702                if (wid_type != AC_WID_PIN)
     703                        continue;
     704                pin = snd_array_new(&codec->init_pins);
     705                if (!pin)
     706                        return -ENOMEM;
     707                pin->nid = nid;
     708                pin->cfg = snd_hda_codec_read(codec, nid, 0,
     709                                              AC_VERB_GET_CONFIG_DEFAULT, 0);
     710        }
     711        return 0;
     712}
     713
     714/* look up the given pin config list and return the item matching with NID */
     715static struct hda_pincfg *look_up_pincfg(struct hda_codec *codec,
     716                                         struct snd_array *array,
     717                                         hda_nid_t nid)
     718{
     719        int i;
     720        for (i = 0; i < array->used; i++) {
     721                struct hda_pincfg *pin = snd_array_elem(array, i);
     722                if (pin->nid == nid)
     723                        return pin;
     724        }
     725        return NULL;
     726}
     727
     728/* write a config value for the given NID */
     729static void set_pincfg(struct hda_codec *codec, hda_nid_t nid,
     730                       unsigned int cfg)
     731{
     732        int i;
     733        for (i = 0; i < 4; i++) {
     734                snd_hda_codec_write(codec, nid, 0,
     735                                    AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
     736                                    cfg & 0xff);
     737                cfg >>= 8;
     738        }
     739}
     740
     741/* set the current pin config value for the given NID.
     742 * the value is cached, and read via snd_hda_codec_get_pincfg()
     743 */
     744int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
     745                       hda_nid_t nid, unsigned int cfg)
     746{
     747        struct hda_pincfg *pin;
     748        unsigned int oldcfg;
     749
     750        oldcfg = snd_hda_codec_get_pincfg(codec, nid);
     751        pin = look_up_pincfg(codec, list, nid);
     752        if (!pin) {
     753                pin = snd_array_new(list);
     754                if (!pin)
     755                        return -ENOMEM;
     756                pin->nid = nid;
     757        }
     758        pin->cfg = cfg;
     759
     760        /* change only when needed; e.g. if the pincfg is already present
     761         * in user_pins[], don't write it
     762         */
     763        cfg = snd_hda_codec_get_pincfg(codec, nid);
     764        if (oldcfg != cfg)
     765                set_pincfg(codec, nid, cfg);
     766        return 0;
     767}
     768
     769int snd_hda_codec_set_pincfg(struct hda_codec *codec,
     770                             hda_nid_t nid, unsigned int cfg)
     771{
     772        return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg);
     773}
     774EXPORT_SYMBOL_HDA(snd_hda_codec_set_pincfg);
     775
     776/* get the current pin config value of the given pin NID */
     777unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
     778{
     779        struct hda_pincfg *pin;
     780
     781#ifdef CONFIG_SND_HDA_HWDEP
     782        pin = look_up_pincfg(codec, &codec->user_pins, nid);
     783        if (pin)
     784                return pin->cfg;
     785#endif
     786        pin = look_up_pincfg(codec, &codec->driver_pins, nid);
     787        if (pin)
     788                return pin->cfg;
     789        pin = look_up_pincfg(codec, &codec->init_pins, nid);
     790        if (pin)
     791                return pin->cfg;
     792        return 0;
     793}
     794EXPORT_SYMBOL_HDA(snd_hda_codec_get_pincfg);
     795
     796/* restore all current pin configs */
     797static void restore_pincfgs(struct hda_codec *codec)
     798{
     799        int i;
     800        for (i = 0; i < codec->init_pins.used; i++) {
     801                struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
     802                set_pincfg(codec, pin->nid,
     803                           snd_hda_codec_get_pincfg(codec, pin->nid));
     804        }
     805}
    655806
    656807static void init_hda_cache(struct hda_cache_rec *cache,
     
    658809static void free_hda_cache(struct hda_cache_rec *cache);
    659810
     811/* restore the initial pin cfgs and release all pincfg lists */
     812static void restore_init_pincfgs(struct hda_codec *codec)
     813{
     814        /* first free driver_pins and user_pins, then call restore_pincfg
     815         * so that only the values in init_pins are restored
     816         */
     817        snd_array_free(&codec->driver_pins);
     818#ifdef CONFIG_SND_HDA_HWDEP
     819        snd_array_free(&codec->user_pins);
     820#endif
     821        restore_pincfgs(codec);
     822        snd_array_free(&codec->init_pins);
     823}
     824
    660825/*
    661826 * codec destructor
     
    665830        if (!codec)
    666831                return;
     832        restore_init_pincfgs(codec);
    667833#ifdef CONFIG_SND_HDA_POWER_SAVE
    668834        cancel_delayed_work(&codec->power_work);
    669         flush_scheduled_work();
     835        flush_workqueue(codec->bus->workq);
    670836#endif
    671837        list_del(&codec->list);
     
    674840        if (codec->patch_ops.free)
    675841                codec->patch_ops.free(codec);
     842        module_put(codec->owner);
    676843        free_hda_cache(&codec->amp_cache);
    677844        free_hda_cache(&codec->cmd_cache);
     
    682849}
    683850
     851static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
     852                                unsigned int power_state);
     853
    684854/**
    685855 * snd_hda_codec_new - create a HDA codec
     
    690860 * Returns 0 if successful, or a negative error code.
    691861 */
    692 int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
    693                                 struct hda_codec **codecp)
     862int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
     863                                    int do_init, struct hda_codec **codecp)
    694864{
    695865        struct hda_codec *codec;
     
    717887        codec->addr = codec_addr;
    718888        mutex_init(&codec->spdif_mutex);
     889        mutex_init(&codec->control_mutex);
    719890        init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
    720891        init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
    721892        snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32);
     893        snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
     894        snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
    722895        if (codec->bus->modelname) {
    723896                codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
     
    756929        if (!codec->afg && !codec->mfg) {
    757930                snd_printdd("hda_codec: no AFG or MFG node found\n");
    758                 snd_hda_codec_free(codec);
    759                 return -ENODEV;
    760         }
    761 
    762         if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) {
     931                err = -ENODEV;
     932                goto error;
     933        }
     934
     935        err = read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg);
     936        if (err < 0) {
    763937                snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
    764                 snd_hda_codec_free(codec);
    765                 return -ENOMEM;
    766         }
     938                goto error;
     939        }
     940        err = read_pin_defaults(codec);
     941        if (err < 0)
     942                goto error;
    767943
    768944        if (!codec->subsystem_id) {
     
    775951                codec->modelname = kstrdup(bus->modelname, GFP_KERNEL);
    776952
    777         err = snd_hda_codec_configure(codec);
    778         if (err < 0) {
    779                 snd_hda_codec_free(codec);
    780                 return err;
     953        /* power-up all before initialization */
     954        hda_set_power_state(codec,
     955                            codec->afg ? codec->afg : codec->mfg,
     956                            AC_PWRST_D0);
     957
     958        if (do_init) {
     959                err = snd_hda_codec_configure(codec);
     960                if (err < 0)
     961                        goto error;
    781962        }
    782963        snd_hda_codec_proc_new(codec);
     
    791972                *codecp = codec;
    792973        return 0;
    793 }
     974
     975 error:
     976        snd_hda_codec_free(codec);
     977        return err;
     978}
     979EXPORT_SYMBOL_HDA(snd_hda_codec_new);
    794980
    795981int snd_hda_codec_configure(struct hda_codec *codec)
     
    8511037        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
    8521038}
     1039EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream);
    8531040
    8541041void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
     
    8641051#endif
    8651052}
     1053EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream);
    8661054
    8671055/*
     
    8711059/* FIXME: more better hash key? */
    8721060#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
     1061#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24))
    8731062#define INFO_AMP_CAPS   (1<<0)
    8741063#define INFO_AMP_VOL(ch)        (1 << (1 + (ch)))
    8751064
    8761065/* initialize the hash table */
    877 static void __devinit init_hda_cache(struct hda_cache_rec *cache,
     1066static void /*__devinit*/ init_hda_cache(struct hda_cache_rec *cache,
    8781067                                     unsigned int record_size)
    8791068{
     
    9451134        return info->amp_caps;
    9461135}
     1136EXPORT_SYMBOL_HDA(query_amp_caps);
    9471137
    9481138int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
     
    9581148        return 0;
    9591149}
     1150EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps);
     1151
     1152u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid)
     1153{
     1154        struct hda_amp_info *info;
     1155
     1156        info = get_alloc_amp_hash(codec, HDA_HASH_PINCAP_KEY(nid));
     1157        if (!info)
     1158                return 0;
     1159        if (!info->head.val) {
     1160                info->amp_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
     1161                info->head.val |= INFO_AMP_CAPS;
     1162        }
     1163        return info->amp_caps;
     1164}
     1165EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps);
    9601166
    9611167/*
     
    10111217        return get_vol_mute(codec, info, nid, ch, direction, index);
    10121218}
     1219EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read);
    10131220
    10141221/*
     
    10301237        return 1;
    10311238}
     1239EXPORT_SYMBOL_HDA(snd_hda_codec_amp_update);
    10321240
    10331241/*
     
    10431251        return ret;
    10441252}
     1253EXPORT_SYMBOL_HDA(snd_hda_codec_amp_stereo);
    10451254
    10461255#ifdef SND_HDA_NEEDS_RESUME
     
    10681277        }
    10691278}
     1279EXPORT_SYMBOL_HDA(snd_hda_codec_resume_amp);
    10701280#endif /* SND_HDA_NEEDS_RESUME */
    10711281
     
    10781288        u8 chs = get_amp_channels(kcontrol);
    10791289        int dir = get_amp_direction(kcontrol);
     1290        unsigned int ofs = get_amp_offset(kcontrol);
    10801291        u32 caps;
    10811292
     
    10891300                return -EINVAL;
    10901301        }
     1302        if (ofs < caps)
     1303                caps -= ofs;
    10911304        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    10921305        uinfo->count = chs == 3 ? 2 : 1;
     
    10941307        uinfo->value.integer.max = caps;
    10951308        return 0;
     1309}
     1310EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info);
     1311
     1312
     1313static inline unsigned int
     1314read_amp_value(struct hda_codec *codec, hda_nid_t nid,
     1315               int ch, int dir, int idx, unsigned int ofs)
     1316{
     1317        unsigned int val;
     1318        val = snd_hda_codec_amp_read(codec, nid, ch, dir, idx);
     1319        val &= HDA_AMP_VOLMASK;
     1320        if (val >= ofs)
     1321                val -= ofs;
     1322        else
     1323                val = 0;
     1324        return val;
     1325}
     1326
     1327static inline int
     1328update_amp_value(struct hda_codec *codec, hda_nid_t nid,
     1329                 int ch, int dir, int idx, unsigned int ofs,
     1330                 unsigned int val)
     1331{
     1332        if (val > 0)
     1333                val += ofs;
     1334        return snd_hda_codec_amp_update(codec, nid, ch, dir, idx,
     1335                                        HDA_AMP_VOLMASK, val);
    10961336}
    10971337
     
    11041344        int dir = get_amp_direction(kcontrol);
    11051345        int idx = get_amp_index(kcontrol);
     1346        unsigned int ofs = get_amp_offset(kcontrol);
    11061347        long *valp = ucontrol->value.integer.value;
    11071348
    11081349        if (chs & 1)
    1109                 *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx)
    1110                         & HDA_AMP_VOLMASK;
     1350                *valp++ = read_amp_value(codec, nid, 0, dir, idx, ofs);
    11111351        if (chs & 2)
    1112                 *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx)
    1113                         & HDA_AMP_VOLMASK;
    1114         return 0;
    1115 }
     1352                *valp = read_amp_value(codec, nid, 1, dir, idx, ofs);
     1353        return 0;
     1354}
     1355EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get);
    11161356
    11171357int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
     
    11231363        int dir = get_amp_direction(kcontrol);
    11241364        int idx = get_amp_index(kcontrol);
     1365        unsigned int ofs = get_amp_offset(kcontrol);
    11251366        long *valp = ucontrol->value.integer.value;
    11261367        int change = 0;
     
    11281369        snd_hda_power_up(codec);
    11291370        if (chs & 1) {
    1130                 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
    1131                                                   0x7f, *valp);
     1371                change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp);
    11321372                valp++;
    11331373        }
    11341374        if (chs & 2)
    1135                 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
    1136                                                    0x7f, *valp);
     1375                change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp);
    11371376        snd_hda_power_down(codec);
    11381377        return change;
    11391378}
     1379EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_put);
    11401380
    11411381int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
     
    11451385        hda_nid_t nid = get_amp_nid(kcontrol);
    11461386        int dir = get_amp_direction(kcontrol);
     1387        unsigned int ofs = get_amp_offset(kcontrol);
    11471388        u32 caps, val1, val2;
    11481389
     
    11531394        val2 = (val2 + 1) * 25;
    11541395        val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
     1396        val1 += ofs;
    11551397        val1 = ((int)val1) * ((int)val2);
    11561398        if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
     
    11641406        return 0;
    11651407}
     1408EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_tlv);
    11661409
    11671410/*
     
    11831426        tlv[3] = step;
    11841427}
     1428EXPORT_SYMBOL_HDA(snd_hda_set_vmaster_tlv);
    11851429
    11861430/* find a mixer control element with the given name */
     
    12021446        return _snd_hda_find_mixer_ctl(codec, name, 0);
    12031447}
     1448EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl);
    12041449
    12051450/* Add a control element and assign to the codec */
     
    12181463        return 0;
    12191464}
     1465EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
    12201466
    12211467/* Clear all controls assigned to the given codec */
     
    12291475}
    12301476
    1231 void snd_hda_codec_reset(struct hda_codec *codec)
    1232 {
    1233         int i;
     1477/* pseudo device locking
     1478 * toggle card->shutdown to allow/disallow the device access (as a hack)
     1479 */
     1480static int hda_lock_devices(struct snd_card *card)
     1481{
     1482        spin_lock(&card->files_lock);
     1483        if (card->shutdown) {
     1484                spin_unlock(&card->files_lock);
     1485                return -EINVAL;
     1486        }
     1487        card->shutdown = 1;
     1488        spin_unlock(&card->files_lock);
     1489        return 0;
     1490}
     1491
     1492static void hda_unlock_devices(struct snd_card *card)
     1493{
     1494        spin_lock(&card->files_lock);
     1495        card->shutdown = 0;
     1496        spin_unlock(&card->files_lock);
     1497}
     1498
     1499int snd_hda_codec_reset(struct hda_codec *codec)
     1500{
     1501        struct snd_card *card = codec->bus->card;
     1502        int i, pcm;
     1503
     1504        if (hda_lock_devices(card) < 0)
     1505                return -EBUSY;
     1506        /* check whether the codec isn't used by any mixer or PCM streams */
     1507        if (!list_empty(&card->ctl_files)) {
     1508                hda_unlock_devices(card);
     1509                return -EBUSY;
     1510        }
     1511        for (pcm = 0; pcm < codec->num_pcms; pcm++) {
     1512                struct hda_pcm *cpcm = &codec->pcm_info[pcm];
     1513                if (!cpcm->pcm)
     1514                        continue;
     1515                if (cpcm->pcm->streams[0].substream_opened ||
     1516                    cpcm->pcm->streams[1].substream_opened) {
     1517                        hda_unlock_devices(card);
     1518                        return -EBUSY;
     1519                }
     1520        }
     1521
     1522        /* OK, let it free */
    12341523
    12351524#ifdef CONFIG_SND_HDA_POWER_SAVE
    12361525        cancel_delayed_work(&codec->power_work);
    1237         flush_scheduled_work();
     1526        flush_workqueue(codec->bus->workq);
    12381527#endif
    12391528        snd_hda_ctls_clear(codec);
    12401529        /* relase PCMs */
    12411530        for (i = 0; i < codec->num_pcms; i++) {
    1242                 if (codec->pcm_info[i].pcm)
    1243                         snd_device_free(codec->bus->card,
    1244                                         codec->pcm_info[i].pcm);
     1531                if (codec->pcm_info[i].pcm) {
     1532                        snd_device_free(card, codec->pcm_info[i].pcm);
     1533                        clear_bit(codec->pcm_info[i].device,
     1534                                  codec->bus->pcm_dev_bits);
     1535                }
    12451536        }
    12461537        if (codec->patch_ops.free)
    12471538                codec->patch_ops.free(codec);
     1539        codec->proc_widget_hook = NULL;
    12481540        codec->spec = NULL;
    12491541        free_hda_cache(&codec->amp_cache);
    12501542        free_hda_cache(&codec->cmd_cache);
     1543        init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
     1544        init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
     1545        /* free only driver_pins so that init_pins + user_pins are restored */
     1546        snd_array_free(&codec->driver_pins);
     1547        restore_pincfgs(codec);
    12511548        codec->num_pcms = 0;
    12521549        codec->pcm_info = NULL;
    12531550        codec->preset = NULL;
     1551        memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
     1552        codec->slave_dig_outs = NULL;
     1553        codec->spdif_status_reset = 0;
     1554        module_put(codec->owner);
     1555        codec->owner = NULL;
     1556
     1557        /* allow device access again */
     1558        hda_unlock_devices(card);
     1559        return 0;
    12541560}
    12551561
     
    12771583        for (s = slaves; *s; s++) {
    12781584                struct snd_kcontrol *sctl;
    1279 
    1280                 sctl = snd_hda_find_mixer_ctl(codec, *s);
    1281                 if (!sctl) {
    1282                         snd_printdd("Cannot find slave %s, skipped\n", *s);
    1283                         continue;
    1284                 }
    1285                 err = snd_ctl_add_slave(kctl, sctl);
    1286                 if (err < 0)
    1287                         return err;
    1288         }
    1289         return 0;
    1290 }
     1585                int i = 0;
     1586                for (;;) {
     1587                        sctl = _snd_hda_find_mixer_ctl(codec, *s, i);
     1588                        if (!sctl) {
     1589                                if (!i)
     1590                                        snd_printdd("Cannot find slave %s, "
     1591                                                    "skipped\n", *s);
     1592                                break;
     1593                        }
     1594                        err = snd_ctl_add_slave(kctl, sctl);
     1595                        if (err < 0)
     1596                                return err;
     1597                        i++;
     1598                }
     1599        }
     1600        return 0;
     1601}
     1602EXPORT_SYMBOL_HDA(snd_hda_add_vmaster);
    12911603
    12921604/* switch */
     
    13021614        return 0;
    13031615}
     1616EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_info);
    13041617
    13051618int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
     
    13211634        return 0;
    13221635}
     1636EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_get);
    13231637
    13241638int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
     
    13511665        return change;
    13521666}
     1667EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put);
    13531668
    13541669/*
     
    13681683        int err;
    13691684
    1370         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1685        mutex_lock(&codec->control_mutex);
    13711686        pval = kcontrol->private_value;
    13721687        kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
    13731688        err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
    13741689        kcontrol->private_value = pval;
    1375         mutex_unlock(&codec->spdif_mutex);
     1690        mutex_unlock(&codec->control_mutex);
    13761691        return err;
    13771692}
     1693EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get);
    13781694
    13791695int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
     
    13841700        int i, indices, err = 0, change = 0;
    13851701
    1386         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1702        mutex_lock(&codec->control_mutex);
    13871703        pval = kcontrol->private_value;
    13881704        indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
     
    13961712        }
    13971713        kcontrol->private_value = pval;
    1398         mutex_unlock(&codec->spdif_mutex);
     1714        mutex_unlock(&codec->control_mutex);
    13991715        return err < 0 ? err : change;
    14001716}
     1717EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put);
    14011718
    14021719/*
     
    14101727        int err;
    14111728
    1412         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1729        mutex_lock(&codec->control_mutex);
    14131730        c = (struct hda_bind_ctls *)kcontrol->private_value;
    14141731        kcontrol->private_value = *c->values;
    14151732        err = c->ops->info(kcontrol, uinfo);
    14161733        kcontrol->private_value = (long)c;
    1417         mutex_unlock(&codec->spdif_mutex);
     1734        mutex_unlock(&codec->control_mutex);
    14181735        return err;
    14191736}
     1737EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info);
    14201738
    14211739int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
     
    14261744        int err;
    14271745
    1428         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1746        mutex_lock(&codec->control_mutex);
    14291747        c = (struct hda_bind_ctls *)kcontrol->private_value;
    14301748        kcontrol->private_value = *c->values;
    14311749        err = c->ops->get(kcontrol, ucontrol);
    14321750        kcontrol->private_value = (long)c;
    1433         mutex_unlock(&codec->spdif_mutex);
     1751        mutex_unlock(&codec->control_mutex);
    14341752        return err;
    14351753}
     1754EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get);
    14361755
    14371756int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
     
    14431762        int err = 0, change = 0;
    14441763
    1445         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1764        mutex_lock(&codec->control_mutex);
    14461765        c = (struct hda_bind_ctls *)kcontrol->private_value;
    14471766        for (vals = c->values; *vals; vals++) {
     
    14531772        }
    14541773        kcontrol->private_value = (long)c;
    1455         mutex_unlock(&codec->spdif_mutex);
     1774        mutex_unlock(&codec->control_mutex);
    14561775        return err < 0 ? err : change;
    14571776}
     1777EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put);
    14581778
    14591779int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
     
    14641784        int err;
    14651785
    1466         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1786        mutex_lock(&codec->control_mutex);
    14671787        c = (struct hda_bind_ctls *)kcontrol->private_value;
    14681788        kcontrol->private_value = *c->values;
    14691789        err = c->ops->tlv(kcontrol, op_flag, size, tlv);
    14701790        kcontrol->private_value = (long)c;
    1471         mutex_unlock(&codec->spdif_mutex);
     1791        mutex_unlock(&codec->control_mutex);
    14721792        return err;
    14731793}
     1794EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv);
    14741795
    14751796struct hda_ctl_ops snd_hda_bind_vol = {
     
    14791800        .tlv = snd_hda_mixer_amp_tlv
    14801801};
     1802EXPORT_SYMBOL_HDA(snd_hda_bind_vol);
    14811803
    14821804struct hda_ctl_ops snd_hda_bind_sw = {
     
    14861808        .tlv = snd_hda_mixer_amp_tlv
    14871809};
     1810EXPORT_SYMBOL_HDA(snd_hda_bind_sw);
    14881811
    14891812/*
     
    15921915        hda_nid_t *d;
    15931916
    1594         snd_hda_codec_write(codec, nid, 0, verb, val);
     1917        snd_hda_codec_write_cache(codec, nid, 0, verb, val);
    15951918        d = codec->slave_dig_outs;
    15961919        if (!d)
    15971920                return;
    15981921        for (; *d; d++)
    1599                 snd_hda_codec_write(codec, *d, 0, verb, val);
     1922                snd_hda_codec_write_cache(codec, *d, 0, verb, val);
    16001923}
    16011924
     
    17472070        return 0;
    17482071}
     2072EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls);
    17492073
    17502074/*
     
    17842108                           snd_ctl_new1(&spdif_share_sw, mout));
    17852109}
     2110EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw);
    17862111
    17872112/*
     
    18822207        for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
    18832208                kctl = snd_ctl_new1(dig_mix, codec);
     2209                if (!kctl)
     2210                        return -ENOMEM;
    18842211                kctl->private_value = nid;
    18852212                err = snd_hda_ctl_add(codec, kctl);
     
    18932220        return 0;
    18942221}
     2222EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls);
    18952223
    18962224#ifdef SND_HDA_NEEDS_RESUME
     
    19292257        if (!err) {
    19302258                struct hda_cache_head *c;
    1931                 u32 key = build_cmd_cache_key(nid, verb);
     2259                u32 key;
     2260                /* parm may contain the verb stuff for get/set amp */
     2261                verb = verb | (parm >> 8);
     2262                parm &= 0xff;
     2263                key = build_cmd_cache_key(nid, verb);
    19322264                c = get_alloc_hash(&codec->cmd_cache, key);
    19332265                if (c)
     
    19382270        return err;
    19392271}
     2272EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache);
    19402273
    19412274/* resume the all commands from the cache */
     
    19532286        }
    19542287}
     2288EXPORT_SYMBOL_HDA(snd_hda_codec_resume_cache);
    19552289
    19562290/**
     
    19702304                                          seq->param);
    19712305}
     2306EXPORT_SYMBOL_HDA(snd_hda_sequence_write_cache);
    19722307#endif /* SND_HDA_NEEDS_RESUME */
    19732308
     
    19972332                                 * eapd and EAPD_BTLENABLE is set.
    19982333                                 */
    1999                                 pincap = snd_hda_param_read(codec, nid,
    2000                                                             AC_PAR_PIN_CAP);
     2334                                pincap = snd_hda_query_pin_caps(codec, nid);
    20012335                                if (pincap & AC_PINCAP_EAPD) {
    20022336                                        int eapd = snd_hda_codec_read(codec,
     
    20672401                            codec->afg ? codec->afg : codec->mfg,
    20682402                            AC_PWRST_D0);
     2403        restore_pincfgs(codec); /* restore all current pin configs */
    20692404        hda_exec_init_verbs(codec);
    20702405        if (codec->patch_ops.resume)
     
    20882423 * Returns 0 if successful, otherwise a negative error code.
    20892424 */
    2090 int __devinit snd_hda_build_controls(struct hda_bus *bus)
     2425int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
    20912426{
    20922427        struct hda_codec *codec;
     
    20942429        list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
    20952430                int err = snd_hda_codec_build_controls(codec);
    2096                 if (err < 0)
    2097                         return err;
    2098         }
    2099 
    2100         return 0;
    2101 }
     2431                if (err < 0) {
     2432                        printk(KERN_ERR "hda_codec: cannot build controls"
     2433                               "for #%d (error %d)\n", codec->addr, err);
     2434                        err = snd_hda_codec_reset(codec);
     2435                        if (err < 0) {
     2436                                printk(KERN_ERR
     2437                                       "hda_codec: cannot revert codec\n");
     2438                                return err;
     2439                        }
     2440                }
     2441        }
     2442        return 0;
     2443}
     2444EXPORT_SYMBOL_HDA(snd_hda_build_controls);
    21022445
    21032446int snd_hda_codec_build_controls(struct hda_codec *codec)
    21042447{
    21052448        int err = 0;
    2106         /* fake as if already powered-on */
    2107         hda_keep_power_on(codec);
    2108         /* then fire up */
    2109         hda_set_power_state(codec,
    2110                             codec->afg ? codec->afg : codec->mfg,
    2111                             AC_PWRST_D0);
    21122449        hda_exec_init_verbs(codec);
    21132450        /* continue to initialize... */
     
    21162453        if (!err && codec->patch_ops.build_controls)
    21172454                err = codec->patch_ops.build_controls(codec);
    2118         snd_hda_power_down(codec);
    21192455        if (err < 0)
    21202456                return err;
     
    22112547        return val;
    22122548}
     2549EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format);
    22132550
    22142551/**
     
    22252562 * Returns 0 if successful, otherwise a negative error code.
    22262563 */
    2227 int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
     2564static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
    22282565                                u32 *ratesp, u64 *formatsp, unsigned int *bpsp)
    22292566{
    2230         int i;
    2231         unsigned int val, streams;
     2567        unsigned int i, val, wcaps;
    22322568
    22332569        val = 0;
    2234         if (nid != codec->afg &&
    2235             (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) {
     2570        wcaps = get_wcaps(codec, nid);
     2571        if (nid != codec->afg && (wcaps & AC_WCAP_FORMAT_OVRD)) {
    22362572                val = snd_hda_param_read(codec, nid, AC_PAR_PCM);
    22372573                if (val == -1)
     
    22472583                                rates |= rate_bits[i].alsa_bits;
    22482584                }
     2585                if (rates == 0) {
     2586                        snd_printk(KERN_ERR "hda_codec: rates == 0 "
     2587                                   "(nid=0x%x, val=0x%x, ovrd=%i)\n",
     2588                                        nid, val,
     2589                                        (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0);
     2590                        return -EIO;
     2591                }
    22492592                *ratesp = rates;
    22502593        }
     
    22522595        if (formatsp || bpsp) {
    22532596                u64 formats = 0;
    2254                 unsigned int bps;
    2255                 unsigned int wcaps;
    2256 
    2257                 wcaps = get_wcaps(codec, nid);
     2597                unsigned int streams, bps;
     2598
    22582599                streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
    22592600                if (streams == -1)
     
    23082649                        bps = 8;
    23092650                }
     2651                if (formats == 0) {
     2652                        snd_printk(KERN_ERR "hda_codec: formats == 0 "
     2653                                   "(nid=0x%x, val=0x%x, ovrd=%i, "
     2654                                   "streams=0x%x)\n",
     2655                                        nid, val,
     2656                                        (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0,
     2657                                        streams);
     2658                        return -EIO;
     2659                }
    23102660                if (formatsp)
    23112661                        *formatsp = formats;
     
    23902740        return 1;
    23912741}
     2742EXPORT_SYMBOL_HDA(snd_hda_is_supported_format);
    23922743
    23932744/*
     
    24222773                                  struct hda_pcm_stream *info)
    24232774{
     2775        int err;
     2776
    24242777        /* query support PCM information from the given NID */
    24252778        if (info->nid && (!info->rates || !info->formats)) {
    2426                 snd_hda_query_supported_pcm(codec, info->nid,
     2779                err = snd_hda_query_supported_pcm(codec, info->nid,
    24272780                                info->rates ? NULL : &info->rates,
    24282781                                info->formats ? NULL : &info->formats,
    24292782                                info->maxbps ? NULL : &info->maxbps);
     2783                if (err < 0)
     2784                        return err;
    24302785        }
    24312786        if (info->ops.open == NULL)
     
    24472802
    24482803/*
    2449  * attach a new PCM stream
    2450  */
    2451 static int __devinit
    2452 snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm)
    2453 {
    2454         struct hda_bus *bus = codec->bus;
    2455         struct hda_pcm_stream *info;
    2456         int stream, err;
    2457 
    2458         if (snd_BUG_ON(!pcm->name))
    2459                 return -EINVAL;
    2460         for (stream = 0; stream < 2; stream++) {
    2461                 info = &pcm->stream[stream];
    2462                 if (info->substreams) {
    2463                         err = set_pcm_default_values(codec, info);
    2464                         if (err < 0)
    2465                                 return err;
    2466                 }
    2467         }
    2468         return bus->ops.attach_pcm(bus, codec, pcm);
    2469 }
    2470 
    2471 /**
    2472  * snd_hda_build_pcms - build PCM information
    2473  * @bus: the BUS
    2474  *
    2475  * Create PCM information for each codec included in the bus.
    2476  *
    2477  * The build_pcms codec patch is requested to set up codec->num_pcms and
    2478  * codec->pcm_info properly.  The array is referred by the top-level driver
    2479  * to create its PCM instances.
    2480  * The allocated codec->pcm_info should be released in codec->patch_ops.free
    2481  * callback.
    2482  *
    2483  * At least, substreams, channels_min and channels_max must be filled for
    2484  * each stream.  substreams = 0 indicates that the stream doesn't exist.
    2485  * When rates and/or formats are zero, the supported values are queried
    2486  * from the given nid.  The nid is used also by the default ops.prepare
    2487  * and ops.cleanup callbacks.
    2488  *
    2489  * The driver needs to call ops.open in its open callback.  Similarly,
    2490  * ops.close is supposed to be called in the close callback.
    2491  * ops.prepare should be called in the prepare or hw_params callback
    2492  * with the proper parameters for set up.
    2493  * ops.cleanup should be called in hw_free for clean up of streams.
    2494  *
    2495  * This function returns 0 if successfull, or a negative error code.
    2496  */
    2497 int snd_hda_build_pcms(struct hda_bus *bus)
     2804 * get the empty PCM device number to assign
     2805 */
     2806static int get_empty_pcm_device(struct hda_bus *bus, int type)
    24982807{
    24992808        static const char *dev_name[HDA_PCM_NTYPES] = {
     
    25092818        /* normal audio device indices; not linear to keep compatibility */
    25102819        static int audio_idx[4] = { 0, 2, 4, 5 };
    2511         struct hda_codec *codec;
    2512         int num_devs[HDA_PCM_NTYPES];
    2513 
    2514         memset(num_devs, 0, sizeof(num_devs));
    2515         list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
    2516                 unsigned int pcm;
    2517                 int err;
    2518                 if (!codec->num_pcms) {
    2519                         if (!codec->patch_ops.build_pcms)
    2520                                 continue;
    2521                         err = codec->patch_ops.build_pcms(codec);
     2820        int i, dev;
     2821
     2822        switch (type) {
     2823        case HDA_PCM_TYPE_AUDIO:
     2824                for (i = 0; i < ARRAY_SIZE(audio_idx); i++) {
     2825                        dev = audio_idx[i];
     2826                        if (!test_bit(dev, bus->pcm_dev_bits))
     2827                                goto ok;
     2828                }
     2829                snd_printk(KERN_WARNING "Too many audio devices\n");
     2830                return -EAGAIN;
     2831        case HDA_PCM_TYPE_SPDIF:
     2832        case HDA_PCM_TYPE_HDMI:
     2833        case HDA_PCM_TYPE_MODEM:
     2834                dev = dev_idx[type];
     2835                if (test_bit(dev, bus->pcm_dev_bits)) {
     2836                        snd_printk(KERN_WARNING "%s already defined\n",
     2837                                   dev_name[type]);
     2838                        return -EAGAIN;
     2839                }
     2840                break;
     2841        default:
     2842                snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
     2843                return -EINVAL;
     2844        }
     2845 ok:
     2846        set_bit(dev, bus->pcm_dev_bits);
     2847        return dev;
     2848}
     2849
     2850/*
     2851 * attach a new PCM stream
     2852 */
     2853static int snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm)
     2854{
     2855        struct hda_bus *bus = codec->bus;
     2856        struct hda_pcm_stream *info;
     2857        int stream, err;
     2858
     2859        if (snd_BUG_ON(!pcm->name))
     2860                return -EINVAL;
     2861        for (stream = 0; stream < 2; stream++) {
     2862                info = &pcm->stream[stream];
     2863                if (info->substreams) {
     2864                        err = set_pcm_default_values(codec, info);
    25222865                        if (err < 0)
    25232866                                return err;
    25242867                }
    2525                 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
    2526                         struct hda_pcm *cpcm = &codec->pcm_info[pcm];
    2527                         int type = cpcm->pcm_type;
    2528                         int dev;
    2529 
    2530                         if (!cpcm->stream[0].substreams &&
    2531                             !cpcm->stream[1].substreams)
    2532                                 continue; /* no substreams assigned */
    2533 
    2534                         switch (type) {
    2535                         case HDA_PCM_TYPE_AUDIO:
    2536                                 if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
    2537                                         snd_printk(KERN_WARNING
    2538                                                    "Too many audio devices\n");
    2539                                         continue;
    2540                                 }
    2541                                 dev = audio_idx[num_devs[type]];
    2542                                 break;
    2543                         case HDA_PCM_TYPE_SPDIF:
    2544                         case HDA_PCM_TYPE_HDMI:
    2545                         case HDA_PCM_TYPE_MODEM:
    2546                                 if (num_devs[type]) {
    2547                                         snd_printk(KERN_WARNING
    2548                                                    "%s already defined\n",
    2549                                                    dev_name[type]);
    2550                                         continue;
    2551                                 }
    2552                                 dev = dev_idx[type];
    2553                                 break;
    2554                         default:
    2555                                 snd_printk(KERN_WARNING
    2556                                            "Invalid PCM type %d\n", type);
    2557                                 continue;
     2868        }
     2869        return bus->ops.attach_pcm(bus, codec, pcm);
     2870}
     2871
     2872/* assign all PCMs of the given codec */
     2873int snd_hda_codec_build_pcms(struct hda_codec *codec)
     2874{
     2875        unsigned int pcm;
     2876        int err;
     2877
     2878        if (!codec->num_pcms) {
     2879                if (!codec->patch_ops.build_pcms)
     2880                        return 0;
     2881                err = codec->patch_ops.build_pcms(codec);
     2882                if (err < 0) {
     2883                        printk(KERN_ERR "hda_codec: cannot build PCMs"
     2884                               "for #%d (error %d)\n", codec->addr, err);
     2885                        err = snd_hda_codec_reset(codec);
     2886                        if (err < 0) {
     2887                                printk(KERN_ERR
     2888                                       "hda_codec: cannot revert codec\n");
     2889                                return err;
    25582890                        }
    2559                         num_devs[type]++;
    2560                         if (!cpcm->pcm) {
    2561                                 cpcm->device = dev;
    2562                                 err = snd_hda_attach_pcm(codec, cpcm);
    2563                                 if (err < 0)
    2564                                         return err;
     2891                }
     2892        }
     2893        for (pcm = 0; pcm < codec->num_pcms; pcm++) {
     2894                struct hda_pcm *cpcm = &codec->pcm_info[pcm];
     2895                int dev;
     2896
     2897                if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
     2898                        continue; /* no substreams assigned */
     2899
     2900                if (!cpcm->pcm) {
     2901                        dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type);
     2902                        if (dev < 0)
     2903                                continue; /* no fatal error */
     2904                        cpcm->device = dev;
     2905                        err = snd_hda_attach_pcm(codec, cpcm);
     2906                        if (err < 0) {
     2907                                printk(KERN_ERR "hda_codec: cannot attach "
     2908                                       "PCM stream %d for codec #%d\n",
     2909                                       dev, codec->addr);
     2910                                continue; /* no fatal error */
    25652911                        }
    25662912                }
     
    25682914        return 0;
    25692915}
     2916
     2917/**
     2918 * snd_hda_build_pcms - build PCM information
     2919 * @bus: the BUS
     2920 *
     2921 * Create PCM information for each codec included in the bus.
     2922 *
     2923 * The build_pcms codec patch is requested to set up codec->num_pcms and
     2924 * codec->pcm_info properly.  The array is referred by the top-level driver
     2925 * to create its PCM instances.
     2926 * The allocated codec->pcm_info should be released in codec->patch_ops.free
     2927 * callback.
     2928 *
     2929 * At least, substreams, channels_min and channels_max must be filled for
     2930 * each stream.  substreams = 0 indicates that the stream doesn't exist.
     2931 * When rates and/or formats are zero, the supported values are queried
     2932 * from the given nid.  The nid is used also by the default ops.prepare
     2933 * and ops.cleanup callbacks.
     2934 *
     2935 * The driver needs to call ops.open in its open callback.  Similarly,
     2936 * ops.close is supposed to be called in the close callback.
     2937 * ops.prepare should be called in the prepare or hw_params callback
     2938 * with the proper parameters for set up.
     2939 * ops.cleanup should be called in hw_free for clean up of streams.
     2940 *
     2941 * This function returns 0 if successfull, or a negative error code.
     2942 */
     2943int __devinit snd_hda_build_pcms(struct hda_bus *bus)
     2944{
     2945        struct hda_codec *codec;
     2946
     2947        list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
     2948                int err = snd_hda_codec_build_pcms(codec);
     2949                if (err < 0)
     2950                        return err;
     2951        }
     2952        return 0;
     2953}
     2954EXPORT_SYMBOL_HDA(snd_hda_build_pcms);
    25702955
    25712956/**
     
    26233008        return -1;
    26243009}
     3010EXPORT_SYMBOL_HDA(snd_hda_check_board_config);
     3011
     3012/**
     3013 * snd_hda_check_board_codec_sid_config - compare the current codec
     3014                                          subsystem ID with the
     3015                                          config table
     3016
     3017           This is important for Gateway notebooks with SB450 HDA Audio
     3018           where the vendor ID of the PCI device is:
     3019                ATI Technologies Inc SB450 HDA Audio [1002:437b]
     3020           and the vendor/subvendor are found only at the codec.
     3021
     3022 * @codec: the HDA codec
     3023 * @num_configs: number of config enums
     3024 * @models: array of model name strings
     3025 * @tbl: configuration table, terminated by null entries
     3026 *
     3027 * Compares the modelname or PCI subsystem id of the current codec with the
     3028 * given configuration table.  If a matching entry is found, returns its
     3029 * config value (supposed to be 0 or positive).
     3030 *
     3031 * If no entries are matching, the function returns a negative value.
     3032 */
     3033int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
     3034                               int num_configs, const char **models,
     3035                               const struct snd_pci_quirk *tbl)
     3036{
     3037        const struct snd_pci_quirk *q;
     3038
     3039        /* Search for codec ID */
     3040        for (q = tbl; q->subvendor; q++) {
     3041                unsigned long vendorid = (q->subdevice) | (q->subvendor << 16);
     3042
     3043                if (vendorid == codec->subsystem_id)
     3044                        break;
     3045        }
     3046
     3047        if (!q->subvendor)
     3048                return -1;
     3049
     3050        tbl = q;
     3051
     3052        if (tbl->value >= 0 && tbl->value < num_configs) {
     3053#ifdef CONFIG_SND_DEBUG_DETECT
     3054                char tmp[10];
     3055                const char *model = NULL;
     3056                if (models)
     3057                        model = models[tbl->value];
     3058                if (!model) {
     3059                        sprintf(tmp, "#%d", tbl->value);
     3060                        model = tmp;
     3061                }
     3062                snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
     3063                            "for config %x:%x (%s)\n",
     3064                            model, tbl->subvendor, tbl->subdevice,
     3065                            (tbl->name ? tbl->name : "Unknown device"));
     3066#endif
     3067                return tbl->value;
     3068        }
     3069        return -1;
     3070}
     3071EXPORT_SYMBOL_HDA(snd_hda_check_board_codec_sid_config);
    26253072
    26263073/**
     
    26583105        return 0;
    26593106}
     3107EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls);
    26603108
    26613109#ifdef CONFIG_SND_HDA_POWER_SAVE
     
    27003148        codec->power_transition = 0;
    27013149}
     3150EXPORT_SYMBOL_HDA(snd_hda_power_up);
     3151
     3152#define power_save(codec)       \
     3153        ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
     3154
     3155#define power_save(codec)       \
     3156        ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
    27023157
    27033158void snd_hda_power_down(struct hda_codec *codec)
     
    27063161        if (!codec->power_on || codec->power_count || codec->power_transition)
    27073162                return;
    2708         if (power_save) {
     3163        if (power_save(codec)) {
    27093164                codec->power_transition = 1; /* avoid reentrance */
    2710                 schedule_delayed_work(&codec->power_work,
    2711                                       msecs_to_jiffies(power_save * 1000));
    2712         }
    2713 }
     3165                queue_delayed_work(codec->bus->workq, &codec->power_work,
     3166                                msecs_to_jiffies(power_save(codec) * 1000));
     3167        }
     3168}
     3169EXPORT_SYMBOL_HDA(snd_hda_power_down);
    27143170
    27153171int snd_hda_check_amp_list_power(struct hda_codec *codec,
     
    27483204        return 0;
    27493205}
     3206EXPORT_SYMBOL_HDA(snd_hda_check_amp_list_power);
    27503207#endif
    27513208
     
    27673224        return 0;
    27683225}
     3226EXPORT_SYMBOL_HDA(snd_hda_ch_mode_info);
    27693227
    27703228int snd_hda_ch_mode_get(struct hda_codec *codec,
     
    27843242        return 0;
    27853243}
     3244EXPORT_SYMBOL_HDA(snd_hda_ch_mode_get);
    27863245
    27873246int snd_hda_ch_mode_put(struct hda_codec *codec,
     
    28043263        return 1;
    28053264}
     3265EXPORT_SYMBOL_HDA(snd_hda_ch_mode_put);
    28063266
    28073267/*
     
    28243284        return 0;
    28253285}
     3286EXPORT_SYMBOL_HDA(snd_hda_input_mux_info);
    28263287
    28273288int snd_hda_input_mux_put(struct hda_codec *codec,
     
    28453306        return 1;
    28463307}
     3308EXPORT_SYMBOL_HDA(snd_hda_input_mux_put);
    28473309
    28483310
     
    28973359        return 0;
    28983360}
     3361EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_open);
    28993362
    29003363int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
     
    29093372        return 0;
    29103373}
     3374EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare);
     3375
     3376int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
     3377                                  struct hda_multi_out *mout)
     3378{
     3379        mutex_lock(&codec->spdif_mutex);
     3380        cleanup_dig_out_stream(codec, mout->dig_out_nid);
     3381        mutex_unlock(&codec->spdif_mutex);
     3382        return 0;
     3383}
     3384EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_cleanup);
    29113385
    29123386/*
     
    29213395        return 0;
    29223396}
     3397EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_close);
    29233398
    29243399/*
     
    29603435                                          SNDRV_PCM_HW_PARAM_CHANNELS, 2);
    29613436}
     3437EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_open);
    29623438
    29633439/*
     
    30183494        return 0;
    30193495}
     3496EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare);
    30203497
    30213498/*
     
    30443521        return 0;
    30453522}
     3523EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup);
    30463524
    30473525/*
     
    31323610                        continue;
    31333611
    3134                 def_conf = snd_hda_codec_read(codec, nid, 0,
    3135                                               AC_VERB_GET_CONFIG_DEFAULT, 0);
     3612                def_conf = snd_hda_codec_get_pincfg(codec, nid);
    31363613                if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
    31373614                        continue;
     
    32093686                        break;
    32103687                case AC_JACK_SPDIF_OUT:
    3211                         cfg->dig_out_pin = nid;
     3688                case AC_JACK_DIG_OTHER_OUT:
     3689                        if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins))
     3690                                continue;
     3691                        cfg->dig_out_pins[cfg->dig_outs] = nid;
     3692                        cfg->dig_out_type[cfg->dig_outs] =
     3693                                (loc == AC_JACK_LOC_HDMI) ?
     3694                                HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF;
     3695                        cfg->dig_outs++;
    32123696                        break;
    32133697                case AC_JACK_SPDIF_IN:
     3698                case AC_JACK_DIG_OTHER_IN:
    32143699                        cfg->dig_in_pin = nid;
     3700                        if (loc == AC_JACK_LOC_HDMI)
     3701                                cfg->dig_in_type = HDA_PCM_TYPE_HDMI;
     3702                        else
     3703                                cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
    32153704                        break;
    32163705                }
     
    33183807                   cfg->hp_pins[3], cfg->hp_pins[4]);
    33193808        snd_printd("   mono: mono_out=0x%x\n", cfg->mono_out_pin);
     3809        if (cfg->dig_outs)
     3810                snd_printd("   dig-out=0x%x/0x%x\n",
     3811                           cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
    33203812        snd_printd("   inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
    33213813                   " cd=0x%x, aux=0x%x\n",
     
    33263818                   cfg->input_pins[AUTO_PIN_CD],
    33273819                   cfg->input_pins[AUTO_PIN_AUX]);
    3328 
    3329         return 0;
    3330 }
     3820        if (cfg->dig_in_pin)
     3821                snd_printd("   dig-in=0x%x\n", cfg->dig_in_pin);
     3822
     3823        return 0;
     3824}
     3825EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config);
    33313826
    33323827/* labels for input pins */
     
    33343829        "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
    33353830};
     3831EXPORT_SYMBOL_HDA(auto_pin_cfg_labels);
    33363832
    33373833
     
    33613857        return 0;
    33623858}
     3859EXPORT_SYMBOL_HDA(snd_hda_suspend);
    33633860
    33643861/**
    33653862 * snd_hda_resume - resume the codecs
    33663863 * @bus: the HDA bus
    3367  * @state: resume state
    33683864 *
    33693865 * Returns 0 if successful.
     
    33823878        return 0;
    33833879}
    3384 #ifdef CONFIG_SND_HDA_POWER_SAVE
    3385 int snd_hda_codecs_inuse(struct hda_bus *bus)
    3386 {
    3387         struct hda_codec *codec;
    3388 
    3389         list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
    3390                 if (snd_hda_codec_needs_resume(codec))
    3391                         return 1;
    3392         }
    3393         return 0;
    3394 }
    3395 #endif
    3396 #endif
     3880EXPORT_SYMBOL_HDA(snd_hda_resume);
     3881#endif /* CONFIG_PM */
    33973882
    33983883/*
     
    34233908        return snd_array_elem(array, array->used++);
    34243909}
     3910EXPORT_SYMBOL_HDA(snd_array_new);
    34253911
    34263912/* free the given array elements */
     
    34323918        array->list = NULL;
    34333919}
     3920EXPORT_SYMBOL_HDA(snd_array_free);
     3921
     3922/*
     3923 * used by hda_proc.c and hda_eld.c
     3924 */
     3925void snd_print_pcm_rates(int pcm, char *buf, int buflen)
     3926{
     3927        static unsigned int rates[] = {
     3928                8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
     3929                96000, 176400, 192000, 384000
     3930        };
     3931        int i, j;
     3932
     3933        for (i = 0, j = 0; i < ARRAY_SIZE(rates); i++)
     3934                if (pcm & (1 << i))
     3935                        j += snprintf(buf + j, buflen - j,  " %d", rates[i]);
     3936
     3937        buf[j] = '\0'; /* necessary when j == 0 */
     3938}
     3939EXPORT_SYMBOL_HDA(snd_print_pcm_rates);
     3940
     3941void snd_print_pcm_bits(int pcm, char *buf, int buflen)
     3942{
     3943        static unsigned int bits[] = { 8, 16, 20, 24, 32 };
     3944        int i, j;
     3945
     3946        for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
     3947                if (pcm & (AC_SUPPCM_BITS_8 << i))
     3948                        j += snprintf(buf + j, buflen - j,  " %d", bits[i]);
     3949
     3950        buf[j] = '\0'; /* necessary when j == 0 */
     3951}
     3952EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
     3953
     3954MODULE_DESCRIPTION("HDA codec core");
     3955MODULE_LICENSE("GPL");
  • GPL/trunk/alsa-kernel/pci/hda/hda_codec.h

    r417 r426  
    586586        struct pci_dev *pci;
    587587        const char *modelname;
     588        int *power_save;
    588589        struct hda_bus_ops ops;
    589590};
     
    602603        struct pci_dev *pci;
    603604        const char *modelname;
     605        int *power_save;
    604606        struct hda_bus_ops ops;
    605607
     
    617619        /* unsolicited event queue */
    618620        struct hda_bus_unsolicited *unsol;
    619 
    620         struct snd_info_entry *proc;
     621        char workq_name[16];
     622        struct workqueue_struct *workq; /* common workqueue for codecs */
     623
     624        /* assigned PCMs */
     625        DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
    621626
    622627        /* misc op flags */
    623628        unsigned int needs_damn_long_delay :1;
     629        unsigned int shutdown :1;       /* being unloaded */
    624630};
    625631
     
    641647};
    642648       
     649struct hda_codec_preset_list {
     650        const struct hda_codec_preset *preset;
     651        struct module *owner;
     652        struct list_head list;
     653};
     654
     655/* initial hook */
     656int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset);
     657int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset);
     658
    643659/* ops set by the preset patch */
    644660struct hda_codec_ops {
     
    728744
    729745        /* ids */
     746        u32 function_id;
    730747        u32 vendor_id;
    731748        u32 subsystem_id;
     
    734751        /* detected preset */
    735752        const struct hda_codec_preset *preset;
     753        struct module *owner;
    736754        const char *name;       /* codec name */
    737755        const char *modelname;  /* model name for preset */
     
    765783        struct semaphore spdif_mutex;
    766784#endif
     785        struct mutex control_mutex;
    767786        unsigned int spdif_status;      /* IEC958 status bits */
    768787        unsigned short spdif_ctls;      /* SPDIF control bits */
    769788        unsigned int spdif_in_enable;   /* SPDIF input enable? */
    770789        hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
     790        struct snd_array init_pins;     /* initial (BIOS) pin configurations */
     791        struct snd_array driver_pins;   /* pin configs set by codec parser */
    771792
    772793#ifdef CONFIG_SND_HDA_HWDEP
     
    774795        struct snd_array init_verbs;    /* additional init verbs */
    775796        struct snd_array hints;         /* additional hints */
     797        struct snd_array user_pins;     /* default pin configs to override */
    776798#endif
    777799
     
    781803                                             * (e.g. Realtek codecs)
    782804                                             */
     805        unsigned int pin_amp_workaround:1; /* pin out-amp takes index
     806                                            * (e.g. Conexant codecs)
     807                                            */
    783808#ifdef CONFIG_SND_HDA_POWER_SAVE
    784809        unsigned int power_on :1;       /* current (global) power-state */
     
    787812        struct delayed_work power_work; /* delayed task for powerdown */
    788813#endif
     814
     815        /* codec-specific additional proc output */
     816        void (*proc_widget_hook)(struct snd_info_buffer *buffer,
     817                                 struct hda_codec *codec, hda_nid_t nid);
    789818};
    790819
     
    801830                    struct hda_bus **busp);
    802831int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
    803                       struct hda_codec **codecp);
     832                      int do_init, struct hda_codec **codecp);
    804833
    805834/*
     
    842871#endif
    843872
     873/* the struct for codec->pin_configs */
     874struct hda_pincfg {
     875        hda_nid_t nid;
     876        unsigned int cfg;
     877};
     878
     879unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
     880int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
     881                             unsigned int cfg);
     882int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
     883                       hda_nid_t nid, unsigned int cfg); /* for hwdep */
     884
    844885/*
    845886 * Mixer
     
    852893 */
    853894int snd_hda_build_pcms(struct hda_bus *bus);
     895int snd_hda_codec_build_pcms(struct hda_codec *codec);
    854896void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
    855897                                u32 stream_tag,
     
    860902                                        unsigned int format,
    861903                                        unsigned int maxbps);
    862 int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
    863                                 u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
    864904int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
    865905                                unsigned int format);
     
    892932void snd_hda_power_down(struct hda_codec *codec);
    893933#define snd_hda_codec_needs_resume(codec) codec->power_count
    894 int snd_hda_codecs_inuse(struct hda_bus *bus);
    895934#else
    896935static inline void snd_hda_power_up(struct hda_codec *codec) {}
    897936static inline void snd_hda_power_down(struct hda_codec *codec) {}
    898937#define snd_hda_codec_needs_resume(codec) 1
    899 #define snd_hda_codecs_inuse(bus) 1
     938#endif
     939
     940/*
     941 * Codec modularization
     942 */
     943
     944/* Export symbols only for communication with codec drivers;
     945 * When built in kernel, all HD-audio drivers are supposed to be statically
     946 * linked to the kernel.  Thus, the symbols don't have to (or shouldn't) be
     947 * exported unless it's built as a module.
     948 */
     949#if defined(MODULE) && !defined(TARGET_OS2)
     950#define EXPORT_SYMBOL_HDA(sym) EXPORT_SYMBOL_GPL(sym)
     951#else
     952#define EXPORT_SYMBOL_HDA(sym)
    900953#endif
    901954
  • GPL/trunk/alsa-kernel/pci/hda/hda_generic.c

    r417 r426  
    145145
    146146        if (node->type == AC_WID_PIN) {
    147                 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP);
     147                node->pin_caps = snd_hda_query_pin_caps(codec, node->nid);
    148148                node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    149                 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     149                node->def_cfg = snd_hda_codec_get_pincfg(codec, node->nid);
    150150        }
    151151
     
    724724                knew.index = index;
    725725                knew.name = name;
     726#ifdef TARGET_OS2
     727                knew.count = 1;
     728#endif
    726729                knew.info = snd_hda_mixer_amp_switch_info;
    727730                knew.get = snd_hda_mixer_amp_switch_get;
     
    741744                knew.index = index;
    742745                knew.name = name;
     746#ifdef TARGET_OS2
     747                knew.count = 1;
     748#endif
    743749                knew.info = snd_hda_mixer_amp_switch_info;
    744750                knew.get = snd_hda_mixer_amp_switch_get;
     
    763769                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    764770                knew.name = name;
     771#ifdef TARGET_OS2
     772                knew.count = 1;
     773#endif
    765774                knew.info = snd_hda_mixer_amp_volume_info;
    766775                knew.get = snd_hda_mixer_amp_volume_get;
     
    777786                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    778787                knew.name = name;
     788#ifdef TARGET_OS2
     789                knew.count = 1;
     790#endif
    779791                knew.info = snd_hda_mixer_amp_volume_info;
    780792                knew.get = snd_hda_mixer_amp_volume_get;
     
    900912                knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    901913                knew.name = name;
     914#ifdef TARGET_OS2
     915                knew.count = 1;
     916#endif
    902917                knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
    903918                    SNDRV_CTL_ELEM_ACCESS_TLV_READ |
     
    11381153        return err;
    11391154}
     1155EXPORT_SYMBOL(snd_hda_parse_generic_codec);
  • GPL/trunk/alsa-kernel/pci/hda/hda_hwdep.c

    r417 r426  
    3131#include <sound/minors.h>
    3232
     33/* hint string pair */
     34struct hda_hint {
     35        const char *key;
     36        const char *val;        /* contained in the same alloc as key */
     37};
     38
    3339/*
    3440 * write/read an out-of-bound verb
     
    100106static void clear_hwdep_elements(struct hda_codec *codec)
    101107{
    102         char **head;
    103108        int i;
    104109
     
    106111        snd_array_free(&codec->init_verbs);
    107112        /* clear hints */
    108         head = codec->hints.list;
    109         for (i = 0; i < codec->hints.used; i++, head++)
    110                 kfree(*head);
     113        for (i = 0; i < codec->hints.used; i++) {
     114                struct hda_hint *hint = snd_array_elem(&codec->hints, i);
     115                kfree(hint->key); /* we don't need to free hint->val */
     116        }
    111117        snd_array_free(&codec->hints);
     118        snd_array_free(&codec->user_pins);
    112119}
    113120
     
    117124}
    118125
    119 int __devinit snd_hda_create_hwdep(struct hda_codec *codec)
     126int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
    120127{
    121128        char hwname[16];
     
    141148
    142149        snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
    143         snd_array_init(&codec->hints, sizeof(char *), 32);
    144 
    145         return 0;
    146 }
     150        snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
     151        snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
     152
     153        return 0;
     154}
     155
     156#ifdef CONFIG_SND_HDA_RECONFIG
    147157
    148158/*
     
    152162static int clear_codec(struct hda_codec *codec)
    153163{
    154         snd_hda_codec_reset(codec);
     164        int err;
     165
     166        err = snd_hda_codec_reset(codec);
     167        if (err < 0) {
     168                snd_printk(KERN_ERR "The codec is being used, can't free.\n");
     169                return err;
     170        }
    155171        clear_hwdep_elements(codec);
    156172        return 0;
     
    161177        int err;
    162178
     179        snd_hda_power_up(codec);
    163180        snd_printk(KERN_INFO "hda-codec: reconfiguring\n");
    164         snd_hda_codec_reset(codec);
     181        err = snd_hda_codec_reset(codec);
     182        if (err < 0) {
     183                snd_printk(KERN_ERR
     184                           "The codec is being used, can't reconfigure.\n");
     185                goto error;
     186        }
    165187        err = snd_hda_codec_configure(codec);
    166188        if (err < 0)
    167                 return err;
     189                goto error;
    168190        /* rebuild PCMs */
    169         err = snd_hda_build_pcms(codec->bus);
     191        err = snd_hda_codec_build_pcms(codec);
    170192        if (err < 0)
    171                 return err;
     193                goto error;
    172194        /* rebuild mixers */
    173195        err = snd_hda_codec_build_controls(codec);
    174196        if (err < 0)
    175                 return err;
    176         return 0;
     197                goto error;
     198        err = snd_card_register(codec->bus->card);
     199 error:
     200        snd_hda_power_down(codec);
     201        return err;
    177202}
    178203
     
    270295CODEC_ACTION_STORE(clear);
    271296
     297static ssize_t init_verbs_show(struct device *dev,
     298                               struct device_attribute *attr,
     299                               char *buf)
     300{
     301        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
     302        struct hda_codec *codec = hwdep->private_data;
     303        int i, len = 0;
     304        for (i = 0; i < codec->init_verbs.used; i++) {
     305                struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
     306                len += snprintf(buf + len, PAGE_SIZE - len,
     307                                "0x%02x 0x%03x 0x%04x\n",
     308                                v->nid, v->verb, v->param);
     309        }
     310        return len;
     311}
     312
    272313static ssize_t init_verbs_store(struct device *dev,
    273314                                struct device_attribute *attr,
     
    276317        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
    277318        struct hda_codec *codec = hwdep->private_data;
    278         char *p;
    279         struct hda_verb verb, *v;
    280 
    281         verb.nid = simple_strtoul(buf, &p, 0);
    282         verb.verb = simple_strtoul(p, &p, 0);
    283         verb.param = simple_strtoul(p, &p, 0);
    284         if (!verb.nid || !verb.verb || !verb.param)
     319        struct hda_verb *v;
     320        int nid, verb, param;
     321
     322        if (sscanf(buf, "%i %i %i", &nid, &verb, &param) != 3)
     323                return -EINVAL;
     324        if (!nid || !verb)
    285325                return -EINVAL;
    286326        v = snd_array_new(&codec->init_verbs);
    287327        if (!v)
    288328                return -ENOMEM;
    289         *v = verb;
     329        v->nid = nid;
     330        v->verb = verb;
     331        v->param = param;
    290332        return count;
    291333}
     334
     335static ssize_t hints_show(struct device *dev,
     336                          struct device_attribute *attr,
     337                          char *buf)
     338{
     339        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
     340        struct hda_codec *codec = hwdep->private_data;
     341        int i, len = 0;
     342        for (i = 0; i < codec->hints.used; i++) {
     343                struct hda_hint *hint = snd_array_elem(&codec->hints, i);
     344                len += snprintf(buf + len, PAGE_SIZE - len,
     345                                "%s = %s\n", hint->key, hint->val);
     346        }
     347        return len;
     348}
     349
     350static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
     351{
     352        int i;
     353
     354        for (i = 0; i < codec->hints.used; i++) {
     355                struct hda_hint *hint = snd_array_elem(&codec->hints, i);
     356                if (!strcmp(hint->key, key))
     357                        return hint;
     358        }
     359        return NULL;
     360}
     361
     362static void remove_trail_spaces(char *str)
     363{
     364        char *p;
     365        if (!*str)
     366                return;
     367        p = str + strlen(str) - 1;
     368        for (; isspace(*p); p--) {
     369                *p = 0;
     370                if (p == str)
     371                        return;
     372        }
     373}
     374
     375#define MAX_HINTS       1024
    292376
    293377static ssize_t hints_store(struct device *dev,
     
    297381        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
    298382        struct hda_codec *codec = hwdep->private_data;
    299         char *p;
    300         char **hint;
    301 
    302         if (!*buf || isspace(*buf) || *buf == '#' || *buf == '\n')
     383        char *key, *val;
     384        struct hda_hint *hint;
     385
     386        while (isspace(*buf))
     387                buf++;
     388        if (!*buf || *buf == '#' || *buf == '\n')
    303389                return count;
    304         p = kstrndup_noeol(buf, 1024);
    305         if (!p)
     390        if (*buf == '=')
     391                return -EINVAL;
     392        key = kstrndup_noeol(buf, 1024);
     393        if (!key)
    306394                return -ENOMEM;
    307         hint = snd_array_new(&codec->hints);
     395        /* extract key and val */
     396        val = strchr(key, '=');
     397        if (!val) {
     398                kfree(key);
     399                return -EINVAL;
     400        }
     401        *val++ = 0;
     402        while (isspace(*val))
     403                val++;
     404        remove_trail_spaces(key);
     405        remove_trail_spaces(val);
     406        hint = get_hint(codec, key);
     407        if (hint) {
     408                /* replace */
     409                kfree(hint->key);
     410                hint->key = key;
     411                hint->val = val;
     412                return count;
     413        }
     414        /* allocate a new hint entry */
     415        if (codec->hints.used >= MAX_HINTS)
     416                hint = NULL;
     417        else
     418                hint = snd_array_new(&codec->hints);
    308419        if (!hint) {
    309                 kfree(p);
     420                kfree(key);
    310421                return -ENOMEM;
    311422        }
    312         *hint = p;
     423        hint->key = key;
     424        hint->val = val;
    313425        return count;
    314426}
    315427
    316 #ifndef TARGET_OS2
     428static ssize_t pin_configs_show(struct hda_codec *codec,
     429                                struct snd_array *list,
     430                                char *buf)
     431{
     432        int i, len = 0;
     433        for (i = 0; i < list->used; i++) {
     434                struct hda_pincfg *pin = snd_array_elem(list, i);
     435                len += sprintf(buf + len, "0x%02x 0x%08x\n",
     436                               pin->nid, pin->cfg);
     437        }
     438        return len;
     439}
     440
     441static ssize_t init_pin_configs_show(struct device *dev,
     442                                     struct device_attribute *attr,
     443                                     char *buf)
     444{
     445        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
     446        struct hda_codec *codec = hwdep->private_data;
     447        return pin_configs_show(codec, &codec->init_pins, buf);
     448}
     449
     450static ssize_t user_pin_configs_show(struct device *dev,
     451                                     struct device_attribute *attr,
     452                                     char *buf)
     453{
     454        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
     455        struct hda_codec *codec = hwdep->private_data;
     456        return pin_configs_show(codec, &codec->user_pins, buf);
     457}
     458
     459static ssize_t driver_pin_configs_show(struct device *dev,
     460                                       struct device_attribute *attr,
     461                                       char *buf)
     462{
     463        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
     464        struct hda_codec *codec = hwdep->private_data;
     465        return pin_configs_show(codec, &codec->driver_pins, buf);
     466}
     467
     468#define MAX_PIN_CONFIGS         32
     469
     470static ssize_t user_pin_configs_store(struct device *dev,
     471                                      struct device_attribute *attr,
     472                                      const char *buf, size_t count)
     473{
     474        struct snd_hwdep *hwdep = dev_get_drvdata(dev);
     475        struct hda_codec *codec = hwdep->private_data;
     476        int nid, cfg;
     477        int err;
     478
     479        if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
     480                return -EINVAL;
     481        if (!nid)
     482                return -EINVAL;
     483        err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
     484        if (err < 0)
     485                return err;
     486        return count;
     487}
     488
    317489#define CODEC_ATTR_RW(type) \
    318490        __ATTR(type, 0644, type##_show, type##_store)
     
    330502        CODEC_ATTR_RW(name),
    331503        CODEC_ATTR_RW(modelname),
    332         CODEC_ATTR_WO(init_verbs),
    333         CODEC_ATTR_WO(hints),
     504        CODEC_ATTR_RW(init_verbs),
     505        CODEC_ATTR_RW(hints),
     506        CODEC_ATTR_RO(init_pin_configs),
     507        CODEC_ATTR_RW(user_pin_configs),
     508        CODEC_ATTR_RO(driver_pin_configs),
    334509        CODEC_ATTR_WO(reconfig),
    335510        CODEC_ATTR_WO(clear),
     
    349524        return 0;
    350525}
    351 #endif /* TARGET_OS2 */
     526
     527/*
     528 * Look for hint string
     529 */
     530const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
     531{
     532        struct hda_hint *hint = get_hint(codec, key);
     533        return hint ? hint->val : NULL;
     534}
     535EXPORT_SYMBOL_HDA(snd_hda_get_hint);
     536
     537int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
     538{
     539        const char *p = snd_hda_get_hint(codec, key);
     540        if (!p || !*p)
     541                return -ENOENT;
     542        switch (toupper(*p)) {
     543        case 'T': /* true */
     544        case 'Y': /* yes */
     545        case '1':
     546                return 1;
     547        }
     548        return 0;
     549}
     550EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint);
     551
     552#endif /* CONFIG_SND_HDA_RECONFIG */
  • GPL/trunk/alsa-kernel/pci/hda/hda_intel.c

    r417 r426  
    5151#include "hda_codec.h"
    5252
     53
    5354static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
    5455static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
     
    6061static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
    6162#else
    62 static int bdl_pos_adj[SNDRV_CARDS] = {-1};
    63 static int probe_mask[SNDRV_CARDS] = {-1};
     63static int bdl_pos_adj[SNDRV_CARDS] = {-1,-1,-1,-1,-1,-1,-1,-1};
     64static int probe_mask[SNDRV_CARDS] = {-1,-1,-1,-1,-1,-1,-1,-1};
    6465#endif
     66static int probe_only[SNDRV_CARDS];
    6567static int single_cmd;
    6668static int enable_msi;
     
    8183module_param_array(probe_mask, int, NULL, 0444);
    8284MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
     85module_param_array(probe_only, bool, NULL, 0444);
     86MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization.");
    8387module_param(single_cmd, bool, 0444);
    8488MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
     
    8892
    8993#ifdef CONFIG_SND_HDA_POWER_SAVE
    90 /* power_save option is defined in hda_codec.c */
     94static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
     95module_param(power_save, int, 0644);
     96MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
     97                 "(in second, 0 = disable).");
    9198
    9299/* reset the HD-audio controller in power save mode.
     
    297304#define VIA_HDAC_DEVICE_ID              0x3288
    298305
     306/* HD Audio class code */
     307#define PCI_CLASS_MULTIMEDIA_HD_AUDIO   0x0403
    299308
    300309/*
     
    308317        u32 *posbuf;            /* position buffer pointer */
    309318#endif
     319
    310320        unsigned int bufsize;   /* size of the play buffer in bytes */
    311321        unsigned int period_bytes; /* size of the period in bytes */
    312322        unsigned int frags;     /* number for period in the play buffer */
    313323        unsigned int fifo_size; /* FIFO size */
     324        unsigned long start_jiffies;    /* start + minimum jiffies */
     325        unsigned long min_jiffies;      /* minimum jiffies before position is valid */
    314326
    315327#ifdef TARGET_OS2
     
    334346        unsigned int running :1;
    335347        unsigned int irq_pending :1;
    336         unsigned int irq_ignore :1;
     348        unsigned int start_flag: 1;     /* stream full start flag */
    337349        /*
    338350         * For VIA:
     
    393405        /* HD codec */
    394406        unsigned short codec_mask;
     407        int  codec_probe_mask; /* copied from probe_mask option */
    395408        struct hda_bus *bus;
    396409
     
    435448        AZX_DRIVER_NVIDIA,
    436449        AZX_DRIVER_TERA,
     450        AZX_DRIVER_GENERIC,
    437451        AZX_NUM_DRIVERS, /* keep this as last entry */
    438452};
     
    448462        [AZX_DRIVER_NVIDIA] = "HDA NVidia",
    449463        [AZX_DRIVER_TERA] = "HDA Teradici",
     464        [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
    450465};
    451466
     
    868883}
    869884
    870 /* stop a stream */
    871 static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
    872 {
    873         /* stop DMA */
     885/* stop DMA */
     886static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
     887{
    874888        azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
    875889                      ~(SD_CTL_DMA_START | SD_INT_MASK));
    876890        azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
     891}
     892
     893/* stop a stream */
     894static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
     895{
     896        azx_stream_clear(chip, azx_dev);
    877897        /* disable SIE */
    878898        azx_writeb(chip, INTCTL,
     
    979999        struct azx_dev *azx_dev;
    9801000        u32 status;
    981   #ifdef TARGET_OS2
    982   u32 ignore_irq = 0;
    983   #endif
    984   int i;
     1001#ifdef TARGET_OS2
     1002        u32 ignore_irq = 0;
     1003#endif
     1004        int i, ok;
    9851005
    9861006        spin_lock(&chip->reg_lock);
     
    9981018                        if (!azx_dev->substream || !azx_dev->running)
    9991019                                continue;
    1000                         /* ignore the first dummy IRQ (due to pos_adj) */
    1001                         if (azx_dev->irq_ignore) {
    1002                                 azx_dev->irq_ignore = 0;
    1003               #ifdef TARGET_OS2
    1004               ignore_irq |= azx_dev->sd_int_sta_mask;
    1005               #endif
    1006               continue;
    1007                         }
     1020#if 0 /* ??????? */
     1021#ifdef TARGET_OS2
     1022                        ignore_irq |= azx_dev->sd_int_sta_mask;
     1023#endif
     1024                        continue;
     1025#endif
    10081026                        /* check whether this IRQ is really acceptable */
    1009                         if (azx_position_ok(chip, azx_dev)) {
     1027                        ok = azx_position_ok(chip, azx_dev);
     1028                        if (ok == 1) {
    10101029                                azx_dev->irq_pending = 0;
    10111030                                spin_unlock(&chip->reg_lock);
    10121031                                snd_pcm_period_elapsed(azx_dev->substream);
    10131032                                spin_lock(&chip->reg_lock);
    1014                         } else {
     1033                        } else if (ok == 0 && chip->bus && chip->bus->workq) {
    10151034                                /* bogus IRQ, process it later */
    10161035                                azx_dev->irq_pending = 1;
    1017 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    1018                                 schedule_work(&chip->irq_pending_work);
    1019 #endif
     1036                                queue_work(chip->bus->workq,
     1037                                           &chip->irq_pending_work);
    10201038                        }
    10211039                }
     
    11021120        azx_sd_writel(azx_dev, SD_BDLPU, 0);
    11031121
    1104         period_bytes = snd_pcm_lib_period_bytes(substream);
    1105         azx_dev->period_bytes = period_bytes;
     1122        period_bytes = azx_dev->period_bytes;
    11061123        periods = azx_dev->bufsize / period_bytes;
    11071124
     
    11101127        ofs = 0;
    11111128        azx_dev->frags = 0;
    1112         azx_dev->irq_ignore = 0;
    11131129        pos_adj = bdl_pos_adj[chip->dev_index];
    11141130        if (pos_adj > 0) {
     
    11311147                        if (ofs < 0)
    11321148                                goto error;
    1133                         azx_dev->irq_ignore = 1;
    11341149                }
    11351150        } else
     
    11501165        snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n",
    11511166                   azx_dev->bufsize, period_bytes);
    1152         /* reset */
    1153         azx_sd_writel(azx_dev, SD_BDLPL, 0);
    1154         azx_sd_writel(azx_dev, SD_BDLPU, 0);
    11551167        return -EINVAL;
    11561168}
    11571169
    1158 /*
    1159  * set up the SD for streaming
    1160  */
    1161 static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
     1170/* reset stream */
     1171static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
    11621172{
    11631173        unsigned char val;
    11641174        int timeout;
    11651175
    1166         /* make sure the run bit is zero for SD */
    1167         azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
    1168                       ~SD_CTL_DMA_START);
    1169         /* reset stream */
     1176        azx_stream_clear(chip, azx_dev);
     1177
    11701178        azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
    11711179                      SD_CTL_STREAM_RESET);
     
    11851193                ;
    11861194
     1195        /* reset first position - may not be synced with hw at this time */
     1196        *azx_dev->posbuf = 0;
     1197}
     1198
     1199/*
     1200 * set up the SD for streaming
     1201 */
     1202static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
     1203{
     1204        /* make sure the run bit is zero for SD */
     1205        azx_stream_clear(chip, azx_dev);
    11871206        /* program the stream_tag */
    11881207        azx_sd_writel(azx_dev, SD_CTL,
     
    12551274
    12561275static int __devinit azx_codec_create(struct azx *chip, const char *model,
    1257                                       unsigned int codec_probe_mask)
     1276                                      int no_init)
    12581277{
    12591278        struct hda_bus_template bus_temp;
     
    12691288        bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
    12701289#ifdef CONFIG_SND_HDA_POWER_SAVE
     1290        bus_temp.power_save = &power_save;
    12711291        bus_temp.ops.pm_notify = azx_power_notify;
    12721292#endif
     
    12861306        /* First try to probe all given codec slots */
    12871307        for (c = 0; c < max_slots; c++) {
    1288                 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
     1308                if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
    12891309                        if (probe_codec(chip, c) < 0) {
    12901310                                /* Some BIOSen give you wrong codec addresses
     
    13101330        /* Then create codec instances */
    13111331        for (c = 0; c < max_slots; c++) {
    1312                 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
     1332                if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
    13131333                        struct hda_codec *codec;
    1314                         err = snd_hda_codec_new(chip->bus, c, &codec);
     1334                        err = snd_hda_codec_new(chip->bus, c, !no_init, &codec);
    13151335                        if (err < 0)
    13161336                                continue;
     
    14281448        snd_pcm_set_sync(substream);
    14291449        mutex_unlock(&chip->open_mutex);
     1450
    14301451        return 0;
    14311452}
     
    14541475                             struct snd_pcm_hw_params *hw_params)
    14551476{
     1477        struct azx_dev *azx_dev = get_azx_dev(substream);
     1478
     1479        azx_dev->bufsize = 0;
     1480        azx_dev->period_bytes = 0;
     1481        azx_dev->format_val = 0;
    14561482        return snd_pcm_lib_malloc_pages(substream,
    14571483                                        params_buffer_bytes(hw_params));
     
    14681494        azx_sd_writel(azx_dev, SD_BDLPU, 0);
    14691495        azx_sd_writel(azx_dev, SD_CTL, 0);
     1496        azx_dev->bufsize = 0;
     1497        azx_dev->period_bytes = 0;
     1498        azx_dev->format_val = 0;
    14701499
    14711500        hinfo->ops.cleanup(hinfo, apcm->codec, substream);
     
    14811510        struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
    14821511        struct snd_pcm_runtime *runtime = substream->runtime;
    1483 
    1484         azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream);
    1485         azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate,
    1486                                                          runtime->channels,
    1487                                                          runtime->format,
    1488                                                          hinfo->maxbps);
    1489         if (!azx_dev->format_val) {
     1512        unsigned int bufsize, period_bytes, format_val;
     1513        int err;
     1514
     1515        azx_stream_reset(chip, azx_dev);
     1516        format_val = snd_hda_calc_stream_format(runtime->rate,
     1517                                                runtime->channels,
     1518                                                runtime->format,
     1519                                                hinfo->maxbps);
     1520        if (!format_val) {
    14901521                snd_printk(KERN_ERR SFX
    14911522                           "invalid format_val, rate=%d, ch=%d, format=%d\n",
     
    14941525        }
    14951526
     1527        bufsize = snd_pcm_lib_buffer_bytes(substream);
     1528        period_bytes = snd_pcm_lib_period_bytes(substream);
     1529
    14961530        snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
    1497                     azx_dev->bufsize, azx_dev->format_val);
    1498         if (azx_setup_periods(chip, substream, azx_dev) < 0)
    1499                 return -EINVAL;
     1531                    bufsize, format_val);
     1532
     1533        if (bufsize != azx_dev->bufsize ||
     1534            period_bytes != azx_dev->period_bytes ||
     1535            format_val != azx_dev->format_val) {
     1536                azx_dev->bufsize = bufsize;
     1537                azx_dev->period_bytes = period_bytes;
     1538                azx_dev->format_val = format_val;
     1539                err = azx_setup_periods(chip, substream, azx_dev);
     1540                if (err < 0)
     1541                        return err;
     1542        }
     1543
     1544        azx_dev->min_jiffies = (runtime->period_size * HZ) /
     1545                                                (runtime->rate * 2);
    15001546        azx_setup_controller(chip, azx_dev);
    15011547        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
     
    15141560        struct azx_dev *azx_dev;
    15151561        struct snd_pcm_substream *s;
    1516         int start, nsync = 0, sbits = 0;
     1562        int rstart = 0, start, nsync = 0, sbits = 0;
    15171563        int nwait, timeout;
    15181564
    15191565        switch (cmd) {
     1566        case SNDRV_PCM_TRIGGER_START:
     1567                rstart = 1;
    15201568        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
    15211569        case SNDRV_PCM_TRIGGER_RESUME:
    1522         case SNDRV_PCM_TRIGGER_START:
    15231570                start = 1;
    15241571                break;
     
    15501597                        continue;
    15511598                azx_dev = get_azx_dev(s);
     1599                if (rstart) {
     1600                        azx_dev->start_flag = 1;
     1601                        azx_dev->start_jiffies = jiffies + azx_dev->min_jiffies;
     1602                }
    15521603                if (start)
    15531604                        azx_stream_start(chip, azx_dev);
     
    16991750        unsigned int pos;
    17001751
     1752        if (azx_dev->start_flag &&
     1753            time_before_eq(jiffies, azx_dev->start_jiffies))
     1754                return -1;      /* bogus (too early) interrupt */
     1755        azx_dev->start_flag = 0;
     1756
    17011757        pos = azx_get_position(chip, azx_dev);
    17021758        if (chip->position_fix == POS_FIX_AUTO) {
     
    17671823                chip->azx_dev[i].irq_pending = 0;
    17681824        spin_unlock_irq(&chip->reg_lock);
    1769         flush_scheduled_work();
    17701825}
    17711826
     
    19381993 * power management
    19391994 */
     1995
     1996static int snd_hda_codecs_inuse(struct hda_bus *bus)
     1997{
     1998        struct hda_codec *codec;
     1999
     2000        list_for_each_entry(codec, &bus->codec_list, list, struct hda_codec) {
     2001                if (snd_hda_codec_needs_resume(codec))
     2002                        return 1;
     2003        }
     2004        return 0;
     2005}
     2006
    19402007static int azx_suspend(struct pci_dev *pci, pm_message_t state)
    19412008{
     
    20782145        const struct snd_pci_quirk *q;
    20792146
    2080         /* Check VIA HD Audio Controller exist */
    2081         if (chip->pci->vendor == PCI_VENDOR_ID_VIA &&
    2082             chip->pci->device == VIA_HDAC_DEVICE_ID) {
     2147        switch (fix) {
     2148        case POS_FIX_LPIB:
     2149        case POS_FIX_POSBUF:
     2150                return fix;
     2151        }
     2152
     2153        /* Check VIA/ATI HD Audio Controller exist */
     2154        switch (chip->driver_type) {
     2155        case AZX_DRIVER_VIA:
     2156        case AZX_DRIVER_ATI:
    20832157                chip->via_dmapos_patch = 1;
    20842158                /* Use link position directly, avoid any transfer problem. */
     
    20872161        chip->via_dmapos_patch = 0;
    20882162
    2089         if (fix == POS_FIX_AUTO) {
    2090                 q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
    2091                 if (q) {
    2092                         printk(KERN_INFO
    2093                                     "hda_intel: position_fix set to %d "
    2094                                     "for device %04x:%04x\n",
    2095                                     q->value, q->subvendor, q->subdevice);
    2096                         return q->value;
    2097                 }
    2098         }
    2099         return fix;
     2163        q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
     2164        if (q) {
     2165                printk(KERN_INFO
     2166                       "hda_intel: position_fix set to %d "
     2167                       "for device %04x:%04x\n",
     2168                       q->value, q->subvendor, q->subdevice);
     2169                return q->value;
     2170        }
     2171        return POS_FIX_AUTO;
    21002172}
    21012173
     
    21102182        SND_PCI_QUIRK(0x17aa, 0x2010, "Thinkpad X/T/R60", 0x01),
    21112183        SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X/T/R61", 0x01),
    2112         /* broken BIOS */
    2113         SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
     2184        /* broken BIOS */
     2185        SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
     2186        /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
     2187        SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
     2188        /* forced codec slots */
     2189        SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103),
    21142190        {0}
    21152191};
    21162192
     2193#define AZX_FORCE_CODEC_MASK    0x100
     2194
    21172195static void __devinit check_probe_mask(struct azx *chip, int dev)
    21182196{
    21192197        const struct snd_pci_quirk *q;
    21202198
    2121         if (probe_mask[dev] == -1) {
     2199        chip->codec_probe_mask = probe_mask[dev];
     2200        if (chip->codec_probe_mask == -1) {
    21222201                q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
    21232202                if (q) {
     
    21262205                               "for device %04x:%04x\n",
    21272206                               q->value, q->subvendor, q->subdevice);
    2128                         probe_mask[dev] = q->value;
     2207                        chip->codec_probe_mask = q->value;
    21292208                }
     2209        }
     2210
     2211        /* check forced option */
     2212        if (chip->codec_probe_mask != -1 &&
     2213            (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
     2214                chip->codec_mask = chip->codec_probe_mask & 0xff;
     2215                printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n",
     2216                       chip->codec_mask);
    21302217        }
    21312218}
     
    22252312        snd_printdd("chipset global capabilities = 0x%x\n", gcap);
    22262313
     2314        /* ATI chips seems buggy about 64bit DMA addresses */
     2315        if (chip->driver_type == AZX_DRIVER_ATI)
     2316                gcap &= ~0x01;
     2317
    22272318        /* allow 64bit DMA address if supported by H/W */
    2228         if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_64BIT_MASK))
    2229                 pci_set_consistent_dma_mask(pci, DMA_64BIT_MASK);
     2319        if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
     2320                pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
     2321        else {
     2322                pci_set_dma_mask(pci, DMA_BIT_MASK(32));
     2323                pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
     2324        }
    22302325
    22312326        /* read number of streams from GCAP register instead of using
     
    22462341                        chip->capture_streams = ATIHDMI_NUM_CAPTURE;
    22472342                        break;
     2343                case AZX_DRIVER_GENERIC:
    22482344                default:
    22492345                        chip->playback_streams = ICH6_NUM_PLAYBACK;
     
    23482444        }
    23492445
    2350         card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
    2351         if (!card) {
     2446        err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     2447        if (err < 0) {
    23522448                snd_printk(KERN_ERR SFX "Error creating card!\n");
    2353                 return -ENOMEM;
     2449                return err;
    23542450        }
    23552451
    23562452        err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
    2357         if (err < 0) {
    2358                 snd_card_free(card);
    2359                 return err;
    2360         }
     2453        if (err < 0)
     2454                goto out_free;
    23612455        card->private_data = chip;
    23622456
    23632457        /* create codec instances */
    2364         err = azx_codec_create(chip, model[dev], probe_mask[dev]);
    2365         if (err < 0) {
    2366                 snd_card_free(card);
    2367                 return err;
    2368         }
     2458        err = azx_codec_create(chip, model[dev], probe_only[dev]);
     2459        if (err < 0)
     2460                goto out_free;
    23692461
    23702462        /* create PCM streams */
    23712463        err = snd_hda_build_pcms(chip->bus);
    2372         if (err < 0) {
    2373                 snd_card_free(card);
    2374                 return err;
    2375         }
     2464        if (err < 0)
     2465                goto out_free;
    23762466
    23772467        /* create mixer controls */
    23782468        err = azx_mixer_create(chip);
    2379         if (err < 0) {
    2380                 snd_card_free(card);
    2381                 return err;
    2382         }
     2469        if (err < 0)
     2470                goto out_free;
    23832471
    23842472        snd_card_set_dev(card, &pci->dev);
    23852473
    23862474        err = snd_card_register(card);
    2387         if (err < 0) {
    2388                 snd_card_free(card);
    2389                 return err;
    2390         }
     2475        if (err < 0)
     2476                goto out_free;
    23912477
    23922478        pci_set_drvdata(pci, card);
     
    23962482
    23972483        dev++;
     2484        return err;
     2485out_free:
     2486        snd_card_free(card);
    23982487        return err;
    23992488}
     
    24642553        { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
    24652554        { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
    2466         { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA },
    2467         { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA },
    2468         { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA },
    2469         { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA },
     2555        { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA },
     2556        { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA },
     2557        { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA },
     2558        { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA },
    24702559        /* Teradici */
    24712560        { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
     2561        /* AMD Generic, PCI class code and Vendor ID for HD Audio */
     2562        { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID),
     2563          .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
     2564          .class_mask = 0xffffff,
     2565          .driver_data = AZX_DRIVER_GENERIC },
    24722566        { 0, }
    24732567};
  • GPL/trunk/alsa-kernel/pci/hda/hda_local.h

    r417 r426  
    2727 * for mixer controls
    2828 */
     29#define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs)            \
     30        ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23))
    2931#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
    30         ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19))
     32        HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0)
    3133/* mono volume with index (index=0,1,...) (channel=1,2) */
    3234#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
     
    9799int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
    98100                        unsigned int *tlv, const char **slaves);
    99 void snd_hda_codec_reset(struct hda_codec *codec);
     101int snd_hda_codec_reset(struct hda_codec *codec);
    100102int snd_hda_codec_configure(struct hda_codec *codec);
    101103
     
    135137struct hda_bind_ctls {
    136138        struct hda_ctl_ops *ops;
    137 #ifndef TARGET_OS2
    138         long values[];
    139 #else
    140139        unsigned long values[];
    141 #endif
    142140};
    143141
     
    232230        hda_nid_t extra_out_nid[3];     /* optional DACs, 0 when not exists */
    233231        hda_nid_t dig_out_nid;  /* digital out audio widget */
     232        hda_nid_t *slave_dig_outs;
    234233        int max_channels;       /* currently supported analog channels */
    235234        int dig_out_used;       /* current usage of digital out (HDA_DIG_XXX) */
     
    256255                                  unsigned int format,
    257256                                  struct snd_pcm_substream *substream);
     257int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
     258                                  struct hda_multi_out *mout);
    258259int snd_hda_multi_out_analog_open(struct hda_codec *codec,
    259260                                  struct hda_multi_out *mout,
     
    289290#endif
    290291
     292#define SND_PRINT_RATES_ADVISED_BUFSIZE 80
     293void snd_print_pcm_rates(int pcm, char *buf, int buflen);
     294
     295#define SND_PRINT_BITS_ADVISED_BUFSIZE  16
     296void snd_print_pcm_bits(int pcm, char *buf, int buflen);
     297
    291298/*
    292299 * Misc
     
    295302                               const char **modelnames,
    296303                               const struct snd_pci_quirk *pci_list);
     304int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
     305                               int num_configs, const char **models,
     306                               const struct snd_pci_quirk *tbl);
    297307int snd_hda_add_new_ctls(struct hda_codec *codec,
    298308                         struct snd_kcontrol_new *knew);
     
    348358        hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS];
    349359        hda_nid_t input_pins[AUTO_PIN_LAST];
    350         hda_nid_t dig_out_pin;
     360        int dig_outs;
     361        hda_nid_t dig_out_pins[2];
    351362        hda_nid_t dig_in_pin;
    352363        hda_nid_t mono_out_pin;
     364        int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */
     365        int dig_in_type; /* HDA_PCM_TYPE_XXX */
    353366};
    354367
     
    399412int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
    400413                              unsigned int caps);
     414u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
    401415
    402416int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl);
     
    408422#ifdef CONFIG_SND_HDA_HWDEP
    409423int snd_hda_create_hwdep(struct hda_codec *codec);
     424#else
     425static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
     426#endif
     427
     428#ifdef CONFIG_SND_HDA_RECONFIG
    410429int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
    411430#else
    412 static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
     431static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
     432{
     433        return 0;
     434}
     435#endif
     436
     437#ifdef CONFIG_SND_HDA_RECONFIG
     438const char *snd_hda_get_hint(struct hda_codec *codec, const char *key);
     439int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key);
     440#else
     441static inline
     442const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
     443{
     444        return NULL;
     445}
     446
     447static inline
     448int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
     449{
     450        return -ENOENT;
     451}
    413452#endif
    414453
     
    444483#define get_amp_direction(kc)   (((kc)->private_value >> 18) & 0x1)
    445484#define get_amp_index(kc)       (((kc)->private_value >> 19) & 0xf)
     485#define get_amp_offset(kc)      (((kc)->private_value >> 23) & 0x3f)
     486
     487/*
     488 * CEA Short Audio Descriptor data
     489 */
     490struct cea_sad {
     491        int     channels;
     492        int     format;         /* (format == 0) indicates invalid SAD */
     493        int     rates;
     494        int     sample_bits;    /* for LPCM */
     495        int     max_bitrate;    /* for AC3...ATRAC */
     496        int     profile;        /* for WMAPRO */
     497};
     498
     499#define ELD_FIXED_BYTES 20
     500#define ELD_MAX_MNL     16
     501#define ELD_MAX_SAD     16
     502
     503/*
     504 * ELD: EDID Like Data
     505 */
     506struct hdmi_eld {
     507        int     eld_size;
     508        int     baseline_len;
     509        int     eld_ver;        /* (eld_ver == 0) indicates invalid ELD */
     510        int     cea_edid_ver;
     511        char    monitor_name[ELD_MAX_MNL + 1];
     512        int     manufacture_id;
     513        int     product_id;
     514        u64     port_id;
     515        int     support_hdcp;
     516        int     support_ai;
     517        int     conn_type;
     518        int     aud_synch_delay;
     519        int     spk_alloc;
     520        int     sad_count;
     521        struct cea_sad sad[ELD_MAX_SAD];
     522#ifdef CONFIG_PROC_FS
     523        struct snd_info_entry *proc_entry;
     524#endif
     525};
     526
     527int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
     528int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t);
     529void snd_hdmi_show_eld(struct hdmi_eld *eld);
     530
     531#ifdef CONFIG_PROC_FS
     532int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld);
     533void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld);
     534#else
     535static inline int snd_hda_eld_proc_new(struct hda_codec *codec,
     536                                       struct hdmi_eld *eld)
     537{
     538        return 0;
     539}
     540static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
     541                                         struct hdmi_eld *eld)
     542{
     543}
     544#endif
     545
     546#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
     547void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
    446548
    447549#endif /* __SOUND_HDA_LOCAL_H */
  • GPL/trunk/alsa-kernel/pci/hda/hda_proc.c

    r417 r426  
    9292static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
    9393{
    94         static unsigned int rates[] = {
    95                 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
    96                 96000, 176400, 192000, 384000
    97         };
    98         int i;
     94        char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
    9995
    10096        pcm &= AC_SUPPCM_RATES;
    10197        snd_iprintf(buffer, "    rates [0x%x]:", pcm);
    102         for (i = 0; i < ARRAY_SIZE(rates); i++)
    103                 if (pcm & (1 << i))
    104                         snd_iprintf(buffer, " %d", rates[i]);
    105         snd_iprintf(buffer, "\n");
     98        snd_print_pcm_rates(pcm, buf, sizeof(buf));
     99        snd_iprintf(buffer, "%s\n", buf);
    106100}
    107101
    108102static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
    109103{
    110         static unsigned int bits[] = { 8, 16, 20, 24, 32 };
    111         int i;
    112 
    113         pcm = (pcm >> 16) & 0xff;
    114         snd_iprintf(buffer, "    bits [0x%x]:", pcm);
    115         for (i = 0; i < ARRAY_SIZE(bits); i++)
    116                 if (pcm & (1 << i))
    117                         snd_iprintf(buffer, " %d", bits[i]);
    118         snd_iprintf(buffer, "\n");
     104        char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
     105
     106        snd_iprintf(buffer, "    bits [0x%x]:", (pcm >> 16) & 0xff);
     107        snd_print_pcm_bits(pcm, buf, sizeof(buf));
     108        snd_iprintf(buffer, "%s\n", buf);
    119109}
    120110
     
    410400        int c, curr = -1;
    411401
    412         if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
     402        if (conn_len > 1 &&
     403            wid_type != AC_WID_AUD_MIX &&
     404            wid_type != AC_WID_VOL_KNB &&
     405            wid_type != AC_WID_POWER)
    413406                curr = snd_hda_codec_read(codec, nid, 0,
    414407                                          AC_VERB_GET_CONNECT_SEL, 0);
     
    423416                snd_iprintf(buffer, "\n");
    424417        }
    425 }
    426 
    427 static void print_realtek_coef(struct snd_info_buffer *buffer,
    428                                struct hda_codec *codec, hda_nid_t nid)
    429 {
    430         int coeff = snd_hda_codec_read(codec, nid, 0,
    431                                        AC_VERB_GET_PROC_COEF, 0);
    432         snd_iprintf(buffer, "  Processing Coefficient: 0x%02x\n", coeff);
    433         coeff = snd_hda_codec_read(codec, nid, 0,
    434                                    AC_VERB_GET_COEF_INDEX, 0);
    435         snd_iprintf(buffer, "  Coefficient Index: 0x%02x\n", coeff);
    436418}
    437419
     
    468450                snd_iprintf(buffer,
    469451                            "  IO[%d]: enable=%d, dir=%d, wake=%d, "
    470                             "sticky=%d, data=%d\n", i,
     452                            "sticky=%d, data=%d, unsol=%d\n", i,
    471453                            (enable & (1<<i)) ? 1 : 0,
    472454                            (direction & (1<<i)) ? 1 : 0,
    473455                            (wake & (1<<i)) ? 1 : 0,
    474456                            (sticky & (1<<i)) ? 1 : 0,
    475                             (data & (1<<i)) ? 1 : 0);
     457                            (data & (1<<i)) ? 1 : 0,
     458                            (unsol & (1<<i)) ? 1 : 0);
    476459        /* FIXME: add GPO and GPI pin information */
    477460}
     
    487470                    codec->name ? codec->name : "Not Set");
    488471        snd_iprintf(buffer, "Address: %d\n", codec->addr);
    489         snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
    490         snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
     472        snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id);
     473        snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
     474        snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
    491475        snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
    492476
     
    514498
    515499        print_gpio(buffer, codec, codec->afg);
     500        if (codec->proc_widget_hook)
     501                codec->proc_widget_hook(buffer, codec, codec->afg);
    516502
    517503        for (i = 0; i < nodes; i++, nid++) {
     
    572558                        print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
    573559                        snd_iprintf(buffer, "  Amp-Out vals: ");
    574                         print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
    575                                        wid_caps & AC_WCAP_STEREO, 1);
     560                        if (wid_type == AC_WID_PIN &&
     561                            codec->pin_amp_workaround)
     562                                print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
     563                                               wid_caps & AC_WCAP_STEREO,
     564                                               conn_len);
     565                        else
     566                                print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
     567                                               wid_caps & AC_WCAP_STEREO, 1);
    576568                }
    577569
     
    616608                        print_proc_caps(buffer, codec, nid);
    617609
    618                 /* NID 0x20 == Realtek Define Registers */
    619                 if (codec->vendor_id == 0x10ec && nid == 0x20)
    620                         print_realtek_coef(buffer, codec, nid);
     610                if (codec->proc_widget_hook)
     611                        codec->proc_widget_hook(buffer, codec, nid);
    621612        }
    622613        snd_hda_power_down(codec);
  • GPL/trunk/alsa-kernel/pci/hda/patch_analog.c

    r417 r426  
    2828#include "hda_codec.h"
    2929#include "hda_local.h"
    30 #include "hda_patch.h"
     30#include "hda_beep.h"
    3131
    3232struct ad198x_spec {
    3333        struct snd_kcontrol_new *mixers[5];
    3434        int num_mixers;
    35 
     35        unsigned int beep_amp;  /* beep amp value, set via set_beep_amp() */
    3636        const struct hda_verb *init_verbs[5];   /* initialization verbs
    3737                                                 * don't forget NULL termination!
     
    155155
    156156static void ad198x_free_kctls(struct hda_codec *codec);
     157
     158/* additional beep mixers; the actual parameters are overwritten at build */
     159static struct snd_kcontrol_new ad_beep_mixer[] = {
     160        HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
     161        HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_OUTPUT),
     162        {0} /* end */
     163};
     164
     165#define set_beep_amp(spec, nid, idx, dir) \
     166        ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
    157167
    158168static int ad198x_build_controls(struct hda_codec *codec)
     
    183193        }
    184194
     195        /* create beep controls if needed */
     196        if (spec->beep_amp) {
     197                struct snd_kcontrol_new *knew;
     198                for (knew = ad_beep_mixer; knew->name; knew++) {
     199                        struct snd_kcontrol *kctl;
     200                        kctl = snd_ctl_new1(knew, codec);
     201                        if (!kctl)
     202                                return -ENOMEM;
     203                        kctl->private_value = spec->beep_amp;
     204                        err = snd_hda_ctl_add(codec, kctl);
     205                        if (err < 0)
     206                                return err;
     207                }
     208        }
     209
    185210        /* if we have no master control, let's create it */
    186211        if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
     
    277302}
    278303
     304static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
     305                                           struct hda_codec *codec,
     306                                           struct snd_pcm_substream *substream)
     307{
     308        struct ad198x_spec *spec = codec->spec;
     309        return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
     310}
     311
    279312/*
    280313 * Analog capture
     
    335368                .open = ad198x_dig_playback_pcm_open,
    336369                .close = ad198x_dig_playback_pcm_close,
    337                 .prepare = ad198x_dig_playback_pcm_prepare
     370                .prepare = ad198x_dig_playback_pcm_prepare,
     371                .cleanup = ad198x_dig_playback_pcm_cleanup
    338372        },
    339373};
     
    399433
    400434        ad198x_free_kctls(codec);
    401         kfree(codec->spec);
     435        kfree(spec);
     436        snd_hda_detach_beep_device(codec);
    402437}
    403438
     
    538573        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    539574        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
    540         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
    541         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
    542575        HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
    543576        HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
     
    603636        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    604637        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
    605         /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
    606            HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
     638        /*
    607639           HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
    608640           HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
     
    639671
    640672static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
     673        HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
     674        HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
     675        HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
     676        HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
     677        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
     678        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
     679        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
     680        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
     681        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
     682        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
     683        HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
     684        {
     685                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     686                .name = "Capture Source",
     687                .info = ad198x_mux_enum_info,
     688                .get = ad198x_mux_enum_get,
     689                .put = ad198x_mux_enum_put,
     690        },
     691        {
     692                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     693                .name = "External Amplifier",
     694                .info = ad198x_eapd_info,
     695                .get = ad198x_eapd_get,
     696                .put = ad198x_eapd_put,
     697                .private_value = 0x1b | (1 << 8), /* port-D, inversed */
     698        },
     699        {0} /* end */
     700};
     701
     702static struct snd_kcontrol_new ad1986a_samsung_mixers[] = {
    641703        HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
    642704        HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
     
    772834        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    773835        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
    774         HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT),
    775         HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT),
    776836        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
    777837        HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
     
    931991        AD1986A_LAPTOP_AUTOMUTE,
    932992        AD1986A_ULTRA,
     993        AD1986A_SAMSUNG,
    933994        AD1986A_MODELS
    934995};
     
    9411002        [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
    9421003        [AD1986A_ULTRA]         = "ultra",
     1004        [AD1986A_SAMSUNG]       = "samsung",
    9431005};
    9441006
     
    9631025        SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
    9641026        SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
    965         SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
    966         SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
    967         SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
    9681027        SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
     1028        SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
    9691029        SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
    9701030        SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
     
    9881048static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
    9891049{
    990         unsigned int conf = snd_hda_codec_read(codec, nid, 0,
    991                                                AC_VERB_GET_CONFIG_DEFAULT, 0);
     1050        unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
    9921051        return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
    9931052}
     
    9961055{
    9971056        struct ad198x_spec *spec;
    998         int board_config;
     1057        int err, board_config;
    9991058
    10001059        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    10031062
    10041063        codec->spec = spec;
     1064
     1065        err = snd_hda_attach_beep_device(codec, 0x19);
     1066        if (err < 0) {
     1067                ad198x_free(codec);
     1068                return err;
     1069        }
     1070        set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
    10051071
    10061072        spec->multiout.max_channels = 6;
     
    10471113        case AD1986A_LAPTOP_EAPD:
    10481114                spec->mixers[0] = ad1986a_laptop_eapd_mixers;
     1115                spec->num_init_verbs = 2;
     1116                spec->init_verbs[1] = ad1986a_eapd_init_verbs;
     1117                spec->multiout.max_channels = 2;
     1118                spec->multiout.num_dacs = 1;
     1119                spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
     1120                if (!is_jack_available(codec, 0x25))
     1121                        spec->multiout.dig_out_nid = 0;
     1122                spec->input_mux = &ad1986a_laptop_eapd_capture_source;
     1123                break;
     1124        case AD1986A_SAMSUNG:
     1125                spec->mixers[0] = ad1986a_samsung_mixers;
    10491126                spec->num_init_verbs = 3;
    10501127                spec->init_verbs[1] = ad1986a_eapd_init_verbs;
     
    11721249        HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
    11731250        HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
    1174         HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
    1175         HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
    11761251        HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
    11771252        HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
     
    12441319{
    12451320        struct ad198x_spec *spec;
     1321        int err;
    12461322
    12471323        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    12501326
    12511327        codec->spec = spec;
     1328
     1329        err = snd_hda_attach_beep_device(codec, 0x10);
     1330        if (err < 0) {
     1331                ad198x_free(codec);
     1332                return err;
     1333        }
     1334        set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
    12521335
    12531336        spec->multiout.max_channels = 2;
     
    13201403        HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
    13211404        HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
    1322         HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
    1323         HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
    13241405        HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
    13251406        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
     
    13661447        {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
    13671448        /* Mic boost: 0dB */
    1368         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
    1369         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
     1449        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     1450        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    13701451        /* Record selector: Front mic */
    13711452        {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
     
    16321713        SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
    16331714        /* All HP models */
    1634         SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
     1715        SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP),
    16351716        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
    16361717        /* Lenovo Thinkpad T60/X60/Z6xx */
    1637         SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
     1718        SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD),
    16381719        /* HP nx6320 (reversed SSID, H/W bug) */
    16391720        SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
     
    16441725{
    16451726        struct ad198x_spec *spec;
    1646         int board_config;
     1727        int err, board_config;
    16471728
    16481729        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    16511732
    16521733        codec->spec = spec;
     1734
     1735        err = snd_hda_attach_beep_device(codec, 0x10);
     1736        if (err < 0) {
     1737                ad198x_free(codec);
     1738                return err;
     1739        }
     1740        set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
    16531741
    16541742        spec->multiout.max_channels = 2;
     
    18441932#define AD1988_SPDIF_IN         0x07
    18451933
    1846 static hda_nid_t ad1989b_slave_dig_outs[2] = {
    1847         AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI
     1934static hda_nid_t ad1989b_slave_dig_outs[] = {
     1935        AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0
    18481936};
    18491937
     
    19382026        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
    19392027
    1940         HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
    1941         HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
    1942 
    19432028        HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
    19442029        HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     
    19842069        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
    19852070
    1986         HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
    1987         HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
    1988 
    19892071        HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
    19902072        HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
     
    20152097        HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
    20162098        HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
    2017 
    2018         HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
    2019         HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
    20202099
    20212100        HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
     
    22472326        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
    22482327        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
    2249         /* ADCs; muted */
    2250         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2251         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2252         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    22532328
    22542329        {0}
     
    23582433        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
    23592434        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
    2360         /* ADCs; muted */
    2361         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2362         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2363         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    23642435        /* Analog Mix output amp */
    23652436        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
     
    24332504        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
    24342505        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
    2435         /* ADCs; muted */
    2436         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2437         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    2438         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    24392506        /* Analog Mix output amp */
    24402507        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
     
    28402907        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    28412908
    2842         if (spec->autocfg.dig_out_pin)
     2909        if (spec->autocfg.dig_outs)
    28432910                spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
    28442911        if (spec->autocfg.dig_in_pin)
     
    28902957{
    28912958        struct ad198x_spec *spec;
    2892         int board_config;
     2959        int err, board_config;
    28932960
    28942961        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    29102977        if (board_config == AD1988_AUTO) {
    29112978                /* automatic parse from the BIOS config */
    2912                 int err = ad1988_parse_auto_config(codec);
     2979                err = ad1988_parse_auto_config(codec);
    29132980                if (err < 0) {
    29142981                        ad198x_free(codec);
     
    29192986                }
    29202987        }
     2988
     2989        err = snd_hda_attach_beep_device(codec, 0x10);
     2990        if (err < 0) {
     2991                ad198x_free(codec);
     2992                return err;
     2993        }
     2994        set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
    29212995
    29222996        switch (board_config) {
     
    30763150        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
    30773151        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
    3078         /*
    3079         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
    3080         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
    3081         HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
    3082         HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
    3083         */
    30843152        HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
    30853153        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
     
    31543222        /* Port-B (front mic) pin */
    31553223        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    3156         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3224        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    31573225        /* Port-C (rear mic) pin */
    31583226        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    3159         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3227        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    31603228        /* Analog mixer; mute as default */
    31613229        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     
    31893257        "CD Playback Volume",
    31903258        "Internal Mic Playback Volume",
    3191         "Docking Mic Playback Volume"
    3192         "Beep Playback Volume",
     3259        "Docking Mic Playback Volume",
     3260        /* "Beep Playback Volume", */
    31933261        "IEC958 Playback Volume",
    31943262        NULL
     
    31983266{
    31993267        struct ad198x_spec *spec;
     3268        int err;
    32003269
    32013270        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    32043273
    32053274        codec->spec = spec;
     3275
     3276        err = snd_hda_attach_beep_device(codec, 0x10);
     3277        if (err < 0) {
     3278                ad198x_free(codec);
     3279                return err;
     3280        }
     3281        set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
    32063282
    32073283        spec->multiout.max_channels = 2;
     
    32713347        HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
    32723348        HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
    3273         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
    3274         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
    32753349        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
    32763350        HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
     
    33083382        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    33093383        /* docking mic boost */
    3310         {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3384        {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    33113385        /* Analog mixer - docking mic; mute as default */
    33123386        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     
    33293403        HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
    33303404        HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
    3331         /*
    3332         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
    3333         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
    3334         */
    33353405        HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
    33363406        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
     
    34183488static struct snd_pci_quirk ad1984_cfg_tbl[] = {
    34193489        /* Lenovo Thinkpad T61/X61 */
    3420         SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
     3490        SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD),
    34213491        SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
    34223492        {0}
     
    35113581        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
    35123582        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
    3513         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
    3514         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
    35153583        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
    35163584        HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
     
    35723640        /* Port-B (front mic) pin */
    35733641        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
    3574         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3642        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    35753643        /* Port-C (rear line-in) pin */
    35763644        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
    3577         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3645        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    35783646        /* Port-E (rear mic) pin */
    35793647        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     
    36453713        HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
    36463714        HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
    3647         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
    3648         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
    36493715        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
    36503716        HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
     
    36743740        HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
    36753741        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
    3676         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
    3677         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
    36783742        HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
    36793743        HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
     
    37543818};
    37553819
     3820static struct hda_verb ad1884a_mobile_verbs[] = {
     3821        /* DACs; unmute as default */
     3822        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
     3823        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
     3824        /* Port-A (HP) mixer - route only from analog mixer */
     3825        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3826        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     3827        /* Port-A pin */
     3828        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3829        /* Port-A (HP) pin - always unmuted */
     3830        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     3831        /* Port-B (mic jack) pin */
     3832        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3833        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
     3834        /* Port-C (int mic) pin */
     3835        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     3836        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
     3837        /* Port-F (int speaker) mixer - route only from analog mixer */
     3838        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3839        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     3840        /* Port-F pin */
     3841        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     3842        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3843        /* Analog mixer; mute as default */
     3844        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     3845        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     3846        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
     3847        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
     3848        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
     3849        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
     3850        /* Analog Mix output amp */
     3851        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3852        /* capture sources */
     3853        /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
     3854        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3855        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
     3856        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
     3857        /* unsolicited event for pin-sense */
     3858        {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
     3859        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
     3860        {0} /* end */
     3861};
     3862
    37563863/*
    37573864 * Thinkpad X300
     
    37863893        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
    37873894        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
    3788         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
    3789         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
    37903895        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
    37913896        HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
     
    38593964static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
    38603965        SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
     3966        SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
    38613967        SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
    3862         SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP),
    3863         SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP),
     3968        SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE),
     3969        SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP),
     3970        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
    38643971        SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
    38653972        {0}
     
    38693976{
    38703977        struct ad198x_spec *spec;
    3871         int board_config;
     3978        int err, board_config;
    38723979
    38733980        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    38763983
    38773984        codec->spec = spec;
     3985
     3986        err = snd_hda_attach_beep_device(codec, 0x10);
     3987        if (err < 0) {
     3988                ad198x_free(codec);
     3989                return err;
     3990        }
     3991        set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
    38783992
    38793993        spec->multiout.max_channels = 2;
     
    39074021                codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
    39084022                codec->patch_ops.init = ad1884a_hp_init;
     4023                /* set the upper-limit for mixer amp to 0dB for avoiding the
     4024                 * possible damage by overloading
     4025                 */
     4026                snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
     4027                                          (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
     4028                                          (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
     4029                                          (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
     4030                                          (1 << AC_AMPCAP_MUTE_SHIFT));
    39094031                break;
    39104032        case AD1884A_MOBILE:
    39114033                spec->mixers[0] = ad1884a_mobile_mixers;
    3912                 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
     4034                spec->init_verbs[0] = ad1884a_mobile_verbs;
    39134035                spec->multiout.dig_out_nid = 0;
    39144036                codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
    39154037                codec->patch_ops.init = ad1884a_hp_init;
     4038                /* set the upper-limit for mixer amp to 0dB for avoiding the
     4039                 * possible damage by overloading
     4040                 */
     4041                snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
     4042                                          (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
     4043                                          (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
     4044                                          (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
     4045                                          (1 << AC_AMPCAP_MUTE_SHIFT));
    39164046                break;
    39174047        case AD1884A_THINKPAD:
     
    40314161        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
    40324162        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
    4033         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
    4034         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
    40354163        {0} /* end */
    40364164};
     
    40454173        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
    40464174        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
    4047         HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
    4048         HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
    40494175        HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT),
    40504176        {0} /* end */
     
    42054331{
    42064332        struct ad198x_spec *spec;
    4207         int board_config;
     4333        int err, board_config;
    42084334
    42094335        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    42124338
    42134339        codec->spec = spec;
     4340
     4341        err = snd_hda_attach_beep_device(codec, 0x10);
     4342        if (err < 0) {
     4343                ad198x_free(codec);
     4344                return err;
     4345        }
     4346        set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
    42144347
    42154348        spec->multiout.max_channels = 6;
     
    42204353        spec->adc_nids = ad1882_adc_nids;
    42214354        spec->capsrc_nids = ad1882_capsrc_nids;
    4222         if (codec->vendor_id == 0x11d1882)
     4355        if (codec->vendor_id == 0x11d41882)
    42234356                spec->input_mux = &ad1882_capture_source;
    42244357        else
     
    42264359        spec->num_mixers = 2;
    42274360        spec->mixers[0] = ad1882_base_mixers;
    4228         if (codec->vendor_id == 0x11d1882)
     4361        if (codec->vendor_id == 0x11d41882)
    42294362                spec->mixers[1] = ad1882_loopback_mixers;
    42304363        else
     
    42664399 * patch entries
    42674400 */
    4268 struct hda_codec_preset snd_hda_preset_analog[] = {
     4401static struct hda_codec_preset snd_hda_preset_analog[] = {
    42694402        { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
    42704403        { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
     
    42844417        {0} /* terminator */
    42854418};
     4419
     4420MODULE_ALIAS("snd-hda-codec-id:11d4*");
     4421
     4422MODULE_LICENSE("GPL");
     4423MODULE_DESCRIPTION("Analog Devices HD-audio codec");
     4424
     4425static struct hda_codec_preset_list analog_list = {
     4426        .preset = snd_hda_preset_analog,
     4427        .owner = THIS_MODULE,
     4428};
     4429
     4430static int __init patch_analog_init(void)
     4431{
     4432        return snd_hda_add_codec_preset(&analog_list);
     4433}
     4434
     4435static void __exit patch_analog_exit(void)
     4436{
     4437        snd_hda_delete_codec_preset(&analog_list);
     4438}
     4439
     4440module_init(patch_analog_init)
     4441module_exit(patch_analog_exit)
  • GPL/trunk/alsa-kernel/pci/hda/patch_atihdmi.c

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

    r417 r426  
    2929#include "hda_codec.h"
    3030#include "hda_local.h"
    31 #include "hda_patch.h"
    3231#define NUM_PINS        11
    3332
     
    682681
    683682                /* collect pin default configuration */
    684                 port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
    685                 port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     683                port_e = snd_hda_codec_get_pincfg(codec, 0x0f);
     684                port_f = snd_hda_codec_get_pincfg(codec, 0x10);
    686685                spec->front_panel = 1;
    687686                if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE ||
    688687                    get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) {
    689                         port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
    690                         port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     688                        port_g = snd_hda_codec_get_pincfg(codec, 0x1f);
     689                        port_h = snd_hda_codec_get_pincfg(codec, 0x20);
    691690                        spec->channel_modes = cmi9880_channel_modes;
    692691                        /* no front panel */
     
    705704                } else {
    706705                        spec->input_mux = &cmi9880_basic_mux;
    707                         port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
    708                         port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     706                        port_spdifi = snd_hda_codec_get_pincfg(codec, 0x13);
     707                        port_spdifo = snd_hda_codec_get_pincfg(codec, 0x12);
    709708                        if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE)
    710709                                spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
     
    737736 * patch entries
    738737 */
    739 struct hda_codec_preset snd_hda_preset_cmedia[] = {
     738static struct hda_codec_preset snd_hda_preset_cmedia[] = {
    740739        { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 },
    741740        { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 },
    742741        {0} /* terminator */
    743742};
     743
     744MODULE_ALIAS("snd-hda-codec-id:13f69880");
     745MODULE_ALIAS("snd-hda-codec-id:434d4980");
     746
     747MODULE_LICENSE("GPL");
     748MODULE_DESCRIPTION("C-Media HD-audio codec");
     749
     750static struct hda_codec_preset_list cmedia_list = {
     751        .preset = snd_hda_preset_cmedia,
     752        .owner = THIS_MODULE,
     753};
     754
     755static int __init patch_cmedia_init(void)
     756{
     757        return snd_hda_add_codec_preset(&cmedia_list);
     758}
     759
     760static void __exit patch_cmedia_exit(void)
     761{
     762        snd_hda_delete_codec_preset(&cmedia_list);
     763}
     764
     765module_init(patch_cmedia_init)
     766module_exit(patch_cmedia_exit)
  • GPL/trunk/alsa-kernel/pci/hda/patch_conexant.c

    r417 r426  
    2626#include <linux/pci.h>
    2727#include <sound/core.h>
     28#include <sound/jack.h>
     29
    2830#include "hda_codec.h"
    2931#include "hda_local.h"
    30 #include "hda_patch.h"
    3132
    3233#define CXT_PIN_DIR_IN              0x00
     
    3940#define CONEXANT_MIC_EVENT      0x38
    4041
    41 
     42/* Conexant 5051 specific */
     43
     44#define CXT5051_SPDIF_OUT       0x1C
     45#define CXT5051_PORTB_EVENT     0x38
     46#define CXT5051_PORTC_EVENT     0x39
     47
     48
     49struct conexant_jack {
     50
     51        hda_nid_t nid;
     52        int type;
     53        struct snd_jack *jack;
     54
     55};
    4256
    4357struct conexant_spec {
     
    4559        struct snd_kcontrol_new *mixers[5];
    4660        int num_mixers;
     61        hda_nid_t vmaster_nid;
    4762
    4863        const struct hda_verb *init_verbs[5];   /* initialization verbs
     
    5974        unsigned int cur_eapd;
    6075        unsigned int hp_present;
     76        unsigned int no_auto_mic;
    6177        unsigned int need_dac_fix;
    6278
     
    84100
    85101        unsigned int spdif_route;
     102
     103        /* jack detection */
     104        struct snd_array jacks;
    86105
    87106        /* dynamic controls, init_verbs and input_mux */
     
    331350}
    332351
     352#ifdef CONFIG_SND_JACK
     353static void conexant_free_jack_priv(struct snd_jack *jack)
     354{
     355        struct conexant_jack *jacks = jack->private_data;
     356        jacks->nid = 0;
     357        jacks->jack = NULL;
     358}
     359
     360static int conexant_add_jack(struct hda_codec *codec,
     361                hda_nid_t nid, int type)
     362{
     363        struct conexant_spec *spec;
     364        struct conexant_jack *jack;
     365        const char *name;
     366        int err;
     367
     368        spec = codec->spec;
     369        snd_array_init(&spec->jacks, sizeof(*jack), 32);
     370        jack = snd_array_new(&spec->jacks);
     371        name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
     372
     373        if (!jack)
     374                return -ENOMEM;
     375
     376        jack->nid = nid;
     377        jack->type = type;
     378
     379        err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
     380        if (err < 0)
     381                return err;
     382        jack->jack->private_data = jack;
     383        jack->jack->private_free = conexant_free_jack_priv;
     384        return 0;
     385}
     386
     387static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
     388{
     389        struct conexant_spec *spec = codec->spec;
     390        struct conexant_jack *jacks = spec->jacks.list;
     391
     392        if (jacks) {
     393                int i;
     394                for (i = 0; i < spec->jacks.used; i++) {
     395                        if (jacks->nid == nid) {
     396                                unsigned int present;
     397                                present = snd_hda_codec_read(codec, nid, 0,
     398                                                AC_VERB_GET_PIN_SENSE, 0) &
     399                                        AC_PINSENSE_PRESENCE;
     400
     401                                present = (present) ? jacks->type : 0 ;
     402
     403                                snd_jack_report(jacks->jack,
     404                                                present);
     405                        }
     406                        jacks++;
     407                }
     408        }
     409}
     410
     411static int conexant_init_jacks(struct hda_codec *codec)
     412{
     413        struct conexant_spec *spec = codec->spec;
     414        int i;
     415
     416        for (i = 0; i < spec->num_init_verbs; i++) {
     417                const struct hda_verb *hv;
     418
     419                hv = spec->init_verbs[i];
     420                while (hv->nid) {
     421                        int err = 0;
     422                        switch (hv->param ^ AC_USRSP_EN) {
     423                        case CONEXANT_HP_EVENT:
     424                                err = conexant_add_jack(codec, hv->nid,
     425                                                SND_JACK_HEADPHONE);
     426                                conexant_report_jack(codec, hv->nid);
     427                                break;
     428                        case CXT5051_PORTC_EVENT:
     429                        case CONEXANT_MIC_EVENT:
     430                                err = conexant_add_jack(codec, hv->nid,
     431                                                SND_JACK_MICROPHONE);
     432                                conexant_report_jack(codec, hv->nid);
     433                                break;
     434                        }
     435                        if (err < 0)
     436                                return err;
     437                        ++hv;
     438                }
     439        }
     440        return 0;
     441
     442}
     443#else
     444static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
     445{
     446}
     447
     448static inline int conexant_init_jacks(struct hda_codec *codec)
     449{
     450        return 0;
     451}
     452#endif
     453
    333454static int conexant_init(struct hda_codec *codec)
    334455{
     
    343464static void conexant_free(struct hda_codec *codec)
    344465{
     466#ifdef CONFIG_SND_JACK
     467        struct conexant_spec *spec = codec->spec;
     468        if (spec->jacks.list) {
     469                struct conexant_jack *jacks = spec->jacks.list;
     470                int i;
     471                for (i = 0; i < spec->jacks.used; i++, jacks++) {
     472                        if (jacks->jack)
     473                                snd_device_free(codec->bus->card, jacks->jack);
     474                }
     475                snd_array_free(&spec->jacks);
     476        }
     477#endif
    345478        kfree(codec->spec);
    346479}
     480
     481static struct snd_kcontrol_new cxt_capture_mixers[] = {
     482        {
     483                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     484                .name = "Capture Source",
     485                .info = conexant_mux_enum_info,
     486                .get = conexant_mux_enum_get,
     487                .put = conexant_mux_enum_put
     488        },
     489        {0}
     490};
     491
     492static const char *slave_vols[] = {
     493        "Headphone Playback Volume",
     494        "Speaker Playback Volume",
     495        NULL
     496};
     497
     498static const char *slave_sws[] = {
     499        "Headphone Playback Switch",
     500        "Speaker Playback Switch",
     501        NULL
     502};
    347503
    348504static int conexant_build_controls(struct hda_codec *codec)
     
    373529                        return err;
    374530        }
     531
     532        /* if we have no master control, let's create it */
     533        if (spec->vmaster_nid &&
     534            !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
     535                unsigned int vmaster_tlv[4];
     536                snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
     537                                        HDA_OUTPUT, vmaster_tlv);
     538                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
     539                                          vmaster_tlv, slave_vols);
     540                if (err < 0)
     541                        return err;
     542        }
     543        if (spec->vmaster_nid &&
     544            !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
     545                err = snd_hda_add_vmaster(codec, "Master Playback Switch",
     546                                          NULL, slave_sws);
     547                if (err < 0)
     548                        return err;
     549        }
     550
     551        if (spec->input_mux) {
     552                err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
     553                if (err < 0)
     554                        return err;
     555        }
     556
    375557        return 0;
    376558}
     
    604786
    605787static struct snd_kcontrol_new cxt5045_mixers[] = {
    606         {
    607                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    608                 .name = "Capture Source",
    609                 .info = conexant_mux_enum_info,
    610                 .get = conexant_mux_enum_get,
    611                 .put = conexant_mux_enum_put
    612         },
    613788        HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
    614789        HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
     
    644819
    645820static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
    646         {
    647                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    648                 .name = "Capture Source",
    649                 .info = conexant_mux_enum_info,
    650                 .get = conexant_mux_enum_get,
    651                 .put = conexant_mux_enum_put
    652         },
    653821        HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
    654822        HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
     
    8871055
    8881056static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
    889         SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
    890         SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
    891         SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
    892         SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
    893         SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
    894         SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
    895         SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
    8961057        SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
    897         SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
     1058        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
     1059                           CXT5045_LAPTOP_HPSENSE),
    8981060        SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
    8991061        SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
     
    9051067        SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
    9061068        SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
    907         SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
    908         SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
     1069        SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
     1070                          CXT5045_LAPTOP_HPMICSENSE),
    9091071        SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
    9101072        {0}
     
    9201082                return -ENOMEM;
    9211083        codec->spec = spec;
     1084        codec->pin_amp_workaround = 1;
    9221085
    9231086        spec->multiout.max_channels = 2;
     
    10191182#define CXT5047_SPDIF_OUT       0x11
    10201183
    1021 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
     1184static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
    10221185static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
    10231186static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
     
    10251188static struct hda_channel_mode cxt5047_modes[1] = {
    10261189        { 2, NULL },
    1027 };
    1028 
    1029 static struct hda_input_mux cxt5047_capture_source = {
    1030         .num_items = 1,
    1031         .items = {
    1032                 { "Mic", 0x2 },
    1033         }
    1034 };
    1035 
    1036 static struct hda_input_mux cxt5047_hp_capture_source = {
    1037         .num_items = 1,
    1038         .items = {
    1039                 { "ExtMic", 0x2 },
    1040         }
    10411190};
    10421191
     
    10641213         */
    10651214        bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
    1066         snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
     1215        /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
     1216         * pin widgets unlike other codecs.  In this case, we need to
     1217         * set index 0x01 for the volume from the mixer amp 0x19.
     1218         */
     1219        snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
    10671220                                 HDA_AMP_MUTE, bits);
    10681221        bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
     
    10721225}
    10731226
    1074 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
    1075 static struct hda_bind_ctls cxt5047_bind_master_vol = {
    1076         .ops = &snd_hda_bind_vol,
    1077         .values = {
    1078                 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
    1079                 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
    1080                 0
    1081         },
    1082 };
    1083 
    10841227/* mute internal speaker if HP is plugged */
    10851228static void cxt5047_hp_automute(struct hda_codec *codec)
     
    10921235
    10931236        bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
    1094         snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
    1095                                  HDA_AMP_MUTE, bits);
    1096         /* Mute/Unmute PCM 2 for good measure - some systems need this */
    1097         snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
    1098                                  HDA_AMP_MUTE, bits);
    1099 }
    1100 
    1101 /* mute internal speaker if HP is plugged */
    1102 static void cxt5047_hp2_automute(struct hda_codec *codec)
    1103 {
    1104         struct conexant_spec *spec = codec->spec;
    1105         unsigned int bits;
    1106 
    1107         spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
    1108                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
    1109 
    1110         bits = spec->hp_present ? HDA_AMP_MUTE : 0;
    1111         snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
    1112                                  HDA_AMP_MUTE, bits);
    1113         /* Mute/Unmute PCM 2 for good measure - some systems need this */
    1114         snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
     1237        /* See the note in cxt5047_hp_master_sw_put */
     1238        snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
    11151239                                 HDA_AMP_MUTE, bits);
    11161240}
     
    11531277}
    11541278
    1155 /* unsolicited event for HP jack sensing - non-EAPD systems */
    1156 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
    1157                                   unsigned int res)
    1158 {
    1159         res >>= 26;
    1160         switch (res) {
    1161         case CONEXANT_HP_EVENT:
    1162                 cxt5047_hp2_automute(codec);
    1163                 break;
    1164         case CONEXANT_MIC_EVENT:
    1165                 cxt5047_hp_automic(codec);
    1166                 break;
    1167         }
    1168 }
    1169 
    1170 static struct snd_kcontrol_new cxt5047_mixers[] = {
    1171         HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
    1172         HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
    1173         HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
    1174         HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
     1279static struct snd_kcontrol_new cxt5047_base_mixers[] = {
     1280        HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
     1281        HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
     1282        HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT),
    11751283        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
    11761284        HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
    11771285        HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
    11781286        HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
    1179         HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
    1180         HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
    1181         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
    1182         HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
    1183         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
    1184         HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
    1185 
    1186         {0}
    1187 };
    1188 
    1189 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
    1190         {
    1191                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1192                 .name = "Capture Source",
    1193                 .info = conexant_mux_enum_info,
    1194                 .get = conexant_mux_enum_get,
    1195                 .put = conexant_mux_enum_put
    1196         },
    1197         HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
    1198         HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
    1199         HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
    1200         HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
    1201         HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
    1202         HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
    1203         HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
    12041287        {
    12051288                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    12141297};
    12151298
    1216 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
    1217         {
    1218                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1219                 .name = "Capture Source",
    1220                 .info = conexant_mux_enum_info,
    1221                 .get = conexant_mux_enum_get,
    1222                 .put = conexant_mux_enum_put
    1223         },
    1224         HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
    1225         HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
    1226         HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
    1227         HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
    1228         HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
    1229         HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
     1299static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
     1300        /* See the note in cxt5047_hp_master_sw_put */
     1301        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
     1302        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
     1303        {0}
     1304};
     1305
     1306static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
    12301307        HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
    1231         {
    1232                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1233                 .name = "Master Playback Switch",
    1234                 .info = cxt_eapd_info,
    1235                 .get = cxt_eapd_get,
    1236                 .put = cxt5047_hp_master_sw_put,
    1237                 .private_value = 0x13,
    1238         },
    12391308        {0} /* end */
    12401309};
     
    12471316        /* HP, Speaker  */
    12481317        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
    1249         {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
    1250         {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
     1318        {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
     1319        {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
    12511320        /* Record selector: Mic */
    12521321        {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
     
    12681337/* configuration for Toshiba Laptops */
    12691338static struct hda_verb cxt5047_toshiba_init_verbs[] = {
    1270         {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
    1271         /* pin sensing on HP and Mic jacks */
    1272         {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
    1273         {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
    1274         /* Speaker routing */
    1275         {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
    1276         {0}
    1277 };
    1278 
    1279 /* configuration for HP Laptops */
    1280 static struct hda_verb cxt5047_hp_init_verbs[] = {
    1281         /* pin sensing on HP jack */
    1282         {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
    1283         /* 0x13 is actually shared by both HP and speaker;
    1284          * setting the connection to 0 (=0x19) makes the master volume control
    1285          * working mysteriouslly...
    1286          */
    1287         {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
    1288         /* Record selector: Ext Mic */
    1289         {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
    1290         {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
    1291          AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
    1292         /* Speaker routing */
    1293         {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
     1339        {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
    12941340        {0}
    12951341};
     
    14561502
    14571503static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
    1458         SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
    14591504        SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
    1460         SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
    1461         SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
     1505        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
     1506                          CXT5047_LAPTOP),
    14621507        SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
    14631508        {0}
     
    14731518                return -ENOMEM;
    14741519        codec->spec = spec;
     1520        codec->pin_amp_workaround = 1;
    14751521
    14761522        spec->multiout.max_channels = 2;
     
    14811527        spec->adc_nids = cxt5047_adc_nids;
    14821528        spec->capsrc_nids = cxt5047_capsrc_nids;
    1483         spec->input_mux = &cxt5047_capture_source;
    14841529        spec->num_mixers = 1;
    1485         spec->mixers[0] = cxt5047_mixers;
     1530        spec->mixers[0] = cxt5047_base_mixers;
    14861531        spec->num_init_verbs = 1;
    14871532        spec->init_verbs[0] = cxt5047_init_verbs;
     
    14971542        switch (board_config) {
    14981543        case CXT5047_LAPTOP:
    1499                 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
     1544                spec->num_mixers = 2;
     1545                spec->mixers[1] = cxt5047_hp_spk_mixers;
     1546                codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
    15001547                break;
    15011548        case CXT5047_LAPTOP_HP:
    1502                 spec->input_mux = &cxt5047_hp_capture_source;
    1503                 spec->num_init_verbs = 2;
    1504                 spec->init_verbs[1] = cxt5047_hp_init_verbs;
    1505                 spec->mixers[0] = cxt5047_hp_mixers;
     1549                spec->num_mixers = 2;
     1550                spec->mixers[1] = cxt5047_hp_only_mixers;
    15061551                codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
    15071552                codec->patch_ops.init = cxt5047_hp_init;
     
    15091554        case CXT5047_LAPTOP_EAPD:
    15101555                spec->input_mux = &cxt5047_toshiba_capture_source;
     1556                spec->num_mixers = 2;
     1557                spec->mixers[1] = cxt5047_hp_spk_mixers;
    15111558                spec->num_init_verbs = 2;
    15121559                spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
    1513                 spec->mixers[0] = cxt5047_toshiba_mixers;
    15141560                codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
    15151561                break;
     
    15221568#endif 
    15231569        }
     1570        spec->vmaster_nid = 0x13;
    15241571        return 0;
    15251572}
     
    15281575static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
    15291576static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
    1530 #define CXT5051_SPDIF_OUT       0x1C
    1531 #define CXT5051_PORTB_EVENT     0x38
    1532 #define CXT5051_PORTC_EVENT     0x39
    15331577
    15341578static struct hda_channel_mode cxt5051_modes[1] = {
     
    15601604static void cxt5051_portb_automic(struct hda_codec *codec)
    15611605{
     1606        struct conexant_spec *spec = codec->spec;
    15621607        unsigned int present;
    15631608
     1609        if (spec->no_auto_mic)
     1610                return;
    15641611        present = snd_hda_codec_read(codec, 0x17, 0,
    15651612                                     AC_VERB_GET_PIN_SENSE, 0) &
     
    15771624        hda_nid_t new_adc;
    15781625
     1626        if (spec->no_auto_mic)
     1627                return;
    15791628        present = snd_hda_codec_read(codec, 0x18, 0,
    15801629                                     AC_VERB_GET_PIN_SENSE, 0) &
     
    16101659                                   unsigned int res)
    16111660{
     1661        int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
    16121662        switch (res >> 26) {
    16131663        case CONEXANT_HP_EVENT:
     
    16211671                break;
    16221672        }
     1673        conexant_report_jack(codec, nid);
    16231674}
    16241675
     
    16481699        HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
    16491700        HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
     1701        HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
     1702        {
     1703                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     1704                .name = "Master Playback Switch",
     1705                .info = cxt_eapd_info,
     1706                .get = cxt_eapd_get,
     1707                .put = cxt5051_hp_master_sw_put,
     1708                .private_value = 0x1a,
     1709        },
     1710
     1711        {0}
     1712};
     1713
     1714static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
     1715        HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT),
     1716        HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT),
    16501717        HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
    16511718        {
     
    16911758};
    16921759
     1760static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
     1761        /* Line in, Mic */
     1762        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
     1763        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1764        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
     1765        {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
     1766        /* SPK  */
     1767        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1768        {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
     1769        /* HP, Amp  */
     1770        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1771        {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
     1772        /* DAC1 */
     1773        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1774        /* Record selector: Int mic */
     1775        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
     1776        {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
     1777        /* SPDIF route: PCM */
     1778        {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
     1779        /* EAPD */
     1780        {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
     1781        {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
     1782        {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
     1783        {0} /* end */
     1784};
     1785
     1786static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
     1787        /* Line in, Mic */
     1788        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
     1789        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1790        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
     1791        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
     1792        {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1793        {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
     1794        /* SPK  */
     1795        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1796        {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
     1797        /* HP, Amp  */
     1798        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1799        {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
     1800        /* Docking HP */
     1801        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     1802        {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
     1803        /* DAC1 */
     1804        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1805        /* Record selector: Int mic */
     1806        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
     1807        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
     1808        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
     1809        /* SPDIF route: PCM */
     1810        {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
     1811        /* EAPD */
     1812        {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
     1813        {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
     1814        {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
     1815        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
     1816        {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
     1817        {0} /* end */
     1818};
     1819
    16931820/* initialize jack-sensing, too */
    16941821static int cxt5051_init(struct hda_codec *codec)
    16951822{
    16961823        conexant_init(codec);
     1824        conexant_init_jacks(codec);
    16971825        if (codec->patch_ops.unsol_event) {
    16981826                cxt5051_hp_automute(codec);
     
    17071835        CXT5051_LAPTOP,  /* Laptops w/ EAPD support */
    17081836        CXT5051_HP,     /* no docking */
     1837        CXT5051_HP_DV6736,      /* HP without mic switch */
     1838        CXT5051_LENOVO_X200,    /* Lenovo X200 laptop */
    17091839        CXT5051_MODELS
    17101840};
     
    17131843        [CXT5051_LAPTOP]        = "laptop",
    17141844        [CXT5051_HP]            = "hp",
     1845        [CXT5051_HP_DV6736]     = "hp-dv6736",
     1846        [CXT5051_LENOVO_X200]   = "lenovo-x200",
    17151847};
    17161848
    17171849static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
     1850        SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
    17181851        SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
    17191852                      CXT5051_LAPTOP),
    17201853        SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
     1854        SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
    17211855        {0}
    17221856};
     
    17311865                return -ENOMEM;
    17321866        codec->spec = spec;
     1867        codec->pin_amp_workaround = 1;
    17331868
    17341869        codec->patch_ops = conexant_patch_ops;
     
    17511886        spec->cur_adc_idx = 0;
    17521887
     1888        codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
     1889
    17531890        board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
    17541891                                                  cxt5051_models,
     
    17561893        switch (board_config) {
    17571894        case CXT5051_HP:
    1758                 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
    17591895                spec->mixers[0] = cxt5051_hp_mixers;
    17601896                break;
    1761         default:
    1762         case CXT5051_LAPTOP:
    1763                 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
     1897        case CXT5051_HP_DV6736:
     1898                spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
     1899                spec->mixers[0] = cxt5051_hp_dv6736_mixers;
     1900                spec->no_auto_mic = 1;
     1901                break;
     1902        case CXT5051_LENOVO_X200:
     1903                spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
    17641904                break;
    17651905        }
     
    17721912 */
    17731913
    1774 struct hda_codec_preset snd_hda_preset_conexant[] = {
     1914static struct hda_codec_preset snd_hda_preset_conexant[] = {
    17751915        { .id = 0x14f15045, .name = "CX20549 (Venice)",
    17761916          .patch = patch_cxt5045 },
     
    17811921        {0} /* terminator */
    17821922};
     1923
     1924MODULE_ALIAS("snd-hda-codec-id:14f15045");
     1925MODULE_ALIAS("snd-hda-codec-id:14f15047");
     1926MODULE_ALIAS("snd-hda-codec-id:14f15051");
     1927
     1928MODULE_LICENSE("GPL");
     1929MODULE_DESCRIPTION("Conexant HD-audio codec");
     1930
     1931static struct hda_codec_preset_list conexant_list = {
     1932        .preset = snd_hda_preset_conexant,
     1933        .owner = THIS_MODULE,
     1934};
     1935
     1936static int __init patch_conexant_init(void)
     1937{
     1938        return snd_hda_add_codec_preset(&conexant_list);
     1939}
     1940
     1941static void __exit patch_conexant_exit(void)
     1942{
     1943        snd_hda_delete_codec_preset(&conexant_list);
     1944}
     1945
     1946module_init(patch_conexant_init)
     1947module_exit(patch_conexant_exit)
  • GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c

    r417 r426  
    3131#include "hda_codec.h"
    3232#include "hda_local.h"
    33 #include "hda_patch.h"
     33#include "hda_beep.h"
    3434
    3535#define ALC880_FRONT_EVENT              0x01
     
    7979        ALC260_WILL,
    8080        ALC260_REPLACER_672V,
     81        ALC260_FAVORIT100,
    8182#ifdef CONFIG_SND_DEBUG
    8283        ALC260_TEST,
     
    105106        ALC262_TOSHIBA_S06,
    106107        ALC262_TOSHIBA_RX1,
     108        ALC262_TYAN,
    107109        ALC262_AUTO,
    108110        ALC262_MODEL_LAST /* last tag */
     
    187189        ALC663_ASUS_MODE5,
    188190        ALC663_ASUS_MODE6,
     191        ALC272_DELL,
     192        ALC272_DELL_ZM1,
    189193        ALC662_AUTO,
    190194        ALC662_MODEL_LAST,
     
    217221        ALC883_ACER,
    218222        ALC883_ACER_ASPIRE,
     223        ALC888_ACER_ASPIRE_4930G,
    219224        ALC883_MEDION,
    220225        ALC883_MEDION_MD2,
     
    230235        ALC883_CLEVO_M720,
    231236        ALC883_FUJITSU_PI2515,
     237        ALC888_FUJITSU_XA3530,
    232238        ALC883_3ST_6ch_INTEL,
    233239        ALC888_ASUS_M90V,
    234240        ALC888_ASUS_EEE1601,
     241        ALC1200_ASUS_P5Q,
    235242        ALC883_AUTO,
    236243        ALC883_MODEL_LAST,
     244};
     245
     246/* styles of capture selection */
     247enum {
     248        CAPT_MUX = 0,   /* only mux based */
     249        CAPT_MIX,       /* only mixer based */
     250        CAPT_1MUX_MIX,  /* first mux and other mixers */
    237251};
    238252
     
    245259        unsigned int num_mixers;
    246260        struct snd_kcontrol_new *cap_mixer;     /* capture mixer */
     261        unsigned int beep_amp;  /* beep amp value, set via set_beep_amp() */
    247262
    248263        const struct hda_verb *init_verbs[5];   /* initialization verbs
     
    268283                                         */
    269284        hda_nid_t alt_dac_nid;
     285        hda_nid_t slave_dig_outs[3];    /* optional - for auto-parsing */
     286        int dig_out_type;
    270287
    271288        /* capture */
     
    274291        hda_nid_t *capsrc_nids;
    275292        hda_nid_t dig_in_nid;           /* digital-in NID; optional */
    276         unsigned char is_mix_capture;   /* matrix-style capture (non-mux) */
     293        int capture_style;              /* capture style (CAPT_*) */
    277294
    278295        /* capture source */
     
    292309        struct auto_pin_cfg autocfg;
    293310        struct snd_array kctls;
    294         struct hda_input_mux private_imux;
     311        struct hda_input_mux private_imux[3];
    295312        hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
    296313
     
    303320        unsigned int jack_present: 1;
    304321        unsigned int master_sw: 1;
     322
     323        /* other flags */
     324        unsigned int no_analog :1; /* digital I/O only */
    305325
    306326        /* for virtual master */
     
    313333        hda_nid_t pll_nid;
    314334        unsigned int pll_coef_idx, pll_coef_bit;
    315 
    316 #ifdef SND_HDA_NEEDS_RESUME
    317 #define ALC_MAX_PINS    16
    318         unsigned int num_pins;
    319         hda_nid_t pin_nids[ALC_MAX_PINS];
    320         unsigned int pin_cfgs[ALC_MAX_PINS];
    321 #endif
    322335};
    323336
     
    335348        hda_nid_t dig_out_nid;          /* optional */
    336349        hda_nid_t hp_nid;               /* optional */
     350        hda_nid_t *slave_dig_outs;
    337351        unsigned int num_adc_nids;
    338352        hda_nid_t *adc_nids;
     
    382396        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    383397        struct alc_spec *spec = codec->spec;
    384         const struct hda_input_mux *imux = spec->input_mux;
     398        const struct hda_input_mux *imux;
    385399        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
     400        unsigned int mux_idx;
    386401        hda_nid_t nid = spec->capsrc_nids ?
    387402                spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
    388403
    389         if (spec->is_mix_capture) {
     404        mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
     405        imux = &spec->input_mux[mux_idx];
     406
     407        if (spec->capture_style &&
     408            !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
    390409                /* Matrix-mixer style (e.g. ALC882) */
    391410                unsigned int *cur_val = &spec->cur_mux[adc_idx];
     
    407426        } else {
    408427                /* MUX style (e.g. ALC880) */
    409                 unsigned int mux_idx;
    410                 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
    411                 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx],
    412                                              ucontrol, nid,
     428                return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
    413429                                             &spec->cur_mux[adc_idx]);
    414430        }
     
    748764
    749765/*
     766 * set up the input pin config (depending on the given auto-pin type)
     767 */
     768static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
     769                              int auto_pin_type)
     770{
     771        unsigned int val = PIN_IN;
     772
     773        if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
     774                unsigned int pincap;
     775                pincap = snd_hda_query_pin_caps(codec, nid);
     776                pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
     777                if (pincap & AC_PINCAP_VREF_80)
     778                        val = PIN_VREF80;
     779        }
     780        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
     781}
     782
     783/*
    750784 */
    751785static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
     
    762796        spec->init_verbs[spec->num_init_verbs++] = verb;
    763797}
     798
     799#ifdef CONFIG_PROC_FS
     800/*
     801 * hook for proc
     802 */
     803static void print_realtek_coef(struct snd_info_buffer *buffer,
     804                               struct hda_codec *codec, hda_nid_t nid)
     805{
     806        int coeff;
     807
     808        if (nid != 0x20)
     809                return;
     810        coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
     811        snd_iprintf(buffer, "  Processing Coefficient: 0x%02x\n", coeff);
     812        coeff = snd_hda_codec_read(codec, nid, 0,
     813                                   AC_VERB_GET_COEF_INDEX, 0);
     814        snd_iprintf(buffer, "  Coefficient Index: 0x%02x\n", coeff);
     815}
     816#else
     817#define print_realtek_coef      NULL
     818#endif
    764819
    765820/*
     
    787842        spec->multiout.dac_nids = preset->dac_nids;
    788843        spec->multiout.dig_out_nid = preset->dig_out_nid;
     844        spec->multiout.slave_dig_outs = preset->slave_dig_outs;
    789845        spec->multiout.hp_nid = preset->hp_nid;
    790846
     
    898954}
    899955#else
    900 #define alc_mic_automute(codec) /* NOP */
     956#define alc_mic_automute(codec) do {} while(0) /* NOP */
    901957#endif /* disabled */
    902958
     
    929985        tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
    930986        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
    931         if ((tmp & 0xf0) == 2)
     987        if ((tmp & 0xf0) == 0x20)
    932988                /* alc888S-VC */
    933989                snd_hda_codec_read(codec, 0x20, 0,
     
    9681024        if (codec->vendor_id == 0x10ec0260)
    9691025                nid = 0x17;
    970         ass = snd_hda_codec_read(codec, nid, 0,
    971                                  AC_VERB_GET_CONFIG_DEFAULT, 0);
     1026        ass = snd_hda_codec_get_pincfg(codec, nid);
    9721027        if (!(ass & 1) && !(ass & 0x100000))
    9731028                return;
     
    10141069                case 0x10ec0268:
    10151070                case 0x10ec0269:
     1071                case 0x10ec0272:
    10161072                case 0x10ec0660:
    10171073                case 0x10ec0662:
     
    10421098                case 0x10ec0883:
    10431099                case 0x10ec0885:
     1100                case 0x10ec0887:
    10441101                case 0x10ec0889:
    10451102                        snd_hda_codec_write(codec, 0x20, 0,
     
    11411198
    11421199        cfg = pinfix[quirk->value];
    1143         for (; cfg->nid; cfg++) {
    1144                 int i;
    1145                 u32 val = cfg->val;
    1146                 for (i = 0; i < 4; i++) {
    1147                         snd_hda_codec_write(codec, cfg->nid, 0,
    1148                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
    1149                                     val & 0xff);
    1150                         val >>= 8;
    1151                 }
     1200        for (; cfg->nid; cfg++)
     1201                snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
     1202}
     1203
     1204/*
     1205 * ALC888
     1206 */
     1207
     1208/*
     1209 * 2ch mode
     1210 */
     1211static struct hda_verb alc888_4ST_ch2_intel_init[] = {
     1212/* Mic-in jack as mic in */
     1213        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     1214        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     1215/* Line-in jack as Line in */
     1216        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
     1217        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     1218/* Line-Out as Front */
     1219        { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
     1220        {0} /* end */
     1221};
     1222
     1223/*
     1224 * 4ch mode
     1225 */
     1226static struct hda_verb alc888_4ST_ch4_intel_init[] = {
     1227/* Mic-in jack as mic in */
     1228        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     1229        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     1230/* Line-in jack as Surround */
     1231        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     1232        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     1233/* Line-Out as Front */
     1234        { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
     1235        {0} /* end */
     1236};
     1237
     1238/*
     1239 * 6ch mode
     1240 */
     1241static struct hda_verb alc888_4ST_ch6_intel_init[] = {
     1242/* Mic-in jack as CLFE */
     1243        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     1244        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     1245/* Line-in jack as Surround */
     1246        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     1247        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     1248/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
     1249        { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
     1250        {0} /* end */
     1251};
     1252
     1253/*
     1254 * 8ch mode
     1255 */
     1256static struct hda_verb alc888_4ST_ch8_intel_init[] = {
     1257/* Mic-in jack as CLFE */
     1258        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     1259        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     1260/* Line-in jack as Surround */
     1261        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     1262        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     1263/* Line-Out as Side */
     1264        { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
     1265        {0} /* end */
     1266};
     1267
     1268static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
     1269        { 2, alc888_4ST_ch2_intel_init },
     1270        { 4, alc888_4ST_ch4_intel_init },
     1271        { 6, alc888_4ST_ch6_intel_init },
     1272        { 8, alc888_4ST_ch8_intel_init },
     1273};
     1274
     1275/*
     1276 * ALC888 Fujitsu Siemens Amillo xa3530
     1277 */
     1278
     1279static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
     1280/* Front Mic: set to PIN_IN (empty by default) */
     1281        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1282/* Connect Internal HP to Front */
     1283        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1284        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1285        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     1286/* Connect Bass HP to Front */
     1287        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1288        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1289        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
     1290/* Connect Line-Out side jack (SPDIF) to Side */
     1291        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1292        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1293        {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
     1294/* Connect Mic jack to CLFE */
     1295        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1296        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1297        {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
     1298/* Connect Line-in jack to Surround */
     1299        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1300        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1301        {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
     1302/* Connect HP out jack to Front */
     1303        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1304        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1305        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
     1306/* Enable unsolicited event for HP jack and Line-out jack */
     1307        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     1308        {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     1309        {0}
     1310};
     1311
     1312static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
     1313{
     1314        unsigned int present;
     1315        unsigned int bits;
     1316        /* Line out presence */
     1317        present = snd_hda_codec_read(codec, 0x17, 0,
     1318                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1319        /* HP out presence */
     1320        present = present || snd_hda_codec_read(codec, 0x1b, 0,
     1321                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1322        bits = present ? HDA_AMP_MUTE : 0;
     1323        /* Toggle internal speakers muting */
     1324        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     1325                                 HDA_AMP_MUTE, bits);
     1326        /* Toggle internal bass muting */
     1327        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     1328                                 HDA_AMP_MUTE, bits);
     1329}
     1330
     1331static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
     1332                unsigned int res)
     1333{
     1334        if (res >> 26 == ALC880_HP_EVENT)
     1335                alc888_fujitsu_xa3530_automute(codec);
     1336}
     1337
     1338
     1339/*
     1340 * ALC888 Acer Aspire 4930G model
     1341 */
     1342
     1343static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
     1344/* Front Mic: set to PIN_IN (empty by default) */
     1345        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     1346/* Unselect Front Mic by default in input mixer 3 */
     1347        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
     1348/* Enable unsolicited event for HP jack */
     1349        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     1350/* Connect Internal HP to front */
     1351        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1352        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1353        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
     1354/* Connect HP out to front */
     1355        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
     1356        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     1357        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
     1358        {0}
     1359};
     1360
     1361static struct hda_input_mux alc888_2_capture_sources[2] = {
     1362        /* Front mic only available on one ADC */
     1363        {
     1364                .num_items = 4,
     1365                .items = {
     1366                        { "Mic", 0x0 },
     1367                        { "Line", 0x2 },
     1368                        { "CD", 0x4 },
     1369                        { "Front Mic", 0xb },
     1370                },
     1371        },
     1372        {
     1373                .num_items = 3,
     1374                .items = {
     1375                        { "Mic", 0x0 },
     1376                        { "Line", 0x2 },
     1377                        { "CD", 0x4 },
     1378                },
    11521379        }
     1380};
     1381
     1382static struct snd_kcontrol_new alc888_base_mixer[] = {
     1383        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     1384        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
     1385        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
     1386        HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
     1387        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
     1388                HDA_OUTPUT),
     1389        HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
     1390        HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
     1391        HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
     1392        HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
     1393        HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
     1394        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
     1395        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
     1396        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     1397        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     1398        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     1399        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
     1400        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     1401        {0} /* end */
     1402};
     1403
     1404static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
     1405{
     1406        unsigned int present;
     1407        unsigned int bits;
     1408        present = snd_hda_codec_read(codec, 0x15, 0,
     1409                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     1410        bits = present ? HDA_AMP_MUTE : 0;
     1411        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     1412                                 HDA_AMP_MUTE, bits);
     1413}
     1414
     1415static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
     1416                unsigned int res)
     1417{
     1418        if (res >> 26 == ALC880_HP_EVENT)
     1419                alc888_acer_aspire_4930g_automute(codec);
    11531420}
    11541421
     
    12381505        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
    12391506        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
    1240         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    1241         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    12421507        HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
    12431508        {
     
    12581523        int err;
    12591524
    1260         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1525        mutex_lock(&codec->control_mutex);
    12611526        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
    12621527                                                      HDA_INPUT);
    12631528        err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
    1264         mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1529        mutex_unlock(&codec->control_mutex);
    12651530        return err;
    12661531}
     
    12731538        int err;
    12741539
    1275         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1540        mutex_lock(&codec->control_mutex);
    12761541        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
    12771542                                                      HDA_INPUT);
    12781543        err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
    1279         mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1544        mutex_unlock(&codec->control_mutex);
    12801545        return err;
    12811546}
     
    12931558        int err;
    12941559
    1295         mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1560        mutex_lock(&codec->control_mutex);
    12961561        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
    12971562                                                      3, 0, HDA_INPUT);
    12981563        err = func(kcontrol, ucontrol);
    1299         mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
     1564        mutex_unlock(&codec->control_mutex);
    13001565        return err;
    13011566}
     
    13321597}
    13331598
    1334 #define DEFINE_CAPMIX(num) \
    1335 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
     1599#define _DEFINE_CAPMIX(num) \
    13361600        { \
    13371601                .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
     
    13541618                .put = alc_cap_vol_put, \
    13551619                .tlv = { .c = alc_cap_vol_tlv }, \
    1356         }, \
     1620        }
     1621
     1622#define _DEFINE_CAPSRC(num) \
    13571623        { \
    13581624                .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
     
    13631629                .get = alc_mux_enum_get, \
    13641630                .put = alc_mux_enum_put, \
    1365         }, \
    1366         {0} /* end */ \
     1631        }
     1632
     1633#define DEFINE_CAPMIX(num) \
     1634static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
     1635        _DEFINE_CAPMIX(num),                                  \
     1636        _DEFINE_CAPSRC(num),                                  \
     1637        {0} /* end */                                         \
     1638}
     1639
     1640#define DEFINE_CAPMIX_NOSRC(num) \
     1641static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
     1642        _DEFINE_CAPMIX(num),                                        \
     1643        {0} /* end */                                               \
    13671644}
    13681645
     
    13711648DEFINE_CAPMIX(2);
    13721649DEFINE_CAPMIX(3);
    1373 
     1650DEFINE_CAPMIX_NOSRC(1);
     1651DEFINE_CAPMIX_NOSRC(2);
     1652DEFINE_CAPMIX_NOSRC(3);
    13741653
    13751654
     
    14611740        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    14621741        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    1463         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    1464         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    14651742        {
    14661743                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    16391916};
    16401917
    1641 /* additional mixers to alc880_asus_mixer */
    1642 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
    1643         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    1644         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    1645         {0} /* end */
    1646 };
    1647 
    16481918/* TCL S700 */
    16491919static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
     
    16781948        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    16791949        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    1680         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    1681         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    16821950        {
    16831951                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    17542022static void alc_free_kctls(struct hda_codec *codec);
    17552023
     2024/* additional beep mixers; the actual parameters are overwritten at build */
     2025static struct snd_kcontrol_new alc_beep_mixer[] = {
     2026        HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
     2027        HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
     2028        {0} /* end */
     2029};
     2030
    17562031static int alc_build_controls(struct hda_codec *codec)
    17572032{
     
    17752050                if (err < 0)
    17762051                        return err;
    1777                 err = snd_hda_create_spdif_share_sw(codec,
    1778                                                     &spec->multiout);
    1779                 if (err < 0)
    1780                         return err;
    1781                 spec->multiout.share_spdif = 1;
     2052                if (!spec->no_analog) {
     2053                        err = snd_hda_create_spdif_share_sw(codec,
     2054                                                            &spec->multiout);
     2055                        if (err < 0)
     2056                                return err;
     2057                        spec->multiout.share_spdif = 1;
     2058                }
    17822059        }
    17832060        if (spec->dig_in_nid) {
     
    17872064        }
    17882065
     2066        /* create beep controls if needed */
     2067        if (spec->beep_amp) {
     2068                struct snd_kcontrol_new *knew;
     2069                for (knew = alc_beep_mixer; knew->name; knew++) {
     2070                        struct snd_kcontrol *kctl;
     2071                        kctl = snd_ctl_new1(knew, codec);
     2072                        if (!kctl)
     2073                                return -ENOMEM;
     2074                        kctl->private_value = spec->beep_amp;
     2075                        err = snd_hda_ctl_add(codec, kctl);
     2076                        if (err < 0)
     2077                                return err;
     2078                }
     2079        }
     2080
    17892081        /* if we have no master control, let's create it */
    1790         if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
     2082        if (!spec->no_analog &&
     2083            !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
    17912084                unsigned int vmaster_tlv[4];
    17922085                snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
     
    17972090                        return err;
    17982091        }
    1799         if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
     2092        if (!spec->no_analog &&
     2093            !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
    18002094                err = snd_hda_add_vmaster(codec, "Master Playback Switch",
    18012095                                          NULL, alc_slave_sws);
     
    27063000}
    27073001
     3002static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
     3003                                           struct hda_codec *codec,
     3004                                           struct snd_pcm_substream *substream)
     3005{
     3006        struct alc_spec *spec = codec->spec;
     3007        return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
     3008}
     3009
    27083010static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
    27093011                                         struct hda_codec *codec,
     
    27893091                .open = alc880_dig_playback_pcm_open,
    27903092                .close = alc880_dig_playback_pcm_close,
    2791                 .prepare = alc880_dig_playback_pcm_prepare
     3093                .prepare = alc880_dig_playback_pcm_prepare,
     3094                .cleanup = alc880_dig_playback_pcm_cleanup
    27923095        },
    27933096};
     
    28153118        codec->num_pcms = 1;
    28163119        codec->pcm_info = info;
     3120
     3121        if (spec->no_analog)
     3122                goto skip_analog;
    28173123
    28183124        info->name = spec->stream_name_analog;
     
    28393145        }
    28403146
     3147 skip_analog:
    28413148        /* SPDIF for stream index #1 */
    28423149        if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
    28433150                codec->num_pcms = 2;
     3151                codec->slave_dig_outs = spec->multiout.slave_dig_outs;
    28443152                info = spec->pcm_rec + 1;
    28453153                info->name = spec->stream_name_digital;
    2846                 info->pcm_type = HDA_PCM_TYPE_SPDIF;
     3154                if (spec->dig_out_type)
     3155                        info->pcm_type = spec->dig_out_type;
     3156                else
     3157                        info->pcm_type = HDA_PCM_TYPE_SPDIF;
    28473158                if (spec->multiout.dig_out_nid &&
    28483159                    spec->stream_digital_playback) {
     
    28583169                codec->spdif_status_reset = 1;
    28593170        }
     3171
     3172        if (spec->no_analog)
     3173                return 0;
    28603174
    28613175        /* If the use of more than one ADC is requested for the current
     
    29173231        alc_free_kctls(codec);
    29183232        kfree(spec);
    2919         codec->spec = NULL; /* to be sure */
     3233        snd_hda_detach_beep_device(codec);
    29203234}
    29213235
    29223236#ifdef SND_HDA_NEEDS_RESUME
    2923 static void store_pin_configs(struct hda_codec *codec)
    2924 {
    2925         struct alc_spec *spec = codec->spec;
    2926         hda_nid_t nid, end_nid;
    2927 
    2928         end_nid = codec->start_nid + codec->num_nodes;
    2929         for (nid = codec->start_nid; nid < end_nid; nid++) {
    2930                 unsigned int wid_caps = get_wcaps(codec, nid);
    2931                 unsigned int wid_type =
    2932                         (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
    2933                 if (wid_type != AC_WID_PIN)
    2934                         continue;
    2935                 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
    2936                         break;
    2937                 spec->pin_nids[spec->num_pins] = nid;
    2938                 spec->pin_cfgs[spec->num_pins] =
    2939                         snd_hda_codec_read(codec, nid, 0,
    2940                                            AC_VERB_GET_CONFIG_DEFAULT, 0);
    2941                 spec->num_pins++;
    2942         }
    2943 }
    2944 
    2945 static void resume_pin_configs(struct hda_codec *codec)
    2946 {
    2947         struct alc_spec *spec = codec->spec;
    2948         int i;
    2949 
    2950         for (i = 0; i < spec->num_pins; i++) {
    2951                 hda_nid_t pin_nid = spec->pin_nids[i];
    2952                 unsigned int pin_config = spec->pin_cfgs[i];
    2953                 snd_hda_codec_write(codec, pin_nid, 0,
    2954                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
    2955                                     pin_config & 0x000000ff);
    2956                 snd_hda_codec_write(codec, pin_nid, 0,
    2957                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
    2958                                     (pin_config & 0x0000ff00) >> 8);
    2959                 snd_hda_codec_write(codec, pin_nid, 0,
    2960                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
    2961                                     (pin_config & 0x00ff0000) >> 16);
    2962                 snd_hda_codec_write(codec, pin_nid, 0,
    2963                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
    2964                                     pin_config >> 24);
    2965         }
    2966 }
    2967 
    29683237static int alc_resume(struct hda_codec *codec)
    29693238{
    2970         resume_pin_configs(codec);
    29713239        codec->patch_ops.init(codec);
    29723240        snd_hda_codec_resume_amp(codec);
     
    29743242        return 0;
    29753243}
    2976 #else
    2977 #define store_pin_configs(codec)
    29783244#endif
    29793245
     
    33143580        SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
    33153581        SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
    3316         SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
     3582        SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
    33173583        SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
    33183584        SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
     
    33573623        SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
    33583624        SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
    3359         SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
     3625        /* default Intel */
     3626        SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
    33603627        SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
    33613628        SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
     
    35373804        },
    35383805        [ALC880_UNIWILL_DIG] = {
    3539                 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
     3806                .mixers = { alc880_asus_mixer },
    35403807                .init_verbs = { alc880_volume_init_verbs,
    35413808                                alc880_pin_asus_init_verbs },
     
    35753842        },
    35763843        [ALC880_FUJITSU] = {
    3577                 .mixers = { alc880_fujitsu_mixer,
    3578                             alc880_pcbeep_mixer, },
     3844                .mixers = { alc880_fujitsu_mixer },
    35793845                .init_verbs = { alc880_volume_init_verbs,
    35803846                                alc880_uniwill_p53_init_verbs,
     
    38694135                                                const struct auto_pin_cfg *cfg)
    38704136{
    3871         struct hda_input_mux *imux = &spec->private_imux;
     4137        struct hda_input_mux *imux = &spec->private_imux[0];
    38724138        int i, err, idx;
    38734139
     
    39574223                hda_nid_t nid = spec->autocfg.input_pins[i];
    39584224                if (alc880_is_input_pin(nid)) {
    3959                         snd_hda_codec_write(codec, nid, 0,
    3960                                             AC_VERB_SET_PIN_WIDGET_CONTROL,
    3961                                             i <= AUTO_PIN_FRONT_MIC ?
    3962                                             PIN_VREF80 : PIN_IN);
    3963                         if (nid != ALC880_PIN_CD_NID)
     4225                        alc_set_input_pin(codec, nid, i);
     4226                        if (nid != ALC880_PIN_CD_NID &&
     4227                            (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
    39644228                                snd_hda_codec_write(codec, nid, 0,
    39654229                                                    AC_VERB_SET_AMP_GAIN_MUTE,
     
    39764240{
    39774241        struct alc_spec *spec = codec->spec;
    3978         int err;
     4242        int i, err;
    39794243        static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
    39804244
     
    40074271        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    40084272
    4009         if (spec->autocfg.dig_out_pin)
    4010                 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
     4273        /* check multiple SPDIF-out (for recent codecs) */
     4274        for (i = 0; i < spec->autocfg.dig_outs; i++) {
     4275                hda_nid_t dig_nid;
     4276                err = snd_hda_get_connections(codec,
     4277                                              spec->autocfg.dig_out_pins[i],
     4278                                              &dig_nid, 1);
     4279                if (err < 0)
     4280                        continue;
     4281                if (!i)
     4282                        spec->multiout.dig_out_nid = dig_nid;
     4283                else {
     4284                        spec->multiout.slave_dig_outs = spec->slave_dig_outs;
     4285                        spec->slave_dig_outs[i - 1] = dig_nid;
     4286                        if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
     4287                                break;
     4288                }
     4289        }
    40114290        if (spec->autocfg.dig_in_pin)
    40124291                spec->dig_in_nid = ALC880_DIGIN_NID;
     
    40184297
    40194298        spec->num_mux_defs = 1;
    4020         spec->input_mux = &spec->private_imux;
    4021 
    4022         store_pin_configs(codec);
     4299        spec->input_mux = &spec->private_imux[0];
     4300
    40234301        return 1;
    40244302}
     
    40354313}
    40364314
     4315static void set_capture_mixer(struct alc_spec *spec)
     4316{
     4317        static struct snd_kcontrol_new *caps[2][3] = {
     4318                { alc_capture_mixer_nosrc1,
     4319                  alc_capture_mixer_nosrc2,
     4320                  alc_capture_mixer_nosrc3 },
     4321                { alc_capture_mixer1,
     4322                  alc_capture_mixer2,
     4323                  alc_capture_mixer3 },
     4324        };
     4325        if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
     4326                int mux;
     4327                if (spec->input_mux && spec->input_mux->num_items > 1)
     4328                        mux = 1;
     4329                else
     4330                        mux = 0;
     4331                spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
     4332        }
     4333}
     4334
     4335#define set_beep_amp(spec, nid, idx, dir) \
     4336        ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
     4337
    40374338/*
    40384339 * OK, here we have finally the patch for ALC880
    40394340 */
    4040 
    4041 static void set_capture_mixer(struct alc_spec *spec)
    4042 {
    4043         static struct snd_kcontrol_new *caps[3] = {
    4044                 alc_capture_mixer1,
    4045                 alc_capture_mixer2,
    4046                 alc_capture_mixer3,
    4047         };
    4048         if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
    4049                 spec->cap_mixer = caps[spec->num_adc_nids - 1];
    4050 }
    40514341
    40524342static int patch_alc880(struct hda_codec *codec)
     
    40834373                        board_config = ALC880_3ST;
    40844374                }
     4375        }
     4376
     4377        err = snd_hda_attach_beep_device(codec, 0x1);
     4378        if (err < 0) {
     4379                alc_free(codec);
     4380                return err;
    40854381        }
    40864382
     
    41114407        }
    41124408        set_capture_mixer(spec);
     4409        set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
    41134410
    41144411        spec->vmaster_nid = 0x0c;
     
    41214418                spec->loopback.amplist = alc880_loopbacks;
    41224419#endif
     4420        codec->proc_widget_hook = print_realtek_coef;
    41234421
    41244422        return 0;
     
    42174515        },
    42184516};
     4517
     4518/* Maxdata Favorit 100XS */
     4519static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
     4520        {
     4521                .num_items = 2,
     4522                .items = {
     4523                        { "Line/Mic", 0x0 },
     4524                        { "CD", 0x4 },
     4525                },
     4526        },
     4527        {
     4528                .num_items = 3,
     4529                .items = {
     4530                        { "Line/Mic", 0x0 },
     4531                        { "CD", 0x4 },
     4532                        { "Mixer", 0x5 },
     4533                },
     4534        },
     4535};
     4536
    42194537/*
    42204538 * This is just place-holder, so there's something for alc_build_pcms to look
     
    42564574        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
    42574575        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
    4258         {0} /* end */
    4259 };
    4260 
    4261 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
    4262         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
    4263         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
    42644576        {0} /* end */
    42654577};
     
    44564768        HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
    44574769        ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
    4458         HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    4459         HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    44604770        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
    44614771        HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
     
    45024812        HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
    45034813        ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
    4504         HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    4505         HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
     4814        {0} /* end */
     4815};
     4816
     4817/* Maxdata Favorit 100XS: one output and one input (0x12) jack
     4818 */
     4819static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
     4820        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
     4821        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
     4822        ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
     4823        HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
     4824        HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
     4825        ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
    45064826        {0} /* end */
    45074827};
     
    45214841        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
    45224842        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
    4523         HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    4524         HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    45254843        {0} /* end */
    45264844};
     
    48805198};
    48815199
     5200/* Initialisation sequence for Maxdata Favorit 100XS
     5201 * (adapted from Acer init verbs).
     5202 */
     5203static struct hda_verb alc260_favorit100_init_verbs[] = {
     5204        /* GPIO 0 enables the output jack.
     5205         * Turn this on and rely on the standard mute
     5206         * methods whenever the user wants to turn these outputs off.
     5207         */
     5208        {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
     5209        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
     5210        {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
     5211        /* Line/Mic input jack is connected to Mic1 pin */
     5212        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
     5213        /* Ensure all other unused pins are disabled and muted. */
     5214        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     5215        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5216        {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     5217        {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5218        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     5219        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5220        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     5221        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5222        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
     5223        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5224        /* Disable digital (SPDIF) pins */
     5225        {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
     5226        {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
     5227
     5228        /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
     5229         * bus when acting as outputs.
     5230         */
     5231        {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
     5232        {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
     5233
     5234        /* Start with output sum widgets muted and their output gains at min */
     5235        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5236        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5237        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5238        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5239        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5240        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5241        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5242        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
     5243        {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     5244
     5245        /* Unmute Line-out pin widget amp left and right
     5246         * (no equiv mixer ctrl)
     5247         */
     5248        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     5249        /* Unmute Mic1 and Line1 pin widget input buffers since they start as
     5250         * inputs. If the pin mode is changed by the user the pin mode control
     5251         * will take care of enabling the pin's input/output buffers as needed.
     5252         * Therefore there's no need to enable the input buffer at this
     5253         * stage.
     5254         */
     5255        {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     5256
     5257        /* Mute capture amp left and right */
     5258        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5259        /* Set ADC connection select to match default mixer setting - mic
     5260         * (on mic1 pin)
     5261         */
     5262        {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
     5263
     5264        /* Do similar with the second ADC: mute capture input amp and
     5265         * set ADC connection to mic to match ALSA's default state.
     5266         */
     5267        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     5268        {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
     5269
     5270        /* Mute all inputs to mixer widget (even unconnected ones) */
     5271        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
     5272        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
     5273        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
     5274        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
     5275        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
     5276        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
     5277        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
     5278        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
     5279
     5280        {0}
     5281};
     5282
    48825283static struct hda_verb alc260_will_verbs[] = {
    48835284        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     
    50265427        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
    50275428        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
    5028         HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
    5029         HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
    50305429        HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
    50315430        HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
     
    52255624                                                const struct auto_pin_cfg *cfg)
    52265625{
    5227         struct hda_input_mux *imux = &spec->private_imux;
     5626        struct hda_input_mux *imux = &spec->private_imux[0];
    52285627        int i, err, idx;
    52295628
     
    53005699                hda_nid_t nid = spec->autocfg.input_pins[i];
    53015700                if (nid >= 0x12) {
    5302                         snd_hda_codec_write(codec, nid, 0,
    5303                                             AC_VERB_SET_PIN_WIDGET_CONTROL,
    5304                                             i <= AUTO_PIN_FRONT_MIC ?
    5305                                             PIN_VREF80 : PIN_IN);
    5306                         if (nid != ALC260_PIN_CD_NID)
     5701                        alc_set_input_pin(codec, nid, i);
     5702                        if (nid != ALC260_PIN_CD_NID &&
     5703                            (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
    53075704                                snd_hda_codec_write(codec, nid, 0,
    53085705                                                    AC_VERB_SET_AMP_GAIN_MUTE,
     
    53775774        spec->multiout.max_channels = 2;
    53785775
    5379         if (spec->autocfg.dig_out_pin)
     5776        if (spec->autocfg.dig_outs)
    53805777                spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
    53815778        if (spec->kctls.list)
     
    53855782
    53865783        spec->num_mux_defs = 1;
    5387         spec->input_mux = &spec->private_imux;
    5388 
    5389         store_pin_configs(codec);
     5784        spec->input_mux = &spec->private_imux[0];
     5785
    53905786        return 1;
    53915787}
     
    54245820        [ALC260_WILL]           = "will",
    54255821        [ALC260_REPLACER_672V]  = "replacer",
     5822        [ALC260_FAVORIT100]     = "favorit100",
    54265823#ifdef CONFIG_SND_DEBUG
    54275824        [ALC260_TEST]           = "test",
     
    54335830        SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
    54345831        SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
     5832        SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
    54355833        SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
    54365834        SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
     
    54555853        [ALC260_BASIC] = {
    54565854                .mixers = { alc260_base_output_mixer,
    5457                             alc260_input_mixer,
    5458                             alc260_pc_beep_mixer },
     5855                            alc260_input_mixer },
    54595856                .init_verbs = { alc260_init_verbs },
    54605857                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     
    55355932                .input_mux = alc260_acer_capture_sources,
    55365933        },
     5934        [ALC260_FAVORIT100] = {
     5935                .mixers = { alc260_favorit100_mixer },
     5936                .init_verbs = { alc260_favorit100_init_verbs },
     5937                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
     5938                .dac_nids = alc260_dac_nids,
     5939                .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
     5940                .adc_nids = alc260_dual_adc_nids,
     5941                .num_channel_mode = ARRAY_SIZE(alc260_modes),
     5942                .channel_mode = alc260_modes,
     5943                .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
     5944                .input_mux = alc260_favorit100_capture_sources,
     5945        },
    55375946        [ALC260_WILL] = {
    55385947                .mixers = { alc260_will_mixer },
     
    56096018                        board_config = ALC260_BASIC;
    56106019                }
     6020        }
     6021
     6022        err = snd_hda_attach_beep_device(codec, 0x1);
     6023        if (err < 0) {
     6024                alc_free(codec);
     6025                return err;
    56116026        }
    56126027
     
    56366051        }
    56376052        set_capture_mixer(spec);
     6053        set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
    56386054
    56396055        spec->vmaster_nid = 0x08;
     
    56466062                spec->loopback.amplist = alc260_loopbacks;
    56476063#endif
     6064        codec->proc_widget_hook = print_realtek_coef;
    56486065
    56496066        return 0;
     
    58066223        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    58076224        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    5808         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    5809         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    58106225        {0} /* end */
    58116226};
     
    58346249        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    58356250        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    5836         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    5837         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    58386251        {0} /* end */
    58396252};
     
    58876300        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    58886301        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    5889         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    5890         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    58916302        {0} /* end */
    58926303};
     
    59976408        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
    59986409        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
     6410        /* FIXME: this looks suspicious...
    59996411        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
    60006412        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
     6413        */
    60016414        {0} /* end */
    60026415};
     
    66307043        for (i = 0; i < AUTO_PIN_LAST; i++) {
    66317044                hda_nid_t nid = spec->autocfg.input_pins[i];
    6632                 unsigned int vref;
    66337045                if (!nid)
    66347046                        continue;
    6635                 vref = PIN_IN;
    6636                 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
    6637                         unsigned int pincap;
    6638                         pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
    6639                         if ((pincap >> AC_PINCAP_VREF_SHIFT) &
    6640                             AC_PINCAP_VREF_80)
    6641                                 vref = PIN_VREF80;
    6642                 }
    6643                 snd_hda_codec_write(codec, nid, 0,
    6644                                     AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
     7047                alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
    66457048                if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
    66467049                        snd_hda_codec_write(codec, nid, 0,
     
    66537056{
    66547057        struct alc_spec *spec = codec->spec;
    6655         const struct hda_input_mux *imux = spec->input_mux;
    66567058        int c;
    66577059
     
    66597061                hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
    66607062                hda_nid_t nid = spec->capsrc_nids[c];
     7063                unsigned int mux_idx;
     7064                const struct hda_input_mux *imux;
    66617065                int conns, mute, idx, item;
    66627066
     
    66657069                if (conns < 0)
    66667070                        continue;
     7071                mux_idx = c >= spec->num_mux_defs ? 0 : c;
     7072                imux = &spec->input_mux[mux_idx];
    66677073                for (idx = 0; idx < conns; idx++) {
    66687074                        /* if the current connection is the selected one,
     
    66777083                                }
    66787084                        }
    6679                         snd_hda_codec_write(codec, nid, 0,
    6680                                             AC_VERB_SET_AMP_GAIN_MUTE, mute);
     7085                        /* check if we have a selector or mixer
     7086                         * we could check for the widget type instead, but
     7087                         * just check for Amp-In presence (in case of mixer
     7088                         * without amp-in there is something wrong, this
     7089                         * function shouldn't be used or capsrc nid is wrong)
     7090                         */
     7091                        if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
     7092                                snd_hda_codec_write(codec, nid, 0,
     7093                                                    AC_VERB_SET_AMP_GAIN_MUTE,
     7094                                                    mute);
     7095                        else if (mute != AMP_IN_MUTE(idx))
     7096                                snd_hda_codec_write(codec, nid, 0,
     7097                                                    AC_VERB_SET_CONNECT_SEL,
     7098                                                    idx);
    66817099                }
    66827100        }
     
    67677185                case 0x106b1000: /* iMac 24 */
    67687186                case 0x106b2800: /* AppleTV */
     7187                case 0x106b3e00: /* iMac 24 Aluminium */
    67697188                        board_config = ALC885_IMAC24;
    67707189                        break;
     7190                case 0x106b00a0: /* MacBookPro3,1 - Another revision */
    67717191                case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
    67727192                case 0x106b00a4: /* MacbookPro4,1 */
    67737193                case 0x106b2c00: /* Macbook Pro rev3 */
    67747194                case 0x106b3600: /* Macbook 3.1 */
     7195                case 0x106b3800: /* MacbookPro4,1 - latter revision */
    67757196                        board_config = ALC885_MBP3;
    67767197                        break;
     
    68047225        }
    68057226
     7227        err = snd_hda_attach_beep_device(codec, 0x1);
     7228        if (err < 0) {
     7229                alc_free(codec);
     7230                return err;
     7231        }
     7232
    68067233        if (board_config != ALC882_AUTO)
    68077234                setup_preset(spec, &alc882_presets[board_config]);
     
    68247251        spec->stream_digital_capture = &alc882_pcm_digital_capture;
    68257252
    6826         spec->is_mix_capture = 1; /* matrix-style capture */
     7253        spec->capture_style = CAPT_MIX; /* matrix-style capture */
    68277254        if (!spec->adc_nids && spec->input_mux) {
    68287255                /* check whether NID 0x07 is valid */
     
    68417268        }
    68427269        set_capture_mixer(spec);
     7270        set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
    68437271
    68447272        spec->vmaster_nid = 0x0c;
     
    68517279                spec->loopback.amplist = alc882_loopbacks;
    68527280#endif
     7281        codec->proc_widget_hook = print_realtek_coef;
    68537282
    68547283        return 0;
     
    68697298#define ALC883_DIGIN_NID        0x0a
    68707299
     7300#define ALC1200_DIGOUT_NID      0x10
     7301
    68717302static hda_nid_t alc883_dac_nids[4] = {
    68727303        /* front, rear, clfe, rear_surr */
     
    68847315};
    68857316
     7317static hda_nid_t alc883_adc_nids_rev[2] = {
     7318        /* ADC2-1 */
     7319        0x09, 0x08
     7320};
     7321
     7322#define alc889_adc_nids         alc880_adc_nids
     7323
    68867324static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
     7325
     7326static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
     7327
     7328#define alc889_capsrc_nids      alc882_capsrc_nids
    68877329
    68887330/* input MUX */
     
    71037545        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    71047546        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    7105         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    7106         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    71077547        {0} /* end */
    71087548};
     
    71677607        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    71687608        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    7169         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    7170         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    71717609        {0} /* end */
    71727610};
     
    71927630        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    71937631        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    7194         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    7195         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    71967632        {0} /* end */
    71977633};
     
    72187654        HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
    72197655        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    7220         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    7221         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    72227656        {0} /* end */
    72237657};
     
    72437677        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    72447678        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    7245         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    7246         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    72477679        {0} /* end */
    72487680};
     
    76528084};
    76538085
     8086static struct hda_verb alc888_6st_dell_verbs[] = {
     8087        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
     8088        {0}
     8089};
     8090
     8091static void alc888_3st_hp_front_automute(struct hda_codec *codec)
     8092{
     8093        unsigned int present, bits;
     8094
     8095        present = snd_hda_codec_read(codec, 0x1b, 0,
     8096                        AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
     8097        bits = present ? HDA_AMP_MUTE : 0;
     8098        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
     8099                                 HDA_AMP_MUTE, bits);
     8100        snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
     8101                                 HDA_AMP_MUTE, bits);
     8102        snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
     8103                                 HDA_AMP_MUTE, bits);
     8104}
     8105
     8106static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
     8107                                      unsigned int res)
     8108{
     8109        switch (res >> 26) {
     8110        case ALC880_HP_EVENT:
     8111                alc888_3st_hp_front_automute(codec);
     8112                break;
     8113        }
     8114}
     8115
    76548116static struct hda_verb alc888_3st_hp_verbs[] = {
    76558117        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Front: output 0 (0x0c) */
    76568118        {0x16, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Rear : output 1 (0x0d) */
    76578119        {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},  /* CLFE : output 2 (0x0e) */
    7658         {0}
    7659 };
    7660 
    7661 static struct hda_verb alc888_6st_dell_verbs[] = {
    76628120        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
    7663         {0}
    7664 };
    7665 
     8121        {0} /* end */
     8122};
     8123
     8124/*
     8125 * 2ch mode
     8126 */
    76668127static struct hda_verb alc888_3st_hp_2ch_init[] = {
    76678128        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     
    76698130        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
    76708131        { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    7671         {0}
    7672 };
    7673 
     8132        {0} /* end */
     8133};
     8134
     8135/*
     8136 * 4ch mode
     8137 */
     8138static struct hda_verb alc888_3st_hp_4ch_init[] = {
     8139        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
     8140        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
     8141        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
     8142        { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     8143        { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
     8144        {0} /* end */
     8145};
     8146
     8147/*
     8148 * 6ch mode
     8149 */
    76748150static struct hda_verb alc888_3st_hp_6ch_init[] = {
    76758151        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    76768152        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
     8153        { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
    76778154        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
    76788155        { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
    7679         {0}
    7680 };
    7681 
    7682 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
     8156        { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
     8157        {0} /* end */
     8158};
     8159
     8160static struct hda_channel_mode alc888_3st_hp_modes[3] = {
    76838161        { 2, alc888_3st_hp_2ch_init },
     8162        { 4, alc888_3st_hp_4ch_init },
    76848163        { 6, alc888_3st_hp_6ch_init },
    76858164};
     
    79428421        switch (res >> 26) {
    79438422        case ALC880_HP_EVENT:
    7944                 printk("hp_event\n");
     8423                /* printk(KERN_DEBUG "hp_event\n"); */
    79458424                alc888_6st_dell_front_automute(codec);
    79468425                break;
     
    81778656        [ALC883_ACER]           = "acer",
    81788657        [ALC883_ACER_ASPIRE]    = "acer-aspire",
     8658        [ALC888_ACER_ASPIRE_4930G]      = "acer-aspire-4930g",
    81798659        [ALC883_MEDION]         = "medion",
    81808660        [ALC883_MEDION_MD2]     = "medion-md2",
     
    81908670        [ALC883_CLEVO_M720]     = "clevo-m720",
    81918671        [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
     8672        [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
    81928673        [ALC883_3ST_6ch_INTEL]  = "3stack-6ch-intel",
     8674        [ALC1200_ASUS_P5Q]      = "asus-p5q",
    81938675        [ALC883_AUTO]           = "auto",
    81948676};
     
    81988680        SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
    81998681        SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
     8682        SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
    82008683        SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
    82018684        SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
    82028685        SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
    8203         SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
     8686        SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
     8687                ALC888_ACER_ASPIRE_4930G),
     8688        SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
     8689                ALC888_ACER_ASPIRE_4930G),
     8690        SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
     8691        SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
     8692        SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
     8693                ALC888_ACER_ASPIRE_4930G),
     8694        SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
     8695                ALC888_ACER_ASPIRE_4930G),
     8696        /* default Acer */
     8697        SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
    82048698        SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
    82058699        SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
     
    82078701        SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
    82088702        SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
     8703        SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
     8704        SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
    82098705        SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
    82108706        SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
     8707        SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
     8708        SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
    82118709        SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
    82128710        SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
    82138711        SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
     8712        SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
    82148713        SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
    82158714        SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
     
    82358734        SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
    82368735        SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
     8736        SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
    82378737        SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
    82388738        SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
     
    82428742        SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
    82438743        SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
    8244         SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
     8744        SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
    82458745        SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
    82468746        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
    8247         SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
     8747        SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
     8748                      ALC883_FUJITSU_PI2515),
     8749        SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
     8750                ALC888_FUJITSU_XA3530),
    82488751        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
    82498752        SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
     
    82578760        SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
    82588761        SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
     8762        SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
     8763        SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
    82598764        SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
    82608765        {0}
     8766};
     8767
     8768static hda_nid_t alc883_slave_dig_outs[] = {
     8769        ALC1200_DIGOUT_NID, 0,
     8770};
     8771
     8772static hda_nid_t alc1200_slave_dig_outs[] = {
     8773        ALC883_DIGOUT_NID, 0,
    82618774};
    82628775
     
    83028815                .dig_out_nid = ALC883_DIGOUT_NID,
    83038816                .dig_in_nid = ALC883_DIGIN_NID,
     8817                .slave_dig_outs = alc883_slave_dig_outs,
    83048818                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
    83058819                .channel_mode = alc883_3ST_6ch_intel_modes,
     
    83718885                .init_hook = alc883_acer_aspire_automute,
    83728886        },
     8887        [ALC888_ACER_ASPIRE_4930G] = {
     8888                .mixers = { alc888_base_mixer,
     8889                                alc883_chmode_mixer },
     8890                .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
     8891                                alc888_acer_aspire_4930g_verbs },
     8892                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     8893                .dac_nids = alc883_dac_nids,
     8894                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
     8895                .adc_nids = alc883_adc_nids_rev,
     8896                .capsrc_nids = alc883_capsrc_nids_rev,
     8897                .dig_out_nid = ALC883_DIGOUT_NID,
     8898                .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
     8899                .channel_mode = alc883_3ST_6ch_modes,
     8900                .need_dac_fix = 1,
     8901                .num_mux_defs =
     8902                        ARRAY_SIZE(alc888_2_capture_sources),
     8903                .input_mux = alc888_2_capture_sources,
     8904                .unsol_event = alc888_acer_aspire_4930g_unsol_event,
     8905                .init_hook = alc888_acer_aspire_4930g_automute,
     8906        },
    83738907        [ALC883_MEDION] = {
    83748908                .mixers = { alc883_fivestack_mixer,
     
    84769010                .need_dac_fix = 1,
    84779011                .input_mux = &alc883_capture_source,
     9012                .unsol_event = alc888_3st_hp_unsol_event,
     9013                .init_hook = alc888_3st_hp_front_automute,
    84789014        },
    84799015        [ALC888_6ST_DELL] = {
     
    85139049                .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
    85149050                .init_hook = alc883_2ch_fujitsu_pi2515_automute,
     9051        },
     9052        [ALC888_FUJITSU_XA3530] = {
     9053                .mixers = { alc888_base_mixer, alc883_chmode_mixer },
     9054                .init_verbs = { alc883_init_verbs,
     9055                        alc888_fujitsu_xa3530_verbs },
     9056                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     9057                .dac_nids = alc883_dac_nids,
     9058                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
     9059                .adc_nids = alc883_adc_nids_rev,
     9060                .capsrc_nids = alc883_capsrc_nids_rev,
     9061                .dig_out_nid = ALC883_DIGOUT_NID,
     9062                .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
     9063                .channel_mode = alc888_4ST_8ch_intel_modes,
     9064                .num_mux_defs =
     9065                        ARRAY_SIZE(alc888_2_capture_sources),
     9066                .input_mux = alc888_2_capture_sources,
     9067                .unsol_event = alc888_fujitsu_xa3530_unsol_event,
     9068                .init_hook = alc888_fujitsu_xa3530_automute,
    85159069        },
    85169070        [ALC888_LENOVO_SKY] = {
     
    85569110                .init_hook = alc883_eee1601_inithook,
    85579111        },
     9112        [ALC1200_ASUS_P5Q] = {
     9113                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
     9114                .init_verbs = { alc883_init_verbs },
     9115                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
     9116                .dac_nids = alc883_dac_nids,
     9117                .dig_out_nid = ALC1200_DIGOUT_NID,
     9118                .dig_in_nid = ALC883_DIGIN_NID,
     9119                .slave_dig_outs = alc1200_slave_dig_outs,
     9120                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
     9121                .channel_mode = alc883_sixstack_modes,
     9122                .input_mux = &alc883_capture_source,
     9123        },
    85589124};
    85599125
     
    86199185                hda_nid_t nid = spec->autocfg.input_pins[i];
    86209186                if (alc883_is_input_pin(nid)) {
    8621                         snd_hda_codec_write(codec, nid, 0,
    8622                                             AC_VERB_SET_PIN_WIDGET_CONTROL,
    8623                                             (i <= AUTO_PIN_FRONT_MIC ?
    8624                                              PIN_VREF80 : PIN_IN));
    8625                         if (nid != ALC883_PIN_CD_NID)
     9187                        alc_set_input_pin(codec, nid, i);
     9188                        if (nid != ALC883_PIN_CD_NID &&
     9189                            (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
    86269190                                snd_hda_codec_write(codec, nid, 0,
    86279191                                                    AC_VERB_SET_AMP_GAIN_MUTE,
     
    86389202        struct alc_spec *spec = codec->spec;
    86399203        int err = alc880_parse_auto_config(codec);
     9204        struct auto_pin_cfg *cfg = &spec->autocfg;
     9205        int i;
    86409206
    86419207        if (err < 0)
     
    86509216        /* hack - override the init verbs */
    86519217        spec->init_verbs[0] = alc883_auto_init_verbs;
     9218
     9219        /* setup input_mux for ALC889 */
     9220        if (codec->vendor_id == 0x10ec0889) {
     9221                /* digital-mic input pin is excluded in alc880_auto_create..()
     9222                 * because it's under 0x18
     9223                 */
     9224                if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
     9225                    cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
     9226                        struct hda_input_mux *imux = &spec->private_imux[0];
     9227                        for (i = 1; i < 3; i++)
     9228                                memcpy(&spec->private_imux[i],
     9229                                       &spec->private_imux[0],
     9230                                       sizeof(spec->private_imux[0]));
     9231                        imux->items[imux->num_items].label = "Int DMic";
     9232                        imux->items[imux->num_items].index = 0x0b;
     9233                        imux->num_items++;
     9234                        spec->num_mux_defs = 3;
     9235                        spec->input_mux = spec->private_imux;
     9236                }
     9237        }
    86529238
    86539239        return 1; /* config found */
     
    87029288        }
    87039289
     9290        err = snd_hda_attach_beep_device(codec, 0x1);
     9291        if (err < 0) {
     9292                alc_free(codec);
     9293                return err;
     9294        }
     9295
    87049296        if (board_config != ALC883_AUTO)
    87059297                setup_preset(spec, &alc883_presets[board_config]);
     
    87149306                        spec->stream_name_digital = "ALC888 Digital";
    87159307                }
     9308                if (!spec->num_adc_nids) {
     9309                        spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
     9310                        spec->adc_nids = alc883_adc_nids;
     9311                }
     9312                if (!spec->capsrc_nids)
     9313                        spec->capsrc_nids = alc883_capsrc_nids;
     9314                spec->capture_style = CAPT_MIX; /* matrix-style capture */
    87169315                break;
    87179316        case 0x10ec0889:
    87189317                spec->stream_name_analog = "ALC889 Analog";
    87199318                spec->stream_name_digital = "ALC889 Digital";
     9319                if (!spec->num_adc_nids) {
     9320                        spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
     9321                        spec->adc_nids = alc889_adc_nids;
     9322                }
     9323                if (!spec->capsrc_nids)
     9324                        spec->capsrc_nids = alc889_capsrc_nids;
     9325                spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
     9326                                                        capture */
    87209327                break;
    87219328        default:
    87229329                spec->stream_name_analog = "ALC883 Analog";
    87239330                spec->stream_name_digital = "ALC883 Digital";
     9331                if (!spec->num_adc_nids) {
     9332                        spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
     9333                        spec->adc_nids = alc883_adc_nids;
     9334                }
     9335                if (!spec->capsrc_nids)
     9336                        spec->capsrc_nids = alc883_capsrc_nids;
     9337                spec->capture_style = CAPT_MIX; /* matrix-style capture */
    87249338                break;
    87259339        }
     
    87329346        spec->stream_digital_capture = &alc883_pcm_digital_capture;
    87339347
    8734         if (!spec->num_adc_nids) {
    8735                 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
    8736                 spec->adc_nids = alc883_adc_nids;
    8737         }
    8738         if (!spec->capsrc_nids)
    8739                 spec->capsrc_nids = alc883_capsrc_nids;
    8740         spec->is_mix_capture = 1; /* matrix-style capture */
    87419348        if (!spec->cap_mixer)
    87429349                set_capture_mixer(spec);
     9350        set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
    87439351
    87449352        spec->vmaster_nid = 0x0c;
     
    87529360                spec->loopback.amplist = alc883_loopbacks;
    87539361#endif
     9362        codec->proc_widget_hook = print_realtek_coef;
    87549363
    87559364        return 0;
     
    87929401        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    87939402        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    8794         /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    8795            HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
    87969403        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
    87979404        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
     
    88149421        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    88159422        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
    8816         /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    8817            HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
    88189423        /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
    88199424        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
     
    89249529        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    89259530        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    8926         HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    8927         HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
    89289531        HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
    89299532        HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
     
    89549557        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    89559558        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    8956         HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
    8957         HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
    89589559        {0} /* end */
    89599560};
     
    91029703        {0} /* end */
    91039704};
     9705
     9706static struct snd_kcontrol_new alc262_tyan_mixer[] = {
     9707        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
     9708        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
     9709        HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
     9710        HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
     9711        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
     9712        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
     9713        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     9714        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
     9715        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
     9716        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
     9717        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
     9718        HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
     9719        {0} /* end */
     9720};
     9721
     9722static struct hda_verb alc262_tyan_verbs[] = {
     9723        /* Headphone automute */
     9724        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     9725        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     9726        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
     9727
     9728        /* P11 AUX_IN, white 4-pin connector */
     9729        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     9730        {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
     9731        {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
     9732        {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
     9733
     9734        {0}
     9735};
     9736
     9737/* unsolicited event for HP jack sensing */
     9738static void alc262_tyan_automute(struct hda_codec *codec)
     9739{
     9740        unsigned int mute;
     9741        unsigned int present;
     9742
     9743        snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
     9744        present = snd_hda_codec_read(codec, 0x1b, 0,
     9745                                     AC_VERB_GET_PIN_SENSE, 0);
     9746        present = (present & 0x80000000) != 0;
     9747        if (present) {
     9748                /* mute line output on ATX panel */
     9749                snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     9750                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
     9751        } else {
     9752                /* unmute line output if necessary */
     9753                mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
     9754                snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
     9755                                         HDA_AMP_MUTE, mute);
     9756        }
     9757}
     9758
     9759static void alc262_tyan_unsol_event(struct hda_codec *codec,
     9760                                       unsigned int res)
     9761{
     9762        if ((res >> 26) != ALC880_HP_EVENT)
     9763                return;
     9764        alc262_tyan_automute(codec);
     9765}
    91049766
    91059767#define alc262_capture_mixer            alc882_capture_mixer
     
    956910231        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    957010232        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    9571         HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
    9572         HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
    957310233        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    957410234        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
     
    1014210802        if (err < 0)
    1014310803                return err;
    10144         if (!spec->autocfg.line_outs)
     10804        if (!spec->autocfg.line_outs) {
     10805                if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
     10806                        spec->multiout.max_channels = 2;
     10807                        spec->no_analog = 1;
     10808                        goto dig_only;
     10809                }
    1014510810                return 0; /* can't find valid BIOS pin config */
     10811        }
    1014610812        err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
    1014710813        if (err < 0)
     
    1015310819        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    1015410820
    10155         if (spec->autocfg.dig_out_pin)
     10821 dig_only:
     10822        if (spec->autocfg.dig_outs) {
    1015610823                spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
     10824                spec->dig_out_type = spec->autocfg.dig_out_type[0];
     10825        }
    1015710826        if (spec->autocfg.dig_in_pin)
    1015810827                spec->dig_in_nid = ALC262_DIGIN_NID;
     
    1016310832        add_verb(spec, alc262_volume_init_verbs);
    1016410833        spec->num_mux_defs = 1;
    10165         spec->input_mux = &spec->private_imux;
     10834        spec->input_mux = &spec->private_imux[0];
    1016610835
    1016710836        err = alc_auto_add_mic_boost(codec);
     
    1016910838                return err;
    1017010839
    10171         store_pin_configs(codec);
    1017210840        return 1;
    1017310841}
     
    1021110879        [ALC262_LENOVO_3000]    = "lenovo-3000",
    1021210880        [ALC262_NEC]            = "nec",
     10881        [ALC262_TYAN]           = "tyan",
    1021310882        [ALC262_AUTO]           = "auto",
    1021410883};
     
    1021710886        SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
    1021810887        SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
    10219         SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
    10220         SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
    10221         SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
    10222         SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
    10223         SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
    10224         SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
    10225         SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
    10226         SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
     10888        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
     10889                           ALC262_HP_BPC),
     10890        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
     10891                           ALC262_HP_BPC),
     10892        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
     10893                           ALC262_HP_BPC),
    1022710894        SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
    1022810895        SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
     
    1024210909        SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
    1024310910        SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
    10244         SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
    10245         SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
     10911        SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
     10912        SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
     10913                           ALC262_SONY_ASSAMD),
    1024610914        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
    1024710915                      ALC262_TOSHIBA_RX1),
     
    1024910917        SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
    1025010918        SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
    10251         SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
    10252         SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
     10919        SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
     10920        SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
     10921                           ALC262_ULTRA),
     10922        SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
    1025310923        SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
    1025410924        SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
     
    1046611136                .init_hook = alc262_hippo_automute,
    1046711137        },
     11138        [ALC262_TYAN] = {
     11139                .mixers = { alc262_tyan_mixer },
     11140                .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
     11141                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
     11142                .dac_nids = alc262_dac_nids,
     11143                .hp_nid = 0x02,
     11144                .dig_out_nid = ALC262_DIGOUT_NID,
     11145                .num_channel_mode = ARRAY_SIZE(alc262_modes),
     11146                .channel_mode = alc262_modes,
     11147                .input_mux = &alc262_capture_source,
     11148                .unsol_event = alc262_tyan_unsol_event,
     11149                .init_hook = alc262_tyan_automute,
     11150        },
    1046811151};
    1046911152
     
    1051811201        }
    1051911202
     11203        if (!spec->no_analog) {
     11204                err = snd_hda_attach_beep_device(codec, 0x1);
     11205                if (err < 0) {
     11206                        alc_free(codec);
     11207                        return err;
     11208                }
     11209        }
     11210
    1052011211        if (board_config != ALC262_AUTO)
    1052111212                setup_preset(spec, &alc262_presets[board_config]);
     
    1052911220        spec->stream_digital_capture = &alc262_pcm_digital_capture;
    1053011221
    10531         spec->is_mix_capture = 1;
     11222        spec->capture_style = CAPT_MIX;
    1053211223        if (!spec->adc_nids && spec->input_mux) {
    1053311224                /* check whether NID 0x07 is valid */
     
    1054611237                }
    1054711238        }
    10548         if (!spec->cap_mixer)
     11239        if (!spec->cap_mixer && !spec->no_analog)
    1054911240                set_capture_mixer(spec);
     11241        if (!spec->no_analog)
     11242                set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
    1055011243
    1055111244        spec->vmaster_nid = 0x0c;
     
    1055811251                spec->loopback.amplist = alc262_loopbacks;
    1055911252#endif
     11253        codec->proc_widget_hook = print_realtek_coef;
    1056011254
    1056111255        return 0;
     
    1092611620        /* Unmute DAC0-1 and set vol = 0 */
    1092711621        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    10928         {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    10929         {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1093011622        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    10931         {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    10932         {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1093311623
    1093411624        /*
     
    1093711627        /* set vol=0 to output mixers */
    1093811628        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    10939         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    10940         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1094111629        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
    1094211630
     
    1095711645        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1095811646        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    10959         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1096011647        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    10961         {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1096211648
    1096311649        /* set PCBEEP vol = 0, mute connections */
     
    1098111667static struct hda_verb alc268_volume_init_verbs[] = {
    1098211668        /* set output DAC */
    10983         {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    10984         {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    10985         {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    10986         {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
     11669        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
     11670        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1098711671
    1098811672        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
     
    1099211676        {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
    1099311677
    10994         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
    1099511678        {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    10996         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    1099711679        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1099811680        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    1099911681
    1100011682        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    11001         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1100211683        {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    11003         {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
    1100411684
    1100511685        /* set PCBEEP vol = 0, mute connections */
     
    1120011880                                                const struct auto_pin_cfg *cfg)
    1120111881{
    11202         struct hda_input_mux *imux = &spec->private_imux;
     11882        struct hda_input_mux *imux = &spec->private_imux[0];
    1120311883        int i, idx1;
    1120411884
     
    1129411974        if (err < 0)
    1129511975                return err;
    11296         if (!spec->autocfg.line_outs)
     11976        if (!spec->autocfg.line_outs) {
     11977                if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
     11978                        spec->multiout.max_channels = 2;
     11979                        spec->no_analog = 1;
     11980                        goto dig_only;
     11981                }
    1129711982                return 0; /* can't find valid BIOS pin config */
    11298 
     11983        }
    1129911984        err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
    1130011985        if (err < 0)
     
    1130611991        spec->multiout.max_channels = 2;
    1130711992
     11993 dig_only:
    1130811994        /* digital only support output */
    11309         if (spec->autocfg.dig_out_pin)
     11995        if (spec->autocfg.dig_outs) {
    1131011996                spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
    11311 
     11997                spec->dig_out_type = spec->autocfg.dig_out_type[0];
     11998        }
    1131211999        if (spec->kctls.list)
    1131312000                add_mixer(spec, spec->kctls.list);
    1131412001
    11315         if (spec->autocfg.speaker_pins[0] != 0x1d)
     12002        if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
    1131612003                add_mixer(spec, alc268_beep_mixer);
    1131712004
    1131812005        add_verb(spec, alc268_volume_init_verbs);
    1131912006        spec->num_mux_defs = 1;
    11320         spec->input_mux = &spec->private_imux;
     12007        spec->input_mux = &spec->private_imux[0];
    1132112008
    1132212009        err = alc_auto_add_mic_boost(codec);
     
    1132412011                return err;
    1132512012
    11326         store_pin_configs(codec);
    1132712013        return 1;
    1132812014}
     
    1137112057                                                ALC268_ACER_ASPIRE_ONE),
    1137212058        SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
     12059        SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
    1137312060        SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
    1137412061        SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
     
    1138512072static struct alc_config_preset alc268_presets[] = {
    1138612073        [ALC267_QUANTA_IL1] = {
    11387                 .mixers = { alc267_quanta_il1_mixer },
     12074                .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
    1138812075                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
    1138912076                                alc267_quanta_il1_verbs },
     
    1146712154        [ALC268_ACER_ASPIRE_ONE] = {
    1146812155                .mixers = { alc268_acer_aspire_one_mixer,
    11469                                 alc268_capture_alt_mixer },
     12156                            alc268_beep_mixer,
     12157                            alc268_capture_alt_mixer },
    1147012158                .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
    1147112159                                alc268_acer_aspire_one_verbs },
     
    1153612224        struct alc_spec *spec;
    1153712225        int board_config;
    11538         int err;
     12226        int i, has_beep, err;
    1153912227
    1154012228        spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
     
    1158512273        spec->stream_digital_playback = &alc268_pcm_digital_playback;
    1158612274
    11587         if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
    11588                 /* override the amp caps for beep generator */
    11589                 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
     12275        has_beep = 0;
     12276        for (i = 0; i < spec->num_mixers; i++) {
     12277                if (spec->mixers[i] == alc268_beep_mixer) {
     12278                        has_beep = 1;
     12279                        break;
     12280                }
     12281        }
     12282
     12283        if (has_beep) {
     12284                err = snd_hda_attach_beep_device(codec, 0x1);
     12285                if (err < 0) {
     12286                        alc_free(codec);
     12287                        return err;
     12288                }
     12289                if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
     12290                        /* override the amp caps for beep generator */
     12291                        snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
    1159012292                                          (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
    1159112293                                          (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
    1159212294                                          (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
    1159312295                                          (0 << AC_AMPCAP_MUTE_SHIFT));
    11594 
    11595         if (!spec->adc_nids && spec->input_mux) {
     12296        }
     12297
     12298        if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
    1159612299                /* check whether NID 0x07 is valid */
    1159712300                unsigned int wcap = get_wcaps(codec, 0x07);
     
    1162312326                spec->init_hook = alc268_auto_init;
    1162412327
     12328        codec->proc_widget_hook = print_realtek_coef;
     12329
    1162512330        return 0;
    1162612331}
     
    1167212377        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
    1167312378        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
    11674         HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
    11675         HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
    1167612379        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
    1167712380        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
     
    1170012403        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
    1170112404        HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
    11702         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
    11703         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
    1170412405        {0}
    1170512406};
     
    1172512426        HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
    1172612427        HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
    11727         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
    11728         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
    1172912428        {0}
    1173012429};
     
    1176012459        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
    1176112460        HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
    11762         {0} /* end */
    11763 };
    11764 
    11765 /* beep control */
    11766 static struct snd_kcontrol_new alc269_beep_mixer[] = {
    11767         HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
    11768         HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
    1176912461        {0} /* end */
    1177012462};
     
    1216912861        if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
    1217012862            cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
    12171                 struct hda_input_mux *imux = &spec->private_imux;
     12863                struct hda_input_mux *imux = &spec->private_imux[0];
    1217212864                imux->items[imux->num_items].label = "Int Mic";
    1217312865                imux->items[imux->num_items].index = 0x05;
     
    1218712879#define alc269_pcm_digital_capture      alc880_pcm_digital_capture
    1218812880
     12881static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
     12882        .substreams = 1,
     12883        .channels_min = 2,
     12884        .channels_max = 8,
     12885        .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
     12886        /* NID is set in alc_build_pcms */
     12887        .ops = {
     12888                .open = alc880_playback_pcm_open,
     12889                .prepare = alc880_playback_pcm_prepare,
     12890                .cleanup = alc880_playback_pcm_cleanup
     12891        },
     12892};
     12893
     12894static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
     12895        .substreams = 1,
     12896        .channels_min = 2,
     12897        .channels_max = 2,
     12898        .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
     12899        /* NID is set in alc_build_pcms */
     12900};
     12901
    1218912902/*
    1219012903 * BIOS auto configuration
     
    1219312906{
    1219412907        struct alc_spec *spec = codec->spec;
    12195         int i, err;
     12908        int err;
    1219612909        static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
    1219712910
     
    1221012923        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    1221112924
    12212         if (spec->autocfg.dig_out_pin)
     12925        if (spec->autocfg.dig_outs)
    1221312926                spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
    1221412927
     
    1221612929                add_mixer(spec, spec->kctls.list);
    1221712930
    12218         /* create a beep mixer control if the pin 0x1d isn't assigned */
    12219         for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
    12220                 if (spec->autocfg.input_pins[i] == 0x1d)
    12221                         break;
    12222         if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
    12223                 add_mixer(spec, alc269_beep_mixer);
    12224 
    1222512931        add_verb(spec, alc269_init_verbs);
    1222612932        spec->num_mux_defs = 1;
    12227         spec->input_mux = &spec->private_imux;
     12933        spec->input_mux = &spec->private_imux[0];
    1222812934        /* set default input source */
    1222912935        snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
     
    1223512941                return err;
    1223612942
    12237         if (!spec->cap_mixer)
     12943        if (!spec->cap_mixer && !spec->no_analog)
    1223812944                set_capture_mixer(spec);
    1223912945
    12240         store_pin_configs(codec);
    1224112946        return 1;
    1224212947}
     
    1227412979        SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
    1227512980                      ALC269_ASUS_EEEPC_P703),
     12981        SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
     12982        SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
     12983        SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
     12984        SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
     12985        SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
     12986        SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
    1227612987        SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
    1227712988                      ALC269_ASUS_EEEPC_P901),
    1227812989        SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
    1227912990                      ALC269_ASUS_EEEPC_P901),
     12991        SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
    1228012992        SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
    1228112993        SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
     
    1233513047        },
    1233613048        [ALC269_FUJITSU] = {
    12337                 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
     13049                .mixers = { alc269_fujitsu_mixer },
    1233813050                .cap_mixer = alc269_epc_capture_mixer,
    1233913051                .init_verbs = { alc269_init_verbs,
     
    1240013112        }
    1240113113
     13114        err = snd_hda_attach_beep_device(codec, 0x1);
     13115        if (err < 0) {
     13116                alc_free(codec);
     13117                return err;
     13118        }
     13119
    1240213120        if (board_config != ALC269_AUTO)
    1240313121                setup_preset(spec, &alc269_presets[board_config]);
    1240413122
    1240513123        spec->stream_name_analog = "ALC269 Analog";
    12406         spec->stream_analog_playback = &alc269_pcm_analog_playback;
    12407         spec->stream_analog_capture = &alc269_pcm_analog_capture;
    12408 
     13124        if (codec->subsystem_id == 0x17aa3bf8) {
     13125                /* Due to a hardware problem on Lenovo Ideadpad, we need to
     13126                 * fix the sample rate of analog I/O to 44.1kHz
     13127                 */
     13128                spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
     13129                spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
     13130        } else {
     13131                spec->stream_analog_playback = &alc269_pcm_analog_playback;
     13132                spec->stream_analog_capture = &alc269_pcm_analog_capture;
     13133        }
    1240913134        spec->stream_name_digital = "ALC269 Digital";
    1241013135        spec->stream_digital_playback = &alc269_pcm_digital_playback;
     
    1241613141        if (!spec->cap_mixer)
    1241713142                set_capture_mixer(spec);
     13143        set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
    1241813144
    1241913145        codec->patch_ops = alc_patch_ops;
     
    1242413150                spec->loopback.amplist = alc269_loopbacks;
    1242513151#endif
     13152        codec->proc_widget_hook = print_realtek_coef;
    1242613153
    1242713154        return 0;
     
    1266413391        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
    1266513392        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
    12666         HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
    12667         HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
    1266813393        {0}
    1266913394};
     
    1313913864                                                const struct auto_pin_cfg *cfg)
    1314013865{
    13141         struct hda_input_mux *imux = &spec->private_imux;
     13866        struct hda_input_mux *imux = &spec->private_imux[0];
    1314213867        int i, err, idx, idx1;
    1314313868
     
    1322613951        for (i = 0; i < AUTO_PIN_LAST; i++) {
    1322713952                hda_nid_t nid = spec->autocfg.input_pins[i];
    13228                 if (nid >= 0x0c && nid <= 0x11) {
    13229                         snd_hda_codec_write(codec, nid, 0,
    13230                                             AC_VERB_SET_PIN_WIDGET_CONTROL,
    13231                                             i <= AUTO_PIN_FRONT_MIC ?
    13232                                             PIN_VREF80 : PIN_IN);
    13233                 }
     13953                if (nid >= 0x0c && nid <= 0x11)
     13954                        alc_set_input_pin(codec, nid, i);
    1323413955        }
    1323513956}
     
    1326713988        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    1326813989
    13269         if (spec->autocfg.dig_out_pin)
     13990        if (spec->autocfg.dig_outs)
    1327013991                spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
    1327113992
     
    1327613997
    1327713998        spec->num_mux_defs = 1;
    13278         spec->input_mux = &spec->private_imux;
     13999        spec->input_mux = &spec->private_imux[0];
    1327914000
    1328014001        spec->adc_nids = alc861_adc_nids;
     
    1328214003        set_capture_mixer(spec);
    1328314004
    13284         store_pin_configs(codec);
    1328514005        return 1;
    1328614006}
     
    1349114211        }
    1349214212
     14213        err = snd_hda_attach_beep_device(codec, 0x23);
     14214        if (err < 0) {
     14215                alc_free(codec);
     14216                return err;
     14217        }
     14218
    1349314219        if (board_config != ALC861_AUTO)
    1349414220                setup_preset(spec, &alc861_presets[board_config]);
     
    1350114227        spec->stream_digital_playback = &alc861_pcm_digital_playback;
    1350214228        spec->stream_digital_capture = &alc861_pcm_digital_capture;
     14229
     14230        set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
    1350314231
    1350414232        spec->vmaster_nid = 0x03;
     
    1351114239                spec->loopback.amplist = alc861_loopbacks;
    1351214240#endif
     14241        codec->proc_widget_hook = print_realtek_coef;
    1351314242
    1351414243        return 0;
     
    1365714386        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    1365814387
    13659         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    13660         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    13661 
    1366214388        {0} /* end */
    1366314389};
     
    1368214408        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
    1368314409        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
    13684 
    13685         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    13686         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    1368714410
    1368814411        {0} /* end */
     
    1372414447        HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    1372514448        HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    13726         HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
    13727         HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
    1372814449        {0} /* end */
    1372914450};
     
    1403614757        SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
    1403714758        SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
    14038         SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
    14039         SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
    14040         SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
     14759        SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
    1404114760        SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
    1404214761        {0}
     
    1420014919                hda_nid_t nid = spec->autocfg.input_pins[i];
    1420114920                if (alc861vd_is_input_pin(nid)) {
    14202                         snd_hda_codec_write(codec, nid, 0,
    14203                                         AC_VERB_SET_PIN_WIDGET_CONTROL,
    14204                                         i <= AUTO_PIN_FRONT_MIC ?
    14205                                                         PIN_VREF80 : PIN_IN);
    14206                         if (nid != ALC861VD_PIN_CD_NID)
     14921                        alc_set_input_pin(codec, nid, i);
     14922                        if (nid != ALC861VD_PIN_CD_NID &&
     14923                            (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
    1420714924                                snd_hda_codec_write(codec, nid, 0,
    1420814925                                                AC_VERB_SET_AMP_GAIN_MUTE,
     
    1437015087        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    1437115088
    14372         if (spec->autocfg.dig_out_pin)
     15089        if (spec->autocfg.dig_outs)
    1437315090                spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
    1437415091
     
    1437915096
    1438015097        spec->num_mux_defs = 1;
    14381         spec->input_mux = &spec->private_imux;
     15098        spec->input_mux = &spec->private_imux[0];
    1438215099
    1438315100        err = alc_auto_add_mic_boost(codec);
     
    1438515102                return err;
    1438615103
    14387         store_pin_configs(codec);
    1438815104        return 1;
    1438915105}
     
    1443615152        }
    1443715153
     15154        err = snd_hda_attach_beep_device(codec, 0x23);
     15155        if (err < 0) {
     15156                alc_free(codec);
     15157                return err;
     15158        }
     15159
    1443815160        if (board_config != ALC861VD_AUTO)
    1443915161                setup_preset(spec, &alc861vd_presets[board_config]);
     
    1445815180        spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
    1445915181        spec->capsrc_nids = alc861vd_capsrc_nids;
    14460         spec->is_mix_capture = 1;
     15182        spec->capture_style = CAPT_MIX;
    1446115183
    1446215184        set_capture_mixer(spec);
     15185        set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
    1446315186
    1446415187        spec->vmaster_nid = 0x02;
     
    1447215195                spec->loopback.amplist = alc861vd_loopbacks;
    1447315196#endif
     15197        codec->proc_widget_hook = print_realtek_coef;
    1447415198
    1447515199        return 0;
     
    1449515219};
    1449615220
     15221static hda_nid_t alc272_dac_nids[2] = {
     15222        0x02, 0x03
     15223};
     15224
    1449715225static hda_nid_t alc662_adc_nids[1] = {
    1449815226        /* ADC1-2 */
     
    1450015228};
    1450115229
     15230static hda_nid_t alc272_adc_nids[1] = {
     15231        /* ADC1-2 */
     15232        0x08,
     15233};
     15234
    1450215235static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
     15236static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
     15237
    1450315238
    1450415239/* input MUX */
     
    1464815383        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    1464915384        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    14650         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    14651         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    1465215385        {0} /* end */
    1465315386};
     
    1467115404        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
    1467215405        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
    14673         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
    14674         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
    1467515406        {0} /* end */
    1467615407};
     
    1493015661        /* Input mixer */
    1493115662        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    14932         {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    14933         {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    14934         {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    14935 
    1493615663        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    14937         {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
    14938         {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
    14939         {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
    1494015664
    1494115665        /* always trun on EAPD */
     
    1513215856};
    1513315857
     15858static struct hda_verb alc272_dell_zm1_init_verbs[] = {
     15859        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15860        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15861        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15862        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15863        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     15864        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     15865        {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Headphone */
     15866        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     15867        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
     15868        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
     15869        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     15870        {0}
     15871};
     15872
     15873static struct hda_verb alc272_dell_init_verbs[] = {
     15874        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15875        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15876        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15877        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
     15878        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
     15879        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
     15880        {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Headphone */
     15881        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
     15882        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
     15883        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
     15884        {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
     15885        {0}
     15886};
     15887
    1513415888static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
    1513515889        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
    1513615890        HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
     15891        {0} /* end */
     15892};
     15893
     15894static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
     15895        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
     15896        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
    1513715897        {0} /* end */
    1513815898};
     
    1564816408
    1564916409static struct snd_pci_quirk alc662_cfg_tbl[] = {
     16410        SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
     16411        SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
     16412        SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
     16413        SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
     16414        SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
     16415        SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
     16416        SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
     16417        SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
     16418        SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
     16419        SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
     16420        SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
     16421        SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
     16422        SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
     16423        SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
     16424        SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
     16425        SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
     16426        SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
     16427        SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
     16428        SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
     16429        SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
     16430        SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
     16431        SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
     16432        SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
     16433        SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
     16434        SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
    1565016435        SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
     16436        /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
     16437        SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
     16438        SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
     16439        SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
     16440        SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
     16441        SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
     16442        SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
     16443        SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
     16444        SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
     16445        SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
     16446        SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
     16447        SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
     16448        SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
     16449        SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
    1565116450        SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
     16451        /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
     16452        SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
     16453        SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
     16454        SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
     16455        SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
     16456        SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
    1565216457        SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
    1565316458        SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
    1565416459        SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
    15655         SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
    15656         SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
    15657         SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
    15658         SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
    15659         SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
    15660         SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
    15661         SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
    15662         SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
    15663         SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
    15664         SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
    15665         SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
    15666         SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
    15667         SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
    15668         SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
    15669         SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
    15670         SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
    15671         SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
    15672         SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
    15673         SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
    15674         SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
    15675         SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
    15676         SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
    15677         SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
    15678         SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
    15679         SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
    15680         SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
    15681         SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
    15682         SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
    15683         SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
    15684         SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
    15685         SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
    15686         SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
     16460        SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
    1568716461        SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
    1568816462                      ALC662_3ST_6ch_DIG),
    15689         SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
    15690         SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
    15691         SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
    1569216463        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
    1569316464                      ALC662_3ST_6ch_DIG),
    1569416465        SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
     16466        SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
     16467        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
    1569516468        SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
    1569616469                                        ALC662_3ST_6ch_DIG),
    15697         SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
    15698         SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
    15699         SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
     16470        SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
     16471                           ALC663_ASUS_H13),
    1570016472        {0}
    1570116473};
     
    1592916701                .unsol_event = alc663_mode6_unsol_event,
    1593016702                .init_hook = alc663_mode6_inithook,
     16703        },
     16704        [ALC272_DELL] = {
     16705                .mixers = { alc663_m51va_mixer },
     16706                .cap_mixer = alc272_auto_capture_mixer,
     16707                .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
     16708                .num_dacs = ARRAY_SIZE(alc272_dac_nids),
     16709                .dac_nids = alc662_dac_nids,
     16710                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
     16711                .adc_nids = alc272_adc_nids,
     16712                .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
     16713                .capsrc_nids = alc272_capsrc_nids,
     16714                .channel_mode = alc662_3ST_2ch_modes,
     16715                .input_mux = &alc663_m51va_capture_source,
     16716                .unsol_event = alc663_m51va_unsol_event,
     16717                .init_hook = alc663_m51va_inithook,
     16718        },
     16719        [ALC272_DELL_ZM1] = {
     16720                .mixers = { alc663_m51va_mixer },
     16721                .cap_mixer = alc662_auto_capture_mixer,
     16722                .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
     16723                .num_dacs = ARRAY_SIZE(alc272_dac_nids),
     16724                .dac_nids = alc662_dac_nids,
     16725                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
     16726                .adc_nids = alc662_adc_nids,
     16727                .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
     16728                .capsrc_nids = alc662_capsrc_nids,
     16729                .channel_mode = alc662_3ST_2ch_modes,
     16730                .input_mux = &alc663_m51va_capture_source,
     16731                .unsol_event = alc663_m51va_unsol_event,
     16732                .init_hook = alc663_m51va_inithook,
    1593116733        },
    1593216734};
     
    1601716819        if (alc880_is_fixed_pin(pin)) {
    1601816820                nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
    16019                 /* printk("DAC nid=%x\n",nid); */
     16821                /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
    1602016822                /* specify the DAC as the extra output */
    1602116823                if (!spec->multiout.hp_nid)
     
    1604716849}
    1604816850
     16851/* return the index of the src widget from the connection list of the nid.
     16852 * return -1 if not found
     16853 */
     16854static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
     16855                                hda_nid_t src)
     16856{
     16857        hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
     16858        int i, conns;
     16859
     16860        conns = snd_hda_get_connections(codec, nid, conn_list,
     16861                                        ARRAY_SIZE(conn_list));
     16862        if (conns < 0)
     16863                return -1;
     16864        for (i = 0; i < conns; i++)
     16865                if (conn_list[i] == src)
     16866                        return i;
     16867        return -1;
     16868}
     16869
     16870static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
     16871{
     16872        unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
     16873        return (pincap & AC_PINCAP_IN) != 0;
     16874}
     16875
    1604916876/* create playback/capture controls for input pins */
    16050 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
     16877static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
    1605116878                                                const struct auto_pin_cfg *cfg)
    1605216879{
    16053         struct hda_input_mux *imux = &spec->private_imux;
     16880        struct alc_spec *spec = codec->spec;
     16881        struct hda_input_mux *imux = &spec->private_imux[0];
    1605416882        int i, err, idx;
    1605516883
    1605616884        for (i = 0; i < AUTO_PIN_LAST; i++) {
    16057                 if (alc880_is_input_pin(cfg->input_pins[i])) {
    16058                         idx = alc880_input_pin_idx(cfg->input_pins[i]);
    16059                         err = new_analog_input(spec, cfg->input_pins[i],
    16060                                                auto_pin_cfg_labels[i],
    16061                                                idx, 0x0b);
    16062                         if (err < 0)
    16063                                 return err;
    16064                         imux->items[imux->num_items].label =
    16065                                 auto_pin_cfg_labels[i];
    16066                         imux->items[imux->num_items].index =
    16067                                 alc880_input_pin_idx(cfg->input_pins[i]);
    16068                         imux->num_items++;
     16885                if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
     16886                        idx = alc662_input_pin_idx(codec, 0x0b,
     16887                                                   cfg->input_pins[i]);
     16888                        if (idx >= 0) {
     16889                                err = new_analog_input(spec, cfg->input_pins[i],
     16890                                                       auto_pin_cfg_labels[i],
     16891                                                       idx, 0x0b);
     16892                                if (err < 0)
     16893                                        return err;
     16894                        }
     16895                        idx = alc662_input_pin_idx(codec, 0x22,
     16896                                                   cfg->input_pins[i]);
     16897                        if (idx >= 0) {
     16898                                imux->items[imux->num_items].label =
     16899                                        auto_pin_cfg_labels[i];
     16900                                imux->items[imux->num_items].index = idx;
     16901                                imux->num_items++;
     16902                        }
    1606916903                }
    1607016904        }
     
    1611616950}
    1611716951
    16118 #define alc662_is_input_pin(nid)        alc880_is_input_pin(nid)
    1611916952#define ALC662_PIN_CD_NID               ALC880_PIN_CD_NID
    1612016953
     
    1612616959        for (i = 0; i < AUTO_PIN_LAST; i++) {
    1612716960                hda_nid_t nid = spec->autocfg.input_pins[i];
    16128                 if (alc662_is_input_pin(nid)) {
    16129                         snd_hda_codec_write(codec, nid, 0,
    16130                                             AC_VERB_SET_PIN_WIDGET_CONTROL,
    16131                                             (i <= AUTO_PIN_FRONT_MIC ?
    16132                                              PIN_VREF80 : PIN_IN));
    16133                         if (nid != ALC662_PIN_CD_NID)
     16961                if (alc662_is_input_pin(codec, nid)) {
     16962                        alc_set_input_pin(codec, nid, i);
     16963                        if (nid != ALC662_PIN_CD_NID &&
     16964                            (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
    1613416965                                snd_hda_codec_write(codec, nid, 0,
    1613516966                                                    AC_VERB_SET_AMP_GAIN_MUTE,
     
    1616917000        if (err < 0)
    1617017001                return err;
    16171         err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
     17002        err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
    1617217003        if (err < 0)
    1617317004                return err;
     
    1617517006        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    1617617007
    16177         if (spec->autocfg.dig_out_pin)
     17008        if (spec->autocfg.dig_outs)
    1617817009                spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
    1617917010
     
    1618217013
    1618317014        spec->num_mux_defs = 1;
    16184         spec->input_mux = &spec->private_imux;
     17015        spec->input_mux = &spec->private_imux[0];
    1618517016
    1618617017        add_verb(spec, alc662_auto_init_verbs);
     
    1619217023                return err;
    1619317024
    16194         store_pin_configs(codec);
    1619517025        return 1;
    1619617026}
     
    1624417074        }
    1624517075
     17076        err = snd_hda_attach_beep_device(codec, 0x1);
     17077        if (err < 0) {
     17078                alc_free(codec);
     17079                return err;
     17080        }
     17081
    1624617082        if (board_config != ALC662_AUTO)
    1624717083                setup_preset(spec, &alc662_presets[board_config]);
     
    1626717103        spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
    1626817104        spec->capsrc_nids = alc662_capsrc_nids;
    16269         spec->is_mix_capture = 1;
     17105        spec->capture_style = CAPT_MIX;
    1627017106
    1627117107        if (!spec->cap_mixer)
    1627217108                set_capture_mixer(spec);
     17109        if (codec->vendor_id == 0x10ec0662)
     17110                set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
     17111        else
     17112                set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
    1627317113
    1627417114        spec->vmaster_nid = 0x02;
     
    1628117121                spec->loopback.amplist = alc662_loopbacks;
    1628217122#endif
     17123        codec->proc_widget_hook = print_realtek_coef;
    1628317124
    1628417125        return 0;
     
    1628817129 * patch entries
    1628917130 */
    16290 struct hda_codec_preset snd_hda_preset_realtek[] = {
     17131static struct hda_codec_preset snd_hda_preset_realtek[] = {
    1629117132        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
    1629217133        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
     
    1631417155        { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
    1631517156        { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
    16316         { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
    1631717157        { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
    1631817158          .patch = patch_alc883 },
     17159        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
    1631917160        { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
    1632017161        {0} /* terminator */
    1632117162};
     17163
     17164MODULE_ALIAS("snd-hda-codec-id:10ec*");
     17165
     17166MODULE_LICENSE("GPL");
     17167MODULE_DESCRIPTION("Realtek HD-audio codec");
     17168
     17169static struct hda_codec_preset_list realtek_list = {
     17170        .preset = snd_hda_preset_realtek,
     17171        .owner = THIS_MODULE,
     17172};
     17173
     17174static int __init patch_realtek_init(void)
     17175{
     17176        return snd_hda_add_codec_preset(&realtek_list);
     17177}
     17178
     17179static void __exit patch_realtek_exit(void)
     17180{
     17181        snd_hda_delete_codec_preset(&realtek_list);
     17182}
     17183
     17184module_init(patch_realtek_init)
     17185module_exit(patch_realtek_exit)
  • GPL/trunk/alsa-kernel/pci/hda/patch_si3054.c

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

    r417 r426  
    3434#include "hda_codec.h"
    3535#include "hda_local.h"
    36 #include "hda_patch.h"
    3736#include "hda_beep.h"
    3837
    39 #define STAC_INSERT_EVENT       0x10
    40 #define STAC_PWR_EVENT          0x20
    41 #define STAC_HP_EVENT           0x30
    42 #define STAC_VREF_EVENT         0x40
    43 
    4438enum {
     39        STAC_VREF_EVENT = 1,
     40        STAC_INSERT_EVENT,
     41        STAC_PWR_EVENT,
     42        STAC_HP_EVENT,
     43};
     44
     45enum {
     46        STAC_AUTO,
    4547        STAC_REF,
    4648        STAC_9200_OQO,
     
    5557        STAC_9200_DELL_M26,
    5658        STAC_9200_DELL_M27,
    57         STAC_9200_GATEWAY,
     59        STAC_9200_M4,
     60        STAC_9200_M4_2,
    5861        STAC_9200_PANASONIC,
    5962        STAC_9200_MODELS
     
    6164
    6265enum {
     66        STAC_9205_AUTO,
    6367        STAC_9205_REF,
    6468        STAC_9205_DELL_M42,
    6569        STAC_9205_DELL_M43,
    6670        STAC_9205_DELL_M44,
     71        STAC_9205_EAPD,
    6772        STAC_9205_MODELS
    6873};
    6974
    7075enum {
     76        STAC_92HD73XX_AUTO,
     77        STAC_92HD73XX_NO_JD, /* no jack-detection */
    7178        STAC_92HD73XX_REF,
    72         STAC_DELL_M6,
     79        STAC_DELL_M6_AMIC,
     80        STAC_DELL_M6_DMIC,
     81        STAC_DELL_M6_BOTH,
    7382        STAC_DELL_EQ,
    7483        STAC_92HD73XX_MODELS
     
    7685
    7786enum {
     87        STAC_92HD83XXX_AUTO,
    7888        STAC_92HD83XXX_REF,
     89        STAC_92HD83XXX_PWR_REF,
     90        STAC_DELL_S14,
    7991        STAC_92HD83XXX_MODELS
    8092};
    8193
    8294enum {
     95        STAC_92HD71BXX_AUTO,
    8396        STAC_92HD71BXX_REF,
    8497        STAC_DELL_M4_1,
    8598        STAC_DELL_M4_2,
     99        STAC_DELL_M4_3,
    86100        STAC_HP_M4,
     101        STAC_HP_DV5,
     102        STAC_HP_HDX,
    87103        STAC_92HD71BXX_MODELS
    88104};
    89105
    90106enum {
     107        STAC_925x_AUTO,
    91108        STAC_925x_REF,
     109        STAC_M1,
     110        STAC_M1_2,
     111        STAC_M2,
    92112        STAC_M2_2,
    93         STAC_MA6,
    94         STAC_PA6,
     113        STAC_M3,
     114        STAC_M5,
     115        STAC_M6,
    95116        STAC_925x_MODELS
    96117};
    97118
    98119enum {
     120        STAC_922X_AUTO,
    99121        STAC_D945_REF,
    100122        STAC_D945GTP3,
     
    124146
    125147enum {
     148        STAC_927X_AUTO,
     149        STAC_D965_REF_NO_JD, /* no jack-detection */
    126150        STAC_D965_REF,
    127151        STAC_D965_3ST,
     
    132156};
    133157
     158enum {
     159        STAC_9872_AUTO,
     160        STAC_9872_VAIO,
     161        STAC_9872_MODELS
     162};
     163
    134164struct sigmatel_event {
    135165        hda_nid_t nid;
     166        unsigned char type;
     167        unsigned char tag;
    136168        int data;
    137169};
     
    148180
    149181        int board_config;
     182        unsigned int eapd_switch: 1;
    150183        unsigned int surr_switch: 1;
    151         unsigned int line_switch: 1;
    152         unsigned int mic_switch: 1;
    153184        unsigned int alt_switch: 1;
    154185        unsigned int hp_detect: 1;
    155186        unsigned int spdif_mute: 1;
     187        unsigned int check_volume_offset:1;
    156188
    157189        /* gpio lines */
     
    166198
    167199        /* analog loopback */
     200        struct snd_kcontrol_new *aloopback_ctl;
    168201        unsigned char aloopback_mask;
    169202        unsigned char aloopback_shift;
     
    187220        struct hda_multi_out multiout;
    188221        hda_nid_t dac_nids[5];
     222        hda_nid_t hp_dacs[5];
     223        hda_nid_t speaker_dacs[5];
     224
     225        int volume_offset;
    189226
    190227        /* capture */
     
    209246        hda_nid_t *pin_nids;
    210247        unsigned int num_pins;
    211         unsigned int *pin_configs;
    212         unsigned int *bios_pin_configs;
    213248
    214249        /* codec specific stuff */
     
    231266        unsigned int io_switch[2];
    232267        unsigned int clfe_swap;
    233         unsigned int hp_switch;
     268        hda_nid_t line_switch;  /* shared line-in for input and output */
     269        hda_nid_t mic_switch;   /* shared mic-in for input and output */
     270        hda_nid_t hp_switch; /* NID of HP as line-out */
    234271        unsigned int aloopback;
    235272
     
    282319
    283320#define STAC92HD73_DAC_COUNT 5
    284 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
    285         0x15, 0x16, 0x17, 0x18, 0x19,
    286 };
    287321
    288322static hda_nid_t stac92hd73xx_mux_nids[4] = {
     
    303337};
    304338
    305 #define STAC92HD81_DAC_COUNT 2
    306339#define STAC92HD83_DAC_COUNT 3
    307 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
    308         0x13, 0x14, 0x22,
    309 };
    310340
    311341static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
     
    326356
    327357static unsigned int stac92hd83xxx_pwr_mapping[4] = {
    328         0x03, 0x0c, 0x10, 0x40,
     358        0x03, 0x0c, 0x20, 0x40,
     359};
     360
     361static hda_nid_t stac92hd83xxx_amp_nids[1] = {
     362        0xc,
    329363};
    330364
     
    347381static hda_nid_t stac92hd71bxx_smux_nids[2] = {
    348382        0x24, 0x25,
    349 };
    350 
    351 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
    352         0x10, /*0x11, */
    353383};
    354384
     
    389419static hda_nid_t stac922x_mux_nids[2] = {
    390420        0x12, 0x13,
     421};
     422
     423static hda_nid_t stac927x_slave_dig_outs[2] = {
     424        0x1f, 0,
    391425};
    392426
     
    463497};
    464498
    465 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
     499static hda_nid_t stac92hd83xxx_pin_nids[10] = {
    466500        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
    467         0x0f, 0x10, 0x11, 0x12, 0x13,
    468         0x1d, 0x1e, 0x1f, 0x20
    469 };
    470 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
     501        0x0f, 0x10, 0x11, 0x1f, 0x20,
     502};
     503
     504#define STAC92HD71BXX_NUM_PINS 13
     505static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
     506        0x0a, 0x0b, 0x0c, 0x0d, 0x00,
     507        0x00, 0x14, 0x18, 0x19, 0x1e,
     508        0x1f, 0x20, 0x27
     509};
     510static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
    471511        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
    472512        0x0f, 0x14, 0x18, 0x19, 0x1e,
    473         0x1f,
     513        0x1f, 0x20, 0x27
    474514};
    475515
     
    584624                        nid = codec->slave_dig_outs[smux_idx - 1];
    585625                if (spec->cur_smux[smux_idx] == smux->num_items - 1)
    586                         val = AMP_OUT_MUTE;
     626                        val = HDA_AMP_MUTE;
    587627                else
    588                         val = AMP_OUT_UNMUTE;
     628                        val = 0;
    589629                /* un/mute SPDIF out */
    590                 snd_hda_codec_write_cache(codec, nid, 0,
    591                         AC_VERB_SET_AMP_GAIN_MUTE, val);
     630                snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
     631                                         HDA_AMP_MUTE, val);
    592632        }
    593633        return 0;
     
    754794        /* set master volume and direct control */
    755795        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    756         /* setup audio connections */
    757         { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
    758         { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
    759         { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
    760796        /* setup adcs to point to mixer */
    761797        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    776812         * and direct control */
    777813        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
    778         /* setup audio connections */
    779         { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
    780         { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
    781         { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
    782814        /* setup adcs to point to mixer */
    783815        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    793825static struct hda_verb dell_m6_core_init[] = {
    794826        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    795         /* setup audio connections */
    796         { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
    797         { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
    798         { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
    799827        /* setup adcs to point to mixer */
    800828        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    811839        /* set master volume and direct control */
    812840        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    813         /* setup audio connections */
    814         { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
    815         { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
    816         { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
    817         /* connect hp ports to dac3 */
    818         { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
    819         { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
    820841        /* setup adcs to point to mixer */
    821842        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    835856        /* set master volume and direct control */
    836857        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    837         /* setup audio connections */
    838         { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
    839         { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
    840         { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
    841858        /* dac3 is connected to import3 mux */
    842859        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
    843         /* connect hp ports to dac4 */
    844         { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
    845         { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
    846860        /* setup adcs to point to mixer */
    847861        { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
     
    859873
    860874static struct hda_verb stac92hd83xxx_core_init[] = {
    861         /* start of config #1 */
    862         { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
    863 
    864         /* start of config #2 */
    865         { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
    866         { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
    867         { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
     875        { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
     876        { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
     877        { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
    868878
    869879        /* power state controls amps */
    870880        { 0x01, AC_VERB_SET_EAPD, 1 << 2},
     881        {0}
    871882};
    872883
     
    874885        /* set master volume and direct control */
    875886        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    876         /* connect headphone jack to dac1 */
    877         { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
    878         /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
    879         { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    880         { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    881         { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    882 };
    883 
    884 #define HD_DISABLE_PORTF 2
     887        {0}
     888};
     889
     890#define HD_DISABLE_PORTF 1
    885891static struct hda_verb stac92hd71bxx_analog_core_init[] = {
    886892        /* start of config #1 */
     
    888894        /* connect port 0f to audio mixer */
    889895        { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
    890         /* unmute right and left channels for node 0x0f */
    891         { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    892896        /* start of config #2 */
    893897
    894898        /* set master volume and direct control */
    895899        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
    896         /* connect headphone jack to dac1 */
    897         { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
    898         /* unmute right and left channels for nodes 0x0a, 0xd */
     900        {0}
     901};
     902
     903static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
     904        /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
     905        { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    899906        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
    900907        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
     
    905912        /* set dac0mux for dac converter */
    906913        { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
     914        /* mute the master volume */
     915        { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
    907916        {0}
    908917};
     
    975984        }
    976985
    977 #define STAC_INPUT_SOURCE(cnt) \
    978         { \
    979                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
    980                 .name = "Input Source", \
    981                 .count = cnt, \
    982                 .info = stac92xx_mux_enum_info, \
    983                 .get = stac92xx_mux_enum_get, \
    984                 .put = stac92xx_mux_enum_put, \
    985         }
    986 
    987986#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
    988987        { \
     
    999998        HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
    1000999        HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
    1001         STAC_INPUT_SOURCE(1),
    10021000        HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
    10031001        HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
     
    10241022        HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
    10251023
    1026         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
    1027 
    10281024        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
    10291025        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
     
    10351031};
    10361032
     1033static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
     1034        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
     1035        {0}
     1036};
     1037
     1038static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
     1039        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
     1040        {0}
     1041};
     1042
     1043static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
     1044        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
     1045        {0}
     1046};
     1047
    10371048static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
    1038         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
    1039 
    10401049        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
    10411050        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
     
    10621071
    10631072static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
    1064         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
    1065 
    10661073        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
    10671074        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
     
    10951102        HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
    10961103
    1097         HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
    1098         HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
    1099 
    1100         HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
    1101         HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
    1102 
    1103         HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
    1104         HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
    1105 
    1106         HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
    1107         HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
     1104        HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
     1105        HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
     1106
     1107        HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
     1108        HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
     1109
     1110        HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
     1111        HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
     1112
     1113        HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
     1114        HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
    11081115
    11091116        /*
    1110         HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
    1111         HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
     1117        HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
     1118        HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
    11121119        */
    11131120        {0} /* end */
     
    11151122
    11161123static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
    1117         STAC_INPUT_SOURCE(2),
    1118         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
    1119 
    11201124        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
    11211125        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
     
    11431147};
    11441148
     1149static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
     1150        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
     1151};
     1152
    11451153static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
    1146         STAC_INPUT_SOURCE(2),
    1147         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
    1148 
    11491154        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
    11501155        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
     
    11561161
    11571162static struct snd_kcontrol_new stac925x_mixer[] = {
    1158         STAC_INPUT_SOURCE(1),
     1163        HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
     1164        HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
    11591165        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
    11601166        HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
     
    11631169
    11641170static struct snd_kcontrol_new stac9205_mixer[] = {
    1165         STAC_INPUT_SOURCE(2),
    1166         STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
    1167 
    11681171        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
    11691172        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
     
    11741177};
    11751178
     1179static struct snd_kcontrol_new stac9205_loopback[] = {
     1180        STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
     1181        {0}
     1182};
     1183
    11761184/* This needs to be generated dynamically based on sequence */
    11771185static struct snd_kcontrol_new stac922x_mixer[] = {
    1178         STAC_INPUT_SOURCE(2),
    11791186        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
    11801187        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
     
    11871194
    11881195static struct snd_kcontrol_new stac927x_mixer[] = {
    1189         STAC_INPUT_SOURCE(3),
    1190         STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
    1191 
    11921196        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
    11931197        HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
     
    11991203        HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
    12001204        {0} /* end */
     1205};
     1206
     1207static struct snd_kcontrol_new stac927x_loopback[] = {
     1208        STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
     1209        {0}
    12011210};
    12021211
     
    12261235        "Side Playback Volume",
    12271236        "Headphone Playback Volume",
    1228         "Headphone Playback Volume",
    12291237        "Speaker Playback Volume",
    1230         "External Speaker Playback Volume",
    1231         "Speaker2 Playback Volume",
    12321238        NULL
    12331239};
     
    12401246        "Side Playback Switch",
    12411247        "Headphone Playback Switch",
    1242         "Headphone Playback Switch",
    12431248        "Speaker Playback Switch",
    1244         "External Speaker Playback Switch",
    1245         "Speaker2 Playback Switch",
    12461249        "IEC958 Playback Switch",
    12471250        NULL
     
    12491252
    12501253static void stac92xx_free_kctls(struct hda_codec *codec);
     1254static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
    12511255
    12521256static int stac92xx_build_controls(struct hda_codec *codec)
    12531257{
    12541258        struct sigmatel_spec *spec = codec->spec;
     1259        struct auto_pin_cfg *cfg = &spec->autocfg;
     1260        hda_nid_t nid;
    12551261        int err;
    12561262        int i;
     
    12831289                }
    12841290                stac_smux_mixer.count = spec->num_smuxes;
    1285                 err = snd_ctl_add(codec->bus->card,
     1291                err = snd_hda_ctl_add(codec,
    12861292                                  snd_ctl_new1(&stac_smux_mixer, codec));
    12871293                if (err < 0)
     
    13101316                snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
    13111317                                        HDA_OUTPUT, vmaster_tlv);
     1318                /* correct volume offset */
     1319                vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
    13121320                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
    13131321                                          vmaster_tlv, slave_vols);
     
    13221330        }
    13231331
     1332        if (spec->aloopback_ctl &&
     1333            snd_hda_get_bool_hint(codec, "loopback") == 1) {
     1334                err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
     1335                if (err < 0)
     1336                        return err;
     1337        }
     1338
    13241339        stac92xx_free_kctls(codec); /* no longer needed */
     1340
     1341        /* create jack input elements */
     1342        if (spec->hp_detect) {
     1343                for (i = 0; i < cfg->hp_outs; i++) {
     1344                        int type = SND_JACK_HEADPHONE;
     1345                        nid = cfg->hp_pins[i];
     1346                        /* jack detection */
     1347                        if (cfg->hp_outs == i)
     1348                                type |= SND_JACK_LINEOUT;
     1349                        err = stac92xx_add_jack(codec, nid, type);
     1350                        if (err < 0)
     1351                                return err;
     1352                }
     1353        }
     1354        for (i = 0; i < cfg->line_outs; i++) {
     1355                err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
     1356                                        SND_JACK_LINEOUT);
     1357                if (err < 0)
     1358                        return err;
     1359        }
     1360        for (i = 0; i < AUTO_PIN_LAST; i++) {
     1361                nid = cfg->input_pins[i];
     1362                if (nid) {
     1363                        err = stac92xx_add_jack(codec, nid,
     1364                                                SND_JACK_MICROPHONE);
     1365                        if (err < 0)
     1366                                return err;
     1367                }
     1368        }
     1369
    13251370        return 0;       
    13261371}
     
    13311376};
    13321377
    1333 /*
     1378static unsigned int gateway9200_m4_pin_configs[8] = {
     1379        0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
     1380        0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
     1381};
     1382static unsigned int gateway9200_m4_2_pin_configs[8] = {
     1383        0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
     1384        0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
     1385};
     1386
     1387/*
    13341388    STAC 9200 pin configs for
    13351389    102801A8
     
    14611515        [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
    14621516        [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
     1517        [STAC_9200_M4] = gateway9200_m4_pin_configs,
     1518        [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
    14631519        [STAC_9200_PANASONIC] = ref9200_pin_configs,
    14641520};
    14651521
    14661522static const char *stac9200_models[STAC_9200_MODELS] = {
     1523        [STAC_AUTO] = "auto",
    14671524        [STAC_REF] = "ref",
    14681525        [STAC_9200_OQO] = "oqo",
     
    14771534        [STAC_9200_DELL_M26] = "dell-m26",
    14781535        [STAC_9200_DELL_M27] = "dell-m27",
    1479         [STAC_9200_GATEWAY] = "gateway",
     1536        [STAC_9200_M4] = "gateway-m4",
     1537        [STAC_9200_M4_2] = "gateway-m4-2",
    14801538        [STAC_9200_PANASONIC] = "panasonic",
    14811539};
     
    14841542        /* SigmaTel reference board */
    14851543        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
     1544                      "DFI LanParty", STAC_REF),
     1545        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
    14861546                      "DFI LanParty", STAC_REF),
    14871547        /* Dell laptops have BIOS problem */
     
    15471607        SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
    15481608        /* Gateway machines needs EAPD to be set on resume */
    1549         SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
    1550         SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
    1551                       STAC_9200_GATEWAY),
    1552         SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
    1553                       STAC_9200_GATEWAY),
     1609        SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
     1610        SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
     1611        SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
    15541612        /* OQO Mobile */
    15551613        SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
     
    15621620};
    15631621
    1564 static unsigned int stac925x_MA6_pin_configs[8] = {
    1565         0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
    1566         0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
    1567 };
    1568 
    1569 static unsigned int stac925x_PA6_pin_configs[8] = {
    1570         0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
    1571         0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
     1622static unsigned int stac925xM1_pin_configs[8] = {
     1623        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1624        0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
     1625};
     1626
     1627static unsigned int stac925xM1_2_pin_configs[8] = {
     1628        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1629        0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
     1630};
     1631
     1632static unsigned int stac925xM2_pin_configs[8] = {
     1633        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1634        0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
    15721635};
    15731636
    15741637static unsigned int stac925xM2_2_pin_configs[8] = {
    1575         0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
    1576         0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
     1638        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1639        0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
     1640};
     1641
     1642static unsigned int stac925xM3_pin_configs[8] = {
     1643        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1644        0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
     1645};
     1646
     1647static unsigned int stac925xM5_pin_configs[8] = {
     1648        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1649        0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
     1650};
     1651
     1652static unsigned int stac925xM6_pin_configs[8] = {
     1653        0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
     1654        0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
    15771655};
    15781656
    15791657static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
    15801658        [STAC_REF] = ref925x_pin_configs,
     1659        [STAC_M1] = stac925xM1_pin_configs,
     1660        [STAC_M1_2] = stac925xM1_2_pin_configs,
     1661        [STAC_M2] = stac925xM2_pin_configs,
    15811662        [STAC_M2_2] = stac925xM2_2_pin_configs,
    1582         [STAC_MA6] = stac925x_MA6_pin_configs,
    1583         [STAC_PA6] = stac925x_PA6_pin_configs,
     1663        [STAC_M3] = stac925xM3_pin_configs,
     1664        [STAC_M5] = stac925xM5_pin_configs,
     1665        [STAC_M6] = stac925xM6_pin_configs,
    15841666};
    15851667
    15861668static const char *stac925x_models[STAC_925x_MODELS] = {
     1669        [STAC_925x_AUTO] = "auto",
    15871670        [STAC_REF] = "ref",
     1671        [STAC_M1] = "m1",
     1672        [STAC_M1_2] = "m1-2",
     1673        [STAC_M2] = "m2",
    15881674        [STAC_M2_2] = "m2-2",
    1589         [STAC_MA6] = "m6",
    1590         [STAC_PA6] = "pa6",
     1675        [STAC_M3] = "m3",
     1676        [STAC_M5] = "m5",
     1677        [STAC_M6] = "m6",
     1678};
     1679
     1680static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
     1681        SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
     1682        SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
     1683        SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
     1684        SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
     1685        SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
     1686        /* Not sure about the brand name for those */
     1687        SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
     1688        SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
     1689        SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
     1690        SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
     1691        {0} /* terminator */
    15911692};
    15921693
     
    15941695        /* SigmaTel reference board */
    15951696        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
     1697        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
    15961698        SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
    1597         SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
    1598         SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
    1599         SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
    1600         SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
    1601         SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
     1699
     1700        /* Default table for unknown ID */
     1701        SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
     1702
    16021703        {0} /* terminator */
    16031704};
     
    16191720static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
    16201721        [STAC_92HD73XX_REF]     = ref92hd73xx_pin_configs,
    1621         [STAC_DELL_M6]  = dell_m6_pin_configs,
     1722        [STAC_DELL_M6_AMIC]     = dell_m6_pin_configs,
     1723        [STAC_DELL_M6_DMIC]     = dell_m6_pin_configs,
     1724        [STAC_DELL_M6_BOTH]     = dell_m6_pin_configs,
    16221725        [STAC_DELL_EQ]  = dell_m6_pin_configs,
    16231726};
    16241727
    16251728static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
     1729        [STAC_92HD73XX_AUTO] = "auto",
     1730        [STAC_92HD73XX_NO_JD] = "no-jd",
    16261731        [STAC_92HD73XX_REF] = "ref",
    1627         [STAC_DELL_M6] = "dell-m6",
     1732        [STAC_DELL_M6_AMIC] = "dell-m6-amic",
     1733        [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
     1734        [STAC_DELL_M6_BOTH] = "dell-m6",
    16281735        [STAC_DELL_EQ] = "dell-eq",
    16291736};
     
    16331740        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    16341741                                "DFI LanParty", STAC_92HD73XX_REF),
     1742        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
     1743                                "DFI LanParty", STAC_92HD73XX_REF),
    16351744        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
    1636                                 "unknown Dell", STAC_DELL_M6),
     1745                                "Dell Studio 1535", STAC_DELL_M6_DMIC),
    16371746        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
    1638                                 "unknown Dell", STAC_DELL_M6),
     1747                                "unknown Dell", STAC_DELL_M6_DMIC),
    16391748        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
    1640                                 "unknown Dell", STAC_DELL_M6),
     1749                                "unknown Dell", STAC_DELL_M6_BOTH),
    16411750        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
    1642                                 "unknown Dell", STAC_DELL_M6),
     1751                                "unknown Dell", STAC_DELL_M6_BOTH),
    16431752        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
    1644                                 "unknown Dell", STAC_DELL_M6),
     1753                                "unknown Dell", STAC_DELL_M6_AMIC),
    16451754        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
    1646                                 "unknown Dell", STAC_DELL_M6),
     1755                                "unknown Dell", STAC_DELL_M6_AMIC),
    16471756        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
    1648                                 "unknown Dell", STAC_DELL_M6),
     1757                                "unknown Dell", STAC_DELL_M6_DMIC),
     1758        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
     1759                                "unknown Dell", STAC_DELL_M6_DMIC),
     1760        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
     1761                                "Dell Studio 1537", STAC_DELL_M6_DMIC),
     1762        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
     1763                                "Dell Studio 17", STAC_DELL_M6_DMIC),
    16491764        {0} /* terminator */
    16501765};
    16511766
    1652 static unsigned int ref92hd83xxx_pin_configs[14] = {
     1767static unsigned int ref92hd83xxx_pin_configs[10] = {
    16531768        0x02214030, 0x02211010, 0x02a19020, 0x02170130,
    16541769        0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
    1655         0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
    16561770        0x01451160, 0x98560170,
     1771};
     1772
     1773static unsigned int dell_s14_pin_configs[10] = {
     1774        0x02214030, 0x02211010, 0x02a19020, 0x01014050,
     1775        0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
     1776        0x40f000f0, 0x40f000f0,
    16571777};
    16581778
    16591779static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
    16601780        [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
     1781        [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
     1782        [STAC_DELL_S14] = dell_s14_pin_configs,
    16611783};
    16621784
    16631785static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
     1786        [STAC_92HD83XXX_AUTO] = "auto",
    16641787        [STAC_92HD83XXX_REF] = "ref",
     1788        [STAC_92HD83XXX_PWR_REF] = "mic-ref",
     1789        [STAC_DELL_S14] = "dell-s14",
    16651790};
    16661791
     
    16681793        /* SigmaTel reference board */
    16691794        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    1670                       "DFI LanParty", STAC_92HD71BXX_REF),
    1671 };
    1672 
    1673 static unsigned int ref92hd71bxx_pin_configs[11] = {
     1795                      "DFI LanParty", STAC_92HD83XXX_REF),
     1796        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
     1797                      "DFI LanParty", STAC_92HD83XXX_REF),
     1798        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
     1799                      "unknown Dell", STAC_DELL_S14),
     1800        {0} /* terminator */
     1801};
     1802
     1803static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
    16741804        0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
    16751805        0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
    1676         0x90a000f0, 0x01452050, 0x01452050,
    1677 };
    1678 
    1679 static unsigned int dell_m4_1_pin_configs[11] = {
     1806        0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
     1807        0x00000000
     1808};
     1809
     1810static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
    16801811        0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
    16811812        0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
    1682         0x40f000f0, 0x4f0000f0, 0x4f0000f0,
    1683 };
    1684 
    1685 static unsigned int dell_m4_2_pin_configs[11] = {
     1813        0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
     1814        0x00000000
     1815};
     1816
     1817static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
    16861818        0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
    16871819        0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
    1688         0x40f000f0, 0x044413b0, 0x044413b0,
     1820        0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
     1821        0x00000000
     1822};
     1823
     1824static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
     1825        0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
     1826        0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
     1827        0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
     1828        0x00000000
    16891829};
    16901830
     
    16931833        [STAC_DELL_M4_1]        = dell_m4_1_pin_configs,
    16941834        [STAC_DELL_M4_2]        = dell_m4_2_pin_configs,
     1835        [STAC_DELL_M4_3]        = dell_m4_3_pin_configs,
    16951836        [STAC_HP_M4]            = NULL,
     1837        [STAC_HP_DV5]           = NULL,
     1838        [STAC_HP_HDX]           = NULL,
    16961839};
    16971840
    16981841static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
     1842        [STAC_92HD71BXX_AUTO] = "auto",
    16991843        [STAC_92HD71BXX_REF] = "ref",
    17001844        [STAC_DELL_M4_1] = "dell-m4-1",
    17011845        [STAC_DELL_M4_2] = "dell-m4-2",
     1846        [STAC_DELL_M4_3] = "dell-m4-3",
    17021847        [STAC_HP_M4] = "hp-m4",
     1848        [STAC_HP_DV5] = "hp-dv5",
     1849        [STAC_HP_HDX] = "hp-hdx",
    17031850};
    17041851
     
    17071854        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    17081855                      "DFI LanParty", STAC_92HD71BXX_REF),
     1856        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
     1857                      "DFI LanParty", STAC_92HD71BXX_REF),
     1858        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
     1859                      "HP", STAC_HP_DV5),
     1860        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
     1861                      "HP dv4-7", STAC_HP_DV5),
     1862        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
     1863                      "HP dv4-7", STAC_HP_DV5),
     1864        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
     1865                      "HP HDX", STAC_HP_HDX),  /* HDX18 */
    17091866        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
    1710                                 "unknown HP", STAC_HP_M4),
     1867                      "HP mini 1000", STAC_HP_M4),
     1868        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
     1869                      "HP HDX", STAC_HP_HDX),  /* HDX16 */
    17111870        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
    17121871                                "unknown Dell", STAC_DELL_M4_1),
     
    17311890        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
    17321891                                "unknown Dell", STAC_DELL_M4_2),
     1892        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
     1893                                "unknown Dell", STAC_DELL_M4_3),
    17331894        {0} /* terminator */
    17341895};
     
    18582019
    18592020static const char *stac922x_models[STAC_922X_MODELS] = {
     2021        [STAC_922X_AUTO] = "auto",
    18602022        [STAC_D945_REF] = "ref",
    18612023        [STAC_D945GTP5] = "5stack",
     
    18842046        /* SigmaTel reference board */
    18852047        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
     2048                      "DFI LanParty", STAC_D945_REF),
     2049        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
    18862050                      "DFI LanParty", STAC_D945_REF),
    18872051        /* Intel 945G based systems */
     
    19382102        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
    19392103                      "Intel D945P", STAC_D945GTP5),
     2104        /* other intel */
     2105        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
     2106                      "Intel D945", STAC_D945_REF),
    19402107        /* other systems  */
    19412108        /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
     
    19622129                      "Dell XPS M1210", STAC_922X_DELL_M82),
    19632130        /* ECS/PC Chips boards */
    1964         SND_PCI_QUIRK(0x1019, 0x2144,
    1965                       "ECS/PC chips", STAC_ECS_202),
    1966         SND_PCI_QUIRK(0x1019, 0x2608,
    1967                       "ECS/PC chips", STAC_ECS_202),
    1968         SND_PCI_QUIRK(0x1019, 0x2633,
    1969                       "ECS/PC chips P17G/1333", STAC_ECS_202),
    1970         SND_PCI_QUIRK(0x1019, 0x2811,
    1971                       "ECS/PC chips", STAC_ECS_202),
    1972         SND_PCI_QUIRK(0x1019, 0x2812,
    1973                       "ECS/PC chips", STAC_ECS_202),
    1974         SND_PCI_QUIRK(0x1019, 0x2813,
    1975                       "ECS/PC chips", STAC_ECS_202),
    1976         SND_PCI_QUIRK(0x1019, 0x2814,
    1977                       "ECS/PC chips", STAC_ECS_202),
    1978         SND_PCI_QUIRK(0x1019, 0x2815,
    1979                       "ECS/PC chips", STAC_ECS_202),
    1980         SND_PCI_QUIRK(0x1019, 0x2816,
    1981                       "ECS/PC chips", STAC_ECS_202),
    1982         SND_PCI_QUIRK(0x1019, 0x2817,
    1983                       "ECS/PC chips", STAC_ECS_202),
    1984         SND_PCI_QUIRK(0x1019, 0x2818,
    1985                       "ECS/PC chips", STAC_ECS_202),
    1986         SND_PCI_QUIRK(0x1019, 0x2819,
    1987                       "ECS/PC chips", STAC_ECS_202),
    1988         SND_PCI_QUIRK(0x1019, 0x2820,
     2131        SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
    19892132                      "ECS/PC chips", STAC_ECS_202),
    19902133        {0} /* terminator */
     
    20202163
    20212164static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
     2165        [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
    20222166        [STAC_D965_REF]  = ref927x_pin_configs,
    20232167        [STAC_D965_3ST]  = d965_3st_pin_configs,
     
    20282172
    20292173static const char *stac927x_models[STAC_927X_MODELS] = {
     2174        [STAC_927X_AUTO]        = "auto",
     2175        [STAC_D965_REF_NO_JD]   = "ref-no-jd",
    20302176        [STAC_D965_REF]         = "ref",
    20312177        [STAC_D965_3ST]         = "3stack",
     
    20392185        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    20402186                      "DFI LanParty", STAC_D965_REF),
     2187        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
     2188                      "DFI LanParty", STAC_D965_REF),
    20412189         /* Intel 946 based systems */
    20422190        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
    20432191        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
    20442192        /* 965 based 3 stack systems */
    2045         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
    2046         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
    2047         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
    2048         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
    2049         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
    2050         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
    2051         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
    2052         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
    2053         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
    2054         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
    2055         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
    2056         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
    2057         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
    2058         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
    2059         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
    2060         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
     2193        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
     2194                           "Intel D965", STAC_D965_3ST),
     2195        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
     2196                           "Intel D965", STAC_D965_3ST),
    20612197        /* Dell 3 stack systems */
    20622198        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
     
    20742210        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
    20752211        /* 965 based 5 stack systems */
    2076         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
    2077         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
    2078         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
    2079         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
    2080         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
    2081         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
    2082         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
    2083         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
    2084         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
     2212        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
     2213                           "Intel D965", STAC_D965_5ST),
     2214        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
     2215                           "Intel D965", STAC_D965_5ST),
    20852216        {0} /* terminator */
    20862217};
     
    21352266        [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
    21362267        [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
     2268        [STAC_9205_EAPD] = NULL,
    21372269};
    21382270
    21392271static const char *stac9205_models[STAC_9205_MODELS] = {
     2272        [STAC_9205_AUTO] = "auto",
    21402273        [STAC_9205_REF] = "ref",
    21412274        [STAC_9205_DELL_M42] = "dell-m42",
    21422275        [STAC_9205_DELL_M43] = "dell-m43",
    21432276        [STAC_9205_DELL_M44] = "dell-m44",
     2277        [STAC_9205_EAPD] = "eapd",
    21442278};
    21452279
     
    21482282        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
    21492283                      "DFI LanParty", STAC_9205_REF),
     2284        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
     2285                      "DFI LanParty", STAC_9205_REF),
     2286        /* Dell */
    21502287        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
    21512288                      "unknown Dell", STAC_9205_DELL_M42),
     
    21782315        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
    21792316                      "Dell Vostro 1500", STAC_9205_DELL_M42),
     2317        /* Gateway */
     2318        SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
    21802319        {0} /* terminator */
    21812320};
    21822321
    2183 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
     2322static void stac92xx_set_config_regs(struct hda_codec *codec,
     2323                                     unsigned int *pincfgs)
    21842324{
    21852325        int i;
    21862326        struct sigmatel_spec *spec = codec->spec;
    2187        
    2188         if (! spec->bios_pin_configs) {
    2189                 spec->bios_pin_configs = kcalloc(spec->num_pins,
    2190                                                  sizeof(*spec->bios_pin_configs), GFP_KERNEL);
    2191                 if (! spec->bios_pin_configs)
    2192                         return -ENOMEM;
    2193         }
    2194        
    2195         for (i = 0; i < spec->num_pins; i++) {
    2196                 hda_nid_t nid = spec->pin_nids[i];
    2197                 unsigned int pin_cfg;
    2198                
    2199                 pin_cfg = snd_hda_codec_read(codec, nid, 0,
    2200                         AC_VERB_GET_CONFIG_DEFAULT, 0x00);     
    2201                 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
    2202                                         nid, pin_cfg);
    2203                 spec->bios_pin_configs[i] = pin_cfg;
    2204         }
    2205        
    2206         return 0;
    2207 }
    2208 
    2209 static void stac92xx_set_config_reg(struct hda_codec *codec,
    2210                                     hda_nid_t pin_nid, unsigned int pin_config)
    2211 {
    2212         int i;
    2213         snd_hda_codec_write(codec, pin_nid, 0,
    2214                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
    2215                             pin_config & 0x000000ff);
    2216         snd_hda_codec_write(codec, pin_nid, 0,
    2217                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
    2218                             (pin_config & 0x0000ff00) >> 8);
    2219         snd_hda_codec_write(codec, pin_nid, 0,
    2220                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
    2221                             (pin_config & 0x00ff0000) >> 16);
    2222         snd_hda_codec_write(codec, pin_nid, 0,
    2223                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
    2224                             pin_config >> 24);
    2225         i = snd_hda_codec_read(codec, pin_nid, 0,
    2226                                AC_VERB_GET_CONFIG_DEFAULT,
    2227                                0x00);   
    2228         snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
    2229                     pin_nid, i);
    2230 }
    2231 
    2232 static void stac92xx_set_config_regs(struct hda_codec *codec)
    2233 {
    2234         int i;
    2235         struct sigmatel_spec *spec = codec->spec;
    2236 
    2237         if (!spec->pin_configs)
    2238                 return;
     2327
     2328        if (!pincfgs)
     2329                return;
    22392330
    22402331        for (i = 0; i < spec->num_pins; i++)
    2241                 stac92xx_set_config_reg(codec, spec->pin_nids[i],
    2242                                         spec->pin_configs[i]);
     2332                if (spec->pin_nids[i] && pincfgs[i])
     2333                        snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
     2334                                                 pincfgs[i]);
    22432335}
    22442336
     
    23032395        return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
    23042396                                             stream_tag, format, substream);
     2397}
     2398
     2399static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
     2400                                        struct hda_codec *codec,
     2401                                        struct snd_pcm_substream *substream)
     2402{
     2403        struct sigmatel_spec *spec = codec->spec;
     2404        return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
    23052405}
    23062406
     
    23202420        if (spec->powerdown_adcs) {
    23212421                msleep(40);
    2322                 snd_hda_codec_write_cache(codec, nid, 0,
     2422                snd_hda_codec_write(codec, nid, 0,
    23232423                        AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
    23242424        }
     
    23362436        snd_hda_codec_cleanup_stream(codec, nid);
    23372437        if (spec->powerdown_adcs)
    2338                 snd_hda_codec_write_cache(codec, nid, 0,
     2438                snd_hda_codec_write(codec, nid, 0,
    23392439                        AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
    23402440        return 0;
     
    23492449                .open = stac92xx_dig_playback_pcm_open,
    23502450                .close = stac92xx_dig_playback_pcm_close,
    2351                 .prepare = stac92xx_dig_playback_pcm_prepare
     2451                .prepare = stac92xx_dig_playback_pcm_prepare,
     2452                .cleanup = stac92xx_dig_playback_pcm_cleanup
    23522453        },
    23532454};
     
    24042505        info->name = "STAC92xx Analog";
    24052506        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
     2507        info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
     2508                spec->multiout.dac_nids[0];
    24062509        info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
    24072510        info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
     
    24192522                info++;
    24202523                info->name = "STAC92xx Digital";
    2421                 info->pcm_type = HDA_PCM_TYPE_SPDIF;
     2524                info->pcm_type = spec->autocfg.dig_out_type[0];
    24222525                if (spec->multiout.dig_out_nid) {
    24232526                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
     
    24352538static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
    24362539{
    2437         unsigned int pincap = snd_hda_param_read(codec, nid,
    2438                                                  AC_PAR_PIN_CAP);
     2540        unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
    24392541        pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
    24402542        if (pincap & AC_PINCAP_VREF_100)
     
    24642566        struct sigmatel_spec *spec = codec->spec;
    24652567
    2466         ucontrol->value.integer.value[0] = spec->hp_switch;
     2568        ucontrol->value.integer.value[0] = !!spec->hp_switch;
    24672569        return 0;
    24682570}
     2571
     2572static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
     2573                                   unsigned char type);
    24692574
    24702575static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
     
    24732578        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    24742579        struct sigmatel_spec *spec = codec->spec;
    2475         struct auto_pin_cfg *cfg = &spec->autocfg;
    2476         int nid = cfg->hp_pins[cfg->hp_outs - 1];
    2477 
    2478         spec->hp_switch = ucontrol->value.integer.value[0];
     2580        int nid = kcontrol->private_value;
     2581 
     2582        spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
    24792583
    24802584        /* check to be sure that the ports are upto date with
    24812585         * switch changes
    24822586         */
    2483         codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
     2587        stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
    24842588
    24852589        return 1;
     
    25212625         */
    25222626        if (spec->hp_detect)
    2523                 codec->patch_ops.unsol_event(codec,
    2524                         (STAC_HP_EVENT | nid) << 26);
     2627                stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
    25252628
    25262629        return 1;
     
    26102713
    26112714/* add dynamic controls */
    2612 static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
    2613                 int idx, const char *name, unsigned long val)
     2715static struct snd_kcontrol_new *
     2716stac_control_new(struct sigmatel_spec *spec,
     2717                 struct snd_kcontrol_new *ktemp,
     2718                 const char *name)
    26142719{
    26152720        struct snd_kcontrol_new *knew;
     
    26182723        knew = snd_array_new(&spec->kctls);
    26192724        if (!knew)
     2725                return NULL;
     2726        *knew = *ktemp;
     2727        knew->name = kstrdup(name, GFP_KERNEL);
     2728        if (!knew->name) {
     2729                /* roolback */
     2730                memset(knew, 0, sizeof(*knew));
     2731                spec->kctls.alloced--;
     2732                return NULL;
     2733        }
     2734        return knew;
     2735}
     2736
     2737static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
     2738                                     struct snd_kcontrol_new *ktemp,
     2739                                     int idx, const char *name,
     2740                                     unsigned long val)
     2741{
     2742        struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
     2743        if (!knew)
    26202744                return -ENOMEM;
    2621         *knew = stac92xx_control_templates[type];
    26222745        knew->index = idx;
    2623         knew->name = kstrdup(name, GFP_KERNEL);
    2624         if (! knew->name)
    2625                 return -ENOMEM;
    26262746        knew->private_value = val;
    26272747        return 0;
    26282748}
    26292749
     2750static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
     2751                                           int type, int idx, const char *name,
     2752                                           unsigned long val)
     2753{
     2754        return stac92xx_add_control_temp(spec,
     2755                                         &stac92xx_control_templates[type],
     2756                                         idx, name, val);
     2757}
     2758
    26302759
    26312760/* add dynamic controls */
    2632 static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
    2633                 const char *name, unsigned long val)
     2761static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
     2762                                       const char *name, unsigned long val)
    26342763{
    26352764        return stac92xx_add_control_idx(spec, type, 0, name, val);
    26362765}
    26372766
    2638 /* flag inputs as additional dynamic lineouts */
    2639 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
    2640 {
    2641         struct sigmatel_spec *spec = codec->spec;
    2642         unsigned int wcaps, wtype;
    2643         int i, num_dacs = 0;
    2644        
    2645         /* use the wcaps cache to count all DACs available for line-outs */
    2646         for (i = 0; i < codec->num_nodes; i++) {
    2647                 wcaps = codec->wcaps[i];
    2648                 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
    2649 
    2650                 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
    2651                         num_dacs++;
    2652         }
    2653 
    2654         snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
    2655        
    2656         switch (cfg->line_outs) {
    2657         case 3:
    2658                 /* add line-in as side */
    2659                 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
    2660                         cfg->line_out_pins[cfg->line_outs] =
    2661                                 cfg->input_pins[AUTO_PIN_LINE];
    2662                         spec->line_switch = 1;
    2663                         cfg->line_outs++;
     2767static struct snd_kcontrol_new stac_input_src_temp = {
     2768        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     2769        .name = "Input Source",
     2770        .info = stac92xx_mux_enum_info,
     2771        .get = stac92xx_mux_enum_get,
     2772        .put = stac92xx_mux_enum_put,
     2773};
     2774
     2775static int stac92xx_add_input_source(struct sigmatel_spec *spec)
     2776{
     2777        struct snd_kcontrol_new *knew;
     2778        struct hda_input_mux *imux = &spec->private_imux;
     2779
     2780        if (!spec->num_adcs || imux->num_items <= 1)
     2781                return 0; /* no need for input source control */
     2782        knew = stac_control_new(spec, &stac_input_src_temp,
     2783                                stac_input_src_temp.name);
     2784        if (!knew)
     2785                return -ENOMEM;
     2786        knew->count = spec->num_adcs;
     2787        return 0;
     2788}
     2789
     2790/* check whether the line-input can be used as line-out */
     2791static hda_nid_t check_line_out_switch(struct hda_codec *codec)
     2792{
     2793        struct sigmatel_spec *spec = codec->spec;
     2794        struct auto_pin_cfg *cfg = &spec->autocfg;
     2795        hda_nid_t nid;
     2796        unsigned int pincap;
     2797
     2798        if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
     2799                return 0;
     2800        nid = cfg->input_pins[AUTO_PIN_LINE];
     2801        pincap = snd_hda_query_pin_caps(codec, nid);
     2802        if (pincap & AC_PINCAP_OUT)
     2803                return nid;
     2804        return 0;
     2805}
     2806
     2807/* check whether the mic-input can be used as line-out */
     2808static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
     2809{
     2810        struct sigmatel_spec *spec = codec->spec;
     2811        struct auto_pin_cfg *cfg = &spec->autocfg;
     2812        unsigned int def_conf, pincap;
     2813        unsigned int mic_pin;
     2814
     2815        if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
     2816                return 0;
     2817        mic_pin = AUTO_PIN_MIC;
     2818        for (;;) {
     2819                hda_nid_t nid = cfg->input_pins[mic_pin];
     2820                def_conf = snd_hda_codec_get_pincfg(codec, nid);
     2821                /* some laptops have an internal analog microphone
     2822                 * which can't be used as a output */
     2823                if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
     2824                        pincap = snd_hda_query_pin_caps(codec, nid);
     2825                        if (pincap & AC_PINCAP_OUT)
     2826                                return nid;
    26642827                }
    2665                 break;
    2666         case 2:
    2667                 /* add line-in as clfe and mic as side */
    2668                 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
    2669                         cfg->line_out_pins[cfg->line_outs] =
    2670                                 cfg->input_pins[AUTO_PIN_LINE];
    2671                         spec->line_switch = 1;
    2672                         cfg->line_outs++;
    2673                 }
    2674                 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
    2675                         cfg->line_out_pins[cfg->line_outs] =
    2676                                 cfg->input_pins[AUTO_PIN_MIC];
    2677                         spec->mic_switch = 1;
    2678                         cfg->line_outs++;
    2679                 }
    2680                 break;
    2681         case 1:
    2682                 /* add line-in as surr and mic as clfe */
    2683                 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
    2684                         cfg->line_out_pins[cfg->line_outs] =
    2685                                 cfg->input_pins[AUTO_PIN_LINE];
    2686                         spec->line_switch = 1;
    2687                         cfg->line_outs++;
    2688                 }
    2689                 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
    2690                         cfg->line_out_pins[cfg->line_outs] =
    2691                                 cfg->input_pins[AUTO_PIN_MIC];
    2692                         spec->mic_switch = 1;
    2693                         cfg->line_outs++;
    2694                 }
    2695                 break;
    2696         }
    2697 
     2828                if (mic_pin == AUTO_PIN_MIC)
     2829                        mic_pin = AUTO_PIN_FRONT_MIC;
     2830                else
     2831                        break;
     2832        }
    26982833        return 0;
    26992834}
    2700 
    27012835
    27022836static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
     
    27112845        return 0;
    27122846}
     2847
     2848static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
     2849{
     2850        int i;
     2851        if (is_in_dac_nids(spec, nid))
     2852                return 1;
     2853        for (i = 0; i < spec->autocfg.hp_outs; i++)
     2854                if (spec->hp_dacs[i] == nid)
     2855                        return 1;
     2856        for (i = 0; i < spec->autocfg.speaker_outs; i++)
     2857                if (spec->speaker_dacs[i] == nid)
     2858                        return 1;
     2859        return 0;
     2860}
     2861
     2862static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
     2863{
     2864        struct sigmatel_spec *spec = codec->spec;
     2865        int j, conn_len;
     2866        hda_nid_t conn[HDA_MAX_CONNECTIONS];
     2867        unsigned int wcaps, wtype;
     2868
     2869        conn_len = snd_hda_get_connections(codec, nid, conn,
     2870                                           HDA_MAX_CONNECTIONS);
     2871        for (j = 0; j < conn_len; j++) {
     2872                wcaps = get_wcaps(codec, conn[j]);
     2873                wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
     2874                /* we check only analog outputs */
     2875                if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
     2876                        continue;
     2877                /* if this route has a free DAC, assign it */
     2878                if (!check_all_dac_nids(spec, conn[j])) {
     2879                        if (conn_len > 1) {
     2880                                /* select this DAC in the pin's input mux */
     2881                                snd_hda_codec_write_cache(codec, nid, 0,
     2882                                                  AC_VERB_SET_CONNECT_SEL, j);
     2883                        }
     2884                        return conn[j];
     2885                }
     2886        }
     2887        /* if all DACs are already assigned, connect to the primary DAC */
     2888        if (conn_len > 1) {
     2889                for (j = 0; j < conn_len; j++) {
     2890                        if (conn[j] == spec->multiout.dac_nids[0]) {
     2891                                snd_hda_codec_write_cache(codec, nid, 0,
     2892                                                  AC_VERB_SET_CONNECT_SEL, j);
     2893                                break;
     2894                        }
     2895                }
     2896        }
     2897        return 0;
     2898}
     2899
     2900static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
     2901static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
    27132902
    27142903/*
     
    27192908 * and 9202/925x. For those, dac_nids[] must be hard-coded.
    27202909 */
    2721 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
    2722                                        struct auto_pin_cfg *cfg)
    2723 {
    2724         struct sigmatel_spec *spec = codec->spec;
    2725         int i, j, conn_len = 0;
    2726         hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
    2727         unsigned int wcaps, wtype;
     2910static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
     2911{
     2912        struct sigmatel_spec *spec = codec->spec;
     2913        struct auto_pin_cfg *cfg = &spec->autocfg;
     2914        int i;
     2915        hda_nid_t nid, dac;
    27282916       
    27292917        for (i = 0; i < cfg->line_outs; i++) {
    27302918                nid = cfg->line_out_pins[i];
    2731                 conn_len = snd_hda_get_connections(codec, nid, conn,
    2732                                                    HDA_MAX_CONNECTIONS);
    2733                 for (j = 0; j < conn_len; j++) {
    2734                         wcaps = snd_hda_param_read(codec, conn[j],
    2735                                                    AC_PAR_AUDIO_WIDGET_CAP);
    2736                         wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
    2737                         if (wtype != AC_WID_AUD_OUT ||
    2738                             (wcaps & AC_WCAP_DIGITAL))
    2739                                 continue;
    2740                         /* conn[j] is a DAC routed to this line-out */
    2741                         if (!is_in_dac_nids(spec, conn[j]))
    2742                                 break;
    2743                 }
    2744 
    2745                 if (j == conn_len) {
     2919                dac = get_unassigned_dac(codec, nid);
     2920                if (!dac) {
    27462921                        if (spec->multiout.num_dacs > 0) {
    27472922                                /* we have already working output pins,
     
    27572932                        return -ENODEV;
    27582933                }
    2759 
    2760                 spec->multiout.dac_nids[i] = conn[j];
    2761                 spec->multiout.num_dacs++;
    2762                 if (conn_len > 1) {
    2763                         /* select this DAC in the pin's input mux */
    2764                         snd_hda_codec_write_cache(codec, nid, 0,
    2765                                                   AC_VERB_SET_CONNECT_SEL, j);
    2766 
     2934                add_spec_dacs(spec, dac);
     2935        }
     2936
     2937        for (i = 0; i < cfg->hp_outs; i++) {
     2938                nid = cfg->hp_pins[i];
     2939                dac = get_unassigned_dac(codec, nid);
     2940                if (dac) {
     2941                        if (!spec->multiout.hp_nid)
     2942                                spec->multiout.hp_nid = dac;
     2943                        else
     2944                                add_spec_extra_dacs(spec, dac);
    27672945                }
    2768         }
    2769 
    2770         snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
     2946                spec->hp_dacs[i] = dac;
     2947        }
     2948
     2949        for (i = 0; i < cfg->speaker_outs; i++) {
     2950                nid = cfg->speaker_pins[i];
     2951                dac = get_unassigned_dac(codec, nid);
     2952                if (dac)
     2953                        add_spec_extra_dacs(spec, dac);
     2954                spec->speaker_dacs[i] = dac;
     2955        }
     2956
     2957        /* add line-in as output */
     2958        nid = check_line_out_switch(codec);
     2959        if (nid) {
     2960                dac = get_unassigned_dac(codec, nid);
     2961                if (dac) {
     2962                        snd_printdd("STAC: Add line-in 0x%x as output %d\n",
     2963                                    nid, cfg->line_outs);
     2964                        cfg->line_out_pins[cfg->line_outs] = nid;
     2965                        cfg->line_outs++;
     2966                        spec->line_switch = nid;
     2967                        add_spec_dacs(spec, dac);
     2968                }
     2969        }
     2970        /* add mic as output */
     2971        nid = check_mic_out_switch(codec);
     2972        if (nid) {
     2973                dac = get_unassigned_dac(codec, nid);
     2974                if (dac) {
     2975                        snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
     2976                                    nid, cfg->line_outs);
     2977                        cfg->line_out_pins[cfg->line_outs] = nid;
     2978                        cfg->line_outs++;
     2979                        spec->mic_switch = nid;
     2980                        add_spec_dacs(spec, dac);
     2981                }
     2982        }
     2983
     2984        snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
    27712985                   spec->multiout.num_dacs,
    27722986                   spec->multiout.dac_nids[0],
     
    27752989                   spec->multiout.dac_nids[3],
    27762990                   spec->multiout.dac_nids[4]);
     2991
    27772992        return 0;
    27782993}
    27792994
    27802995/* create volume control/switch for the given prefx type */
    2781 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
    2782 {
     2996static int create_controls_idx(struct hda_codec *codec, const char *pfx,
     2997                               int idx, hda_nid_t nid, int chs)
     2998{
     2999        struct sigmatel_spec *spec = codec->spec;
    27833000        char name[32];
    27843001        int err;
    27853002
     3003        if (!spec->check_volume_offset) {
     3004                unsigned int caps, step, nums, db_scale;
     3005                caps = query_amp_caps(codec, nid, HDA_OUTPUT);
     3006                step = (caps & AC_AMPCAP_STEP_SIZE) >>
     3007                        AC_AMPCAP_STEP_SIZE_SHIFT;
     3008                step = (step + 1) * 25; /* in .01dB unit */
     3009                nums = (caps & AC_AMPCAP_NUM_STEPS) >>
     3010                        AC_AMPCAP_NUM_STEPS_SHIFT;
     3011                db_scale = nums * step;
     3012                /* if dB scale is over -64dB, and finer enough,
     3013                 * let's reduce it to half
     3014                 */
     3015                if (db_scale > 6400 && nums >= 0x1f)
     3016                        spec->volume_offset = nums / 2;
     3017                spec->check_volume_offset = 1;
     3018        }
     3019
    27863020        sprintf(name, "%s Playback Volume", pfx);
    2787         err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
    2788                                    HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
     3021        err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
     3022                HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
     3023                                        spec->volume_offset));
    27893024        if (err < 0)
    27903025                return err;
    27913026        sprintf(name, "%s Playback Switch", pfx);
    2792         err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
     3027        err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
    27933028                                   HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
    27943029        if (err < 0)
     
    27973032}
    27983033
     3034#define create_controls(codec, pfx, nid, chs) \
     3035        create_controls_idx(codec, pfx, 0, nid, chs)
     3036
    27993037static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
    28003038{
    2801         if (!spec->multiout.hp_nid)
    2802                 spec->multiout.hp_nid = nid;
    2803         else if (spec->multiout.num_dacs > 4) {
     3039        if (spec->multiout.num_dacs > 4) {
    28043040                printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
    28053041                return 1;
     
    28113047}
    28123048
    2813 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
    2814 {
    2815         if (is_in_dac_nids(spec, nid))
    2816                 return 1;
    2817         if (spec->multiout.hp_nid == nid)
    2818                 return 1;
    2819         return 0;
    2820 }
    2821 
    2822 /* add playback controls from the parsed DAC table */
    2823 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
    2824                                                const struct auto_pin_cfg *cfg)
    2825 {
     3049static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
     3050{
     3051        int i;
     3052        for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
     3053                if (!spec->multiout.extra_out_nid[i]) {
     3054                        spec->multiout.extra_out_nid[i] = nid;
     3055                        return 0;
     3056                }
     3057        }
     3058        printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
     3059        return 1;
     3060}
     3061
     3062/* Create output controls
     3063 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
     3064 */
     3065static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
     3066                                 const hda_nid_t *pins,
     3067                                 const hda_nid_t *dac_nids,
     3068                                 int type)
     3069{
     3070        struct sigmatel_spec *spec = codec->spec;
    28263071        static const char *chname[4] = {
    28273072                "Front", "Surround", NULL /*CLFE*/, "Side"
    28283073        };
    2829         hda_nid_t nid = 0;
     3074        hda_nid_t nid;
    28303075        int i, err;
    2831 
    2832         struct sigmatel_spec *spec = codec->spec;
    2833         unsigned int wid_caps, pincap;
    2834 
    2835 
    2836         for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
    2837                 if (!spec->multiout.dac_nids[i])
     3076        unsigned int wid_caps;
     3077
     3078        for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
     3079                if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
     3080                        wid_caps = get_wcaps(codec, pins[i]);
     3081                        if (wid_caps & AC_WCAP_UNSOL_CAP)
     3082                                spec->hp_detect = 1;
     3083                }
     3084                nid = dac_nids[i];
     3085                if (!nid)
    28383086                        continue;
    2839 
    2840                 nid = spec->multiout.dac_nids[i];
    2841 
    2842                 if (i == 2) {
     3087                if (type != AUTO_PIN_HP_OUT && i == 2) {
    28433088                        /* Center/LFE */
    2844                         err = create_controls(spec, "Center", nid, 1);
     3089                        err = create_controls(codec, "Center", nid, 1);
    28453090                        if (err < 0)
    28463091                                return err;
    2847                         err = create_controls(spec, "LFE", nid, 2);
     3092                        err = create_controls(codec, "LFE", nid, 2);
    28483093                        if (err < 0)
    28493094                                return err;
     
    28613106
    28623107                } else {
    2863                         err = create_controls(spec, chname[i], nid, 3);
     3108                        const char *name;
     3109                        int idx;
     3110                        switch (type) {
     3111                        case AUTO_PIN_HP_OUT:
     3112                                name = "Headphone";
     3113                                idx = i;
     3114                                break;
     3115                        case AUTO_PIN_SPEAKER_OUT:
     3116                                name = "Speaker";
     3117                                idx = i;
     3118                                break;
     3119                        default:
     3120                                name = chname[i];
     3121                                idx = 0;
     3122                                break;
     3123                        }
     3124                        err = create_controls_idx(codec, name, idx, nid, 3);
    28643125                        if (err < 0)
    28653126                                return err;
    28663127                }
    28673128        }
    2868 
    2869         if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
    2870                         cfg->hp_outs && !spec->multiout.hp_nid)
    2871                 spec->multiout.hp_nid = nid;
    2872 
    2873         if (cfg->hp_outs > 1) {
     3129        return 0;
     3130}
     3131
     3132/* add playback controls from the parsed DAC table */
     3133static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
     3134                                               const struct auto_pin_cfg *cfg)
     3135{
     3136        struct sigmatel_spec *spec = codec->spec;
     3137        int err;
     3138
     3139        err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
     3140                                    spec->multiout.dac_nids,
     3141                                    cfg->line_out_type);
     3142        if (err < 0)
     3143                return err;
     3144
     3145        if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
    28743146                err = stac92xx_add_control(spec,
    28753147                        STAC_CTL_WIDGET_HP_SWITCH,
    2876                         "Headphone as Line Out Switch", 0);
     3148                        "Headphone as Line Out Switch",
     3149                        cfg->hp_pins[cfg->hp_outs - 1]);
    28773150                if (err < 0)
    28783151                        return err;
     
    28803153
    28813154        if (spec->line_switch) {
    2882                 nid = cfg->input_pins[AUTO_PIN_LINE];
    2883                 pincap = snd_hda_param_read(codec, nid,
    2884                                                 AC_PAR_PIN_CAP);
    2885                 if (pincap & AC_PINCAP_OUT) {
    2886                         err = stac92xx_add_control(spec,
    2887                                 STAC_CTL_WIDGET_IO_SWITCH,
    2888                                 "Line In as Output Switch", nid << 8);
    2889                         if (err < 0)
    2890                                 return err;
    2891                 }
     3155                err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
     3156                                           "Line In as Output Switch",
     3157                                           spec->line_switch << 8);
     3158                if (err < 0)
     3159                        return err;
    28923160        }
    28933161
    28943162        if (spec->mic_switch) {
    2895                 unsigned int def_conf;
    2896                 unsigned int mic_pin = AUTO_PIN_MIC;
    2897 again:
    2898                 nid = cfg->input_pins[mic_pin];
    2899                 def_conf = snd_hda_codec_read(codec, nid, 0,
    2900                                                 AC_VERB_GET_CONFIG_DEFAULT, 0);
    2901                 /* some laptops have an internal analog microphone
    2902                  * which can't be used as a output */
    2903                 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
    2904                         pincap = snd_hda_param_read(codec, nid,
    2905                                                         AC_PAR_PIN_CAP);
    2906                         if (pincap & AC_PINCAP_OUT) {
    2907                                 err = stac92xx_add_control(spec,
    2908                                         STAC_CTL_WIDGET_IO_SWITCH,
    2909                                         "Mic as Output Switch", (nid << 8) | 1);
    2910                                 nid = snd_hda_codec_read(codec, nid, 0,
    2911                                          AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
    2912                                 if (!check_in_dac_nids(spec, nid))
    2913                                         add_spec_dacs(spec, nid);
    2914                                 if (err < 0)
    2915                                         return err;
    2916                         }
    2917                 } else if (mic_pin == AUTO_PIN_MIC) {
    2918                         mic_pin = AUTO_PIN_FRONT_MIC;
    2919                         goto again;
    2920                 }
     3163                err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
     3164                                           "Mic as Output Switch",
     3165                                           (spec->mic_switch << 8) | 1);
     3166                if (err < 0)
     3167                        return err;
    29213168        }
    29223169
     
    29293176{
    29303177        struct sigmatel_spec *spec = codec->spec;
    2931         hda_nid_t nid;
    2932         int i, old_num_dacs, err;
    2933 
    2934         old_num_dacs = spec->multiout.num_dacs;
    2935         for (i = 0; i < cfg->hp_outs; i++) {
    2936                 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
    2937                 if (wid_caps & AC_WCAP_UNSOL_CAP)
    2938                         spec->hp_detect = 1;
    2939                 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
    2940                                          AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
    2941                 if (check_in_dac_nids(spec, nid))
    2942                         nid = 0;
    2943                 if (! nid)
    2944                         continue;
    2945                 add_spec_dacs(spec, nid);
    2946         }
    2947         for (i = 0; i < cfg->speaker_outs; i++) {
    2948                 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
    2949                                          AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
    2950                 if (check_in_dac_nids(spec, nid))
    2951                         nid = 0;
    2952                 if (! nid)
    2953                         continue;
    2954                 add_spec_dacs(spec, nid);
    2955         }
    2956         for (i = 0; i < cfg->line_outs; i++) {
    2957                 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
    2958                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
    2959                 if (check_in_dac_nids(spec, nid))
    2960                         nid = 0;
    2961                 if (! nid)
    2962                         continue;
    2963                 add_spec_dacs(spec, nid);
    2964         }
    2965         for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
    2966                 static const char *pfxs[] = {
    2967                         "Speaker", "External Speaker", "Speaker2",
    2968                 };
    2969                 err = create_controls(spec, pfxs[i - old_num_dacs],
    2970                                       spec->multiout.dac_nids[i], 3);
    2971                 if (err < 0)
    2972                         return err;
    2973         }
    2974         if (spec->multiout.hp_nid) {
    2975                 err = create_controls(spec, "Headphone",
    2976                                       spec->multiout.hp_nid, 3);
    2977                 if (err < 0)
    2978                         return err;
    2979         }
     3178        int err;
     3179
     3180        err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
     3181                                    spec->hp_dacs, AUTO_PIN_HP_OUT);
     3182        if (err < 0)
     3183                return err;
     3184
     3185        err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
     3186                                    spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
     3187        if (err < 0)
     3188                return err;
    29803189
    29813190        return 0;
     
    30723281}
    30733282
     3283#ifdef CONFIG_SND_HDA_INPUT_BEEP
     3284#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
     3285
     3286static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
     3287                                        struct snd_ctl_elem_value *ucontrol)
     3288{
     3289        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     3290        ucontrol->value.integer.value[0] = codec->beep->enabled;
     3291        return 0;
     3292}
     3293
     3294static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
     3295                                        struct snd_ctl_elem_value *ucontrol)
     3296{
     3297        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
     3298        int enabled = !!ucontrol->value.integer.value[0];
     3299        if (codec->beep->enabled != enabled) {
     3300                codec->beep->enabled = enabled;
     3301                return 1;
     3302        }
     3303        return 0;
     3304}
     3305
     3306static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
     3307        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     3308        .info = stac92xx_dig_beep_switch_info,
     3309        .get = stac92xx_dig_beep_switch_get,
     3310        .put = stac92xx_dig_beep_switch_put,
     3311};
     3312
     3313static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
     3314{
     3315        return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
     3316                                         0, "PC Beep Playback Switch", 0);
     3317}
     3318#endif
     3319
    30743320static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
    30753321{
     
    31503396                unsigned int def_conf;
    31513397
    3152                 def_conf = snd_hda_codec_read(codec,
    3153                                               spec->dmic_nids[i],
    3154                                               0,
    3155                                               AC_VERB_GET_CONFIG_DEFAULT,
    3156                                               0);
     3398                def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
    31573399                if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
    31583400                        continue;
     
    32783520{
    32793521        struct sigmatel_spec *spec = codec->spec;
     3522        int hp_swap = 0;
    32803523        int err;
    3281         int hp_speaker_swap = 0;
    32823524
    32833525        if ((err = snd_hda_parse_pin_def_config(codec,
     
    32973539                 * HP pins as primary outputs.
    32983540                 */
     3541                snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
    32993542                memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
    33003543                       sizeof(spec->autocfg.line_out_pins));
     
    33033546                       sizeof(spec->autocfg.hp_pins));
    33043547                spec->autocfg.line_outs = spec->autocfg.hp_outs;
    3305                 hp_speaker_swap = 1;
     3548                spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
     3549                spec->autocfg.hp_outs = 0;
     3550                hp_swap = 1;
    33063551        }
    33073552        if (spec->autocfg.mono_out_pin) {
     
    33553600        }
    33563601
    3357         if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
    3358                 return err;
    3359         if (spec->multiout.num_dacs == 0)
    3360                 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
     3602        if (!spec->multiout.num_dacs) {
     3603                err = stac92xx_auto_fill_dac_nids(codec);
     3604                if (err < 0)
    33613605                        return err;
    3362 
    3363         err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
    3364 
    3365         if (err < 0)
    3366                 return err;
     3606                err = stac92xx_auto_create_multi_out_ctls(codec,
     3607                                                          &spec->autocfg);
     3608                if (err < 0)
     3609                        return err;
     3610        }
    33673611
    33683612        /* setup analog beep controls */
     
    33783622        if (spec->digbeep_nid > 0) {
    33793623                hda_nid_t nid = spec->digbeep_nid;
     3624                unsigned int caps;
    33803625
    33813626                err = stac92xx_auto_create_beep_ctls(codec, nid);
     
    33853630                if (err < 0)
    33863631                        return err;
     3632                /* if no beep switch is available, make its own one */
     3633                caps = query_amp_caps(codec, nid, HDA_OUTPUT);
     3634                if (codec->beep &&
     3635                    !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
     3636                        err = stac92xx_beep_switch_ctl(codec);
     3637                        if (err < 0)
     3638                                return err;
     3639                }
    33873640        }
    33883641#endif
    33893642
    3390         if (hp_speaker_swap == 1) {
    3391                 /* Restore the hp_outs and line_outs */
    3392                 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
    3393                        sizeof(spec->autocfg.line_out_pins));
    3394                 spec->autocfg.hp_outs = spec->autocfg.line_outs;
    3395                 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
    3396                        sizeof(spec->autocfg.speaker_pins));
    3397                 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
    3398                 memset(spec->autocfg.speaker_pins, 0,
    3399                        sizeof(spec->autocfg.speaker_pins));
    3400                 spec->autocfg.speaker_outs = 0;
    3401         }
    3402 
    34033643        err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
    3404 
    34053644        if (err < 0)
    34063645                return err;
    34073646
     3647        /* All output parsing done, now restore the swapped hp pins */
     3648        if (hp_swap) {
     3649                memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
     3650                       sizeof(spec->autocfg.hp_pins));
     3651                spec->autocfg.hp_outs = spec->autocfg.line_outs;
     3652                spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
     3653                spec->autocfg.line_outs = 0;
     3654        }
     3655
    34083656        err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
    3409 
    34103657        if (err < 0)
    34113658                return err;
     
    34363683        }
    34373684
     3685        err = stac92xx_add_input_source(spec);
     3686        if (err < 0)
     3687                return err;
     3688
    34383689        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    34393690        if (spec->multiout.max_channels > 2)
    34403691                spec->surr_switch = 1;
    34413692
    3442         if (spec->autocfg.dig_out_pin)
     3693        if (spec->autocfg.dig_outs)
    34433694                spec->multiout.dig_out_nid = dig_out;
    34443695        if (dig_in && spec->autocfg.dig_in_pin)
     
    34493700
    34503701        spec->input_mux = &spec->private_imux;
    3451         spec->dinput_mux = &spec->private_dimux;
     3702        if (!spec->dinput_mux)
     3703                spec->dinput_mux = &spec->private_dimux;
    34523704        spec->sinput_mux = &spec->private_smux;
    34533705        spec->mono_mux = &spec->private_mono_mux;
     
    35023754                        hda_nid_t pin = spec->autocfg.line_out_pins[i];
    35033755                        unsigned int defcfg;
    3504                         defcfg = snd_hda_codec_read(codec, pin, 0,
    3505                                                  AC_VERB_GET_CONFIG_DEFAULT,
    3506                                                  0x00);
     3756                        defcfg = snd_hda_codec_get_pincfg(codec, pin);
    35073757                        if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
    35083758                                unsigned int wcaps = get_wcaps(codec, pin);
     
    35173767
    35183768        if (lfe_pin) {
    3519                 err = create_controls(spec, "LFE", lfe_pin, 1);
     3769                err = create_controls(codec, "LFE", lfe_pin, 1);
    35203770                if (err < 0)
    35213771                        return err;
     
    35423792                return err;
    35433793
    3544         if (spec->autocfg.dig_out_pin)
     3794        if (spec->num_muxes > 0) {
     3795                err = stac92xx_auto_create_mux_input_ctls(codec);
     3796                if (err < 0)
     3797                        return err;
     3798        }
     3799
     3800        err = stac92xx_add_input_source(spec);
     3801        if (err < 0)
     3802                return err;
     3803
     3804        if (spec->autocfg.dig_outs)
    35453805                spec->multiout.dig_out_nid = 0x05;
    35463806        if (spec->autocfg.dig_in_pin)
     
    35923852}
    35933853
     3854#ifdef CONFIG_SND_JACK
     3855static void stac92xx_free_jack_priv(struct snd_jack *jack)
     3856{
     3857        struct sigmatel_jack *jacks = jack->private_data;
     3858        jacks->nid = 0;
     3859        jacks->jack = NULL;
     3860}
     3861#endif
     3862
    35943863static int stac92xx_add_jack(struct hda_codec *codec,
    35953864                hda_nid_t nid, int type)
    35963865{
     3866#ifdef CONFIG_SND_JACK
    35973867        struct sigmatel_spec *spec = codec->spec;
    35983868        struct sigmatel_jack *jack;
    3599         int def_conf = snd_hda_codec_read(codec, nid,
    3600                         0, AC_VERB_GET_CONFIG_DEFAULT, 0);
     3869        int def_conf = snd_hda_codec_get_pincfg(codec, nid);
    36013870        int connectivity = get_defcfg_connect(def_conf);
    36023871        char name[32];
     3872        int err;
    36033873
    36043874        if (connectivity && connectivity != AC_JACK_PORT_FIXED)
     
    36173887                snd_hda_get_jack_location(def_conf));
    36183888
    3619         return snd_jack_new(codec->bus->card, name, type, &jack->jack);
    3620 }
    3621 
    3622 static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
    3623                              int data)
     3889        err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
     3890        if (err < 0) {
     3891                jack->nid = 0;
     3892                return err;
     3893        }
     3894        jack->jack->private_data = jack;
     3895        jack->jack->private_free = stac92xx_free_jack_priv;
     3896#endif
     3897        return 0;
     3898}
     3899
     3900static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
     3901                          unsigned char type, int data)
    36243902{
    36253903        struct sigmatel_event *event;
     
    36303908                return -ENOMEM;
    36313909        event->nid = nid;
     3910        event->type = type;
     3911        event->tag = spec->events.used;
    36323912        event->data = data;
    36333913
    3634         return 0;
    3635 }
    3636 
    3637 static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
    3638 {
    3639         struct sigmatel_spec *spec = codec->spec;
    3640         struct sigmatel_event *events = spec->events.list;
    3641         if (events) {
    3642                 int i;
    3643                 for (i = 0; i < spec->events.used; i++)
    3644                         if (events[i].nid == nid)
    3645                                 return events[i].data;
    3646         }
    3647         return 0;
     3914        return event->tag;
     3915}
     3916
     3917static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
     3918                                             hda_nid_t nid, unsigned char type)
     3919{
     3920        struct sigmatel_spec *spec = codec->spec;
     3921        struct sigmatel_event *event = spec->events.list;
     3922        int i;
     3923
     3924        for (i = 0; i < spec->events.used; i++, event++) {
     3925                if (event->nid == nid && event->type == type)
     3926                        return event;
     3927        }
     3928        return NULL;
     3929}
     3930
     3931static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
     3932                                                      unsigned char tag)
     3933{
     3934        struct sigmatel_spec *spec = codec->spec;
     3935        struct sigmatel_event *event = spec->events.list;
     3936        int i;
     3937
     3938        for (i = 0; i < spec->events.used; i++, event++) {
     3939                if (event->tag == tag)
     3940                        return event;
     3941        }
     3942        return NULL;
    36483943}
    36493944
    36503945static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
    3651                               unsigned int event)
    3652 {
    3653         if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
    3654                 snd_hda_codec_write_cache(codec, nid, 0,
    3655                                           AC_VERB_SET_UNSOLICITED_ENABLE,
    3656                                           (AC_USRSP_EN | event | nid));
    3657         }
     3946                              unsigned int type)
     3947{
     3948        struct sigmatel_event *event;
     3949        int tag;
     3950
     3951        if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
     3952                return;
     3953        event = stac_get_event(codec, nid, type);
     3954        if (event)
     3955                tag = event->tag;
     3956        else
     3957                tag = stac_add_event(codec->spec, nid, type, 0);
     3958        if (tag < 0)
     3959                return;
     3960        snd_hda_codec_write_cache(codec, nid, 0,
     3961                                  AC_VERB_SET_UNSOLICITED_ENABLE,
     3962                                  AC_USRSP_EN | tag);
    36583963}
    36593964
     
    36753980        hda_nid_t *dac;
    36763981        for (dac = spec->dac_list; *dac; dac++)
    3677                 if (!is_in_dac_nids(spec, *dac) &&
    3678                         spec->multiout.hp_nid != *dac)
    3679                         snd_hda_codec_write_cache(codec, *dac, 0,
     3982                if (!check_all_dac_nids(spec, *dac))
     3983                        snd_hda_codec_write(codec, *dac, 0,
    36803984                                        AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
    36813985}
    36823986
     3987static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
     3988                                  int enable);
     3989
     3990/* override some hints from the hwdep entry */
     3991static void stac_store_hints(struct hda_codec *codec)
     3992{
     3993        struct sigmatel_spec *spec = codec->spec;
     3994        const char *p;
     3995        int val;
     3996
     3997        val = snd_hda_get_bool_hint(codec, "hp_detect");
     3998        if (val >= 0)
     3999                spec->hp_detect = val;
     4000        p = snd_hda_get_hint(codec, "gpio_mask");
     4001        if (p) {
     4002                spec->gpio_mask = simple_strtoul(p, NULL, 0);
     4003                spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
     4004                        spec->gpio_mask;
     4005        }
     4006        p = snd_hda_get_hint(codec, "gpio_dir");
     4007        if (p)
     4008                spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
     4009        p = snd_hda_get_hint(codec, "gpio_data");
     4010        if (p)
     4011                spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
     4012        p = snd_hda_get_hint(codec, "eapd_mask");
     4013        if (p)
     4014                spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
     4015        val = snd_hda_get_bool_hint(codec, "eapd_switch");
     4016        if (val >= 0)
     4017                spec->eapd_switch = val;
     4018}
     4019
    36834020static int stac92xx_init(struct hda_codec *codec)
    36844021{
    36854022        struct sigmatel_spec *spec = codec->spec;
    36864023        struct auto_pin_cfg *cfg = &spec->autocfg;
    3687         int i, err;
     4024        unsigned int gpio;
     4025        int i;
    36884026
    36894027        snd_hda_sequence_write(codec, spec->init);
     
    36924030        if (spec->powerdown_adcs)
    36934031                for (i = 0; i < spec->num_adcs; i++)
    3694                         snd_hda_codec_write_cache(codec,
     4032                        snd_hda_codec_write(codec,
    36954033                                spec->adc_nids[i], 0,
    36964034                                AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
     4035
     4036        /* override some hints */
     4037        stac_store_hints(codec);
     4038
     4039        /* set up GPIO */
     4040        gpio = spec->gpio_data;
     4041        /* turn on EAPD statically when spec->eapd_switch isn't set.
     4042         * otherwise, unsol event will turn it on/off dynamically
     4043         */
     4044        if (!spec->eapd_switch)
     4045                gpio |= spec->eapd_mask;
     4046        stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
     4047
    36974048        /* set up pins */
    36984049        if (spec->hp_detect) {
    36994050                /* Enable unsolicited responses on the HP widget */
    37004051                for (i = 0; i < cfg->hp_outs; i++) {
    3701                         int type = SND_JACK_HEADPHONE;
    37024052                        hda_nid_t nid = cfg->hp_pins[i];
    3703                         enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
    3704                         /* jack detection */
    3705                         if (cfg->hp_outs == i)
    3706                                 type |= SND_JACK_LINEOUT;
    3707                         err = stac92xx_add_jack(codec, nid, type);
    3708                         if (err < 0)
    3709                                 return err;
    3710 
     4053                        enable_pin_detect(codec, nid, STAC_HP_EVENT);
    37114054                }
    37124055                /* force to enable the first line-out; the others are set up
     
    37164059                                AC_PINCTL_OUT_EN);
    37174060                /* fake event to set up pins */
    3718                 codec->patch_ops.unsol_event(codec,
    3719                         (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
     4061                stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
     4062                                       STAC_HP_EVENT);
    37204063        } else {
    37214064                stac92xx_auto_init_multi_out(codec);
    37224065                stac92xx_auto_init_hp_out(codec);
    3723         }
    3724         for (i = 0; i < cfg->line_outs; i++) {
    3725                 err = stac92xx_add_jack(codec,
    3726                                 cfg->line_out_pins[i], SND_JACK_LINEOUT);
    3727                 if (err < 0)
    3728                         return err;
     4066                for (i = 0; i < cfg->hp_outs; i++)
     4067                        stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
    37294068        }
    37304069        for (i = 0; i < AUTO_PIN_LAST; i++) {
    37314070                hda_nid_t nid = cfg->input_pins[i];
    37324071                if (nid) {
    3733                         unsigned int pinctl = snd_hda_codec_read(codec, nid,
    3734                                 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    3735                         /* if PINCTL already set then skip */
    3736                         if (pinctl & AC_PINCAP_IN)
    3737                                 continue;
    3738                         pinctl = AC_PINCTL_IN_EN;
    3739                         if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
    3740                                 pinctl |= stac92xx_get_vref(codec, nid);
    3741                         stac92xx_auto_set_pinctl(codec, nid, pinctl);
    3742                         err = stac92xx_add_jack(codec, nid,
    3743                                 SND_JACK_MICROPHONE);
    3744                         if (err < 0)
    3745                                 return err;
    3746                         enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
     4072                        unsigned int pinctl, conf;
     4073                        if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
     4074                                /* for mic pins, force to initialize */
     4075                                pinctl = stac92xx_get_vref(codec, nid);
     4076                                pinctl |= AC_PINCTL_IN_EN;
     4077                                stac92xx_auto_set_pinctl(codec, nid, pinctl);
     4078                        } else {
     4079                                pinctl = snd_hda_codec_read(codec, nid, 0,
     4080                                        AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     4081                                /* if PINCTL already set then skip */
     4082                                if (!(pinctl & AC_PINCTL_IN_EN)) {
     4083                                        pinctl |= AC_PINCTL_IN_EN;
     4084                                        stac92xx_auto_set_pinctl(codec, nid,
     4085                                                                 pinctl);
     4086                                }
     4087                        }
     4088                        conf = snd_hda_codec_get_pincfg(codec, nid);
     4089                        if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
     4090                                enable_pin_detect(codec, nid,
     4091                                                  STAC_INSERT_EVENT);
     4092                                stac_issue_unsol_event(codec, nid,
     4093                                                       STAC_INSERT_EVENT);
     4094                        }
    37474095                }
    37484096        }
     
    37504098                stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
    37514099                                        AC_PINCTL_IN_EN);
     4100        if (cfg->dig_out_pins[0])
     4101                stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
     4102                                         AC_PINCTL_OUT_EN);
     4103        if (cfg->dig_in_pin)
     4104                stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
     4105                                         AC_PINCTL_IN_EN);
    37524106        for (i = 0; i < spec->num_pwrs; i++)  {
    3753                 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
    3754                                         ? STAC_HP_EVENT : STAC_PWR_EVENT;
    3755                 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
    3756                                         0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    3757                 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
    3758                                         0, AC_VERB_GET_CONFIG_DEFAULT, 0);
    3759                 def_conf = get_defcfg_connect(def_conf);
     4107                hda_nid_t nid = spec->pwr_nids[i];
     4108                int pinctl, def_conf;
     4109
     4110                /* power on when no jack detection is available */
     4111                if (!spec->hp_detect) {
     4112                        stac_toggle_power_map(codec, nid, 1);
     4113                        continue;
     4114                }
     4115
     4116                if (is_nid_hp_pin(cfg, nid))
     4117                        continue; /* already has an unsol event */
     4118
     4119                pinctl = snd_hda_codec_read(codec, nid, 0,
     4120                                            AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    37604121                /* outputs are only ports capable of power management
    37614122                 * any attempts on powering down a input port cause the
    37624123                 * referenced VREF to act quirky.
    37634124                 */
    3764                 if (pinctl & AC_PINCTL_IN_EN)
     4125                if (pinctl & AC_PINCTL_IN_EN) {
     4126                        stac_toggle_power_map(codec, nid, 1);
    37654127                        continue;
     4128                }
     4129                def_conf = snd_hda_codec_get_pincfg(codec, nid);
     4130                def_conf = get_defcfg_connect(def_conf);
    37664131                /* skip any ports that don't have jacks since presence
    37674132                 * detection is useless */
    3768                 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
     4133                if (def_conf != AC_JACK_PORT_COMPLEX) {
     4134                        if (def_conf != AC_JACK_PORT_NONE)
     4135                                stac_toggle_power_map(codec, nid, 1);
    37694136                        continue;
    3770                 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
    3771                 codec->patch_ops.unsol_event(codec, (event | i) << 26);
     4137                }
     4138                if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
     4139                        enable_pin_detect(codec, nid, STAC_PWR_EVENT);
     4140                        stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
     4141                }
    37724142        }
    37734143        if (spec->dac_list)
    37744144                stac92xx_power_down(codec);
    3775         if (cfg->dig_out_pin)
    3776                 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
    3777                                          AC_PINCTL_OUT_EN);
    3778         if (cfg->dig_in_pin)
    3779                 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
    3780                                          AC_PINCTL_IN_EN);
    3781 
    3782         stac_gpio_set(codec, spec->gpio_mask,
    3783                                         spec->gpio_dir, spec->gpio_data);
    3784 
    37854145        return 0;
    37864146}
     
    37884148static void stac92xx_free_jacks(struct hda_codec *codec)
    37894149{
    3790         struct sigmatel_spec *spec = codec->spec;
    3791         if (spec->jacks.list) {
     4150#ifdef CONFIG_SND_JACK
     4151        /* free jack instances manually when clearing/reconfiguring */
     4152        struct sigmatel_spec *spec = codec->spec;
     4153        if (!codec->bus->shutdown && spec->jacks.list) {
    37924154                struct sigmatel_jack *jacks = spec->jacks.list;
    37934155                int i;
    3794                 for (i = 0; i < spec->jacks.used; i++)
    3795                         snd_device_free(codec->bus->card, &jacks[i].jack);
     4156                for (i = 0; i < spec->jacks.used; i++, jacks++) {
     4157                        if (jacks->jack)
     4158                                snd_device_free(codec->bus->card, jacks->jack);
     4159                }
    37964160        }
    37974161        snd_array_free(&spec->jacks);
     4162#endif
    37984163}
    37994164
     
    38184183                return;
    38194184
    3820         if (spec->bios_pin_configs)
    3821                 kfree(spec->bios_pin_configs);
    38224185        stac92xx_free_jacks(codec);
    38234186        snd_array_free(&spec->events);
     
    38304193                                unsigned int flag)
    38314194{
    3832         unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
     4195        unsigned int old_ctl, pin_ctl;
     4196
     4197        pin_ctl = snd_hda_codec_read(codec, nid,
    38334198                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
    38344199
     
    38404205                 */
    38414206                struct sigmatel_spec *spec = codec->spec;
    3842                 struct auto_pin_cfg *cfg = &spec->autocfg;
    3843                 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
    3844                      spec->line_switch) ||
    3845                     (nid == cfg->input_pins[AUTO_PIN_MIC] &&
    3846                      spec->mic_switch))
     4207                if (nid == spec->line_switch || nid == spec->mic_switch)
    38474208                        return;
    38484209        }
    38494210
     4211        old_ctl = pin_ctl;
    38504212        /* if setting pin direction bits, clear the current
    38514213           direction bits first */
     
    38534215                pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
    38544216       
    3855         snd_hda_codec_write_cache(codec, nid, 0,
    3856                         AC_VERB_SET_PIN_WIDGET_CONTROL,
    3857                         pin_ctl | flag);
     4217        pin_ctl |= flag;
     4218        if (old_ctl != pin_ctl)
     4219                snd_hda_codec_write_cache(codec, nid, 0,
     4220                                          AC_VERB_SET_PIN_WIDGET_CONTROL,
     4221                                          pin_ctl);
    38584222}
    38594223
     
    38634227        unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
    38644228                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
    3865         snd_hda_codec_write_cache(codec, nid, 0,
    3866                         AC_VERB_SET_PIN_WIDGET_CONTROL,
    3867                         pin_ctl & ~flag);
    3868 }
    3869 
    3870 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
     4229        if (pin_ctl & flag)
     4230                snd_hda_codec_write_cache(codec, nid, 0,
     4231                                          AC_VERB_SET_PIN_WIDGET_CONTROL,
     4232                                          pin_ctl & ~flag);
     4233}
     4234
     4235static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
    38714236{
    38724237        if (!nid)
    38734238                return 0;
    38744239        if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
    3875             & (1 << 31)) {
    3876                 unsigned int pinctl;
    3877                 pinctl = snd_hda_codec_read(codec, nid, 0,
    3878                                             AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
    3879                 if (pinctl & AC_PINCTL_IN_EN)
    3880                         return 0; /* mic- or line-input */
    3881                 else
    3882                         return 1; /* HP-output */
    3883         }
     4240            & (1 << 31))
     4241                return 1;
    38844242        return 0;
    38854243}
    38864244
    3887 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
    3888 {
    3889         struct sigmatel_spec *spec = codec->spec;
     4245/* return non-zero if the hp-pin of the given array index isn't
     4246 * a jack-detection target
     4247 */
     4248static int no_hp_sensing(struct sigmatel_spec *spec, int i)
     4249{
    38904250        struct auto_pin_cfg *cfg = &spec->autocfg;
    3891         int nid = cfg->hp_pins[cfg->hp_outs - 1];
     4251
     4252        /* ignore sensing of shared line and mic jacks */
     4253        if (cfg->hp_pins[i] == spec->line_switch)
     4254                return 1;
     4255        if (cfg->hp_pins[i] == spec->mic_switch)
     4256                return 1;
     4257        /* ignore if the pin is set as line-out */
     4258        if (cfg->hp_pins[i] == spec->hp_switch)
     4259                return 1;
     4260        return 0;
     4261}
     4262
     4263static void stac92xx_hp_detect(struct hda_codec *codec)
     4264{
     4265        struct sigmatel_spec *spec = codec->spec;
     4266        struct auto_pin_cfg *cfg = &spec->autocfg;
    38924267        int i, presence;
    38934268
     
    39004275                if (presence)
    39014276                        break;
    3902                 if (spec->hp_switch && cfg->hp_pins[i] == nid)
    3903                         break;
    3904                 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
     4277                if (no_hp_sensing(spec, i))
     4278                        continue;
     4279                presence = get_pin_presence(codec, cfg->hp_pins[i]);
     4280                if (presence) {
     4281                        unsigned int pinctl;
     4282                        pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
     4283                                            AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
     4284                        if (pinctl & AC_PINCTL_IN_EN)
     4285                                presence = 0; /* mic- or line-input */
     4286                }
    39054287        }
    39064288
    39074289        if (presence) {
    3908                 /* disable lineouts, enable hp */
     4290                /* disable lineouts */
    39094291                if (spec->hp_switch)
    3910                         stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
     4292                        stac92xx_reset_pinctl(codec, spec->hp_switch,
     4293                                              AC_PINCTL_OUT_EN);
    39114294                for (i = 0; i < cfg->line_outs; i++)
    39124295                        stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
     
    39154298                        stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
    39164299                                                AC_PINCTL_OUT_EN);
    3917                 if (spec->eapd_mask)
     4300                if (spec->eapd_mask && spec->eapd_switch)
    39184301                        stac_gpio_set(codec, spec->gpio_mask,
    39194302                                spec->gpio_dir, spec->gpio_data &
    39204303                                ~spec->eapd_mask);
    39214304        } else {
    3922                 /* enable lineouts, disable hp */
     4305                /* enable lineouts */
    39234306                if (spec->hp_switch)
    3924                         stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
     4307                        stac92xx_set_pinctl(codec, spec->hp_switch,
     4308                                            AC_PINCTL_OUT_EN);
    39254309                for (i = 0; i < cfg->line_outs; i++)
    39264310                        stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
     
    39294313                        stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
    39304314                                                AC_PINCTL_OUT_EN);
    3931                 if (spec->eapd_mask)
     4315                if (spec->eapd_mask && spec->eapd_switch)
    39324316                        stac_gpio_set(codec, spec->gpio_mask,
    39334317                                spec->gpio_dir, spec->gpio_data |
    39344318                                spec->eapd_mask);
    39354319        }
    3936         if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
    3937                 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
     4320        /* toggle hp outs */
     4321        for (i = 0; i < cfg->hp_outs; i++) {
     4322                unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
     4323                if (no_hp_sensing(spec, i))
     4324                        continue;
     4325                if (presence)
     4326                        stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
     4327#if 0 /* FIXME */
     4328/* Resetting the pinctl like below may lead to (a sort of) regressions
     4329 * on some devices since they use the HP pin actually for line/speaker
     4330 * outs although the default pin config shows a different pin (that is
     4331 * wrong and useless).
     4332 *
     4333 * So, it's basically a problem of default pin configs, likely a BIOS issue.
     4334 * But, disabling the code below just works around it, and I'm too tired of
     4335 * bug reports with such devices...
     4336 */
     4337                else
     4338                        stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
     4339#endif /* FIXME */
     4340        }
    39384341}
    39394342
    3940 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
    3941 {
    3942         struct sigmatel_spec *spec = codec->spec;
    3943         hda_nid_t nid = spec->pwr_nids[idx];
    3944         int presence, val;
    3945         val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
    3946                                                         & 0x000000ff;
    3947         presence = get_hp_pin_presence(codec, nid);
     4343static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
     4344                                  int enable)
     4345{
     4346        struct sigmatel_spec *spec = codec->spec;
     4347        unsigned int idx, val;
     4348
     4349        for (idx = 0; idx < spec->num_pwrs; idx++) {
     4350                if (spec->pwr_nids[idx] == nid)
     4351                        break;
     4352        }
     4353        if (idx >= spec->num_pwrs)
     4354                return;
    39484355
    39494356        /* several codecs have two power down bits */
     
    39534360                idx = 1 << idx;
    39544361
    3955         if (presence)
     4362        val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
     4363        if (enable)
    39564364                val &= ~idx;
    39574365        else
     
    39604368        /* power down unused output ports */
    39614369        snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
     4370}
     4371
     4372static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
     4373{
     4374        stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
    39624375}
    39634376
     
    39814394                                        ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
    39824395                                snd_jack_report(jacks->jack,
    3983                                         get_hp_pin_presence(codec, nid)
     4396                                        get_pin_presence(codec, nid)
    39844397                                        ? type : 0);
    39854398                        }
     
    39894402}
    39904403
     4404static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
     4405                                   unsigned char type)
     4406{
     4407        struct sigmatel_event *event = stac_get_event(codec, nid, type);
     4408        if (!event)
     4409                return;
     4410        codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
     4411}
     4412
    39914413static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
    39924414{
    39934415        struct sigmatel_spec *spec = codec->spec;
    3994         int event = (res >> 26) & 0x70;
    3995         int nid = res >> 26 & 0x0f;
    3996 
    3997         switch (event) {
     4416        struct sigmatel_event *event;
     4417        int tag, data;
     4418
     4419        tag = (res >> 26) & 0x7f;
     4420        event = stac_get_event_from_tag(codec, tag);
     4421        if (!event)
     4422                return;
     4423
     4424        switch (event->type) {
    39984425        case STAC_HP_EVENT:
    3999                 stac92xx_hp_detect(codec, res);
     4426                stac92xx_hp_detect(codec);
    40004427                /* fallthru */
    40014428        case STAC_INSERT_EVENT:
    40024429        case STAC_PWR_EVENT:
    4003                 if (nid) {
    4004                         if (spec->num_pwrs > 0)
    4005                                 stac92xx_pin_sense(codec, nid);
    4006                         stac92xx_report_jack(codec, nid);
     4430                if (spec->num_pwrs > 0)
     4431                        stac92xx_pin_sense(codec, event->nid);
     4432                stac92xx_report_jack(codec, event->nid);
     4433
     4434                switch (codec->subsystem_id) {
     4435                case 0x103c308f:
     4436                        if (event->nid == 0xb) {
     4437                                int pin = AC_PINCTL_IN_EN;
     4438
     4439                                if (get_pin_presence(codec, 0xa)
     4440                                                && get_pin_presence(codec, 0xb))
     4441                                        pin |= AC_PINCTL_VREF_80;
     4442                                if (!get_pin_presence(codec, 0xb))
     4443                                        pin |= AC_PINCTL_VREF_80;
     4444
     4445                                /* toggle VREF state based on mic + hp pin
     4446                                 * status
     4447                                 */
     4448                                stac92xx_auto_set_pinctl(codec, 0x0a, pin);
     4449                        }
    40074450                }
    40084451                break;
    4009         case STAC_VREF_EVENT: {
    4010                 int data = snd_hda_codec_read(codec, codec->afg, 0,
    4011                         AC_VERB_GET_GPIO_DATA, 0);
    4012                 int idx = stac92xx_event_data(codec, nid);
     4452        case STAC_VREF_EVENT:
     4453                data = snd_hda_codec_read(codec, codec->afg, 0,
     4454                                          AC_VERB_GET_GPIO_DATA, 0);
    40134455                /* toggle VREF state based on GPIOx status */
    40144456                snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
    4015                         !!(data & (1 << idx)));
     4457                                    !!(data & (1 << event->data)));
    40164458                break;
    4017                 }
    4018         }
    4019 }
     4459        }
     4460}
     4461
     4462#ifdef CONFIG_PROC_FS
     4463static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
     4464                               struct hda_codec *codec, hda_nid_t nid)
     4465{
     4466        if (nid == codec->afg)
     4467                snd_iprintf(buffer, "Power-Map: 0x%02x\n",
     4468                            snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
     4469}
     4470
     4471static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
     4472                                  struct hda_codec *codec,
     4473                                  unsigned int verb)
     4474{
     4475        snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
     4476                    snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
     4477}
     4478
     4479/* stac92hd71bxx, stac92hd73xx */
     4480static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
     4481                                 struct hda_codec *codec, hda_nid_t nid)
     4482{
     4483        stac92hd_proc_hook(buffer, codec, nid);
     4484        if (nid == codec->afg)
     4485                analog_loop_proc_hook(buffer, codec, 0xfa0);
     4486}
     4487
     4488static void stac9205_proc_hook(struct snd_info_buffer *buffer,
     4489                               struct hda_codec *codec, hda_nid_t nid)
     4490{
     4491        if (nid == codec->afg)
     4492                analog_loop_proc_hook(buffer, codec, 0xfe0);
     4493}
     4494
     4495static void stac927x_proc_hook(struct snd_info_buffer *buffer,
     4496                               struct hda_codec *codec, hda_nid_t nid)
     4497{
     4498        if (nid == codec->afg)
     4499                analog_loop_proc_hook(buffer, codec, 0xfeb);
     4500}
     4501#else
     4502#define stac92hd_proc_hook      NULL
     4503#define stac92hd7x_proc_hook    NULL
     4504#define stac9205_proc_hook      NULL
     4505#define stac927x_proc_hook      NULL
     4506#endif
    40204507
    40214508#ifdef SND_HDA_NEEDS_RESUME
     
    40244511        struct sigmatel_spec *spec = codec->spec;
    40254512
    4026         stac92xx_set_config_regs(codec);
    4027         snd_hda_sequence_write(codec, spec->init);
    4028         stac_gpio_set(codec, spec->gpio_mask,
    4029                 spec->gpio_dir, spec->gpio_data);
     4513        stac92xx_init(codec);
    40304514        snd_hda_codec_resume_amp(codec);
    40314515        snd_hda_codec_resume_cache(codec);
    4032         /* power down inactive DACs */
    4033         if (spec->dac_list)
    4034                 stac92xx_power_down(codec);
    4035         /* invoke unsolicited event to reset the HP state */
     4516        /* fake event to set up pins again to override cached values */
    40364517        if (spec->hp_detect)
    4037                 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
     4518                stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
     4519                                       STAC_HP_EVENT);
     4520        return 0;
     4521}
     4522
     4523
     4524/*
     4525 * using power check for controlling mute led of HP HDX notebooks
     4526 * check for mute state only on Speakers (nid = 0x10)
     4527 *
     4528 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
     4529 * the LED is NOT working properly !
     4530 */
     4531
     4532#ifdef CONFIG_SND_HDA_POWER_SAVE
     4533static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec,
     4534                                              hda_nid_t nid)
     4535{
     4536        struct sigmatel_spec *spec = codec->spec;
     4537
     4538        if (nid == 0x10) {
     4539                if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
     4540                    HDA_AMP_MUTE)
     4541                        spec->gpio_data &= ~0x08;  /* orange */
     4542                else
     4543                        spec->gpio_data |= 0x08;   /* white */
     4544
     4545                stac_gpio_set(codec, spec->gpio_mask,
     4546                              spec->gpio_dir,
     4547                              spec->gpio_data);
     4548        }
     4549
     4550        return 0;
     4551}
     4552#endif
     4553
     4554static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
     4555{
     4556        struct sigmatel_spec *spec = codec->spec;
     4557        if (spec->eapd_mask)
     4558                stac_gpio_set(codec, spec->gpio_mask,
     4559                                spec->gpio_dir, spec->gpio_data &
     4560                                ~spec->eapd_mask);
    40384561        return 0;
    40394562}
     
    40474570        .unsol_event = stac92xx_unsol_event,
    40484571#ifdef SND_HDA_NEEDS_RESUME
     4572        .suspend = stac92xx_suspend,
    40494573        .resume = stac92xx_resume,
    40504574#endif
     
    40664590                                                        stac9200_models,
    40674591                                                        stac9200_cfg_tbl);
    4068         if (spec->board_config < 0) {
     4592        if (spec->board_config < 0)
    40694593                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
    4070                 err = stac92xx_save_bios_config_regs(codec);
    4071                 if (err < 0) {
    4072                         stac92xx_free(codec);
    4073                         return err;
    4074                 }
    4075                 spec->pin_configs = spec->bios_pin_configs;
    4076         } else {
    4077                 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
    4078                 stac92xx_set_config_regs(codec);
    4079         }
     4594        else
     4595                stac92xx_set_config_regs(codec,
     4596                                         stac9200_brd_tbl[spec->board_config]);
    40804597
    40814598        spec->multiout.max_channels = 2;
     
    40894606        spec->num_pwrs = 0;
    40904607
    4091         if (spec->board_config == STAC_9200_GATEWAY ||
     4608        if (spec->board_config == STAC_9200_M4 ||
     4609            spec->board_config == STAC_9200_M4_2 ||
    40924610            spec->board_config == STAC_9200_OQO)
    40934611                spec->init = stac9200_eapd_init;
     
    41074625        }
    41084626
     4627        /* CF-74 has no headphone detection, and the driver should *NOT*
     4628         * do detection and HP/speaker toggle because the hardware does it.
     4629         */
     4630        if (spec->board_config == STAC_9200_PANASONIC)
     4631                spec->hp_detect = 0;
     4632
    41094633        codec->patch_ops = stac92xx_patch_ops;
    41104634
     
    41244648        spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
    41254649        spec->pin_nids = stac925x_pin_nids;
    4126         spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
     4650
     4651        /* Check first for codec ID */
     4652        spec->board_config = snd_hda_check_board_codec_sid_config(codec,
     4653                                                        STAC_925x_MODELS,
     4654                                                        stac925x_models,
     4655                                                        stac925x_codec_id_cfg_tbl);
     4656
     4657        /* Now checks for PCI ID, if codec ID is not found */
     4658        if (spec->board_config < 0)
     4659                spec->board_config = snd_hda_check_board_config(codec,
     4660                                                        STAC_925x_MODELS,
    41274661                                                        stac925x_models,
    41284662                                                        stac925x_cfg_tbl);
    41294663 again:
    4130         if (spec->board_config < 0) {
    4131                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 
     4664        if (spec->board_config < 0)
     4665                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
    41324666                                      "using BIOS defaults\n");
    4133                 err = stac92xx_save_bios_config_regs(codec);
    4134                 if (err < 0) {
    4135                         stac92xx_free(codec);
    4136                         return err;
    4137                 }
    4138                 spec->pin_configs = spec->bios_pin_configs;
    4139         } else if (stac925x_brd_tbl[spec->board_config] != NULL){
    4140                 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
    4141                 stac92xx_set_config_regs(codec);
    4142         }
     4667        else
     4668                stac92xx_set_config_regs(codec,
     4669                                         stac925x_brd_tbl[spec->board_config]);
    41434670
    41444671        spec->multiout.max_channels = 2;
     
    42034730        hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
    42044731        int err = 0;
     4732        int num_dacs;
    42054733
    42064734        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    42174745                                                        stac92hd73xx_cfg_tbl);
    42184746again:
    4219         if (spec->board_config < 0) {
     4747        if (spec->board_config < 0)
    42204748                snd_printdd(KERN_INFO "hda_codec: Unknown model for"
    42214749                        " STAC92HD73XX, using BIOS defaults\n");
    4222                 err = stac92xx_save_bios_config_regs(codec);
    4223                 if (err < 0) {
    4224                         stac92xx_free(codec);
    4225                         return err;
    4226                 }
    4227                 spec->pin_configs = spec->bios_pin_configs;
    4228         } else {
    4229                 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
    4230                 stac92xx_set_config_regs(codec);
    4231         }
    4232 
    4233         spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
     4750        else
     4751                stac92xx_set_config_regs(codec,
     4752                                stac92hd73xx_brd_tbl[spec->board_config]);
     4753
     4754        num_dacs = snd_hda_get_connections(codec, 0x0a,
    42344755                        conn, STAC92HD73_DAC_COUNT + 2) - 1;
    42354756
    4236         if (spec->multiout.num_dacs < 0) {
     4757        if (num_dacs < 3 || num_dacs > 5) {
    42374758                printk(KERN_WARNING "hda_codec: Could not determine "
    42384759                       "number of channels defaulting to DAC count\n");
    4239                 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
    4240         }
    4241 
    4242         switch (spec->multiout.num_dacs) {
     4760                num_dacs = STAC92HD73_DAC_COUNT;
     4761        }
     4762        switch (num_dacs) {
    42434763        case 0x3: /* 6 Channel */
    42444764                spec->mixer = stac92hd73xx_6ch_mixer;
    42454765                spec->init = stac92hd73xx_6ch_core_init;
     4766                spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
    42464767                break;
    42474768        case 0x4: /* 8 Channel */
    42484769                spec->mixer = stac92hd73xx_8ch_mixer;
    42494770                spec->init = stac92hd73xx_8ch_core_init;
     4771                spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
    42504772                break;
    42514773        case 0x5: /* 10 Channel */
    42524774                spec->mixer = stac92hd73xx_10ch_mixer;
    42534775                spec->init = stac92hd73xx_10ch_core_init;
    4254         };
    4255 
    4256         spec->multiout.dac_nids = stac92hd73xx_dac_nids;
     4776                spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
     4777                break;
     4778        }
     4779        spec->multiout.dac_nids = spec->dac_nids;
     4780
    42574781        spec->aloopback_mask = 0x01;
    42584782        spec->aloopback_shift = 8;
     
    42774801                spec->init = dell_eq_core_init;
    42784802                /* fallthru */
    4279         case STAC_DELL_M6:
     4803        case STAC_DELL_M6_AMIC:
     4804        case STAC_DELL_M6_DMIC:
     4805        case STAC_DELL_M6_BOTH:
    42804806                spec->num_smuxes = 0;
    42814807                spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
    42824808                spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
     4809                spec->eapd_switch = 0;
    42834810                spec->num_amps = 1;
    42844811
    4285                 if (!spec->init)
     4812                if (spec->board_config != STAC_DELL_EQ)
    42864813                        spec->init = dell_m6_core_init;
    4287                 switch (codec->subsystem_id) {
    4288                 case 0x1028025e: /* Analog Mics */
    4289                 case 0x1028025f:
    4290                         stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
     4814                switch (spec->board_config) {
     4815                case STAC_DELL_M6_AMIC: /* Analog Mics */
     4816                        snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
    42914817                        spec->num_dmics = 0;
    42924818                        spec->private_dimux.num_items = 1;
    42934819                        break;
    4294                 case 0x10280271: /* Digital Mics */
    4295                 case 0x10280272:
    4296                 case 0x10280254:
    4297                 case 0x10280255:
    4298                         stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
     4820                case STAC_DELL_M6_DMIC: /* Digital Mics */
     4821                        snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
    42994822                        spec->num_dmics = 1;
    43004823                        spec->private_dimux.num_items = 2;
    43014824                        break;
    4302                 case 0x10280256: /* Both */
    4303                 case 0x10280057:
    4304                         stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
    4305                         stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
     4825                case STAC_DELL_M6_BOTH: /* Both */
     4826                        snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
     4827                        snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
    43064828                        spec->num_dmics = 1;
    43074829                        spec->private_dimux.num_items = 2;
     
    43124834                spec->num_dmics = STAC92HD73XX_NUM_DMICS;
    43134835                spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
     4836                spec->eapd_switch = 1;
    43144837        }
    43154838        if (spec->board_config > STAC_92HD73XX_REF) {
     
    43404863        }
    43414864
     4865        if (spec->board_config == STAC_92HD73XX_NO_JD)
     4866                spec->hp_detect = 0;
     4867
    43424868        codec->patch_ops = stac92xx_patch_ops;
     4869
     4870        codec->proc_widget_hook = stac92hd7x_proc_hook;
    43434871
    43444872        return 0;
     
    43574885{
    43584886        struct sigmatel_spec *spec;
     4887        hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
    43594888        int err;
     4889        int num_dacs;
     4890        hda_nid_t nid;
    43604891
    43614892        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    43714902        spec->adc_nids = stac92hd83xxx_adc_nids;
    43724903        spec->pwr_nids = stac92hd83xxx_pwr_nids;
     4904        spec->amp_nids = stac92hd83xxx_amp_nids;
    43734905        spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
    43744906        spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
    4375         spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
     4907        spec->multiout.dac_nids = spec->dac_nids;
    43764908
    43774909        spec->init = stac92hd83xxx_core_init;
    4378         switch (codec->vendor_id) {
    4379         case 0x111d7605:
    4380                 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
    4381                 break;
    4382         default:
    4383                 spec->num_pwrs--;
    4384                 spec->init++; /* switch to config #2 */
    4385                 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
    4386         }
    4387 
    43884910        spec->mixer = stac92hd83xxx_mixer;
    43894911        spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
    43904912        spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
    43914913        spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
     4914        spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
    43924915        spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
    43934916        spec->dinput_mux = &stac92hd83xxx_dmux;
     
    43984921                                                        stac92hd83xxx_cfg_tbl);
    43994922again:
    4400         if (spec->board_config < 0) {
     4923        if (spec->board_config < 0)
    44014924                snd_printdd(KERN_INFO "hda_codec: Unknown model for"
    44024925                        " STAC92HD83XXX, using BIOS defaults\n");
    4403                 err = stac92xx_save_bios_config_regs(codec);
    4404                 if (err < 0) {
    4405                         stac92xx_free(codec);
    4406                         return err;
    4407                 }
    4408                 spec->pin_configs = spec->bios_pin_configs;
    4409         } else {
    4410                 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
    4411                 stac92xx_set_config_regs(codec);
     4926        else
     4927                stac92xx_set_config_regs(codec,
     4928                                stac92hd83xxx_brd_tbl[spec->board_config]);
     4929
     4930        switch (codec->vendor_id) {
     4931        case 0x111d7604:
     4932        case 0x111d7605:
     4933        case 0x111d76d5:
     4934                if (spec->board_config == STAC_92HD83XXX_PWR_REF)
     4935                        break;
     4936                spec->num_pwrs = 0;
     4937                break;
    44124938        }
    44134939
     
    44284954        }
    44294955
     4956        switch (spec->board_config) {
     4957        case STAC_DELL_S14:
     4958                nid = 0xf;
     4959                break;
     4960        default:
     4961                nid = 0xe;
     4962                break;
     4963        }
     4964
     4965        num_dacs = snd_hda_get_connections(codec, nid,
     4966                                conn, STAC92HD83_DAC_COUNT + 1) - 1;
     4967
     4968        /* set port X to select the last DAC
     4969         */
     4970        snd_hda_codec_write_cache(codec, nid, 0,
     4971                        AC_VERB_SET_CONNECT_SEL, num_dacs);
     4972
    44304973        codec->patch_ops = stac92xx_patch_ops;
    44314974
     4975        codec->proc_widget_hook = stac92hd_proc_hook;
     4976
    44324977        return 0;
    44334978}
    44344979
    4435 #ifdef SND_HDA_NEEDS_RESUME
    4436 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
    4437 {
    4438         struct sigmatel_spec *spec = codec->spec;
    4439         int i;
    4440         snd_hda_codec_write_cache(codec, codec->afg, 0,
    4441                 AC_VERB_SET_POWER_STATE, pwr);
    4442 
    4443         msleep(1);
    4444         for (i = 0; i < spec->num_adcs; i++) {
    4445                 snd_hda_codec_write_cache(codec,
    4446                         spec->adc_nids[i], 0,
    4447                         AC_VERB_SET_POWER_STATE, pwr);
    4448         }
    4449 };
    4450 
    4451 static int stac92hd71xx_resume(struct hda_codec *codec)
    4452 {
    4453         stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
    4454         return stac92xx_resume(codec);
    4455 }
    4456 
    4457 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
    4458 {
    4459         stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
    4460         return 0;
    4461 };
    4462 
    4463 #endif
    4464 
    4465 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
    4466         .build_controls = stac92xx_build_controls,
    4467         .build_pcms = stac92xx_build_pcms,
    4468         .init = stac92xx_init,
    4469         .free = stac92xx_free,
    4470         .unsol_event = stac92xx_unsol_event,
    4471 #ifdef SND_HDA_NEEDS_RESUME
    4472         .resume = stac92hd71xx_resume,
    4473         .suspend = stac92hd71xx_suspend,
    4474 #endif
    4475 };
    4476 
    4477 static struct hda_input_mux stac92hd71bxx_dmux = {
     4980static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
     4981        .num_items = 3,
     4982        .items = {
     4983                { "Analog Inputs", 0x00 },
     4984                { "Digital Mic 1", 0x02 },
     4985                { "Digital Mic 2", 0x03 },
     4986        }
     4987};
     4988
     4989static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
    44784990        .num_items = 4,
    44794991        .items = {
     
    44854997};
    44864998
     4999/* get the pin connection (fixed, none, etc) */
     5000static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
     5001{
     5002        struct sigmatel_spec *spec = codec->spec;
     5003        unsigned int cfg;
     5004
     5005        cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
     5006        return get_defcfg_connect(cfg);
     5007}
     5008
     5009static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
     5010                                         hda_nid_t *nids, int num_nids)
     5011{
     5012        struct sigmatel_spec *spec = codec->spec;
     5013        int idx, num;
     5014        unsigned int def_conf;
     5015
     5016        for (num = 0; num < num_nids; num++) {
     5017                for (idx = 0; idx < spec->num_pins; idx++)
     5018                        if (spec->pin_nids[idx] == nids[num])
     5019                                break;
     5020                if (idx >= spec->num_pins)
     5021                        break;
     5022                def_conf = stac_get_defcfg_connect(codec, idx);
     5023                if (def_conf == AC_JACK_PORT_NONE)
     5024                        break;
     5025        }
     5026        return num;
     5027}
     5028
     5029static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
     5030                                          hda_nid_t dig0pin)
     5031{
     5032        struct sigmatel_spec *spec = codec->spec;
     5033        int idx;
     5034
     5035        for (idx = 0; idx < spec->num_pins; idx++)
     5036                if (spec->pin_nids[idx] == dig0pin)
     5037                        break;
     5038        if ((idx + 2) >= spec->num_pins)
     5039                return 0;
     5040
     5041        /* dig1pin case */
     5042        if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
     5043                return 2;
     5044
     5045        /* dig0pin + dig2pin case */
     5046        if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
     5047                return 2;
     5048        if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
     5049                return 1;
     5050        else
     5051                return 0;
     5052}
     5053
    44875054static int patch_stac92hd71bxx(struct hda_codec *codec)
    44885055{
    44895056        struct sigmatel_spec *spec;
     5057        struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
    44905058        int err = 0;
     5059        unsigned int ndmic_nids = 0;
    44915060
    44925061        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
     
    44965065        codec->spec = spec;
    44975066        codec->patch_ops = stac92xx_patch_ops;
    4498         spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
     5067        spec->num_pins = STAC92HD71BXX_NUM_PINS;
     5068        switch (codec->vendor_id) {
     5069        case 0x111d76b6:
     5070        case 0x111d76b7:
     5071                spec->pin_nids = stac92hd71bxx_pin_nids_4port;
     5072                break;
     5073        case 0x111d7603:
     5074        case 0x111d7608:
     5075                /* On 92HD75Bx 0x27 isn't a pin nid */
     5076                spec->num_pins--;
     5077                /* fallthrough */
     5078        default:
     5079                spec->pin_nids = stac92hd71bxx_pin_nids_6port;
     5080        }
    44995081        spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
    4500         spec->pin_nids = stac92hd71bxx_pin_nids;
    4501         memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
    4502                         sizeof(stac92hd71bxx_dmux));
    45035082        spec->board_config = snd_hda_check_board_config(codec,
    45045083                                                        STAC_92HD71BXX_MODELS,
     
    45065085                                                        stac92hd71bxx_cfg_tbl);
    45075086again:
    4508         if (spec->board_config < 0) {
     5087        if (spec->board_config < 0)
    45095088                snd_printdd(KERN_INFO "hda_codec: Unknown model for"
    45105089                        " STAC92HD71BXX, using BIOS defaults\n");
    4511                 err = stac92xx_save_bios_config_regs(codec);
    4512                 if (err < 0) {
    4513                         stac92xx_free(codec);
    4514                         return err;
    4515                 }
    4516                 spec->pin_configs = spec->bios_pin_configs;
    4517         } else {
    4518                 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
    4519                 stac92xx_set_config_regs(codec);
    4520         }
    4521 
    4522         switch (codec->vendor_id) {
    4523         case 0x111d76b6: /* 4 Port without Analog Mixer */
    4524         case 0x111d76b7:
    4525         case 0x111d76b4: /* 6 Port without Analog Mixer */
    4526         case 0x111d76b5:
    4527                 spec->mixer = stac92hd71bxx_mixer;
    4528                 spec->init = stac92hd71bxx_core_init;
    4529                 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
    4530                 break;
    4531         case 0x111d7608: /* 5 Port with Analog Mixer */
    4532                 switch (codec->subsystem_id) {
    4533                 case 0x103c361a:
    4534                         /* Enable VREF power saving on GPIO1 detect */
    4535                         snd_hda_codec_write(codec, codec->afg, 0,
    4536                                 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
    4537                         snd_hda_codec_write_cache(codec, codec->afg, 0,
    4538                                 AC_VERB_SET_UNSOLICITED_ENABLE,
    4539                                 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
    4540                         err = stac92xx_add_event(spec, codec->afg, 0x02);
    4541                         if (err < 0)
    4542                                 return err;
    4543                         spec->gpio_mask |= 0x02;
    4544                         break;
    4545                 }
    4546                 if ((codec->revision_id & 0xf) == 0 ||
    4547                                 (codec->revision_id & 0xf) == 1) {
    4548 #ifdef SND_HDA_NEEDS_RESUME
    4549                         codec->patch_ops = stac92hd71bxx_patch_ops;
    4550 #endif
    4551                         spec->stream_delay = 40; /* 40 milliseconds */
    4552                 }
    4553 
    4554                 /* no output amps */
    4555                 spec->num_pwrs = 0;
    4556                 spec->mixer = stac92hd71bxx_analog_mixer;
    4557                 spec->dinput_mux = &spec->private_dimux;
    4558 
    4559                 /* disable VSW */
    4560                 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
    4561                 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
    4562                 break;
    4563         case 0x111d7603: /* 6 Port with Analog Mixer */
    4564                 if ((codec->revision_id & 0xf) == 1) {
    4565 #ifdef SND_HDA_NEEDS_RESUME
    4566                         codec->patch_ops = stac92hd71bxx_patch_ops;
    4567 #endif
    4568                         spec->stream_delay = 40; /* 40 milliseconds */
    4569                 }
    4570 
    4571                 /* no output amps */
    4572                 spec->num_pwrs = 0;
    4573                 /* fallthru */
    4574         default:
    4575                 spec->dinput_mux = &spec->private_dimux;
    4576                 spec->mixer = stac92hd71bxx_analog_mixer;
    4577                 spec->init = stac92hd71bxx_analog_core_init;
    4578                 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
    4579         }
    4580 
    4581         spec->aloopback_mask = 0x50;
    4582         spec->aloopback_shift = 0;
     5090        else
     5091                stac92xx_set_config_regs(codec,
     5092                                stac92hd71bxx_brd_tbl[spec->board_config]);
    45835093
    45845094        if (spec->board_config > STAC_92HD71BXX_REF) {
     
    45895099        }
    45905100
     5101        spec->dmic_nids = stac92hd71bxx_dmic_nids;
     5102        spec->dmux_nids = stac92hd71bxx_dmux_nids;
     5103
     5104        switch (codec->vendor_id) {
     5105        case 0x111d76b6: /* 4 Port without Analog Mixer */
     5106        case 0x111d76b7:
     5107                unmute_init++;
     5108                /* fallthru */
     5109        case 0x111d76b4: /* 6 Port without Analog Mixer */
     5110        case 0x111d76b5:
     5111                memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
     5112                       sizeof(stac92hd71bxx_dmux_nomixer));
     5113                spec->mixer = stac92hd71bxx_mixer;
     5114                spec->init = stac92hd71bxx_core_init;
     5115                codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
     5116                spec->num_dmics = stac92hd71bxx_connected_ports(codec,
     5117                                        stac92hd71bxx_dmic_nids,
     5118                                        STAC92HD71BXX_NUM_DMICS);
     5119                if (spec->num_dmics) {
     5120                        spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
     5121                        spec->dinput_mux = &spec->private_dimux;
     5122                        ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
     5123                }
     5124                break;
     5125        case 0x111d7608: /* 5 Port with Analog Mixer */
     5126                memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
     5127                       sizeof(stac92hd71bxx_dmux_amixer));
     5128                spec->private_dimux.num_items--;
     5129                switch (spec->board_config) {
     5130                case STAC_HP_M4:
     5131                        /* Enable VREF power saving on GPIO1 detect */
     5132                        err = stac_add_event(spec, codec->afg,
     5133                                             STAC_VREF_EVENT, 0x02);
     5134                        if (err < 0)
     5135                                return err;
     5136                        snd_hda_codec_write_cache(codec, codec->afg, 0,
     5137                                AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
     5138                        snd_hda_codec_write_cache(codec, codec->afg, 0,
     5139                                AC_VERB_SET_UNSOLICITED_ENABLE,
     5140                                AC_USRSP_EN | err);
     5141                        spec->gpio_mask |= 0x02;
     5142                        break;
     5143                }
     5144                if ((codec->revision_id & 0xf) == 0 ||
     5145                    (codec->revision_id & 0xf) == 1)
     5146                        spec->stream_delay = 40; /* 40 milliseconds */
     5147
     5148                /* no output amps */
     5149                spec->num_pwrs = 0;
     5150                spec->mixer = stac92hd71bxx_analog_mixer;
     5151                spec->dinput_mux = &spec->private_dimux;
     5152
     5153                /* disable VSW */
     5154                spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
     5155                unmute_init++;
     5156                snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
     5157                snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
     5158                stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
     5159                spec->num_dmics = stac92hd71bxx_connected_ports(codec,
     5160                                        stac92hd71bxx_dmic_nids,
     5161                                        STAC92HD71BXX_NUM_DMICS - 1);
     5162                spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
     5163                ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
     5164                break;
     5165        case 0x111d7603: /* 6 Port with Analog Mixer */
     5166                if ((codec->revision_id & 0xf) == 1)
     5167                        spec->stream_delay = 40; /* 40 milliseconds */
     5168
     5169                /* no output amps */
     5170                spec->num_pwrs = 0;
     5171                /* fallthru */
     5172        default:
     5173                memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
     5174                       sizeof(stac92hd71bxx_dmux_amixer));
     5175                spec->dinput_mux = &spec->private_dimux;
     5176                spec->mixer = stac92hd71bxx_analog_mixer;
     5177                spec->init = stac92hd71bxx_analog_core_init;
     5178                codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
     5179                spec->num_dmics = stac92hd71bxx_connected_ports(codec,
     5180                                        stac92hd71bxx_dmic_nids,
     5181                                        STAC92HD71BXX_NUM_DMICS);
     5182                spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
     5183                ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
     5184        }
     5185
     5186        if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
     5187                snd_hda_sequence_write_cache(codec, unmute_init);
     5188
     5189        spec->aloopback_ctl = stac92hd71bxx_loopback;
     5190        spec->aloopback_mask = 0x50;
     5191        spec->aloopback_shift = 0;
     5192
    45915193        spec->powerdown_adcs = 1;
    45925194        spec->digbeep_nid = 0x26;
    45935195        spec->mux_nids = stac92hd71bxx_mux_nids;
    45945196        spec->adc_nids = stac92hd71bxx_adc_nids;
    4595         spec->dmic_nids = stac92hd71bxx_dmic_nids;
    4596         spec->dmux_nids = stac92hd71bxx_dmux_nids;
    45975197        spec->smux_nids = stac92hd71bxx_smux_nids;
    45985198        spec->pwr_nids = stac92hd71bxx_pwr_nids;
     
    46005200        spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
    46015201        spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
     5202        spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
    46025203
    46035204        switch (spec->board_config) {
    46045205        case STAC_HP_M4:
     5206                /* enable internal microphone */
     5207                snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
     5208                stac92xx_auto_set_pinctl(codec, 0x0e,
     5209                        AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
     5210                /* fallthru */
     5211        case STAC_DELL_M4_2:
    46055212                spec->num_dmics = 0;
    46065213                spec->num_smuxes = 0;
    46075214                spec->num_dmuxes = 0;
    4608 
    4609                 /* enable internal microphone */
    4610                 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
    4611                 stac92xx_auto_set_pinctl(codec, 0x0e,
    4612                         AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
    46135215                break;
    4614         default:
    4615                 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
    4616                 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
    4617                 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
     5216        case STAC_DELL_M4_1:
     5217        case STAC_DELL_M4_3:
     5218                spec->num_dmics = 1;
     5219                spec->num_smuxes = 0;
     5220                spec->num_dmuxes = 1;
     5221                break;
     5222        case STAC_HP_DV5:
     5223                snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
     5224                stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
     5225                break;
     5226        case STAC_HP_HDX:
     5227                spec->num_dmics = 1;
     5228                spec->num_dmuxes = 1;
     5229                spec->num_smuxes = 1;
     5230                /*
     5231                 * For controlling MUTE LED on HP HDX16/HDX18 notebooks,
     5232                 * the CONFIG_SND_HDA_POWER_SAVE is needed to be set.
     5233                 */
     5234#ifdef CONFIG_SND_HDA_POWER_SAVE
     5235                /* orange/white mute led on GPIO3, orange=0, white=1 */
     5236                spec->gpio_mask |= 0x08;
     5237                spec->gpio_dir  |= 0x08;
     5238                spec->gpio_data |= 0x08;  /* set to white */
     5239
     5240                /* register check_power_status callback. */
     5241                codec->patch_ops.check_power_status =
     5242                    stac92xx_hp_hdx_check_power_status;
     5243#endif 
     5244                break;
    46185245        };
    46195246
    4620         spec->multiout.num_dacs = 1;
    4621         spec->multiout.hp_nid = 0x11;
    4622         spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
     5247        spec->multiout.dac_nids = spec->dac_nids;
    46235248        if (spec->dinput_mux)
    4624                 spec->private_dimux.num_items +=
    4625                         spec->num_dmics -
    4626                                 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
    4627 
    4628         err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
     5249                spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
     5250
     5251        err = stac92xx_parse_auto_config(codec, 0x21, 0);
    46295252        if (!err) {
    46305253                if (spec->board_config < 0) {
     
    46415264                return err;
    46425265        }
     5266
     5267        codec->proc_widget_hook = stac92hd7x_proc_hook;
    46435268
    46445269        return 0;
     
    46995324
    47005325 again:
    4701         if (spec->board_config < 0) {
     5326        if (spec->board_config < 0)
    47025327                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
    47035328                        "using BIOS defaults\n");
    4704                 err = stac92xx_save_bios_config_regs(codec);
    4705                 if (err < 0) {
    4706                         stac92xx_free(codec);
    4707                         return err;
    4708                 }
    4709                 spec->pin_configs = spec->bios_pin_configs;
    4710         } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
    4711                 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
    4712                 stac92xx_set_config_regs(codec);
    4713         }
     5329        else
     5330                stac92xx_set_config_regs(codec,
     5331                                stac922x_brd_tbl[spec->board_config]);
    47145332
    47155333        spec->adc_nids = stac922x_adc_nids;
     
    47625380
    47635381        codec->spec = spec;
     5382        codec->slave_dig_outs = stac927x_slave_dig_outs;
    47645383        spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
    47655384        spec->pin_nids = stac927x_pin_nids;
     
    47685387                                                        stac927x_cfg_tbl);
    47695388 again:
    4770         if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
    4771                 if (spec->board_config < 0)
    4772                         snd_printdd(KERN_INFO "hda_codec: Unknown model for"
    4773                                     "STAC927x, using BIOS defaults\n");
    4774                 err = stac92xx_save_bios_config_regs(codec);
    4775                 if (err < 0) {
    4776                         stac92xx_free(codec);
    4777                         return err;
    4778                 }
    4779                 spec->pin_configs = spec->bios_pin_configs;
    4780         } else {
    4781                 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
    4782                 stac92xx_set_config_regs(codec);
    4783         }
     5389        if (spec->board_config < 0)
     5390                snd_printdd(KERN_INFO "hda_codec: Unknown model for"
     5391                            "STAC927x, using BIOS defaults\n");
     5392        else
     5393                stac92xx_set_config_regs(codec,
     5394                                stac927x_brd_tbl[spec->board_config]);
    47845395
    47855396        spec->digbeep_nid = 0x23;
     
    48105421                case 0x1028022e:
    48115422                        /* correct the device field to SPDIF out */
    4812                         stac92xx_set_config_reg(codec, 0x21, 0x01442070);
     5423                        snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
    48135424                        break;
    48145425                };
    48155426                /* configure the analog microphone on some laptops */
    4816                 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
     5427                snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
    48175428                /* correct the front output jack as a hp out */
    4818                 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
     5429                snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
    48195430                /* correct the front input jack as a mic */
    4820                 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
     5431                snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
    48215432                /* fallthru */
    48225433        case STAC_DELL_3ST:
     
    48455456
    48465457        spec->num_pwrs = 0;
     5458        spec->aloopback_ctl = stac927x_loopback;
    48475459        spec->aloopback_mask = 0x40;
    48485460        spec->aloopback_shift = 0;
     5461        spec->eapd_switch = 1;
    48495462
    48505463        err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
     
    48645477
    48655478        codec->patch_ops = stac92xx_patch_ops;
     5479
     5480        codec->proc_widget_hook = stac927x_proc_hook;
    48665481
    48675482        /*
     
    48775492        codec->bus->needs_damn_long_delay = 1;
    48785493
     5494        /* no jack detecion for ref-no-jd model */
     5495        if (spec->board_config == STAC_D965_REF_NO_JD)
     5496                spec->hp_detect = 0;
     5497
    48795498        return 0;
    48805499}
     
    48965515                                                        stac9205_cfg_tbl);
    48975516 again:
    4898         if (spec->board_config < 0) {
     5517        if (spec->board_config < 0)
    48995518                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
    4900                 err = stac92xx_save_bios_config_regs(codec);
    4901                 if (err < 0) {
    4902                         stac92xx_free(codec);
    4903                         return err;
    4904                 }
    4905                 spec->pin_configs = spec->bios_pin_configs;
    4906         } else {
    4907                 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
    4908                 stac92xx_set_config_regs(codec);
    4909         }
     5519        else
     5520                stac92xx_set_config_regs(codec,
     5521                                         stac9205_brd_tbl[spec->board_config]);
    49105522
    49115523        spec->digbeep_nid = 0x23;
     
    49245536        spec->init = stac9205_core_init;
    49255537        spec->mixer = stac9205_mixer;
     5538        spec->aloopback_ctl = stac9205_loopback;
    49265539
    49275540        spec->aloopback_mask = 0x40;
    49285541        spec->aloopback_shift = 0;
     5542        /* Turn on/off EAPD per HP plugging */
     5543        if (spec->board_config != STAC_9205_EAPD)
     5544                spec->eapd_switch = 1;
    49295545        spec->multiout.dac_nids = spec->dac_nids;
    49305546       
     
    49325548        case STAC_9205_DELL_M43:
    49335549                /* Enable SPDIF in/out */
    4934                 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
    4935                 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
     5550                snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
     5551                snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
    49365552
    49375553                /* Enable unsol response for GPIO4/Dock HP connection */
    4938                 snd_hda_codec_write(codec, codec->afg, 0,
     5554                err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
     5555                if (err < 0)
     5556                        return err;
     5557                snd_hda_codec_write_cache(codec, codec->afg, 0,
    49395558                        AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
    49405559                snd_hda_codec_write_cache(codec, codec->afg, 0,
    4941                         AC_VERB_SET_UNSOLICITED_ENABLE,
    4942                         (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
    4943                 err = stac92xx_add_event(spec, codec->afg, 0x01);
    4944                 if (err < 0)
    4945                         return err;
     5560                                          AC_VERB_SET_UNSOLICITED_ENABLE,
     5561                                          AC_USRSP_EN | err);
    49465562
    49475563                spec->gpio_dir = 0x0b;
     
    49815597        codec->patch_ops = stac92xx_patch_ops;
    49825598
     5599        codec->proc_widget_hook = stac9205_proc_hook;
     5600
    49835601        return 0;
    49845602}
     
    49885606 */
    49895607
    4990 /* static config for Sony VAIO FE550G and Sony VAIO AR */
    4991 static hda_nid_t vaio_dacs[] = { 0x2 };
    4992 #define VAIO_HP_DAC     0x5
    4993 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
    4994 static hda_nid_t vaio_mux_nids[] = { 0x15 };
    4995 
    4996 static struct hda_input_mux vaio_mux = {
    4997         .num_items = 3,
    4998         .items = {
    4999                 /* { "HP", 0x0 }, */
    5000                 { "Mic Jack", 0x1 },
    5001                 { "Internal Mic", 0x2 },
    5002                 { "PCM", 0x3 },
    5003         }
    5004 };
    5005 
    5006 static struct hda_verb vaio_init[] = {
    5007         {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
    5008         {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
    5009         {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
    5010         {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
    5011         {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
    5012         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
     5608static struct hda_verb stac9872_core_init[] = {
    50135609        {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
    5014         {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
    5015         {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
    5016         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
    5017         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
    50185610        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
    50195611        {0}
    50205612};
    50215613
    5022 static struct hda_verb vaio_ar_init[] = {
    5023         {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
    5024         {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
    5025         {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
    5026         {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
    5027 /*      {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
    5028         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
    5029         {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
    5030         {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
    5031         {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
    5032 /*      {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
    5033         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
    5034         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
    5035         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
    5036         {0}
    5037 };
    5038 
    5039 /* bind volumes of both NID 0x02 and 0x05 */
    5040 static struct hda_bind_ctls vaio_bind_master_vol = {
    5041         .ops = &snd_hda_bind_vol,
    5042         .values = {
    5043                 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
    5044                 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
    5045                 0
    5046         },
    5047 };
    5048 
    5049 /* bind volumes of both NID 0x02 and 0x05 */
    5050 static struct hda_bind_ctls vaio_bind_master_sw = {
    5051         .ops = &snd_hda_bind_sw,
    5052         .values = {
    5053                 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
    5054                 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
    5055                 0,
    5056         },
    5057 };
    5058 
    5059 static struct snd_kcontrol_new vaio_mixer[] = {
    5060         HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
    5061         HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
    5062         /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
     5614static struct snd_kcontrol_new stac9872_mixer[] = {
    50635615        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
    50645616        HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
    5065         {
    5066                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5067                 .name = "Capture Source",
    5068                 .count = 1,
    5069                 .info = stac92xx_mux_enum_info,
    5070                 .get = stac92xx_mux_enum_get,
    5071                 .put = stac92xx_mux_enum_put,
    5072         },
    5073         {0}
    5074 };
    5075 
    5076 static struct snd_kcontrol_new vaio_ar_mixer[] = {
    5077         HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
    5078         HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
    5079         /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
    5080         HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
    5081         HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
    5082         /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
    5083         HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
    5084         {
    5085                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    5086                 .name = "Capture Source",
    5087                 .count = 1,
    5088                 .info = stac92xx_mux_enum_info,
    5089                 .get = stac92xx_mux_enum_get,
    5090                 .put = stac92xx_mux_enum_put,
    5091         },
    5092         {0}
    5093 };
    5094 
    5095 static struct hda_codec_ops stac9872_patch_ops = {
    5096         .build_controls = stac92xx_build_controls,
    5097         .build_pcms = stac92xx_build_pcms,
    5098         .init = stac92xx_init,
    5099         .free = stac92xx_free,
    5100 #ifdef SND_HDA_NEEDS_RESUME
    5101         .resume = stac92xx_resume,
    5102 #endif
    5103 };
    5104 
    5105 static int stac9872_vaio_init(struct hda_codec *codec)
    5106 {
     5617        {0} /* end */
     5618};
     5619
     5620static hda_nid_t stac9872_pin_nids[] = {
     5621        0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
     5622        0x11, 0x13, 0x14,
     5623};
     5624
     5625static hda_nid_t stac9872_adc_nids[] = {
     5626        0x8 /*,0x6*/
     5627};
     5628
     5629static hda_nid_t stac9872_mux_nids[] = {
     5630        0x15
     5631};
     5632
     5633static unsigned int stac9872_vaio_pin_configs[9] = {
     5634        0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
     5635        0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
     5636        0x90a7013e
     5637};
     5638
     5639static const char *stac9872_models[STAC_9872_MODELS] = {
     5640        [STAC_9872_AUTO] = "auto",
     5641        [STAC_9872_VAIO] = "vaio",
     5642};
     5643
     5644static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
     5645        [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
     5646};
     5647
     5648static struct snd_pci_quirk stac9872_cfg_tbl[] = {
     5649        {0} /* terminator */
     5650};
     5651
     5652static int patch_stac9872(struct hda_codec *codec)
     5653{
     5654        struct sigmatel_spec *spec;
    51075655        int err;
    51085656
    5109         err = stac92xx_init(codec);
    5110         if (err < 0)
    5111                 return err;
    5112         if (codec->patch_ops.unsol_event)
    5113                 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
    5114         return 0;
    5115 }
    5116 
    5117 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
    5118 {
    5119         if (get_hp_pin_presence(codec, 0x0a)) {
    5120                 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
    5121                 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
    5122         } else {
    5123                 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
    5124                 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
    5125         }
    5126 }
    5127 
    5128 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
    5129 {
    5130         switch (res >> 26) {
    5131         case STAC_HP_EVENT:
    5132                 stac9872_vaio_hp_detect(codec, res);
    5133                 break;
    5134         }
    5135 }
    5136 
    5137 static struct hda_codec_ops stac9872_vaio_patch_ops = {
    5138         .build_controls = stac92xx_build_controls,
    5139         .build_pcms = stac92xx_build_pcms,
    5140         .init = stac9872_vaio_init,
    5141         .free = stac92xx_free,
    5142         .unsol_event = stac9872_vaio_unsol_event,
    5143 #ifdef CONFIG_PM
    5144         .resume = stac92xx_resume,
    5145 #endif
    5146 };
    5147 
    5148 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
    5149        CXD9872RD_VAIO,
    5150        /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
    5151        STAC9872AK_VAIO,
    5152        /* Unknown. id=0x83847661 and subsys=0x104D1200. */
    5153        STAC9872K_VAIO,
    5154        /* AR Series. id=0x83847664 and subsys=104D1300 */
    5155        CXD9872AKD_VAIO,
    5156        STAC_9872_MODELS,
    5157 };
    5158 
    5159 static const char *stac9872_models[STAC_9872_MODELS] = {
    5160         [CXD9872RD_VAIO]        = "vaio",
    5161         [CXD9872AKD_VAIO]       = "vaio-ar",
    5162 };
    5163 
    5164 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
    5165         SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
    5166         SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
    5167         SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
    5168         SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
    5169         {0}
    5170 };
    5171 
    5172 static int patch_stac9872(struct hda_codec *codec)
    5173 {
    5174         struct sigmatel_spec *spec;
    5175         int board_config;
    5176 
    5177         board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
    5178                                                   stac9872_models,
    5179                                                   stac9872_cfg_tbl);
    5180         if (board_config < 0)
    5181                 /* unknown config, let generic-parser do its job... */
    5182                 return snd_hda_parse_generic_codec(codec);
    5183        
    51845657        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
    51855658        if (spec == NULL)
    51865659                return -ENOMEM;
    5187 
    51885660        codec->spec = spec;
    5189         switch (board_config) {
    5190         case CXD9872RD_VAIO:
    5191         case STAC9872AK_VAIO:
    5192         case STAC9872K_VAIO:
    5193                 spec->mixer = vaio_mixer;
    5194                 spec->init = vaio_init;
    5195                 spec->multiout.max_channels = 2;
    5196                 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
    5197                 spec->multiout.dac_nids = vaio_dacs;
    5198                 spec->multiout.hp_nid = VAIO_HP_DAC;
    5199                 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
    5200                 spec->adc_nids = vaio_adcs;
    5201                 spec->num_pwrs = 0;
    5202                 spec->input_mux = &vaio_mux;
    5203                 spec->mux_nids = vaio_mux_nids;
    5204                 codec->patch_ops = stac9872_vaio_patch_ops;
    5205                 break;
    5206        
    5207         case CXD9872AKD_VAIO:
    5208                 spec->mixer = vaio_ar_mixer;
    5209                 spec->init = vaio_ar_init;
    5210                 spec->multiout.max_channels = 2;
    5211                 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
    5212                 spec->multiout.dac_nids = vaio_dacs;
    5213                 spec->multiout.hp_nid = VAIO_HP_DAC;
    5214                 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
    5215                 spec->num_pwrs = 0;
    5216                 spec->adc_nids = vaio_adcs;
    5217                 spec->input_mux = &vaio_mux;
    5218                 spec->mux_nids = vaio_mux_nids;
    5219                 codec->patch_ops = stac9872_patch_ops;
    5220                 break;
    5221         }
    5222 
     5661
     5662        spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
     5663                                                        stac9872_models,
     5664                                                        stac9872_cfg_tbl);
     5665        if (spec->board_config < 0)
     5666                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
     5667                            "using BIOS defaults\n");
     5668        else
     5669                stac92xx_set_config_regs(codec,
     5670                                         stac9872_brd_tbl[spec->board_config]);
     5671
     5672        spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
     5673        spec->pin_nids = stac9872_pin_nids;
     5674        spec->multiout.dac_nids = spec->dac_nids;
     5675        spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
     5676        spec->adc_nids = stac9872_adc_nids;
     5677        spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
     5678        spec->mux_nids = stac9872_mux_nids;
     5679        spec->mixer = stac9872_mixer;
     5680        spec->init = stac9872_core_init;
     5681
     5682        err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
     5683        if (err < 0) {
     5684                stac92xx_free(codec);
     5685                return -EINVAL;
     5686        }
     5687        spec->input_mux = &spec->private_imux;
     5688        codec->patch_ops = stac92xx_patch_ops;
    52235689        return 0;
    52245690}
     
    52285694 * patch entries
    52295695 */
    5230 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
     5696static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
    52315697        { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
    52325698        { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
     
    52785744        { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
    52795745        { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
     5746        { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
    52805747        { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
    52815748        { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
     
    52925759        {0} /* terminator */
    52935760};
     5761
     5762MODULE_ALIAS("snd-hda-codec-id:8384*");
     5763MODULE_ALIAS("snd-hda-codec-id:111d*");
     5764
     5765MODULE_LICENSE("GPL");
     5766MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
     5767
     5768static struct hda_codec_preset_list sigmatel_list = {
     5769        .preset = snd_hda_preset_sigmatel,
     5770        .owner = THIS_MODULE,
     5771};
     5772
     5773static int __init patch_sigmatel_init(void)
     5774{
     5775        return snd_hda_add_codec_preset(&sigmatel_list);
     5776}
     5777
     5778static void __exit patch_sigmatel_exit(void)
     5779{
     5780        snd_hda_delete_codec_preset(&sigmatel_list);
     5781}
     5782
     5783module_init(patch_sigmatel_init)
     5784module_exit(patch_sigmatel_exit)
  • GPL/trunk/alsa-kernel/pci/hda/patch_via.c

    r417 r426  
    4848#include "hda_codec.h"
    4949#include "hda_local.h"
    50 #include "hda_patch.h"
    5150
    5251/* amp values */
     
    142141        AUTO_SEQ_SIDE
    143142};
    144 
    145 #define get_amp_nid(kc) ((kc)->private_value & 0xffff)
    146143
    147144/* Some VT1708S based boards gets the micboost setting wrong, so we have
     
    13121309        unsigned char seqassoc;
    13131310
    1314         def_conf = snd_hda_codec_read(codec, nid, 0,
    1315                                       AC_VERB_GET_CONFIG_DEFAULT, 0);
     1311        def_conf = snd_hda_codec_get_pincfg(codec, nid);
    13161312        seqassoc = (unsigned char) get_defcfg_association(def_conf);
    13171313        seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf);
     
    13191315                if (seqassoc == 0xff) {
    13201316                        def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30));
    1321                         snd_hda_codec_write(codec, nid, 0,
    1322                                             AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
    1323                                             def_conf >> 24);
     1317                        snd_hda_codec_set_pincfg(codec, nid, def_conf);
    13241318                }
    13251319        }
     
    13581352        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    13591353
    1360         if (spec->autocfg.dig_out_pin)
     1354        if (spec->autocfg.dig_outs)
    13611355                spec->multiout.dig_out_nid = VT1708_DIGOUT_NID;
    13621356        if (spec->autocfg.dig_in_pin)
     
    18311825        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    18321826
    1833         if (spec->autocfg.dig_out_pin)
     1827        if (spec->autocfg.dig_outs)
    18341828                spec->multiout.dig_out_nid = VT1709_DIGOUT_NID;
    18351829        if (spec->autocfg.dig_in_pin)
     
    23792373        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    23802374
    2381         if (spec->autocfg.dig_out_pin)
     2375        if (spec->autocfg.dig_outs)
    23822376                spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID;
    23832377        if (spec->autocfg.dig_in_pin)
     
    28412835        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    28422836
    2843         if (spec->autocfg.dig_out_pin)
     2837        if (spec->autocfg.dig_outs)
    28442838                spec->multiout.dig_out_nid = VT1708S_DIGOUT_NID;
    28452839
     
    31603154        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
    31613155
    3162         if (spec->autocfg.dig_out_pin)
     3156        if (spec->autocfg.dig_outs)
    31633157                spec->multiout.dig_out_nid = VT1702_DIGOUT_NID;
    31643158
     
    32533247 * patch entries
    32543248 */
    3255 struct hda_codec_preset snd_hda_preset_via[] = {
    3256         { .id = 0x11061708, .name = "VIA VT1708", .patch = patch_vt1708},
    3257         { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708},
    3258         { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708},
    3259         { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708},
    3260         { .id = 0x1106E710, .name = "VIA VT1709 10-Ch",
     3249static struct hda_codec_preset snd_hda_preset_via[] = {
     3250        { .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708},
     3251        { .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708},
     3252        { .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708},
     3253        { .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708},
     3254        { .id = 0x1106e710, .name = "VT1709 10-Ch",
    32613255          .patch = patch_vt1709_10ch},
    3262         { .id = 0x1106E711, .name = "VIA VT1709 10-Ch",
     3256        { .id = 0x1106e711, .name = "VT1709 10-Ch",
    32633257          .patch = patch_vt1709_10ch},
    3264         { .id = 0x1106E712, .name = "VIA VT1709 10-Ch",
     3258        { .id = 0x1106e712, .name = "VT1709 10-Ch",
    32653259          .patch = patch_vt1709_10ch},
    3266         { .id = 0x1106E713, .name = "VIA VT1709 10-Ch",
     3260        { .id = 0x1106e713, .name = "VT1709 10-Ch",
    32673261          .patch = patch_vt1709_10ch},
    3268         { .id = 0x1106E714, .name = "VIA VT1709 6-Ch",
     3262        { .id = 0x1106e714, .name = "VT1709 6-Ch",
    32693263          .patch = patch_vt1709_6ch},
    3270         { .id = 0x1106E715, .name = "VIA VT1709 6-Ch",
     3264        { .id = 0x1106e715, .name = "VT1709 6-Ch",
    32713265          .patch = patch_vt1709_6ch},
    3272         { .id = 0x1106E716, .name = "VIA VT1709 6-Ch",
     3266        { .id = 0x1106e716, .name = "VT1709 6-Ch",
    32733267          .patch = patch_vt1709_6ch},
    3274         { .id = 0x1106E717, .name = "VIA VT1709 6-Ch",
     3268        { .id = 0x1106e717, .name = "VT1709 6-Ch",
    32753269          .patch = patch_vt1709_6ch},
    3276         { .id = 0x1106E720, .name = "VIA VT1708B 8-Ch",
     3270        { .id = 0x1106e720, .name = "VT1708B 8-Ch",
    32773271          .patch = patch_vt1708B_8ch},
    3278         { .id = 0x1106E721, .name = "VIA VT1708B 8-Ch",
     3272        { .id = 0x1106e721, .name = "VT1708B 8-Ch",
    32793273          .patch = patch_vt1708B_8ch},
    3280         { .id = 0x1106E722, .name = "VIA VT1708B 8-Ch",
     3274        { .id = 0x1106e722, .name = "VT1708B 8-Ch",
    32813275          .patch = patch_vt1708B_8ch},
    3282         { .id = 0x1106E723, .name = "VIA VT1708B 8-Ch",
     3276        { .id = 0x1106e723, .name = "VT1708B 8-Ch",
    32833277          .patch = patch_vt1708B_8ch},
    3284         { .id = 0x1106E724, .name = "VIA VT1708B 4-Ch",
     3278        { .id = 0x1106e724, .name = "VT1708B 4-Ch",
    32853279          .patch = patch_vt1708B_4ch},
    3286         { .id = 0x1106E725, .name = "VIA VT1708B 4-Ch",
     3280        { .id = 0x1106e725, .name = "VT1708B 4-Ch",
    32873281          .patch = patch_vt1708B_4ch},
    3288         { .id = 0x1106E726, .name = "VIA VT1708B 4-Ch",
     3282        { .id = 0x1106e726, .name = "VT1708B 4-Ch",
    32893283          .patch = patch_vt1708B_4ch},
    3290         { .id = 0x1106E727, .name = "VIA VT1708B 4-Ch",
     3284        { .id = 0x1106e727, .name = "VT1708B 4-Ch",
    32913285          .patch = patch_vt1708B_4ch},
    3292         { .id = 0x11060397, .name = "VIA VT1708S",
     3286        { .id = 0x11060397, .name = "VT1708S",
    32933287          .patch = patch_vt1708S},
    3294         { .id = 0x11061397, .name = "VIA VT1708S",
     3288        { .id = 0x11061397, .name = "VT1708S",
    32953289          .patch = patch_vt1708S},
    3296         { .id = 0x11062397, .name = "VIA VT1708S",
     3290        { .id = 0x11062397, .name = "VT1708S",
    32973291          .patch = patch_vt1708S},
    3298         { .id = 0x11063397, .name = "VIA VT1708S",
     3292        { .id = 0x11063397, .name = "VT1708S",
    32993293          .patch = patch_vt1708S},
    3300         { .id = 0x11064397, .name = "VIA VT1708S",
     3294        { .id = 0x11064397, .name = "VT1708S",
    33013295          .patch = patch_vt1708S},
    3302         { .id = 0x11065397, .name = "VIA VT1708S",
     3296        { .id = 0x11065397, .name = "VT1708S",
    33033297          .patch = patch_vt1708S},
    3304         { .id = 0x11066397, .name = "VIA VT1708S",
     3298        { .id = 0x11066397, .name = "VT1708S",
    33053299          .patch = patch_vt1708S},
    3306         { .id = 0x11067397, .name = "VIA VT1708S",
     3300        { .id = 0x11067397, .name = "VT1708S",
    33073301          .patch = patch_vt1708S},
    3308         { .id = 0x11060398, .name = "VIA VT1702",
     3302        { .id = 0x11060398, .name = "VT1702",
    33093303          .patch = patch_vt1702},
    3310         { .id = 0x11061398, .name = "VIA VT1702",
     3304        { .id = 0x11061398, .name = "VT1702",
    33113305          .patch = patch_vt1702},
    3312         { .id = 0x11062398, .name = "VIA VT1702",
     3306        { .id = 0x11062398, .name = "VT1702",
    33133307          .patch = patch_vt1702},
    3314         { .id = 0x11063398, .name = "VIA VT1702",
     3308        { .id = 0x11063398, .name = "VT1702",
    33153309          .patch = patch_vt1702},
    3316         { .id = 0x11064398, .name = "VIA VT1702",
     3310        { .id = 0x11064398, .name = "VT1702",
    33173311          .patch = patch_vt1702},
    3318         { .id = 0x11065398, .name = "VIA VT1702",
     3312        { .id = 0x11065398, .name = "VT1702",
    33193313          .patch = patch_vt1702},
    3320         { .id = 0x11066398, .name = "VIA VT1702",
     3314        { .id = 0x11066398, .name = "VT1702",
    33213315          .patch = patch_vt1702},
    3322         { .id = 0x11067398, .name = "VIA VT1702",
     3316        { .id = 0x11067398, .name = "VT1702",
    33233317          .patch = patch_vt1702},
    33243318        {0} /* terminator */
    33253319};
     3320
     3321MODULE_ALIAS("snd-hda-codec-id:1106*");
     3322
     3323static struct hda_codec_preset_list via_list = {
     3324        .preset = snd_hda_preset_via,
     3325        .owner = THIS_MODULE,
     3326};
     3327
     3328MODULE_LICENSE("GPL");
     3329MODULE_DESCRIPTION("VIA HD-audio codec");
     3330
     3331static int __init patch_via_init(void)
     3332{
     3333        return snd_hda_add_codec_preset(&via_list);
     3334}
     3335
     3336static void __exit patch_via_exit(void)
     3337{
     3338        snd_hda_delete_codec_preset(&via_list);
     3339}
     3340
     3341module_init(patch_via_init)
     3342module_exit(patch_via_exit)
  • GPL/trunk/alsa-kernel/pci/intel8x0.c

    r410 r426  
    358358        unsigned int position;
    359359        unsigned int pos_shift;
     360        unsigned int last_pos;
     361        unsigned long last_pos_jiffies;
     362        unsigned int jiffy_to_bytes;
    360363        int frags;
    361364        int lvi;
     
    620623        if (chip->buggy_semaphore)
    621624                return 0; /* just ignore ... */
    622         while (time-- && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
     625        while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
    623626                udelay(1);
    624627        if (! time && ! chip->in_ac97_init)
     
    692695                                                     ichdev->fragsize >> ichdev->pos_shift);
    693696#if 0
    694                         printk("bdbar[%i] = 0x%x [0x%x]\n",
     697                        printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
    695698                               idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
    696699#endif
     
    704707        ichdev->position = 0;
    705708#if 0
    706         printk("lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
    707                         ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1);
     709        printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
     710               "period_size1 = 0x%x\n",
     711               ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
     712               ichdev->fragsize1);
    708713#endif
    709714        /* clear interrupts */
     
    771776                ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
    772777#if 0
    773         printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
     778        printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, "
     779               "all = 0x%x, 0x%x\n",
    774780               ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
    775781               ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
     
    838844                /* fallthru */
    839845        case SNDRV_PCM_TRIGGER_START:
     846        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
    840847                val = ICH_IOCE | ICH_STARTBM;
     848                ichdev->last_pos = ichdev->position;
     849                ichdev->last_pos_jiffies = jiffies;
    841850                break;
    842851        case SNDRV_PCM_TRIGGER_SUSPEND:
     
    848857        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
    849858                val = ICH_IOCE;
    850                 break;
    851         case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
    852                 val = ICH_IOCE | ICH_STARTBM;
    853859                break;
    854860        default:
     
    10451051        }
    10461052        snd_intel8x0_setup_periods(chip, ichdev);
     1053        ichdev->jiffy_to_bytes = (runtime->rate * 4 * ichdev->pos_shift) / HZ;
    10471054        return 0;
    10481055}
     
    10531060        struct ichdev *ichdev = get_ichdev(substream);
    10541061        size_t ptr1, ptr;
    1055         int civ, timeout = 100;
     1062        int civ, timeout = 10;
    10561063        unsigned int position;
    10571064
     
    10691076                        break;
    10701077        } while (timeout--);
    1071         ptr1 <<= ichdev->pos_shift;
    1072         ptr = ichdev->fragsize1 - ptr1;
    1073         ptr += position;
     1078        if (ptr1 != 0) {
     1079                ptr1 <<= ichdev->pos_shift;
     1080                ptr = ichdev->fragsize1 - ptr1;
     1081                ptr += position;
     1082                ichdev->last_pos = ptr;
     1083                ichdev->last_pos_jiffies = jiffies;
     1084        } else {
     1085                ptr1 = jiffies - ichdev->last_pos_jiffies;
     1086                if (ptr1)
     1087                        ptr1 -= 1;
     1088                ptr = ichdev->last_pos + ptr1 * ichdev->jiffy_to_bytes;
     1089                ptr %= ichdev->size;
     1090        }
    10741091        spin_unlock(&chip->reg_lock);
    10751092        if (ptr >= ichdev->size)
     
    18421859        {
    18431860                .subvendor = 0x1028,
     1861                .subdevice = 0x016a,
     1862                .name = "Dell Inspiron 8600",   /* STAC9750/51 */
     1863                .type = AC97_TUNE_HP_ONLY
     1864        },
     1865        {
     1866                .subvendor = 0x1028,
    18441867                .subdevice = 0x0186,
    18451868                .name = "Dell Latitude D810", /* cf. Malone #41015 */
     
    18801903                .subdevice = 0x0890,
    18811904                .name = "HP nc6000",
    1882                 .type = AC97_TUNE_MUTE_LED
    1883         },
    1884         {
    1885                 .subvendor = 0x103c,
    1886                 .subdevice = 0x0934,
    1887                 .name = "HP nx8220",
    18881905                .type = AC97_TUNE_MUTE_LED
    18891906        },
     
    22922309}
    22932310
    2294 static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
    2295 {
    2296         unsigned long end_time;
    2297         unsigned int cnt, status, nstatus;
    2298        
    2299         /* put logic to right state */
    2300         /* first clear status bits */
    2301         status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
    2302         if (chip->device_type == DEVICE_NFORCE)
    2303                 status |= ICH_NVSPINT;
    2304         cnt = igetdword(chip, ICHREG(GLOB_STA));
    2305         iputdword(chip, ICHREG(GLOB_STA), cnt & status);
    2306 
     2311#ifdef CONFIG_SND_AC97_POWER_SAVE
     2312static struct snd_pci_quirk ich_chip_reset_mode[] = {
     2313        SND_PCI_QUIRK(0x1014, 0x051f, "Thinkpad R32", 1),
     2314        { } /* end */
     2315};
     2316
     2317static int snd_intel8x0_ich_chip_cold_reset(struct intel8x0 *chip)
     2318{
     2319        unsigned int cnt;
    23072320        /* ACLink on, 2 channels */
     2321
     2322        if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
     2323                return -EIO;
     2324
    23082325        cnt = igetdword(chip, ICHREG(GLOB_CNT));
    23092326        cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
    2310 #ifdef CONFIG_SND_AC97_POWER_SAVE
     2327
    23112328        /* do cold reset - the full ac97 powerdown may leave the controller
    23122329         * in a warm state but actually it cannot communicate with the codec.
     
    23172334        iputdword(chip, ICHREG(GLOB_CNT), cnt | ICH_AC97COLD);
    23182335        msleep(1);
     2336        return 0;
     2337}
     2338#define snd_intel8x0_ich_chip_can_cold_reset(chip) \
     2339        (!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
    23192340#else
     2341#define snd_intel8x0_ich_chip_cold_reset(chip)  0
     2342#define snd_intel8x0_ich_chip_can_cold_reset(chip) (0)
     2343#endif
     2344
     2345static int snd_intel8x0_ich_chip_reset(struct intel8x0 *chip)
     2346{
     2347        unsigned long end_time;
     2348        unsigned int cnt;
     2349        /* ACLink on, 2 channels */
     2350        cnt = igetdword(chip, ICHREG(GLOB_CNT));
     2351        cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
    23202352        /* finish cold or do warm reset */
    23212353        cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM;
     
    23242356        do {
    23252357                if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
    2326                         goto __ok;
     2358                        return 0;
    23272359                schedule_timeout_uninterruptible(1);
    23282360        } while (time_after_eq(end_time, jiffies));
     
    23302362                   igetdword(chip, ICHREG(GLOB_CNT)));
    23312363        return -EIO;
    2332 
    2333       __ok:
    2334 #endif
     2364}
     2365
     2366static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
     2367{
     2368        unsigned long end_time;
     2369        unsigned int status, nstatus;
     2370        unsigned int cnt;
     2371        int err;
     2372
     2373        /* put logic to right state */
     2374        /* first clear status bits */
     2375        status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
     2376        if (chip->device_type == DEVICE_NFORCE)
     2377                status |= ICH_NVSPINT;
     2378        cnt = igetdword(chip, ICHREG(GLOB_STA));
     2379        iputdword(chip, ICHREG(GLOB_STA), cnt & status);
     2380
     2381        if (snd_intel8x0_ich_chip_can_cold_reset(chip))
     2382                err = snd_intel8x0_ich_chip_cold_reset(chip);
     2383        else
     2384                err = snd_intel8x0_ich_chip_reset(chip);
     2385        if (err < 0)
     2386                return err;
     2387
    23352388        if (probing) {
    23362389                /* wait for any codec ready status.
     
    26272680        struct ichdev *ichdev;
    26282681        unsigned long port;
    2629         unsigned long pos, t;
    2630         struct timeval start_time, stop_time;
     2682        unsigned long pos, pos1, t;
     2683        int civ, timeout = 1000, attempt = 1;
     2684        struct timespec start_time, stop_time;
    26312685
    26322686        if (chip->ac97_bus->clock != 48000)
    26332687                return; /* specified in module option */
    26342688
     2689      __again:
    26352690        subs = chip->pcm[0]->streams[0].substream;
    26362691        if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) {
     
    26402695        ichdev = &chip->ichd[ICHD_PCMOUT];
    26412696        ichdev->physbuf = subs->dma_buffer.addr;
    2642         ichdev->size = chip->ichd[ICHD_PCMOUT].fragsize = INTEL8X0_TESTBUF_SIZE;
     2697        ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE;
    26432698        ichdev->substream = NULL; /* don't process interrupts */
    26442699
     
    26592714                iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot);
    26602715        }
    2661         do_gettimeofday(&start_time);
     2716        do_posix_clock_monotonic_gettime(&start_time);
    26622717        spin_unlock_irq(&chip->reg_lock);
    26632718        msleep(50);
    26642719        spin_lock_irq(&chip->reg_lock);
    26652720        /* check the position */
    2666         pos = ichdev->fragsize1;
    2667         pos -= igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << ichdev->pos_shift;
    2668         pos += ichdev->position;
     2721        do {
     2722                civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
     2723                pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb);
     2724                if (pos1 == 0) {
     2725                        udelay(10);
     2726                        continue;
     2727                }
     2728                if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) &&
     2729                    pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
     2730                        break;
     2731        } while (timeout--);
     2732        if (pos1 == 0) {        /* oops, this value is not reliable */
     2733                pos = 0;
     2734        } else {
     2735                pos = ichdev->fragsize1;
     2736                pos -= pos1 << ichdev->pos_shift;
     2737                pos += ichdev->position;
     2738        }
    26692739        chip->in_measurement = 0;
    2670         do_gettimeofday(&stop_time);
     2740        do_posix_clock_monotonic_gettime(&stop_time);
    26712741        /* stop */
    26722742        if (chip->device_type == DEVICE_ALI) {
     
    26832753        spin_unlock_irq(&chip->reg_lock);
    26842754
     2755        if (pos == 0) {
     2756                snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n");
     2757              __retry:
     2758                if (attempt < 3) {
     2759                        msleep(300);
     2760                        attempt++;
     2761                        goto __again;
     2762                }
     2763                goto __end;
     2764        }
     2765
     2766        pos /= 4;
    26852767        t = stop_time.tv_sec - start_time.tv_sec;
    26862768        t *= 1000000;
    2687         t += stop_time.tv_usec - start_time.tv_usec;
    2688         printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t);
     2769        t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
     2770        printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
    26892771        if (t == 0) {
    2690                 snd_printk(KERN_ERR "?? calculation error..\n");
    2691                 return;
    2692         }
    2693         pos = (pos / 4) * 1000;
     2772                snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n");
     2773                goto __retry;
     2774        }
     2775        pos *= 1000;
    26942776        pos = (pos / t) * 1000 + ((pos % t) * 1000) / t;
    2695         if (pos < 40000 || pos >= 60000)
     2777        if (pos < 40000 || pos >= 60000) {
    26962778                /* abnormal value. hw problem? */
    26972779                printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos);
     2780                goto __retry;
     2781        } else if (pos > 40500 && pos < 41500)
     2782                /* first exception - 41000Hz reference clock */
     2783                chip->ac97_bus->clock = 41000;
     2784        else if (pos > 43600 && pos < 44600)
     2785                /* second exception - 44100HZ reference clock */
     2786                chip->ac97_bus->clock = 44100;
    26982787        else if (pos < 47500 || pos > 48500)
    26992788                /* not 48000Hz, tuning the clock.. */
    27002789                chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
     2790      __end:
    27012791        printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock);
    27022792        snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
  • GPL/trunk/alsa-kernel/pci/maestro3.c

    r410 r426  
    25352535
    25362536        /* check, if we can restrict PCI DMA transfers to 28 bits */
    2537         if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
    2538             pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
     2537        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
     2538            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
    25392539                snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
    25402540                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/rme9652/hdsp.c

    r410 r426  
    114114/* the meters are regular i/o-mapped registers, but offset
    115115   considerably from the rest. the peak registers are reset
    116    when read; the least-significant 4 bits are full-scale counters; 
     116   when read; the least-significant 4 bits are full-scale counters;
    117117   the actual peak value is in the most-significant 24 bits.
    118118*/
     
    132132   14*3 in ds mode, with no gap between values
    133133*/
    134 #define HDSP_9652_peakBase      7164   
     134#define HDSP_9652_peakBase      7164
    135135#define HDSP_9652_rmsBase       4096
    136136
     
    174174#define HDSP_SPDIFNonAudio        (1<<11) /* 0=off, 1=on */
    175175#define HDSP_SPDIFOpticalOut      (1<<12) /* 1=use 1st ADAT connector for SPDIF, 0=do not */
    176 #define HDSP_SyncRef2             (1<<13) 
    177 #define HDSP_SPDIFInputSelect0    (1<<14) 
    178 #define HDSP_SPDIFInputSelect1    (1<<15) 
    179 #define HDSP_SyncRef0             (1<<16) 
     176#define HDSP_SyncRef2             (1<<13)
     177#define HDSP_SPDIFInputSelect0    (1<<14)
     178#define HDSP_SPDIFInputSelect1    (1<<15)
     179#define HDSP_SyncRef0             (1<<16)
    180180#define HDSP_SyncRef1             (1<<17)
    181 #define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */ 
     181#define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */
    182182#define HDSP_XLRBreakoutCable     (1<<20) /* For H9632 cards */
    183183#define HDSP_Midi0InterruptEnable (1<<22)
     
    315315#define HDSP_AEBO               (1<<28) /* H9632 specific Analog Extension Boards */
    316316#define HDSP_AEBI               (1<<29) /* 0 = present, 1 = absent */
    317 #define HDSP_midi0IRQPending    (1<<30) 
     317#define HDSP_midi0IRQPending    (1<<30)
    318318#define HDSP_midi1IRQPending    (1<<31)
    319319
     
    392392
    393393/* the size of the area we need to allocate for DMA transfers. the
    394    size is the same regardless of the number of channels - the 
     394   size is the same regardless of the number of channels - the
    395395   Multiface still uses the same memory area.
    396396
     
    461461        unsigned char         ds_in_channels;
    462462        unsigned char         ss_in_channels;       /* different for multiface/digiface */
    463         unsigned char         qs_out_channels;     
     463        unsigned char         qs_out_channels;
    464464        unsigned char         ds_out_channels;
    465465        unsigned char         ss_out_channels;
     
    503503static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */
    504504        /* Analog */
    505         0, 1, 2, 3, 4, 5, 6, 7, 
     505        0, 1, 2, 3, 4, 5, 6, 7,
    506506        /* ADAT 2 */
    507         16, 17, 18, 19, 20, 21, 22, 23, 
     507        16, 17, 18, 19, 20, 21, 22, 23,
    508508        /* SPDIF */
    509509        24, 25,
     
    526526        8, 9,
    527527        /* Analog */
    528         10, 11, 
     528        10, 11,
    529529        /* AO4S-192 and AI4S-192 extension boards */
    530530        12, 13, 14, 15,
    531531        /* others don't exist */
    532         -1, -1, -1, -1, -1, -1, -1, -1, 
     532        -1, -1, -1, -1, -1, -1, -1, -1,
    533533        -1, -1
    534534};
     
    540540        8, 9,
    541541        /* Analog */
    542         10, 11, 
     542        10, 11,
    543543        /* AO4S-192 and AI4S-192 extension boards */
    544544        12, 13, 14, 15,
     
    588588        {
    589589                .vendor = PCI_VENDOR_ID_XILINX,
    590                 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, 
     590                .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP,
    591591                .subvendor = PCI_ANY_ID,
    592592                .subdevice = PCI_ANY_ID,
     
    654654static int hdsp_check_for_iobox (struct hdsp *hdsp)
    655655{
    656 
    657656        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
    658657        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) {
     
    662661        }
    663662        return 0;
    664 
     663}
     664
     665static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops,
     666                               unsigned int delay)
     667{
     668        unsigned int i;
     669
     670        if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
     671                return 0;
     672
     673        for (i = 0; i != loops; ++i) {
     674                if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError)
     675                        msleep(delay);
     676                else {
     677                        snd_printd("Hammerfall-DSP: iobox found after %ums!\n",
     678                                   i * delay);
     679                        return 0;
     680                }
     681        }
     682
     683        snd_printk("Hammerfall-DSP: no Digiface or Multiface connected!\n");
     684        hdsp->state &= ~HDSP_FirmwareLoaded;
     685        return -EIO;
    665686}
    666687
     
    671692
    672693        if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
    673                
     694
    674695                snd_printk ("Hammerfall-DSP: loading firmware\n");
    675696
    676697                hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM);
    677698                hdsp_write (hdsp, HDSP_fifoData, 0);
    678                
     699
    679700                if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
    680701                        snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n");
    681702                        return -EIO;
    682703                }
    683                
     704
    684705                hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD);
    685                
     706
    686707                for (i = 0; i < 24413; ++i) {
    687708                        hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]);
     
    693714
    694715                ssleep(3);
    695                
     716
    696717                if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
    697718                        snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n");
     
    706727                hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
    707728                snd_printk ("Hammerfall-DSP: finished firmware loading\n");
    708                
     729
    709730        }
    710731        if (hdsp->state & HDSP_InitializationComplete) {
     
    712733                spin_lock_irqsave(&hdsp->lock, flags);
    713734                snd_hdsp_set_defaults(hdsp);
    714                 spin_unlock_irqrestore(&hdsp->lock, flags); 
    715         }
    716        
     735                spin_unlock_irqrestore(&hdsp->lock, flags);
     736        }
     737
    717738        hdsp->state |= HDSP_FirmwareLoaded;
    718739
     
    723744{
    724745        if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
    725        
     746
    726747                hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM);
    727748                hdsp_write (hdsp, HDSP_fifoData, 0);
     
    739760                } else {
    740761                        hdsp->io_type = Digiface;
    741                 } 
     762                }
    742763        } else {
    743764                /* firmware was already loaded, get iobox type */
     
    787808
    788809static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
    789 {   
     810{
    790811        int i;
    791812
     
    793814           are available in the command FIFO.
    794815        */
    795        
     816
    796817        for (i = 0; i < timeout; i++) {
    797818
     
    825846        if (addr >= HDSP_MATRIX_MIXER_SIZE)
    826847                return -1;
    827        
     848
    828849        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) {
    829850
    830851                /* from martin bjornsen:
    831                    
     852
    832853                   "You can only write dwords to the
    833854                   mixer memory which contain two
     
    848869                hdsp->mixer_matrix[addr] = data;
    849870
    850                
     871
    851872                /* `addr' addresses a 16-bit wide address, but
    852873                   the address space accessed via hdsp_write
     
    857878                */
    858879                ad = addr/2;
    859        
    860                 hdsp_write (hdsp, 4096 + (ad*4), 
    861                             (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + 
     880
     881                hdsp_write (hdsp, 4096 + (ad*4),
     882                            (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) +
    862883                            hdsp->mixer_matrix[addr&0x7fe]);
    863                
     884
    864885                return 0;
    865886
     
    867888
    868889                ad = (addr << 16) + data;
    869                
     890
    870891                if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT))
    871892                        return -1;
     
    903924        if (status & HDSP_SPDIFErrorFlag)
    904925                return 0;
    905        
     926
    906927        switch (rate_bits) {
    907928        case HDSP_spdifFrequency32KHz: return 32000;
     
    911932        case HDSP_spdifFrequency88_2KHz: return 88200;
    912933        case HDSP_spdifFrequency96KHz: return 96000;
    913         case HDSP_spdifFrequency128KHz: 
     934        case HDSP_spdifFrequency128KHz:
    914935                if (hdsp->io_type == H9632) return 128000;
    915936                break;
    916         case HDSP_spdifFrequency176_4KHz: 
     937        case HDSP_spdifFrequency176_4KHz:
    917938                if (hdsp->io_type == H9632) return 176400;
    918939                break;
    919         case HDSP_spdifFrequency192KHz: 
     940        case HDSP_spdifFrequency192KHz:
    920941                if (hdsp->io_type == H9632) return 192000;
    921942                break;
     
    10281049        u64 n;
    10291050        u32 r;
    1030        
     1051
    10311052        if (rate >= 112000)
    10321053                rate /= 4;
     
    10541075           initialization).
    10551076        */
    1056        
    1057         if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 
     1077
     1078        if (!(hdsp->control_register & HDSP_ClockModeMaster)) {
    10581079                if (called_internally) {
    10591080                        /* request from ctl or card initialization */
    10601081                        snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
    10611082                        return -1;
    1062                 } else {               
     1083                } else {
    10631084                        /* hw_param request while in AutoSync mode */
    10641085                        int external_freq = hdsp_external_sample_rate(hdsp);
    10651086                        int spdif_freq = hdsp_spdif_sample_rate(hdsp);
    1066                
     1087
    10671088                        if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
    10681089                                snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n");
    10691090                        else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
    1070                                 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");                     
     1091                                snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");
    10711092                        else if (rate != external_freq) {
    10721093                                snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n");
    10731094                                return -1;
    1074                         }               
    1075                 }       
     1095                        }
     1096                }
    10761097        }
    10771098
     
    10801101        /* Changing from a "single speed" to a "double speed" rate is
    10811102           not allowed if any substreams are open. This is because
    1082            such a change causes a shift in the location of 
     1103           such a change causes a shift in the location of
    10831104           the DMA buffers and a reduction in the number of available
    1084            buffers. 
     1105           buffers.
    10851106
    10861107           Note that a similar but essentially insoluble problem
     
    10901111        if (rate > 96000 && hdsp->io_type != H9632)
    10911112                return -EINVAL;
    1092        
     1113
    10931114        switch (rate) {
    10941115        case 32000:
     
    11801201                }
    11811202        }
    1182        
     1203
    11831204        hdsp->system_sample_rate = rate;
    11841205
     
    12461267
    12471268        /* Output is not interrupt driven */
    1248                
     1269
    12491270        spin_lock_irqsave (&hmidi->lock, flags);
    12501271        if (hmidi->output) {
     
    12531274                                if (n_pending > (int)sizeof (buf))
    12541275                                        n_pending = sizeof (buf);
    1255                                
     1276
    12561277                                if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) {
    1257                                         for (i = 0; i < to_write; ++i) 
     1278                                        for (i = 0; i < to_write; ++i)
    12581279                                                snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]);
    12591280                                }
     
    13261347        struct hdsp_midi *hmidi = (struct hdsp_midi *) data;
    13271348        unsigned long flags;
    1328        
     1349
    13291350        snd_hdsp_midi_output_write(hmidi);
    13301351        spin_lock_irqsave (&hmidi->lock, flags);
     
    13331354           kernel automatically removed the timer when it
    13341355           expired, and we are now adding it back, thus
    1335            leaving istimer wherever it was set before. 
     1356           leaving istimer wherever it was set before.
    13361357        */
    13371358
     
    15021523{
    15031524        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1504        
     1525
    15051526        snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif);
    15061527        return 0;
     
    15121533        int change;
    15131534        u32 val;
    1514        
     1535
    15151536        val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
    15161537        spin_lock_irq(&hdsp->lock);
     
    15311552{
    15321553        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1533        
     1554
    15341555        snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream);
    15351556        return 0;
     
    15411562        int change;
    15421563        u32 val;
    1543        
     1564
    15441565        val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
    15451566        spin_lock_irq(&hdsp->lock);
     
    16031624{
    16041625        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1605        
     1626
    16061627        ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp);
    16071628        return 0;
     
    16131634        int change;
    16141635        unsigned int val;
    1615        
     1636
    16161637        if (!snd_hdsp_use_is_exclusive(hdsp))
    16171638                return -EBUSY;
     
    16501671{
    16511672        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1652        
     1673
    16531674        ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp);
    16541675        return 0;
     
    16601681        int change;
    16611682        unsigned int val;
    1662        
     1683
    16631684        if (!snd_hdsp_use_is_exclusive(hdsp))
    16641685                return -EBUSY;
     
    16941715{
    16951716        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1696        
     1717
    16971718        ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp);
    16981719        return 0;
     
    17041725        int change;
    17051726        unsigned int val;
    1706        
     1727
    17071728        if (!snd_hdsp_use_is_exclusive(hdsp))
    17081729                return -EBUSY;
     
    17381759{
    17391760        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1740        
     1761
    17411762        ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp);
    17421763        return 0;
     
    17481769        int change;
    17491770        unsigned int val;
    1750        
     1771
    17511772        if (!snd_hdsp_use_is_exclusive(hdsp))
    17521773                return -EBUSY;
     
    17821803{
    17831804        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1784        
     1805
    17851806        ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp);
    17861807        return 0;
     
    17921813        int change;
    17931814        unsigned int val;
    1794        
     1815
    17951816        if (!snd_hdsp_use_is_exclusive(hdsp))
    17961817                return -EBUSY;
     
    18291850{
    18301851        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1831        
     1852
    18321853        switch (hdsp_spdif_sample_rate(hdsp)) {
    18331854        case 32000:
     
    18591880                break;
    18601881        default:
    1861                 ucontrol->value.enumerated.item[0] = 6;         
     1882                ucontrol->value.enumerated.item[0] = 6;
    18621883        }
    18631884        return 0;
     
    18831904{
    18841905        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1885        
     1906
    18861907        ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate;
    18871908        return 0;
     
    19001921{
    19011922        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1902         static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};   
     1923        static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
    19031924        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    19041925        uinfo->count = 1;
     
    19131934{
    19141935        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1915        
     1936
    19161937        switch (hdsp_external_sample_rate(hdsp)) {
    19171938        case 32000:
     
    19411962        case 192000:
    19421963                ucontrol->value.enumerated.item[0] = 9;
    1943                 break; 
     1964                break;
    19441965        default:
    1945                 ucontrol->value.enumerated.item[0] = 6;         
     1966                ucontrol->value.enumerated.item[0] = 6;
    19461967        }
    19471968        return 0;
     
    19691990{
    19701991        static char *texts[] = {"Master", "Slave" };
    1971        
     1992
    19721993        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    19731994        uinfo->count = 1;
     
    19822003{
    19832004        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    1984        
     2005
    19852006        ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp);
    19862007        return 0;
     
    20192040                        return 9;
    20202041                default:
    2021                         return 3;       
     2042                        return 3;
    20222043                }
    20232044        } else {
     
    20332054                if (hdsp_external_sample_rate(hdsp) != 0) {
    20342055                    if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) {
    2035                         hdsp->control_register &= ~HDSP_ClockModeMaster;               
     2056                        hdsp->control_register &= ~HDSP_ClockModeMaster;
    20362057                        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
    20372058                        return 0;
     
    20442065        case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ:
    20452066                rate = 44100;
    2046                 break;     
     2067                break;
    20472068        case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ:
    20482069                rate = 48000;
     
    20792100        static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };
    20802101        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2081        
     2102
    20822103        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    20832104        uinfo->count = 1;
     
    20852106            uinfo->value.enumerated.items = 10;
    20862107        else
    2087             uinfo->value.enumerated.items = 7; 
     2108            uinfo->value.enumerated.items = 7;
    20882109        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
    20892110                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     
    20952116{
    20962117        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2097        
     2118
    20982119        ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp);
    20992120        return 0;
     
    21052126        int change;
    21062127        int val;
    2107        
     2128
    21082129        if (!snd_hdsp_use_is_exclusive(hdsp))
    21092130                return -EBUSY;
     
    21312152{
    21322153        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2133        
     2154
    21342155        ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
    21352156        return 0;
     
    21662187                return 2;
    21672188        default:
    2168                 return 1;       
     2189                return 1;
    21692190        }
    21702191}
     
    21812202                break;
    21822203        case 2:
    2183                 hdsp->control_register |= HDSP_DAGainMinus10dBV;               
    2184                 break;     
     2204                hdsp->control_register |= HDSP_DAGainMinus10dBV;
     2205                break;
    21852206        default:
    21862207                return -1;
     
    21942215{
    21952216        static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"};
    2196        
     2217
    21972218        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    21982219        uinfo->count = 1;
     
    22072228{
    22082229        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2209        
     2230
    22102231        ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp);
    22112232        return 0;
     
    22172238        int change;
    22182239        int val;
    2219        
     2240
    22202241        if (!snd_hdsp_use_is_exclusive(hdsp))
    22212242                return -EBUSY;
     
    22512272                return 2;
    22522273        default:
    2253                 return 1;       
     2274                return 1;
    22542275        }
    22552276}
     
    22632284                break;
    22642285        case 1:
    2265                 hdsp->control_register |= HDSP_ADGainPlus4dBu;         
     2286                hdsp->control_register |= HDSP_ADGainPlus4dBu;
    22662287                break;
    22672288        case 2:
    2268                 hdsp->control_register |= HDSP_ADGainLowGain;           
    2269                 break;     
     2289                hdsp->control_register |= HDSP_ADGainLowGain;
     2290                break;
    22702291        default:
    22712292                return -1;
     
    22792300{
    22802301        static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"};
    2281        
     2302
    22822303        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    22832304        uinfo->count = 1;
     
    22922313{
    22932314        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2294        
     2315
    22952316        ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp);
    22962317        return 0;
     
    23022323        int change;
    23032324        int val;
    2304        
     2325
    23052326        if (!snd_hdsp_use_is_exclusive(hdsp))
    23062327                return -EBUSY;
     
    23362357                return 2;
    23372358        default:
    2338                 return 0;       
     2359                return 0;
    23392360        }
    23402361}
     
    23482369                break;
    23492370        case 1:
    2350                 hdsp->control_register |= HDSP_PhoneGainMinus6dB;               
     2371                hdsp->control_register |= HDSP_PhoneGainMinus6dB;
    23512372                break;
    23522373        case 2:
    2353                 hdsp->control_register |= HDSP_PhoneGainMinus12dB;             
    2354                 break;     
     2374                hdsp->control_register |= HDSP_PhoneGainMinus12dB;
     2375                break;
    23552376        default:
    23562377                return -1;
     
    23642385{
    23652386        static char *texts[] = {"0 dB", "-6 dB", "-12 dB"};
    2366        
     2387
    23672388        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    23682389        uinfo->count = 1;
     
    23772398{
    23782399        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2379        
     2400
    23802401        ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp);
    23812402        return 0;
     
    23872408        int change;
    23882409        int val;
    2389        
     2410
    23902411        if (!snd_hdsp_use_is_exclusive(hdsp))
    23912412                return -EBUSY;
     
    24332454{
    24342455        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2435        
     2456
    24362457        ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp);
    24372458        return 0;
     
    24432464        int change;
    24442465        int val;
    2445        
     2466
    24462467        if (!snd_hdsp_use_is_exclusive(hdsp))
    24472468                return -EBUSY;
     
    24892510{
    24902511        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2491        
     2512
    24922513        ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp);
    24932514        return 0;
     
    24992520        int change;
    25002521        int val;
    2501        
     2522
    25022523        if (!snd_hdsp_use_is_exclusive(hdsp))
    25032524                return -EBUSY;
     
    25772598        static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" };
    25782599        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2579        
     2600
    25802601        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    25812602        uinfo->count = 1;
     
    25962617                break;
    25972618        }
    2598                
     2619
    25992620        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
    26002621                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     
    26062627{
    26072628        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2608        
     2629
    26092630        ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp);
    26102631        return 0;
     
    26162637        int change, max;
    26172638        unsigned int val;
    2618        
     2639
    26192640        if (!snd_hdsp_use_is_exclusive(hdsp))
    26202641                return -EBUSY;
     
    26652686                return HDSP_AUTOSYNC_FROM_SPDIF;
    26662687        case HDSP_SelSyncRefMask:
    2667                 return HDSP_AUTOSYNC_FROM_NONE; 
     2688                return HDSP_AUTOSYNC_FROM_NONE;
    26682689        case HDSP_SelSyncRef_ADAT1:
    26692690                return HDSP_AUTOSYNC_FROM_ADAT1;
     
    26812702{
    26822703        static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" };
    2683        
     2704
    26842705        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    26852706        uinfo->count = 1;
     
    26942715{
    26952716        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2696        
     2717
    26972718        ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp);
    26982719        return 0;
     
    27282749{
    27292750        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2730        
     2751
    27312752        spin_lock_irq(&hdsp->lock);
    27322753        ucontrol->value.integer.value[0] = hdsp_line_out(hdsp);
     
    27402761        int change;
    27412762        unsigned int val;
    2742        
     2763
    27432764        if (!snd_hdsp_use_is_exclusive(hdsp))
    27442765                return -EBUSY;
     
    27742795{
    27752796        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2776        
     2797
    27772798        spin_lock_irq(&hdsp->lock);
    27782799        ucontrol->value.integer.value[0] = hdsp->precise_ptr;
     
    27862807        int change;
    27872808        unsigned int val;
    2788        
     2809
    27892810        if (!snd_hdsp_use_is_exclusive(hdsp))
    27902811                return -EBUSY;
     
    28202841{
    28212842        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    2822        
     2843
    28232844        spin_lock_irq(&hdsp->lock);
    28242845        ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet;
     
    28322853        int change;
    28332854        unsigned int val;
    2834        
     2855
    28352856        if (!snd_hdsp_use_is_exclusive(hdsp))
    28362857                return -EBUSY;
     
    28742895        source = ucontrol->value.integer.value[0];
    28752896        destination = ucontrol->value.integer.value[1];
    2876        
     2897
    28772898        if (source >= hdsp->max_channels)
    28782899                addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination);
    28792900        else
    28802901                addr = hdsp_input_to_output_key(hdsp,source, destination);
    2881        
     2902
    28822903        spin_lock_irq(&hdsp->lock);
    28832904        ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr);
     
    29272948static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    29282949{
    2929         static char *texts[] = {"No Lock", "Lock", "Sync" };   
     2950        static char *texts[] = {"No Lock", "Lock", "Sync" };
    29302951        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    29312952        uinfo->count = 1;
     
    29722993        if (status & HDSP_SPDIFErrorFlag)
    29732994                return 0;
    2974         else { 
     2995        else {
    29752996                if (status & HDSP_SPDIFSync)
    29762997                        return 2;
     
    30083029        } else
    30093030                return 0;
    3010 }       
     3031}
    30113032
    30123033static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
     
    30263047
    30273048static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx)
    3028 {       
     3049{
    30293050        int status = hdsp_read(hdsp, HDSP_statusRegister);
    3030        
     3051
    30313052        if (status & (HDSP_Lock0>>idx)) {
    30323053                if (status & (HDSP_Sync0>>idx))
    30333054                        return 2;
    30343055                else
    3035                         return 1;               
     3056                        return 1;
    30363057        } else
    30373058                return 0;
    3038 } 
     3059}
    30393060
    30403061static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
     
    30543075        case Multiface:
    30553076        case H9632:
    3056                 if (offset >= 1) 
     3077                if (offset >= 1)
    30573078                        return -EINVAL;
    30583079                break;
     
    31163137{
    31173138        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
    3118        
     3139
    31193140        ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
    31203141        return 0;
     
    31263147        int change;
    31273148        int val;
    3128        
     3149
    31293150        if (!snd_hdsp_use_is_exclusive(hdsp))
    31303151                return -EBUSY;
     
    31713192        .private_value = IEC958_AES0_NONAUDIO |
    31723193                         IEC958_AES0_PROFESSIONAL |
    3173                          IEC958_AES0_CON_EMPHASIS,                                                                                           
     3194                         IEC958_AES0_CON_EMPHASIS,
    31743195},
    31753196{
     
    31893210HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0),
    31903211HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
    3191 /* 'Sample Clock Source' complies with the alsa control naming scheme */ 
     3212/* 'Sample Clock Source' complies with the alsa control naming scheme */
    31923213HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
    31933214{
     
    32413262                }
    32423263        }
    3243        
     3264
    32443265        /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */
    32453266        if (hdsp->io_type == H9632) {
     
    32603281
    32613282/*------------------------------------------------------------
    3262    /proc interface 
     3283   /proc interface
    32633284 ------------------------------------------------------------*/
    32643285
     
    32993320                }
    33003321        }
    3301        
     3322
    33023323        status = hdsp_read(hdsp, HDSP_statusRegister);
    33033324        status2 = hdsp_read(hdsp, HDSP_status2Register);
     
    33633384                case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ:
    33643385                clock_source = "Internal 192 kHz";
    3365                 break; 
     3386                break;
    33663387        default:
    3367                 clock_source = "Error";         
     3388                clock_source = "Error";
    33683389        }
    33693390        snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source);
    3370                        
     3391
    33713392        if (hdsp_system_clock_mode(hdsp))
    33723393                system_clock_mode = "Slave";
    33733394        else
    33743395                system_clock_mode = "Master";
    3375        
     3396
    33763397        switch (hdsp_pref_sync_ref (hdsp)) {
    33773398        case HDSP_SYNC_FROM_WORD:
     
    33983419        }
    33993420        snd_iprintf (buffer, "Preferred Sync Reference: %s\n", pref_sync_ref);
    3400        
     3421
    34013422        switch (hdsp_autosync_ref (hdsp)) {
    34023423        case HDSP_AUTOSYNC_FROM_WORD:
     
    34113432        case HDSP_AUTOSYNC_FROM_NONE:
    34123433                autosync_ref = "None";
    3413                 break; 
     3434                break;
    34143435        case HDSP_AUTOSYNC_FROM_ADAT1:
    34153436                autosync_ref = "ADAT1";
     
    34263447        }
    34273448        snd_iprintf (buffer, "AutoSync Reference: %s\n", autosync_ref);
    3428        
     3449
    34293450        snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp));
    3430        
     3451
    34313452        snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
    34323453
    34333454        snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
    34343455        snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
    3435                
     3456
    34363457        snd_iprintf(buffer, "\n");
    34373458
     
    34533474                break;
    34543475        }
    3455        
     3476
    34563477        if (hdsp->control_register & HDSP_SPDIFOpticalOut)
    34573478                snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n");
     
    35113532        else
    35123533                snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock");
    3513        
     3534
    35143535        x = status2 & HDSP_wc_sync;
    35153536        if (status2 & HDSP_wc_lock)
     
    35173538        else
    35183539                snd_iprintf (buffer, "Word Clock: No Lock\n");
    3519        
     3540
    35203541        x = status & HDSP_TimecodeSync;
    35213542        if (status & HDSP_TimecodeLock)
     
    35253546
    35263547        snd_iprintf(buffer, "\n");
    3527        
     3548
    35283549        /* Informations about H9632 specific controls */
    35293550        if (hdsp->io_type == H9632) {
    35303551                char *tmp;
    3531        
     3552
    35323553                switch (hdsp_ad_gain(hdsp)) {
    35333554                case 0:
     
    35553576                }
    35563577                snd_iprintf(buffer, "DA Gain : %s\n", tmp);
    3557                
     3578
    35583579                switch (hdsp_phone_gain(hdsp)) {
    35593580                case 0:
     
    35693590                snd_iprintf(buffer, "Phones Gain : %s\n", tmp);
    35703591
    3571                 snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no"); 
    3572                
     3592                snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no");
     3593
    35733594                if (hdsp->control_register & HDSP_AnalogExtensionBoard)
    35743595                        snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n");
     
    36333654        /* set defaults:
    36343655
    3635            SPDIF Input via Coax 
     3656           SPDIF Input via Coax
    36363657           Master clock mode
    36373658           maximum latency (7 => 2^7 = 8192 samples, 64Kbyte buffer,
    36383659                            which implies 2 4096 sample, 32Kbyte periods).
    3639            Enable line out.                         
     3660           Enable line out.
    36403661         */
    36413662
    3642         hdsp->control_register = HDSP_ClockModeMaster | 
    3643                                  HDSP_SPDIFInputCoaxial | 
    3644                                  hdsp_encode_latency(7) | 
     3663        hdsp->control_register = HDSP_ClockModeMaster |
     3664                                 HDSP_SPDIFInputCoaxial |
     3665                                 hdsp_encode_latency(7) |
    36453666                                 HDSP_LineOut;
    3646        
     3667
    36473668
    36483669        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     
    36623683
    36633684        /* silence everything */
    3664        
     3685
    36653686        for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i)
    36663687                hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN;
     
    36703691                        return -EIO;
    36713692        }
    3672        
     3693
    36733694        /* H9632 specific defaults */
    36743695        if (hdsp->io_type == H9632) {
     
    36883709{
    36893710        struct hdsp *hdsp = (struct hdsp *)arg;
    3690        
     3711
    36913712        if (hdsp->midi[0].pending)
    36923713                snd_hdsp_midi_input_read (&hdsp->midi[0]);
    36933714        if (hdsp->midi[1].pending)
    36943715                snd_hdsp_midi_input_read (&hdsp->midi[1]);
    3695 } 
     3716}
    36963717
    36973718static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
     
    37053726        unsigned int midi1status;
    37063727        int schedule = 0;
    3707        
     3728
    37083729        status = hdsp_read(hdsp, HDSP_statusRegister);
    37093730
     
    37193740        midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff;
    37203741        midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff;
    3721        
     3742
     3743        if (!(hdsp->state & HDSP_InitializationComplete))
     3744                return IRQ_HANDLED;
     3745
    37223746        if (audio) {
    37233747                if (hdsp->capture_substream)
    37243748                        snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
    3725                
     3749
    37263750                if (hdsp->playback_substream)
    37273751                        snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
    37283752        }
    3729        
     3753
    37303754        if (midi0 && midi0status) {
    37313755                if (hdsp->use_midi_tasklet) {
     
    37703794        if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels))
    37713795                return NULL;
    3772        
     3796
    37733797        if ((mapped_channel = hdsp->channel_map[channel]) < 0)
    37743798                return NULL;
    3775        
     3799
    37763800        if (stream == SNDRV_PCM_STREAM_CAPTURE)
    37773801                return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
     
    39663990        struct snd_pcm_substream *other;
    39673991        int running;
    3968        
     3992
    39693993        if (hdsp_check_for_iobox (hdsp))
    39703994                return -EIO;
     
    40604084#endif
    40614085        .rates =                (SNDRV_PCM_RATE_32000 |
    4062                                  SNDRV_PCM_RATE_44100 | 
    4063                                  SNDRV_PCM_RATE_48000 | 
    4064                                  SNDRV_PCM_RATE_64000 | 
    4065                                  SNDRV_PCM_RATE_88200 | 
     4086                                 SNDRV_PCM_RATE_44100 |
     4087                                 SNDRV_PCM_RATE_48000 |
     4088                                 SNDRV_PCM_RATE_64000 |
     4089                                 SNDRV_PCM_RATE_88200 |
    40664090                                 SNDRV_PCM_RATE_96000),
    40674091        .rate_min =             32000,
     
    40894113#endif
    40904114        .rates =                (SNDRV_PCM_RATE_32000 |
    4091                                  SNDRV_PCM_RATE_44100 | 
    4092                                  SNDRV_PCM_RATE_48000 | 
    4093                                  SNDRV_PCM_RATE_64000 | 
    4094                                  SNDRV_PCM_RATE_88200 | 
     4115                                 SNDRV_PCM_RATE_44100 |
     4116                                 SNDRV_PCM_RATE_48000 |
     4117                                 SNDRV_PCM_RATE_64000 |
     4118                                 SNDRV_PCM_RATE_88200 |
    40954119                                 SNDRV_PCM_RATE_96000),
    40964120        .rate_min =             32000,
     
    41714195                        .integer = 1,
    41724196                };
    4173                 return snd_interval_refine(c, &t);     
     4197                return snd_interval_refine(c, &t);
    41744198        } else if (r->min > 48000 && r->max <= 96000) {
    41754199                struct snd_interval t = {
     
    42024226                        .integer = 1,
    42034227                };
    4204                 return snd_interval_refine(c, &t);     
     4228                return snd_interval_refine(c, &t);
    42054229        } else if (r->min > 48000 && r->max <= 96000) {
    42064230                struct snd_interval t = {
     
    43194343                runtime->hw.channels_min = hdsp->qs_out_channels;
    43204344                runtime->hw.channels_max = hdsp->ss_out_channels;
    4321         }       
    4322        
     4345        }
     4346
    43234347        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
    43244348                             snd_hdsp_hw_rule_out_channels, hdsp,
     
    44134437        return 0;
    44144438}
    4415 
    4416 static int snd_hdsp_hwdep_dummy_op(struct snd_hwdep *hw, struct file *file)
    4417 {
    4418         /* we have nothing to initialize but the call is required */
    4419         return 0;
    4420 }
    4421 
    44224439
    44234440/* helper functions for copying meter values */
     
    45374554                                hdsp->iobase + HDSP_playbackRmsLevel + i * 8))
    45384555                        return -EFAULT;
    4539                 if (copy_u64_le(&peak_rms->input_rms[i], 
     4556                if (copy_u64_le(&peak_rms->input_rms[i],
    45404557                                hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4,
    45414558                                hdsp->iobase + HDSP_inputRmsLevel + i * 8))
     
    45474564static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)
    45484565{
    4549         struct hdsp *hdsp = (struct hdsp *)hw->private_data;   
     4566        struct hdsp *hdsp = (struct hdsp *)hw->private_data;
    45504567        void __user *argp = (void __user *)arg;
    45514568        int err;
     
    45814598                unsigned long flags;
    45824599                int i;
    4583                
     4600
    45844601                err = hdsp_check_for_iobox(hdsp);
    45854602                if (err < 0)
     
    46154632                        info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp);
    46164633                        info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp);
    4617                
     4634
    46184635                }
    46194636                if (hdsp->io_type == H9632 || hdsp->io_type == H9652)
     
    46264643        case SNDRV_HDSP_IOCTL_GET_9632_AEB: {
    46274644                struct hdsp_9632_aeb h9632_aeb;
    4628                
     4645
    46294646                if (hdsp->io_type != H9632) return -EINVAL;
    46304647                h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
     
    46374654                struct hdsp_version hdsp_version;
    46384655                int err;
    4639                
     4656
    46404657                if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
    46414658                if (hdsp->io_type == Undefined) {
     
    46534670                u32 __user *firmware_data;
    46544671                int err;
    4655                
     4672
    46564673                if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
    46574674                /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */
     
    46664683                if (get_user(firmware_data, &firmware->firmware_data))
    46674684                        return -EFAULT;
    4668                
     4685
    46694686                if (hdsp_check_for_iobox (hdsp))
    46704687                        return -EIO;
     
    46724689                if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0)
    46734690                        return -EFAULT;
    4674                
     4691
    46754692                hdsp->state |= HDSP_FirmwareCached;
    46764693
    46774694                if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
    46784695                        return err;
    4679                
     4696
    46804697                if (!(hdsp->state & HDSP_InitializationComplete)) {
    46814698                        if ((err = snd_hdsp_enable_io(hdsp)) < 0)
    46824699                                return err;
    4683                        
    4684                         snd_hdsp_initialize_channels(hdsp);             
     4700
     4701                        snd_hdsp_initialize_channels(hdsp);
    46854702                        snd_hdsp_initialize_midi_flush(hdsp);
    4686            
     4703
    46874704                        if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
    46884705                                snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
     
    47314748        struct snd_hwdep *hw;
    47324749        int err;
    4733        
     4750
    47344751        if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0)
    47354752                return err;
    4736                
     4753
    47374754        hdsp->hwdep = hw;
    47384755        hw->private_data = hdsp;
    47394756        strcpy(hw->name, "HDSP hwdep interface");
    47404757
    4741         hw->ops.open = snd_hdsp_hwdep_dummy_op;
    47424758        hw->ops.ioctl = snd_hdsp_hwdep_ioctl;
    4743         hw->ops.release = snd_hdsp_hwdep_dummy_op;
    4744                
     4759
    47454760        return 0;
    47464761}
     
    47754790{
    47764791        int i;
    4777        
     4792
    47784793        if (hdsp_fifo_wait (hdsp, 0, 100)) {
    47794794                snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n");
    47804795                return -EIO;
    47814796        }
    4782        
     4797
    47834798        for (i = 0; i < hdsp->max_channels; ++i) {
    47844799                hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1);
    47854800                hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1);
    47864801        }
    4787        
     4802
    47884803        return 0;
    47894804}
     
    47924807{
    47934808        int status, aebi_channels, aebo_channels;
    4794        
     4809
    47954810        switch (hdsp->io_type) {
    47964811        case Digiface:
     
    48054820                hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS;
    48064821                break;
    4807        
     4822
    48084823        case H9632:
    48094824                status = hdsp_read(hdsp, HDSP_statusRegister);
     
    48254840                hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS;
    48264841                break;
    4827                
     4842
    48284843        default:
    48294844                /* should never get here */
     
    48414856{
    48424857        int err;
    4843        
     4858
    48444859        if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
    48454860                snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n");
    48464861                return err;
    48474862        }
    4848        
     4863
    48494864
    48504865        if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
     
    48774892                return err;
    48784893        }
    4879        
     4894
    48804895        if (!(hdsp->state & HDSP_InitializationComplete)) {
    48814896                strcpy(card->shortname, "Hammerfall DSP");
    4882                 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 
     4897                sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
    48834898                        hdsp->port, hdsp->irq);
    4884            
     4899
    48854900                if ((err = snd_card_register(card)) < 0) {
    48864901                        snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n");
     
    48894904                hdsp->state |= HDSP_InitializationComplete;
    48904905        }
    4891        
     4906
    48924907        return 0;
    48934908}
     
    49004915        const struct firmware *fw;
    49014916        int err;
    4902                
     4917
    49034918        if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
    49044919                return 0;
     
    49094924                        return 0;
    49104925        }
    4911        
     4926
    49124927        /* caution: max length of firmware filename is 30! */
    49134928        switch (hdsp->io_type) {
     
    49434958
    49444959        release_firmware(fw);
    4945                
     4960
    49464961        hdsp->state |= HDSP_FirmwareCached;
    49474962
    49484963        if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
    49494964                return err;
    4950                
     4965
    49514966        if (!(hdsp->state & HDSP_InitializationComplete)) {
    49524967                if ((err = snd_hdsp_enable_io(hdsp)) < 0)
     
    49955010
    49965011        hdsp->card = card;
    4997        
     5012
    49985013        spin_lock_init(&hdsp->lock);
    49995014
    50005015        tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp);
    5001        
     5016
    50025017        pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev);
    50035018        hdsp->firmware_rev &= 0xff;
    5004        
     5019
    50055020        /* From Martin Bjoernsen :
    50065021            "It is important that the card's latency timer register in
     
    50115026        */
    50125027        pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF);
    5013        
     5028
    50145029        strcpy(card->driver, "H-DSP");
    50155030        strcpy(card->mixername, "Xilinx FPGA");
     
    50255040                hdsp->card_name = "RME HDSP 9632";
    50265041                hdsp->max_channels = 16;
    5027                 is_9632 = 1;   
     5042                is_9632 = 1;
    50285043        }
    50295044
     
    50545069        if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
    50555070                return err;
    5056        
     5071
    50575072        if (!is_9652 && !is_9632) {
    5058                 /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
    5059                 ssleep(2);
    5060 
    5061                 err = hdsp_check_for_iobox(hdsp);
     5073                /* we wait a maximum of 10 seconds to let freshly
     5074                 * inserted cardbus cards do their hardware init */
     5075                err = hdsp_wait_for_iobox(hdsp, 1000, 10);
     5076
    50625077                if (err < 0)
    50635078                        return err;
     
    50815096                        return 0;
    50825097                } else {
    5083                         snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");     
     5098                        snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");
    50845099                        if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
    50855100                                hdsp->io_type = Multiface;
    5086                         else 
     5101                        else
    50875102                                hdsp->io_type = Digiface;
    50885103                }
    50895104        }
    5090        
     5105
    50915106        if ((err = snd_hdsp_enable_io(hdsp)) != 0)
    50925107                return err;
    5093        
     5108
    50945109        if (is_9652)
    50955110                hdsp->io_type = H9652;
    5096        
     5111
    50975112        if (is_9632)
    50985113                hdsp->io_type = H9632;
     
    51005115        if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
    51015116                return err;
    5102        
     5117
    51035118        snd_hdsp_initialize_channels(hdsp);
    51045119        snd_hdsp_initialize_midi_flush(hdsp);
    51055120
    5106         hdsp->state |= HDSP_FirmwareLoaded;     
     5121        hdsp->state |= HDSP_FirmwareLoaded;
    51075122
    51085123        if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0)
    51095124                return err;
    51105125
    5111         return 0;       
     5126        return 0;
    51125127}
    51135128
     
    51255140
    51265141        snd_hdsp_free_buffers(hdsp);
    5127        
     5142
    51285143        if (hdsp->iobase)
    51295144                iounmap(hdsp->iobase);
     
    51315146        if (hdsp->port)
    51325147                pci_release_regions(hdsp->pci);
    5133                
     5148
    51345149        pci_disable_device(hdsp->pci);
    51355150        return 0;
     
    51765191
    51775192        strcpy(card->shortname, "Hammerfall DSP");
    5178         sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 
     5193        sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
    51795194                hdsp->port, hdsp->irq);
    51805195
  • GPL/trunk/alsa-kernel/pci/rme9652/hdspm.c

    r410 r426  
    41014101}
    41024102
    4103 static int snd_hdspm_hwdep_dummy_op(struct snd_hwdep * hw, struct file *file)
    4104 {
    4105         /* we have nothing to initialize but the call is required */
    4106         return 0;
    4107 }
    4108 
    4109 
    41104103static int snd_hdspm_hwdep_ioctl(struct snd_hwdep * hw, struct file *file,
    41114104                                 unsigned int cmd, unsigned long arg)
     
    42144207        strcpy(hw->name, "HDSPM hwdep interface");
    42154208
    4216         hw->ops.open = snd_hdspm_hwdep_dummy_op;
    42174209        hw->ops.ioctl = snd_hdspm_hwdep_ioctl;
    4218         hw->ops.release = snd_hdspm_hwdep_dummy_op;
    42194210
    42204211        return 0;
  • GPL/trunk/alsa-kernel/pci/sonicvibes.c

    r410 r426  
    274274        outb(0x18, sonic->dmaa_port + SV_DMA_MODE);
    275275#if 0
    276         printk("program dmaa: addr = 0x%x, paddr = 0x%x\n", addr, inl(sonic->dmaa_port + SV_DMA_ADDR0));
     276        printk(KERN_DEBUG "program dmaa: addr = 0x%x, paddr = 0x%x\n",
     277               addr, inl(sonic->dmaa_port + SV_DMA_ADDR0));
    277278#endif
    278279}
     
    289290        outb(0x14, sonic->dmac_port + SV_DMA_MODE);
    290291#if 0
    291         printk("program dmac: addr = 0x%x, paddr = 0x%x\n", addr, inl(sonic->dmac_port + SV_DMA_ADDR0));
     292        printk(KERN_DEBUG "program dmac: addr = 0x%x, paddr = 0x%x\n",
     293               addr, inl(sonic->dmac_port + SV_DMA_ADDR0));
    292294#endif
    293295}
     
    356358static void snd_sonicvibes_debug(struct sonicvibes * sonic)
    357359{
    358         printk("SV REGS:          INDEX = 0x%02x  ", inb(SV_REG(sonic, INDEX)));
     360        printk(KERN_DEBUG
     361               "SV REGS:          INDEX = 0x%02x  ", inb(SV_REG(sonic, INDEX)));
    359362        printk("                 STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS)));
    360         printk("  0x00: left input      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x00));
     363        printk(KERN_DEBUG
     364               "  0x00: left input      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x00));
    361365        printk("  0x20: synth rate low  = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20));
    362         printk("  0x01: right input     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x01));
     366        printk(KERN_DEBUG
     367               "  0x01: right input     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x01));
    363368        printk("  0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21));
    364         printk("  0x02: left AUX1       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x02));
     369        printk(KERN_DEBUG
     370               "  0x02: left AUX1       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x02));
    365371        printk("  0x22: ADC clock       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22));
    366         printk("  0x03: right AUX1      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x03));
     372        printk(KERN_DEBUG
     373               "  0x03: right AUX1      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x03));
    367374        printk("  0x23: ADC alt rate    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23));
    368         printk("  0x04: left CD         = 0x%02x  ", snd_sonicvibes_in(sonic, 0x04));
     375        printk(KERN_DEBUG
     376               "  0x04: left CD         = 0x%02x  ", snd_sonicvibes_in(sonic, 0x04));
    369377        printk("  0x24: ADC pll M       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24));
    370         printk("  0x05: right CD        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x05));
     378        printk(KERN_DEBUG
     379               "  0x05: right CD        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x05));
    371380        printk("  0x25: ADC pll N       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25));
    372         printk("  0x06: left line       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x06));
     381        printk(KERN_DEBUG
     382               "  0x06: left line       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x06));
    373383        printk("  0x26: Synth pll M     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26));
    374         printk("  0x07: right line      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x07));
     384        printk(KERN_DEBUG
     385               "  0x07: right line      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x07));
    375386        printk("  0x27: Synth pll N     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27));
    376         printk("  0x08: MIC             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x08));
     387        printk(KERN_DEBUG
     388               "  0x08: MIC             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x08));
    377389        printk("  0x28: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28));
    378         printk("  0x09: Game port       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x09));
     390        printk(KERN_DEBUG
     391               "  0x09: Game port       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x09));
    379392        printk("  0x29: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29));
    380         printk("  0x0a: left synth      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0a));
     393        printk(KERN_DEBUG
     394               "  0x0a: left synth      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0a));
    381395        printk("  0x2a: MPU401          = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a));
    382         printk("  0x0b: right synth     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0b));
     396        printk(KERN_DEBUG
     397               "  0x0b: right synth     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0b));
    383398        printk("  0x2b: drive ctrl      = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b));
    384         printk("  0x0c: left AUX2       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0c));
     399        printk(KERN_DEBUG
     400               "  0x0c: left AUX2       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0c));
    385401        printk("  0x2c: SRS space       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c));
    386         printk("  0x0d: right AUX2      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0d));
     402        printk(KERN_DEBUG
     403               "  0x0d: right AUX2      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0d));
    387404        printk("  0x2d: SRS center      = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d));
    388         printk("  0x0e: left analog     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0e));
     405        printk(KERN_DEBUG
     406               "  0x0e: left analog     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0e));
    389407        printk("  0x2e: wave source     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e));
    390         printk("  0x0f: right analog    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0f));
     408        printk(KERN_DEBUG
     409               "  0x0f: right analog    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0f));
    391410        printk("  0x2f: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f));
    392         printk("  0x10: left PCM        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x10));
     411        printk(KERN_DEBUG
     412               "  0x10: left PCM        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x10));
    393413        printk("  0x30: analog power    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30));
    394         printk("  0x11: right PCM       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x11));
     414        printk(KERN_DEBUG
     415               "  0x11: right PCM       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x11));
    395416        printk("  0x31: analog power    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31));
    396         printk("  0x12: DMA data format = 0x%02x  ", snd_sonicvibes_in(sonic, 0x12));
     417        printk(KERN_DEBUG
     418               "  0x12: DMA data format = 0x%02x  ", snd_sonicvibes_in(sonic, 0x12));
    397419        printk("  0x32: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32));
    398         printk("  0x13: P/C enable      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x13));
     420        printk(KERN_DEBUG
     421               "  0x13: P/C enable      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x13));
    399422        printk("  0x33: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33));
    400         printk("  0x14: U/D button      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x14));
     423        printk(KERN_DEBUG
     424               "  0x14: U/D button      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x14));
    401425        printk("  0x34: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34));
    402         printk("  0x15: revision        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x15));
     426        printk(KERN_DEBUG
     427               "  0x15: revision        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x15));
    403428        printk("  0x35: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35));
    404         printk("  0x16: ADC output ctrl = 0x%02x  ", snd_sonicvibes_in(sonic, 0x16));
     429        printk(KERN_DEBUG
     430               "  0x16: ADC output ctrl = 0x%02x  ", snd_sonicvibes_in(sonic, 0x16));
    405431        printk("  0x36: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36));
    406         printk("  0x17: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x17));
     432        printk(KERN_DEBUG
     433               "  0x17: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x17));
    407434        printk("  0x37: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37));
    408         printk("  0x18: DMA A upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x18));
     435        printk(KERN_DEBUG
     436               "  0x18: DMA A upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x18));
    409437        printk("  0x38: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38));
    410         printk("  0x19: DMA A lower cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x19));
     438        printk(KERN_DEBUG
     439               "  0x19: DMA A lower cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x19));
    411440        printk("  0x39: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39));
    412         printk("  0x1a: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1a));
     441        printk(KERN_DEBUG
     442               "  0x1a: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1a));
    413443        printk("  0x3a: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a));
    414         printk("  0x1b: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1b));
     444        printk(KERN_DEBUG
     445               "  0x1b: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1b));
    415446        printk("  0x3b: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b));
    416         printk("  0x1c: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1c));
     447        printk(KERN_DEBUG
     448               "  0x1c: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1c));
    417449        printk("  0x3c: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c));
    418         printk("  0x1d: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1d));
     450        printk(KERN_DEBUG
     451               "  0x1d: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1d));
    419452        printk("  0x3d: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d));
    420         printk("  0x1e: PCM rate low    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1e));
     453        printk(KERN_DEBUG
     454               "  0x1e: PCM rate low    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1e));
    421455        printk("  0x3e: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e));
    422         printk("  0x1f: PCM rate high   = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1f));
     456        printk(KERN_DEBUG
     457               "  0x1f: PCM rate high   = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1f));
    423458        printk("  0x3f: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f));
    424459}
     
    477512        *res_n = n;
    478513#if 0
    479         printk("metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
    480         printk("pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
     514        printk(KERN_DEBUG "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
     515        printk(KERN_DEBUG "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
    481516#endif
    482517}
     
    12301265                return err;
    12311266        /* check, if we can restrict PCI DMA transfers to 24 bits */
    1232         if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 ||
    1233             pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) {
     1267        if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
     1268            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
    12341269                snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
    12351270                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/trident/trident_main.c

    r399 r426  
    6969        unsigned int val, tmp;
    7070
    71         printk("Trident voice %i:\n", voice);
     71        printk(KERN_DEBUG "Trident voice %i:\n", voice);
    7272        outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR));
    7373        val = inl(TRID_REG(trident, CH_LBA));
    74         printk("LBA: 0x%x\n", val);
     74        printk(KERN_DEBUG "LBA: 0x%x\n", val);
    7575        val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
    76         printk("GVSel: %i\n", val >> 31);
    77         printk("Pan: 0x%x\n", (val >> 24) & 0x7f);
    78         printk("Vol: 0x%x\n", (val >> 16) & 0xff);
    79         printk("CTRL: 0x%x\n", (val >> 12) & 0x0f);
    80         printk("EC: 0x%x\n", val & 0x0fff);
     76        printk(KERN_DEBUG "GVSel: %i\n", val >> 31);
     77        printk(KERN_DEBUG "Pan: 0x%x\n", (val >> 24) & 0x7f);
     78        printk(KERN_DEBUG "Vol: 0x%x\n", (val >> 16) & 0xff);
     79        printk(KERN_DEBUG "CTRL: 0x%x\n", (val >> 12) & 0x0f);
     80        printk(KERN_DEBUG "EC: 0x%x\n", val & 0x0fff);
    8181        if (trident->device != TRIDENT_DEVICE_ID_NX) {
    8282                val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS));
    83                 printk("CSO: 0x%x\n", val >> 16);
     83                printk(KERN_DEBUG "CSO: 0x%x\n", val >> 16);
    8484                printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff);
    85                 printk("FMS: 0x%x\n", val & 0x0f);
     85                printk(KERN_DEBUG "FMS: 0x%x\n", val & 0x0f);
    8686                val = inl(TRID_REG(trident, CH_DX_ESO_DELTA));
    87                 printk("ESO: 0x%x\n", val >> 16);
    88                 printk("Delta: 0x%x\n", val & 0xffff);
     87                printk(KERN_DEBUG "ESO: 0x%x\n", val >> 16);
     88                printk(KERN_DEBUG "Delta: 0x%x\n", val & 0xffff);
    8989                val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL));
    9090        } else {                // TRIDENT_DEVICE_ID_NX
    9191                val = inl(TRID_REG(trident, CH_NX_DELTA_CSO));
    9292                tmp = (val >> 24) & 0xff;
    93                 printk("CSO: 0x%x\n", val & 0x00ffffff);
     93                printk(KERN_DEBUG "CSO: 0x%x\n", val & 0x00ffffff);
    9494                val = inl(TRID_REG(trident, CH_NX_DELTA_ESO));
    9595                tmp |= (val >> 16) & 0xff00;
    96                 printk("Delta: 0x%x\n", tmp);
    97                 printk("ESO: 0x%x\n", val & 0x00ffffff);
     96                printk(KERN_DEBUG "Delta: 0x%x\n", tmp);
     97                printk(KERN_DEBUG "ESO: 0x%x\n", val & 0x00ffffff);
    9898                val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL));
    99                 printk("Alpha: 0x%x\n", val >> 20);
    100                 printk("FMS: 0x%x\n", (val >> 16) & 0x0f);
    101         }
    102         printk("FMC: 0x%x\n", (val >> 14) & 3);
    103         printk("RVol: 0x%x\n", (val >> 7) & 0x7f);
    104         printk("CVol: 0x%x\n", val & 0x7f);
     99                printk(KERN_DEBUG "Alpha: 0x%x\n", val >> 20);
     100                printk(KERN_DEBUG "FMS: 0x%x\n", (val >> 16) & 0x0f);
     101        }
     102        printk(KERN_DEBUG "FMC: 0x%x\n", (val >> 14) & 3);
     103        printk(KERN_DEBUG "RVol: 0x%x\n", (val >> 7) & 0x7f);
     104        printk(KERN_DEBUG "CVol: 0x%x\n", val & 0x7f);
    105105}
    106106#endif
     
    497497
    498498#if 0
    499         printk("written %i channel:\n", voice->number);
    500         printk("  regs[0] = 0x%x/0x%x\n", regs[0], inl(TRID_REG(trident, CH_START + 0)));
    501         printk("  regs[1] = 0x%x/0x%x\n", regs[1], inl(TRID_REG(trident, CH_START + 4)));
    502         printk("  regs[2] = 0x%x/0x%x\n", regs[2], inl(TRID_REG(trident, CH_START + 8)));
    503         printk("  regs[3] = 0x%x/0x%x\n", regs[3], inl(TRID_REG(trident, CH_START + 12)));
    504         printk("  regs[4] = 0x%x/0x%x\n", regs[4], inl(TRID_REG(trident, CH_START + 16)));
     499        printk(KERN_DEBUG "written %i channel:\n", voice->number);
     500        printk(KERN_DEBUG "  regs[0] = 0x%x/0x%x\n",
     501               regs[0], inl(TRID_REG(trident, CH_START + 0)));
     502        printk(KERN_DEBUG "  regs[1] = 0x%x/0x%x\n",
     503               regs[1], inl(TRID_REG(trident, CH_START + 4)));
     504        printk(KERN_DEBUG "  regs[2] = 0x%x/0x%x\n",
     505               regs[2], inl(TRID_REG(trident, CH_START + 8)));
     506        printk(KERN_DEBUG "  regs[3] = 0x%x/0x%x\n",
     507               regs[3], inl(TRID_REG(trident, CH_START + 12)));
     508        printk(KERN_DEBUG "  regs[4] = 0x%x/0x%x\n",
     509               regs[4], inl(TRID_REG(trident, CH_START + 16)));
    505510#endif
    506511}
     
    584589                break;
    585590        case TRIDENT_DEVICE_ID_SI7018:
    586                 // printk("voice->Vol = 0x%x\n", voice->Vol);
     591                /* printk(KERN_DEBUG "voice->Vol = 0x%x\n", voice->Vol); */
    587592                outw((voice->CTRL << 12) | voice->Vol,
    588593                     TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
     
    35553560                return err;
    35563561        /* check, if we can restrict PCI DMA transfers to 30 bits */
    3557         if (pci_set_dma_mask(pci, DMA_30BIT_MASK) < 0 ||
    3558             pci_set_consistent_dma_mask(pci, DMA_30BIT_MASK) < 0) {
     3562        if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 ||
     3563            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
    35593564                snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n");
    35603565                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/via82xx.c

    r410 r426  
    467467                        } else
    468468                                flag = 0; /* period continues to the next */
    469                         // printk("via: tbl %d: at %d  size %d (rest %d)\n", idx, ofs, r, rest);
     469                        /*
     470                        printk(KERN_DEBUG "via: tbl %d: at %d  size %d "
     471                               "(rest %d)\n", idx, ofs, r, rest);
     472                        */
    470473                        ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
    471474                        dev->idx_table[idx].offset = ofs;
     
    16851688}
    16861689
    1687 static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -9450, 150, 1);
     1690static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -4650, 150, 1);
    16881691
    16891692static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = {
     
    23612364        SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA),
    23622365        SND_PCI_QUIRK(0x1019, 0x0a85, "ECS L7VMM2", VIA_DXS_NO_VRA),
    2363         SND_PCI_QUIRK(0x1019, 0, "ESC K8", VIA_DXS_SRC),
     2366        SND_PCI_QUIRK_VENDOR(0x1019, "ESC K8", VIA_DXS_SRC),
    23642367        SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC),
    23652368        SND_PCI_QUIRK(0x1025, 0x0033, "Acer Inspire 1353LM", VIA_DXS_NO_VRA),
    23662369        SND_PCI_QUIRK(0x1025, 0x0046, "Acer Aspire 1524 WLMi", VIA_DXS_SRC),
    2367         SND_PCI_QUIRK(0x1043, 0, "ASUS A7/A8", VIA_DXS_NO_VRA),
    2368         SND_PCI_QUIRK(0x1071, 0, "Diverse Notebook", VIA_DXS_NO_VRA),
     2370        SND_PCI_QUIRK_VENDOR(0x1043, "ASUS A7/A8", VIA_DXS_NO_VRA),
     2371        SND_PCI_QUIRK_VENDOR(0x1071, "Diverse Notebook", VIA_DXS_NO_VRA),
    23692372        SND_PCI_QUIRK(0x10cf, 0x118e, "FSC Laptop", VIA_DXS_ENABLE),
    2370         SND_PCI_QUIRK(0x1106, 0, "ASRock", VIA_DXS_SRC),
     2373        SND_PCI_QUIRK_VENDOR(0x1106, "ASRock", VIA_DXS_SRC),
    23712374        SND_PCI_QUIRK(0x1297, 0xa231, "Shuttle AK31v2", VIA_DXS_SRC),
    23722375        SND_PCI_QUIRK(0x1297, 0xa232, "Shuttle", VIA_DXS_SRC),
     
    23762379        SND_PCI_QUIRK(0x1462, 0x7120, "MSI KT4V", VIA_DXS_ENABLE),
    23772380        SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE),
    2378         SND_PCI_QUIRK(0x1462, 0, "MSI Mobo", VIA_DXS_SRC),
     2381        SND_PCI_QUIRK_VENDOR(0x1462, "MSI Mobo", VIA_DXS_SRC),
    23792382        SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE),
    23802383        SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE),
     
    23902393        SND_PCI_QUIRK(0x1631, 0xe004, "PB EasyNote 3174", VIA_DXS_ENABLE),
    23912394        SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE),
    2392         SND_PCI_QUIRK(0x1695, 0, "EPoX mobo", VIA_DXS_SRC),
    2393         SND_PCI_QUIRK(0x16f3, 0, "Jetway K8", VIA_DXS_SRC),
    2394         SND_PCI_QUIRK(0x1734, 0, "FSC Laptop", VIA_DXS_SRC),
     2395        SND_PCI_QUIRK_VENDOR(0x1695, "EPoX mobo", VIA_DXS_SRC),
     2396        SND_PCI_QUIRK_VENDOR(0x16f3, "Jetway K8", VIA_DXS_SRC),
     2397        SND_PCI_QUIRK_VENDOR(0x1734, "FSC Laptop", VIA_DXS_SRC),
    23952398        SND_PCI_QUIRK(0x1849, 0x3059, "ASRock K7VM2", VIA_DXS_NO_VRA),
    2396         SND_PCI_QUIRK(0x1849, 0, "ASRock mobo", VIA_DXS_SRC),
     2399        SND_PCI_QUIRK_VENDOR(0x1849, "ASRock mobo", VIA_DXS_SRC),
    23972400        SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8",  VIA_DXS_NO_VRA),
    23982401        SND_PCI_QUIRK(0x4005, 0x4710, "MSI K7T266", VIA_DXS_SRC),
  • GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci_main.c

    r399 r426  
    324324                ypcm->last_pos = pos;
    325325                if (ypcm->period_pos >= ypcm->period_size) {
    326                         // printk("done - active_bank = 0x%x, start = 0x%x\n", chip->active_bank, voice->bank[chip->active_bank].start);
     326                        /*
     327                        printk(KERN_DEBUG
     328                               "done - active_bank = 0x%x, start = 0x%x\n",
     329                               chip->active_bank,
     330                               voice->bank[chip->active_bank].start);
     331                        */
    327332                        ypcm->period_pos %= ypcm->period_size;
    328333                        spin_unlock(&chip->reg_lock);
     
    372377                if (ypcm->period_pos >= ypcm->period_size) {
    373378                        ypcm->period_pos %= ypcm->period_size;
    374                         // printk("done - active_bank = 0x%x, start = 0x%x\n", chip->active_bank, voice->bank[chip->active_bank].start);
     379                        /*
     380                        printk(KERN_DEBUG
     381                               "done - active_bank = 0x%x, start = 0x%x\n",
     382                               chip->active_bank,
     383                               voice->bank[chip->active_bank].start);
     384                        */
    375385                        spin_unlock(&chip->reg_lock);
    376386                        snd_pcm_period_elapsed(substream);
Note: See TracChangeset for help on using the changeset viewer.