xref: /netbsd-src/sys/dev/ic/cs4231var.h (revision 8a962f23f21e491a16f05bc9dacdb84f8b05ac43)
1*8a962f23Sjmcneill /*	$NetBSD: cs4231var.h,v 1.10 2011/11/23 23:07:32 jmcneill Exp $	*/
267cbdf56Smrg 
367cbdf56Smrg /*-
467cbdf56Smrg  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
567cbdf56Smrg  * All rights reserved.
667cbdf56Smrg  *
767cbdf56Smrg  * This code is derived from software contributed to The NetBSD Foundation
867cbdf56Smrg  * by Paul Kranenburg.
967cbdf56Smrg  *
1067cbdf56Smrg  * Redistribution and use in source and binary forms, with or without
1167cbdf56Smrg  * modification, are permitted provided that the following conditions
1267cbdf56Smrg  * are met:
1367cbdf56Smrg  * 1. Redistributions of source code must retain the above copyright
1467cbdf56Smrg  *    notice, this list of conditions and the following disclaimer.
1567cbdf56Smrg  * 2. Redistributions in binary form must reproduce the above copyright
1667cbdf56Smrg  *    notice, this list of conditions and the following disclaimer in the
1767cbdf56Smrg  *    documentation and/or other materials provided with the distribution.
1867cbdf56Smrg  *
1967cbdf56Smrg  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2067cbdf56Smrg  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2167cbdf56Smrg  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2267cbdf56Smrg  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2367cbdf56Smrg  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2467cbdf56Smrg  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2567cbdf56Smrg  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2667cbdf56Smrg  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2767cbdf56Smrg  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2867cbdf56Smrg  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2967cbdf56Smrg  * POSSIBILITY OF SUCH DAMAGE.
3067cbdf56Smrg  */
3167cbdf56Smrg 
32a05702eaSuwe #ifndef _DEV_IC_CS4231VAR_H_
33a05702eaSuwe #define _DEV_IC_CS4231VAR_H_
34a05702eaSuwe 
35a05702eaSuwe #define AUDIOCS_PROM_NAME	"SUNW,CS4231"
36a05702eaSuwe 
37a05702eaSuwe /*
38a05702eaSuwe  * List of device memory allocations (see cs4231_malloc/cs4231_free).
39a05702eaSuwe  */
40a05702eaSuwe struct cs_dma {
41a05702eaSuwe 	struct	cs_dma	*next;
4253524e44Schristos 	void *		addr;
43a05702eaSuwe 	bus_dmamap_t	dmamap;
44a05702eaSuwe 	bus_dma_segment_t segs[1];
45a05702eaSuwe 	int		nsegs;
46a05702eaSuwe 	size_t		size;
47a05702eaSuwe };
48a05702eaSuwe 
49a05702eaSuwe 
50a05702eaSuwe /*
51a05702eaSuwe  * DMA transfer to/from CS4231.
52a05702eaSuwe  */
53a05702eaSuwe struct cs_transfer {
54a05702eaSuwe 	int t_active;		/* this transfer is currently active */
55a05702eaSuwe 	struct cs_dma *t_dma;	/* dma memory to transfer from/to */
56a05702eaSuwe 	vsize_t t_segsz;	/* size of the segment */
57a05702eaSuwe 	vsize_t t_blksz;	/* call audio(9) after this many bytes */
58a05702eaSuwe 	vsize_t t_cnt;		/* how far are we into the segment */
59a05702eaSuwe 
60a05702eaSuwe 	void (*t_intr)(void*);	/* audio(9) callback */
61a05702eaSuwe 	void *t_arg;
62a05702eaSuwe 
63a05702eaSuwe 	const char *t_name;	/* for error/debug messages */
64a05702eaSuwe 
65a05702eaSuwe 	struct evcnt t_intrcnt;
66a05702eaSuwe 	struct evcnt t_ierrcnt;
67a05702eaSuwe };
68a05702eaSuwe 
69a05702eaSuwe 
7067cbdf56Smrg /*
7167cbdf56Smrg  * Software state, per CS4231 audio chip.
7267cbdf56Smrg  */
7367cbdf56Smrg struct cs4231_softc {
7467cbdf56Smrg 	struct ad1848_softc sc_ad1848;	/* base device */
75a05702eaSuwe 
7667cbdf56Smrg 	bus_space_tag_t	sc_bustag;
7767cbdf56Smrg 	bus_dma_tag_t sc_dmatag;
7867cbdf56Smrg 
79a05702eaSuwe 	struct cs_dma *sc_dmas;		/* allocated dma resources */
8067cbdf56Smrg 
81a05702eaSuwe 	struct evcnt sc_intrcnt;	/* parent counter */
82a05702eaSuwe 
83a05702eaSuwe 	struct cs_transfer sc_playback;
84a05702eaSuwe 	struct cs_transfer sc_capture;
8567cbdf56Smrg };
8667cbdf56Smrg 
87a05702eaSuwe 
88a05702eaSuwe /*
89a05702eaSuwe  * Bus independent code shared by sbus and ebus attachments.
90a05702eaSuwe  */
914418f775Schristos void	cs4231_common_attach(struct cs4231_softc *, device_t,
924418f775Schristos 			     bus_space_handle_t);
93a05702eaSuwe int	cs4231_transfer_init(struct cs4231_softc *, struct cs_transfer *,
94a05702eaSuwe 			     bus_addr_t *, bus_size_t *,
95a05702eaSuwe 			     void *, void *, int, void (*)(void *), void *);
96a05702eaSuwe void	cs4231_transfer_advance(struct cs_transfer *,
97a05702eaSuwe 				bus_addr_t *, bus_size_t *);
98a05702eaSuwe 
99a05702eaSuwe 
100a05702eaSuwe /*
101a05702eaSuwe  * Bus independent audio(9) methods.
102a05702eaSuwe  */
103a05702eaSuwe int	cs4231_open(void *, int);
104a05702eaSuwe void	cs4231_close(void *);
105a05702eaSuwe int	cs4231_getdev(void *, struct audio_device *);
106a05702eaSuwe int	cs4231_set_port(void *, mixer_ctrl_t *);
107a05702eaSuwe int	cs4231_get_port(void *, mixer_ctrl_t *);
108a05702eaSuwe int	cs4231_query_devinfo(void *, mixer_devinfo_t *);
109a05702eaSuwe int	cs4231_get_props(void *);
110a05702eaSuwe 
111*8a962f23Sjmcneill void	*cs4231_malloc(void *, int, size_t);
112*8a962f23Sjmcneill void	cs4231_free(void *, void *, size_t);
113a05702eaSuwe 
114a05702eaSuwe #endif /* _DEV_IC_CS4231VAR_H_ */
115