Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/4bf0107c64ed
branches:  isaki-audio2
changeset: 451000:4bf0107c64ed
user:      isaki <isaki%NetBSD.org@localhost>
date:      Fri May 03 04:15:23 2019 +0000

description:
Adapt to audio2.
- audio2 limits the lowest frequency.
- Remove unused sc_encodings.
- In audio2, round_buffersize(RECORD) will not be called if the
  driver does not support recording.

diffstat:

 sys/arch/dreamcast/dev/g2/aica.c |  105 ++++++++++++--------------------------
 1 files changed, 34 insertions(+), 71 deletions(-)

diffs (179 lines):

diff -r 3e8d836a34b2 -r 4bf0107c64ed sys/arch/dreamcast/dev/g2/aica.c
--- a/sys/arch/dreamcast/dev/g2/aica.c  Fri May 03 03:00:33 2019 +0000
+++ b/sys/arch/dreamcast/dev/g2/aica.c  Fri May 03 04:15:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aica.c,v 1.25.2.1 2019/04/21 05:11:21 isaki Exp $      */
+/*     $NetBSD: aica.c,v 1.25.2.2 2019/05/03 04:15:23 isaki Exp $      */
 
 /*
  * Copyright (c) 2003 SHIMIZU Ryo <ryo%misakimix.org@localhost>
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.25.2.1 2019/04/21 05:11:21 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.25.2.2 2019/05/03 04:15:23 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -40,8 +40,7 @@
 #include <sys/bus.h>
 
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
+#include <dev/audio/audiovar.h>        /* AUDIO_MIN_FREQUENCY */
 
 #include <machine/sysasicvar.h>
 
@@ -65,7 +64,6 @@
 
        /* audio property */
        int                     sc_open;
-       int                     sc_encodings;
        int                     sc_precision;
        int                     sc_channels;
        int                     sc_rate;
@@ -85,41 +83,19 @@
        int                     sc_nextfill;
 };
 
-const struct {
-       const char *name;
-       int     encoding;
-       int     precision;
-} aica_encodings[] = {
-       {AudioEadpcm,           AUDIO_ENCODING_ADPCM,           4},
-       {AudioEslinear,         AUDIO_ENCODING_SLINEAR,         8},
-       {AudioEulinear,         AUDIO_ENCODING_ULINEAR,         8},
-       {AudioEmulaw,           AUDIO_ENCODING_ULAW,            8},
-       {AudioEalaw,            AUDIO_ENCODING_ALAW,            8},
-       {AudioEslinear_be,      AUDIO_ENCODING_SLINEAR_BE,      16},
-       {AudioEslinear_le,      AUDIO_ENCODING_SLINEAR_LE,      16},
-       {AudioEulinear_be,      AUDIO_ENCODING_ULINEAR_BE,      16},
-       {AudioEulinear_le,      AUDIO_ENCODING_ULINEAR_LE,      16},
+static const struct audio_format aica_formats[] = {
+       {
+               .mode           = AUMODE_PLAY,
+               .encoding       = AUDIO_ENCODING_SLINEAR_LE,
+               .validbits      = 16,
+               .precision      = 16,
+               .channels       = 2,
+               .channel_mask   = AUFMT_STEREO,
+               .frequency_type = 0,
+               .frequency      = { AUDIO_MIN_FREQUENCY, 65536 },
+       },
 };
-
-#define AICA_NFORMATS  5
-#define AICA_FORMAT(enc, prec, ch, chmask) \
-       { \
-               .mode           = AUMODE_PLAY, \
-               .encoding       = (enc), \
-               .validbits      = (prec), \
-               .precision      = (prec), \
-               .channels       = (ch), \
-               .channel_mask   = (chmask), \
-               .frequency_type = 0, \
-               .frequency      = { 1, 65536 }, \
-       }
-static const struct audio_format aica_formats[AICA_NFORMATS] = {
-       AICA_FORMAT(AUDIO_ENCODING_ADPCM,       4, 1, AUFMT_MONAURAL),
-       AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-       AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-       AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE,  8, 1, AUFMT_MONAURAL),
-       AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE,  8, 2, AUFMT_STEREO),
-};
+#define AICA_NFORMATS  __arraycount(aica_formats)
 
 int aica_match(device_t, cfdata_t, void *);
 void aica_attach(device_t, device_t, void *);
@@ -151,9 +127,10 @@
 /* for audio */
 int aica_open(void *, int);
 void aica_close(void *);
-int aica_query_encoding(void *, struct audio_encoding *);
-int aica_set_params(void *, int, int, audio_params_t *,
-    audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+int aica_query_format(void *, audio_format_query_t *);
+int aica_set_format(void *, int,
+    const audio_params_t *, const audio_params_t *,
+    audio_filter_reg_t *, audio_filter_reg_t *);
 int aica_round_blocksize(void *, int, int, const audio_params_t *);
 size_t aica_round_buffersize(void *, int, size_t);
 int aica_trigger_output(void *, void *, void *, int, void (*)(void *), void *,
@@ -173,8 +150,8 @@
 const struct audio_hw_if aica_hw_if = {
        .open                   = aica_open,
        .close                  = aica_close,
-       .query_encoding         = aica_query_encoding,
-       .set_params             = aica_set_params,
+       .query_format           = aica_query_format,
+       .set_format             = aica_set_format,
        .round_blocksize        = aica_round_blocksize,
        .halt_output            = aica_halt_output,
        .halt_input             = aica_halt_input,
@@ -442,38 +419,23 @@
 }
 
 int
-aica_query_encoding(void *addr, struct audio_encoding *fp)
+aica_query_format(void *addr, audio_format_query_t *afp)
 {
-       if (fp->index >= sizeof(aica_encodings) / sizeof(aica_encodings[0]))
-               return EINVAL;
 
-       strcpy(fp->name, aica_encodings[fp->index].name);
-       fp->encoding = aica_encodings[fp->index].encoding;
-       fp->precision = aica_encodings[fp->index].precision;
-       fp->flags = 0;
-
-       return 0;
+       return audio_query_format(aica_formats, AICA_NFORMATS, afp);
 }
 
 int
-aica_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)
+aica_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)
 {
        struct aica_softc *sc;
-       const audio_params_t *hw;
-       int i;
 
-       i = auconv_set_converter(aica_formats, AICA_NFORMATS,
-                                AUMODE_PLAY, play, false, pfil);
-       if (i < 0)
-               return EINVAL;
-       hw = pfil->req_size > 0 ? &pfil->filters[0].param : play;
        sc = addr;
-       sc->sc_precision = hw->precision;
-       sc->sc_channels = hw->channels;
-       sc->sc_rate = hw->sample_rate;
-       sc->sc_encodings = hw->encoding;
+       sc->sc_precision = play->precision;
+       sc->sc_channels = play->channels;
+       sc->sc_rate = play->sample_rate;
        return 0;
 }
 
@@ -514,11 +476,12 @@
 size_t
 aica_round_buffersize(void *addr, int dir, size_t bufsize)
 {
+       struct aica_softc *sc;
 
-       if (dir == AUMODE_PLAY)
-               return 65536;
-
-       return 512;     /* XXX: AUMINBUF */
+       sc = addr;
+       if (bufsize > 65536 * sc->sc_channels)
+               return 65536 * sc->sc_channels;
+       return bufsize;
 }
 
 void



Home | Main Index | Thread Index | Old Index