Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/553cb31ee753
branches:  isaki-audio2
changeset: 450885:553cb31ee753
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Apr 28 03:00:21 2019 +0000

description:
Adapt to audio2.
- Fix wrong round_blocksize() calculation. ~0x20 -> -0x20.

diffstat:

 sys/dev/pci/esa.c |  133 ++++++++++++-----------------------------------------
 1 files changed, 32 insertions(+), 101 deletions(-)

diffs (215 lines):

diff -r de692c3db2d4 -r 553cb31ee753 sys/dev/pci/esa.c
--- a/sys/dev/pci/esa.c Sun Apr 28 02:15:32 2019 +0000
+++ b/sys/dev/pci/esa.c Sun Apr 28 03:00:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: esa.c,v 1.63.2.1 2019/04/21 05:11:22 isaki Exp $ */
+/* $NetBSD: esa.c,v 1.63.2.2 2019/04/28 03:00:21 isaki Exp $ */
 
 /*
  * Copyright (c) 2001-2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.63.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.63.2.2 2019/04/28 03:00:21 isaki Exp $");
 
 #include <sys/types.h>
 #include <sys/errno.h>
@@ -56,8 +56,6 @@
 #include <sys/intr.h>
 
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
 
 #include <dev/ic/ac97var.h>
 #include <dev/ic/ac97reg.h>
@@ -104,10 +102,12 @@
 static void            esa_childdet(device_t, device_t);
 
 /* audio(9) functions */
-static int             esa_query_encoding(void *, struct audio_encoding *);
-static int             esa_set_params(void *, int, int, audio_params_t *,
-                                      audio_params_t *, stream_filter_list_t *,
-                                      stream_filter_list_t *);
+static int             esa_query_format(void *, audio_format_query_t *);
+static int             esa_set_format(void *, int,
+                                      const audio_params_t *,
+                                      const audio_params_t *,
+                                      audio_filter_reg_t *,
+                                      audio_filter_reg_t *);
 static int             esa_round_blocksize(void *, int, int,
                                            const audio_params_t *);
 static int             esa_commit_settings(void *);
@@ -119,7 +119,6 @@
 static void *          esa_malloc(void *, int, size_t);
 static void            esa_free(void *, void *, size_t);
 static int             esa_getdev(void *, struct audio_device *);
