Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/isaki-audio2]: src/sys/arch/amiga/dev Adapt to audio2.



details:   https://anonhg.NetBSD.org/src/rev/c106c319c7ee
branches:  isaki-audio2
changeset: 450645:c106c319c7ee
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Apr 21 09:41:58 2019 +0000

description:
Adapt to audio2.

diffstat:

 sys/arch/amiga/dev/repulse.c |  414 ++++--------------------------------------
 1 files changed, 48 insertions(+), 366 deletions(-)

diffs (truncated from 562 to 300 lines):

diff -r 0d23884bbb2c -r c106c319c7ee sys/arch/amiga/dev/repulse.c
--- a/sys/arch/amiga/dev/repulse.c      Sun Apr 21 09:33:54 2019 +0000
+++ b/sys/arch/amiga/dev/repulse.c      Sun Apr 21 09:41:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: repulse.c,v 1.21 2019/03/16 12:09:56 isaki Exp $ */
+/*     $NetBSD: repulse.c,v 1.21.2.1 2019/04/21 09:41:58 isaki Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: repulse.c,v 1.21 2019/03/16 12:09:56 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: repulse.c,v 1.21.2.1 2019/04/21 09:41:58 isaki Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -42,7 +42,6 @@
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
 
 #include <dev/ic/ac97reg.h>
 #include <dev/ic/ac97var.h>
@@ -72,19 +71,17 @@
 
 /* audio attachment functions */
 
-void rep_close(void *);
 int rep_getdev(void *, struct audio_device *);
 int rep_get_props(void *);
 int rep_halt_output(void *);
 int rep_halt_input(void *);
