Home | History | Annotate | Line # | Download | only in ic
      1 /*	$NetBSD: cs4231var.h,v 1.10 2011/11/23 23:07:32 jmcneill 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  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _DEV_IC_CS4231VAR_H_
     33 #define _DEV_IC_CS4231VAR_H_
     34 
     35 #define AUDIOCS_PROM_NAME	"SUNW,CS4231"
     36 
     37 /*
     38  * List of device memory allocations (see cs4231_malloc/cs4231_free).
     39  */
     40 struct cs_dma {
     41 	struct	cs_dma	*next;
     42 	void *		addr;
     43 	bus_dmamap_t	dmamap;
     44 	bus_dma_segment_t segs[1];
     45 	int		nsegs;
     46 	size_t		size;
     47 };
     48 
     49 
     50 /*
     51  * DMA transfer to/from CS4231.
     52  */
     53 struct cs_transfer {
     54 	int t_active;		/* this transfer is currently active */
     55 	struct cs_dma *t_dma;	/* dma memory to transfer from/to */
     56 	vsize_t t_segsz;	/* size of the segment */
     57 	vsize_t t_blksz;	/* call audio(9) after this many bytes */
     58 	vsize_t t_cnt;		/* how far are we into the segment */
     59 
     60 	void (*t_intr)(void*);	/* audio(9) callback */
     61 	void *t_arg;
     62 
     63 	const char *t_name;	/* for error/debug messages */
     64 
     65 	struct evcnt t_intrcnt;
     66 	struct evcnt t_ierrcnt;
     67 };
     68 
     69 
     70 /*
     71  * Software state, per CS4231 audio chip.
     72  */
     73 struct cs4231_softc {
     74 	struct ad1848_softc sc_ad1848;	/* base device */
     75 
     76 	bus_space_tag_t	sc_bustag;
     77 	bus_dma_tag_t sc_dmatag;
     78 
     79 	struct cs_dma *sc_dmas;		/* allocated dma resources */
     80 
     81 	struct evcnt sc_intrcnt;	/* parent counter */
     82 
     83 	struct cs_transfer sc_playback;
     84 	struct cs_transfer sc_capture;
     85 };
     86 
     87 
     88 /*
     89  * Bus independent code shared by sbus and ebus attachments.
     90  */
     91 void	cs4231_common_attach(struct cs4231_softc *, device_t,
     92 			     bus_space_handle_t);
     93 int	cs4231_transfer_init(struct cs4231_softc *, struct cs_transfer *,
     94 			     bus_addr_t *, bus_size_t *,
     95 			     void *, void *, int, void (*)(void *), void *);
     96 void	cs4231_transfer_advance(struct cs_transfer *,
     97 				bus_addr_t *, bus_size_t *);
     98 
     99 
    100 /*
    101  * Bus independent audio(9) methods.
    102  */
    103 int	cs4231_open(void *, int);
    104 void	cs4231_close(void *);
    105 int	cs4231_getdev(void *, struct audio_device *);
    106 int	cs4231_set_port(void *, mixer_ctrl_t *);
    107 int	cs4231_get_port(void *, mixer_ctrl_t *);
    108 int	cs4231_query_devinfo(void *, mixer_devinfo_t *);
    109 int	cs4231_get_props(void *);
    110 
    111 void	*cs4231_malloc(void *, int, size_t);
    112 void	cs4231_free(void *, void *, size_t);
    113 
    114 #endif /* _DEV_IC_CS4231VAR_H_ */
    115