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/90eac3bf523b
branches:  isaki-audio2
changeset: 450886:90eac3bf523b
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Apr 28 03:33:26 2019 +0000

description:
Adapt to audio2.
- Recording seems a bit tricky so I left it untouched.
  (It should work on audio2 as well if it works on -current/-8.)

diffstat:

 sys/dev/pci/esm.c    |  117 +++++++++-----------------------------------------
 sys/dev/pci/esmvar.h |   10 ++--
 2 files changed, 26 insertions(+), 101 deletions(-)

diffs (226 lines):

diff -r 553cb31ee753 -r 90eac3bf523b sys/dev/pci/esm.c
--- a/sys/dev/pci/esm.c Sun Apr 28 03:00:21 2019 +0000
+++ b/sys/dev/pci/esm.c Sun Apr 28 03:33:26 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: esm.c,v 1.61.2.1 2019/04/21 05:11:22 isaki Exp $      */
+/*      $NetBSD: esm.c,v 1.61.2.2 2019/04/28 03:33:26 isaki Exp $      */
 
 /*-
  * Copyright (c) 2002, 2003 Matt Fredette
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.61.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.61.2.2 2019/04/28 03:33:26 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,8 +77,6 @@
 #include <sys/audioio.h>
 
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
 
 #include <dev/ic/ac97var.h>
 #include <dev/ic/ac97reg.h>
@@ -160,8 +158,8 @@
     esm_match, esm_attach, esm_detach, NULL, NULL, esm_childdet);
 
 const struct audio_hw_if esm_hw_if = {
-       .query_encoding         = esm_query_encoding,
-       .set_params             = esm_set_params,
+       .query_format           = esm_query_format,
+       .set_format             = esm_set_format,
        .round_blocksize        = esm_round_blocksize,
        .init_output            = esm_init_output,
        .init_input             = esm_init_input,
@@ -174,7 +172,6 @@
        .allocm                 = esm_malloc,
        .freem                  = esm_free,
        .round_buffersize       = esm_round_buffersize,
-       .mappage                = esm_mappage,
        .get_props              = esm_get_props,
        .trigger_output         = esm_trigger_output,
        .trigger_input          = esm_trigger_input,
@@ -187,23 +184,6 @@
        "esm"
 };
 
-#define MAESTRO_NENCODINGS 8
-static audio_encoding_t esm_encoding[MAESTRO_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, 0 },
-       { 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 },
-};
-
-#define ESM_NFORMATS   4
 #define ESM_FORMAT(enc, prec, ch, chmask) \
        { \
                .mode           = AUMODE_PLAY | AUMODE_RECORD, \
@@ -215,12 +195,17 @@
                .frequency_type = 0, \
                .frequency      = { 4000, 48000 }, \
        }
-static const struct audio_format esm_formats[ESM_NFORMATS] = {
+/*
+ * XXX Recodring on 16bit/stereo seems a bit tricky so I left all
+ * combination 8/16bit and mono/stereo.
+ */
+static const struct audio_format esm_formats[] = {
        ESM_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
        ESM_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
        ESM_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
        ESM_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
 };
+#define ESM_NFORMATS   __arraycount(esm_formats)
 
 static const struct esm_quirks esm_quirks[] = {
        /* COMPAL 38W2 OEM Notebook, e.g. Dell INSPIRON 5000e */
@@ -1208,66 +1193,28 @@
 }
 
 int
-esm_query_encoding(void *sc, struct audio_encoding *fp)
+esm_query_format(void *sc, audio_format_query_t *afp)
 {
 
-       DPRINTF(ESM_DEBUG_PARAM,
-           ("esm_query_encoding(%p, %d)\n", sc, fp->index));
-
-       if (fp->index < 0 || fp->index >= MAESTRO_NENCODINGS)
-               return EINVAL;
-
-       *fp = esm_encoding[fp->index];
-       return 0;
+       return audio_query_format(esm_formats, ESM_NFORMATS, afp);
 }
 
 int
