xref: /netbsd-src/sys/arch/arm/xscale/pxa2x0_i2s.h (revision e622eac459adf11c2e710d7a4de0f05510bbbe61)
1 /*	$NetBSD: pxa2x0_i2s.h,v 1.6 2019/05/08 13:40:14 isaki Exp $	*/
2 /*	$OpenBSD: pxa2x0_i2s.h,v 1.3 2006/04/04 11:45:40 pascoe Exp $	*/
3 
4 /*
5  * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _PXA2X0_I2S_H_
21 #define _PXA2X0_I2S_H_
22 
23 #include <sys/bus.h>
24 
25 struct pxa2x0_i2s_dma;
26 struct audio_params;
27 
28 struct pxa2x0_i2s_softc {
29 	kmutex_t *sc_intr_lock;
30 
31 	bus_space_tag_t sc_iot;
32 	bus_space_handle_t sc_ioh;
33 	bus_size_t sc_size;
34 	bus_dma_tag_t sc_dmat;
35 
36 	int sc_open;
37 	uint32_t sc_sadiv;
38 
39 	struct pxa2x0_i2s_dma *sc_dmas;
40 
41 	/* Dummy DMA segment which points to the I2S SADR */
42 	bus_dma_segment_t sc_dr;
43 
44 	/* PCM Output (Tx) state */
45 	struct pxa2x0_i2s_dma *sc_txdma;
46 	void (*sc_txfunc)(void *);
47 	void *sc_txarg;
48 
49 	/* PCM Input (Rx) state */
50 	struct pxa2x0_i2s_dma *sc_rxdma;
51 	void (*sc_rxfunc)(void *);
52 	void *sc_rxarg;
53 };
54 
55 void	pxa2x0_i2s_init(struct pxa2x0_i2s_softc *sc);
56 int	pxa2x0_i2s_attach_sub(struct pxa2x0_i2s_softc *);
57 int	pxa2x0_i2s_detach_sub(struct pxa2x0_i2s_softc *);
58 void	pxa2x0_i2s_open(struct pxa2x0_i2s_softc *);
59 void	pxa2x0_i2s_close(struct pxa2x0_i2s_softc *);
60 void	pxa2x0_i2s_write(struct pxa2x0_i2s_softc *, uint32_t);
61 
62 void	pxa2x0_i2s_setspeed(struct pxa2x0_i2s_softc *, u_int);
63 
64 void *	pxa2x0_i2s_allocm(void *, int, size_t);
65 void	pxa2x0_i2s_freem(void  *, void *, size_t);
66 int	pxa2x0_i2s_round_blocksize(void *, int, int, const struct audio_params *);
67 size_t	pxa2x0_i2s_round_buffersize(void *, int, size_t);
68 int	pxa2x0_i2s_halt_output(void *);
69 int	pxa2x0_i2s_halt_input(void *);
70 int	pxa2x0_i2s_start_output(void *, void *, int, void (*)(void *), void *);
71 int	pxa2x0_i2s_start_input(void *, void *, int, void (*)(void *), void *);
72 
73 #endif
74