diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2007-11-05 00:17:29 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2007-11-05 00:17:29 +0000 |
commit | 807508d2835434424b1a9b4ff449247de67abb5e (patch) | |
tree | 82e12f7944552ddbee8fd3747e0acaad0779e686 /sys/arch/macppc/dev | |
parent | e9b7a83f6578c78422460eb291021722dc97c534 (diff) |
audio encoding conversion cleanup
- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)
thanks ajacoutot@ and sthen@ for !x86 testing
Diffstat (limited to 'sys/arch/macppc/dev')
-rw-r--r-- | sys/arch/macppc/dev/awacs.c | 52 | ||||
-rw-r--r-- | sys/arch/macppc/dev/i2s.c | 47 |
2 files changed, 9 insertions, 90 deletions
diff --git a/sys/arch/macppc/dev/awacs.c b/sys/arch/macppc/dev/awacs.c index 380b4a79e9e..b7dcfd723fd 100644 --- a/sys/arch/macppc/dev/awacs.c +++ b/sys/arch/macppc/dev/awacs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: awacs.c,v 1.20 2007/09/17 01:33:33 krw Exp $ */ +/* $OpenBSD: awacs.c,v 1.21 2007/11/05 00:17:28 jakemsr Exp $ */ /* $NetBSD: awacs.c,v 1.4 2001/02/26 21:07:51 wiz Exp $ */ /*- @@ -122,10 +122,6 @@ void awacs_write_codec(struct awacs_softc *, int); void awacs_set_speaker_volume(struct awacs_softc *, int, int); void awacs_set_ext_volume(struct awacs_softc *, int, int); void awacs_set_rate(struct awacs_softc *, struct audio_params *); -void awacs_mono16_to_stereo16(void *, u_char *, int); -void awacs_swap_bytes_mono16_to_stereo16(void *, u_char *, int); -void awacs_cvt_ulinear_mono_16_be(void *, u_char *, int); -void awacs_cvt_ulinear_mono_16_le(void *, u_char *, int); struct cfattach awacs_ca = { sizeof(struct awacs_softc), awacs_match, awacs_attach @@ -555,43 +551,6 @@ awacs_query_encoding(void *h, struct audio_encoding *ae) return (0); } -void -awacs_mono16_to_stereo16(void *v, u_char *p, int cc) -{ - int x; - int16_t *src, *dst; - - src = (void *)(p + cc); - dst = (void *)(p + cc * 2); - while (cc > 0) { - x = *--src; - *--dst = x; - *--dst = x; - cc -= 2; - } -} - -void -awacs_swap_bytes_mono16_to_stereo16(void *v, u_char *p, int cc) -{ - swap_bytes(v, p, cc); - awacs_mono16_to_stereo16(v, p, cc); -} - -void -awacs_cvt_ulinear_mono_16_le(void *v, u_char *p, int cc) -{ - swap_bytes_change_sign16_be(v, p, cc); - awacs_mono16_to_stereo16(v, p, cc); -} - -void -awacs_cvt_ulinear_mono_16_be(void *v, u_char *p, int cc) -{ - change_sign16_be(v, p, cc); - awacs_mono16_to_stereo16(v, p, cc); -} - int awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, struct audio_params *rec) @@ -640,8 +599,7 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, } if (p->channels == 1 && p->precision == 16) { p->factor = 2; - p->sw_code = - awacs_swap_bytes_mono16_to_stereo16; + p->sw_code = swap_bytes_mts; break; } return (EINVAL); @@ -650,7 +608,7 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, break; if (p->channels == 1 && p->precision == 16) { p->factor = 2; - p->sw_code = awacs_mono16_to_stereo16; + p->sw_code = noswap_bytes_mts; break; } return (EINVAL); @@ -661,7 +619,7 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, } if (p->channels == 1 && p->precision == 16) { p->factor = 2; - p->sw_code = awacs_cvt_ulinear_mono_16_le; + p->sw_code = swap_bytes_change_sign16_be_mts; break; } return (EINVAL); @@ -672,7 +630,7 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, } if (p->channels == 1 && p->precision == 16) { p->factor = 2; - p->sw_code = awacs_cvt_ulinear_mono_16_be; + p->sw_code = change_sign16_be_mts; break; } return (EINVAL); diff --git a/sys/arch/macppc/dev/i2s.c b/sys/arch/macppc/dev/i2s.c index c82529f87fe..aafcdab4f00 100644 --- a/sys/arch/macppc/dev/i2s.c +++ b/sys/arch/macppc/dev/i2s.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i2s.c,v 1.9 2007/09/17 01:33:33 krw Exp $ */ +/* $OpenBSD: i2s.c,v 1.10 2007/11/05 00:17:28 jakemsr Exp $ */ /* $NetBSD: i2s.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */ /*- @@ -54,7 +54,6 @@ #endif struct i2s_mode *i2s_find_mode(u_int, u_int, u_int); -void i2s_cs16mts(void *, u_char *, int); static int gpio_read(char *); static void gpio_write(char *, int); @@ -65,9 +64,6 @@ int i2s_cint(void *); u_char *i2s_gpio_map(struct i2s_softc *, char *, int *); void i2s_init(struct i2s_softc *, int); -static void mono16_to_stereo16(void *, u_char *, int); -static void swap_bytes_mono16_to_stereo16(void *, u_char *, int); - /* XXX */ void keylargo_fcr_enable(int, u_int32_t); void keylargo_fcr_disable(int, u_int32_t); @@ -271,41 +267,6 @@ i2s_query_encoding(h, ae) return (err); } -static void -mono16_to_stereo16(v, p, cc) - void *v; - u_char *p; - int cc; -{ - int x; - int16_t *src, *dst; - - src = (void *)(p + cc); - dst = (void *)(p + cc * 2); - while (cc > 0) { - x = *--src; - *--dst = x; - *--dst = x; - cc -= 2; - } -} - -static void -swap_bytes_mono16_to_stereo16(v, p, cc) - void *v; - u_char *p; - int cc; -{ - swap_bytes(v, p, cc); - mono16_to_stereo16(v, p, cc); -} - -void -i2s_cs16mts(void *v, u_char *p, int cc) -{ - mono16_to_stereo16(v, p, cc); - change_sign16_be(v, p, cc * 2); -} struct i2s_mode { u_int encoding; @@ -316,11 +277,11 @@ struct i2s_mode { } i2s_modes[] = { { AUDIO_ENCODING_SLINEAR_LE, 8, 1, linear8_to_linear16_be_mts, 4 }, { AUDIO_ENCODING_SLINEAR_LE, 8, 2, linear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_SLINEAR_LE, 16, 1, swap_bytes_mono16_to_stereo16, 2 }, + { AUDIO_ENCODING_SLINEAR_LE, 16, 1, swap_bytes_mts, 2 }, { AUDIO_ENCODING_SLINEAR_LE, 16, 2, swap_bytes, 1 }, { AUDIO_ENCODING_SLINEAR_BE, 8, 1, linear8_to_linear16_be_mts, 4 }, { AUDIO_ENCODING_SLINEAR_BE, 8, 2, linear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_SLINEAR_BE, 16, 1, mono16_to_stereo16, 2 }, + { AUDIO_ENCODING_SLINEAR_BE, 16, 1, noswap_bytes_mts, 2 }, { AUDIO_ENCODING_SLINEAR_BE, 16, 2, NULL, 1 }, { AUDIO_ENCODING_ULINEAR_LE, 8, 1, ulinear8_to_linear16_be_mts, 4 }, { AUDIO_ENCODING_ULINEAR_LE, 8, 2, ulinear8_to_linear16_be, 2 }, @@ -328,7 +289,7 @@ struct i2s_mode { { AUDIO_ENCODING_ULINEAR_LE, 16, 2, swap_bytes_change_sign16_be, 1 }, { AUDIO_ENCODING_ULINEAR_BE, 8, 1, ulinear8_to_linear16_be_mts, 4 }, { AUDIO_ENCODING_ULINEAR_BE, 8, 2, ulinear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_ULINEAR_BE, 16, 1, i2s_cs16mts, 2 }, + { AUDIO_ENCODING_ULINEAR_BE, 16, 1, change_sign16_be_mts, 2 }, { AUDIO_ENCODING_ULINEAR_BE, 16, 2, change_sign16_be, 1 } }; |