1/* $NetBSD: harmonyvar.h,v 1.6 2011/11/23 23:07:29 jmcneill Exp $ */ 2 3/* $OpenBSD: harmonyvar.h,v 1.8 2003/08/15 13:25:53 mickey Exp $ */ 4 5/* 6 * Copyright (c) 2003 Jason L. Wright (jason@thought.net) 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 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. 17 * 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. 29 */ 30 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 42 43#define HARMONY_IN_MIC 0 44#define HARMONY_IN_LINE 1 45 46#define HARMONY_OUT_LINE 0 47#define HARMONY_OUT_SPEAKER 1 48#define HARMONY_OUT_HEADPHONE 2 49 50#define PLAYBACK_EMPTYS 3 /* playback empty buffers */ 51#define CAPTURE_EMPTYS 3 /* capture empty buffers */ 52 53struct harmony_volume { 54 u_char left, right; 55}; 56 57struct harmony_empty { 58 uint8_t playback[PLAYBACK_EMPTYS][HARMONY_BUFSIZE]; 59 uint8_t capture[CAPTURE_EMPTYS][HARMONY_BUFSIZE]; 60}; 61 62struct harmony_dma { 63 struct harmony_dma *d_next; 64 bus_dmamap_t d_map; 65 bus_dma_segment_t d_seg; 66 void *d_kva; 67 size_t d_size; 68}; 69 70struct harmony_channel { 71 struct harmony_dma *c_current; 72 bus_size_t c_segsz; 73 bus_size_t c_cnt; 74 bus_size_t c_blksz; 75 bus_addr_t c_lastaddr; 76 void (*c_intr)(void *); 77 void *c_intrarg; 78 bus_addr_t c_theaddr; 79}; 80 81struct harmony_softc { 82 device_t sc_dv; 83 kmutex_t sc_lock; 84 kmutex_t sc_intr_lock; 85 struct audio_device sc_audev; 86 87 bus_dma_tag_t sc_dmat; 88 bus_space_tag_t sc_bt; 89 bus_space_handle_t sc_bh; 90 int sc_open; 91 uint32_t sc_cntlbits; 92 int sc_need_commit; 93 int sc_playback_empty; 94 bus_addr_t sc_playback_paddrs[PLAYBACK_EMPTYS]; 95 int sc_capture_empty; 96 bus_addr_t sc_capture_paddrs[CAPTURE_EMPTYS]; 97 bus_dmamap_t sc_empty_map; 98 bus_dma_segment_t sc_empty_seg; 99 int sc_empty_rseg; 100 struct harmony_empty *sc_empty_kva; 101 struct harmony_dma *sc_dmas; 102 int sc_playing, sc_capturing; 103 struct harmony_channel sc_playback, sc_capture; 104 struct harmony_volume sc_monitor_lvl, sc_input_lvl, sc_output_lvl; 105 int sc_in_port, sc_out_port, sc_hasulinear8; 106 int sc_micpreamp, sc_ov, sc_outputgain; 107 int sc_teleshare; 108 109 krndsource_t sc_rnd_source; 110 struct callout sc_acc_tmo; 111 uint32_t sc_acc, sc_acc_num, sc_acc_cnt; 112}; 113 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), \ 120 (flags)) 121