Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/7018fc3cfb32
branches:  isaki-audio2
changeset: 450646:7018fc3cfb32
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Apr 21 09:54:00 2019 +0000

description:
Adapt to audio2.

diffstat:

 sys/arch/hpcmips/vr/vraiu.c    |  515 ++--------------------------------------
 sys/arch/hppa/gsc/harmony.c    |  200 +++------------
 sys/arch/hppa/gsc/harmonyvar.h |    4 +-
 3 files changed, 75 insertions(+), 644 deletions(-)

diffs (truncated from 933 to 300 lines):

diff -r c106c319c7ee -r 7018fc3cfb32 sys/arch/hpcmips/vr/vraiu.c
--- a/sys/arch/hpcmips/vr/vraiu.c       Sun Apr 21 09:41:58 2019 +0000
+++ b/sys/arch/hpcmips/vr/vraiu.c       Sun Apr 21 09:54:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vraiu.c,v 1.16 2019/03/16 12:09:56 isaki Exp $ */
+/*     $NetBSD: vraiu.c,v 1.16.2.1 2019/04/21 09:54:00 isaki Exp $     */
 
 /*
  * Copyright (c) 2001 HAMAJIMA Katsuomi. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.16 2019/03/16 12:09:56 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.16.2.1 2019/04/21 09:54:00 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -74,12 +74,7 @@
        u_short *sc_buf;        /* DMA buffer pointer */
        int     sc_status;      /* status */
        u_int   sc_rate;        /* sampling rate */
-       u_int   sc_channels;    /* # of channels used */
-       u_int   sc_encoding;    /* encoding type */
-       int     sc_precision;   /* 8 or 16 bits */
-                               /* pointer to format conversion routine */
        u_char  sc_volume;      /* volume */
-       void    (*sc_decodefunc)(struct vraiu_softc *, u_short *, void *, int);
        void    (*sc_intr)(void *);     /* interrupt routine */
        void    *sc_intrdata;           /* interrupt data */
 };
@@ -97,12 +92,23 @@
        "aiu"
 };
 
+const struct audio_format vraiu_formats = {
+       .mode           = AUMODE_PLAY,
+       .encoding       = AUDIO_ENCODING_SLINEAR_NE,
+       .validbits      = 10,
+       .precision      = 16,
+       .channels       = 1,
+       .channel_mask   = AUFMT_MONAURAL,
+       .frequency_type = 4,
+       .frequency      = { 8000, 11025, 22050, 44100 },
+};
+
 /*
  * Define our interface to the higher level audio driver.
  */
 int vraiu_open(void *, int);
 void vraiu_close(void *);
-int vraiu_query_encoding(void *, struct audio_encoding *);
+int vraiu_query_format(void *, audio_format_query_t *);
 int vraiu_round_blocksize(void *, int, int, const audio_params_t *);
 int vraiu_commit_settings(void *);
 int vraiu_init_output(void *, void*, int);
@@ -114,16 +120,17 @@
 int vraiu_set_port(void *, mixer_ctrl_t *);
 int vraiu_get_port(void *, mixer_ctrl_t *);
 int vraiu_query_devinfo(void *, mixer_devinfo_t *);
