Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Add slinear encoding. Tested by flxd@



details:   https://anonhg.NetBSD.org/src/rev/b5250ff668df
branches:  trunk
changeset: 349930:b5250ff668df
user:      nat <nat%NetBSD.org@localhost>
date:      Wed Dec 28 10:04:53 2016 +0000

description:
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.

diffstat:

 sys/dev/ic/am7930.c |  25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diffs (74 lines):

diff -r 61c08bceb8b6 -r b5250ff668df sys/dev/ic/am7930.c
--- a/sys/dev/ic/am7930.c       Wed Dec 28 09:36:02 2016 +0000
+++ b/sys/dev/ic/am7930.c       Wed Dec 28 10:04:53 2016 +0000
@@ -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 @@
 
 #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 @@
        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 @@
        }
        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 @@
                }
        }
 
+       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 @@
                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*/



Home | Main Index | Thread Index | Old Index