summaryrefslogtreecommitdiff
path: root/sys/arch/zaurus
diff options
context:
space:
mode:
authorChristopher Pascoe <pascoe@cvs.openbsd.org>2005-04-15 01:05:52 +0000
committerChristopher Pascoe <pascoe@cvs.openbsd.org>2005-04-15 01:05:52 +0000
commite98c8eadc2a658a4599ac3c5b74fcca6f94420d5 (patch)
tree31f2c2f0b0237bc01eb60051de7954a6e0e64505 /sys/arch/zaurus
parent89ffd6176c431304bc414278cedeb5aed33a580a (diff)
Add basic audio playback support for the Zaurus SL-C3000.
ok dlg@ drahn@ uwe@ deraadt@
Diffstat (limited to 'sys/arch/zaurus')
-rw-r--r--sys/arch/zaurus/conf/GENERIC5
-rw-r--r--sys/arch/zaurus/conf/files.zaurus9
-rw-r--r--sys/arch/zaurus/dev/zaurus_audio.c679
-rw-r--r--sys/arch/zaurus/dev/zaurus_scoop.c25
-rw-r--r--sys/arch/zaurus/dev/zaurus_scoopvar.h3
5 files changed, 716 insertions, 5 deletions
diff --git a/sys/arch/zaurus/conf/GENERIC b/sys/arch/zaurus/conf/GENERIC
index bc0248518c4..eacbdf27b6b 100644
--- a/sys/arch/zaurus/conf/GENERIC
+++ b/sys/arch/zaurus/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.32 2005/04/14 23:40:34 pascoe Exp $
+# $OpenBSD: GENERIC,v 1.33 2005/04/15 01:05:50 pascoe Exp $
#
# GENERIC machine description file
#
@@ -148,7 +148,8 @@ com1 at pxaip? addr 0x40200000 intr 21 # BlueTooth UART
options FFUARTCONSOLE
#options BTUARTCONSOLE
-#aupxa0 at pxaip? # AC97 interface
+zaudio0 at pxaip? # Zaurus I2S/I2C sound
+audio* at zaudio?
# CF (pcmcia) support
pxapcic0 at pxaip?
diff --git a/sys/arch/zaurus/conf/files.zaurus b/sys/arch/zaurus/conf/files.zaurus
index 51726538074..6813b3395e9 100644
--- a/sys/arch/zaurus/conf/files.zaurus
+++ b/sys/arch/zaurus/conf/files.zaurus
@@ -1,4 +1,4 @@
-# $OpenBSD: files.zaurus,v 1.15 2005/01/28 17:14:31 drahn Exp $
+# $OpenBSD: files.zaurus,v 1.16 2005/04/15 01:05:50 pascoe Exp $
#
# First try for arm-specific configuration info
#
@@ -52,6 +52,13 @@ device zts: wsmousedev
attach zts at pxaip
file arch/zaurus/dev/zts.c zts
+# Zaurus sound
+device zaudio: audio
+attach zaudio at pxaip
+file arch/zaurus/dev/zaurus_audio.c zaudio
+file arch/arm/xscale/pxa2x0_i2s.c zaudio
+file arch/arm/xscale/pxa2x0_i2c.c zaudio
+
#
# Machine-independent ATA drivers
#
diff --git a/sys/arch/zaurus/dev/zaurus_audio.c b/sys/arch/zaurus/dev/zaurus_audio.c
new file mode 100644
index 00000000000..478e6990976
--- /dev/null
+++ b/sys/arch/zaurus/dev/zaurus_audio.c
@@ -0,0 +1,679 @@
+/* $OpenBSD: zaurus_audio.c,v 1.1 2005/04/15 01:05:51 pascoe Exp $ */
+
+/*
+ * Copyright (c) 2005 Christopher Pascoe <pascoe@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/audioio.h>
+
+#include <machine/intr.h>
+#include <machine/bus.h>
+
+#include <arm/xscale/pxa2x0reg.h>
+#include <arm/xscale/pxa2x0var.h>
+#include <arm/xscale/pxa2x0_i2c.h>
+#include <arm/xscale/pxa2x0_i2s.h>
+#include <arm/xscale/pxa2x0_dmac.h>
+
+#include <zaurus/dev/zaurus_scoopvar.h>
+#include <dev/i2c/wm8750reg.h>
+
+#include <dev/audio_if.h>
+#include <dev/mulaw.h>
+#include <dev/auconv.h>
+
+#define WM8750_ADDRESS 0x1B
+#define SPKR_VOLUME 112
+
+#define wm8750_write(sc, reg, val) pxa2x0_i2c_write_2(&sc->sc_i2c, \
+ WM8750_ADDRESS, (((reg) << 9) | ((val) & 0x1ff)))
+
+int zaudio_match(struct device *, void *, void *);
+void zaudio_attach(struct device *, struct device *, void *);
+int zaudio_detach(struct device *, int);
+void zaudio_power(int, void *);
+
+struct zaudio_softc {
+ struct device sc_dev;
+
+ /* i2s device softc */
+ /* NB: pxa2x0_i2s requires this to be the second struct member */
+ struct pxa2x0_i2s_softc sc_i2s;
+
+ /* i2c device softc */
+ struct pxa2x0_i2c_softc sc_i2c;
+
+ void *sc_powerhook;
+ int sc_playing;
+};
+
+struct cfattach zaudio_ca = {
+ sizeof(struct zaudio_softc), zaudio_match, zaudio_attach,
+ zaudio_detach
+};
+
+struct cfdriver zaudio_cd = {
+ NULL, "zaudio", DV_DULL
+};
+
+struct audio_device wm8750_device = {
+ "WM8750",
+ "1.0",
+ "wm"
+};
+
+void zaudio_init(struct zaudio_softc *);
+void zaudio_standby(struct zaudio_softc *);
+void zaudio_play_setup(struct zaudio_softc *);
+int zaudio_open(void *, int);
+void zaudio_close(void *);
+int zaudio_query_encoding(void *, struct audio_encoding *);
+int zaudio_set_params(void *, int, int, struct audio_params *,
+ struct audio_params *);
+int zaudio_halt_output(void *);
+int zaudio_halt_input(void *);
+int zaudio_getdev(void *, struct audio_device *);
+int zaudio_set_port(void *, struct mixer_ctrl *);
+int zaudio_get_port(void *, struct mixer_ctrl *);
+int zaudio_query_devinfo(void *, struct mixer_devinfo *);
+int zaudio_get_props(void *);
+int zaudio_start_output(void *, void *, int, void (*)(void *), void *);
+int zaudio_start_input(void *, void *, int, void (*)(void *), void *);
+
+struct audio_hw_if wm8750_hw_if = {
+ zaudio_open,
+ zaudio_close,
+ NULL /* zaudio_drain */,
+ zaudio_query_encoding,
+ zaudio_set_params,
+ pxa2x0_i2s_round_blocksize,
+ NULL /* zaudio_commit_settings */,
+ NULL /* zaudio_init_output */,
+ NULL /* zaudio_init_input */,
+ zaudio_start_output,
+ zaudio_start_input,
+ zaudio_halt_output,
+ zaudio_halt_input,
+ NULL /* zaudio_speaker_ctl */,
+ zaudio_getdev,
+ NULL /* zaudio_setfd */,
+ zaudio_set_port,
+ zaudio_get_port,
+ zaudio_query_devinfo,
+ pxa2x0_i2s_allocm,
+ pxa2x0_i2s_freem,
+ pxa2x0_i2s_round_buffersize,
+ pxa2x0_i2s_mappage,
+ zaudio_get_props,
+ NULL /* zaudio_trigger_output */,
+ NULL /* zaudio_trigger_input */
+};
+
+static const unsigned short playback_registers[][2] = {
+ /* Unmute DAC */
+ { ADCDACCTL_REG, 0x000 },
+
+ /* 16 bit audio words */
+ { AUDINT_REG, AUDINT_SET_FORMAT(2) },
+
+ /* Enable thermal protection, power */
+ { ADCTL1_REG, ADCTL1_TSDEN | ADCTL1_SET_VSEL(3) },
+
+ /* Enable speaker driver, DAC oversampling */
+ { ADCTL2_REG, ADCTL2_ROUT2INV | ADCTL2_DACOSR },
+
+ /* Set DAC voltage references */
+ { PWRMGMT1_REG, PWRMGMT1_SET_VMIDSEL(1) | PWRMGMT1_VREF },
+
+ /* Power DACs and outputs */
+ { PWRMGMT2_REG, PWRMGMT2_DACL | PWRMGMT2_DACR | PWRMGMT2_LOUT1 |
+ PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2 },
+
+ /* Set left/right channel mix mixer */
+ { LOUTMIX1_REG, LOUTMIX1_LD2LO | LOUTMIX1_SET_LI2LOVOL(5) },
+ { ROUTMIX2_REG, ROUTMIX2_RD2RO | ROUTMIX2_SET_RI2ROVOL(5) },
+
+ /* Set speaker volume */
+ { LOUT2VOL_REG, LOUT2VOL_LO2VU | LOUT2VOL_SET_LOUT2VOL(SPKR_VOLUME) },
+ { ROUT2VOL_REG, ROUT2VOL_RO2VU | ROUT2VOL_SET_ROUT2VOL(0) },
+
+ /* End of list */
+ { 0xffff, 0xffff }
+};
+
+int
+zaudio_match(struct device *parent, void *match, void *aux)
+{
+ return (1);
+}
+
+void
+zaudio_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct zaudio_softc *sc = (struct zaudio_softc *)self;
+ struct pxaip_attach_args *pxa = aux;
+
+ sc->sc_powerhook = powerhook_establish(zaudio_power, sc);
+ if (sc->sc_powerhook == NULL) {
+ printf(": unable to establish powerhook\n");
+ return;
+ }
+
+ sc->sc_i2s.sc_iot = pxa->pxa_iot;
+ sc->sc_i2s.sc_dmat = pxa->pxa_dmat;
+ sc->sc_i2s.sc_size = PXA2X0_I2S_SIZE;
+ if (pxa2x0_i2s_attach_sub(&sc->sc_i2s)) {
+ printf(": unable to attach I2S\n");
+ goto fail_i2s;
+ }
+
+ sc->sc_i2c.sc_iot = pxa->pxa_iot;
+ sc->sc_i2c.sc_size = PXA2X0_I2C_SIZE;
+ if (pxa2x0_i2c_attach_sub(&sc->sc_i2c)) {
+ printf(": unable to attach I2C\n");
+ goto fail_i2c;
+ }
+
+ /* Check for an I2C response from the wm8750 */
+ pxa2x0_i2s_open(&sc->sc_i2s); /* supply the codec with a clock */
+ pxa2x0_i2c_open(&sc->sc_i2c);
+
+ if (wm8750_write(sc, RESET_REG, 0)) {
+ printf(": codec failed to respond\n");
+ goto fail_probe;
+ }
+ delay(100);
+
+ zaudio_init(sc);
+
+ pxa2x0_i2c_close(&sc->sc_i2c);
+ pxa2x0_i2s_close(&sc->sc_i2s);
+
+ printf(": I2C, I2S, WM8750 Audio\n");
+
+ audio_attach_mi(&wm8750_hw_if, sc, &sc->sc_dev);
+
+ return;
+
+fail_probe:
+ pxa2x0_i2c_close(&sc->sc_i2c);
+ pxa2x0_i2s_close(&sc->sc_i2s);
+ pxa2x0_i2c_detach_sub(&sc->sc_i2c);
+fail_i2c:
+ pxa2x0_i2s_detach_sub(&sc->sc_i2s);
+fail_i2s:
+ powerhook_disestablish(sc->sc_powerhook);
+}
+
+int
+zaudio_detach(struct device *self, int flags)
+{
+ struct zaudio_softc *sc = (struct zaudio_softc *)self;
+
+ if (sc->sc_powerhook != NULL) {
+ powerhook_disestablish(sc->sc_powerhook);
+ sc->sc_powerhook = NULL;
+ }
+
+ pxa2x0_i2c_detach_sub(&sc->sc_i2c);
+ pxa2x0_i2s_detach_sub(&sc->sc_i2s);
+
+ return (0);
+}
+
+void
+zaudio_power(int why, void *arg)
+{
+ /* XXX */
+ return;
+}
+
+void
+zaudio_init(struct zaudio_softc *sc)
+{
+ /* Reset the codec */
+ wm8750_write(sc, RESET_REG, 0);
+ delay(100);
+
+ /* Switch to standby power only */
+ wm8750_write(sc, PWRMGMT1_REG, PWRMGMT1_SET_VMIDSEL(2));
+ wm8750_write(sc, PWRMGMT2_REG, 0);
+
+ /* Configure digital interface for I2S */
+ wm8750_write(sc, AUDINT_REG, AUDINT_SET_FORMAT(2));
+}
+
+void
+zaudio_standby(struct zaudio_softc *sc)
+{
+ /* Switch codec to standby power only */
+ wm8750_write(sc, PWRMGMT1_REG, PWRMGMT1_SET_VMIDSEL(2));
+ wm8750_write(sc, PWRMGMT2_REG, 0);
+}
+
+void
+zaudio_play_setup(struct zaudio_softc *sc)
+{
+ int i = 0;
+
+ pxa2x0_i2c_open(&sc->sc_i2c);
+
+ /* Program the codec with playback settings */
+ while (playback_registers[i][0] != 0xffff) {
+ wm8750_write(sc, playback_registers[i][0],
+ playback_registers[i][1]);
+ i++;
+ }
+
+ pxa2x0_i2c_close(&sc->sc_i2c);
+}
+
+int
+zaudio_open(void *hdl, int flags)
+{
+ struct zaudio_softc *sc = hdl;
+
+ /* Power on the I2S bus and codec */
+ pxa2x0_i2s_open(&sc->sc_i2s);
+ scoop_audio_set(1);
+
+ return 0;
+}
+
+void
+zaudio_close(void *hdl)
+{
+ struct zaudio_softc *sc = hdl;
+
+ /* Power off the I2S bus and codec */
+ pxa2x0_i2s_close(&sc->sc_i2s);
+ scoop_audio_set(0);
+}
+
+int
+zaudio_query_encoding(void *hdl, struct audio_encoding *aep)
+{
+ switch (aep->index) {
+ case 0:
+ strlcpy(aep->name, AudioEulinear, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_ULINEAR;
+ aep->precision = 8;
+ aep->flags = 0;
+ return (0);
+ case 1:
+ strlcpy(aep->name, AudioEmulaw, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_ULAW;
+ aep->precision = 8;
+ aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ return (0);
+ case 2:
+ strlcpy(aep->name, AudioEalaw, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_ALAW;
+ aep->precision = 8;
+ aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ return (0);
+ case 3:
+ strlcpy(aep->name, AudioEslinear, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_SLINEAR;
+ aep->precision = 8;
+ aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ return (0);
+ case 4:
+ strlcpy(aep->name, AudioEslinear_le, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_SLINEAR_LE;
+ aep->precision = 16;
+ aep->flags = 0;
+ return (0);
+ case 5:
+ strlcpy(aep->name, AudioEulinear_le, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_ULINEAR_LE;
+ aep->precision = 16;
+ aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ return (0);
+ case 6:
+ strlcpy(aep->name, AudioEslinear_be, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_SLINEAR_BE;
+ aep->precision = 16;
+ aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ return (0);
+ case 7:
+ strlcpy(aep->name, AudioEulinear_be, sizeof(aep->name));
+ aep->encoding = AUDIO_ENCODING_ULINEAR_BE;
+ aep->precision = 16;
+ aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ return (0);
+ default:
+ return (EINVAL);
+ }
+}
+
+int
+zaudio_set_params(void *hdl, int setmode, int usemode,
+ struct audio_params *play, struct audio_params *rec)
+{
+ struct zaudio_softc *sc = hdl;
+
+ if (setmode & AUMODE_PLAY) {
+ play->factor = 1;
+ play->sw_code = NULL;
+ switch(play->encoding) {
+ case AUDIO_ENCODING_ULAW:
+ switch (play->channels) {
+ case 1:
+ play->factor = 4;
+ play->sw_code = mulaw_to_slinear16_mts;
+ break;
+ case 2:
+ play->factor = 2;
+ play->sw_code = mulaw_to_slinear16;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case AUDIO_ENCODING_SLINEAR_LE:
+ switch (play->precision) {
+ case 8:
+ switch (play->channels) {
+ case 1:
+ play->factor = 4;
+ play->sw_code = linear8_to_linear16_mts;
+ break;
+ case 2:
+ play->factor = 2;
+ play->sw_code = linear8_to_linear16;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case 16:
+ switch (play->channels) {
+ case 1:
+ play->factor = 2;
+ play->sw_code = noswap_bytes_mts;
+ break;
+ case 2:
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case AUDIO_ENCODING_ULINEAR_LE:
+ switch (play->precision) {
+ case 8:
+ switch (play->channels) {
+ case 1:
+ play->factor = 4;
+ play->sw_code =
+ ulinear8_to_linear16_mts;
+ break;
+ case 2:
+ play->factor = 2;
+ play->sw_code = ulinear8_to_linear16;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case 16:
+ switch (play->channels) {
+ case 1:
+ play->factor = 2;
+ play->sw_code = change_sign16_mts;
+ break;
+ case 2:
+ play->sw_code = change_sign16;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case AUDIO_ENCODING_ALAW:
+ switch (play->channels) {
+ case 1:
+ play->factor = 4;
+ play->sw_code = alaw_to_slinear16_mts;
+ case 2:
+ play->factor = 2;
+ play->sw_code = alaw_to_slinear16;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case AUDIO_ENCODING_SLINEAR_BE:
+ switch (play->precision) {
+ case 8:
+ switch (play->channels) {
+ case 1:
+ play->factor = 4;
+ play->sw_code =
+ linear8_to_linear16_mts;
+ break;
+ case 2:
+ play->factor = 2;
+ play->sw_code = linear8_to_linear16;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case 16:
+ switch (play->channels) {
+ case 1:
+ play->factor = 2;
+ play->sw_code = swap_bytes_mts;
+ break;
+ case 2:
+ play->sw_code = swap_bytes;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case AUDIO_ENCODING_ULINEAR_BE:
+ switch (play->precision) {
+ case 8:
+ switch (play->channels) {
+ case 1:
+ play->factor = 4;
+ play->sw_code =
+ ulinear8_to_linear16_mts;
+ break;
+ case 2:
+ play->factor = 2;
+ play->sw_code = ulinear8_to_linear16;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ case 16:
+ switch (play->channels) {
+ case 1:
+ play->factor = 2;
+ play->sw_code =
+ change_sign16_swap_bytes_mts;
+ break;
+ case 2:
+ play->sw_code =
+ change_sign16_swap_bytes;
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ default:
+ return (EINVAL);
+ }
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ pxa2x0_i2s_setspeed(&sc->sc_i2s, &play->sample_rate);
+ }
+
+#if RECORD_XXX_NOT_YET
+ if (setmode & AUMODE_RECORD) {
+ rec->factor = 1;
+ rec->sw_code = NULL;
+ switch(rec->encoding) {
+ case AUDIO_ENCODING_ULAW:
+ rec->sw_code = ulinear8_to_mulaw;
+ break;
+ case AUDIO_ENCODING_SLINEAR_LE:
+ if (rec->precision == 8)
+ rec->sw_code = change_sign8;
+ break;
+ case AUDIO_ENCODING_ULINEAR_LE:
+ if (rec->precision == 16)
+ rec->sw_code = change_sign16;
+ break;
+ case AUDIO_ENCODING_ALAW:
+ rec->sw_code = ulinear8_to_alaw;
+ break;
+ case AUDIO_ENCODING_SLINEAR_BE:
+ if (rec->precision == 16)
+ rec->sw_code = swap_bytes;
+ else
+ rec->sw_code = change_sign8;
+ break;
+ case AUDIO_ENCODING_ULINEAR_BE:
+ if (rec->precision == 16)
+ rec->sw_code = swap_bytes_change_sign16;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ pxa2x0_i2s_setspeed(sc, &rec->sample_rate);
+ }
+#endif
+
+ return (0);
+}
+
+int
+zaudio_halt_output(void *hdl)
+{
+ struct zaudio_softc *sc = hdl;
+
+ /* XXX forcibly stop output DMA? */
+
+ pxa2x0_i2c_open(&sc->sc_i2c);
+
+ zaudio_standby(sc);
+ sc->sc_playing = 0;
+
+ pxa2x0_i2c_close(&sc->sc_i2c);
+
+ return 0;
+}
+
+int
+zaudio_halt_input(void *hdl)
+{
+ /* struct zaudio_softc *sc = hdl; */
+
+ return 0;
+}
+
+int
+zaudio_getdev(void *hdl, struct audio_device *ret)
+{
+ /* struct zaudio_softc *sc = hdl; */
+
+ *ret = wm8750_device;
+ return 0;
+}
+
+int
+zaudio_set_port(void *hdl, struct mixer_ctrl *mc)
+{
+ /* struct zaudio_softc *sc = hdl; */
+
+ return 0;
+}
+
+int
+zaudio_get_port(void *hdl, struct mixer_ctrl *mc)
+{
+ /* struct zaudio_softc *sc = hdl; */
+
+ return 0;
+}
+
+int
+zaudio_query_devinfo(void *hdl, struct mixer_devinfo *di)
+{
+ /* struct zaudio_softc *sc = hdl; */
+
+ di->prev = di->next = AUDIO_MIXER_LAST;
+
+ return ENXIO;
+}
+
+int
+zaudio_get_props(void *hdl)
+{
+ return AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT | AUDIO_PROP_FULLDUPLEX;
+}
+
+int
+zaudio_start_output(void *hdl, void *block, int bsize, void (*intr)(void *),
+ void *intrarg)
+{
+ struct zaudio_softc *sc = hdl;
+ int err;
+
+ /* Power up codec if we are not already playing. */
+ if (!sc->sc_playing) {
+ sc->sc_playing = 1;
+ zaudio_play_setup(sc);
+ }
+
+ /* Start DMA via I2S */
+ err = pxa2x0_i2s_start_output(&sc->sc_i2s, block, bsize, intr, intrarg);
+ if (err) {
+ zaudio_standby(sc);
+ sc->sc_playing = 0;
+ }
+ return err;
+}
+
+int
+zaudio_start_input(void *hdl, void *block, int bsize, void (*intr)(void *),
+ void *intrarg)
+{
+ return ENXIO;
+}
diff --git a/sys/arch/zaurus/dev/zaurus_scoop.c b/sys/arch/zaurus/dev/zaurus_scoop.c
index b741464aa33..e46e28e93a1 100644
--- a/sys/arch/zaurus/dev/zaurus_scoop.c
+++ b/sys/arch/zaurus/dev/zaurus_scoop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_scoop.c,v 1.7 2005/03/08 23:29:06 uwe Exp $ */
+/* $OpenBSD: zaurus_scoop.c,v 1.8 2005/04/15 01:05:51 pascoe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -166,6 +166,29 @@ scoop_led_set(int led, int on)
}
void
+scoop_audio_set(int on)
+{
+ if (scoop_cd.cd_ndevs < 1 || scoop_cd.cd_devs[0] == NULL)
+ return;
+
+ if (on) {
+ scoop_gpio_pin_ctl(scoop_cd.cd_devs[0], SCOOP0_MUTE_L,
+ GPIO_PIN_OUTPUT);
+ scoop_gpio_pin_ctl(scoop_cd.cd_devs[0], SCOOP0_MUTE_R,
+ GPIO_PIN_OUTPUT);
+ scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_L,
+ GPIO_PIN_LOW);
+ scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_R,
+ GPIO_PIN_LOW);
+ } else {
+ scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_L,
+ GPIO_PIN_HIGH);
+ scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_R,
+ GPIO_PIN_HIGH);
+ }
+}
+
+void
scoop_battery_temp_adc(int enable)
{
diff --git a/sys/arch/zaurus/dev/zaurus_scoopvar.h b/sys/arch/zaurus/dev/zaurus_scoopvar.h
index 31307a16142..20c02284a49 100644
--- a/sys/arch/zaurus/dev/zaurus_scoopvar.h
+++ b/sys/arch/zaurus/dev/zaurus_scoopvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_scoopvar.h,v 1.6 2005/02/22 21:53:03 uwe Exp $ */
+/* $OpenBSD: zaurus_scoopvar.h,v 1.7 2005/04/15 01:05:51 pascoe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -25,5 +25,6 @@ void scoop_battery_temp_adc(int);
void scoop_charge_battery(int, int);
void scoop_discharge_battery(int);
void scoop_check_mcr(void);
+void scoop_audio_set(int);
void scoop_suspend(void);
void scoop_resume(void);