Module Name:    src
Committed By:   isaki
Date:           Wed Apr 24 13:03:07 UTC 2019

Modified Files:
        src/sys/arch/arm/xscale [isaki-audio2]: pxa2x0_i2s.c pxa2x0_i2s.h
        src/sys/arch/zaurus/dev [isaki-audio2]: wm8731_zaudio.c wm8750_zaudio.c
            zaudio.c zaudiovar.h

Log Message:
Adapt zaudio family to audio2.
- wm8731 and wm8750 can share zaudio_formats[].
- Drop INDEPENDENT property.  These share sample rate in play and rec.
- pxa2x0_i2s_setspeed() no longer needs to writeback sample rate.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.12.1 src/sys/arch/arm/xscale/pxa2x0_i2s.c
cvs rdiff -u -r1.5 -r1.5.40.1 src/sys/arch/arm/xscale/pxa2x0_i2s.h
cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/arch/zaurus/dev/wm8731_zaudio.c
cvs rdiff -u -r1.2.4.1 -r1.2.4.2 src/sys/arch/zaurus/dev/wm8750_zaudio.c
cvs rdiff -u -r1.21 -r1.21.22.1 src/sys/arch/zaurus/dev/zaudio.c
cvs rdiff -u -r1.2 -r1.2.22.1 src/sys/arch/zaurus/dev/zaudiovar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xscale/pxa2x0_i2s.c
diff -u src/sys/arch/arm/xscale/pxa2x0_i2s.c:1.12 src/sys/arch/arm/xscale/pxa2x0_i2s.c:1.12.12.1
--- src/sys/arch/arm/xscale/pxa2x0_i2s.c:1.12	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/arm/xscale/pxa2x0_i2s.c	Wed Apr 24 13:03:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pxa2x0_i2s.c,v 1.12 2017/06/01 02:45:06 chs Exp $	*/
+/*	$NetBSD: pxa2x0_i2s.c,v 1.12.12.1 2019/04/24 13:03:06 isaki Exp $	*/
 /*	$OpenBSD: pxa2x0_i2s.c,v 1.7 2006/04/04 11:45:40 pascoe Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pxa2x0_i2s.c,v 1.12 2017/06/01 02:45:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pxa2x0_i2s.c,v 1.12.12.1 2019/04/24 13:03:06 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -140,11 +140,10 @@ pxa2x0_i2s_write(struct pxa2x0_i2s_softc
 }
 
 void
-pxa2x0_i2s_setspeed(struct pxa2x0_i2s_softc *sc, u_int *argp)
+pxa2x0_i2s_setspeed(struct pxa2x0_i2s_softc *sc, u_int arg)
 {
 	/*
 	 * The available speeds are in the following table.
-	 * Keep the speeds in increasing order.
 	 */
 	static const struct speed_struct {
 		int	speed;
@@ -158,7 +157,6 @@ pxa2x0_i2s_setspeed(struct pxa2x0_i2s_so
 		{48000,	SADIV_3_058MHz},
 	};
 	const int n = (int)__arraycount(speed_table);
-	u_int arg = (u_int)*argp;
 	int selected = -1;
 	int i;
 
@@ -167,25 +165,11 @@ pxa2x0_i2s_setspeed(struct pxa2x0_i2s_so
 	if (arg > speed_table[n - 1].speed)
 		selected = n - 1;
 
-	for (i = 1; selected == -1 && i < n; i++) {
+	for (i = 0; selected == -1 && i < n; i++) {
 		if (speed_table[i].speed == arg)
 			selected = i;
-		else if (speed_table[i].speed > arg) {
-			int diff1, diff2;
-
-			diff1 = arg - speed_table[i - 1].speed;
-			diff2 = speed_table[i].speed - arg;
-			if (diff1 < diff2)
-				selected = i - 1;
-			else
-				selected = i;
-		}
 	}
-
-	if (selected == -1)
-		selected = 0;
-
-	*argp = speed_table[selected].speed;
+	KASSERT(selected != -1);
 
 	sc->sc_sadiv = speed_table[selected].div;
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, I2S_SADIV, sc->sc_sadiv);
@@ -275,27 +259,6 @@ pxa2x0_i2s_freem(void *hdl, void *ptr, s
 	panic("pxa2x0_i2s_freem: trying to free unallocated memory");
 }
 
-paddr_t
-pxa2x0_i2s_mappage(void *hdl, void *mem, off_t off, int prot)
-{
-	struct pxa2x0_i2s_softc *sc = hdl;
-	struct pxa2x0_i2s_dma *p;
-
-	if (off < 0)
-		return -1;
-
-	for (p = sc->sc_dmas; p && p->addr != mem; p = p->next)
-		continue;
-	if (p == NULL)
-		return -1;
-
-	if (off > p->size)
-		return -1;
-
-	return bus_dmamem_mmap(sc->sc_dmat, p->segs, p->nsegs, off, prot,
-	    BUS_DMA_WAITOK);
-}
-
 int
 pxa2x0_i2s_round_blocksize(void *hdl, int bs, int mode,
     const struct audio_params *param)

Index: src/sys/arch/arm/xscale/pxa2x0_i2s.h
diff -u src/sys/arch/arm/xscale/pxa2x0_i2s.h:1.5 src/sys/arch/arm/xscale/pxa2x0_i2s.h:1.5.40.1
--- src/sys/arch/arm/xscale/pxa2x0_i2s.h:1.5	Mon Nov 12 18:00:38 2012
+++ src/sys/arch/arm/xscale/pxa2x0_i2s.h	Wed Apr 24 13:03:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pxa2x0_i2s.h,v 1.5 2012/11/12 18:00:38 skrll Exp $	*/
+/*	$NetBSD: pxa2x0_i2s.h,v 1.5.40.1 2019/04/24 13:03:06 isaki Exp $	*/
 /*	$OpenBSD: pxa2x0_i2s.h,v 1.3 2006/04/04 11:45:40 pascoe Exp $	*/
 
 /*
@@ -59,11 +59,10 @@ void	pxa2x0_i2s_open(struct pxa2x0_i2s_s
 void	pxa2x0_i2s_close(struct pxa2x0_i2s_softc *);
 void	pxa2x0_i2s_write(struct pxa2x0_i2s_softc *, uint32_t);
 
-void	pxa2x0_i2s_setspeed(struct pxa2x0_i2s_softc *, u_int *);
+void	pxa2x0_i2s_setspeed(struct pxa2x0_i2s_softc *, u_int);
 
 void *	pxa2x0_i2s_allocm(void *, int, size_t);
 void	pxa2x0_i2s_freem(void  *, void *, size_t);
-paddr_t	pxa2x0_i2s_mappage(void *, void *, off_t, int);
 int	pxa2x0_i2s_round_blocksize(void *, int, int, const struct audio_params *);
 size_t	pxa2x0_i2s_round_buffersize(void *, int, size_t);
 int	pxa2x0_i2s_halt_output(void *);

Index: src/sys/arch/zaurus/dev/wm8731_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2 src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2.4.1
--- src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2	Sat Jun 16 21:22:13 2018
+++ src/sys/arch/zaurus/dev/wm8731_zaudio.c	Wed Apr 24 13:03:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wm8731_zaudio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $	*/
+/*	$NetBSD: wm8731_zaudio.c,v 1.2.4.1 2019/04/24 13:03:06 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include "opt_zaudio.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.2.4.1 2019/04/24 13:03:06 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,8 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: wm8731_zaudi
 #include <sys/bus.h>
 
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -92,21 +90,6 @@ static struct audio_device wm8731_device
 	"wm"
 };
 
-static const struct audio_format wm8731_formats[] = {
-	{
-		.driver_data	= NULL,
-		.mode		= AUMODE_PLAY | AUMODE_RECORD,
-		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
-		.validbits	= 16,
-		.precision	= 16,
-		.channels	= 2,
-		.channel_mask	= AUFMT_STEREO,
-		.frequency_type	= 0,
-		.frequency	= { 4000, 48000 }
-	}
-};
-static const int wm8731_nformats = (int)__arraycount(wm8731_formats);
-
 static void wm8731_init(struct zaudio_softc *);
 static int wm8731_jack_intr(void *);
 static void wm8731_jack(void *);
@@ -115,9 +98,6 @@ static void wm8731_update_volume(struct 
 static void wm8731_update_mutes(struct zaudio_softc *, int);
 static void wm8731_play_setup(struct zaudio_softc *);
 /*static*/ void wm8731_record_setup(struct zaudio_softc *);
-static int wm8731_query_encoding(void *, struct audio_encoding *);
-static int wm8731_set_params(void *, int, int, audio_params_t *,
-    audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
 static int wm8731_start_output(void *, void *, int, void (*)(void *), void *);
 static int wm8731_start_input(void *, void *, int, void (*)(void *), void *);
 static int wm8731_halt_output(void *);
@@ -131,8 +111,8 @@ static struct audio_hw_if wm8731_hw_if =
 	.open			= zaudio_open,
 	.close			= zaudio_close,
 	.drain			= NULL,
-	.query_encoding		= wm8731_query_encoding,
-	.set_params		= wm8731_set_params,
+	.query_format		= zaudio_query_format,
+	.set_format		= zaudio_set_format,
 	.round_blocksize	= zaudio_round_blocksize,
 	.commit_settings	= NULL,
 	.init_output		= NULL,
@@ -150,7 +130,6 @@ static struct audio_hw_if wm8731_hw_if =
 	.allocm			= zaudio_allocm,
 	.freem			= zaudio_freem,
 	.round_buffersize	= zaudio_round_buffersize,
-	.mappage		= zaudio_mappage,
 	.get_props		= zaudio_get_props,
 	.trigger_output		= NULL,
 	.trigger_input		= NULL,
@@ -614,122 +593,6 @@ wm8731_record_setup(struct zaudio_softc 
 }
 
 static int
-wm8731_query_encoding(void *hdl, struct audio_encoding *aep)
-{
-
-	switch (aep->index) {
-	case 0:
-		strlcpy(aep->name, AudioEulinear, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULINEAR;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 1:
-		strlcpy(aep->name, AudioEmulaw, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULAW;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 2:
-		strlcpy(aep->name, AudioEalaw, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ALAW;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 3:
-		strlcpy(aep->name, AudioEslinear, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_SLINEAR;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 4:
-		strlcpy(aep->name, AudioEslinear_le, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_SLINEAR_LE;
-		aep->precision = 16;
-		aep->flags = 0;
-		break;
-
-	case 5:
-		strlcpy(aep->name, AudioEulinear_le, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULINEAR_LE;
-		aep->precision = 16;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 6:
-		strlcpy(aep->name, AudioEslinear_be, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_SLINEAR_BE;
-		aep->precision = 16;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 7:
-		strlcpy(aep->name, AudioEulinear_be, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULINEAR_BE;
-		aep->precision = 16;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	default:
-		return EINVAL;
-	}
-
-	return 0;
-}
-
-static int
-wm8731_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)
-{
-	struct zaudio_softc *sc = hdl;
-	struct audio_params *p;
-	stream_filter_list_t *fil;
-	int mode, i;
-
-	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 > 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(wm8731_formats, wm8731_nformats,
-					 mode, p, true, fil);
-		if (i < 0)
-			return EINVAL;
-	}
-
-	if (setmode == AUMODE_RECORD)
-		pxa2x0_i2s_setspeed(&sc->sc_i2s, &rec->sample_rate);
-	else
-		pxa2x0_i2s_setspeed(&sc->sc_i2s, &play->sample_rate);
-
-	return 0;
-}
-
-static int
 wm8731_halt_output(void *hdl)
 {
 	struct zaudio_softc *sc = hdl;

Index: src/sys/arch/zaurus/dev/wm8750_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2.4.1 src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2.4.2
--- src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2.4.1	Sun Apr 21 05:11:22 2019
+++ src/sys/arch/zaurus/dev/wm8750_zaudio.c	Wed Apr 24 13:03:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wm8750_zaudio.c,v 1.2.4.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: wm8750_zaudio.c,v 1.2.4.2 2019/04/24 13:03:06 isaki Exp $	*/
 /*	$OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $	*/
 
 /*
@@ -51,7 +51,7 @@
 #include "opt_zaudio.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.2.4.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.2.4.2 2019/04/24 13:03:06 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,8 +65,6 @@ __KERNEL_RCSID(0, "$NetBSD: wm8750_zaudi
 #include <sys/bus.h>
 
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -112,25 +110,6 @@ static struct audio_device wm8750_device
 	"wm"
 };
 
-#define WM8750_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	= { 4000, 48000 }, \
-	}
-static const struct audio_format wm8750_formats[] = {
-	WM8750_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	WM8750_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	WM8750_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	WM8750_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
-};
-static const int wm8750_nformats = (int)__arraycount(wm8750_formats);
-
 static void wm8750_init(struct zaudio_softc *);
 static int wm8750_jack_intr(void *);
 static void wm8750_jack(void *);
@@ -139,9 +118,6 @@ static void wm8750_update_volume(struct 
 static void wm8750_update_mutes(struct zaudio_softc *, int);
 static void wm8750_play_setup(struct zaudio_softc *);
 /*static*/ void wm8750_record_setup(struct zaudio_softc *);
-static int wm8750_query_encoding(void *, struct audio_encoding *);
-static int wm8750_set_params(void *, int, int, audio_params_t *,
-    audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
 static int wm8750_start_output(void *, void *, int, void (*)(void *), void *);
 static int wm8750_start_input(void *, void *, int, void (*)(void *), void *);
 static int wm8750_halt_output(void *);
@@ -155,8 +131,8 @@ static struct audio_hw_if wm8750_hw_if =
 	.open			= zaudio_open,
 	.close			= zaudio_close,
 	.drain			= NULL,
-	.query_encoding		= wm8750_query_encoding,
-	.set_params		= wm8750_set_params,
+	.query_format		= zaudio_query_format,
+	.set_format		= zaudio_set_format,
 	.round_blocksize	= zaudio_round_blocksize,
 	.commit_settings	= NULL,
 	.init_output		= NULL,
@@ -174,7 +150,6 @@ static struct audio_hw_if wm8750_hw_if =
 	.allocm			= zaudio_allocm,
 	.freem			= zaudio_freem,
 	.round_buffersize	= zaudio_round_buffersize,
-	.mappage		= zaudio_mappage,
 	.get_props		= zaudio_get_props,
 	.trigger_output		= NULL,
 	.trigger_input		= NULL,
@@ -675,122 +650,6 @@ wm8750_record_setup(struct zaudio_softc 
 }
 
 static int
-wm8750_query_encoding(void *hdl, struct audio_encoding *aep)
-{
-
-	switch (aep->index) {
-	case 0:
-		strlcpy(aep->name, AudioEulinear, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULINEAR;
-		aep->precision = 8;
-		aep->flags = 0;
-		break;
-
-	case 1:
-		strlcpy(aep->name, AudioEmulaw, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULAW;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 2:
-		strlcpy(aep->name, AudioEalaw, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ALAW;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 3:
-		strlcpy(aep->name, AudioEslinear, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_SLINEAR;
-		aep->precision = 8;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 4:
-		strlcpy(aep->name, AudioEslinear_le, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_SLINEAR_LE;
-		aep->precision = 16;
-		aep->flags = 0;
-		break;
-
-	case 5:
-		strlcpy(aep->name, AudioEulinear_le, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULINEAR_LE;
-		aep->precision = 16;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 6:
-		strlcpy(aep->name, AudioEslinear_be, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_SLINEAR_BE;
-		aep->precision = 16;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	case 7:
-		strlcpy(aep->name, AudioEulinear_be, sizeof(aep->name));
-		aep->encoding = AUDIO_ENCODING_ULINEAR_BE;
-		aep->precision = 16;
-		aep->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-
-	default:
-		return EINVAL;
-	}
-
-	return 0;
-}
-
-static int
-wm8750_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)
-{
-	struct zaudio_softc *sc = hdl;
-	struct audio_params *p;
-	stream_filter_list_t *fil;
-	int mode, i;
-
-	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 > 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(wm8750_formats, wm8750_nformats,
-		    mode, p, false, fil);
-		if (i < 0)
-			return EINVAL;
-	}
-
-	if (setmode == AUMODE_RECORD)
-		pxa2x0_i2s_setspeed(&sc->sc_i2s, &rec->sample_rate);
-	else
-		pxa2x0_i2s_setspeed(&sc->sc_i2s, &play->sample_rate);
-
-	return 0;
-}
-
-static int
 wm8750_halt_output(void *hdl)
 {
 	struct zaudio_softc *sc = hdl;

Index: src/sys/arch/zaurus/dev/zaudio.c
diff -u src/sys/arch/zaurus/dev/zaudio.c:1.21 src/sys/arch/zaurus/dev/zaudio.c:1.21.22.1
--- src/sys/arch/zaurus/dev/zaudio.c:1.21	Tue Sep 23 14:49:46 2014
+++ src/sys/arch/zaurus/dev/zaudio.c	Wed Apr 24 13:03:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: zaudio.c,v 1.21 2014/09/23 14:49:46 nonaka Exp $	*/
+/*	$NetBSD: zaudio.c,v 1.21.22.1 2019/04/24 13:03:06 isaki Exp $	*/
 /*	$OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $	*/
 
 /*
@@ -50,7 +50,7 @@
 #include "opt_cputypes.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1.21 2014/09/23 14:49:46 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1.21.22.1 2019/04/24 13:03:06 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -82,6 +82,20 @@ static void	zaudio_attach(device_t, devi
 CFATTACH_DECL_NEW(zaudio, sizeof(struct zaudio_softc), 
     zaudio_match, zaudio_attach, NULL, NULL);
 
+static const struct audio_format zaudio_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 6,
+		.frequency	= { 8000, 11025, 16000, 22050, 44100, 48000 },
+	}
+};
+#define ZAUDIO_NFORMATS	__arraycount(zaudio_formats)
+
 static int
 zaudio_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -158,6 +172,30 @@ zaudio_close(void *hdl)
 }
 
 int
+zaudio_query_format(void *hdl, audio_format_query_t *afp)
+{
+
+	return audio_query_format(zaudio_formats, ZAUDIO_NFORMATS, afp);
+}
+
+int
+zaudio_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 zaudio_softc *sc = hdl;
+
+	/* *play and *rec are the identical because !AUDIO_PROP_INDEPENDENT. */
+
+	if (setmode == AUMODE_RECORD)
+		pxa2x0_i2s_setspeed(&sc->sc_i2s, rec->sample_rate);
+	else
+		pxa2x0_i2s_setspeed(&sc->sc_i2s, play->sample_rate);
+
+	return 0;
+}
+
+int
 zaudio_round_blocksize(void *hdl, int bs, int mode, const audio_params_t *param)
 {
 	struct zaudio_softc *sc = hdl;
@@ -189,19 +227,11 @@ zaudio_round_buffersize(void *hdl, int d
 	return pxa2x0_i2s_round_buffersize(&sc->sc_i2s, direction, bufsize);
 }
 
-paddr_t
-zaudio_mappage(void *hdl, void *mem, off_t off, int prot)
-{
-	struct zaudio_softc *sc = hdl;
-	
-	return pxa2x0_i2s_mappage(&sc->sc_i2s, mem, off, prot);
-}
-
 int
 zaudio_get_props(void *hdl)
 {
 
-	return AUDIO_PROP_MMAP|AUDIO_PROP_INDEPENDENT;
+	return AUDIO_PROP_MMAP;
 }
 
 void

Index: src/sys/arch/zaurus/dev/zaudiovar.h
diff -u src/sys/arch/zaurus/dev/zaudiovar.h:1.2 src/sys/arch/zaurus/dev/zaudiovar.h:1.2.22.1
--- src/sys/arch/zaurus/dev/zaudiovar.h:1.2	Thu Jul  7 06:55:40 2016
+++ src/sys/arch/zaurus/dev/zaudiovar.h	Wed Apr 24 13:03:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: zaudiovar.h,v 1.2 2016/07/07 06:55:40 msaitoh Exp $	*/
+/*	$NetBSD: zaudiovar.h,v 1.2.22.1 2019/04/24 13:03:06 isaki Exp $	*/
 /*	$OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $	*/
 
 /*
@@ -83,11 +83,14 @@ struct zaudio_softc {
 
 int	zaudio_open(void *, int);
 void	zaudio_close(void *);
+int	zaudio_query_format(void *, audio_format_query_t *);
+int	zaudio_set_format(void *, int,
+	    const audio_params_t *, const audio_params_t *,
+	    audio_filter_reg_t *, audio_filter_reg_t *);
 int	zaudio_round_blocksize(void *, int, int, const audio_params_t *);
 void *	zaudio_allocm(void *, int, size_t);
 void	zaudio_freem(void  *, void *, size_t);
 size_t	zaudio_round_buffersize(void *, int, size_t);
-paddr_t	zaudio_mappage(void *, void *, off_t, int);
 int	zaudio_get_props(void *);
 void	zaudio_get_locks(void *, kmutex_t **, kmutex_t **);
 

Reply via email to