patch-2.4.5 linux/drivers/sound/trident.c
Next file: linux/drivers/sound/via82cxxx_audio.c
Previous file: linux/drivers/sound/sb_card.c
Back to the patch index
Back to the overall index
- Lines: 133
- Date:
Sat May 19 17:43:10 2001
- Orig file:
v2.4.4/linux/drivers/sound/trident.c
- Orig date:
Fri Apr 6 10:51:19 2001
diff -u --recursive --new-file v2.4.4/linux/drivers/sound/trident.c linux/drivers/sound/trident.c
@@ -732,7 +732,7 @@
struct dmabuf *dmabuf = &state->dmabuf;
struct trident_channel *channel = dmabuf->channel;
- channel->lba = virt_to_bus(dmabuf->rawbuf);
+ channel->lba = dmabuf->dma_handle;
channel->delta = compute_rate_play(dmabuf->rate);
channel->eso = dmabuf->dmasize >> sample_shift[dmabuf->fmt];
@@ -808,7 +808,7 @@
return;
}
- channel->lba = virt_to_bus(dmabuf->rawbuf);
+ channel->lba = dmabuf->dma_handle;
channel->delta = compute_rate_rec(dmabuf->rate);
if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) && (channel->num == ALI_SPDIF_IN_CHANNEL)) {
rate = ali_get_spdif_in_rate(card);
@@ -1074,14 +1074,21 @@
}
}
else {
- if ((order = state->dmabuf.buforder - 1) >= DMABUF_MINORDER)
- dmabuf->rawbuf = (void *)__get_free_pages(GFP_KERNEL | GFP_DMA, order);
+ if ((order = state->dmabuf.buforder - 1) >= DMABUF_MINORDER) {
+ dmabuf->rawbuf = pci_alloc_consistent(state->card->pci_dev,
+ PAGE_SIZE << order,
+ &dmabuf->dma_handle);
+ }
if (!dmabuf->rawbuf) {
free_pages((unsigned long)state->dmabuf.rawbuf, state->dmabuf.buforder);
state->dmabuf.rawbuf = NULL;
i-=2;
- for (; i >= 0; i--)
- free_pages((unsigned long)state->other_states[i]->dmabuf.rawbuf, state->other_states[i]->dmabuf.buforder);
+ for (; i >= 0; i--) {
+ pci_free_consistent(state->card->pci_dev,
+ PAGE_SIZE << state->other_states[i]->dmabuf.buforder,
+ state->other_states[i]->dmabuf.rawbuf,
+ state->other_states[i]->dmabuf.dma_handle);
+ }
unlock_set_fmt(state);
return -ENOMEM;
}
@@ -1967,9 +1974,9 @@
case SNDCTL_DSP_GETTRIGGER:
val = 0;
- if (file->f_mode & FMODE_READ && dmabuf->enable)
+ if ((file->f_mode & FMODE_READ) && dmabuf->enable)
val |= PCM_ENABLE_INPUT;
- if (file->f_mode & FMODE_WRITE && dmabuf->enable)
+ if ((file->f_mode & FMODE_WRITE) && dmabuf->enable)
val |= PCM_ENABLE_OUTPUT;
return put_user(val, (int *)arg);
@@ -3157,20 +3164,34 @@
{
struct trident_card *card = (struct trident_card *)data;
unsigned long flags;
+ char c;
+
+ if (count<0)
+ return -EINVAL;
+ if (count == 0)
+ return 0;
+ if (get_user(c, buffer))
+ return -EFAULT;
spin_lock_irqsave(&card->lock, flags);
- if (*buffer == '0') { //default
+ switch (c) {
+ case '0':
ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
- }
- else if (*buffer == '1')
+ break;
+ case '1':
ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT|ALI_SPDIF_OUT_PCM);
- else if (*buffer == '2') //AC3 data
+ break;
+ case '2':
ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT|ALI_SPDIF_OUT_NON_PCM);
- else if (*buffer == '3')
+ break;
+ case '3':
ali_disable_spdif_in(card); //default
- else if (*buffer == '4')
+ break;
+ case '4':
ali_setup_spdif_in(card);
+ break;
+ }
spin_unlock_irqrestore(&card->lock, flags);
return count;
@@ -3307,11 +3328,23 @@
{
unsigned long iobase;
struct trident_card *card;
+ dma_addr_t mask;
+ int bits;
u8 revision;
- if (pci_set_dma_mask(pci_dev, TRIDENT_DMA_MASK)) {
+ if (pci_enable_device(pci_dev))
+ return -ENODEV;
+
+ if (pci_dev->device == PCI_DEVICE_ID_ALI_5451) {
+ mask = 0xffffffff;
+ bits = 32;
+ } else {
+ mask = TRIDENT_DMA_MASK;
+ bits = 30;
+ }
+ if (pci_set_dma_mask(pci_dev, mask)) {
printk(KERN_ERR "trident: architecture does not support"
- " 30bit PCI busmaster DMA\n");
+ " %dbit PCI busmaster DMA\n", bits);
return -ENODEV;
}
pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &revision);
@@ -3322,9 +3355,6 @@
iobase);
return -ENODEV;
}
-
- if (pci_enable_device(pci_dev))
- return -ENODEV;
if ((card = kmalloc(sizeof(struct trident_card), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "trident: out of memory\n");
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)