Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Use endian conversion macros (and some rearrange ...
details: https://anonhg.NetBSD.org/src/rev/fb33cdb94fca
branches: trunk
changeset: 355554:fb33cdb94fca
user: isaki <isaki%NetBSD.org@localhost>
date: Wed Aug 02 10:10:10 2017 +0000
description:
Use endian conversion macros (and some rearrange for readability).
No functional changes.
diffstat:
sys/dev/ic/msm6258.c | 60 +++++++++++++---------------------------------------
1 files changed, 15 insertions(+), 45 deletions(-)
diffs (158 lines):
diff -r bed9412aaf53 -r fb33cdb94fca sys/dev/ic/msm6258.c
--- a/sys/dev/ic/msm6258.c Wed Aug 02 08:39:14 2017 +0000
+++ b/sys/dev/ic/msm6258.c Wed Aug 02 10:10:10 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msm6258.c,v 1.20 2017/07/30 05:51:34 isaki Exp $ */
+/* $NetBSD: msm6258.c,v 1.21 2017/08/02 10:10:10 isaki Exp $ */
/*
* Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 1.20 2017/07/30 05:51:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 1.21 2017/08/02 10:10:10 isaki Exp $");
#include <sys/systm.h>
#include <sys/device.h>
@@ -167,41 +167,27 @@
while (dst->used < m && this->src->used >= 4) {
uint8_t f;
int16_t ss;
-#if BYTE_ORDER == LITTLE_ENDIAN
- ss = *(const int16_t*)s;
- s = audio_stream_add_outp(this->src, s, 2);
+ ss = le16toh(*(const int16_t*)s);
f = pcm2adpcm_step(mc, ss);
- ss = *(const int16_t*)s;
-#else
- ss = (s[1] << 8) | s[0];
s = audio_stream_add_outp(this->src, s, 2);
- f = pcm2adpcm_step(mc, ss);
- ss = (s[1] << 8) | s[0];
-#endif
+ ss = le16toh(*(const int16_t*)s);
f |= pcm2adpcm_step(mc, ss) << 4;
+ s = audio_stream_add_outp(this->src, s, 2);
*d = f;
d = audio_stream_add_inp(dst, d, 1);
- s = audio_stream_add_outp(this->src, s, 2);
}
} else if (enc_src == AUDIO_ENCODING_SLINEAR_BE) {
while (dst->used < m && this->src->used >= 4) {
uint8_t f;
int16_t ss;
-#if BYTE_ORDER == BIG_ENDIAN
- ss = *(const int16_t*)s;
+ ss = be16toh(*(const int16_t*)s);
s = audio_stream_add_outp(this->src, s, 2);
f = pcm2adpcm_step(mc, ss);
- ss = *(const int16_t*)s;
-#else
- ss = (s[0] << 8) | s[1];
+ ss = be16toh(*(const int16_t*)s);
s = audio_stream_add_outp(this->src, s, 2);
- f = pcm2adpcm_step(mc, ss);
- ss = (s[0] << 8) | s[1];
-#endif
f |= pcm2adpcm_step(mc, ss) << 4;
*d = f;
d = audio_stream_add_inp(dst, d, 1);
- s = audio_stream_add_outp(this->src, s, 2);
}
} else {
#if defined(DIAGNOSTIC)
@@ -246,10 +232,10 @@
s = audio_stream_add_outp(this->src, s, 1);
f = pcm2adpcm_step(mc, ss);
ss = ((int16_t)s[0]) * 256;
+ s = audio_stream_add_outp(this->src, s, 1);
f |= pcm2adpcm_step(mc, ss) << 4;
*d = f;
d = audio_stream_add_inp(dst, d, 1);
- s = audio_stream_add_outp(this->src, s, 1);
}
} else if (enc_src == AUDIO_ENCODING_ULINEAR_LE
|| enc_src == AUDIO_ENCODING_ULINEAR_BE) {
@@ -260,10 +246,10 @@
s = audio_stream_add_outp(this->src, s, 1);
f = pcm2adpcm_step(mc, ss);
ss = ((int16_t)(s[0] ^ 0x80)) * 256;
+ s = audio_stream_add_outp(this->src, s, 1);
f |= pcm2adpcm_step(mc, ss) << 4;
*d = f;
d = audio_stream_add_inp(dst, d, 1);
- s = audio_stream_add_outp(this->src, s, 1);
}
} else {
#if defined(DIAGNOSTIC)
@@ -328,17 +314,9 @@
a = s[0];
s1 = adpcm2pcm_step(mc, a & 0x0f);
s2 = adpcm2pcm_step(mc, a >> 4);
-#if BYTE_ORDER == LITTLE_ENDIAN
- *(int16_t*)d = s1;
+ *(int16_t*)d = htole16(s1);
d = audio_stream_add_inp(dst, d, 2);
- *(int16_t*)d = s2;
-#else
- d[0] = s1;
- d[1] = s1 >> 8;
- d = audio_stream_add_inp(dst, d, 2);
- d[0] = s2;
- d[1] = s2 >> 8;
-#endif
+ *(int16_t*)d = htole16(s2);
d = audio_stream_add_inp(dst, d, 2);
s = audio_stream_add_outp(this->src, s, 1);
}
@@ -349,17 +327,9 @@
a = s[0];
s1 = adpcm2pcm_step(mc, a & 0x0f);
s2 = adpcm2pcm_step(mc, a >> 4);
-#if BYTE_ORDER == BIG_ENDIAN
- *(int16_t*)d = s1;
+ *(int16_t*)d = htobe16(s1);
d = audio_stream_add_inp(dst, d, 2);
- *(int16_t*)d = s2;
-#else
- d[1] = s1;
- d[0] = s1 >> 8;
- d = audio_stream_add_inp(dst, d, 2);
- d[1] = s2;
- d[0] = s2 >> 8;
-#endif
+ *(int16_t*)d = htobe16(s2);
d = audio_stream_add_inp(dst, d, 2);
s = audio_stream_add_outp(this->src, s, 1);
}
@@ -404,26 +374,26 @@
uint8_t a;
int16_t s1, s2;
a = s[0];
+ s = audio_stream_add_outp(this->src, s, 1);
s1 = adpcm2pcm_step(mc, a & 0x0f);
s2 = adpcm2pcm_step(mc, a >> 4);
d[0] = s1 / 266;
d = audio_stream_add_inp(dst, d, 1);
d[0] = s2 / 266;
d = audio_stream_add_inp(dst, d, 1);
- s = audio_stream_add_outp(this->src, s, 1);
}
} else if (enc_dst == AUDIO_ENCODING_ULINEAR_LE) {
while (dst->used < m && this->src->used >= 1) {
uint8_t a;
int16_t s1, s2;
a = s[0];
+ s = audio_stream_add_outp(this->src, s, 1);
s1 = adpcm2pcm_step(mc, a & 0x0f);
s2 = adpcm2pcm_step(mc, a >> 4);
d[0] = (s1 / 266) ^ 0x80;
d = audio_stream_add_inp(dst, d, 1);
d[0] = (s2 / 266) ^ 0x80;
d = audio_stream_add_inp(dst, d, 1);
- s = audio_stream_add_outp(this->src, s, 1);
}
} else {
#if defined(DIAGNOSTIC)
Home |
Main Index |
Thread Index |
Old Index