1 /* $OpenBSD: esavar.h,v 1.3 2024/10/22 21:50:02 jsg Exp $ */ 2 /* $NetBSD: esavar.h,v 1.4 2002/03/16 14:34:01 jmcneill Exp $ */ 3 4 /* 5 * Copyright (c) 2001, 2002 Jared D. McNeill <jmcneill@invisible.yi.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 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 WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 /* 30 * ESS Allegro-1 / Maestro3 Audio Driver 31 * 32 * Based on the FreeBSD maestro3 driver 33 * 34 */ 35 36 /* 37 * Number of simultaneous voices 38 * 39 * NOTE: The current code attaches audio0 thru audioESA_NUM_VOICES-1 40 * to this driver, and a lot of people probably don't want that. 41 * So, we'll default to 1 but we'll allow for the possibility of 42 * more. 43 * 44 * The current MINISRC image limits us to a maximum of 4 simultaneous voices. 45 */ 46 #ifndef ESA_NUM_VOICES 47 #define ESA_NUM_VOICES 1 48 #endif 49 50 #define KERNADDR(p) ((void *)((p)->addr)) 51 #define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr) 52 53 #define ESA_MINRATE 8000 54 #define ESA_MAXRATE 48000 55 56 struct esa_list { 57 int currlen; 58 int mem_addr; 59 int max; 60 int indexmap[ESA_NUM_VOICES * 2]; 61 }; 62 63 struct esa_dma { 64 bus_dmamap_t map; 65 caddr_t addr; 66 bus_dma_segment_t segs[1]; 67 int nsegs; 68 size_t size; 69 struct esa_dma *next; 70 }; 71 72 struct esa_channel { 73 int active; 74 int data_offset; 75 int index; 76 size_t bufsize; 77 int blksize; 78 int pos; 79 void *buf; 80 u_int32_t start; 81 u_int32_t count; 82 83 /* mode settings */ 84 struct audio_params mode; 85 86 void (*intr)(void *); 87 void *arg; 88 }; 89 90 struct esa_voice { 91 struct device *parent; /* pointer to our parent */ 92 struct esa_channel play; 93 struct esa_channel rec; 94 struct esa_dma *dma; 95 int inlist; 96 int index; /* 0: play, 1: record */ 97 }; 98 99 struct esa_softc { 100 struct device sc_dev; 101 bus_space_tag_t sc_iot; 102 bus_space_handle_t sc_ioh; 103 bus_addr_t sc_iob; 104 bus_size_t sc_ios; 105 106 pcitag_t sc_tag; 107 pci_chipset_tag_t sc_pct; 108 bus_dma_tag_t sc_dmat; 109 pcireg_t sc_pcireg; 110 111 void *sc_ih; 112 113 struct ac97_codec_if *codec_if; 114 struct ac97_host_if host_if; 115 enum ac97_host_flags codec_flags; 116 117 struct device *sc_audiodev[ESA_NUM_VOICES]; 118 119 struct esa_voice voice[ESA_NUM_VOICES]; 120 struct esa_dma *sc_dmas; 121 int count; 122 123 /* timer management */ 124 int sc_ntimers; 125 126 /* packed list structures */ 127 struct esa_list mixer_list; 128 struct esa_list adc1_list; 129 struct esa_list dma_list; 130 struct esa_list msrc_list; 131 132 int type; /* Allegro-1 or Maestro 3? */ 133 int delay1, delay2; 134 135 u_int16_t *savemem; 136 }; 137