xref: /openbsd/sys/arch/macppc/dev/i2svar.h (revision cc5bdd41)
1 /*	$OpenBSD: i2svar.h,v 1.10 2022/10/26 20:19:07 kn Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001,2003 Tsubai Masanari.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #if !defined(I2S_H_INCLUDE)
30 #define I2S_H_INCLUDE
31 
32 #define I2S_DMALIST_MAX		32
33 #define I2S_DMASEG_MAX		NBPG
34 
35 struct i2s_dma {
36 	bus_dmamap_t map;
37 	caddr_t addr;
38 	bus_dma_segment_t segs[I2S_DMALIST_MAX];
39 	int nsegs;
40 	size_t size;
41 	struct i2s_dma *next;
42 };
43 
44 struct i2s_softc {
45 	struct device sc_dev;
46 	int sc_flags;
47 	int sc_node;
48 	u_int sc_baseaddr;
49 
50 	void (*sc_ointr)(void *);	/* dma completion intr handler */
51 	void *sc_oarg;			/* arg for sc_ointr() */
52 	int sc_opages;			/* # of output pages */
53 
54 	void (*sc_iintr)(void *);	/* dma completion intr handler */
55 	void *sc_iarg;			/* arg for sc_iintr() */
56 
57 	u_int sc_record_source;		/* recording source mask */
58 	u_int sc_output_mask;		/* output source mask */
59 
60 	void (*sc_setvolume)(struct i2s_softc *, int, int);
61 	void (*sc_setbass)(struct i2s_softc *, int);
62 	void (*sc_settreble)(struct i2s_softc *, int);
63 	void (*sc_setinput)(struct i2s_softc *, int);
64 
65 	u_char *sc_reg;
66 	void *sc_i2c;
67 
68 	u_int sc_rate;
69 	u_int sc_vol_l;
70 	u_int sc_vol_r;
71 	u_int sc_bass;
72 	u_int sc_treble;
73 	u_int sc_mute;
74 
75 	u_int sc_spkr;			/* amp mute gpio offset */
76 	u_int sc_hp;			/* headphone mute gpio offset */
77 	u_int sc_hp_detect;		/* headphone detect gpio */
78 	u_int sc_hp_active;
79 	u_int sc_line;			/* line out mute gpio offset */
80 	u_int sc_line_detect;		/* line detect gpio */
81 	u_int sc_line_active;
82 	u_int sc_hw_reset;		/* hw reset gpio */
83 
84 
85 	bus_dma_tag_t sc_dmat;
86 	dbdma_regmap_t *sc_odma;
87 	dbdma_regmap_t *sc_idma;
88 	struct dbdma_command *sc_odmacmd, *sc_odmap;
89 	struct dbdma_command *sc_idmacmd, *sc_idmap;
90 	dbdma_t sc_odbdma, sc_idbdma;
91 
92 	struct i2s_dma *sc_dmas;
93 };
94 
95 void i2s_attach(struct device *, struct i2s_softc *, struct confargs *);
96 int i2s_intr(void *);
97 int i2s_open(void *, int);
98 void i2s_close(void *);
99 int i2s_set_params(void *, int, int, struct audio_params *, struct audio_params *);
100 int i2s_round_blocksize(void *, int);
101 int i2s_halt_output(void *);
102 int i2s_halt_input(void *);
103 int i2s_set_port(void *, mixer_ctrl_t *);
104 int i2s_get_port(void *, mixer_ctrl_t *);
105 int i2s_query_devinfo(void *, mixer_devinfo_t *);
106 size_t i2s_round_buffersize(void *, int, size_t);
107 int i2s_trigger_output(void *, void *, void *, int, void (*)(void *),
108     void *, struct audio_params *);
109 int i2s_trigger_input(void *, void *, void *, int, void (*)(void *),
110     void *, struct audio_params *);
111 int i2s_set_rate(struct i2s_softc *, int);
112 void i2s_gpio_init(struct i2s_softc *, int, struct device *);
113 void *i2s_allocm(void *, int, size_t, int, int);
114 int deq_reset(struct i2s_softc *);
115 
116 #endif
117