-esm_set_params(void *sc, int setmode, int usemode,
-       audio_params_t *play, audio_params_t *rec,
-       stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+esm_set_format(void *sc, int setmode,
+       const audio_params_t *play, const audio_params_t *rec,
+       audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
        struct esm_softc *ess;
-       audio_params_t *p;
-       const audio_params_t *hw_play, *hw_rec;
-       stream_filter_list_t *fil;
-       int mode, i;
 
        DPRINTF(ESM_DEBUG_PARAM,
-           ("esm_set_params(%p, 0x%x, 0x%x, %p, %p)\n",
-           sc, setmode, usemode, play, rec));
+           ("%s(%p, 0x%x, %p, %p)\n", __func__,
+           sc, setmode, play, rec));
        ess = sc;
-       hw_play = NULL;
-       hw_rec = NULL;
-       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 > 48000 ||
-                   (p->precision != 8 && p->precision != 16) ||
-                   (p->channels != 1 && p->channels != 2))
-                       return EINVAL;
 
-               fil = mode == AUMODE_PLAY ? pfil : rfil;
-               i = auconv_set_converter(esm_formats, ESM_NFORMATS,
-                                        mode, p, FALSE, fil);
-               if (i < 0)
-                       return EINVAL;
-               if (fil->req_size > 0)
-                       p = &fil->filters[0].param;
-               if (mode == AUMODE_PLAY)
-                       hw_play = p;
-               else
-                       hw_rec = p;
-       }
-
-       if (hw_play)
-               esmch_set_format(&ess->pch, hw_play);
-
-       if (hw_rec)
-               esmch_set_format(&ess->rch, hw_rec);
+       if ((setmode & AUMODE_PLAY))
+               esmch_set_format(&ess->pch, play);
+       if ((setmode & AUMODE_RECORD))
+               esmch_set_format(&ess->rch, rec);
 
        return 0;
 }
@@ -1353,28 +1300,6 @@
        return size;
 }
 
-paddr_t
-esm_mappage(void *sc, void *mem, off_t off, int prot)
-{
-       struct esm_softc *ess;
-
-       DPRINTF(ESM_DEBUG_DMA,
-           ("esm_mappage(%p, %p, 0x%lx, 0x%x)\n",
-           sc, mem, (unsigned long)off, prot));
-       ess = sc;
-       if (off < 0)
-               return -1;
-
-       if ((char *)mem == (char *)ess->sc_dma.addr + MAESTRO_PLAYBUF_OFF)
-               off += MAESTRO_PLAYBUF_OFF;
-       else if ((char *)mem == (char *)ess->sc_dma.addr + MAESTRO_RECBUF_OFF)
-               off += MAESTRO_RECBUF_OFF;
-       else
-               return -1;
-       return bus_dmamem_mmap(ess->dmat, ess->sc_dma.segs, ess->sc_dma.nsegs,
-           off, prot, BUS_DMA_WAITOK);
-}
-
 int
 esm_get_props(void *sc)
 {
diff -r 553cb31ee753 -r 90eac3bf523b sys/dev/pci/esmvar.h
--- a/sys/dev/pci/esmvar.h      Sun Apr 28 03:00:21 2019 +0000
+++ b/sys/dev/pci/esmvar.h      Sun Apr 28 03:33:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: esmvar.h,v 1.18 2011/11/23 23:07:35 jmcneill Exp $     */
+/*     $NetBSD: esmvar.h,v 1.18.54.1 2019/04/28 03:33:26 isaki Exp $   */
 
 /*-
  * Copyright (c) 2002, 2003 Matt Fredette
@@ -214,16 +214,16 @@
 int    esm_halt_input(void *);
 int    esm_getdev(void *, struct audio_device *);
 int    esm_round_blocksize(void *, int, int, const audio_params_t *);
-int    esm_query_encoding(void *, struct audio_encoding *);
-int    esm_set_params(void *, int, int, audio_params_t *, audio_params_t *,
-           stream_filter_list_t *, stream_filter_list_t *);
+int    esm_query_format(void *, audio_format_query_t *);
+int    esm_set_format(void *, int,
+           const audio_params_t *, const audio_params_t *,
+           audio_filter_reg_t *, audio_filter_reg_t *);
 int    esm_set_port(void *, mixer_ctrl_t *);
 int    esm_get_port(void *, mixer_ctrl_t *);
 int    esm_query_devinfo(void *, mixer_devinfo_t *);
 void   *esm_malloc(void *, int, size_t);
 void   esm_free(void *, void *, size_t);
 size_t esm_round_buffersize(void *, int, size_t);
-paddr_t        esm_mappage(void *, void *, off_t, int);
 int    esm_get_props(void *);
 void   esm_get_locks(void *, kmutex_t **, kmutex_t **);
 



Home | Main Index | Thread Index | Old Index