Home | History | Annotate | Line # | Download | only in ic
ad1848var.h revision 1.17.4.1
      1  1.17.4.1  jmcneill /*	$NetBSD: ad1848var.h,v 1.17.4.1 2011/11/19 21:49:36 jmcneill Exp $	*/
      2       1.1        pk 
      3       1.4   mycroft /*-
      4  1.17.4.1  jmcneill  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
      5       1.4   mycroft  * All rights reserved.
      6       1.4   mycroft  *
      7       1.4   mycroft  * This code is derived from software contributed to The NetBSD Foundation
      8       1.4   mycroft  * by Ken Hornstein and John Kohl.
      9       1.4   mycroft  *
     10       1.4   mycroft  * Redistribution and use in source and binary forms, with or without
     11       1.4   mycroft  * modification, are permitted provided that the following conditions
     12       1.4   mycroft  * are met:
     13       1.4   mycroft  * 1. Redistributions of source code must retain the above copyright
     14       1.4   mycroft  *    notice, this list of conditions and the following disclaimer.
     15       1.4   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.4   mycroft  *    notice, this list of conditions and the following disclaimer in the
     17       1.4   mycroft  *    documentation and/or other materials provided with the distribution.
     18       1.4   mycroft  *
     19       1.4   mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.4   mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.4   mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.4   mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.4   mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.4   mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.4   mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.4   mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.4   mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.4   mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.4   mycroft  * POSSIBILITY OF SUCH DAMAGE.
     30       1.4   mycroft  */
     31       1.1        pk /*
     32       1.1        pk  * Copyright (c) 1994 John Brezak
     33       1.1        pk  * Copyright (c) 1991-1993 Regents of the University of California.
     34       1.1        pk  * All rights reserved.
     35       1.1        pk  *
     36       1.1        pk  * Redistribution and use in source and binary forms, with or without
     37       1.1        pk  * modification, are permitted provided that the following conditions
     38       1.1        pk  * are met:
     39       1.1        pk  * 1. Redistributions of source code must retain the above copyright
     40       1.1        pk  *    notice, this list of conditions and the following disclaimer.
     41       1.1        pk  * 2. Redistributions in binary form must reproduce the above copyright
     42       1.1        pk  *    notice, this list of conditions and the following disclaimer in the
     43       1.1        pk  *    documentation and/or other materials provided with the distribution.
     44       1.1        pk  * 3. All advertising materials mentioning features or use of this software
     45       1.1        pk  *    must display the following acknowledgement:
     46       1.1        pk  *	This product includes software developed by the Computer Systems
     47       1.1        pk  *	Engineering Group at Lawrence Berkeley Laboratory.
     48       1.1        pk  * 4. Neither the name of the University nor of the Laboratory may be used
     49       1.1        pk  *    to endorse or promote products derived from this software without
     50       1.1        pk  *    specific prior written permission.
     51       1.1        pk  *
     52       1.1        pk  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     53       1.1        pk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54       1.1        pk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55       1.1        pk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     56       1.1        pk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57       1.1        pk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58       1.1        pk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59       1.1        pk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60       1.1        pk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61       1.1        pk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62       1.1        pk  * SUCH DAMAGE.
     63       1.1        pk  *
     64       1.1        pk  */
     65       1.1        pk 
     66       1.1        pk 
     67      1.10    martin #define MUTE_LEFT       1
     68      1.10    martin #define MUTE_RIGHT      2
     69      1.12      kent #define MUTE_ALL	(MUTE_LEFT | MUTE_RIGHT)
     70      1.10    martin #define MUTE_MONO       MUTE_ALL
     71      1.10    martin 
     72      1.10    martin #define WAVE_MUTE0	1		/* force mute (overrides UNMUTE1) */
     73      1.10    martin #define WAVE_UNMUTE1	2		/* unmute (overrides MUTE2) */
     74      1.10    martin #define WAVE_MUTE2	4		/* weak mute */
     75      1.10    martin #define WAVE_MUTE2_INIT	0		/* init and MUTE2 */
     76      1.10    martin 
     77      1.10    martin /*
     78      1.10    martin  * Don't change this ordering without seriously looking around.
     79      1.10    martin  * These are indexes into mute[] array and into a register
     80      1.10    martin  * information array.
     81      1.10    martin  */
     82      1.10    martin #define AD1848_AUX2_CHANNEL	0
     83      1.10    martin #define AD1848_AUX1_CHANNEL	1
     84      1.10    martin #define AD1848_DAC_CHANNEL	2
     85      1.10    martin #define AD1848_LINE_CHANNEL	3
     86      1.10    martin #define AD1848_MONO_CHANNEL	4
     87      1.10    martin #define AD1848_OUT_CHANNEL	5
     88      1.10    martin #define AD1848_MONITOR_CHANNEL	6 /* Doesn't seem to be on all later chips */
     89      1.10    martin 
     90      1.10    martin #define	AD1848_NUM_CHANNELS	7
     91      1.10    martin 
     92       1.1        pk struct ad1848_volume {
     93       1.1        pk 	u_char	left;
     94       1.1        pk 	u_char	right;
     95       1.1        pk };
     96       1.1        pk 
     97       1.1        pk struct ad1848_softc {
     98      1.17  christos 	device_t sc_dev;		/* base device */
     99  1.17.4.1  jmcneill 	kmutex_t sc_lock;
    100  1.17.4.1  jmcneill 	kmutex_t sc_intr_lock;
    101       1.1        pk 	bus_space_tag_t sc_iot;		/* tag */
    102       1.1        pk 	bus_space_handle_t sc_ioh;	/* handle */
    103       1.1        pk 
    104      1.12      kent 	int	(*sc_readreg)(struct ad1848_softc *, int);
    105      1.12      kent 	void	(*sc_writereg)(struct ad1848_softc *, int, int);
    106       1.1        pk #define ADREAD(sc, index)		(*(sc)->sc_readreg)(sc, index)
    107       1.1        pk #define ADWRITE(sc, index, data)	(*(sc)->sc_writereg)(sc, index, data)
    108       1.1        pk 
    109       1.1        pk 	void	*parent;
    110       1.2        pk 
    111       1.1        pk 	/* We keep track of these */
    112      1.10    martin 	struct ad1848_volume gains[AD1848_NUM_CHANNELS];
    113       1.1        pk 	struct ad1848_volume rec_gain;
    114       1.1        pk 
    115       1.1        pk 	int	rec_port;		/* recording port */
    116       1.1        pk 
    117       1.1        pk 	/* ad1848 */
    118       1.1        pk 	u_char	MCE_bit;
    119       1.1        pk 	char	mic_gain_on;		/* CS4231 only */
    120      1.12      kent 	char    mute[AD1848_NUM_CHANNELS];
    121       1.1        pk 
    122      1.13  christos 	const char	*chip_name;
    123       1.1        pk 	int	mode;
    124       1.8     itohy 	int	is_ad1845;
    125       1.2        pk 
    126       1.1        pk 	u_int	precision;		/* 8/16 bits */
    127       1.1        pk 	int	channels;
    128       1.2        pk 
    129       1.1        pk 	u_char	speed_bits;
    130       1.1        pk 	u_char	format_bits;
    131       1.1        pk 	u_char	need_commit;
    132       1.6     itohy 
    133       1.6     itohy 	u_char	wave_mute_status;
    134       1.6     itohy 	int	open_mode;
    135       1.1        pk };
    136       1.1        pk 
    137       1.1        pk /*
    138       1.2        pk  * Ad1848 registers.
    139       1.1        pk  */
    140       1.1        pk #define MIC_IN_PORT	0
    141       1.1        pk #define LINE_IN_PORT	1
    142       1.1        pk #define AUX1_IN_PORT	2
    143       1.1        pk #define DAC_IN_PORT	3
    144       1.1        pk 
    145      1.12      kent #define AD1848_KIND_LVL		0
    146      1.12      kent #define AD1848_KIND_MUTE	1
    147      1.12      kent #define AD1848_KIND_RECORDGAIN	2
    148      1.12      kent #define AD1848_KIND_MICGAIN	3
    149       1.1        pk #define AD1848_KIND_RECORDSOURCE 4
    150       1.1        pk 
    151       1.1        pk typedef struct ad1848_devmap {
    152       1.1        pk 	int  id;
    153       1.1        pk 	int  kind;
    154       1.1        pk 	int  dev;
    155       1.1        pk } ad1848_devmap_t;
    156       1.1        pk 
    157       1.6     itohy #ifdef _KERNEL
    158       1.6     itohy 
    159      1.12      kent int	ad_read(struct ad1848_softc *, int);
    160      1.12      kent int	ad_xread(struct ad1848_softc *, int);
    161      1.12      kent void	ad_write(struct ad1848_softc *, int, int);
    162      1.12      kent void	ad_xwrite(struct ad1848_softc *, int, int);
    163      1.12      kent 
    164      1.12      kent void	ad1848_attach(struct ad1848_softc *);
    165      1.12      kent void	ad1848_reset(struct ad1848_softc *);
    166      1.12      kent int	ad1848_open(void *, int);
    167      1.12      kent void	ad1848_close(void *);
    168      1.12      kent 
    169      1.15    martin int	ad1848_mixer_get_port(struct ad1848_softc *, const ad1848_devmap_t *,
    170      1.12      kent 	    int, mixer_ctrl_t *);
    171      1.15    martin int	ad1848_mixer_set_port(struct ad1848_softc *, const ad1848_devmap_t *,
    172      1.12      kent 	    int, mixer_ctrl_t *);
    173      1.12      kent int	ad1848_set_speed(struct ad1848_softc *, u_int *);
    174      1.12      kent void	ad1848_mute_wave_output(struct ad1848_softc *, int, int);
    175      1.12      kent int	ad1848_query_encoding(void *, struct audio_encoding *);
    176      1.12      kent int	ad1848_set_params(void *, int, int, audio_params_t *,
    177      1.12      kent 	    audio_params_t *, stream_filter_list_t *,
    178      1.12      kent 	    stream_filter_list_t *);
    179      1.12      kent int	ad1848_round_blocksize(void *, int, int, const audio_params_t *);
    180      1.12      kent int	ad1848_commit_settings(void *);
    181      1.12      kent int	ad1848_set_rec_port(struct ad1848_softc *, int);
    182      1.12      kent int	ad1848_get_rec_port(struct ad1848_softc *);
    183      1.12      kent int	ad1848_set_channel_gain(struct ad1848_softc *, int,
    184      1.12      kent 	    struct ad1848_volume *);
    185      1.12      kent int	ad1848_get_device_gain(struct ad1848_softc *, int,
    186      1.12      kent 	    struct ad1848_volume *);
    187      1.12      kent int	ad1848_set_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
    188      1.12      kent int	ad1848_get_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
    189       1.1        pk /* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
    190      1.12      kent int	ad1848_set_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
    191      1.12      kent int	ad1848_get_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
    192      1.12      kent void	ad1848_mute_channel(struct ad1848_softc *, int, int);
    193      1.12      kent int	ad1848_to_vol(mixer_ctrl_t *, struct ad1848_volume *);
    194      1.12      kent int	ad1848_from_vol(mixer_ctrl_t *, struct ad1848_volume *);
    195  1.17.4.1  jmcneill void	ad1848_init_locks(struct ad1848_softc *, int);
    196  1.17.4.1  jmcneill void	ad1848_destroy_locks(struct ad1848_softc *);
    197      1.12      kent 
    198      1.12      kent int	ad1848_halt_output(void *);
    199      1.12      kent int	ad1848_halt_input(void *);
    200      1.12      kent paddr_t	ad1848_mappage(void *, void *, off_t, int);
    201  1.17.4.1  jmcneill void	ad1848_get_locks(void *, kmutex_t **, kmutex_t **);
    202       1.1        pk 
    203       1.1        pk #ifdef AUDIO_DEBUG
    204      1.12      kent void	ad1848_dump_regs(struct ad1848_softc *);
    205       1.1        pk #endif
    206       1.1        pk 
    207       1.1        pk #endif
    208