-int rep_query_encoding(void *, struct audio_encoding *);
-int rep_set_params(void *, int, int, audio_params_t *,
-    audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+int rep_query_format(void *, audio_format_query_t *);
+int rep_set_format(void *, int, const audio_params_t *, const audio_params_t *,
+       audio_filter_reg_t *, audio_filter_reg_t *);
 int rep_round_blocksize(void *, int, int, const audio_params_t *);
 int rep_set_port(void *, mixer_ctrl_t *);
 int rep_get_port(void *, mixer_ctrl_t *);
 int rep_query_devinfo(void *, mixer_devinfo_t *);
-size_t rep_round_buffersize(void *, int, size_t);
 void rep_get_locks(void *, kmutex_t **, kmutex_t **);
 
 int rep_start_input(void *, void *, int, void (*)(void *), void *);
@@ -96,9 +93,8 @@
 /* audio attachment */
 
 const struct audio_hw_if rep_hw_if = {
-       .close                  = rep_close,
-       .query_encoding         = rep_query_encoding,
-       .set_params             = rep_set_params,
+       .query_format           = rep_query_format,
+       .set_format             = rep_set_format,
        .round_blocksize        = rep_round_blocksize,
        .start_output           = rep_start_output,
        .start_input            = rep_start_input,
@@ -108,7 +104,6 @@
        .set_port               = rep_set_port,
        .get_port               = rep_get_port,
        .query_devinfo          = rep_query_devinfo,
-       .round_buffersize       = rep_round_buffersize,
        .get_props              = rep_get_props,
        .get_locks              = rep_get_locks,
 };
@@ -168,16 +163,6 @@
 #define REPFIFO_PLAYFIFOGAUGE(x) ((x << 4) & 0xf000)
 #define REPFIFO_RECFIFOGAUGE(x)                (x & 0xf000)
 
-/* ac97 data stream transfer functions */
-void rep_read_16_stereo(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_read_16_mono(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_write_16_stereo(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_write_16_mono(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_read_8_stereo(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_read_8_mono(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_write_8_stereo(struct repulse_hw *, uint8_t *, int, unsigned);
-void rep_write_8_mono(struct repulse_hw *, uint8_t *, int, unsigned);
-
 /* AmigaDOS Delay() ticks */
 
 #define USECPERTICK    (1000000/50)
@@ -195,7 +180,6 @@
        void    (*sc_captmore)(void *);
        void     *sc_captarg;
 
-       void    (*sc_captfun)(struct repulse_hw *, uint8_t *, int, unsigned);
        void     *sc_captbuf;
        int       sc_captscale;
        int       sc_captbufsz;
@@ -204,7 +188,6 @@
 
        void    (*sc_playmore)(void *);
        void     *sc_playarg;
-       void    (*sc_playfun)(struct repulse_hw *, uint8_t *, int, unsigned);
        int       sc_playscale;
        unsigned  sc_playflags;
 
@@ -212,6 +195,17 @@
        kmutex_t  sc_intr_lock;
 };
 
+const struct audio_format repulse_format = {
+       .mode           = AUMODE_PLAY | AUMODE_RECORD,
+       .encoding       = AUDIO_ENCODING_SLINEAR_BE,
+       .validbits      = 16,
+       .precision      = 16,
+       .channels       = 2,
+       .channel_mask   = AUFMT_STEREO,
+       .frequency_type = 6,
+       .frequency      = { 8000, 16000, 22050, 32000, 44100, 48000 },
+};
+
 int repulse_match (device_t, cfdata_t, void *);
 void repulse_attach (device_t, device_t, void *);
 
@@ -249,6 +243,8 @@
        zap = aux;
        bp = (struct repulse_hw *)zap->va;
        sc->sc_boardp = bp;
+       sc->sc_playscale = 4;
+       sc->sc_captscale = 4;
 
        needs_firmware = 0;
        if (bp->rhw_fifostatus & 0x00f0)
@@ -421,16 +417,6 @@
 
 /* audio(9) support stuff which is not ac97-constant */
 
-void
-rep_close(void *arg)
-{
-       struct repulse_softc *sc;
-
-       sc = arg;
-       rep_halt_output(sc);
-       rep_halt_input(sc);
-}
-
 int
 rep_getdev(void *arg, struct audio_device *retp)
 {
@@ -482,46 +468,11 @@
        return 0;
 }
 
-/*
- * Encoding support.
- *
- * TODO: add 24bit and 32bit modes here and in setparams.
- */
-
-const struct repulse_encoding_query {
-       const char *name;
-       int encoding, precision, flags;
-} rep_encoding_queries[] = {
-       { AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0},
-       { AudioEmulaw,  AUDIO_ENCODING_ULAW, 8, AUDIO_ENCODINGFLAG_EMULATED},
-       { AudioEalaw,   AUDIO_ENCODING_ALAW, 8, AUDIO_ENCODINGFLAG_EMULATED},
-       { AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 0},
-       { AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0},
-       { AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, 0},
-       { AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, 0},
-       { AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, 0},
-};
+int
+rep_query_format(void *arg, audio_format_query_t *afp)
+{
 
-int
-rep_query_encoding(void *arg, struct audio_encoding *fp)
-{
-       int i;
-       const struct repulse_encoding_query *p;
-
-       i = fp->index;
-
-       if (i >= sizeof(rep_encoding_queries) /
-           sizeof(struct repulse_encoding_query))
-               return EINVAL;
-
-       p = &rep_encoding_queries[i];
-
-       strncpy (fp->name, p->name, sizeof(fp->name));
-       fp->encoding = p->encoding;
-       fp->precision = p->precision;
-       fp->flags = p->flags;
-
-       return 0;
+       return audio_query_format(&repulse_format, 1, afp);
 }
 
 /*
@@ -568,12 +519,6 @@
        return b1;
 }
 
-size_t
-rep_round_buffersize(void *arg, int direction, size_t size)
-{
-       return size;
-}
-
 void
 rep_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
 {
@@ -585,310 +530,36 @@
 
 
 int
-rep_set_params(void *addr, int setmode, int usemode,
-       audio_params_t *play, audio_params_t *rec,
-       stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+rep_set_format(void *addr, int setmode,
+       const audio_params_t *play, const audio_params_t *rec,
+       audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
-       audio_params_t hw;
        struct repulse_softc *sc;
-       audio_params_t *p;
-       int mode, reg;
-       unsigned  flags;
-       u_int16_t a;
 
        sc = addr;
-       /* for mode in (RECORD, PLAY) */
-       for (mode = AUMODE_RECORD; mode != -1;
-           mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
-
-               if ((setmode & mode) == 0)
-                    continue;
-
-               p = mode == AUMODE_PLAY ? play : rec;
-
-               /* TODO XXX we can do upto 32bit, 96000 */
-               if (p->sample_rate < 4000 || p->sample_rate > 48000 ||
-                   (p->precision != 8 && p->precision != 16) ||
-                   (p->channels != 1 && p->channels != 2))
-                       return EINVAL;
-
-               reg = mode == AUMODE_PLAY ?
-                       AC97_REG_PCM_FRONT_DAC_RATE : AC97_REG_PCM_LR_ADC_RATE;
-
-               repac_write(sc, reg, (uint16_t) p->sample_rate);
-               repac_read(sc, reg, &a);
-               p->sample_rate = a;
-
-               if (mode == AUMODE_PLAY)
-                       sc->sc_playscale = p->channels * p->precision / 8;
-               else
-                       sc->sc_captscale = p->channels * p->precision / 8;
-
-               hw = *p;
-
-               /* everything else is software, alas... */
-               /* XXX TBD signed/unsigned, *law, etc */
-
-               flags = 0;
-               if (p->encoding == AUDIO_ENCODING_ULINEAR_LE ||
-                   p->encoding == AUDIO_ENCODING_ULINEAR_BE ||
-                   p->encoding == AUDIO_ENCODING_ULINEAR)
-                       flags |= 1;
-
-               if (p->encoding == AUDIO_ENCODING_SLINEAR_LE ||
-                   p->encoding == AUDIO_ENCODING_ULINEAR_LE)
-                       flags |= 2;
+       /* XXX 96kHz */
+       if ((setmode & AUMODE_PLAY)) {
+               repac_write(sc, AC97_REG_PCM_FRONT_DAC_RATE, play->sample_rate);
+       }
+       if ((setmode & AUMODE_RECORD)) {
+               repac_write(sc, AC97_REG_PCM_LR_ADC_RATE, rec->sample_rate);
+       }
 
-               if (mode == AUMODE_PLAY) {
-                       sc->sc_playflags = flags;
-                       if (p->encoding == AUDIO_ENCODING_ULAW) {
-                               sc->sc_playfun = p->channels == 1 ?
-                                       rep_write_16_mono :
-                                       rep_write_16_stereo;
-                               sc->sc_playflags = 0;
-                               sc->sc_playscale = p->channels * 2;
-                               hw.encoding = AUDIO_ENCODING_SLINEAR_BE;
-                               hw.precision = hw.validbits = 16;
-                               pfil->append(pfil, mulaw_to_linear16, &hw);
-                       } else
-                       if (p->encoding == AUDIO_ENCODING_ALAW) {
-                               sc->sc_playfun = p->channels == 1 ?
-                                       rep_write_16_mono :
-                                       rep_write_16_stereo;
-                               sc->sc_playflags = 0;
-                               sc->sc_playscale = p->channels * 2;
-                               hw.encoding = AUDIO_ENCODING_SLINEAR_BE;
-                               hw.precision = hw.validbits = 16;
-                               pfil->append(pfil, alaw_to_linear16, &hw);
-                       } else



Home | Main Index | Thread Index | Old Index