Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/67a4b4ea78b0
branches:  isaki-audio2
changeset: 450964:67a4b4ea78b0
user:      isaki <isaki%NetBSD.org@localhost>
date:      Wed May 01 12:18:59 2019 +0000

description:
Adapt dbri to audio2.
- Add some mutex_enter/exit.
- Remove DBRI_BIG_BUFFER option.  Such big buffer will not necessary
  in audio2.
Thank you, macallan@.

diffstat:

 sys/arch/sparc/conf/GENERIC    |    5 +-
 sys/arch/sparc/conf/TADPOLE3GX |    3 +-
 sys/dev/sbus/dbri.c            |  262 ++++++----------------------------------
 sys/dev/sbus/dbrivar.h         |    5 +-
 sys/dev/sbus/files.sbus        |    4 +-
 5 files changed, 53 insertions(+), 226 deletions(-)

diffs (truncated from 489 to 300 lines):

diff -r ee27548fa3ad -r 67a4b4ea78b0 sys/arch/sparc/conf/GENERIC
--- a/sys/arch/sparc/conf/GENERIC       Wed May 01 09:41:50 2019 +0000
+++ b/sys/arch/sparc/conf/GENERIC       Wed May 01 12:18:59 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.265 2019/04/13 08:23:00 isaki Exp $
+# $NetBSD: GENERIC,v 1.265.2.1 2019/05/01 12:18:59 isaki Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.265 $"
+#ident                 "GENERIC-$Revision: 1.265.2.1 $"
 
 maxusers       32
 
@@ -609,7 +609,6 @@
 audiocs0       at sbus0 slot ? offset ?                # SUNW,CS4231
 
 #options       DBRI_DEBUG      # noisy debug output from the dbri driver
-#options       DBRI_BIG_BUFFER # use bigger DMA buffers, for slow CPUs
 dbri*          at sbus? slot ? offset ?                # SUNW,DBRI[s3|e]
 
 audio*         at audiobus?
diff -r ee27548fa3ad -r 67a4b4ea78b0 sys/arch/sparc/conf/TADPOLE3GX
--- a/sys/arch/sparc/conf/TADPOLE3GX    Wed May 01 09:41:50 2019 +0000
+++ b/sys/arch/sparc/conf/TADPOLE3GX    Wed May 01 12:18:59 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: TADPOLE3GX,v 1.77 2019/04/13 08:23:00 isaki Exp $
+#      $NetBSD: TADPOLE3GX,v 1.77.2.1 2019/05/01 12:18:59 isaki Exp $
 
 include "arch/sparc/conf/std.sparc"
 
@@ -317,7 +317,6 @@
 ## /dev/audio support
 
 #options       DBRI_DEBUG      # noisy debug output from the dbri driver
-options        DBRI_BIG_BUFFER # use bigger DMA buffers, for slow CPUs
 dbri0          at sbus0 slot ? offset ?                # SUNW,DBRI[s3|e]
 audio*         at audiobus?
 
diff -r ee27548fa3ad -r 67a4b4ea78b0 sys/dev/sbus/dbri.c
--- a/sys/dev/sbus/dbri.c       Wed May 01 09:41:50 2019 +0000
+++ b/sys/dev/sbus/dbri.c       Wed May 01 12:18:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dbri.c,v 1.39.2.1 2019/04/21 05:11:22 isaki Exp $      */
+/*     $NetBSD: dbri.c,v 1.39.2.2 2019/05/01 12:18:59 isaki Exp $      */
 
 /*
  * Copyright (C) 1997 Rudolf Koenig (rfkoenig%immd4.informatik.uni-erlangen.de@localhost)
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.39.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.39.2.2 2019/05/01 12:18:59 isaki Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -55,7 +55,6 @@
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
-#include <dev/auconv.h>
 
 #include <dev/ic/cs4215reg.h>
 #include <dev/ic/cs4215var.h>
@@ -132,9 +131,10 @@
 static int     pipe_active(struct dbri_softc *, int);
 
 /* audio(9) stuff */
-static int     dbri_query_encoding(void *, struct audio_encoding *);
-static int     dbri_set_params(void *, int, int, struct audio_params *,
-    struct audio_params *,stream_filter_list_t *, stream_filter_list_t *);
+static int     dbri_query_format(void *, audio_format_query_t *);
+static int     dbri_set_format(void *, int,
+    const audio_params_t *, const audio_params_t *,
+    audio_filter_reg_t *, audio_filter_reg_t *);
 static int     dbri_round_blocksize(void *, int, int, const audio_params_t *);
 static int     dbri_halt_output(void *);
 static int     dbri_halt_input(void *);
