Ignore:
Timestamp:
Jul 23, 2006, 11:54:27 AM (19 years ago)
Author:
vladest
Message:

Provide sources to latest exist binary. See changelog for changes

Location:
GPL/trunk/alsa-kernel/pci/ac97
Files:
4 edited

Legend:

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

    r76 r77  
    4747MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control");
    4848
     49#ifdef CONFIG_SND_AC97_POWER_SAVE
     50static int power_save = 1;
     51//module_param(power_save, bool, 0644);
     52MODULE_PARM_DESC(power_save, "Enable AC97 power-saving control");
     53#endif
    4954/*
    5055
     
    152157{ 0x4e534350, 0xffffffff, "LM4550",             NULL,           NULL },
    153158{ 0x4e534350, 0xffffffff, "LM4550",             patch_lm4550,   NULL }, // volume wrap fix
    154 { 0x50534304, 0xffffffff, "UCB1400",            NULL,           NULL },
     159{ 0x50534304, 0xffffffff, "UCB1400",            patch_ucb1400,  NULL },
    155160{ 0x53494c20, 0xffffffe0, "Si3036,8",           mpatch_si3036,  mpatch_si3036, AC97_MODEM_PATCH },
    156161{ 0x54524102, 0xffffffff, "TR28022",            NULL,           NULL },
     
    186191};
    187192
     193static void update_power_regs(struct snd_ac97 *ac97);
    188194
    189195/*
     
    543549        }
    544550        err = snd_ac97_update_bits(ac97, reg, val_mask, val);
    545         snd_ac97_page_restore(ac97, page_save);
     551        snd_ac97_page_restore(ac97, page_save);
     552#ifdef CONFIG_SND_AC97_POWER_SAVE
     553        /* check analog mixer power-down */
     554        if ((val_mask & 0x8000) &&
     555            (kcontrol->private_value & (1<<30))) {
     556                if (val & 0x8000)
     557                        ac97->power_up &= ~(1 << (reg>>1));
     558                else
     559                        ac97->power_up |= 1 << (reg>>1);
     560                if (power_save)
     561                        update_power_regs(ac97);
     562        }
     563#endif
    546564        return err;
    547565}
     
    951969static int snd_ac97_free(struct snd_ac97 *ac97)
    952970{
    953         if (ac97) {
    954                 snd_ac97_proc_done(ac97);
    955                 if (ac97->bus)
    956                         ac97->bus->codec[ac97->num] = NULL;
    957                 if (ac97->private_free)
    958                         ac97->private_free(ac97);
    959                 kfree(ac97);
    960         }
    961         return 0;
     971    if (ac97) {
     972#ifdef CONFIG_SND_AC97_POWER_SAVE
     973        if (ac97->power_workq)
     974            destroy_workqueue(ac97->power_workq);
     975#endif
     976        snd_ac97_proc_done(ac97);
     977        if (ac97->bus)
     978            ac97->bus->codec[ac97->num] = NULL;
     979        if (ac97->private_free)
     980            ac97->private_free(ac97);
     981        kfree(ac97);
     982    }
     983    return 0;
    962984}
    963985
     
    11071129 * create mute switch(es) for normal stereo controls
    11081130 */
    1109 static int snd_ac97_cmute_new_stereo(struct snd_card *card, char *name, int reg, int check_stereo, struct snd_ac97 *ac97)
     1131static int snd_ac97_cmute_new_stereo(struct snd_card *card, char *name, int reg,
     1132                                     int check_stereo, int check_amix,
     1133                                     struct snd_ac97 *ac97)
    11101134{
    11111135        struct snd_kcontrol *kctl;
     
    11351159        if (mute_mask == 0x8080) {
    11361160            tmp.private_value = reg | (15 << 8) | (7 << 12) | (1 << 16) | (1 << 24);
     1161            if (check_amix)
     1162                tmp.private_value |= (1 << 30);
    11371163        } else {
    11381164            tmp.private_value = reg | (15 << 8) | (1 << 16) | (1 << 24);
     1165            if (check_amix)
     1166                tmp.private_value |= (1 << 30);
    11391167        }
    11401168        kctl = snd_ctl_new1(&tmp, ac97);
     
    12121240 * create a mute-switch and a volume for normal stereo/mono controls
    12131241 */
    1214 static int snd_ac97_cmix_new_stereo(struct snd_card *card, const char *pfx, int reg, int check_stereo, struct snd_ac97 *ac97)
     1242static int snd_ac97_cmix_new_stereo(struct snd_card *card, const char *pfx,
     1243                                    int reg, int check_stereo, int check_amix,
     1244                                    struct snd_ac97 *ac97)
    12151245{
    12161246        int err;
     
    12221252
    12231253        if (snd_ac97_try_bit(ac97, reg, 15)) {
    1224                 sprintf(name, "%s Switch", pfx);
    1225                 if ((err = snd_ac97_cmute_new_stereo(card, name, reg, check_stereo, ac97)) < 0)
     1254            sprintf(name, "%s Switch", pfx);
     1255            if ((err = snd_ac97_cmute_new_stereo(card, name, reg,
     1256                                                 check_stereo, check_amix,
     1257                                                 ac97)) < 0)
    12261258                        return err;
    12271259        }
     
    12351267}
    12361268
    1237 #define snd_ac97_cmix_new(card, pfx, reg, ac97) snd_ac97_cmix_new_stereo(card, pfx, reg, 0, ac97)
    1238 #define snd_ac97_cmute_new(card, name, reg, ac97)       snd_ac97_cmute_new_stereo(card, name, reg, 0, ac97)
     1269#define snd_ac97_cmix_new(card, pfx, reg, acheck, ac97) \
     1270        snd_ac97_cmix_new_stereo(card, pfx, reg, 0, acheck, ac97)
     1271#define snd_ac97_cmute_new(card, name, reg, acheck, ac97) \
     1272        snd_ac97_cmute_new_stereo(card, name, reg, 0, acheck, ac97)
    12391273
    12401274static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97);
     
    12521286        if (snd_ac97_try_volume_mix(ac97, AC97_MASTER)) {
    12531287#ifndef TARGET_OS2
    1254                 if (ac97->flags & AC97_HAS_NO_MASTER_VOL)
    1255                         err = snd_ac97_cmute_new(card, "Master Playback Switch", AC97_MASTER, ac97);
    1256                 else
     1288            if (ac97->flags & AC97_HAS_NO_MASTER_VOL)
     1289                err = snd_ac97_cmute_new(card, "Master Playback Switch",
     1290                                         AC97_MASTER, 0, ac97);
     1291            else
    12571292#endif
    1258                         err = snd_ac97_cmix_new(card, "Master Playback", AC97_MASTER, ac97);
    1259                 if (err < 0)
    1260                         return err;
     1293                err = snd_ac97_cmix_new(card, "Master Playback",
     1294                                        AC97_MASTER, 0, ac97);
     1295            if (err < 0)
     1296                return err;
    12611297        }
    12621298
    12631299        ac97->regs[AC97_CENTER_LFE_MASTER] = 0x8080;
    12641300
    1265         /* build center controls */
    1266         if (snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER)) {
     1301        /* build center controls */
     1302        if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER))
     1303            && !(ac97->flags & AC97_AD_MULTI)) {
    12671304                if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_center[0], ac97))) < 0)
    12681305                        return err;
     
    12751312        }
    12761313
    1277         /* build LFE controls */
    1278         if (snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER+1)) {
     1314        /* build LFE controls */
     1315        if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER+1))
     1316            && !(ac97->flags & AC97_AD_MULTI)) {
    12791317                if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_lfe[0], ac97))) < 0)
    12801318                        return err;
     
    12871325        }
    12881326
    1289         /* build surround controls */
    1290         if (snd_ac97_try_volume_mix(ac97, AC97_SURROUND_MASTER)) {
    1291                 /* Surround Master (0x38) is with stereo mutes */
    1292                 if ((err = snd_ac97_cmix_new_stereo(card, "Surround Playback", AC97_SURROUND_MASTER, 1, ac97)) < 0)
     1327        /* build surround controls */
     1328        if ((snd_ac97_try_volume_mix(ac97, AC97_SURROUND_MASTER))
     1329            && !(ac97->flags & AC97_AD_MULTI)) {
     1330            /* Surround Master (0x38) is with stereo mutes */
     1331            if ((err = snd_ac97_cmix_new_stereo(card, "Surround Playback",
     1332                                                AC97_SURROUND_MASTER, 1, 0,
     1333                                                ac97)) < 0)
    12931334                        return err;
    12941335        }
    12951336
    12961337        /* build headphone controls */
    1297         if (snd_ac97_try_volume_mix(ac97, AC97_HEADPHONE)) {
    1298                 if ((err = snd_ac97_cmix_new(card, "Headphone Playback", AC97_HEADPHONE, ac97)) < 0)
    1299                         return err;
     1338        if (snd_ac97_try_volume_mix(ac97, AC97_HEADPHONE)) {
     1339            if ((err = snd_ac97_cmix_new(card, "Headphone Playback",
     1340                                         AC97_HEADPHONE, 0, ac97)) < 0)
     1341                return err;
    13001342        }
    13011343
    13021344        /* build master mono controls */
    1303         if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_MONO)) {
    1304                 if ((err = snd_ac97_cmix_new(card, "Master Mono Playback", AC97_MASTER_MONO, ac97)) < 0)
    1305                         return err;
     1345        if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_MONO)) {
     1346            if ((err = snd_ac97_cmix_new(card, "Master Mono Playback",
     1347                                         AC97_MASTER_MONO, 0, ac97)) < 0)
     1348                return err;
    13061349        }
    13071350
     
    13341377        /* build Phone controls */
    13351378        if (!(ac97->flags & AC97_HAS_NO_PHONE)) {
    1336                 if (snd_ac97_try_volume_mix(ac97, AC97_PHONE)) {
    1337                         if ((err = snd_ac97_cmix_new(card, "Phone Playback", AC97_PHONE, ac97)) < 0)
    1338                                 return err;
    1339                 }
    1340         }
     1379            if (snd_ac97_try_volume_mix(ac97, AC97_PHONE)) {
     1380                if ((err = snd_ac97_cmix_new(card, "Phone Playback",
     1381                                             AC97_PHONE, 1, ac97)) < 0)
     1382                    return err;
     1383            }
     1384        }
    13411385
    13421386        /* build MIC controls */
    13431387        if (!(ac97->flags & AC97_HAS_NO_MIC)) {
    1344                 if (snd_ac97_try_volume_mix(ac97, AC97_MIC)) {
    1345                         if ((err = snd_ac97_cmix_new(card, "Mic Playback", AC97_MIC, ac97)) < 0)
    1346                                 return err;
    1347                         if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_boost, ac97))) < 0)
    1348                                 return err;
    1349                 }
    1350         }
     1388            if (snd_ac97_try_volume_mix(ac97, AC97_MIC)) {
     1389                if ((err = snd_ac97_cmix_new(card, "Mic Playback",
     1390                                             AC97_MIC, 1, ac97)) < 0)
     1391                    return err;
     1392                if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_boost, ac97))) < 0)
     1393                    return err;
     1394            }
     1395        }
    13511396
    13521397        /* build Line controls */
    1353         if (snd_ac97_try_volume_mix(ac97, AC97_LINE)) {
    1354                 if ((err = snd_ac97_cmix_new(card, "Line Playback", AC97_LINE, ac97)) < 0)
    1355                         return err;
     1398        if (snd_ac97_try_volume_mix(ac97, AC97_LINE)) {
     1399            if ((err = snd_ac97_cmix_new(card, "Line Playback",
     1400                                         AC97_LINE, 1, ac97)) < 0)
     1401                return err;
    13561402        }
    13571403
    13581404        /* build CD controls */
    13591405        if (!(ac97->flags & AC97_HAS_NO_CD)) {
    1360                 if (snd_ac97_try_volume_mix(ac97, AC97_CD)) {
    1361                         if ((err = snd_ac97_cmix_new(card, "CD Playback", AC97_CD, ac97)) < 0)
    1362                                 return err;
    1363                 }
    1364         }
     1406            if (snd_ac97_try_volume_mix(ac97, AC97_CD)) {
     1407                if ((err = snd_ac97_cmix_new(card, "CD Playback",
     1408                                             AC97_CD, 1, ac97)) < 0)
     1409                    return err;
     1410            }
     1411        }
    13651412
    13661413        /* build Video controls */
    13671414        if (!(ac97->flags & AC97_HAS_NO_VIDEO)) {
    1368                 if (snd_ac97_try_volume_mix(ac97, AC97_VIDEO)) {
    1369                         if ((err = snd_ac97_cmix_new(card, "Video Playback", AC97_VIDEO, ac97)) < 0)
    1370                                 return err;
    1371                 }
    1372         }
    1373 
    1374         /* build Aux controls */
    1375         if (snd_ac97_try_volume_mix(ac97, AC97_AUX)) {
    1376                 if ((err = snd_ac97_cmix_new(card, "Aux Playback", AC97_AUX, ac97)) < 0)
    1377                         return err;
     1415            if (snd_ac97_try_volume_mix(ac97, AC97_VIDEO)) {
     1416                if ((err = snd_ac97_cmix_new(card, "Video Playback",
     1417                                             AC97_VIDEO, 1, ac97)) < 0)
     1418                    return err;
     1419            }
     1420        }
     1421
     1422        /* build Aux controls */
     1423        if (!(ac97->flags & AC97_HAS_NO_AUX)) {
     1424            if (snd_ac97_try_volume_mix(ac97, AC97_AUX)) {
     1425                if ((err = snd_ac97_cmix_new(card, "Aux Playback",
     1426                                             AC97_AUX, 1, ac97)) < 0)
     1427                    return err;
     1428            }
    13781429        }
    13791430
     
    14081459            if (!(ac97->flags & AC97_HAS_NO_STD_PCM)) {
    14091460#ifndef TARGET_OS2
    1410                         if (ac97->flags & AC97_HAS_NO_PCM_VOL)
    1411                                 err = snd_ac97_cmute_new(card, "PCM Playback Switch", AC97_PCM, ac97);
    1412                         else
     1461                if (ac97->flags & AC97_HAS_NO_PCM_VOL)
     1462                    err = snd_ac97_cmute_new(card,
     1463                                             "PCM Playback Switch",
     1464                                             AC97_PCM, 0, ac97);
     1465                else
    14131466#endif
    1414                                 err = snd_ac97_cmix_new(card, "PCM Playback", AC97_PCM, ac97);
    1415                         if (err < 0)
    1416                                 return err;
    1417                 }
     1467                    err = snd_ac97_cmix_new(card, "PCM Playback",
     1468                                            AC97_PCM, 0, ac97);
     1469                if (err < 0)
     1470                    return err;
     1471            }
    14181472        }
    14191473
     
    14221476                if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_src, ac97))) < 0)
    14231477                        return err;
    1424                 if (snd_ac97_try_bit(ac97, AC97_REC_GAIN, 15)) {
    1425                         if ((err = snd_ac97_cmute_new(card, "Capture Switch", AC97_REC_GAIN, ac97)) < 0)
    1426                                 return err;
     1478                if (snd_ac97_try_bit(ac97, AC97_REC_GAIN, 15)) {
     1479                    err = snd_ac97_cmute_new(card, "Capture Switch",
     1480                                             AC97_REC_GAIN, 0, ac97);
     1481                    if (err < 0)
     1482                        return err;
    14271483                }
    14281484                if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97))) < 0)
     
    18581914static struct snd_ac97_build_ops null_build_ops;
    18591915
     1916#ifdef CONFIG_SND_AC97_POWER_SAVE
     1917static void do_update_power(void *data)
     1918{
     1919    update_power_regs(data);
     1920}
     1921#endif
     1922
    18601923/**
    18611924 * snd_ac97_mixer - create an Codec97 component
     
    19121975        init_MUTEX(&ac97->reg_mutex);
    19131976        init_MUTEX(&ac97->page_mutex);
    1914 
     1977#ifdef CONFIG_SND_AC97_POWER_SAVE
     1978        ac97->power_workq = create_workqueue("ac97");
     1979        INIT_WORK(&ac97->power_work, do_update_power, ac97);
     1980#endif
    19151981#ifdef CONFIG_PCI
    19161982        if (ac97->pci) {
     
    21462212                }
    21472213        }
    2148         /* make sure the proper powerdown bits are cleared */
    2149         if (ac97->scaps && ac97_is_audio(ac97)) {
    2150                 reg = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
    2151                 if (ac97->scaps & AC97_SCAP_SURROUND_DAC)
    2152                         reg &= ~AC97_EA_PRJ;
    2153                 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC)
    2154                         reg &= ~(AC97_EA_PRI | AC97_EA_PRK);
    2155                 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, reg);
    2156         }
     2214        /* make sure the proper powerdown bits are cleared */
     2215        if (ac97_is_audio(ac97))
     2216            update_power_regs(ac97);
    21572217        snd_ac97_proc_init(ac97);
    21582218        if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ac97, &ops)) < 0) {
     
    21812241        }
    21822242
    2183         power = ac97->regs[AC97_POWERDOWN] | 0x8000;    /* EAPD */
    2184         power |= 0x4000;        /* Headphone amplifier powerdown */
    2185         power |= 0x0300;        /* ADC & DAC powerdown */
     2243/* surround, CLFE, mic powerdown */
     2244        power = ac97->regs[AC97_EXTENDED_STATUS];
     2245        if (ac97->scaps & AC97_SCAP_SURROUND_DAC)
     2246                power |= AC97_EA_PRJ;
     2247        if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC)
     2248                power |= AC97_EA_PRI | AC97_EA_PRK;
     2249        power |= AC97_EA_PRL;
     2250        snd_ac97_write(ac97, AC97_EXTENDED_STATUS, power);
     2251
     2252        /* powerdown external amplifier */
     2253        if (ac97->scaps & AC97_SCAP_INV_EAPD)
     2254                power = ac97->regs[AC97_POWERDOWN] & ~AC97_PD_EAPD;
     2255        else if (! (ac97->scaps & AC97_SCAP_EAPD_LED))
     2256                power = ac97->regs[AC97_POWERDOWN] | AC97_PD_EAPD;
     2257        power |= AC97_PD_PR6;   /* Headphone amplifier powerdown */
     2258        power |= AC97_PD_PR0 | AC97_PD_PR1;     /* ADC & DAC powerdown */
    21862259        snd_ac97_write(ac97, AC97_POWERDOWN, power);
    21872260        udelay(100);
    2188         power |= 0x0400;        /* Analog Mixer powerdown (Vref on) */
    2189         snd_ac97_write(ac97, AC97_POWERDOWN, power);
    2190         udelay(100);
    2191 #if 0
    2192         /* FIXME: this causes click noises on some boards at resume */
    2193         power |= 0x3800;        /* AC-link powerdown, internal Clk disable */
    2194         snd_ac97_write(ac97, AC97_POWERDOWN, power);
     2261        power |= AC97_PD_PR2 | AC97_PD_PR3;     /* Analog Mixer powerdown */
     2262        snd_ac97_write(ac97, AC97_POWERDOWN, power);
     2263#ifdef CONFIG_SND_AC97_POWER_SAVE
     2264        if (power_save) {
     2265            udelay(100);
     2266            /* AC-link powerdown, internal Clk disable */
     2267            /* FIXME: this may cause click noises on some boards */
     2268            power |= AC97_PD_PR4 | AC97_PD_PR5;
     2269            snd_ac97_write(ac97, AC97_POWERDOWN, power);
     2270        }
    21952271#endif
    21962272}
    21972273
     2274
     2275struct ac97_power_reg {
     2276    unsigned short reg;
     2277    unsigned short power_reg;
     2278    unsigned short mask;
     2279};
     2280
     2281enum { PWIDX_ADC, PWIDX_FRONT, PWIDX_CLFE, PWIDX_SURR, PWIDX_MIC, PWIDX_SIZE };
     2282
     2283static struct ac97_power_reg power_regs[PWIDX_SIZE] = {
     2284    [PWIDX_ADC] = { AC97_PCM_LR_ADC_RATE, AC97_POWERDOWN, AC97_PD_PR0},
     2285    [PWIDX_FRONT] = { AC97_PCM_FRONT_DAC_RATE, AC97_POWERDOWN, AC97_PD_PR1},
     2286    [PWIDX_CLFE] = { AC97_PCM_LFE_DAC_RATE, AC97_EXTENDED_STATUS,
     2287    AC97_EA_PRI | AC97_EA_PRK},
     2288    [PWIDX_SURR] = { AC97_PCM_SURR_DAC_RATE, AC97_EXTENDED_STATUS,
     2289    AC97_EA_PRJ},
     2290    [PWIDX_MIC] = { AC97_PCM_MIC_ADC_RATE, AC97_EXTENDED_STATUS,
     2291    AC97_EA_PRL},
     2292};
     2293
     2294#ifdef CONFIG_SND_AC97_POWER_SAVE
     2295/**
     2296 * snd_ac97_update_power - update the powerdown register
     2297 * @ac97: the codec instance
     2298 * @reg: the rate register, e.g. AC97_PCM_FRONT_DAC_RATE
     2299 * @powerup: non-zero when power up the part
     2300 *
     2301 * Update the AC97 powerdown register bits of the given part.
     2302 */
     2303int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup)
     2304{
     2305    int i;
     2306
     2307    if (! ac97)
     2308        return 0;
     2309
     2310    if (reg) {
     2311        /* SPDIF requires DAC power, too */
     2312        if (reg == AC97_SPDIF)
     2313            reg = AC97_PCM_FRONT_DAC_RATE;
     2314        for (i = 0; i < PWIDX_SIZE; i++) {
     2315            if (power_regs[i].reg == reg) {
     2316                if (powerup)
     2317                    ac97->power_up |= (1 << i);
     2318                else
     2319                    ac97->power_up &= ~(1 << i);
     2320                break;
     2321            }
     2322        }
     2323    }
     2324
     2325    if (! power_save)
     2326        return 0;
     2327
     2328    if (! powerup && ac97->power_workq)
     2329        /* adjust power-down bits after two seconds delay
     2330         * (for avoiding loud click noises for many (OSS) apps
     2331         *  that open/close frequently)
     2332         */
     2333        queue_delayed_work(ac97->power_workq, &ac97->power_work, HZ*2);
     2334    else
     2335        update_power_regs(ac97);
     2336
     2337    return 0;
     2338}
     2339
     2340EXPORT_SYMBOL(snd_ac97_update_power);
     2341#endif /* CONFIG_SND_AC97_POWER_SAVE */
     2342
     2343static void update_power_regs(struct snd_ac97 *ac97)
     2344{
     2345    unsigned int power_up, bits;
     2346    int i;
     2347
     2348#ifdef CONFIG_SND_AC97_POWER_SAVE
     2349    if (power_save)
     2350        power_up = ac97->power_up;
     2351    else {
     2352#endif
     2353        power_up = (1 << PWIDX_FRONT) | (1 << PWIDX_ADC);
     2354        power_up |= (1 << PWIDX_MIC);
     2355        if (ac97->scaps & AC97_SCAP_SURROUND_DAC)
     2356            power_up |= (1 << PWIDX_SURR);
     2357        if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC)
     2358            power_up |= (1 << PWIDX_CLFE);
     2359#ifdef CONFIG_SND_AC97_POWER_SAVE
     2360    }
     2361#endif
     2362    if (power_up) {
     2363        if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) {
     2364            /* needs power-up analog mix and vref */
     2365            snd_ac97_update_bits(ac97, AC97_POWERDOWN,
     2366                                 AC97_PD_PR3, 0);
     2367            msleep(1);
     2368            snd_ac97_update_bits(ac97, AC97_POWERDOWN,
     2369                                 AC97_PD_PR2, 0);
     2370        }
     2371    }
     2372    for (i = 0; i < PWIDX_SIZE; i++) {
     2373        if (power_up & (1 << i))
     2374            bits = 0;
     2375        else
     2376            bits = power_regs[i].mask;
     2377        snd_ac97_update_bits(ac97, power_regs[i].power_reg,
     2378                             power_regs[i].mask, bits);
     2379    }
     2380    if (! power_up) {
     2381        if (! (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2)) {
     2382            /* power down analog mix and vref */
     2383            snd_ac97_update_bits(ac97, AC97_POWERDOWN,
     2384                                 AC97_PD_PR2, AC97_PD_PR2);
     2385            snd_ac97_update_bits(ac97, AC97_POWERDOWN,
     2386                                 AC97_PD_PR3, AC97_PD_PR3);
     2387        }
     2388    }
     2389}
    21982390
    21992391#ifdef CONFIG_PM
     
    25072699        msw->put = master_mute_sw_put;
    25082700        snd_ac97_remove_ctl(ac97, "External Amplifier", NULL);
    2509         snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, 0x8000); /* mute LED on */
     2701        snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, 0x8000); /* mute LED on */
     2702        ac97->scaps |= AC97_SCAP_EAPD_LED;
    25102703        return 0;
    25112704}
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.c

    r76 r77  
    461461int patch_wolfson05(struct snd_ac97 * ac97)
    462462{
    463         /* WM9705, WM9710 */
    464         ac97->build_ops = &patch_wolfson_wm9705_ops;
    465         return 0;
     463    /* WM9705, WM9710 */
     464    ac97->build_ops = &patch_wolfson_wm9705_ops;
     465#ifdef CONFIG_TOUCHSCREEN_WM9705
     466    /* WM9705 touchscreen uses AUX and VIDEO for touch */
     467    ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
     468#endif
     469    return 0;
    466470}
    467471
     
    13661370        snd_ac97_restore_iec958(ac97);
    13671371}
     1372
     1373static void ad1888_resume(struct snd_ac97 *ac97)
     1374{
     1375    ad18xx_resume(ac97);
     1376    snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x8080);
     1377}
     1378
    13681379#endif
    13691380
     
    16261637 */
    16271638static unsigned int ad1981_jacks_blacklist[] = {
    1628         0x10140554, /* Thinkpad T42p/R50p */
    1629         0 /* end */
     1639    0x10140537, /* Thinkpad T41p */
     1640    0x10140554, /* Thinkpad T42p/R50p */
     1641    0 /* end */
    16301642};
    16311643
     
    18101822                .get = snd_ac97_ad1888_lohpsel_get,
    18111823                .put = snd_ac97_ad1888_lohpsel_put
    1812         },
     1824        },
     1825        AC97_SINGLE("V_REFOUT Enable", AC97_AD_MISC, 2, 1, 1),
     1826        AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1),
    18131827        AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0),
    18141828        {
     
    18381852        .build_specific = patch_ad1888_specific,
    18391853#ifdef CONFIG_PM
    1840         .resume = ad18xx_resume,
     1854        .resume = ad1888_resume,
    18411855#endif
    18421856        .update_jacks = ad1888_update_jacks,
     
    20462060        /* Enable SPDIF-IN only on Rev.E and above */
    20472061        val = snd_ac97_read(ac97, AC97_ALC650_CLOCK);
    2048         /* SPDIF IN with pin 47 */
    2049         if (ac97->spec.dev_flags)
    2050                 val |= 0x03; /* enable */
    2051         else
    2052                 val &= ~0x03; /* disable */
     2062        /* SPDIF IN with pin 47 */
     2063        if (ac97->spec.dev_flags &&
     2064            /* ASUS A6KM requires EAPD */
     2065            ! (ac97->subsystem_vendor == 0x1043 &&
     2066               ac97->subsystem_device == 0x1103))
     2067            val |= 0x03; /* enable */
     2068        else
     2069            val &= ~0x03; /* disable */
    20532070        snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, val);
    20542071
     
    28552872}
    28562873
     2874/*
     2875 *  UCB1400 codec (http://www.semiconductors.philips.com/acrobat_download/datasheets/UCB1400-02.pdf)
     2876 */
     2877static const struct snd_kcontrol_new snd_ac97_controls_ucb1400[] = {
     2878    /* enable/disable headphone driver which allows direct connection to
     2879     stereo headphone without the use of external DC blocking
     2880     capacitors */
     2881    AC97_SINGLE("Headphone Driver", 0x6a, 6, 1, 0),
     2882    /* Filter used to compensate the DC offset is added in the ADC to remove idle
     2883     tones from the audio band. */
     2884    AC97_SINGLE("DC Filter", 0x6a, 4, 1, 0),
     2885    /* Control smart-low-power mode feature. Allows automatic power down
     2886     of unused blocks in the ADC analog front end and the PLL. */
     2887    AC97_SINGLE("Smart Low Power Mode", 0x6c, 4, 3, 0),
     2888};
     2889
     2890static int patch_ucb1400_specific(struct snd_ac97 * ac97)
     2891{
     2892    int idx, err;
     2893    for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_ucb1400); idx++)
     2894        if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97))) < 0)
     2895            return err;
     2896    return 0;
     2897}
     2898
     2899static struct snd_ac97_build_ops patch_ucb1400_ops = {
     2900    .build_specific     = patch_ucb1400_specific,
     2901};
     2902
     2903int patch_ucb1400(struct snd_ac97 * ac97)
     2904{
     2905    ac97->build_ops = &patch_ucb1400_ops;
     2906    /* enable headphone driver and smart low power mode by default */
     2907    snd_ac97_write(ac97, 0x6a, 0x0050);
     2908    snd_ac97_write(ac97, 0x6c, 0x0030);
     2909    return 0;
     2910}
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.h

    r76 r77  
    5959int patch_vt1617a(struct snd_ac97 * ac97);
    6060int patch_it2646(struct snd_ac97 * ac97);
     61int patch_ucb1400(struct snd_ac97 * ac97);
    6162int mpatch_si3036(struct snd_ac97 * ac97);
    6263int patch_lm4550(struct snd_ac97 * ac97);
  • GPL/trunk/alsa-kernel/pci/ac97/ac97_pcm.c

    r72 r77  
    259259        int dbl;
    260260        unsigned int tmp;
    261        
     261
    262262        dbl = rate > 48000;
    263263        if (dbl) {
     
    268268        }
    269269
     270        snd_ac97_update_power(ac97, reg, 1);
    270271        switch (reg) {
    271272        case AC97_PCM_MIC_ADC_RATE:
     
    600601                        goto error;
    601602                }
    602         }
     603        }
     604        pcm->cur_dbl = r;
    603605        spin_unlock_irq(&pcm->bus->bus_lock);
    604606        for (i = 3; i < 12; i++) {
     
    640642int snd_ac97_pcm_close(struct ac97_pcm *pcm)
    641643{
    642         struct snd_ac97_bus *bus;
    643         unsigned short slots = pcm->aslots;
    644         int i, cidx;
    645 
    646         bus = pcm->bus;
    647         spin_lock_irq(&pcm->bus->bus_lock);
    648         for (i = 3; i < 12; i++) {
    649                 if (!(slots & (1 << i)))
    650                         continue;
    651                 for (cidx = 0; cidx < 4; cidx++)
    652                         bus->used_slots[pcm->stream][cidx] &= ~(1 << i);
    653         }
    654         pcm->aslots = 0;
    655         spin_unlock_irq(&pcm->bus->bus_lock);
    656         return 0;
     644    struct snd_ac97_bus *bus;
     645    unsigned short slots = pcm->aslots;
     646    int i, cidx;
     647
     648#ifdef CONFIG_SND_AC97_POWER_SAVE
     649    int r = pcm->cur_dbl;
     650    for (i = 3; i < 12; i++) {
     651        if (!(slots & (1 << i)))
     652            continue;
     653        for (cidx = 0; cidx < 4; cidx++) {
     654            if (pcm->r[r].rslots[cidx] & (1 << i)) {
     655                int reg = get_slot_reg(pcm, cidx, i, r);
     656                snd_ac97_update_power(pcm->r[r].codec[cidx],
     657                                      reg, 0);
     658            }
     659        }
     660    }
     661#endif
     662
     663    bus = pcm->bus;
     664    spin_lock_irq(&pcm->bus->bus_lock);
     665    for (i = 3; i < 12; i++) {
     666        if (!(slots & (1 << i)))
     667            continue;
     668        for (cidx = 0; cidx < 4; cidx++)
     669            bus->used_slots[pcm->stream][cidx] &= ~(1 << i);
     670    }
     671    pcm->aslots = 0;
     672    pcm->cur_dbl = 0;
     673    spin_unlock_irq(&pcm->bus->bus_lock);
     674    return 0;
    657675}
    658676
Note: See TracChangeset for help on using the changeset viewer.