Adapt to audio2.
This commit is contained in:
parent
60f21f6c35
commit
a7af0695c5
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vaudio.c,v 1.4.32.1 2019/04/21 05:11:22 isaki Exp $ */
|
||||
/* $NetBSD: vaudio.c,v 1.4.32.2 2019/04/27 11:58:02 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.4.32.1 2019/04/21 05:11:22 isaki Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.4.32.2 2019/04/27 11:58:02 isaki Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -39,7 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.4.32.1 2019/04/21 05:11:22 isaki Exp $"
|
|||
#include <machine/thunk.h>
|
||||
|
||||
#include <dev/audio_if.h>
|
||||
#include <dev/auconv.h>
|
||||
|
||||
static const struct audio_format vaudio_audio_formats[1] = {
|
||||
{
|
||||
|
@ -53,6 +52,7 @@ static const struct audio_format vaudio_audio_formats[1] = {
|
|||
.frequency = { 8000, 48000 },
|
||||
},
|
||||
};
|
||||
#define VAUDIO_NFORMATS __arraycount(vaudio_audio_formats)
|
||||
|
||||
struct vaudio_stream {
|
||||
struct vaudio_softc *st_softc;
|
||||
|
@ -72,7 +72,6 @@ struct vaudio_softc {
|
|||
void * sc_audiodev;
|
||||
const char * sc_audiopath;
|
||||
int sc_audiofd;
|
||||
struct audio_encoding_set * sc_encodings;
|
||||
audio_params_t sc_pparam;
|
||||
audio_params_t sc_rparam;
|
||||
kmutex_t sc_lock;
|
||||
|
@ -90,13 +89,10 @@ static void vaudio_intr(void *);
|
|||
static void vaudio_softintr_play(void *);
|
||||
static void vaudio_softintr_record(void *);
|
||||
|
||||
static int vaudio_open(void *, int);
|
||||
static void vaudio_close(void *);
|
||||
static int vaudio_drain(void *);
|
||||
static int vaudio_query_encoding(void *, audio_encoding_t *);
|
||||
static int vaudio_set_params(void *, int, int, audio_params_t *,
|
||||
audio_params_t *, stream_filter_list_t *,
|
||||
stream_filter_list_t *);
|
||||
static int vaudio_query_format(void *, audio_format_query_t *);
|
||||
static int vaudio_set_format(void *, int, const audio_params_t *,
|
||||
const audio_params_t *,
|
||||
audio_filter_reg_t *, audio_filter_reg_t *);
|
||||
static int vaudio_commit_settings(void *);
|
||||
static int vaudio_trigger_output(void *, void *, void *, int,
|
||||
void (*)(void *), void *,
|
||||
|
@ -117,11 +113,8 @@ CFATTACH_DECL_NEW(vaudio, sizeof(struct vaudio_softc),
|
|||
vaudio_match, vaudio_attach, NULL, NULL);
|
||||
|
||||
static const struct audio_hw_if vaudio_hw_if = {
|
||||
.open = vaudio_open,
|
||||
.close = vaudio_close,
|
||||
.drain = vaudio_drain,
|
||||
.query_encoding = vaudio_query_encoding,
|
||||
.set_params = vaudio_set_params,
|
||||
.query_format = vaudio_query_format,
|
||||
.set_format = vaudio_set_format,
|
||||
.commit_settings = vaudio_commit_settings,
|
||||
.halt_output = vaudio_halt_output,
|
||||
.halt_input = vaudio_halt_input,
|
||||
|
@ -151,7 +144,6 @@ vaudio_attach(device_t parent, device_t self, void *opaque)
|
|||
{
|
||||
struct vaudio_softc *sc = device_private(self);
|
||||
struct thunkbus_attach_args *taa = opaque;
|
||||
int error;
|
||||
|
||||
aprint_naive("\n");
|
||||
aprint_normal(": Virtual Audio (device = %s)\n", taa->u.vaudio.device);
|
||||
|
@ -171,13 +163,6 @@ vaudio_attach(device_t parent, device_t self, void *opaque)
|
|||
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_AUDIO);
|
||||
|
||||
error = auconv_create_encodings(vaudio_audio_formats,
|
||||
__arraycount(vaudio_audio_formats), &sc->sc_encodings);
|
||||
if (error) {
|
||||
aprint_error_dev(self, "couldn't create encodings\n");
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_play.st_softc = sc;
|
||||
sc->sc_play.st_sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE,
|
||||
vaudio_softintr_play, &sc->sc_play);
|
||||
|
@ -259,63 +244,23 @@ vaudio_softintr_record(void *opaque)
|
|||
}
|
||||
|
||||
static int
|
||||
vaudio_open(void *opaque, int flags)
|
||||
vaudio_query_format(void *opaque, audio_format_query_t *afp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
vaudio_close(void *opaque)
|
||||
{
|
||||
return audio_query_format(vaudio_audio_formats, VAUDIO_NFORMATS, afp);
|
||||
}
|
||||
|
||||
static int
|
||||
vaudio_drain(void *opaque)
|
||||
vaudio_set_format(void *opaque, int setmode,
|
||||
const audio_params_t *play, const audio_params_t *rec,
|
||||
audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
|
||||
{
|
||||
struct vaudio_softc *sc = opaque;
|
||||
|
||||
return thunk_audio_drain(sc->sc_audiofd);
|
||||
}
|
||||
|
||||
static int
|
||||
vaudio_query_encoding(void *opaque, audio_encoding_t *enc)
|
||||
{
|
||||
struct vaudio_softc *sc = opaque;
|
||||
|
||||
return auconv_query_encoding(sc->sc_encodings, enc);
|
||||
}
|
||||
|
||||
static int
|
||||
vaudio_set_params(void *opaque, int setmode, int usemode,
|
||||
audio_params_t *play, audio_params_t *rec,
|
||||
stream_filter_list_t *pfil, stream_filter_list_t *rfil)
|
||||
{
|
||||
struct vaudio_softc *sc = opaque;
|
||||
audio_params_t *p;
|
||||
stream_filter_list_t *fil;
|
||||
int mode, index;
|
||||
|
||||
for (mode = AUMODE_RECORD; mode != -1;
|
||||
mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
|
||||
if ((setmode & mode) == 0)
|
||||
continue;
|
||||
p = mode == AUMODE_PLAY ? play : rec;
|
||||
fil = mode == AUMODE_PLAY ? pfil : rfil;
|
||||
if (p == NULL)
|
||||
continue;
|
||||
|
||||
index = auconv_set_converter(vaudio_audio_formats,
|
||||
__arraycount(vaudio_audio_formats), mode, p, TRUE, fil);
|
||||
if (index < 0)
|
||||
return EINVAL;
|
||||
if (fil->req_size > 0)
|
||||
p = &fil->filters[0].param;
|
||||
|
||||
if (mode == AUMODE_PLAY)
|
||||
sc->sc_pparam = *p;
|
||||
else
|
||||
sc->sc_rparam = *p;
|
||||
}
|
||||
if ((setmode & AUMODE_PLAY))
|
||||
sc->sc_pparam = *play;
|
||||
if ((setmode & AUMODE_RECORD))
|
||||
sc->sc_rparam = *rec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: thunk.h,v 1.66 2018/08/01 09:46:46 reinoud Exp $ */
|
||||
/* $NetBSD: thunk.h,v 1.66.2.1 2019/04/27 11:58:02 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
|
@ -185,7 +185,6 @@ typedef struct {
|
|||
|
||||
int thunk_audio_open(const char *);
|
||||
int thunk_audio_close(int);
|
||||
int thunk_audio_drain(int);
|
||||
int thunk_audio_config(int, const thunk_audio_config_t *,
|
||||
const thunk_audio_config_t *);
|
||||
int thunk_audio_pollout(int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: thunk.c,v 1.91 2018/08/01 09:44:31 reinoud Exp $ */
|
||||
/* $NetBSD: thunk.c,v 1.91.2.1 2019/04/27 11:58:02 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifdef __NetBSD__
|
||||
__RCSID("$NetBSD: thunk.c,v 1.91 2018/08/01 09:44:31 reinoud Exp $");
|
||||
__RCSID("$NetBSD: thunk.c,v 1.91.2.1 2019/04/27 11:58:02 isaki Exp $");
|
||||
#endif
|
||||
|
||||
#define _KMEMUSER
|
||||
|
@ -911,12 +911,6 @@ thunk_audio_close(int fd)
|
|||
return close(fd);
|
||||
}
|
||||
|
||||
int
|
||||
thunk_audio_drain(int fd)
|
||||
{
|
||||
return ioctl(fd, AUDIO_DRAIN, 0);
|
||||
}
|
||||
|
||||
int
|
||||
thunk_audio_config(int fd, const thunk_audio_config_t *pconf,
|
||||
const thunk_audio_config_t *rconf)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pl041.c,v 1.5 2018/09/03 16:29:31 riastradh Exp $ */
|
||||
/* $NetBSD: pl041.c,v 1.5.2.1 2019/04/27 11:52:53 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.5 2018/09/03 16:29:31 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.5.2.1 2019/04/27 11:52:53 isaki Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -37,7 +37,6 @@ __KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.5 2018/09/03 16:29:31 riastradh Exp $");
|
|||
#include <sys/audioio.h>
|
||||
|
||||
#include <dev/audio_if.h>
|
||||
#include <dev/auconv.h>
|
||||
|
||||
#include <dev/ic/ac97var.h>
|
||||
#include <dev/ic/ac97reg.h>
|
||||
|
@ -93,8 +92,8 @@ static const struct audio_format aaci_format = {
|
|||
.precision = 16,
|
||||
.channels = 2,
|
||||
.channel_mask = AUFMT_STEREO,
|
||||
.frequency_type = 0,
|
||||
.frequency = { 48000, 48000 }
|
||||
.frequency_type = 1,
|
||||
.frequency = { 48000 }
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -122,27 +121,19 @@ aaci_write_data(struct aaci_softc *sc)
|
|||
}
|
||||
|
||||
static int
|
||||
aaci_query_encoding(void *priv, struct audio_encoding *enc)
|
||||
aaci_query_format(void *priv, audio_format_query_t *afp)
|
||||
{
|
||||
struct aaci_softc * const sc = priv;
|
||||
|
||||
return auconv_query_encoding(sc->sc_encodings, enc);
|
||||
return audio_query_format(&aaci_format, 1, afp);
|
||||
}
|
||||
|
||||
static int
|
||||
aaci_set_params(void *priv, int setmode, int usermode,
|
||||
audio_params_t *play, audio_params_t *rec,
|
||||
stream_filter_list_t *pfil, stream_filter_list_t *rfil)
|
||||
aaci_set_format(void *priv, int setmode,
|
||||
const audio_params_t *play, const audio_params_t *rec,
|
||||
audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (play && (setmode & AUMODE_PLAY) != 0) {
|
||||
index = auconv_set_converter(&aaci_format, 1, AUMODE_PLAY,
|
||||
play, true, pfil);
|
||||
if (index < 0)
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* We have only one format so nothing to do here. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -250,8 +241,8 @@ aaci_get_locks(void *priv, kmutex_t **intr, kmutex_t **thread)
|
|||
}
|
||||
|
||||
static const struct audio_hw_if aaci_hw_if = {
|
||||
.query_encoding = aaci_query_encoding,
|
||||
.set_params = aaci_set_params,
|
||||
.query_format = aaci_query_format,
|
||||
.set_format = aaci_set_format,
|
||||
.getdev = aaci_getdev,
|
||||
.set_port = aaci_set_port,
|
||||
.get_port = aaci_get_port,
|
||||
|
@ -322,13 +313,6 @@ aaci_attach(struct aaci_softc *sc)
|
|||
return;
|
||||
}
|
||||
|
||||
error = auconv_create_encodings(&aaci_format, 1, &sc->sc_encodings);
|
||||
if (error) {
|
||||
aprint_error_dev(sc->sc_dev, "couldn't create encodings (%d)\n",
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_audiodev = audio_attach_mi(&aaci_hw_if, sc, sc->sc_dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pl041var.h,v 1.1 2017/06/08 10:02:39 jmcneill Exp $ */
|
||||
/* $NetBSD: pl041var.h,v 1.1.16.1 2019/04/27 11:52:53 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
|
||||
|
@ -50,8 +50,6 @@ struct aaci_softc {
|
|||
|
||||
uint32_t *sc_pcur;
|
||||
int sc_pblkresid;
|
||||
|
||||
struct audio_encoding_set *sc_encodings;
|
||||
};
|
||||
|
||||
void aaci_attach(struct aaci_softc *);
|
||||
|
|
Loading…
Reference in New Issue