@@ -142,7 +142,6 @@
 static int     dbri_set_port(void *, mixer_ctrl_t *);
 static int     dbri_get_port(void *, mixer_ctrl_t *);
 static int     dbri_query_devinfo(void *, mixer_devinfo_t *);
-static size_t  dbri_round_buffersize(void *, int, size_t);
 static int     dbri_get_props(void *);
 static int     dbri_open(void *, int);
 static void    dbri_close(void *);
@@ -160,7 +159,6 @@
 
 static void    *dbri_malloc(void *, int, size_t);
 static void    dbri_free(void *, void *, size_t);
-static paddr_t dbri_mappage(void *, void *, off_t, int);
 static void    dbri_set_power(struct dbri_softc *, int);
 static void    dbri_bring_up(struct dbri_softc *);
 static bool    dbri_suspend(device_t, const pmf_qual_t *);
@@ -179,8 +177,8 @@
 struct audio_hw_if dbri_hw_if = {
        .open                   = dbri_open,
        .close                  = dbri_close,
-       .query_encoding         = dbri_query_encoding,
-       .set_params             = dbri_set_params,
+       .query_format           = dbri_query_format,
+       .set_format             = dbri_set_format,
        .round_blocksize        = dbri_round_blocksize,
        .halt_output            = dbri_halt_output,
        .halt_input             = dbri_halt_input,
@@ -190,8 +188,6 @@
        .query_devinfo          = dbri_query_devinfo,
        .allocm                 = dbri_malloc,
        .freem                  = dbri_free,
-       .round_buffersize       = dbri_round_buffersize,
-       .mappage                = dbri_mappage,
        .get_props              = dbri_get_props,
        .trigger_output         = dbri_trigger_output,
        .trigger_input          = dbri_trigger_input,
@@ -202,28 +198,19 @@
 CFATTACH_DECL_NEW(dbri, sizeof(struct dbri_softc),
     dbri_match_sbus, dbri_attach_sbus, NULL, NULL);
 
-#define DBRI_FORMAT(enc, prec, ch, chmask) \
-       { \
-               .mode           = AUMODE_PLAY | AUMODE_RECORD, \
-               .encoding       = (enc), \
-               .validbits      = (prec), \
-               .precision      = (prec), \
-               .channels       = (ch), \
-               .channel_mask   = (chmask), \
-               .frequency_type = 8, \
-               .frequency      = \
-                   { 8000, 9600, 11025, 16000, 22050, 32000, 44100, 48000 },\
-       }
+/* The HW actually supports more encodings/frequencies, but it's enough. */
 static const struct audio_format dbri_formats[] = {
-       DBRI_FORMAT(AUDIO_ENCODING_SLINEAR_BE, 16, 2, AUFMT_STEREO),
-/*
-       DBRI_FORMAT(AUDIO_ENCODING_ULAW,        8, 2, AUFMT_STEREO),
-       DBRI_FORMAT(AUDIO_ENCODING_ALAW,        8, 2, AUFMT_STEREO),
-       DBRI_FORMAT(AUDIO_ENCODING_ULINEAR,     8, 2, AUFMT_STEREO),
-*/
-       DBRI_FORMAT(AUDIO_ENCODING_ULAW,        8, 1, AUFMT_MONAURAL),
-       DBRI_FORMAT(AUDIO_ENCODING_ALAW,        8, 1, AUFMT_MONAURAL),
-       DBRI_FORMAT(AUDIO_ENCODING_ULINEAR,     8, 1, AUFMT_MONAURAL),
+       {
+               .mode           = AUMODE_PLAY | AUMODE_RECORD,
+               .encoding       = AUDIO_ENCODING_SLINEAR_BE,
+               .validbits      = 16,
+               .precision      = 16,
+               .channels       = 2,
+               .channel_mask   = AUFMT_STEREO,
+               .frequency_type = 8,
+               .frequency      =
+                   { 8000, 9600, 11025, 16000, 22050, 32000, 44100, 48000 },
+       },
 };
 #define DBRI_NFORMATS  __arraycount(dbri_formats)
 
@@ -306,6 +293,7 @@
        for (i = 0; i < DBRI_NUM_DESCRIPTORS; i++) {
                sc->sc_desc[i].softint = softint_establish(SOFTINT_SERIAL,
                    dbri_softint, &sc->sc_desc[i]);
+               sc->sc_desc[i].sc = sc;
        }
 
        if (sa->sa_npromvaddrs)
@@ -534,9 +522,12 @@
 dbri_softint(void *cookie)
 {
        struct dbri_desc *dd = cookie;
+       struct dbri_softc *sc = dd->sc;
 
+       mutex_spin_enter(&sc->sc_intr_lock);
        if (dd->callback != NULL)
                dd->callback(dd->callback_args);
+       mutex_spin_exit(&sc->sc_intr_lock);
 }
 
 static int
@@ -1600,135 +1591,28 @@
  */
 
 static int
-dbri_query_encoding(void *hdl, struct audio_encoding *ae)
+dbri_query_format(void *hdl, audio_format_query_t *afp)
 {
 
-       switch (ae->index) {
-       case 0:
-               strcpy(ae->name, AudioEulinear);
-               ae->encoding = AUDIO_ENCODING_ULINEAR;
-               ae->precision = 8;
-               ae->flags = 0;
-               break;
-       case 1:
-               strcpy(ae->name, AudioEmulaw);
-               ae->encoding = AUDIO_ENCODING_ULAW;
-               ae->precision = 8;
-               ae->flags = 0;
-               break;
-       case 2:
-               strcpy(ae->name, AudioEalaw);
-               ae->encoding = AUDIO_ENCODING_ALAW;
-               ae->precision = 8;
-               ae->flags = 0;
-               break;
-       case 3:
-               strcpy(ae->name, AudioEslinear);
-               ae->encoding = AUDIO_ENCODING_SLINEAR;
-               ae->precision = 8;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 4:
-               strcpy(ae->name, AudioEslinear_le);
-               ae->encoding = AUDIO_ENCODING_SLINEAR_LE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 5:
-               strcpy(ae->name, AudioEulinear_le);
-               ae->encoding = AUDIO_ENCODING_ULINEAR_LE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 6:
-               strcpy(ae->name, AudioEslinear_be);
-               ae->encoding = AUDIO_ENCODING_SLINEAR_BE;
-               ae->precision = 16;
-               ae->flags = 0;
-               break;
-       case 7:
-               strcpy(ae->name, AudioEulinear_be);
-               ae->encoding = AUDIO_ENCODING_ULINEAR_BE;
-               ae->precision = 16;
-               ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-       case 8:
-               strcpy(ae->name, AudioEslinear);
-               ae->encoding = AUDIO_ENCODING_SLINEAR;
-               ae->precision = 16;
-               ae->flags = 0;
-               break;
-       default:
-               return (EINVAL);
-       }
-
-       return (0);
+       return audio_query_format(dbri_formats, DBRI_NFORMATS, afp);
 }
 
 static int
-dbri_set_params(void *hdl, int setmode, int usemode,
-               struct audio_params *play, struct audio_params *rec,
-               stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+dbri_set_format(void *hdl, int setmode,
+               const audio_params_t *play, const audio_params_t *rec,
+               audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
        struct dbri_softc *sc = hdl;
        int rate;
-       audio_params_t *p = NULL;
-       stream_filter_list_t *fil;
-       int mode;
 
-       /*
-        * This device only has one clock, so make the sample rates match.
-        */
-       if (play->sample_rate != rec->sample_rate &&
-           usemode == (AUMODE_PLAY | AUMODE_RECORD)) {
-               if (setmode == AUMODE_PLAY) {
-                       rec->sample_rate = play->sample_rate;
-                       setmode |= AUMODE_RECORD;
-               } else if (setmode == AUMODE_RECORD) {
-                       play->sample_rate = rec->sample_rate;
-                       setmode |= AUMODE_PLAY;
-               } else
-                       return EINVAL;
-       }
-
-       for (mode = AUMODE_RECORD; mode != -1;
-            mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
-               if ((setmode & mode) == 0)
-                       continue;
-
-               p = mode == AUMODE_PLAY ? play : rec;
-               if (p->sample_rate < 4000 || p->sample_rate > 50000) {
-                       DPRINTF("dbri_set_params: invalid rate %d\n", 
-                           p->sample_rate);
-                       return EINVAL;
-               }
-
-               fil = mode == AUMODE_PLAY ? pfil : rfil;
-       DPRINTF("requested enc: %d rate: %d prec: %d chan: %d\n", p->encoding,
-           p->sample_rate, p->precision, p->channels); 
-               if (auconv_set_converter(dbri_formats, DBRI_NFORMATS,
-                                        mode, p, true, fil) < 0) {
-                       aprint_debug("dbri_set_params: auconv_set_converter failed\n");
-                       return EINVAL;



Home | Main Index | Thread Index | Old Index