Home | History | Annotate | Line # | Download | only in ic
cs4231var.h revision 1.2
      1 /*	$NetBSD: cs4231var.h,v 1.2 2002/03/12 04:48:28 uwe Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Paul Kranenburg.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _DEV_IC_CS4231VAR_H_
     40 #define _DEV_IC_CS4231VAR_H_
     41 
     42 #define AUDIOCS_PROM_NAME	"SUNW,CS4231"
     43 
     44 /*
     45  * List of device memory allocations (see cs4231_malloc/cs4231_free).
     46  */
     47 struct cs_dma {
     48 	struct	cs_dma	*next;
     49 	caddr_t		addr;
     50 	bus_dmamap_t	dmamap;
     51 	bus_dma_segment_t segs[1];
     52 	int		nsegs;
     53 	size_t		size;
     54 };
     55 
     56 
     57 /*
     58  * DMA transfer to/from CS4231.
     59  */
     60 struct cs_transfer {
     61 	int t_active;		/* this transfer is currently active */
     62 	struct cs_dma *t_dma;	/* dma memory to transfer from/to */
     63 	vsize_t t_segsz;	/* size of the segment */
     64 	vsize_t t_blksz;	/* call audio(9) after this many bytes */
     65 	vsize_t t_cnt;		/* how far are we into the segment */
     66 
     67 	void (*t_intr)(void*);	/* audio(9) callback */
     68 	void *t_arg;
     69 
     70 	const char *t_name;	/* for error/debug messages */
     71 
     72 	struct evcnt t_intrcnt;
     73 	struct evcnt t_ierrcnt;
     74 };
     75 
     76 
     77 /*
     78  * Software state, per CS4231 audio chip.
     79  */
     80 struct cs4231_softc {
     81 	struct ad1848_softc sc_ad1848;	/* base device */
     82 
     83 	bus_space_tag_t	sc_bustag;
     84 	bus_dma_tag_t sc_dmatag;
     85 
     86 	int sc_open;			/* single use device */
     87 	struct cs_dma *sc_dmas;		/* allocated dma resources */
     88 
     89 	struct evcnt sc_intrcnt;	/* parent counter */
     90 
     91 	struct cs_transfer sc_playback;
     92 	struct cs_transfer sc_capture;
     93 };
     94 
     95 
     96 /*
     97  * Bus independent code shared by sbus and ebus attachments.
     98  */
     99 void	cs4231_common_attach(struct cs4231_softc *, bus_space_handle_t);
    100 int	cs4231_transfer_init(struct cs4231_softc *, struct cs_transfer *,
    101 			     bus_addr_t *, bus_size_t *,
    102 			     void *, void *, int, void (*)(void *), void *);
    103 void	cs4231_transfer_advance(struct cs_transfer *,
    104 				bus_addr_t *, bus_size_t *);
    105 
    106 
    107 /*
    108  * Bus independent audio(9) methods.
    109  */
    110 int	cs4231_open(void *, int);
    111 void	cs4231_close(void *);
    112 size_t	cs4231_round_buffersize(void *, int, size_t);
    113 int	cs4231_round_blocksize(void *, int);
    114 int	cs4231_getdev(void *, struct audio_device *);
    115 int	cs4231_set_port(void *, mixer_ctrl_t *);
    116 int	cs4231_get_port(void *, mixer_ctrl_t *);
    117 int	cs4231_query_devinfo(void *, mixer_devinfo_t *);
    118 int	cs4231_get_props(void *);
    119 
    120 void	*cs4231_malloc(void *, int, size_t, int, int);
    121 void	cs4231_free(void *, void *, int);
    122 
    123 #endif /* _DEV_IC_CS4231VAR_H_ */
    124