aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_intel.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/hda_intel.c')
-rw-r--r--sound/pci/hda/hda_intel.c121
1 files changed, 80 insertions, 41 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index f3b5723c2859..30829ee920c3 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -381,6 +381,7 @@ struct azx {
381 381
382 /* HD codec */ 382 /* HD codec */
383 unsigned short codec_mask; 383 unsigned short codec_mask;
384 int codec_probe_mask; /* copied from probe_mask option */
384 struct hda_bus *bus; 385 struct hda_bus *bus;
385 386
386 /* CORB/RIRB */ 387 /* CORB/RIRB */
@@ -858,13 +859,18 @@ static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
858 SD_CTL_DMA_START | SD_INT_MASK); 859 SD_CTL_DMA_START | SD_INT_MASK);
859} 860}
860 861
861/* stop a stream */ 862/* stop DMA */
862static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) 863static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
863{ 864{
864 /* stop DMA */
865 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & 865 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
866 ~(SD_CTL_DMA_START | SD_INT_MASK)); 866 ~(SD_CTL_DMA_START | SD_INT_MASK));
867 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ 867 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
868}
869
870/* stop a stream */
871static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
872{
873 azx_stream_clear(chip, azx_dev);
868 /* disable SIE */ 874 /* disable SIE */
869 azx_writeb(chip, INTCTL, 875 azx_writeb(chip, INTCTL,
870 azx_readb(chip, INTCTL) & ~(1 << azx_dev->index)); 876 azx_readb(chip, INTCTL) & ~(1 << azx_dev->index));
@@ -1075,8 +1081,7 @@ static int azx_setup_periods(struct azx *chip,
1075 azx_sd_writel(azx_dev, SD_BDLPL, 0); 1081 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1076 azx_sd_writel(azx_dev, SD_BDLPU, 0); 1082 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1077 1083
1078 period_bytes = snd_pcm_lib_period_bytes(substream); 1084 period_bytes = azx_dev->period_bytes;
1079 azx_dev->period_bytes = period_bytes;
1080 periods = azx_dev->bufsize / period_bytes; 1085 periods = azx_dev->bufsize / period_bytes;
1081 1086
1082 /* program the initial BDL entries */ 1087 /* program the initial BDL entries */
@@ -1123,24 +1128,17 @@ static int azx_setup_periods(struct azx *chip,
1123 error: 1128 error:
1124 snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n", 1129 snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n",
1125 azx_dev->bufsize, period_bytes); 1130 azx_dev->bufsize, period_bytes);
1126 /* reset */
1127 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1128 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1129 return -EINVAL; 1131 return -EINVAL;
1130} 1132}
1131 1133
1132/* 1134/* reset stream */
1133 * set up the SD for streaming 1135static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
1134 */
1135static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1136{ 1136{
1137 unsigned char val; 1137 unsigned char val;
1138 int timeout; 1138 int timeout;
1139 1139
1140 /* make sure the run bit is zero for SD */ 1140 azx_stream_clear(chip, azx_dev);
1141 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & 1141
1142 ~SD_CTL_DMA_START);
1143 /* reset stream */
1144 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | 1142 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
1145 SD_CTL_STREAM_RESET); 1143 SD_CTL_STREAM_RESET);
1146 udelay(3); 1144 udelay(3);
@@ -1157,7 +1155,15 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1157 while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && 1155 while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
1158 --timeout) 1156 --timeout)
1159 ; 1157 ;
1158}
1160 1159
1160/*
1161 * set up the SD for streaming
1162 */
1163static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1164{
1165 /* make sure the run bit is zero for SD */
1166 azx_stream_clear(chip, azx_dev);
1161 /* program the stream_tag */ 1167 /* program the stream_tag */
1162 azx_sd_writel(azx_dev, SD_CTL, 1168 azx_sd_writel(azx_dev, SD_CTL,
1163 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)| 1169 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)|
@@ -1228,7 +1234,6 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1228}; 1234};
1229 1235
1230static int __devinit azx_codec_create(struct azx *chip, const char *model, 1236static int __devinit azx_codec_create(struct azx *chip, const char *model,
1231 unsigned int codec_probe_mask,
1232 int no_init) 1237 int no_init)
1233{ 1238{
1234 struct hda_bus_template bus_temp; 1239 struct hda_bus_template bus_temp;
@@ -1261,7 +1266,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1261 1266
1262 /* First try to probe all given codec slots */ 1267 /* First try to probe all given codec slots */
1263 for (c = 0; c < max_slots; c++) { 1268 for (c = 0; c < max_slots; c++) {
1264 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1269 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1265 if (probe_codec(chip, c) < 0) { 1270 if (probe_codec(chip, c) < 0) {
1266 /* Some BIOSen give you wrong codec addresses 1271 /* Some BIOSen give you wrong codec addresses
1267 * that don't exist 1272 * that don't exist
@@ -1285,7 +1290,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1285 1290
1286 /* Then create codec instances */ 1291 /* Then create codec instances */
1287 for (c = 0; c < max_slots; c++) { 1292 for (c = 0; c < max_slots; c++) {
1288 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1293 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1289 struct hda_codec *codec; 1294 struct hda_codec *codec;
1290 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); 1295 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec);
1291 if (err < 0) 1296 if (err < 0)
@@ -1403,6 +1408,8 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1403 runtime->private_data = azx_dev; 1408 runtime->private_data = azx_dev;
1404 snd_pcm_set_sync(substream); 1409 snd_pcm_set_sync(substream);
1405 mutex_unlock(&chip->open_mutex); 1410 mutex_unlock(&chip->open_mutex);
1411
1412 azx_stream_reset(chip, azx_dev);
1406 return 0; 1413 return 0;
1407} 1414}
1408 1415
@@ -1429,6 +1436,11 @@ static int azx_pcm_close(struct snd_pcm_substream *substream)
1429static int azx_pcm_hw_params(struct snd_pcm_substream *substream, 1436static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
1430 struct snd_pcm_hw_params *hw_params) 1437 struct snd_pcm_hw_params *hw_params)
1431{ 1438{
1439 struct azx_dev *azx_dev = get_azx_dev(substream);
1440
1441 azx_dev->bufsize = 0;
1442 azx_dev->period_bytes = 0;
1443 azx_dev->format_val = 0;
1432 return snd_pcm_lib_malloc_pages(substream, 1444 return snd_pcm_lib_malloc_pages(substream,
1433 params_buffer_bytes(hw_params)); 1445 params_buffer_bytes(hw_params));
1434} 1446}
@@ -1443,6 +1455,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
1443 azx_sd_writel(azx_dev, SD_BDLPL, 0); 1455 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1444 azx_sd_writel(azx_dev, SD_BDLPU, 0); 1456 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1445 azx_sd_writel(azx_dev, SD_CTL, 0); 1457 azx_sd_writel(azx_dev, SD_CTL, 0);
1458 azx_dev->bufsize = 0;
1459 azx_dev->period_bytes = 0;
1460 azx_dev->format_val = 0;
1446 1461
1447 hinfo->ops.cleanup(hinfo, apcm->codec, substream); 1462 hinfo->ops.cleanup(hinfo, apcm->codec, substream);
1448 1463
@@ -1456,23 +1471,37 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1456 struct azx_dev *azx_dev = get_azx_dev(substream); 1471 struct azx_dev *azx_dev = get_azx_dev(substream);
1457 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1472 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1458 struct snd_pcm_runtime *runtime = substream->runtime; 1473 struct snd_pcm_runtime *runtime = substream->runtime;
1474 unsigned int bufsize, period_bytes, format_val;
1475 int err;
1459 1476
1460 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); 1477 format_val = snd_hda_calc_stream_format(runtime->rate,
1461 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate, 1478 runtime->channels,
1462 runtime->channels, 1479 runtime->format,
1463 runtime->format, 1480 hinfo->maxbps);
1464 hinfo->maxbps); 1481 if (!format_val) {
1465 if (!azx_dev->format_val) {
1466 snd_printk(KERN_ERR SFX 1482 snd_printk(KERN_ERR SFX
1467 "invalid format_val, rate=%d, ch=%d, format=%d\n", 1483 "invalid format_val, rate=%d, ch=%d, format=%d\n",
1468 runtime->rate, runtime->channels, runtime->format); 1484 runtime->rate, runtime->channels, runtime->format);
1469 return -EINVAL; 1485 return -EINVAL;
1470 } 1486 }
1471 1487
1488 bufsize = snd_pcm_lib_buffer_bytes(substream);
1489 period_bytes = snd_pcm_lib_period_bytes(substream);
1490
1472 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n", 1491 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
1473 azx_dev->bufsize, azx_dev->format_val); 1492 bufsize, format_val);
1474 if (azx_setup_periods(chip, substream, azx_dev) < 0) 1493
1475 return -EINVAL; 1494 if (bufsize != azx_dev->bufsize ||
1495 period_bytes != azx_dev->period_bytes ||
1496 format_val != azx_dev->format_val) {
1497 azx_dev->bufsize = bufsize;
1498 azx_dev->period_bytes = period_bytes;
1499 azx_dev->format_val = format_val;
1500 err = azx_setup_periods(chip, substream, azx_dev);
1501 if (err < 0)
1502 return err;
1503 }
1504
1476 azx_setup_controller(chip, azx_dev); 1505 azx_setup_controller(chip, azx_dev);
1477 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1506 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1478 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; 1507 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
@@ -2100,25 +2129,36 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
2100 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01), 2129 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
2101 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ 2130 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
2102 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), 2131 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
2103 /* conflict of ALC268 in slot#3 (digital I/O); a temporary fix */ 2132 /* forced codec slots */
2104 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba laptop", 0x03), 2133 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103),
2105 {} 2134 {}
2106}; 2135};
2107 2136
2137#define AZX_FORCE_CODEC_MASK 0x100
2138
2108static void __devinit check_probe_mask(struct azx *chip, int dev) 2139static void __devinit check_probe_mask(struct azx *chip, int dev)
2109{ 2140{
2110 const struct snd_pci_quirk *q; 2141 const struct snd_pci_quirk *q;
2111 2142
2112 if (probe_mask[dev] == -1) { 2143 chip->codec_probe_mask = probe_mask[dev];
2144 if (chip->codec_probe_mask == -1) {
2113 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); 2145 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
2114 if (q) { 2146 if (q) {
2115 printk(KERN_INFO 2147 printk(KERN_INFO
2116 "hda_intel: probe_mask set to 0x%x " 2148 "hda_intel: probe_mask set to 0x%x "
2117 "for device %04x:%04x\n", 2149 "for device %04x:%04x\n",
2118 q->value, q->subvendor, q->subdevice); 2150 q->value, q->subvendor, q->subdevice);
2119 probe_mask[dev] = q->value; 2151 chip->codec_probe_mask = q->value;
2120 } 2152 }
2121 } 2153 }
2154
2155 /* check forced option */
2156 if (chip->codec_probe_mask != -1 &&
2157 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
2158 chip->codec_mask = chip->codec_probe_mask & 0xff;
2159 printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n",
2160 chip->codec_mask);
2161 }
2122} 2162}
2123 2163
2124 2164
@@ -2347,10 +2387,10 @@ static int __devinit azx_probe(struct pci_dev *pci,
2347 return -ENOENT; 2387 return -ENOENT;
2348 } 2388 }
2349 2389
2350 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 2390 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
2351 if (!card) { 2391 if (err < 0) {
2352 snd_printk(KERN_ERR SFX "Error creating card!\n"); 2392 snd_printk(KERN_ERR SFX "Error creating card!\n");
2353 return -ENOMEM; 2393 return err;
2354 } 2394 }
2355 2395
2356 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); 2396 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
@@ -2359,8 +2399,7 @@ static int __devinit azx_probe(struct pci_dev *pci,
2359 card->private_data = chip; 2399 card->private_data = chip;
2360 2400
2361 /* create codec instances */ 2401 /* create codec instances */
2362 err = azx_codec_create(chip, model[dev], probe_mask[dev], 2402 err = azx_codec_create(chip, model[dev], probe_only[dev]);
2363 probe_only[dev]);
2364 if (err < 0) 2403 if (err < 0)
2365 goto out_free; 2404 goto out_free;
2366 2405
@@ -2457,10 +2496,10 @@ static struct pci_device_id azx_ids[] = {
2457 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, 2496 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2458 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, 2497 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2459 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, 2498 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2460 { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA }, 2499 { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA },
2461 { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA }, 2500 { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA },
2462 { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA }, 2501 { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA },
2463 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA }, 2502 { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA },
2464 /* Teradici */ 2503 /* Teradici */
2465 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2504 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
2466 /* AMD Generic, PCI class code and Vendor ID for HD Audio */ 2505 /* AMD Generic, PCI class code and Vendor ID for HD Audio */