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/9deea2ac808d
branches: isaki-audio2
changeset: 840887:9deea2ac808d
user: isaki <isaki%NetBSD.org@localhost>
date: Sun Apr 28 02:15:32 2019 +0000
description:
Adapt to audio2.
diffstat:
sys/dev/pci/azalia.c | 51 +++++-------------
sys/dev/pci/azalia.h | 3 +-
sys/dev/pci/cmpci.c | 142 ++++++++++----------------------------------------
3 files changed, 43 insertions(+), 153 deletions(-)
diffs (truncated from 392 to 300 lines):
diff -r 1ecb0e00d544 -r 9deea2ac808d sys/dev/pci/azalia.c
--- a/sys/dev/pci/azalia.c Sun Apr 28 02:07:42 2019 +0000
+++ b/sys/dev/pci/azalia.c Sun Apr 28 02:15:32 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: azalia.c,v 1.86 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: azalia.c,v 1.86.2.1 2019/04/28 02:15:32 isaki Exp $ */
/*-
* Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: azalia.c,v 1.86 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: azalia.c,v 1.86.2.1 2019/04/28 02:15:32 isaki Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -51,7 +51,6 @@
#include <sys/module.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcivar.h>
@@ -205,9 +204,10 @@
static int azalia_open(void *, int);
static void azalia_close(void *);
-static int azalia_query_encoding(void *, audio_encoding_t *);
-static int azalia_set_params(void *, int, int, audio_params_t *,
- audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+static int azalia_query_format(void *, audio_format_query_t *);
+static int azalia_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
static int azalia_round_blocksize(void *, int, int, const audio_params_t *);
static int azalia_halt_output(void *);
static int azalia_halt_input(void *);
@@ -235,8 +235,8 @@
static const struct audio_hw_if azalia_hw_if = {
.open = azalia_open,
.close = azalia_close,
- .query_encoding = azalia_query_encoding,
- .set_params = azalia_set_params,
+ .query_format = azalia_query_format,
+ .set_format = azalia_set_format,
.round_blocksize = azalia_round_blocksize,
.halt_output = azalia_halt_output,
.halt_input = azalia_halt_input,
@@ -1298,8 +1298,6 @@
kmem_free(this->formats, this->szformats);
this->formats = NULL;
}
- auconv_delete_encodings(this->encodings);
- this->encodings = NULL;
if (this->extra != NULL) {
kmem_free(this->extra, this->szextra);
this->extra = NULL;
@@ -1318,7 +1316,7 @@
const convgroup_t *group;
uint32_t bits_rates;
int variation;
- int nbits, c, chan, i, err;
+ int nbits, c, chan, i;
nid_t nid;
variation = 0;
@@ -1435,10 +1433,6 @@
}
#endif
- err = auconv_create_encodings(this->formats, this->nformats,
- &this->encodings);
- if (err)
- return err;
return 0;
}
@@ -2121,39 +2115,22 @@
}
static int
-azalia_query_encoding(void *v, audio_encoding_t *enc)
+azalia_query_format(void *v, audio_format_query_t *afp)
{
azalia_t *az;
codec_t *codec;
az = v;
codec = &az->codecs[az->codecno];
- return auconv_query_encoding(codec->encodings, enc);
+ return audio_query_format(codec->formats, codec->nformats, afp);
}
static int
-azalia_set_params(void *v, int smode, int umode, audio_params_t *p,
- audio_params_t *r, stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+azalia_set_format(void *v, int setmode,
+ const audio_params_t *p, const audio_params_t *r,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
- azalia_t *az;
- codec_t *codec;
- int index;
- az = v;
- codec = &az->codecs[az->codecno];
- smode &= az->mode_cap;
- if (smode & AUMODE_RECORD && r != NULL) {
- index = auconv_set_converter(codec->formats, codec->nformats,
- AUMODE_RECORD, r, TRUE, rfil);
- if (index < 0)
- return EINVAL;
- }
- if (smode & AUMODE_PLAY && p != NULL) {
- index = auconv_set_converter(codec->formats, codec->nformats,
- AUMODE_PLAY, p, TRUE, pfil);
- if (index < 0)
- return EINVAL;
- }
return 0;
}
diff -r 1ecb0e00d544 -r 9deea2ac808d sys/dev/pci/azalia.h
--- a/sys/dev/pci/azalia.h Sun Apr 28 02:07:42 2019 +0000
+++ b/sys/dev/pci/azalia.h Sun Apr 28 02:15:32 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: azalia.h,v 1.21 2011/11/23 23:07:35 jmcneill Exp $ */
+/* $NetBSD: azalia.h,v 1.21.54.1 2019/04/28 02:15:32 isaki Exp $ */
/*-
* Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -584,7 +584,6 @@
struct audio_format *formats;
int nformats;
size_t szformats;
- struct audio_encoding_set *encodings;
uint32_t *extra;
size_t szextra;
diff -r 1ecb0e00d544 -r 9deea2ac808d sys/dev/pci/cmpci.c
--- a/sys/dev/pci/cmpci.c Sun Apr 28 02:07:42 2019 +0000
+++ b/sys/dev/pci/cmpci.c Sun Apr 28 02:15:32 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmpci.c,v 1.53.2.1 2019/04/21 05:11:22 isaki Exp $ */
+/* $NetBSD: cmpci.c,v 1.53.2.2 2019/04/28 02:19:35 isaki Exp $ */
/*
* Copyright (c) 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cmpci.c,v 1.53.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmpci.c,v 1.53.2.2 2019/04/28 02:19:35 isaki Exp $");
#if defined(AUDIO_DEBUG) || defined(DEBUG)
#define DPRINTF(x) if (cmpcidebug) printf x
@@ -68,8 +68,6 @@
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/pci/cmpcireg.h>
#include <dev/pci/cmpcivar.h>
@@ -128,9 +126,10 @@
/*
* interface to machine independent layer
*/
-static int cmpci_query_encoding(void *, struct audio_encoding *);
-static int cmpci_set_params(void *, int, int, audio_params_t *,
- audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+static int cmpci_query_format(void *, audio_format_query_t *);
+static int cmpci_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
static int cmpci_round_blocksize(void *, int, int, const audio_params_t *);
static int cmpci_halt_output(void *);
static int cmpci_halt_input(void *);
@@ -141,7 +140,6 @@
static void *cmpci_allocm(void *, int, size_t);
static void cmpci_freem(void *, void *, size_t);
static size_t cmpci_round_buffersize(void *, int, size_t);
-static paddr_t cmpci_mappage(void *, void *, off_t, int);
static int cmpci_get_props(void *);
static int cmpci_trigger_output(void *, void *, void *, int,
void (*)(void *), void *, const audio_params_t *);
@@ -150,8 +148,8 @@
static void cmpci_get_locks(void *, kmutex_t **, kmutex_t **);
static const struct audio_hw_if cmpci_hw_if = {
- .query_encoding = cmpci_query_encoding,
- .set_params = cmpci_set_params,
+ .query_format = cmpci_query_format,
+ .set_format = cmpci_set_format,
.round_blocksize = cmpci_round_blocksize,
.halt_output = cmpci_halt_output,
.halt_input = cmpci_halt_input,
@@ -162,31 +160,26 @@
.allocm = cmpci_allocm,
.freem = cmpci_freem,
.round_buffersize = cmpci_round_buffersize,
- .mappage = cmpci_mappage,
.get_props = cmpci_get_props,
.trigger_output = cmpci_trigger_output,
.trigger_input = cmpci_trigger_input,
.get_locks = cmpci_get_locks,
};
-#define CMPCI_NFORMATS 4
-#define CMPCI_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 = { 5512, 48000 }, \
- }
-static const struct audio_format cmpci_formats[CMPCI_NFORMATS] = {
- CMPCI_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
- CMPCI_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
- CMPCI_FORMAT(AUDIO_ENCODING_ULINEAR_LE, 8, 2, AUFMT_STEREO),
- CMPCI_FORMAT(AUDIO_ENCODING_ULINEAR_LE, 8, 1, AUFMT_MONAURAL),
+static const struct audio_format cmpci_formats[] = {
+ {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_SLINEAR_LE,
+ .validbits = 16,
+ .precision = 16,
+ .channels = 2,
+ .channel_mask = AUFMT_STEREO,
+ .frequency_type = 8,
+ .frequency =
+ { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000 },
+ },
};
+#define CMPCI_NFORMATS __arraycount(cmpci_formats)
/*
@@ -330,8 +323,7 @@
int i;
for (i = 0; i < CMPCI_REG_NUMRATE - 1; i++)
- if (rate <=
- (cmpci_rate_table[i].rate+cmpci_rate_table[i+1].rate) / 2)
+ if (rate == cmpci_rate_table[i].rate)
return i;
return i; /* 48000 */
}
@@ -572,69 +564,16 @@
}
static int
-cmpci_query_encoding(void *handle, struct audio_encoding *fp)
+cmpci_query_format(void *handle, audio_format_query_t *afp)
{
- switch (fp->index) {
- case 0:
- strcpy(fp->name, AudioEulinear);
- fp->encoding = AUDIO_ENCODING_ULINEAR;
- fp->precision = 8;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 1:
- strcpy(fp->name, AudioEmulaw);
- fp->encoding = AUDIO_ENCODING_ULAW;
- fp->precision = 8;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 2:
- strcpy(fp->name, AudioEalaw);
- fp->encoding = AUDIO_ENCODING_ALAW;
- fp->precision = 8;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 3:
- strcpy(fp->name, AudioEslinear);
- fp->encoding = AUDIO_ENCODING_SLINEAR;
- fp->precision = 8;
- fp->flags = 0;
- break;
- case 4:
- strcpy(fp->name, AudioEslinear_le);
- fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
- fp->precision = 16;
- fp->flags = 0;
- break;
- case 5:
- strcpy(fp->name, AudioEulinear_le);
- fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
- fp->precision = 16;
Home |
Main Index |
Thread Index |
Old Index