1 /* $NetBSD: harmonyvar.h,v 1.3 2007/03/04 05:59:51 christos Exp $ */
3 /* $OpenBSD: harmonyvar.h,v 1.8 2003/08/15 13:25:53 mickey Exp $ */
6 * Copyright (c) 2003 Jason L. Wright (jason@thought.net)
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #define HARMONY_PORT_INPUT_LVL 0
32 #define HARMONY_PORT_INPUT_OV 1
33 #define HARMONY_PORT_OUTPUT_LVL 2
34 #define HARMONY_PORT_OUTPUT_GAIN 3
35 #define HARMONY_PORT_MONITOR_LVL 4
36 #define HARMONY_PORT_RECORD_SOURCE 5
37 #define HARMONY_PORT_OUTPUT_SOURCE 6
38 #define HARMONY_PORT_INPUT_CLASS 7
39 #define HARMONY_PORT_OUTPUT_CLASS 8
40 #define HARMONY_PORT_MONITOR_CLASS 9
41 #define HARMONY_PORT_RECORD_CLASS 10
43 #define HARMONY_IN_MIC 0
44 #define HARMONY_IN_LINE 1
46 #define HARMONY_OUT_LINE 0
47 #define HARMONY_OUT_SPEAKER 1
48 #define HARMONY_OUT_HEADPHONE 2
50 #define PLAYBACK_EMPTYS 3 /* playback empty buffers */
51 #define CAPTURE_EMPTYS 3 /* capture empty buffers */
53 struct harmony_volume
{
57 struct harmony_empty
{
58 uint8_t playback
[PLAYBACK_EMPTYS
][HARMONY_BUFSIZE
];
59 uint8_t capture
[CAPTURE_EMPTYS
][HARMONY_BUFSIZE
];
63 struct harmony_dma
*d_next
;
65 bus_dma_segment_t d_seg
;
70 struct harmony_channel
{
71 struct harmony_dma
*c_current
;
75 bus_addr_t c_lastaddr
;
76 void (*c_intr
)(void *);
81 struct harmony_softc
{
83 struct audio_device sc_audev
;
85 bus_dma_tag_t sc_dmat
;
86 bus_space_tag_t sc_bt
;
87 bus_space_handle_t sc_bh
;
91 int sc_playback_empty
;
92 bus_addr_t sc_playback_paddrs
[PLAYBACK_EMPTYS
];
94 bus_addr_t sc_capture_paddrs
[CAPTURE_EMPTYS
];
95 bus_dmamap_t sc_empty_map
;
96 bus_dma_segment_t sc_empty_seg
;
98 struct harmony_empty
*sc_empty_kva
;
99 struct harmony_dma
*sc_dmas
;
100 int sc_playing
, sc_capturing
;
101 struct harmony_channel sc_playback
, sc_capture
;
102 struct harmony_volume sc_monitor_lvl
, sc_input_lvl
, sc_output_lvl
;
103 int sc_in_port
, sc_out_port
, sc_hasulinear8
;
104 int sc_micpreamp
, sc_ov
, sc_outputgain
;
108 rndsource_element_t sc_rnd_source
;
109 struct callout sc_acc_tmo
;
110 uint32_t sc_acc
, sc_acc_num
, sc_acc_cnt
;
114 #define READ_REG(sc, reg) \
115 bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, (reg))
116 #define WRITE_REG(sc, reg, val) \
117 bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg), (val))
118 #define SYNC_REG(sc, reg, flags) \
119 bus_space_barrier((sc)->sc_bt, (sc)->sc_bh, (reg), sizeof(uint32_t), \