summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-07-20 21:44:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-07-20 21:44:35 +0000
commitec791d29f98c4070482700d98b3c1d25f3259425 (patch)
treed52b6033ca30c77490d046da3466ba7face8c905 /sys
parente1426744a4975e9035c98a5a8124f89b6c3fe3f2 (diff)
extend with new netbsd api, and add backwards compat hacks for drivers
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/auconv.c103
-rw-r--r--sys/dev/auconv.h40
-rw-r--r--sys/dev/mulaw.c108
-rw-r--r--sys/dev/mulaw.h28
4 files changed, 214 insertions, 65 deletions
diff --git a/sys/dev/auconv.c b/sys/dev/auconv.c
index d144027462c..94f0bbde42a 100644
--- a/sys/dev/auconv.c
+++ b/sys/dev/auconv.c
@@ -1,5 +1,4 @@
-/* $OpenBSD: auconv.c,v 1.1 1997/10/07 14:07:45 niklas Exp $ */
-/* $NetBSD: auconv.c,v 1.2 1997/08/24 22:20:24 augustss Exp $ */
+/* $NetBSD: auconv.c,v 1.3 1999/11/01 18:12:19 augustss Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -37,17 +36,8 @@
#include <sys/types.h>
#include <sys/audioio.h>
-#include <machine/endian.h>
#include <dev/auconv.h>
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define LO 0
-#define HI 1
-#else
-#define LO 1
-#define HI 0
-#endif
-
void
change_sign8(v, p, cc)
void *v;
@@ -61,13 +51,25 @@ change_sign8(v, p, cc)
}
void
-change_sign16(v, p, cc)
+change_sign16_le(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ while ((cc -= 2) >= 0) {
+ p[1] ^= 0x80;
+ p += 2;
+ }
+}
+
+void
+change_sign16_be(v, p, cc)
void *v;
u_char *p;
int cc;
{
while ((cc -= 2) >= 0) {
- p[HI] ^= 0x80;
+ p[0] ^= 0x80;
p += 2;
}
}
@@ -89,7 +91,7 @@ swap_bytes(v, p, cc)
}
void
-swap_bytes_change_sign16(v, p, cc)
+swap_bytes_change_sign16_le(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -97,15 +99,15 @@ swap_bytes_change_sign16(v, p, cc)
u_char t;
while ((cc -= 2) >= 0) {
- t = p[HI];
- p[HI] = p[LO] ^ 0x80;
- p[LO] = t;
+ t = p[1];
+ p[1] = p[0] ^ 0x80;
+ p[0] = t;
p += 2;
}
}
void
-change_sign16_swap_bytes(v, p, cc)
+swap_bytes_change_sign16_be(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -113,15 +115,33 @@ change_sign16_swap_bytes(v, p, cc)
u_char t;
while ((cc -= 2) >= 0) {
- t = p[LO];
- p[LO] = p[HI] ^ 0x80;
- p[HI] = t;
+ t = p[0];
+ p[0] = p[1] ^ 0x80;
+ p[1] = t;
p += 2;
}
}
void
-linear8_to_linear16(v, p, cc)
+change_sign16_swap_bytes_le(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ swap_bytes_change_sign16_be(v, p, cc);
+}
+
+void
+change_sign16_swap_bytes_be(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ swap_bytes_change_sign16_le(v, p, cc);
+}
+
+void
+linear8_to_linear16_le(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -132,13 +152,44 @@ linear8_to_linear16(v, p, cc)
q += cc * 2;
while (--cc >= 0) {
q -= 2;
- q[HI] = *--p;
- q[LO] = 0;
+ q[1] = *--p;
+ q[0] = 0;
+ }
+}
+
+void
+linear8_to_linear16_be(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while (--cc >= 0) {
+ q -= 2;
+ q[0] = *--p;
+ q[1] = 0;
+ }
+}
+
+void
+linear16_to_linear8_le(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ while ((cc -= 2) >= 0) {
+ *q++ = p[1];
+ p += 2;
}
}
void
-linear16_to_linear8(v, p, cc)
+linear16_to_linear8_be(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -146,7 +197,7 @@ linear16_to_linear8(v, p, cc)
u_char *q = p;
while ((cc -= 2) >= 0) {
- *q++ = p[HI];
+ *q++ = p[0];
p += 2;
}
}
diff --git a/sys/dev/auconv.h b/sys/dev/auconv.h
index 4e52bfdb62c..017cd58158e 100644
--- a/sys/dev/auconv.h
+++ b/sys/dev/auconv.h
@@ -1,10 +1,12 @@
-/* $OpenBSD: auconv.h,v 1.1 1997/10/07 14:07:46 niklas Exp $ */
-/* $NetBSD: auconv.h,v 1.2 1997/08/24 22:20:25 augustss Exp $ */
+/* $NetBSD: auconv.h,v 1.5 1999/11/01 18:12:19 augustss Exp $ */
/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -24,8 +26,8 @@
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
@@ -36,11 +38,29 @@
/* Convert between signed and unsigned. */
extern void change_sign8 __P((void *, u_char *, int));
-extern void change_sign16 __P((void *, u_char *, int));
+extern void change_sign16_le __P((void *, u_char *, int));
+extern void change_sign16_be __P((void *, u_char *, int));
/* Convert between little and big endian. */
extern void swap_bytes __P((void *, u_char *, int));
-extern void swap_bytes_change_sign16 __P((void *, u_char *, int));
-extern void change_sign16_swap_bytes __P((void *, u_char *, int));
+extern void swap_bytes_change_sign16_le __P((void *, u_char *, int));
+extern void swap_bytes_change_sign16_be __P((void *, u_char *, int));
+extern void change_sign16_swap_bytes_le __P((void *, u_char *, int));
+extern void change_sign16_swap_bytes_be __P((void *, u_char *, int));
/* Byte expansion/contraction */
-extern void linear8_to_linear16 __P((void *, u_char *, int));
-extern void linear16_to_linear8 __P((void *, u_char *, int));
+extern void linear8_to_linear16_le __P((void *, u_char *, int));
+extern void linear8_to_linear16_be __P((void *, u_char *, int));
+extern void linear16_to_linear8_le __P((void *, u_char *, int));
+extern void linear16_to_linear8_be __P((void *, u_char *, int));
+
+/* backwards compat for now */
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define change_sign16 change_sign16_le
+#define change_sign16_swap_bytes swap_bytes_change_sign16_le
+#define swap_bytes_change_sign16 swap_bytes_change_sign16_le
+#define linear8_to_linear16 linear8_to_linear16_le
+#else
+#define change_sign16 change_sign16_be
+#define change_sign16_swap_bytes swap_bytes_change_sign16_be
+#define swap_bytes_change_sign16 swap_bytes_change_sign16_be
+#define linear8_to_linear16 linear8_to_linear16_be
+#endif
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c
index e1134b6c444..7621217be41 100644
--- a/sys/dev/mulaw.c
+++ b/sys/dev/mulaw.c
@@ -1,5 +1,4 @@
-/* $OpenBSD: mulaw.c,v 1.4 1998/10/28 18:01:01 downsj Exp $ */
-/* $NetBSD: mulaw.c,v 1.12 1998/08/09 21:41:45 mycroft Exp $ */
+/* $NetBSD: mulaw.c,v 1.13 1999/11/01 18:12:19 augustss Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -37,17 +36,8 @@
#include <sys/types.h>
#include <sys/audioio.h>
-#include <machine/endian.h>
#include <dev/mulaw.h>
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define LO 0
-#define HI 1
-#else
-#define LO 1
-#define HI 0
-#endif
-
/*
* This table converts a (8 bit) mulaw value two a 16 bit value.
* The 16 bits are represented as an array of two butes for easier access
@@ -284,7 +274,43 @@ mulaw_to_slinear8(v, p, cc)
}
void
-mulaw_to_ulinear16(v, p, cc)
+mulaw_to_ulinear16_le(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc << 1;
+ while (--cc >= 0) {
+ --p;
+ q -= 2;
+ q[1] = mulawtolin16[*p][0];
+ q[0] = mulawtolin16[*p][1];
+ }
+}
+
+void
+mulaw_to_ulinear16_be(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc << 1;
+ while (--cc >= 0) {
+ --p;
+ q -= 2;
+ q[0] = mulawtolin16[*p][0];
+ q[1] = mulawtolin16[*p][1];
+ }
+}
+
+void
+mulaw_to_slinear16_le(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -296,13 +322,13 @@ mulaw_to_ulinear16(v, p, cc)
while (--cc >= 0) {
--p;
q -= 2;
- q[HI] = mulawtolin16[*p][0];
- q[LO] = mulawtolin16[*p][1];
+ q[1] = mulawtolin16[*p][0] ^ 0x80;
+ q[0] = mulawtolin16[*p][1];
}
}
void
-mulaw_to_slinear16(v, p, cc)
+mulaw_to_slinear16_be(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -314,8 +340,8 @@ mulaw_to_slinear16(v, p, cc)
while (--cc >= 0) {
--p;
q -= 2;
- q[HI] = mulawtolin16[*p][0] ^ 0x80;
- q[LO] = mulawtolin16[*p][1];
+ q[0] = mulawtolin16[*p][0] ^ 0x80;
+ q[1] = mulawtolin16[*p][1];
}
}
@@ -370,7 +396,43 @@ alaw_to_slinear8(v, p, cc)
}
void
-alaw_to_ulinear16(v, p, cc)
+alaw_to_ulinear16_le(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc << 1;
+ while (--cc >= 0) {
+ --p;
+ q -= 2;
+ q[1] = alawtolin16[*p][0];
+ q[0] = alawtolin16[*p][1];
+ }
+}
+
+void
+alaw_to_ulinear16_be(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc << 1;
+ while (--cc >= 0) {
+ --p;
+ q -= 2;
+ q[0] = alawtolin16[*p][0];
+ q[1] = alawtolin16[*p][1];
+ }
+}
+
+void
+alaw_to_slinear16_le(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -382,13 +444,13 @@ alaw_to_ulinear16(v, p, cc)
while (--cc >= 0) {
--p;
q -= 2;
- q[HI] = alawtolin16[*p][0];
- q[LO] = alawtolin16[*p][1];
+ q[1] = alawtolin16[*p][0] ^ 0x80;
+ q[0] = alawtolin16[*p][1];
}
}
void
-alaw_to_slinear16(v, p, cc)
+alaw_to_slinear16_be(v, p, cc)
void *v;
u_char *p;
int cc;
@@ -400,8 +462,8 @@ alaw_to_slinear16(v, p, cc)
while (--cc >= 0) {
--p;
q -= 2;
- q[HI] = alawtolin16[*p][0] ^ 0x80;
- q[LO] = alawtolin16[*p][1];
+ q[0] = alawtolin16[*p][0] ^ 0x80;
+ q[1] = alawtolin16[*p][1];
}
}
diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h
index dbe57673682..c724d88d4af 100644
--- a/sys/dev/mulaw.h
+++ b/sys/dev/mulaw.h
@@ -1,5 +1,4 @@
-/* $OpenBSD: mulaw.h,v 1.4 1998/10/28 18:01:02 downsj Exp $ */
-/* $NetBSD: mulaw.h,v 1.10 1998/08/09 19:22:15 mycroft Exp $ */
+/* $NetBSD: mulaw.h,v 1.11 1999/11/01 18:12:19 augustss Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,9 +37,11 @@
*/
/* Convert 8-bit mu-law to 16 bit unsigned linear. */
-extern void mulaw_to_ulinear16 __P((void *, u_char *buf, int cnt));
+extern void mulaw_to_ulinear16_le __P((void *, u_char *buf, int cnt));
+extern void mulaw_to_ulinear16_be __P((void *, u_char *buf, int cnt));
/* Convert 8-bit mu-law to 16 bit signed linear. */
-extern void mulaw_to_slinear16 __P((void *, u_char *buf, int cnt));
+extern void mulaw_to_slinear16_le __P((void *, u_char *buf, int cnt));
+extern void mulaw_to_slinear16_be __P((void *, u_char *buf, int cnt));
/* Convert 8-bit mu-law to/from 8 bit unsigned linear. */
extern void mulaw_to_ulinear8 __P((void *, u_char *buf, int cnt));
extern void ulinear8_to_mulaw __P((void *, u_char *buf, int cnt));
@@ -48,12 +49,27 @@ extern void ulinear8_to_mulaw __P((void *, u_char *buf, int cnt));
extern void mulaw_to_slinear8 __P((void *, u_char *buf, int cnt));
extern void slinear8_to_mulaw __P((void *, u_char *buf, int cnt));
/* Convert 8-bit a-law to 16 bit unsigned linear. */
-extern void alaw_to_ulinear16 __P((void *, u_char *buf, int cnt));
+extern void alaw_to_ulinear16_le __P((void *, u_char *buf, int cnt));
+extern void alaw_to_ulinear16_be __P((void *, u_char *buf, int cnt));
/* Convert 8-bit a-law to 16 bit signed linear. */
-extern void alaw_to_slinear16 __P((void *, u_char *buf, int cnt));
+extern void alaw_to_slinear16_le __P((void *, u_char *buf, int cnt));
+extern void alaw_to_slinear16_be __P((void *, u_char *buf, int cnt));
/* Convert 8-bit a-law to/from 8 bit unsigned linear. */
extern void alaw_to_ulinear8 __P((void *, u_char *buf, int cnt));
extern void ulinear8_to_alaw __P((void *, u_char *buf, int cnt));
/* Convert 8-bit a-law to/from 8 bit signed linear. */
extern void alaw_to_slinear8 __P((void *, u_char *buf, int cnt));
extern void slinear8_to_alaw __P((void *, u_char *buf, int cnt));
+
+/* backwards compat for now */
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define mulaw_to_ulinear16 mulaw_to_slinear16_le
+#define alaw_to_ulinear16 alaw_to_ulinear16_le
+#define mulaw_to_slinear16 mulaw_to_ulinear16_le
+#define alaw_to_slinear16 alaw_to_slinear16_le
+#else
+#define mulaw_to_ulinear16 mulaw_to_slinear16_be
+#define alaw_to_ulinear16 alaw_to_ulinear16_be
+#define mulaw_to_slinear16 mulaw_to_ulinear16_be
+#define alaw_to_slinear16 alaw_to_slinear16_be
+#endif