-int vraiu_set_params(void *, int, int, audio_params_t *, audio_params_t *,
-                    stream_filter_list_t *, stream_filter_list_t *);
+int vraiu_set_format(void *, int,
+    const audio_params_t *, const audio_params_t *,
+    audio_filter_reg_t *, audio_filter_reg_t *);
 int vraiu_get_props(void *);
 void vraiu_get_locks(void *, kmutex_t **, kmutex_t **);
 
 const struct audio_hw_if vraiu_hw_if = {
        .open                   = vraiu_open,
        .close                  = vraiu_close,
-       .query_encoding         = vraiu_query_encoding,
-       .set_params             = vraiu_set_params,
+       .query_format           = vraiu_query_format,
+       .set_format             = vraiu_set_format,
        .round_blocksize        = vraiu_round_blocksize,
        .commit_settings        = vraiu_commit_settings,
        .init_output            = vraiu_init_output,
@@ -143,20 +150,7 @@
 /*
  * convert to 1ch 10bit unsigned PCM data.
  */
-static void vraiu_slinear8_1(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_slinear8_2(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_ulinear8_1(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_ulinear8_2(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_mulaw_1(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_mulaw_2(struct vraiu_softc *, u_short *, void *, int);
 static void vraiu_slinear16_1(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_slinear16_2(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_slinear16sw_1(struct vraiu_softc *, u_short *, void *, int);
-static void vraiu_slinear16sw_2(struct vraiu_softc *, u_short *, void *, int);
-/*
- * software volume control
- */
-static void vraiu_volume(struct vraiu_softc *, u_short *, void *, int);
 
 int
 vraiu_match(device_t parent, cfdata_t cf, void *aux)
@@ -261,10 +255,6 @@
 
        sc->sc_status = 0;
        sc->sc_rate = SPS8000;
-       sc->sc_channels = 1;
-       sc->sc_precision = 8;
-       sc->sc_encoding = AUDIO_ENCODING_ULAW;
-       sc->sc_decodefunc = vraiu_mulaw_1;
        DPRINTFN(1, ("vraiu_attach: reset AIU\n"))
        bus_space_write_2(sc->sc_iot, sc->sc_ioh, SEQ_REG_W, AIURST);
        /* attach audio subsystem */
@@ -293,89 +283,28 @@
 
        DPRINTFN(1, ("vraiu_close\n"));
        sc = self;
-       vraiu_halt_output(self);
        sc->sc_status = 0;
 }
 
 int
-vraiu_query_encoding(void *self, struct audio_encoding *ae)
+vraiu_query_format(void *self, audio_format_query_t *afp)
 {
-       DPRINTFN(3, ("vraiu_query_encoding\n"));
 
-       switch (ae->index) {
-       case 0:
-               strcpy(ae->name, AudioEslinear);
-               ae->encoding = AUDIO_ENCODING_SLINEAR;
-               ae->precision = 8;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 1:
-               strcpy(ae->name, AudioEmulaw);
-               ae->encoding = AUDIO_ENCODING_ULAW;
-               ae->precision = 8;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 2:
-               strcpy(ae->name, AudioEulinear);
-               ae->encoding = AUDIO_ENCODING_ULINEAR;
-               ae->precision = 8;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 3:
-               strcpy(ae->name, AudioEslinear);
-               ae->encoding = AUDIO_ENCODING_SLINEAR;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 4:
-               strcpy(ae->name, AudioEslinear_be);
-               ae->encoding = AUDIO_ENCODING_SLINEAR_BE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 5:
-               strcpy(ae->name, AudioEslinear_le);
-               ae->encoding = AUDIO_ENCODING_SLINEAR_LE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 6:
-               strcpy(ae->name, AudioEslinear);
-               ae->encoding = AUDIO_ENCODING_ULINEAR;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 7:
-               strcpy(ae->name, AudioEslinear_be);
-               ae->encoding = AUDIO_ENCODING_ULINEAR_BE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 8:
-               strcpy(ae->name, AudioEslinear_le);
-               ae->encoding = AUDIO_ENCODING_ULINEAR_LE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       default:
-               DPRINTFN(0, ("vraiu_query_encoding: param error"
-                            " (%d)\n", ae->index));
-               return EINVAL;
-       }
-       return 0;
+       return audio_query_format(&vraiu_formats, 1, afp);
 }
 
 int
-vraiu_set_params(void *self, int setmode, int usemode,
-                audio_params_t *play, audio_params_t *rec,
-                stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+vraiu_set_format(void *self, int setmode,
+                const audio_params_t *play, const audio_params_t *rec,
+                audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
        struct vraiu_softc *sc;
 
-       DPRINTFN(1, ("vraiu_set_params: %ubit, %uch, %uHz, encoding %u\n",
+       DPRINTFN(1, ("%s: %ubit, %uch, %uHz, encoding %u\n", __func__,
                     play->precision, play->channels, play->sample_rate,
                     play->encoding));
        sc = self;
+
        switch (play->sample_rate) {
        case 8000:
                sc->sc_rate = SPS8000;
@@ -390,152 +319,17 @@
                sc->sc_rate = SPS44100;
                break;
        default:
-               DPRINTFN(0, ("vraiu_set_params: rate error (%ld)\n",
-                            play->sample_rate));
-               return EINVAL;
+               /* NOTREACHED */
+               panic("%s: rate error (%d)\n", __func__, play->sample_rate);
        }
 
-       switch (play->precision) {
-       case 8:
-               switch (play->encoding) {
-               case AUDIO_ENCODING_ULAW:
-                       switch (play->channels) {
-                       case 1:
-                               sc->sc_decodefunc = vraiu_mulaw_1;
-                               break;
-                       case 2:
-                               sc->sc_decodefunc = vraiu_mulaw_2;
-                               break;
-                       default:
-                               DPRINTFN(0, ("vraiu_set_params: channel error"
-                                            " (%d)\n", play->channels));
-                               return EINVAL;
-                       }
-                       break;
-               case AUDIO_ENCODING_SLINEAR:
-               case AUDIO_ENCODING_SLINEAR_BE:
-               case AUDIO_ENCODING_SLINEAR_LE:
-                       switch (play->channels) {
-                       case 1:
-                               sc->sc_decodefunc = vraiu_slinear8_1;
-                               break;
-                       case 2:
-                               sc->sc_decodefunc = vraiu_slinear8_2;
-                               break;
-                       default:
-                               DPRINTFN(0, ("vraiu_set_params: channel error"
-                                            " (%d)\n", play->channels));
-                               return EINVAL;
-                       }
-                       break;
-               case AUDIO_ENCODING_ULINEAR:
-               case AUDIO_ENCODING_ULINEAR_BE:
-               case AUDIO_ENCODING_ULINEAR_LE:
-                       switch (play->channels) {
-                       case 1:
-                               sc->sc_decodefunc = vraiu_ulinear8_1;
-                               break;
-                       case 2:
-                               sc->sc_decodefunc = vraiu_ulinear8_2;
-                               break;
-                       default:
-                               DPRINTFN(0, ("vraiu_set_params: channel error"
-                                            " (%d)\n", play->channels));
-                               return EINVAL;
-                       }
-                       break;
-               default:
-                       DPRINTFN(0, ("vraiu_set_params: encoding error"
-                                    " (%d)\n", play->encoding));
-                       return EINVAL;
-               }
-               break;
-       case 16:
-               switch (play->encoding) {
-#if BYTE_ORDER == BIG_ENDIAN
-               case AUDIO_ENCODING_SLINEAR:
-#endif
-               case AUDIO_ENCODING_SLINEAR_BE:
-                       switch (play->channels) {
-                       case 1:
-#if BYTE_ORDER == BIG_ENDIAN
-                               sc->sc_decodefunc = vraiu_slinear16_1;
-#else
-                               sc->sc_decodefunc = vraiu_slinear16sw_1;
-#endif
-                               break;
-                       case 2:
-#if BYTE_ORDER == BIG_ENDIAN
-                               sc->sc_decodefunc = vraiu_slinear16_2;
-#else
-                               sc->sc_decodefunc = vraiu_slinear16sw_2;
-#endif
-                               break;
-                       default:
-                               DPRINTFN(0, ("vraiu_set_params: channel error"
-                                            " (%d)\n", play->channels));
-                               return EINVAL;
-                       }
-                       break;



Home | Main Index | Thread Index | Old Index