Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add AC97 mixer/codec support. From OpenBSD and FreeBSD.
details: https://anonhg.NetBSD.org/src/rev/fe716492fc4b
branches: trunk
changeset: 477675:fe716492fc4b
user: augustss <augustss%NetBSD.org@localhost>
date: Wed Oct 27 13:18:02 1999 +0000
description:
Add AC97 mixer/codec support. From OpenBSD and FreeBSD.
diffstat:
sys/conf/files | 6 +-
sys/dev/ic/ac97.c | 742 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
sys/dev/ic/ac97.h | 62 ++++
3 files changed, 809 insertions(+), 1 deletions(-)
diffs (truncated from 832 to 300 lines):
diff -r f704c54afd2e -r fe716492fc4b sys/conf/files
--- a/sys/conf/files Wed Oct 27 13:17:46 1999 +0000
+++ b/sys/conf/files Wed Oct 27 13:18:02 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.325 1999/10/25 19:18:10 drochner Exp $
+# $NetBSD: files,v 1.326 1999/10/27 13:18:02 augustss Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -361,6 +361,10 @@
device audiocs: audio, auconv, ad1848
file dev/ic/cs4231.c audiocs
+# AC-97 CODECs
+define ac97
+file dev/ic/ac97.c ac97
+
# LSI64854 DMA controller back-end
define lsi64854
file dev/ic/lsi64854.c lsi64854
diff -r f704c54afd2e -r fe716492fc4b sys/dev/ic/ac97.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/ac97.c Wed Oct 27 13:18:02 1999 +0000
@@ -0,0 +1,742 @@
+/* $NetBSD: ac97.c,v 1.1 1999/10/27 13:18:03 augustss Exp $ */
+/* $OpenBSD: ac97.c,v 1.2 1999/09/21 16:06:27 csapuntz Exp $ */
+
+/*
+ * Copyright (c) 1999 Constantine Sapuntzakis
+ *
+ * Author: Constantine Sapuntzakis <csapuntz%stanford.edu@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CONSTANTINE SAPUNTZAKIS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Partially inspired by FreeBSD's sys/dev/pcm/ac97.c. It came with
+ the following copyright */
+
+/*
+ * Copyright (c) 1999 Cameron Grant <gandalf%vilnya.demon.co.uk@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+#include <dev/ic/ac97.h>
+
+#define AC97_REG_RESET 0x00
+#define AC97_SOUND_ENHANCEMENT(reg) (((reg) >> 10) & 0x1f)
+#define AC97_REG_MASTER_VOLUME 0x02
+#define AC97_REG_HEADPHONE_VOLUME 0x04
+#define AC97_REG_MASTER_VOLUME_MONO 0x06
+#define AC97_REG_MASTER_TONE 0x08
+#define AC97_REG_PCBEEP_VOLUME 0x0a
+#define AC97_REG_PHONE_VOLUME 0x0c
+#define AC97_REG_MIC_VOLUME 0x0e
+#define AC97_REG_LINEIN_VOLUME 0x10
+#define AC97_REG_CD_VOLUME 0x12
+#define AC97_REG_VIDEO_VOLUME 0x14
+#define AC97_REG_AUX_VOLUME 0x16
+#define AC97_REG_PCMOUT_VOLUME 0x18
+#define AC97_REG_RECORD_SELECT 0x1a
+#define AC97_REG_RECORD_GAIN 0x1c
+#define AC97_REG_RECORD_GAIN_MIC 0x1e
+#define AC97_REG_GP 0x20
+#define AC97_REG_3D_CONTROL 0x22
+#define AC97_REG_POWER 0x26
+#define AC97_REG_VENDOR_ID1 0x7c
+#define AC97_REG_VENDOR_ID2 0x7e
+
+static struct audio_mixer_enum ac97_on_off = { 2,
+ { { { AudioNoff } , 0 },
+ { { AudioNon } , 1 } }};
+
+
+static struct audio_mixer_enum ac97_mic_select = { 2,
+ { { { AudioNmicrophone "0" },
+ 0 },
+ { { AudioNmicrophone "1" },
+ 1 } }};
+
+static struct audio_mixer_enum ac97_mono_select = { 2,
+ { { { AudioNmixerout },
+ 0 },
+ { { AudioNmicrophone },
+ 1 } }};
+
+static struct audio_mixer_enum ac97_source = { 8,
+ { { { AudioNmicrophone } , 0 },
+ { { AudioNcd }, 1 },
+ { { "video" }, 2 },
+ { { AudioNaux }, 3 },
+ { { AudioNline }, 4 },
+ { { AudioNmixerout }, 5 },
+ { { AudioNmixerout AudioNmono }, 6 },
+ { { "phone" }, 7 }}};
+
+static struct audio_mixer_value ac97_volume_stereo = { { AudioNvolume },
+ 2 };
+
+
+static struct audio_mixer_value ac97_volume_mono = { { AudioNvolume },
+ 1 };
+
+#define WRAP(a) &a, sizeof(a)
+
+struct ac97_source_info {
+ char *class;
+ char *device;
+ char *qualifier;
+ int type;
+
+ void *info;
+ int info_size;
+
+ u_int8_t reg;
+ u_int8_t bits:3;
+ u_int8_t ofs:4;
+ u_int8_t mute:1;
+ u_int8_t polarity:1; /* Does 0 == MAX or MIN */
+
+ int prev;
+ int next;
+ int mixer_class;
+} source_info[] = {
+ { AudioCinputs , NULL, NULL, AUDIO_MIXER_CLASS,
+ },
+ { AudioCoutputs, NULL, NULL, AUDIO_MIXER_CLASS,
+ },
+ { AudioCrecord , NULL, NULL, AUDIO_MIXER_CLASS,
+ },
+ /* Stereo master volume*/
+ { AudioCoutputs, AudioNmaster, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_MASTER_VOLUME, 5, 0, 1,
+ },
+ /* Mono volume */
+ { AudioCoutputs, AudioNmono, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_MASTER_VOLUME_MONO, 6, 0, 1,
+ },
+ { AudioCoutputs, AudioNmono,AudioNsource, AUDIO_MIXER_ENUM,
+ WRAP(ac97_mono_select),
+ AC97_REG_GP, 1, 9, 0,
+ },
+ /* Headphone volume */
+ { AudioCoutputs, AudioNheadphone, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_HEADPHONE_VOLUME, 6, 0, 1,
+ },
+ /* Tone */
+ { AudioCoutputs, "tone", NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_MASTER_TONE, 4, 0, 0,
+ },
+ /* PC Beep Volume */
+ { AudioCinputs, AudioNspeaker, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_PCBEEP_VOLUME, 4, 1, 1,
+ },
+ /* Phone */
+ { AudioCinputs, "phone", NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_PHONE_VOLUME, 5, 0, 1,
+ },
+ /* Mic Volume */
+ { AudioCinputs, AudioNmicrophone, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_MIC_VOLUME, 5, 0, 1,
+ },
+ { AudioCinputs, AudioNmicrophone, AudioNpreamp, AUDIO_MIXER_ENUM,
+ WRAP(ac97_on_off),
+ AC97_REG_MIC_VOLUME, 1, 6, 0,
+ },
+ { AudioCinputs, AudioNmicrophone, AudioNsource, AUDIO_MIXER_ENUM,
+ WRAP(ac97_mic_select),
+ AC97_REG_GP, 1, 8, 0,
+ },
+ /* Line in Volume */
+ { AudioCinputs, AudioNline, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_LINEIN_VOLUME, 5, 0, 1,
+ },
+ /* CD Volume */
+ { AudioCinputs, AudioNcd, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_CD_VOLUME, 5, 0, 1,
+ },
+ /* Video Volume */
+ { AudioCinputs, "video", NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_VIDEO_VOLUME, 5, 0, 1,
+ },
+ /* AUX volume */
+ { AudioCinputs, AudioNaux, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_AUX_VOLUME, 5, 0, 1,
+ },
+ /* PCM out volume */
+ { AudioCinputs, AudioNdac, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_PCMOUT_VOLUME, 5, 0, 1,
+ },
+ /* Record Source - some logic for this is hard coded - see below */
+ { AudioCrecord, AudioNsource, NULL, AUDIO_MIXER_ENUM,
+ WRAP(ac97_source),
+ AC97_REG_RECORD_SELECT, 3, 0, 0,
+ },
+ /* Record Gain */
+ { AudioCrecord, AudioNvolume, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_stereo),
+ AC97_REG_RECORD_GAIN, 4, 0, 1,
+ },
+ /* Record Gain mic */
+ { AudioCrecord, AudioNmicrophone, NULL, AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_RECORD_GAIN_MIC, 4, 0, 1, 1,
+ },
+ /* */
+ { AudioCoutputs, AudioNloudness, NULL, AUDIO_MIXER_ENUM,
+ WRAP(ac97_on_off),
+ AC97_REG_GP, 1, 12, 0,
+ },
+ { AudioCoutputs, AudioNspatial, NULL, AUDIO_MIXER_ENUM,
+ WRAP(ac97_on_off),
+ AC97_REG_GP, 1, 13, 0,
+ },
+ { AudioCoutputs, AudioNspatial, "center", AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_3D_CONTROL, 4, 8, 0, 1,
+ },
+ { AudioCoutputs, AudioNspatial, "depth", AUDIO_MIXER_VALUE,
+ WRAP(ac97_volume_mono),
+ AC97_REG_3D_CONTROL, 4, 0, 0, 1,
+ },
+
+ /* Missing features: Simulated Stereo, POP, Loopback mode */
+} ;
+
+#define SOURCE_INFO_SIZE (sizeof(source_info)/sizeof(source_info[0]))
+
+/*
+ * Check out http://developer.intel.com/pc-supp/platform/ac97/ for
+ * information on AC-97
+ */
+
+struct ac97_softc {
+ struct ac97_codec_if codecIf;
+
+ struct ac97_host_if *hostIf;
+
+ struct ac97_source_info source_info[2 * SOURCE_INFO_SIZE];
Home |
Main Index |
Thread Index |
Old Index