Ignore:
Timestamp:
Jan 14, 2006, 6:38:48 PM (20 years ago)
Author:
vladest
Message:

Ensonic/Maestro3/VIA/ATI power management fixes
Intel ICH SI7012 fixes

File:
1 edited

Legend:

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

    r64 r70  
    260260#define   ICH_SAMPLE_16_20      0x00400000      /* ICH4: 16- and 20-bit samples */
    261261#define   ICH_MULTICHAN_CAP     0x00300000      /* ICH4: multi-channel capability bits (RO) */
     262#define   ICH_SIS_TRI           0x00080000      /* SIS: tertiary resume irq */
     263#define   ICH_SIS_TCR           0x00040000      /* SIS: tertiary codec ready */
    262264#define   ICH_MD3               0x00020000      /* modem power down semaphore */
    263265#define   ICH_AD3               0x00010000      /* audio power down semaphore */
     
    457459    ac97_t *ac97[3];
    458460    unsigned int ac97_sdin[3];
     461    unsigned int max_codecs, ncodecs;
     462    unsigned int *codec_bit;
     463    unsigned int codec_isr_bits;
     464    unsigned int codec_ready_bits;
    459465
    460466    snd_rawmidi_t *rmidi;
     
    577583 */
    578584
    579 /* return the GLOB_STA bit for the corresponding codec */
    580 static unsigned int get_ich_codec_bit(struct intel8x0 *chip, unsigned int codec)
    581 {
    582     static unsigned int codec_bit[3] = {
    583         ICH_PCR, ICH_SCR, ICH_TCR
    584     };
    585     snd_assert(codec < 3, return ICH_PCR);
    586     if (chip->device_type == DEVICE_INTEL_ICH4 ||
    587         chip->device_type == DEVICE_INTEL_ICH5)
    588         codec = chip->ac97_sdin[codec];
    589     return codec_bit[codec];
    590 }
    591 
    592585static int snd_intel8x0_codec_semaphore(struct intel8x0 *chip, unsigned int codec)
    593586{
     
    599592        /* we don't know the ready bit assignment at the moment */
    600593        /* so we check any */
    601         codec = ICH_PCR | ICH_SCR | ICH_TCR;
     594        codec = chip->codec_isr_bits;
    602595    } else {
    603         codec = get_ich_codec_bit(chip, codec);
     596        codec = chip->codec_bit[chip->ac97_sdin[codec]];
    604597    }
    605598
     
    654647        if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) {
    655648            /* reset RCS and preserve other R/WC bits */
    656             iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
     649            iputdword(chip, ICHREG(GLOB_STA), tmp & ~(chip->codec_ready_bits | ICH_GSCI));
    657650            if (! chip->in_ac97_init)
    658651                snd_printk("codec_read %d: read timeout for register 0x%x\n", ac97->num, reg);
     
    663656}
    664657
    665 static void snd_intel8x0_codec_read_test(struct intel8x0 *chip, unsigned int codec)
     658static void __devinit snd_intel8x0_codec_read_test(struct intel8x0 *chip,
     659                                                   unsigned int codec)
    666660{
    667661    unsigned int tmp;
     
    671665        if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) {
    672666            /* reset RCS and preserve other R/WC bits */
    673             iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
     667            iputdword(chip, ICHREG(GLOB_STA), tmp & ~(chip->codec_ready_bits | ICH_GSCI));
    674668        }
    675669    }
     
    18221816        },
    18231817        {
    1824                 .subvendor = 0x1028,
     1818            .subvendor = 0x1028,
     1819            .subdevice = 0x0151,
     1820            .name = "Dell Optiplex GX270",  /* AD1981B */
     1821            .type = AC97_TUNE_HP_ONLY
     1822        },
     1823        {
     1824            .subvendor = 0x1028,
    18251825                .subdevice = 0x0163,
    18261826                .name = "Dell Unknown", /* STAC9750/51 */
     
    18621862            .name = "HP nx8220",
    18631863            .type = AC97_TUNE_MUTE_LED
    1864         },
    1865         {
    1866             .subvendor = 0x103c,
    1867             .subdevice = 0x099c,
    1868             .name = "HP nx6110",    /* AD1981B */
    1869             .type = AC97_TUNE_HP_ONLY
    18701864        },
    18711865        {
     
    18901884            .subvendor = 0x103c,
    18911885            .subdevice = 0x0944,
    1892             .name = "HP nc6220",
     1886            .name = "HP nx6110/nc6120",
    18931887            .type = AC97_TUNE_HP_MUTE_LED
    18941888        },
     
    20922086        glob_sta = igetdword(chip, ICHREG(GLOB_STA));
    20932087        ops = &standard_bus_ops;
    2094         if (chip->device_type == DEVICE_INTEL_ICH4 ||
    2095             chip->device_type == DEVICE_INTEL_ICH5) {
    2096             codecs = 0;
    2097             if (glob_sta & ICH_PCR)
    2098                 codecs++;
    2099             if (glob_sta & ICH_SCR)
    2100                 codecs++;
    2101             if (glob_sta & ICH_TCR)
    2102                 codecs++;
     2088        chip->in_sdin_init = 1;
     2089        codecs = 0;
     2090        for (i = 0; i < chip->max_codecs; i++) {
     2091            if (! (glob_sta & chip->codec_bit[i]))
     2092                continue;
     2093            if (chip->device_type == DEVICE_INTEL_ICH4 ||
     2094                chip->device_type == DEVICE_INTEL_ICH5) {
     2095                snd_intel8x0_codec_read_test(chip, codecs);
     2096                chip->ac97_sdin[codecs] =
     2097                    igetbyte(chip, ICHREG(SDM)) & ICH_LDI_MASK;
     2098                snd_assert(chip->ac97_sdin[codecs] < 3,
     2099                           chip->ac97_sdin[codecs] = 0);
     2100            } else
     2101                chip->ac97_sdin[codecs] = i;
     2102            codecs++;
    21032103            chip->in_sdin_init = 1;
    2104 #if 1 //vladest 06.10.2003 15:55 - bull shit!!! it doesnt works here
    2105             for (i = 0; i < codecs; i++) {
    2106                 printk("codec %i read test begins...", i);
    2107                 snd_intel8x0_codec_read_test(chip, i);
    2108                 chip->ac97_sdin[i] = igetbyte(chip, ICHREG(SDM)) & ICH_LDI_MASK;
    2109                 printk("finished\n");
    2110             }
    2111 #endif
    2112             chip->in_sdin_init = 0;
    2113         } else {
    2114             codecs = glob_sta & ICH_SCR ? 2 : 1;
    2115         }
     2104        }
     2105        chip->in_sdin_init = 0;
     2106        if (! codecs)
     2107            codecs = 1;
    21162108    } else {
    21172109        ops = &ali_bus_ops;
     
    21312123        goto __err;
    21322124    pbus->private_free = snd_intel8x0_mixer_free_ac97_bus;
    2133     pbus->shared_type = AC97_SHARED_TYPE_ICH;       /* shared with modem driver */
    21342125    if (ac97_clock >= 8000 && ac97_clock <= 48000)
    21352126        pbus->clock = ac97_clock;
     
    21402131        pbus->dra = 1;
    21412132    chip->ac97_bus = pbus;
     2133    chip->ncodecs = codecs;
    21422134
    21432135    ac97.pci = chip->pci;
     
    23202312        i = 0;
    23212313        do {
    2322             status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR);
     2314            status = igetdword(chip, ICHREG(GLOB_STA)) & chip->codec_isr_bits;;
    23232315            if (status)
    23242316                break;
     
    23382330//        mdelay(50);
    23392331
    2340         if (chip->device_type == DEVICE_INTEL_ICH4 ||
    2341             chip->device_type == DEVICE_INTEL_ICH5)
    2342             /* ICH4 can have three codecs */
    2343             nstatus = ICH_PCR | ICH_SCR | ICH_TCR;
    2344         else
    2345             /* others up to two codecs */
    2346             nstatus = ICH_PCR | ICH_SCR;
    23472332        /* wait for other codecs ready status. */
    23482333        end_time = jiffies + HZ / 4;
    2349         while (status != nstatus && time_after_eq(end_time, jiffies)) {
     2334        while (status != chip->codec_isr_bits &&
     2335               time_after_eq(end_time, jiffies)) {
    23502336            do_delay(chip);
    2351             status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus;
     2337            status |= igetdword(chip, ICHREG(GLOB_STA)) &
     2338                chip->codec_isr_bits;
    23522339        }
    23532340    } else {
     
    23552342        int i;
    23562343        status = 0;
    2357         for (i = 0; i < 3; i++)
     2344        for (i = 0; i < chip->ncodecs; i++)
    23582345            if (chip->ac97[i])
    2359                 status |= get_ich_codec_bit(chip, i);
     2346                status |= chip->codec_bit[chip->ac97_sdin[i]];
    23602347        /* wait until all the probed codecs are ready */
    23612348        end_time = jiffies + HZ;
    23622349        do {
    2363             nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR);
     2350            nstatus = igetdword(chip, ICHREG(GLOB_STA)) & chip->codec_isr_bits;;
    23642351            if (status == nstatus)
    23652352                break;
     
    24972484        snd_pcm_suspend_all(chip->pcm[i]);
    24982485
    2499     for (i = 0; i < 3; i++)
     2486    for (i = 0; i < chip->ncodecs; i++)
    25002487        if (chip->ac97[i])      //Rudi: check, if codec present !!!
    25012488            snd_ac97_suspend(chip->ac97[i]);
     
    25362523    }
    25372524
    2538     for (i = 0; i < 3; i++)
     2525    for (i = 0; i < chip->ncodecs; i++)
    25392526        if (chip->ac97[i])              //Rudi: check, if codec present !!!
    25402527            snd_ac97_resume(chip->ac97[i]);
     
    26552642        chip->device_type == DEVICE_INTEL_ICH5)
    26562643        snd_iprintf(buffer, "SDM                   : 0x%08x\n", igetdword(chip, ICHREG(SDM)));
    2657     snd_iprintf(buffer, "AC'97 codecs ready    :%s%s%s%s\n",
    2658                 tmp & ICH_PCR ? " primary" : "",
    2659                 tmp & ICH_SCR ? " secondary" : "",
    2660                 tmp & ICH_TCR ? " tertiary" : "",
    2661                 (tmp & (ICH_PCR | ICH_SCR | ICH_TCR)) == 0 ? " none" : "");
     2644    snd_iprintf(buffer, "AC'97 codecs ready    :");
     2645    if (tmp & chip->codec_isr_bits) {
     2646        int i;
     2647        static const char *codecs[3] = {
     2648            "primary", "secondary", "tertiary"
     2649        };
     2650        for (i = 0; i < chip->max_codecs; i++)
     2651            if (tmp & chip->codec_bit[i])
     2652                snd_iprintf(buffer, " %s", codecs[i]);
     2653    } else
     2654        snd_iprintf(buffer, " none");
     2655    snd_iprintf(buffer, "\n");
    26622656    if (chip->device_type == DEVICE_INTEL_ICH4 ||
    2663         chip->device_type == DEVICE_INTEL_ICH5)
     2657                     chip->device_type == DEVICE_SIS)
    26642658        snd_iprintf(buffer, "AC'97 codecs SDIN     : %i %i %i\n",
    26652659                    chip->ac97_sdin[0],
     
    26902684};
    26912685
     2686static unsigned int ich_codec_bits[3] = {
     2687    ICH_PCR, ICH_SCR, ICH_TCR
     2688};
     2689static unsigned int sis_codec_bits[3] = {
     2690    ICH_PCR, ICH_SCR, ICH_SIS_TCR
     2691};
    26922692
    26932693static int __devinit snd_intel8x0_create(snd_card_t * card,
     
    29292929    synchronize_irq(chip->irq);
    29302930
     2931    switch(chip->device_type) {
     2932    case DEVICE_INTEL_ICH4:
     2933    case DEVICE_INTEL_ICH5:
     2934        /* ICH4/5 can have three codecs */
     2935        chip->max_codecs = 3;
     2936        chip->codec_bit = ich_codec_bits;
     2937        chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_TRI;
     2938        break;
     2939    case DEVICE_SIS:
     2940        /* recent SIS7012 can have three codecs */
     2941        chip->max_codecs = 3;
     2942        chip->codec_bit = sis_codec_bits;
     2943        chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_SIS_TRI;
     2944        break;
     2945    default:
     2946        /* others up to two codecs */
     2947        chip->max_codecs = 2;
     2948        chip->codec_bit = ich_codec_bits;
     2949        chip->codec_ready_bits = ICH_PRI | ICH_SRI;
     2950        break;
     2951    }
     2952    for (i = 0; i < chip->max_codecs; i++)
     2953        chip->codec_isr_bits |= chip->codec_bit[i];
     2954
    29312955    if ((err = snd_intel8x0_chip_init(chip, 1)) < 0) {
    29322956        snd_intel8x0_free(chip);
Note: See TracChangeset for help on using the changeset viewer.