aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/via82xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/via82xx.c')
-rw-r--r--sound/pci/via82xx.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 6781be9e3078..1aafe956ee2b 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -313,6 +313,7 @@ struct snd_via_sg_table {
313} ; 313} ;
314 314
315#define VIA_TABLE_SIZE 255 315#define VIA_TABLE_SIZE 255
316#define VIA_MAX_BUFSIZE (1<<24)
316 317
317struct viadev { 318struct viadev {
318 unsigned int reg_offset; 319 unsigned int reg_offset;
@@ -420,7 +421,6 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
420{ 421{
421 unsigned int i, idx, ofs, rest; 422 unsigned int i, idx, ofs, rest;
422 struct via82xx *chip = snd_pcm_substream_chip(substream); 423 struct via82xx *chip = snd_pcm_substream_chip(substream);
423 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
424 424
425 if (dev->table.area == NULL) { 425 if (dev->table.area == NULL) {
426 /* the start of each lists must be aligned to 8 bytes, 426 /* the start of each lists must be aligned to 8 bytes,
@@ -449,15 +449,15 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
449 do { 449 do {
450 unsigned int r; 450 unsigned int r;
451 unsigned int flag; 451 unsigned int flag;
452 unsigned int addr;
452 453
453 if (idx >= VIA_TABLE_SIZE) { 454 if (idx >= VIA_TABLE_SIZE) {
454 snd_printk(KERN_ERR "via82xx: too much table size!\n"); 455 snd_printk(KERN_ERR "via82xx: too much table size!\n");
455 return -EINVAL; 456 return -EINVAL;
456 } 457 }
457 ((u32 *)dev->table.area)[idx << 1] = cpu_to_le32((u32)snd_pcm_sgbuf_get_addr(sgbuf, ofs)); 458 addr = snd_pcm_sgbuf_get_addr(substream, ofs);
458 r = PAGE_SIZE - (ofs % PAGE_SIZE); 459 ((u32 *)dev->table.area)[idx << 1] = cpu_to_le32(addr);
459 if (rest < r) 460 r = snd_pcm_sgbuf_get_chunk_size(substream, ofs, rest);
460 r = rest;
461 rest -= r; 461 rest -= r;
462 if (! rest) { 462 if (! rest) {
463 if (i == periods - 1) 463 if (i == periods - 1)
@@ -824,7 +824,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
824 struct viadev *viadev = substream->runtime->private_data; 824 struct viadev *viadev = substream->runtime->private_data;
825 unsigned int idx, ptr, count, res; 825 unsigned int idx, ptr, count, res;
826 826
827 snd_assert(viadev->tbl_entries, return 0); 827 if (snd_BUG_ON(!viadev->tbl_entries))
828 return 0;
828 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) 829 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
829 return 0; 830 return 0;
830 831
@@ -855,7 +856,8 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *subst
855 unsigned int idx, count, res; 856 unsigned int idx, count, res;
856 int status; 857 int status;
857 858
858 snd_assert(viadev->tbl_entries, return 0); 859 if (snd_BUG_ON(!viadev->tbl_entries))
860 return 0;
859 861
860 spin_lock(&chip->reg_lock); 862 spin_lock(&chip->reg_lock);
861 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)); 863 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
@@ -1037,7 +1039,7 @@ static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream)
1037 else 1039 else
1038 rbits = (0x100000 / 48000) * runtime->rate + 1040 rbits = (0x100000 / 48000) * runtime->rate +
1039 ((0x100000 % 48000) * runtime->rate) / 48000; 1041 ((0x100000 % 48000) * runtime->rate) / 48000;
1040 snd_assert((rbits & ~0xfffff) == 0, return -EINVAL); 1042 snd_BUG_ON(rbits & ~0xfffff);
1041 snd_via82xx_channel_reset(chip, viadev); 1043 snd_via82xx_channel_reset(chip, viadev);
1042 snd_via82xx_set_table_ptr(chip, viadev); 1044 snd_via82xx_set_table_ptr(chip, viadev);
1043 outb(chip->playback_volume[viadev->reg_offset / 0x10][0], 1045 outb(chip->playback_volume[viadev->reg_offset / 0x10][0],
@@ -1144,9 +1146,9 @@ static struct snd_pcm_hardware snd_via82xx_hw =
1144 .rate_max = 48000, 1146 .rate_max = 48000,
1145 .channels_min = 1, 1147 .channels_min = 1,
1146 .channels_max = 2, 1148 .channels_max = 2,
1147 .buffer_bytes_max = 128 * 1024, 1149 .buffer_bytes_max = VIA_MAX_BUFSIZE,
1148 .period_bytes_min = 32, 1150 .period_bytes_min = 32,
1149 .period_bytes_max = 128 * 1024, 1151 .period_bytes_max = VIA_MAX_BUFSIZE / 2,
1150 .periods_min = 2, 1152 .periods_min = 2,
1151 .periods_max = VIA_TABLE_SIZE / 2, 1153 .periods_max = VIA_TABLE_SIZE / 2,
1152 .fifo_size = 0, 1154 .fifo_size = 0,
@@ -1398,10 +1400,9 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
1398 /* capture */ 1400 /* capture */
1399 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); 1401 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
1400 1402
1401 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1403 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1402 snd_dma_pci_data(chip->pci), 1404 snd_dma_pci_data(chip->pci),
1403 64*1024, 128*1024)) < 0) 1405 64*1024, VIA_MAX_BUFSIZE);
1404 return err;
1405 1406
1406 /* PCM #1: multi-channel playback and 2nd capture */ 1407 /* PCM #1: multi-channel playback and 2nd capture */
1407 err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm); 1408 err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm);
@@ -1417,11 +1418,9 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
1417 /* set up capture */ 1418 /* set up capture */
1418 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); 1419 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1);
1419 1420
1420 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1421 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1421 snd_dma_pci_data(chip->pci), 1422 snd_dma_pci_data(chip->pci),
1422 64*1024, 128*1024)) < 0) 1423 64*1024, VIA_MAX_BUFSIZE);
1423 return err;
1424
1425 return 0; 1424 return 0;
1426} 1425}
1427 1426
@@ -1453,10 +1452,9 @@ static int __devinit snd_via8233a_pcm_new(struct via82xx *chip)
1453 /* capture */ 1452 /* capture */
1454 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); 1453 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
1455 1454
1456 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1455 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1457 snd_dma_pci_data(chip->pci), 1456 snd_dma_pci_data(chip->pci),
1458 64*1024, 128*1024)) < 0) 1457 64*1024, VIA_MAX_BUFSIZE);
1459 return err;
1460 1458
1461 /* SPDIF supported? */ 1459 /* SPDIF supported? */
1462 if (! ac97_can_spdif(chip->ac97)) 1460 if (! ac97_can_spdif(chip->ac97))
@@ -1473,11 +1471,9 @@ static int __devinit snd_via8233a_pcm_new(struct via82xx *chip)
1473 /* set up playback */ 1471 /* set up playback */
1474 init_viadev(chip, chip->playback_devno, 0x30, 3, 0); 1472 init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
1475 1473
1476 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1474 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1477 snd_dma_pci_data(chip->pci), 1475 snd_dma_pci_data(chip->pci),
1478 64*1024, 128*1024)) < 0) 1476 64*1024, VIA_MAX_BUFSIZE);
1479 return err;
1480
1481 return 0; 1477 return 0;
1482} 1478}
1483 1479
@@ -1505,11 +1501,9 @@ static int __devinit snd_via686_pcm_new(struct via82xx *chip)
1505 init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); 1501 init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0);
1506 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); 1502 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
1507 1503
1508 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1504 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1509 snd_dma_pci_data(chip->pci), 1505 snd_dma_pci_data(chip->pci),
1510 64*1024, 128*1024)) < 0) 1506 64*1024, VIA_MAX_BUFSIZE);
1511 return err;
1512
1513 return 0; 1507 return 0;
1514} 1508}
1515 1509