X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Foss%2Fmsnd.c;h=4f1ff1bccdcee0a6106ffbd16b206071564c22d6;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=6ccdd096f9183ed7e437b2b5387b2f689453d32f;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/sound/oss/msnd.c b/sound/oss/msnd.c index 6ccdd096f..4f1ff1bcc 100644 --- a/sound/oss/msnd.c +++ b/sound/oss/msnd.c @@ -33,6 +33,8 @@ #include #include #include +#include + #include #include #include @@ -79,31 +81,12 @@ void msnd_unregister(multisound_dev_t *dev) --num_devs; } -int msnd_get_num_devs(void) -{ - return num_devs; -} - -multisound_dev_t *msnd_get_dev(int j) -{ - int i; - - for (i = 0; i < MSND_MAX_DEVS && j; ++i) - if (devs[i] != NULL) - --j; - - if (i == MSND_MAX_DEVS || j != 0) - return NULL; - - return devs[i]; -} - -void msnd_init_queue(unsigned long base, int start, int size) +void msnd_init_queue(void __iomem *base, int start, int size) { - isa_writew(PCTODSP_BASED(start), base + JQS_wStart); - isa_writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize); - isa_writew(0, base + JQS_wHead); - isa_writew(0, base + JQS_wTail); + writew(PCTODSP_BASED(start), base + JQS_wStart); + writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize); + writew(0, base + JQS_wHead); + writew(0, base + JQS_wTail); } void msnd_fifo_init(msnd_fifo *f) @@ -139,6 +122,37 @@ void msnd_fifo_make_empty(msnd_fifo *f) f->len = f->tail = f->head = 0; } +int msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len) +{ + int count = 0; + + while ((count < len) && (f->len != f->n)) { + + int nwritten; + + if (f->head <= f->tail) { + nwritten = len - count; + if (nwritten > f->n - f->tail) + nwritten = f->n - f->tail; + } + else { + nwritten = f->head - f->tail; + if (nwritten > len - count) + nwritten = len - count; + } + + memcpy_fromio(f->data + f->tail, buf, nwritten); + + count += nwritten; + buf += nwritten; + f->len += nwritten; + f->tail += nwritten; + f->tail %= f->n; + } + + return count; +} + int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) { int count = 0; @@ -158,7 +172,7 @@ int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) nwritten = len - count; } - isa_memcpy_fromio(f->data + f->tail, (unsigned long) buf, nwritten); + memcpy(f->data + f->tail, buf, nwritten); count += nwritten; buf += nwritten; @@ -170,6 +184,37 @@ int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) return count; } +int msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len) +{ + int count = 0; + + while ((count < len) && (f->len > 0)) { + + int nread; + + if (f->tail <= f->head) { + nread = len - count; + if (nread > f->n - f->head) + nread = f->n - f->head; + } + else { + nread = f->tail - f->head; + if (nread > len - count) + nread = len - count; + } + + memcpy_toio(buf, f->data + f->head, nread); + + count += nread; + buf += nread; + f->len -= nread; + f->head += nread; + f->head %= f->n; + } + + return count; +} + int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) { int count = 0; @@ -189,7 +234,7 @@ int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) nread = len - count; } - isa_memcpy_toio((unsigned long) buf, f->data + f->head, nread); + memcpy(buf, f->data + f->head, nread); count += nread; buf += nread; @@ -201,25 +246,25 @@ int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) return count; } -int msnd_wait_TXDE(multisound_dev_t *dev) +static int msnd_wait_TXDE(multisound_dev_t *dev) { register unsigned int io = dev->io; register int timeout = 1000; while(timeout-- > 0) - if (inb(io + HP_ISR) & HPISR_TXDE) + if (msnd_inb(io + HP_ISR) & HPISR_TXDE) return 0; return -EIO; } -int msnd_wait_HC0(multisound_dev_t *dev) +static int msnd_wait_HC0(multisound_dev_t *dev) { register unsigned int io = dev->io; register int timeout = 1000; while(timeout-- > 0) - if (!(inb(io + HP_CVR) & HPCVR_HC)) + if (!(msnd_inb(io + HP_CVR) & HPCVR_HC)) return 0; return -EIO; @@ -231,7 +276,7 @@ int msnd_send_dsp_cmd(multisound_dev_t *dev, BYTE cmd) spin_lock_irqsave(&dev->lock, flags); if (msnd_wait_HC0(dev) == 0) { - outb(cmd, dev->io + HP_CVR); + msnd_outb(cmd, dev->io + HP_CVR); spin_unlock_irqrestore(&dev->lock, flags); return 0; } @@ -248,9 +293,9 @@ int msnd_send_word(multisound_dev_t *dev, unsigned char high, register unsigned int io = dev->io; if (msnd_wait_TXDE(dev) == 0) { - outb(high, io + HP_TXH); - outb(mid, io + HP_TXM); - outb(low, io + HP_TXL); + msnd_outb(high, io + HP_TXH); + msnd_outb(mid, io + HP_TXM); + msnd_outb(low, io + HP_TXL); return 0; } @@ -272,8 +317,8 @@ int msnd_upload_host(multisound_dev_t *dev, char *bin, int len) if (msnd_send_word(dev, bin[i], bin[i + 1], bin[i + 2]) != 0) return -EIO; - inb(dev->io + HP_RXL); - inb(dev->io + HP_CVR); + msnd_inb(dev->io + HP_RXL); + msnd_inb(dev->io + HP_CVR); return 0; } @@ -289,11 +334,11 @@ int msnd_enable_irq(multisound_dev_t *dev) spin_lock_irqsave(&dev->lock, flags); if (msnd_wait_TXDE(dev) == 0) { - outb(inb(dev->io + HP_ICR) | HPICR_TREQ, dev->io + HP_ICR); + msnd_outb(msnd_inb(dev->io + HP_ICR) | HPICR_TREQ, dev->io + HP_ICR); if (dev->type == msndClassic) - outb(dev->irqid, dev->io + HP_IRQM); - outb(inb(dev->io + HP_ICR) & ~HPICR_TREQ, dev->io + HP_ICR); - outb(inb(dev->io + HP_ICR) | HPICR_RREQ, dev->io + HP_ICR); + msnd_outb(dev->irqid, dev->io + HP_IRQM); + msnd_outb(msnd_inb(dev->io + HP_ICR) & ~HPICR_TREQ, dev->io + HP_ICR); + msnd_outb(msnd_inb(dev->io + HP_ICR) | HPICR_RREQ, dev->io + HP_ICR); enable_irq(dev->irq); msnd_init_queue(dev->DSPQ, dev->dspq_data_buff, dev->dspq_buff_size); spin_unlock_irqrestore(&dev->lock, flags); @@ -320,9 +365,9 @@ int msnd_disable_irq(multisound_dev_t *dev) spin_lock_irqsave(&dev->lock, flags); if (msnd_wait_TXDE(dev) == 0) { - outb(inb(dev->io + HP_ICR) & ~HPICR_RREQ, dev->io + HP_ICR); + msnd_outb(msnd_inb(dev->io + HP_ICR) & ~HPICR_RREQ, dev->io + HP_ICR); if (dev->type == msndClassic) - outb(HPIRQ_NONE, dev->io + HP_IRQM); + msnd_outb(HPIRQ_NONE, dev->io + HP_IRQM); disable_irq(dev->irq); spin_unlock_irqrestore(&dev->lock, flags); return 0; @@ -337,8 +382,6 @@ int msnd_disable_irq(multisound_dev_t *dev) #ifndef LINUX20 EXPORT_SYMBOL(msnd_register); EXPORT_SYMBOL(msnd_unregister); -EXPORT_SYMBOL(msnd_get_num_devs); -EXPORT_SYMBOL(msnd_get_dev); EXPORT_SYMBOL(msnd_init_queue); @@ -346,11 +389,11 @@ EXPORT_SYMBOL(msnd_fifo_init); EXPORT_SYMBOL(msnd_fifo_free); EXPORT_SYMBOL(msnd_fifo_alloc); EXPORT_SYMBOL(msnd_fifo_make_empty); +EXPORT_SYMBOL(msnd_fifo_write_io); +EXPORT_SYMBOL(msnd_fifo_read_io); EXPORT_SYMBOL(msnd_fifo_write); EXPORT_SYMBOL(msnd_fifo_read); -EXPORT_SYMBOL(msnd_wait_TXDE); -EXPORT_SYMBOL(msnd_wait_HC0); EXPORT_SYMBOL(msnd_send_dsp_cmd); EXPORT_SYMBOL(msnd_send_word); EXPORT_SYMBOL(msnd_upload_host);