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