1/*	$OpenBSD: am7930var.h,v 1.6 2022/10/26 20:19:07 kn Exp $	*/
2/*	$NetBSD: am7930var.h,v 1.10 2005/01/15 15:19:52 kent Exp $	*/
3
4/*
5 * Copyright (c) 1992, 1993
6 *	The Regents of the University of California.  All rights reserved.
7 *
8 * This software was developed by the Computer Systems Engineering group
9 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10 * contributed to Berkeley.
11 *
12 * All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement:
14 *	This product includes software developed by the University of
15 *	California, Lawrence Berkeley Laboratory.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 *    notice, this list of conditions and the following disclaimer in the
24 *    documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of the University nor the names of its contributors
26 *    may be used to endorse or promote products derived from this software
27 *    without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 *	@(#)bsd_audiovar.h	8.1 (Berkeley) 6/11/93
42 */
43
44struct am7930_softc;
45
46struct am7930_glue {
47	uint8_t	(*codec_iread)(struct am7930_softc *sc, int);
48	void	(*codec_iwrite)(struct am7930_softc *sc, int, uint8_t);
49	uint16_t	(*codec_iread16)(struct am7930_softc *sc, int);
50	void	(*codec_iwrite16)(struct am7930_softc *sc, int, uint16_t);
51	void	(*onopen)(struct am7930_softc *sc);
52	void	(*onclose)(struct am7930_softc *sc);
53	int	precision;
54};
55
56struct am7930_softc {
57	struct device sc_dev;	/* base device */
58	int	sc_open;
59	int	sc_locked;
60
61	uint8_t	sc_rlevel;	/* record level */
62	uint8_t	sc_plevel;	/* play level */
63	uint8_t	sc_mlevel;	/* monitor level */
64	uint8_t	sc_out_port;	/* output port */
65	uint8_t	sc_mic_mute;
66
67	struct am7930_glue *sc_glue;
68};
69
70extern int     am7930debug;
71
72void	am7930_init(struct am7930_softc *, int);
73
74#define AM7930_IWRITE(x,y,z)	(*(x)->sc_glue->codec_iwrite)((x),(y),(z))
75#define AM7930_IREAD(x,y)	(*(x)->sc_glue->codec_iread)((x),(y))
76#define AM7930_IWRITE16(x,y,z)	(*(x)->sc_glue->codec_iwrite16)((x),(y),(z))
77#define AM7930_IREAD16(x,y)	(*(x)->sc_glue->codec_iread16)((x),(y))
78
79#define AUDIOAMD_POLL_MODE	0
80#define AUDIOAMD_DMA_MODE	1
81
82/*
83 * audio channel definitions.
84 */
85
86#define AUDIOAMD_SPEAKER_VOL	0	/* speaker volume */
87#define AUDIOAMD_HEADPHONES_VOL	1	/* headphones volume */
88#define AUDIOAMD_OUTPUT_CLASS	2
89
90#define AUDIOAMD_MONITOR_VOL	3	/* monitor input volume */
91#define AUDIOAMD_MONITOR_OUTPUT	4	/* output selector */
92#define AUDIOAMD_MONITOR_CLASS	5
93
94#define AUDIOAMD_MIC_VOL	6	/* microphone volume */
95#define AUDIOAMD_MIC_MUTE	7
96#define AUDIOAMD_INPUT_CLASS	8
97
98#define AUDIOAMD_RECORD_SOURCE	9	/* source selector */
99#define AUDIOAMD_RECORD_CLASS	10
100
101/*
102 * audio(9) MI callbacks from upper-level audio layer.
103 */
104
105struct audio_params;
106
107int	am7930_open(void *, int);
108void	am7930_close(void *);
109int	am7930_set_params(void *, int, int, struct audio_params *,
110	    struct audio_params *);
111int	am7930_commit_settings(void *);
112int	am7930_round_blocksize(void *, int);
113int	am7930_halt_output(void *);
114int	am7930_halt_input(void *);
115int	am7930_set_port(void *, mixer_ctrl_t *);
116int	am7930_get_port(void *, mixer_ctrl_t *);
117int	am7930_query_devinfo(void *, mixer_devinfo_t *);
118