Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys/dev/ic Pull up revisions 1.13-1.19 (requested by sk...
details: https://anonhg.NetBSD.org/src/rev/01b0117e2802
branches: netbsd-1-5
changeset: 491611:01b0117e2802
user: he <he%NetBSD.org@localhost>
date: Thu May 03 20:59:27 2001 +0000
description:
Pull up revisions 1.13-1.19 (requested by skrll and he):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
diffstat:
sys/dev/ic/ac97.c | 312 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 209 insertions(+), 103 deletions(-)
diffs (truncated from 621 to 300 lines):
diff -r cac8e750c63f -r 01b0117e2802 sys/dev/ic/ac97.c
--- a/sys/dev/ic/ac97.c Thu May 03 20:59:01 2001 +0000
+++ b/sys/dev/ic/ac97.c Thu May 03 20:59:27 2001 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: ac97.c,v 1.11.2.1 2000/09/03 22:47:53 soren Exp $ */
-/* $OpenBSD: ac97.c,v 1.2 1999/09/21 16:06:27 csapuntz Exp $ */
+/* $NetBSD: ac97.c,v 1.11.2.2 2001/05/03 20:59:27 he Exp $ */
+/* $OpenBSD: ac97.c,v 1.8 2000/07/19 09:01:35 csapuntz Exp $ */
/*
- * Copyright (c) 1999 Constantine Sapuntzakis
+ * Copyright (c) 1999, 2000 Constantine Sapuntzakis
*
* Author: Constantine Sapuntzakis <csapuntz%stanford.edu@localhost>
*
@@ -14,18 +14,21 @@
* 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.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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
@@ -71,24 +74,24 @@
#include <dev/ic/ac97reg.h>
#include <dev/ic/ac97var.h>
-static struct audio_mixer_enum ac97_on_off = { 2,
+static const struct audio_mixer_enum ac97_on_off = { 2,
{ { { AudioNoff } , 0 },
{ { AudioNon } , 1 } }};
-static struct audio_mixer_enum ac97_mic_select = { 2,
+static const struct audio_mixer_enum ac97_mic_select = { 2,
{ { { AudioNmicrophone "0" },
0 },
{ { AudioNmicrophone "1" },
1 } }};
-static struct audio_mixer_enum ac97_mono_select = { 2,
+static const struct audio_mixer_enum ac97_mono_select = { 2,
{ { { AudioNmixerout },
0 },
{ { AudioNmicrophone },
1 } }};
-static struct audio_mixer_enum ac97_source = { 8,
+static const struct audio_mixer_enum ac97_source = { 8,
{ { { AudioNmicrophone } , 0 },
{ { AudioNcd }, 1 },
{ { "video" }, 2 },
@@ -98,25 +101,30 @@
{ { AudioNmixerout AudioNmono }, 6 },
{ { "phone" }, 7 }}};
-static struct audio_mixer_value ac97_volume_stereo = { { AudioNvolume },
+/*
+ * Due to different values for each source that uses these structures,
+ * the ac97_query_devinfo function sets delta in mixer_devinfo_t using
+ * ac97_source_info.bits.
+ */
+static const struct audio_mixer_value ac97_volume_stereo = { { AudioNvolume },
2 };
-
-static struct audio_mixer_value ac97_volume_mono = { { AudioNvolume },
+static const 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;
+const struct ac97_source_info {
+ const char *class;
+ const char *device;
+ const char *qualifier;
int type;
- void *info;
+ const void *info;
int info_size;
u_int8_t reg;
+ u_int16_t default_value;
u_int8_t bits:3;
u_int8_t ofs:4;
u_int8_t mute:1;
@@ -135,106 +143,106 @@
/* Stereo master volume*/
{ AudioCoutputs, AudioNmaster, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_MASTER_VOLUME, 5, 0, 1,
+ AC97_REG_MASTER_VOLUME, 0x8000, 5, 0, 1,
},
/* Mono volume */
{ AudioCoutputs, AudioNmono, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_mono),
- AC97_REG_MASTER_VOLUME_MONO, 6, 0, 1,
+ AC97_REG_MASTER_VOLUME_MONO, 0x8000, 6, 0, 1,
},
{ AudioCoutputs, AudioNmono,AudioNsource, AUDIO_MIXER_ENUM,
WRAP(ac97_mono_select),
- AC97_REG_GP, 1, 9, 0,
+ AC97_REG_GP, 0x0000, 1, 9, 0,
},
/* Headphone volume */
{ AudioCoutputs, AudioNheadphone, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_HEADPHONE_VOLUME, 6, 0, 1,
+ AC97_REG_HEADPHONE_VOLUME, 0x8000, 6, 0, 1,
},
/* Tone */
{ AudioCoutputs, "tone", NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_MASTER_TONE, 4, 0, 0,
+ AC97_REG_MASTER_TONE, 0x0f0f, 4, 0, 0,
},
/* PC Beep Volume */
{ AudioCinputs, AudioNspeaker, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_mono),
- AC97_REG_PCBEEP_VOLUME, 4, 1, 1,
+ AC97_REG_PCBEEP_VOLUME, 0x0000, 4, 1, 1,
},
/* Phone */
{ AudioCinputs, "phone", NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_mono),
- AC97_REG_PHONE_VOLUME, 5, 0, 1,
+ AC97_REG_PHONE_VOLUME, 0x8008, 5, 0, 1,
},
/* Mic Volume */
{ AudioCinputs, AudioNmicrophone, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_mono),
- AC97_REG_MIC_VOLUME, 5, 0, 1,
+ AC97_REG_MIC_VOLUME, 0x8008, 5, 0, 1,
},
{ AudioCinputs, AudioNmicrophone, AudioNpreamp, AUDIO_MIXER_ENUM,
WRAP(ac97_on_off),
- AC97_REG_MIC_VOLUME, 1, 6, 0,
+ AC97_REG_MIC_VOLUME, 0x8008, 1, 6, 0,
},
{ AudioCinputs, AudioNmicrophone, AudioNsource, AUDIO_MIXER_ENUM,
WRAP(ac97_mic_select),
- AC97_REG_GP, 1, 8, 0,
+ AC97_REG_GP, 0x0000, 1, 8, 0,
},
/* Line in Volume */
{ AudioCinputs, AudioNline, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_LINEIN_VOLUME, 5, 0, 1,
+ AC97_REG_LINEIN_VOLUME, 0x8808, 5, 0, 1,
},
/* CD Volume */
{ AudioCinputs, AudioNcd, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_CD_VOLUME, 5, 0, 1,
+ AC97_REG_CD_VOLUME, 0x8808, 5, 0, 1,
},
/* Video Volume */
{ AudioCinputs, "video", NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_VIDEO_VOLUME, 5, 0, 1,
+ AC97_REG_VIDEO_VOLUME, 0x8808, 5, 0, 1,
},
/* AUX volume */
{ AudioCinputs, AudioNaux, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_AUX_VOLUME, 5, 0, 1,
+ AC97_REG_AUX_VOLUME, 0x8808, 5, 0, 1,
},
/* PCM out volume */
{ AudioCinputs, AudioNdac, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_PCMOUT_VOLUME, 5, 0, 1,
+ AC97_REG_PCMOUT_VOLUME, 0x8808, 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,
+ AC97_REG_RECORD_SELECT, 0x0000, 3, 0, 0,
},
/* Record Gain */
{ AudioCrecord, AudioNvolume, NULL, AUDIO_MIXER_VALUE,
WRAP(ac97_volume_stereo),
- AC97_REG_RECORD_GAIN, 4, 0, 1,
+ AC97_REG_RECORD_GAIN, 0x8000, 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,
+ AC97_REG_RECORD_GAIN_MIC, 0x8000, 4, 0, 1, 1,
},
/* */
{ AudioCoutputs, AudioNloudness, NULL, AUDIO_MIXER_ENUM,
WRAP(ac97_on_off),
- AC97_REG_GP, 1, 12, 0,
+ AC97_REG_GP, 0x0000, 1, 12, 0,
},
{ AudioCoutputs, AudioNspatial, NULL, AUDIO_MIXER_ENUM,
WRAP(ac97_on_off),
- AC97_REG_GP, 1, 13, 0,
+ AC97_REG_GP, 0x0000, 1, 13, 0,
},
{ AudioCoutputs, AudioNspatial, "center", AUDIO_MIXER_VALUE,
WRAP(ac97_volume_mono),
- AC97_REG_3D_CONTROL, 4, 8, 0, 1,
+ AC97_REG_3D_CONTROL, 0x0000, 4, 8, 0, 1,
},
{ AudioCoutputs, AudioNspatial, "depth", AUDIO_MIXER_VALUE,
WRAP(ac97_volume_mono),
- AC97_REG_3D_CONTROL, 4, 0, 0, 1,
+ AC97_REG_3D_CONTROL, 0x0000, 4, 0, 0, 1,
},
/* Missing features: Simulated Stereo, POP, Loopback mode */
@@ -248,12 +256,16 @@
*/
struct ac97_softc {
- struct ac97_codec_if codecIf;
+ struct ac97_codec_if codec_if;
- struct ac97_host_if *hostIf;
+ struct ac97_host_if *host_if;
struct ac97_source_info source_info[2 * SOURCE_INFO_SIZE];
int num_source_info;
+
+ enum ac97_host_flags host_flags;
+
+ u_int16_t shadow_reg[128];
};
int ac97_mixer_get_port __P((struct ac97_codec_if *self, mixer_ctrl_t *cp));
@@ -261,33 +273,52 @@
int ac97_query_devinfo __P((struct ac97_codec_if *self, mixer_devinfo_t *));
int ac97_get_portnum_by_name __P((struct ac97_codec_if *, char *, char *,
char *));
+void ac97_restore_shadow __P((struct ac97_codec_if *self));
struct ac97_codec_if_vtbl ac97civ = {
ac97_mixer_get_port,
ac97_mixer_set_port,
ac97_query_devinfo,
- ac97_get_portnum_by_name
+ ac97_get_portnum_by_name,
+ ac97_restore_shadow,
};
static const struct ac97_codecid {
u_int32_t id;
const char *name;
} ac97codecid[] = {
+ { AC97_CODEC_ID('A', 'D', 'S', 64), "Analog Devices AD1881" },
{ AC97_CODEC_ID('A', 'K', 'M', 0), "Asahi Kasei AK4540" },
-#if 0
+ { AC97_CODEC_ID('A', 'K', 'M', 2), "Asahi Kasei AK4543" },
{ AC97_CODEC_ID('C', 'R', 'Y', 0), "Crystal CS4297" },
-#endif
{ AC97_CODEC_ID('C', 'R', 'Y', 3), "Crystal CS4297" },
{ AC97_CODEC_ID('C', 'R', 'Y', 19), "Crystal CS4297A" },
- { 0x83847600, "SigmaTel STAC????" },
- { 0x83847604, "SigmaTel STAC9701/3/4/5" },
- { 0x83847605, "SigmaTel STAC9704" },
- { 0x83847608, "SigmaTel STAC9708" },
- { 0x83847609, "SigmaTel STAC9721" },
- { 0, NULL }
+ { AC97_CODEC_ID('C', 'R', 'Y', 35), "Crystal CS4298", },
+ { AC97_CODEC_ID('C', 'R', 'Y', 43), "Crystal CS4294", },
Home |
Main Index |
Thread Index |
Old Index