Changeset 77 for GPL/trunk/alsa-kernel/pci/ac97
- Timestamp:
- Jul 23, 2006, 11:54:27 AM (19 years ago)
- Location:
- GPL/trunk/alsa-kernel/pci/ac97
- Files:
-
- 4 edited
-
ac97_codec.c (modified) (21 diffs)
-
ac97_patch.c (modified) (7 diffs)
-
ac97_patch.h (modified) (1 diff)
-
ac97_pcm.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/pci/ac97/ac97_codec.c
r76 r77 47 47 MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control"); 48 48 49 #ifdef CONFIG_SND_AC97_POWER_SAVE 50 static int power_save = 1; 51 //module_param(power_save, bool, 0644); 52 MODULE_PARM_DESC(power_save, "Enable AC97 power-saving control"); 53 #endif 49 54 /* 50 55 … … 152 157 { 0x4e534350, 0xffffffff, "LM4550", NULL, NULL }, 153 158 { 0x4e534350, 0xffffffff, "LM4550", patch_lm4550, NULL }, // volume wrap fix 154 { 0x50534304, 0xffffffff, "UCB1400", NULL,NULL },159 { 0x50534304, 0xffffffff, "UCB1400", patch_ucb1400, NULL }, 155 160 { 0x53494c20, 0xffffffe0, "Si3036,8", mpatch_si3036, mpatch_si3036, AC97_MODEM_PATCH }, 156 161 { 0x54524102, 0xffffffff, "TR28022", NULL, NULL }, … … 186 191 }; 187 192 193 static void update_power_regs(struct snd_ac97 *ac97); 188 194 189 195 /* … … 543 549 } 544 550 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 546 564 return err; 547 565 } … … 951 969 static int snd_ac97_free(struct snd_ac97 *ac97) 952 970 { 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; 962 984 } 963 985 … … 1107 1129 * create mute switch(es) for normal stereo controls 1108 1130 */ 1109 static int snd_ac97_cmute_new_stereo(struct snd_card *card, char *name, int reg, int check_stereo, struct snd_ac97 *ac97) 1131 static 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) 1110 1134 { 1111 1135 struct snd_kcontrol *kctl; … … 1135 1159 if (mute_mask == 0x8080) { 1136 1160 tmp.private_value = reg | (15 << 8) | (7 << 12) | (1 << 16) | (1 << 24); 1161 if (check_amix) 1162 tmp.private_value |= (1 << 30); 1137 1163 } else { 1138 1164 tmp.private_value = reg | (15 << 8) | (1 << 16) | (1 << 24); 1165 if (check_amix) 1166 tmp.private_value |= (1 << 30); 1139 1167 } 1140 1168 kctl = snd_ctl_new1(&tmp, ac97); … … 1212 1240 * create a mute-switch and a volume for normal stereo/mono controls 1213 1241 */ 1214 static int snd_ac97_cmix_new_stereo(struct snd_card *card, const char *pfx, int reg, int check_stereo, struct snd_ac97 *ac97) 1242 static 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) 1215 1245 { 1216 1246 int err; … … 1222 1252 1223 1253 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) 1226 1258 return err; 1227 1259 } … … 1235 1267 } 1236 1268 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) 1239 1273 1240 1274 static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97); … … 1252 1286 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER)) { 1253 1287 #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 1257 1292 #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; 1261 1297 } 1262 1298 1263 1299 ac97->regs[AC97_CENTER_LFE_MASTER] = 0x8080; 1264 1300 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)) { 1267 1304 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_center[0], ac97))) < 0) 1268 1305 return err; … … 1275 1312 } 1276 1313 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)) { 1279 1317 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_lfe[0], ac97))) < 0) 1280 1318 return err; … … 1287 1325 } 1288 1326 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) 1293 1334 return err; 1294 1335 } 1295 1336 1296 1337 /* 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; 1300 1342 } 1301 1343 1302 1344 /* 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; 1306 1349 } 1307 1350 … … 1334 1377 /* build Phone controls */ 1335 1378 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 } 1341 1385 1342 1386 /* build MIC controls */ 1343 1387 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 } 1351 1396 1352 1397 /* 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; 1356 1402 } 1357 1403 1358 1404 /* build CD controls */ 1359 1405 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 } 1365 1412 1366 1413 /* build Video controls */ 1367 1414 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 } 1378 1429 } 1379 1430 … … 1408 1459 if (!(ac97->flags & AC97_HAS_NO_STD_PCM)) { 1409 1460 #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 1413 1466 #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 } 1418 1472 } 1419 1473 … … 1422 1476 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_src, ac97))) < 0) 1423 1477 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; 1427 1483 } 1428 1484 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97))) < 0) … … 1858 1914 static struct snd_ac97_build_ops null_build_ops; 1859 1915 1916 #ifdef CONFIG_SND_AC97_POWER_SAVE 1917 static void do_update_power(void *data) 1918 { 1919 update_power_regs(data); 1920 } 1921 #endif 1922 1860 1923 /** 1861 1924 * snd_ac97_mixer - create an Codec97 component … … 1912 1975 init_MUTEX(&ac97->reg_mutex); 1913 1976 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 1915 1981 #ifdef CONFIG_PCI 1916 1982 if (ac97->pci) { … … 2146 2212 } 2147 2213 } 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); 2157 2217 snd_ac97_proc_init(ac97); 2158 2218 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ac97, &ops)) < 0) { … … 2181 2241 } 2182 2242 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 */ 2186 2259 snd_ac97_write(ac97, AC97_POWERDOWN, power); 2187 2260 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 } 2195 2271 #endif 2196 2272 } 2197 2273 2274 2275 struct ac97_power_reg { 2276 unsigned short reg; 2277 unsigned short power_reg; 2278 unsigned short mask; 2279 }; 2280 2281 enum { PWIDX_ADC, PWIDX_FRONT, PWIDX_CLFE, PWIDX_SURR, PWIDX_MIC, PWIDX_SIZE }; 2282 2283 static 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 */ 2303 int 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 2340 EXPORT_SYMBOL(snd_ac97_update_power); 2341 #endif /* CONFIG_SND_AC97_POWER_SAVE */ 2342 2343 static 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 } 2198 2390 2199 2391 #ifdef CONFIG_PM … … 2507 2699 msw->put = master_mute_sw_put; 2508 2700 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; 2510 2703 return 0; 2511 2704 } -
GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.c
r76 r77 461 461 int patch_wolfson05(struct snd_ac97 * ac97) 462 462 { 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; 466 470 } 467 471 … … 1366 1370 snd_ac97_restore_iec958(ac97); 1367 1371 } 1372 1373 static 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 1368 1379 #endif 1369 1380 … … 1626 1637 */ 1627 1638 static 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 */ 1630 1642 }; 1631 1643 … … 1810 1822 .get = snd_ac97_ad1888_lohpsel_get, 1811 1823 .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), 1813 1827 AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0), 1814 1828 { … … 1838 1852 .build_specific = patch_ad1888_specific, 1839 1853 #ifdef CONFIG_PM 1840 .resume = ad18xx_resume,1854 .resume = ad1888_resume, 1841 1855 #endif 1842 1856 .update_jacks = ad1888_update_jacks, … … 2046 2060 /* Enable SPDIF-IN only on Rev.E and above */ 2047 2061 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 */ 2053 2070 snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, val); 2054 2071 … … 2855 2872 } 2856 2873 2874 /* 2875 * UCB1400 codec (http://www.semiconductors.philips.com/acrobat_download/datasheets/UCB1400-02.pdf) 2876 */ 2877 static 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 2890 static 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 2899 static struct snd_ac97_build_ops patch_ucb1400_ops = { 2900 .build_specific = patch_ucb1400_specific, 2901 }; 2902 2903 int 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 59 59 int patch_vt1617a(struct snd_ac97 * ac97); 60 60 int patch_it2646(struct snd_ac97 * ac97); 61 int patch_ucb1400(struct snd_ac97 * ac97); 61 62 int mpatch_si3036(struct snd_ac97 * ac97); 62 63 int patch_lm4550(struct snd_ac97 * ac97); -
GPL/trunk/alsa-kernel/pci/ac97/ac97_pcm.c
r72 r77 259 259 int dbl; 260 260 unsigned int tmp; 261 261 262 262 dbl = rate > 48000; 263 263 if (dbl) { … … 268 268 } 269 269 270 snd_ac97_update_power(ac97, reg, 1); 270 271 switch (reg) { 271 272 case AC97_PCM_MIC_ADC_RATE: … … 600 601 goto error; 601 602 } 602 } 603 } 604 pcm->cur_dbl = r; 603 605 spin_unlock_irq(&pcm->bus->bus_lock); 604 606 for (i = 3; i < 12; i++) { … … 640 642 int snd_ac97_pcm_close(struct ac97_pcm *pcm) 641 643 { 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; 657 675 } 658 676
Note:
See TracChangeset
for help on using the changeset viewer.
