*
********************************************************************/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/mm.h>
#include <linux/init.h>
+#include <linux/interrupt.h>
+
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/spinlock.h>
static multisound_dev_t *devs[MSND_MAX_DEVS];
static int num_devs;
-int __init msnd_register(multisound_dev_t *dev)
+int msnd_register(multisound_dev_t *dev)
{
int i;
--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)
void msnd_fifo_free(msnd_fifo *f)
{
- if (f->data) {
- vfree(f->data);
- f->data = NULL;
- }
+ vfree(f->data);
+ f->data = NULL;
}
int msnd_fifo_alloc(msnd_fifo *f, size_t n)
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;
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;
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;
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;
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;
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;
#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);
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);