Home | History | Annotate | Line # | Download | only in isa
ymvar.h revision 1.4
      1 /*	$NetBSD: ymvar.h,v 1.4 1999/10/05 03:46:08 itohy Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by ITOH Yasufumi.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * Copyright (c) 1994 John Brezak
     41  * Copyright (c) 1991-1993 Regents of the University of California.
     42  * All rights reserved.
     43  *
     44  * Redistribution and use in source and binary forms, with or without
     45  * modification, are permitted provided that the following conditions
     46  * are met:
     47  * 1. Redistributions of source code must retain the above copyright
     48  *    notice, this list of conditions and the following disclaimer.
     49  * 2. Redistributions in binary form must reproduce the above copyright
     50  *    notice, this list of conditions and the following disclaimer in the
     51  *    documentation and/or other materials provided with the distribution.
     52  * 3. All advertising materials mentioning features or use of this software
     53  *    must display the following acknowledgement:
     54  *	This product includes software developed by the Computer Systems
     55  *	Engineering Group at Lawrence Berkeley Laboratory.
     56  * 4. Neither the name of the University nor of the Laboratory may be used
     57  *    to endorse or promote products derived from this software without
     58  *    specific prior written permission.
     59  *
     60  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     61  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     62  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     63  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     64  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     65  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     66  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     67  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     68  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     69  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     70  * SUCH DAMAGE.
     71  *
     72  */
     73 
     74 /*
     75  *  Original code from OpenBSD.
     76  */
     77 
     78 /*
     79  * Mixer devices
     80  */
     81 #define YM_DAC_LVL		0
     82 #define YM_MIDI_LVL		1
     83 #define YM_CD_LVL		2
     84 #define YM_LINE_LVL		3
     85 #define YM_SPEAKER_LVL		4
     86 #define YM_MIC_LVL		5
     87 #define YM_MONITOR_LVL		6
     88 #define YM_DAC_MUTE		7
     89 #define YM_MIDI_MUTE		8
     90 #define YM_CD_MUTE		9
     91 #define YM_LINE_MUTE		10
     92 #define YM_SPEAKER_MUTE		11
     93 #define YM_MIC_MUTE		12
     94 #define YM_MONITOR_MUTE		13
     95 
     96 #define YM_REC_LVL		14
     97 #define YM_RECORD_SOURCE	15
     98 
     99 #define YM_OUTPUT_LVL		16
    100 #define YM_OUTPUT_MUTE		17
    101 
    102 #define YM_MASTER_EQMODE	18
    103 #define YM_MASTER_TREBLE	19
    104 #define YM_MASTER_BASS		20
    105 #define YM_MASTER_WIDE		21
    106 
    107 #ifndef AUDIO_NO_POWER_CTL
    108 #define YM_PWR_MODE		22
    109 #define YM_PWR_TIMEOUT		23
    110 #endif
    111 
    112 /* Classes - don't change this without looking at mixer_classes array */
    113 #ifdef AUDIO_NO_POWER_CTL
    114 #define YM_CLASS_TOP		22
    115 #else
    116 #define YM_CLASS_TOP		24
    117 #endif
    118 #define YM_INPUT_CLASS		(YM_CLASS_TOP + 0)
    119 #define YM_RECORD_CLASS		(YM_CLASS_TOP + 1)
    120 #define YM_OUTPUT_CLASS		(YM_CLASS_TOP + 2)
    121 #define YM_MONITOR_CLASS	(YM_CLASS_TOP + 3)
    122 #define YM_EQ_CLASS		(YM_CLASS_TOP + 4)
    123 #ifndef AUDIO_NO_POWER_CTL
    124 #define YM_PWR_CLASS		(YM_CLASS_TOP + 5)
    125 #endif
    126 
    127 /* XXX should be in <sys/audioio.h> */
    128 #define AudioNmode		"mode"
    129 #define AudioNdesktop		"desktop"
    130 #define AudioNlaptop		"laptop"
    131 #define AudioNsubnote		"subnote"
    132 #define AudioNhifi		"hifi"
    133 
    134 #ifndef AUDIO_NO_POWER_CTL
    135 #define AudioCpower		"power"
    136 #define AudioNpower		"power"
    137 #define AudioNtimeout		"timeout"
    138 #define AudioNpowerdown		"powerdown"
    139 #define AudioNpowersave		"powersave"
    140 #define AudioNnosave		"nosave"
    141 #endif
    142 
    143 
    144 struct ym_softc {
    145 	struct	ad1848_isa_softc sc_ad1848;
    146 #define ym_irq		sc_ad1848.sc_irq
    147 #define ym_playdrq	sc_ad1848.sc_playdrq
    148 #define ym_recdrq	sc_ad1848.sc_recdrq
    149 
    150 	bus_space_tag_t sc_iot;		/* tag */
    151 	bus_space_handle_t sc_ioh;	/* handle */
    152 	isa_chipset_tag_t sc_ic;
    153 
    154 	bus_space_handle_t sc_controlioh;
    155 	bus_space_handle_t sc_opl_ioh;
    156 	bus_space_handle_t sc_sb_ioh;	/* only used to disable it */
    157 
    158 	int  master_mute, mic_mute;
    159 	struct ad1848_volume master_gain;
    160 	u_int8_t mic_gain;
    161 
    162 	u_int8_t sc_version;		/* hardware version */
    163 
    164 	/* 3D encehamcement */
    165 	u_int8_t sc_eqmode;
    166 	struct ad1848_volume sc_treble, sc_bass, sc_wide;
    167 #define YM_EQ_OFF(v)	\
    168 	((v)->left < (AUDIO_MAX_GAIN + 1) / (SA3_3D_BITS + 1) &&	\
    169 	(v)->right < (AUDIO_MAX_GAIN + 1) / (SA3_3D_BITS + 1))
    170 
    171 	struct device *sc_audiodev;
    172 
    173 #if NMPU_YM > 0
    174 	bus_space_handle_t sc_mpu_ioh;
    175 	struct device *sc_mpudev;
    176 #endif
    177 
    178 #ifndef AUDIO_NO_POWER_CTL
    179 	enum ym_pow_mode {
    180 		YM_POWER_POWERDOWN, YM_POWER_POWERSAVE, YM_POWER_NOSAVE
    181 	} sc_pow_mode;
    182 	int	sc_pow_timeout;
    183 
    184 	u_int8_t sc_codec_scan[0x20];
    185 #define YM_SAVE_REG_MAX	SA3_HVOL_INTR_CNF
    186 	u_int8_t sc_sa3_scan[YM_SAVE_REG_MAX + 1];
    187 
    188 	u_int16_t sc_on_blocks;
    189 	u_int16_t sc_turning_off;
    190 
    191 	int	sc_in_power_ctl;
    192 #define YM_POWER_CTL_INUSE	1
    193 #define YM_POWER_CTL_WANTED	2
    194 #endif /* not AUDIO_NO_POWER_CTL */
    195 };
    196 
    197 #ifndef AUDIO_NO_POWER_CTL
    198 /* digital */
    199 #define YM_POWER_CODEC_P	SA3_DPWRDWN_WSS_P
    200 #define YM_POWER_CODEC_R	SA3_DPWRDWN_WSS_R
    201 #define YM_POWER_OPL3		SA3_DPWRDWN_FM
    202 #define YM_POWER_MPU401		SA3_DPWRDWN_MPU
    203 #define YM_POWER_JOYSTICK	SA3_DPWRDWN_JOY
    204 /* analog */
    205 #define YM_POWER_3D		(SA3_APWRDWN_WIDE << 8)
    206 #define YM_POWER_CODEC_DA	(SA3_APWRDWN_DA << 8)
    207 #define YM_POWER_CODEC_AD	(SA3_APWRDWN_AD << 8)
    208 #define YM_POWER_OPL3_DA	(SA3_APWRDWN_FMDAC << 8)
    209 /* pseudo */
    210 #define YM_POWER_CODEC_CTL	0x8000
    211 
    212 #define YM_POWER_CODEC_DIGITAL	\
    213 		(YM_POWER_CODEC_P | YM_POWER_CODEC_R | YM_POWER_CODEC_CTL)
    214 /* 3D enhance is passive */
    215 #define YM_POWER_ACTIVE		(0xffff & ~YM_POWER_3D)
    216 
    217 #ifdef _KERNEL
    218 void	ym_power_ctl __P((struct ym_softc *, int, int));
    219 #endif
    220 #endif /* not AUDIO_NO_POWER_CTL */
    221 
    222 #ifdef _KERNEL
    223 void	ym_attach __P((struct ym_softc *));
    224 #endif
    225