xref: /openbsd/sys/arch/hppa/gsc/harmonyvar.h (revision 56fd3f56)
1 /*	$OpenBSD: harmonyvar.h,v 1.9 2016/09/19 06:46:43 ratchov Exp $	*/
2 
3 /*
4  * Copyright (c) 2003 Jason L. Wright (jason@thought.net)
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #define	HARMONY_PORT_INPUT_LVL		0
30 #define	HARMONY_PORT_INPUT_OV		1
31 #define	HARMONY_PORT_OUTPUT_LVL		2
32 #define	HARMONY_PORT_OUTPUT_GAIN	3
33 #define	HARMONY_PORT_MONITOR_LVL	4
34 #define	HARMONY_PORT_RECORD_SOURCE	5
35 #define	HARMONY_PORT_OUTPUT_SOURCE	6
36 #define	HARMONY_PORT_INPUT_CLASS	7
37 #define	HARMONY_PORT_OUTPUT_CLASS	8
38 #define	HARMONY_PORT_MONITOR_CLASS	9
39 #define	HARMONY_PORT_RECORD_CLASS	10
40 
41 #define	HARMONY_IN_MIC			0
42 #define	HARMONY_IN_LINE			1
43 
44 #define	HARMONY_OUT_LINE		0
45 #define	HARMONY_OUT_SPEAKER		1
46 #define	HARMONY_OUT_HEADPHONE		2
47 
48 #define	PLAYBACK_EMPTYS			3	/* playback empty buffers */
49 #define	CAPTURE_EMPTYS			3	/* capture empty buffers */
50 
51 struct harmony_volume {
52 	u_char left, right;
53 };
54 
55 struct harmony_empty {
56 	u_int8_t	playback[PLAYBACK_EMPTYS][HARMONY_BUFSIZE];
57 	u_int8_t	capture[CAPTURE_EMPTYS][HARMONY_BUFSIZE];
58 };
59 
60 struct harmony_dma {
61 	struct harmony_dma *d_next;
62 	bus_dmamap_t d_map;
63 	bus_dma_segment_t d_seg;
64 	caddr_t d_kva;
65 	size_t d_size;
66 };
67 
68 struct harmony_channel {
69 	struct harmony_dma *c_current;
70 	bus_size_t c_segsz;
71 	bus_size_t c_cnt;
72 	bus_size_t c_blksz;
73 	bus_addr_t c_lastaddr;
74 	void (*c_intr)(void *);
75 	void *c_intrarg;
76 	bus_addr_t c_theaddr;
77 };
78 
79 struct harmony_softc {
80 	struct device sc_dv;
81 
82 	bus_dma_tag_t sc_dmat;
83 	bus_space_tag_t sc_bt;
84 	bus_space_handle_t sc_bh;
85 	int sc_open;
86 	u_int32_t sc_cntlbits;
87 	int sc_need_commit;
88 	int sc_playback_empty;
89 	bus_addr_t sc_playback_paddrs[PLAYBACK_EMPTYS];
90 	int sc_capture_empty;
91 	bus_addr_t sc_capture_paddrs[CAPTURE_EMPTYS];
92 	bus_dmamap_t sc_empty_map;
93 	bus_dma_segment_t sc_empty_seg;
94 	int sc_empty_rseg;
95 	struct harmony_empty *sc_empty_kva;
96 	struct harmony_dma *sc_dmas;
97 	int sc_playing, sc_capturing;
98 	struct harmony_channel sc_playback, sc_capture;
99 	struct harmony_volume sc_monitor_lvl, sc_input_lvl, sc_output_lvl;
100 	int sc_in_port, sc_out_port, sc_hasulinear8;
101 	int sc_micpreamp, sc_ov, sc_outputgain;
102 	int sc_teleshare;
103 
104 	struct timeout sc_acc_tmo;
105 	u_int32_t sc_acc, sc_acc_num, sc_acc_cnt;
106 };
107 
108 #define	READ_REG(sc, reg)		\
109     bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, (reg))
110 #define	WRITE_REG(sc, reg, val)		\
111     bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg), (val))
112 #define	SYNC_REG(sc, reg, flags)	\
113     bus_space_barrier((sc)->sc_bt, (sc)->sc_bh, (reg), sizeof(u_int32_t), \
114 	(flags))
115