aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_intel.c150
1 files changed, 117 insertions, 33 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 58e15b8896ac..15107df1f490 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -72,7 +72,8 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
72 "{ATI, SB450}," 72 "{ATI, SB450},"
73 "{VIA, VT8251}," 73 "{VIA, VT8251},"
74 "{VIA, VT8237A}," 74 "{VIA, VT8237A},"
75 "{SiS, SIS966}}"); 75 "{SiS, SIS966},"
76 "{ULI, M5461}}");
76MODULE_DESCRIPTION("Intel HDA driver"); 77MODULE_DESCRIPTION("Intel HDA driver");
77 78
78#define SFX "hda-intel: " 79#define SFX "hda-intel: "
@@ -142,9 +143,24 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
142 */ 143 */
143 144
144/* max number of SDs */ 145/* max number of SDs */
145#define MAX_ICH6_DEV 8 146/* ICH, ATI and VIA have 4 playback and 4 capture */
147#define ICH6_CAPTURE_INDEX 0
148#define ICH6_NUM_CAPTURE 4
149#define ICH6_PLAYBACK_INDEX 4
150#define ICH6_NUM_PLAYBACK 4
151
152/* ULI has 6 playback and 5 capture */
153#define ULI_CAPTURE_INDEX 0
154#define ULI_NUM_CAPTURE 5
155#define ULI_PLAYBACK_INDEX 5
156#define ULI_NUM_PLAYBACK 6
157
158/* this number is statically defined for simplicity */
159#define MAX_AZX_DEV 16
160
146/* max number of fragments - we may use more if allocating more pages for BDL */ 161/* max number of fragments - we may use more if allocating more pages for BDL */
147#define AZX_MAX_FRAG (PAGE_SIZE / (MAX_ICH6_DEV * 16)) 162#define BDL_SIZE PAGE_ALIGN(8192)
163#define AZX_MAX_FRAG (BDL_SIZE / (MAX_AZX_DEV * 16))
148/* max buffer size - no h/w limit, you can increase as you like */ 164/* max buffer size - no h/w limit, you can increase as you like */
149#define AZX_MAX_BUF_SIZE (1024*1024*1024) 165#define AZX_MAX_BUF_SIZE (1024*1024*1024)
150/* max number of PCM devics per card */ 166/* max number of PCM devics per card */
@@ -201,7 +217,6 @@ enum {
201}; 217};
202 218
203/* Defines for ATI HD Audio support in SB450 south bridge */ 219/* Defines for ATI HD Audio support in SB450 south bridge */
204#define ATI_SB450_HDAUDIO_PCI_DEVICE_ID 0x437b
205#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42 220#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
206#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02 221#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
207 222
@@ -259,6 +274,14 @@ struct snd_azx {
259 snd_card_t *card; 274 snd_card_t *card;
260 struct pci_dev *pci; 275 struct pci_dev *pci;
261 276
277 /* chip type specific */
278 int driver_type;
279 int playback_streams;
280 int playback_index_offset;
281 int capture_streams;
282 int capture_index_offset;
283 int num_streams;
284
262 /* pci resources */ 285 /* pci resources */
263 unsigned long addr; 286 unsigned long addr;
264 void __iomem *remap_addr; 287 void __iomem *remap_addr;
@@ -268,8 +291,8 @@ struct snd_azx {
268 spinlock_t reg_lock; 291 spinlock_t reg_lock;
269 struct semaphore open_mutex; 292 struct semaphore open_mutex;
270 293
271 /* streams */ 294 /* streams (x num_streams) */
272 azx_dev_t azx_dev[MAX_ICH6_DEV]; 295 azx_dev_t *azx_dev;
273 296
274 /* PCM */ 297 /* PCM */
275 unsigned int pcm_devs; 298 unsigned int pcm_devs;
@@ -293,6 +316,23 @@ struct snd_azx {
293 unsigned int initialized: 1; 316 unsigned int initialized: 1;
294}; 317};
295 318
319/* driver types */
320enum {
321 AZX_DRIVER_ICH,
322 AZX_DRIVER_ATI,
323 AZX_DRIVER_VIA,
324 AZX_DRIVER_SIS,
325 AZX_DRIVER_ULI,
326};
327
328static char *driver_short_names[] __devinitdata = {
329 [AZX_DRIVER_ICH] = "HDA Intel",
330 [AZX_DRIVER_ATI] = "HDA ATI SB",
331 [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
332 [AZX_DRIVER_SIS] = "HDA SIS966",
333 [AZX_DRIVER_ULI] = "HDA ULI M5461"
334};
335
296/* 336/*
297 * macros for easy use 337 * macros for easy use
298 */ 338 */
@@ -361,6 +401,8 @@ static void azx_init_cmd_io(azx_t *chip)
361 azx_writel(chip, CORBLBASE, (u32)chip->corb.addr); 401 azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
362 azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr)); 402 azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr));
363 403
404 /* set the corb size to 256 entries (ULI requires explicitly) */
405 azx_writeb(chip, CORBSIZE, 0x02);
364 /* set the corb write pointer to 0 */ 406 /* set the corb write pointer to 0 */
365 azx_writew(chip, CORBWP, 0); 407 azx_writew(chip, CORBWP, 0);
366 /* reset the corb hw read pointer */ 408 /* reset the corb hw read pointer */
@@ -374,6 +416,8 @@ static void azx_init_cmd_io(azx_t *chip)
374 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); 416 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
375 azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr)); 417 azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr));
376 418
419 /* set the rirb size to 256 entries (ULI requires explicitly) */
420 azx_writeb(chip, RIRBSIZE, 0x02);
377 /* reset the rirb hw write pointer */ 421 /* reset the rirb hw write pointer */
378 azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR); 422 azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR);
379 /* set N=1, get RIRB response interrupt for new entry */ 423 /* set N=1, get RIRB response interrupt for new entry */
@@ -597,7 +641,7 @@ static void azx_int_disable(azx_t *chip)
597 int i; 641 int i;
598 642
599 /* disable interrupts in stream descriptor */ 643 /* disable interrupts in stream descriptor */
600 for (i = 0; i < MAX_ICH6_DEV; i++) { 644 for (i = 0; i < chip->num_streams; i++) {
601 azx_dev_t *azx_dev = &chip->azx_dev[i]; 645 azx_dev_t *azx_dev = &chip->azx_dev[i];
602 azx_sd_writeb(azx_dev, SD_CTL, 646 azx_sd_writeb(azx_dev, SD_CTL,
603 azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK); 647 azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK);
@@ -617,7 +661,7 @@ static void azx_int_clear(azx_t *chip)
617 int i; 661 int i;
618 662
619 /* clear stream status */ 663 /* clear stream status */
620 for (i = 0; i < MAX_ICH6_DEV; i++) { 664 for (i = 0; i < chip->num_streams; i++) {
621 azx_dev_t *azx_dev = &chip->azx_dev[i]; 665 azx_dev_t *azx_dev = &chip->azx_dev[i];
622 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 666 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
623 } 667 }
@@ -687,8 +731,7 @@ static void azx_init_chip(azx_t *chip)
687 } 731 }
688 732
689 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 733 /* For ATI SB450 azalia HD audio, we need to enable snoop */
690 if (chip->pci->vendor == PCI_VENDOR_ID_ATI && 734 if (chip->driver_type == AZX_DRIVER_ATI) {
691 chip->pci->device == ATI_SB450_HDAUDIO_PCI_DEVICE_ID) {
692 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 735 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
693 &ati_misc_cntl2); 736 &ati_misc_cntl2);
694 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 737 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
@@ -715,7 +758,7 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs)
715 return IRQ_NONE; 758 return IRQ_NONE;
716 } 759 }
717 760
718 for (i = 0; i < MAX_ICH6_DEV; i++) { 761 for (i = 0; i < chip->num_streams; i++) {
719 azx_dev = &chip->azx_dev[i]; 762 azx_dev = &chip->azx_dev[i];
720 if (status & azx_dev->sd_int_sta_mask) { 763 if (status & azx_dev->sd_int_sta_mask) {
721 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 764 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
@@ -880,9 +923,15 @@ static int __devinit azx_codec_create(azx_t *chip, const char *model)
880/* assign a stream for the PCM */ 923/* assign a stream for the PCM */
881static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream) 924static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream)
882{ 925{
883 int dev, i; 926 int dev, i, nums;
884 dev = stream == SNDRV_PCM_STREAM_PLAYBACK ? 4 : 0; 927 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
885 for (i = 0; i < 4; i++, dev++) 928 dev = chip->playback_index_offset;
929 nums = chip->playback_streams;
930 } else {
931 dev = chip->capture_index_offset;
932 nums = chip->capture_streams;
933 }
934 for (i = 0; i < nums; i++, dev++)
886 if (! chip->azx_dev[dev].opened) { 935 if (! chip->azx_dev[dev].opened) {
887 chip->azx_dev[dev].opened = 1; 936 chip->azx_dev[dev].opened = 1;
888 return &chip->azx_dev[dev]; 937 return &chip->azx_dev[dev];
@@ -1190,7 +1239,7 @@ static int __devinit azx_init_stream(azx_t *chip)
1190 /* initialize each stream (aka device) 1239 /* initialize each stream (aka device)
1191 * assign the starting bdl address to each stream (device) and initialize 1240 * assign the starting bdl address to each stream (device) and initialize
1192 */ 1241 */
1193 for (i = 0; i < MAX_ICH6_DEV; i++) { 1242 for (i = 0; i < chip->num_streams; i++) {
1194 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4); 1243 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4);
1195 azx_dev_t *azx_dev = &chip->azx_dev[i]; 1244 azx_dev_t *azx_dev = &chip->azx_dev[i];
1196 azx_dev->bdl = (u32 *)(chip->bdl.area + off); 1245 azx_dev->bdl = (u32 *)(chip->bdl.area + off);
@@ -1249,7 +1298,7 @@ static int azx_free(azx_t *chip)
1249 if (chip->initialized) { 1298 if (chip->initialized) {
1250 int i; 1299 int i;
1251 1300
1252 for (i = 0; i < MAX_ICH6_DEV; i++) 1301 for (i = 0; i < chip->num_streams; i++)
1253 azx_stream_stop(chip, &chip->azx_dev[i]); 1302 azx_stream_stop(chip, &chip->azx_dev[i]);
1254 1303
1255 /* disable interrupts */ 1304 /* disable interrupts */
@@ -1265,10 +1314,10 @@ static int azx_free(azx_t *chip)
1265 1314
1266 /* wait a little for interrupts to finish */ 1315 /* wait a little for interrupts to finish */
1267 msleep(1); 1316 msleep(1);
1268
1269 iounmap(chip->remap_addr);
1270 } 1317 }
1271 1318
1319 if (chip->remap_addr)
1320 iounmap(chip->remap_addr);
1272 if (chip->irq >= 0) 1321 if (chip->irq >= 0)
1273 free_irq(chip->irq, (void*)chip); 1322 free_irq(chip->irq, (void*)chip);
1274 1323
@@ -1280,6 +1329,7 @@ static int azx_free(azx_t *chip)
1280 snd_dma_free_pages(&chip->posbuf); 1329 snd_dma_free_pages(&chip->posbuf);
1281 pci_release_regions(chip->pci); 1330 pci_release_regions(chip->pci);
1282 pci_disable_device(chip->pci); 1331 pci_disable_device(chip->pci);
1332 kfree(chip->azx_dev);
1283 kfree(chip); 1333 kfree(chip);
1284 1334
1285 return 0; 1335 return 0;
@@ -1294,7 +1344,8 @@ static int azx_dev_free(snd_device_t *device)
1294 * constructor 1344 * constructor
1295 */ 1345 */
1296static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, 1346static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1297 int posfix, azx_t **rchip) 1347 int posfix, int driver_type,
1348 azx_t **rchip)
1298{ 1349{
1299 azx_t *chip; 1350 azx_t *chip;
1300 int err = 0; 1351 int err = 0;
@@ -1320,9 +1371,20 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1320 chip->card = card; 1371 chip->card = card;
1321 chip->pci = pci; 1372 chip->pci = pci;
1322 chip->irq = -1; 1373 chip->irq = -1;
1374 chip->driver_type = driver_type;
1323 1375
1324 chip->position_fix = posfix; 1376 chip->position_fix = posfix;
1325 1377
1378#if BITS_PER_LONG != 64
1379 /* Fix up base address on ULI M5461 */
1380 if (chip->driver_type == AZX_DRIVER_ULI) {
1381 u16 tmp3;
1382 pci_read_config_word(pci, 0x40, &tmp3);
1383 pci_write_config_word(pci, 0x40, tmp3 | 0x10);
1384 pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);
1385 }
1386#endif
1387
1326 if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) { 1388 if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) {
1327 kfree(chip); 1389 kfree(chip);
1328 pci_disable_device(pci); 1390 pci_disable_device(pci);
@@ -1348,16 +1410,37 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1348 pci_set_master(pci); 1410 pci_set_master(pci);
1349 synchronize_irq(chip->irq); 1411 synchronize_irq(chip->irq);
1350 1412
1413 switch (chip->driver_type) {
1414 case AZX_DRIVER_ULI:
1415 chip->playback_streams = ULI_NUM_PLAYBACK;
1416 chip->capture_streams = ULI_NUM_CAPTURE;
1417 chip->playback_index_offset = ULI_PLAYBACK_INDEX;
1418 chip->capture_index_offset = ULI_CAPTURE_INDEX;
1419 break;
1420 default:
1421 chip->playback_streams = ICH6_NUM_PLAYBACK;
1422 chip->capture_streams = ICH6_NUM_CAPTURE;
1423 chip->playback_index_offset = ICH6_PLAYBACK_INDEX;
1424 chip->capture_index_offset = ICH6_CAPTURE_INDEX;
1425 break;
1426 }
1427 chip->num_streams = chip->playback_streams + chip->capture_streams;
1428 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL);
1429 if (! chip->azx_dev) {
1430 snd_printk(KERN_ERR "cannot malloc azx_dev\n");
1431 goto errout;
1432 }
1433
1351 /* allocate memory for the BDL for each stream */ 1434 /* allocate memory for the BDL for each stream */
1352 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1435 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1353 PAGE_SIZE, &chip->bdl)) < 0) { 1436 BDL_SIZE, &chip->bdl)) < 0) {
1354 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1437 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
1355 goto errout; 1438 goto errout;
1356 } 1439 }
1357 if (chip->position_fix == POS_FIX_POSBUF) { 1440 if (chip->position_fix == POS_FIX_POSBUF) {
1358 /* allocate memory for the position buffer */ 1441 /* allocate memory for the position buffer */
1359 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1442 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1360 MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) { 1443 chip->num_streams * 8, &chip->posbuf)) < 0) {
1361 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 1444 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
1362 goto errout; 1445 goto errout;
1363 } 1446 }
@@ -1386,6 +1469,10 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1386 goto errout; 1469 goto errout;
1387 } 1470 }
1388 1471
1472 strcpy(card->driver, "HDA-Intel");
1473 strcpy(card->shortname, driver_short_names[chip->driver_type]);
1474 sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq);
1475
1389 *rchip = chip; 1476 *rchip = chip;
1390 return 0; 1477 return 0;
1391 1478
@@ -1414,15 +1501,12 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *
1414 return -ENOMEM; 1501 return -ENOMEM;
1415 } 1502 }
1416 1503
1417 if ((err = azx_create(card, pci, position_fix[dev], &chip)) < 0) { 1504 if ((err = azx_create(card, pci, position_fix[dev], pci_id->driver_data,
1505 &chip)) < 0) {
1418 snd_card_free(card); 1506 snd_card_free(card);
1419 return err; 1507 return err;
1420 } 1508 }
1421 1509
1422 strcpy(card->driver, "HDA-Intel");
1423 strcpy(card->shortname, "HDA Intel");
1424 sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq);
1425
1426 /* create codec instances */ 1510 /* create codec instances */
1427 if ((err = azx_codec_create(chip, model[dev])) < 0) { 1511 if ((err = azx_codec_create(chip, model[dev])) < 0) {
1428 snd_card_free(card); 1512 snd_card_free(card);
@@ -1463,13 +1547,13 @@ static void __devexit azx_remove(struct pci_dev *pci)
1463 1547
1464/* PCI IDs */ 1548/* PCI IDs */
1465static struct pci_device_id azx_ids[] = { 1549static struct pci_device_id azx_ids[] = {
1466 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ 1550 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */
1467 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ 1551 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */
1468 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */ 1552 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */
1469 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */ 1553 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
1470 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */ 1554 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1471 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SIS966 */ 1555 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
1472 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ALI 5461? */ 1556 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
1473 { 0, } 1557 { 0, }
1474}; 1558};
1475MODULE_DEVICE_TABLE(pci, azx_ids); 1559MODULE_DEVICE_TABLE(pci, azx_ids);