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/37d4c899da33
branches: isaki-audio2
changeset: 998500:37d4c899da33
user: isaki <isaki%NetBSD.org@localhost>
date: Sat Apr 27 13:10:03 2019 +0000
description:
Adapt to audio2.
- Move auixp_formats' definition from header to source.
- Make compilable even with DEBUG_AUIXP.
diffstat:
sys/dev/pci/auixp.c | 120 +++++++++++++++---------------------------------
sys/dev/pci/auixpvar.h | 26 +---------
2 files changed, 41 insertions(+), 105 deletions(-)
diffs (290 lines):
diff -r 68ac61ed51d2 -r 37d4c899da33 sys/dev/pci/auixp.c
--- a/sys/dev/pci/auixp.c Sat Apr 27 12:57:54 2019 +0000
+++ b/sys/dev/pci/auixp.c Sat Apr 27 13:10:03 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auixp.c,v 1.45 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: auixp.c,v 1.45.2.1 2019/04/27 13:10:03 isaki Exp $ */
/*
* Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auixp.c,v 1.45 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auixp.c,v 1.45.2.1 2019/04/27 13:10:03 isaki Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -68,8 +68,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>
@@ -119,6 +117,25 @@
"auixp"
};
+/*
+ * current AC'97 driver only supports SPDIF outputting channel 3&4 i.e. STEREO
+ */
+#define AUIXP_FORMAT(aumode, ch, chmask) \
+ { \
+ .mode = (aumode), \
+ .encoding = AUDIO_ENCODING_SLINEAR_LE, \
+ .validbits = 16, \
+ .precision = 16, \
+ .channels = (ch), \
+ .channel_mask = (chmask), \
+ .frequency_type = 0, \
+ .frequency = { 7000, 48000 }, \
+ }
+static const struct audio_format auixp_formats[AUIXP_NFORMATS] = {
+ AUIXP_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 2, AUFMT_STEREO),
+ AUIXP_FORMAT(AUMODE_PLAY , 4, AUFMT_SURROUND4),
+ AUIXP_FORMAT(AUMODE_PLAY , 6, AUFMT_DOLBY_5_1),
+};
/* codec detection constant indicating the interrupt flags */
#define ALL_CODECS_NOT_READY \
@@ -135,10 +152,10 @@
/* audio(9) function prototypes */
-static int auixp_query_encoding(void *, struct audio_encoding *);
-static int auixp_set_params(void *, int, int, audio_params_t *,
- audio_params_t *,
- stream_filter_list_t *, stream_filter_list_t *);
+static int auixp_query_format(void *, audio_format_query_t *);
+static int auixp_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
static int auixp_commit_settings(void *);
static int auixp_round_blocksize(void *, int, int, const audio_params_t *);
static int auixp_trigger_output(void *, void *, void *, int,
@@ -161,7 +178,6 @@
static int auixp_allocmem(struct auixp_softc *, size_t, size_t,
struct auixp_dma *);
static int auixp_freemem(struct auixp_softc *, struct auixp_dma *);
-static paddr_t auixp_mappage(void *, void *, off_t, int);
/* Supporting subroutines */
static int auixp_init(struct auixp_softc *);
@@ -199,7 +215,7 @@
#ifdef DEBUG_AUIXP
static struct auixp_softc *static_sc;
-static void auixp_dumpreg(void);
+static void auixp_dumpreg(void) __unused;
# define DPRINTF(x) printf x;
#else
# define DPRINTF(x)
@@ -207,8 +223,8 @@
static const struct audio_hw_if auixp_hw_if = {
- .query_encoding = auixp_query_encoding,
- .set_params = auixp_set_params,
+ .query_format = auixp_query_format,
+ .set_format = auixp_set_format,
.round_blocksize = auixp_round_blocksize,
.commit_settings = auixp_commit_settings,
.halt_output = auixp_halt_output,
@@ -220,7 +236,6 @@
.allocm = auixp_malloc,
.freem = auixp_free,
.round_buffersize = auixp_round_buffersize,
- .mappage = auixp_mappage,
.get_props = auixp_get_props,
.trigger_output = auixp_trigger_output,
.trigger_input = auixp_trigger_input,
@@ -237,14 +252,14 @@
*/
static int
-auixp_query_encoding(void *hdl, struct audio_encoding *ae)
+auixp_query_format(void *hdl, audio_format_query_t *afp)
{
struct auixp_codec *co;
struct auixp_softc *sc;
co = (struct auixp_codec *) hdl;
sc = co->sc;
- return auconv_query_encoding(sc->sc_encodings, ae);
+ return audio_query_format(sc->sc_formats, AUIXP_NFORMATS, afp);
}
@@ -365,14 +380,13 @@
/* set audio properties in desired setting */
static int
-auixp_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)
+auixp_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 auixp_codec *co;
struct auixp_softc *sc;
- audio_params_t *params;
- stream_filter_list_t *fil;
+ const audio_params_t *params;
int mode, index;
/*
@@ -387,27 +401,12 @@
if ((setmode & mode) == 0)
continue;
- params = (mode == AUMODE_PLAY) ? play : rec;
- fil = (mode == AUMODE_PLAY) ? pfil : rfil;
+ params = (mode == AUMODE_PLAY) ? play : rec;
if (params == NULL)
continue;
- /* AD1888 settings ... don't know the IXP limits */
- if (params->sample_rate < AUIXP_MINRATE)
- return EINVAL;
- if (params->sample_rate > AUIXP_MAXRATE)
- return EINVAL;
-
- index = auconv_set_converter(sc->sc_formats, AUIXP_NFORMATS,
- mode, params, TRUE, fil);
-
- /* nothing found? */
- if (index < 0)
- return EINVAL;
-
- /* not sure yet as to why i have to change params here */
- if (fil->req_size > 0)
- params = &fil->filters[0].param;
+ index = audio_indexof_format(sc->sc_formats, AUIXP_NFORMATS,
+ mode, params);
/* if variable speed and we can't set the desired rate, fail */
if ((sc->sc_formats[index].frequency_type != 1) &&
@@ -471,7 +470,7 @@
}
SLIST_INSERT_HEAD(&sc->sc_dma_list, dma, dma_chain);
- DPRINTF(("auixp_malloc: returning kern %p, hw 0x%08x for %d bytes "
+ DPRINTF(("auixp_malloc: returning kern %p, hw 0x%08x for %zd bytes "
"in %d segs\n", KERNADDR(dma), (uint32_t) DMAADDR(dma), dma->size,
dma->nsegs)
);
@@ -1019,36 +1018,6 @@
}
-/* memory map dma memory */
-static paddr_t
-auixp_mappage(void *hdl, void *mem, off_t off, int prot)
-{
- struct auixp_codec *co;
- struct auixp_softc *sc;
- struct auixp_dma *p;
-
- co = (struct auixp_codec *) hdl;
- sc = co->sc;
- /* for sanity */
- if (off < 0)
- return -1;
-
- /* look up allocated DMA area */
- SLIST_FOREACH(p, &sc->sc_dma_list, dma_chain) {
- if (KERNADDR(p) == mem)
- break;
- }
-
- /* have we found it ? */
- if (!p)
- return -1;
-
- /* return mmap'd region */
- return bus_dmamem_mmap(sc->sc_dmat, p->segs, p->nsegs,
- off, prot, BUS_DMA_WAITOK);
-}
-
-
/*
* Attachment section
*/
@@ -1199,7 +1168,7 @@
struct auixp_softc *sc;
struct auixp_codec *codec;
int codec_nr;
- int res, i;
+ int i;
sc = device_private(self);
/* detect the AC97 codecs */
@@ -1245,17 +1214,6 @@
}
}
- /*
- * Create all encodings (and/or -translations) based on the formats
- * supported. */
- res = auconv_create_encodings(sc->sc_formats, AUIXP_NFORMATS,
- &sc->sc_encodings);
- if (res) {
- printf("%s: auconv_create_encodings failed; "
- "no attachments\n", device_xname(sc->sc_dev));
- return;
- }
-
if (sc->has_spdif) {
aprint_normal_dev(sc->sc_dev, "codec spdif support detected but disabled "
"for now\n");
diff -r 68ac61ed51d2 -r 37d4c899da33 sys/dev/pci/auixpvar.h
--- a/sys/dev/pci/auixpvar.h Sat Apr 27 12:57:54 2019 +0000
+++ b/sys/dev/pci/auixpvar.h Sat Apr 27 13:10:03 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auixpvar.h,v 1.8.42.1 2019/04/21 05:11:22 isaki Exp $*/
+/* $NetBSD: auixpvar.h,v 1.8.42.2 2019/04/27 13:10:03 isaki Exp $*/
/*
* Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -42,35 +42,13 @@
/* audio format structure describing our hardware capabilities */
/* XXX min and max sample rates are for AD1888 codec XXX */
-#define AUIXP_NFORMATS 6
+#define AUIXP_NFORMATS 3
#define AUIXP_MINRATE 7000
#define AUIXP_MAXRATE 48000
-/* current AC'97 driver only supports SPDIF outputting channel 3&4 i.e. STEREO */
-#define AUIXP_FORMAT(aumode, prec, ch, chmask) \
- { \
- .mode = (aumode), \
- .encoding = AUDIO_ENCODING_SLINEAR_LE, \
- .validbits = (prec), \
- .precision = (prec), \
- .channels = (ch), \
- .channel_mask = (chmask), \
- .frequency_type = 0, \
- .frequency = { 7000, 48000 }, \
- }
-static const struct audio_format auixp_formats[AUIXP_NFORMATS] = {
- AUIXP_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 16, 2, AUFMT_STEREO),
- AUIXP_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 32, 2, AUFMT_STEREO),
- AUIXP_FORMAT(AUMODE_PLAY , 16, 4, AUFMT_SURROUND4),
- AUIXP_FORMAT(AUMODE_PLAY , 32, 4, AUFMT_SURROUND4),
- AUIXP_FORMAT(AUMODE_PLAY , 16, 6, AUFMT_DOLBY_5_1),
- AUIXP_FORMAT(AUMODE_PLAY , 32, 6, AUFMT_DOLBY_5_1),
-};
-
-
/* auixp structures; used to record alloced DMA space */
struct auixp_dma {
/* bus mappings */
Home |
Main Index |
Thread Index |
Old Index