-static size_t          esa_round_buffersize(void *, int, size_t);
 static int             esa_get_props(void *);
 static int             esa_trigger_output(void *, void *, void *, int,
                                           void (*)(void *), void *,
@@ -166,45 +165,23 @@
 static bool            esa_resume(device_t, const pmf_qual_t *);
 
 
-#define ESA_NENCODINGS 8
-static audio_encoding_t esa_encoding[ESA_NENCODINGS] = {
-       { 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0 },
-       { 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8,
-               AUDIO_ENCODINGFLAG_EMULATED },
-       { 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, AUDIO_ENCODINGFLAG_EMULATED },
-       { 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8,
-               AUDIO_ENCODINGFLAG_EMULATED }, /* XXX: Are you sure? */
-       { 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0 },
-       { 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16,
-               AUDIO_ENCODINGFLAG_EMULATED },
-       { 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16,
-               AUDIO_ENCODINGFLAG_EMULATED },
-       { 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16,
-               AUDIO_ENCODINGFLAG_EMULATED }
+static const struct audio_format esa_formats[] = {
+       {
+               .mode           = AUMODE_PLAY | AUMODE_RECORD,
+               .encoding       = AUDIO_ENCODING_SLINEAR_LE,
+               .validbits      = 16,
+               .precision      = 16,
+               .channels       = 2,
+               .channel_mask   = AUFMT_STEREO,
+               .frequency_type = 0,
+               .frequency      = { ESA_MINRATE, ESA_MAXRATE },
+       },
 };
-
-#define ESA_NFORMATS   4
-#define ESA_FORMAT(enc, prec, ch, chmask) \
-       { \
-               .mode           = AUMODE_PLAY | AUMODE_RECORD, \
-               .encoding       = (enc), \
-               .validbits      = (prec), \
-               .precision      = (prec), \
-               .channels       = (ch), \
-               .channel_mask   = (chmask), \
-               .frequency_type = 0, \
-               .frequency      = { ESA_MINRATE, ESA_MAXRATE }, \
-       }
-static const struct audio_format esa_formats[ESA_NFORMATS] = {
-       ESA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-       ESA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-       ESA_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-       ESA_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
-};
+#define ESA_NFORMATS   __arraycount(esa_formats)
 
 static const struct audio_hw_if esa_hw_if = {
-       .query_encoding         = esa_query_encoding,
-       .set_params             = esa_set_params,
+       .query_format           = esa_query_format,
+       .set_format             = esa_set_format,
        .round_blocksize        = esa_round_blocksize,
        .commit_settings        = esa_commit_settings,
        .halt_output            = esa_halt_output,
@@ -215,7 +192,6 @@
        .query_devinfo          = esa_query_devinfo,
        .allocm                 = esa_malloc,
        .freem                  = esa_free,
-       .round_buffersize       = esa_round_buffersize,
        .mappage                = esa_mappage,
        .get_props              = esa_get_props,
        .trigger_output         = esa_trigger_output,
@@ -231,62 +207,24 @@
  */
 
 static int
-esa_query_encoding(void *hdl, struct audio_encoding *ae)
+esa_query_format(void *hdl, audio_format_query_t *afp)
 {
 
-       if (ae->index < 0 || ae->index >= ESA_NENCODINGS)
-               return EINVAL;
-       *ae = esa_encoding[ae->index];
-
-       return 0;
+       return audio_query_format(esa_formats, ESA_NFORMATS, afp);
 }
 
 static int
-esa_set_params(void *hdl, int setmode, int usemode,
-    audio_params_t *play, audio_params_t *rec, stream_filter_list_t *pfil,
-    stream_filter_list_t *rfil)
+esa_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 esa_voice *vc;
-       struct esa_channel *ch;
-       struct audio_params *p;
-       stream_filter_list_t *fil;
-       int mode, i;
 
        vc = hdl;
-       for (mode = AUMODE_RECORD; mode != -1;
-            mode = (mode == AUMODE_RECORD) ? AUMODE_PLAY : -1) {
-               if ((setmode & mode) == 0)
-                       continue;
-
-               switch (mode) {
-               case AUMODE_PLAY:
-                       p = play;
-                       ch = &vc->play;
-                       fil = pfil;
-                       break;
-               case AUMODE_RECORD:
-                       p = rec;
-                       ch = &vc->rec;
-                       fil = rfil;
-                       break;
-               default:
-                       return EINVAL;
-               }
-
-               if (p->sample_rate < ESA_MINRATE ||
-                   p->sample_rate > ESA_MAXRATE ||
-                   (p->precision != 8 && p->precision != 16) ||
-                   (p->channels < 1 || p->channels > 2))
-                       return EINVAL;
-
-               i = auconv_set_converter(esa_formats, ESA_NFORMATS,
-                                        mode, p, FALSE, fil);
-               if (i < 0)
-                       return EINVAL;
-               if (fil->req_size > 0)
-                       p = &fil->filters[0].param;
-               ch->mode = *p;
-       }
+       if ((setmode & AUMODE_PLAY))
+               vc->play.mode = *play;
+       if ((setmode & AUMODE_RECORD))
+               vc->rec.mode = *rec;
 
        return 0;
 }
@@ -363,7 +301,7 @@
     const audio_params_t *param)
 {
 
-       return bs & ~0x20;      /* Be conservative; align to 32 bytes */
+       return bs & -0x20;      /* Be conservative; align to 32 bytes */
 }
 
 static int
@@ -535,13 +473,6 @@
        return sc->codec_if->vtbl->query_devinfo(sc->codec_if, di);
 }
 
-static size_t
-esa_round_buffersize(void *hdl, int direction, size_t bufsize)
-{
-
-       return bufsize;
-}
-
 static int
 esa_get_props(void *hdl)
 {



Home | Main Index | Thread Index | Old Index