1 /* $OpenBSD: i2svar.h,v 1.5 2008/10/29 00:04:14 jakemsr Exp $ */ 2 /* $Id: i2svar.h,v 1.5 2008/10/29 00:04:14 jakemsr Exp $ */ 3 4 /*- 5 * Copyright (c) 2001,2003 Tsubai Masanari. 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 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 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 WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #if !defined(I2S_H_INCLUDE) 31 #define I2S_H_INCLUDE 32 33 #define I2S_DMALIST_MAX 32 34 #define I2S_DMASEG_MAX NBPG 35 36 struct i2s_dma { 37 bus_dmamap_t map; 38 caddr_t addr; 39 bus_dma_segment_t segs[I2S_DMALIST_MAX]; 40 int nsegs; 41 size_t size; 42 struct i2s_dma *next; 43 }; 44 45 struct i2s_softc { 46 struct device sc_dev; 47 int sc_flags; 48 int sc_node; 49 u_int sc_baseaddr; 50 51 void (*sc_ointr)(void *); /* dma completion intr handler */ 52 void *sc_oarg; /* arg for sc_ointr() */ 53 int sc_opages; /* # of output pages */ 54 55 void (*sc_iintr)(void *); /* dma completion intr handler */ 56 void *sc_iarg; /* arg for sc_iintr() */ 57 58 u_int sc_record_source; /* recording source mask */ 59 u_int sc_output_mask; /* output source mask */ 60 61 void (*sc_setvolume)(struct i2s_softc *, int, int); 62 void (*sc_setbass)(struct i2s_softc *, int); 63 void (*sc_settreble)(struct i2s_softc *, int); 64 void (*sc_setinput)(struct i2s_softc *, int); 65 66 u_char *sc_reg; 67 void *sc_i2c; 68 69 u_int sc_rate; 70 u_int sc_vol_l; 71 u_int sc_vol_r; 72 u_int sc_bass; 73 u_int sc_treble; 74 75 bus_dma_tag_t sc_dmat; 76 dbdma_regmap_t *sc_odma; 77 dbdma_regmap_t *sc_idma; 78 struct dbdma_command *sc_odmacmd, *sc_odmap; 79 struct dbdma_command *sc_idmacmd, *sc_idmap; 80 dbdma_t sc_odbdma, sc_idbdma; 81 82 struct i2s_dma *sc_dmas; 83 }; 84 85 void i2s_attach(struct device *, struct i2s_softc *, struct confargs *); 86 int i2s_intr(void *); 87 int i2s_open(void *, int); 88 void i2s_close(void *); 89 int i2s_query_encoding(void *, struct audio_encoding *); 90 int i2s_set_params(void *, int, int, struct audio_params *, struct audio_params *); 91 void i2s_get_default_params(struct audio_params *); 92 int i2s_round_blocksize(void *, int); 93 int i2s_halt_output(void *); 94 int i2s_halt_input(void *); 95 int i2s_set_port(void *, mixer_ctrl_t *); 96 int i2s_get_port(void *, mixer_ctrl_t *); 97 int i2s_query_devinfo(void *, mixer_devinfo_t *); 98 size_t i2s_round_buffersize(void *, int, size_t); 99 paddr_t i2s_mappage(void *, void *, off_t, int); 100 int i2s_get_props(void *); 101 int i2s_trigger_output(void *, void *, void *, int, void (*)(void *), 102 void *, struct audio_params *); 103 int i2s_trigger_input(void *, void *, void *, int, void (*)(void *), 104 void *, struct audio_params *); 105 int i2s_set_rate(struct i2s_softc *, int); 106 void i2s_gpio_init(struct i2s_softc *, int, struct device *); 107 void *i2s_allocm(void *, int, size_t, int, int); 108 int deq_reset(struct i2s_softc *); 109 110 #endif 111