ad1848var.h revision 1.1
11.1Spk/*	$NetBSD: ad1848var.h,v 1.1 1998/08/25 22:36:40 pk Exp $	*/
21.1Spk
31.1Spk/*
41.1Spk * Copyright (c) 1994 John Brezak
51.1Spk * Copyright (c) 1991-1993 Regents of the University of California.
61.1Spk * All rights reserved.
71.1Spk *
81.1Spk * Redistribution and use in source and binary forms, with or without
91.1Spk * modification, are permitted provided that the following conditions
101.1Spk * are met:
111.1Spk * 1. Redistributions of source code must retain the above copyright
121.1Spk *    notice, this list of conditions and the following disclaimer.
131.1Spk * 2. Redistributions in binary form must reproduce the above copyright
141.1Spk *    notice, this list of conditions and the following disclaimer in the
151.1Spk *    documentation and/or other materials provided with the distribution.
161.1Spk * 3. All advertising materials mentioning features or use of this software
171.1Spk *    must display the following acknowledgement:
181.1Spk *	This product includes software developed by the Computer Systems
191.1Spk *	Engineering Group at Lawrence Berkeley Laboratory.
201.1Spk * 4. Neither the name of the University nor of the Laboratory may be used
211.1Spk *    to endorse or promote products derived from this software without
221.1Spk *    specific prior written permission.
231.1Spk *
241.1Spk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251.1Spk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261.1Spk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271.1Spk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281.1Spk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291.1Spk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301.1Spk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311.1Spk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321.1Spk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331.1Spk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341.1Spk * SUCH DAMAGE.
351.1Spk *
361.1Spk */
371.1Spk
381.1Spk
391.1Spkstruct ad1848_volume {
401.1Spk	u_char	left;
411.1Spk	u_char	right;
421.1Spk};
431.1Spk
441.1Spkstruct ad1848_softc {
451.1Spk	struct	device sc_dev;		/* base device */
461.1Spk	bus_space_tag_t sc_iot;		/* tag */
471.1Spk	bus_space_handle_t sc_ioh;	/* handle */
481.1Spk
491.1Spk	int	(*sc_readreg)__P((struct ad1848_softc *, int));
501.1Spk	void	(*sc_writereg)__P((struct ad1848_softc *, int, int));
511.1Spk#define ADREAD(sc, index)		(*(sc)->sc_readreg)(sc, index)
521.1Spk#define ADWRITE(sc, index, data)	(*(sc)->sc_writereg)(sc, index, data)
531.1Spk
541.1Spk	void	*parent;
551.1Spk
561.1Spk	u_short	sc_locked;		/* true when doing HS DMA  */
571.1Spk	int	sc_mode;		/* half-duplex record/play */
581.1Spk
591.1Spk	/* We keep track of these */
601.1Spk        struct ad1848_volume gains[6];
611.1Spk
621.1Spk	struct ad1848_volume rec_gain;
631.1Spk
641.1Spk	int	rec_port;		/* recording port */
651.1Spk
661.1Spk	/* ad1848 */
671.1Spk	u_char	MCE_bit;
681.1Spk	char	mic_gain_on;		/* CS4231 only */
691.1Spk        char    mute[6];
701.1Spk
711.1Spk	char	*chip_name;
721.1Spk	int	mode;
731.1Spk
741.1Spk	u_int	precision;		/* 8/16 bits */
751.1Spk	int	channels;
761.1Spk
771.1Spk	u_char	speed_bits;
781.1Spk	u_char	format_bits;
791.1Spk	u_char	need_commit;
801.1Spk};
811.1Spk
821.1Spk#define MUTE_LEFT       1
831.1Spk#define MUTE_RIGHT      2
841.1Spk#define MUTE_ALL        (MUTE_LEFT | MUTE_RIGHT)
851.1Spk#define MUTE_MONO       MUTE_ALL
861.1Spk
871.1Spk/* Don't change this ordering without seriously looking around.
881.1Spk   These are indexes into mute[] array and into a register information
891.1Spk   array */
901.1Spk#define AD1848_AUX2_CHANNEL        0
911.1Spk#define AD1848_AUX1_CHANNEL        1
921.1Spk#define AD1848_DAC_CHANNEL         2
931.1Spk#define AD1848_LINE_CHANNEL        3
941.1Spk#define AD1848_MONO_CHANNEL        4
951.1Spk#define AD1848_MONITOR_CHANNEL     5    /* Doesn't seem to be on all later chips */
961.1Spk
971.1Spk/*
981.1Spk * Ad1848 ports
991.1Spk */
1001.1Spk#define MIC_IN_PORT	0
1011.1Spk#define LINE_IN_PORT	1
1021.1Spk#define AUX1_IN_PORT	2
1031.1Spk#define DAC_IN_PORT	3
1041.1Spk
1051.1Spk#ifdef _KERNEL
1061.1Spk
1071.1Spk#define AD1848_KIND_LVL   0
1081.1Spk#define AD1848_KIND_MUTE  1
1091.1Spk#define AD1848_KIND_RECORDGAIN 2
1101.1Spk#define AD1848_KIND_MICGAIN 3
1111.1Spk#define AD1848_KIND_RECORDSOURCE 4
1121.1Spk
1131.1Spktypedef struct ad1848_devmap {
1141.1Spk	int  id;
1151.1Spk	int  kind;
1161.1Spk	int  dev;
1171.1Spk} ad1848_devmap_t;
1181.1Spk
1191.1Spkint	ad_read __P((struct ad1848_softc *, int));
1201.1Spkvoid	ad_write __P((struct ad1848_softc *, int, int));
1211.1Spk
1221.1Spkint     ad1848_mixer_get_port __P((struct ad1848_softc *, ad1848_devmap_t *, int cnt, mixer_ctrl_t *));
1231.1Spkint     ad1848_mixer_set_port __P((struct ad1848_softc *, ad1848_devmap_t *, int, mixer_ctrl_t *));
1241.1Spkvoid	ad1848_attach __P((struct ad1848_softc *));
1251.1Spk
1261.1Spkint	ad1848_open __P((void *, int));
1271.1Spkvoid	ad1848_close __P((void *));
1281.1Spk
1291.1Spkint	ad1848_query_encoding __P((void *, struct audio_encoding *));
1301.1Spkint	ad1848_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
1311.1Spk
1321.1Spkint	ad1848_round_blocksize __P((void *, int));
1331.1Spk
1341.1Spkint	ad1848_commit_settings __P((void *));
1351.1Spk
1361.1Spkint	ad1848_halt_in __P((void *));
1371.1Spkint	ad1848_halt_out __P((void *));
1381.1Spk
1391.1Spkint	ad1848_set_rec_port __P((struct ad1848_softc *, int));
1401.1Spkint	ad1848_get_rec_port __P((struct ad1848_softc *));
1411.1Spk
1421.1Spkint	ad1848_set_channel_gain __P((struct ad1848_softc *, int, struct ad1848_volume *));
1431.1Spkint	ad1848_get_device_gain __P((struct ad1848_softc *, int, struct ad1848_volume *));
1441.1Spkint	ad1848_set_rec_gain __P((struct ad1848_softc *, struct ad1848_volume *));
1451.1Spkint	ad1848_get_rec_gain __P((struct ad1848_softc *, struct ad1848_volume *));
1461.1Spk/* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
1471.1Spkint	ad1848_set_mic_gain __P((struct ad1848_softc *, struct ad1848_volume *));
1481.1Spkint	ad1848_get_mic_gain __P((struct ad1848_softc *, struct ad1848_volume *));
1491.1Spkvoid     ad1848_mute_channel __P((struct ad1848_softc *, int device, int mute));
1501.1Spkint	ad1848_to_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
1511.1Spkint	ad1848_from_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
1521.1Spk
1531.1Spkunsigned long ad1848_round __P((void *, unsigned long));
1541.1Spkint	ad1848_mappage __P((void *, void *, int, int));
1551.1Spk
1561.1Spk#ifdef AUDIO_DEBUG
1571.1Spkvoid ad1848_dump_regs __P((struct ad1848_softc *));
1581.1Spk#endif
1591.1Spk
1601.1Spk#endif
161