Module Name: src
Committed By: nat
Date: Wed Dec 28 10:04:53 UTC 2016
Modified Files:
src/sys/dev/ic: am7930.c
Log Message:
Add slinear encoding. Tested by flxd@
Addresses PR kern/51703: audio fails to attach if hardware can't do CD
quality.
Autoconfiguration of hw paramaters to be done later. For now it is
possibile to set 8 bits precision 8000 Hz 1 channel via sysctls.
To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/ic/am7930.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/am7930.c
diff -u src/sys/dev/ic/am7930.c:1.52 src/sys/dev/ic/am7930.c:1.53
--- src/sys/dev/ic/am7930.c:1.52 Sat Dec 20 23:36:21 2014
+++ src/sys/dev/ic/am7930.c Wed Dec 28 10:04:53 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: am7930.c,v 1.52 2014/12/20 23:36:21 jklos Exp $ */
+/* $NetBSD: am7930.c,v 1.53 2016/12/28 10:04:53 nat Exp $ */
/*
* Copyright (c) 1995 Rolf Grossmann
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1.52 2014/12/20 23:36:21 jklos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1.53 2016/12/28 10:04:53 nat Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1
#include <sys/audioio.h>
#include <dev/audio_if.h>
+#include <dev/mulaw.h>
#include <dev/ic/am7930reg.h>
#include <dev/ic/am7930var.h>
@@ -229,7 +230,8 @@ am7930_set_params(void *addr, int setmod
sc = addr;
if ((usemode & AUMODE_PLAY) == AUMODE_PLAY) {
if (p->sample_rate < 7500 || p->sample_rate > 8500 ||
- p->encoding != AUDIO_ENCODING_ULAW ||
+ (p->encoding != AUDIO_ENCODING_ULAW &&
+ p->encoding != AUDIO_ENCODING_SLINEAR) ||
p->precision != 8 ||
p->channels != 1)
return EINVAL;
@@ -243,7 +245,8 @@ am7930_set_params(void *addr, int setmod
}
if ((usemode & AUMODE_RECORD) == AUMODE_RECORD) {
if (r->sample_rate < 7500 || r->sample_rate > 8500 ||
- r->encoding != AUDIO_ENCODING_ULAW ||
+ (r->encoding != AUDIO_ENCODING_ULAW &&
+ r->encoding != AUDIO_ENCODING_SLINEAR) ||
r->precision != 8 ||
r->channels != 1)
return EINVAL;
@@ -256,6 +259,14 @@ am7930_set_params(void *addr, int setmod
}
}
+ if (p->encoding == AUDIO_ENCODING_SLINEAR ||
+ r->encoding == AUDIO_ENCODING_SLINEAR) {
+ hw.encoding = AUDIO_ENCODING_ULAW;
+ pfil->req_size = rfil->req_size = 0;
+ pfil->append(rfil, mulaw_to_linear8, &hw);
+ rfil->append(pfil, linear8_to_mulaw, &hw);
+ }
+
return 0;
}
@@ -269,6 +280,12 @@ am7930_query_encoding(void *addr, struct
fp->precision = 8;
fp->flags = 0;
break;
+ case 1:
+ strcpy(fp->name, AudioEslinear);
+ fp->encoding = AUDIO_ENCODING_SLINEAR;
+ fp->precision = 8;
+ fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ break;
default:
return EINVAL;
/*NOTREACHED*/