Home | History | Annotate | Line # | Download | only in ic
tms320av110var.h revision 1.12
      1 /*	$NetBSD: tms320av110var.h,v 1.12 2012/10/27 17:18:23 chs Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Ignatios Souvatzis.
      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 /*
     33  * Machine independent definitions, declarations and data structures for
     34  * access to the TMS320AV110 data sheet.
     35  *
     36  * Currently, only minimum support for audio output. For audio/video
     37  * synchronization, more is needed.
     38  */
     39 
     40 #ifndef _TMS320AV110_VAR_H_
     41 #define _TMS320AV110_VAR_H_
     42 
     43 #include <sys/bus.h>
     44 
     45 /* softc */
     46 
     47 struct tav_softc {
     48 	device_t	sc_dev;
     49 	kmutex_t	sc_lock;
     50 	kmutex_t	sc_intr_lock;
     51 	kcondvar_t	sc_cv;
     52 
     53 	bus_space_tag_t sc_iot;
     54 	bus_space_handle_t sc_ioh;
     55 
     56 	/* above audio callback function */
     57 	void		(*sc_intr)(void *);
     58 	void		*sc_intrarg;
     59 	int		sc_bsize;
     60 
     61 	/* below audio interrupt acknowledge function. Ignored if NULL */
     62 	void		(*sc_intack)(struct tav_softc *);
     63 
     64 	/* initialization from below */
     65 
     66 	uint8_t		sc_pcm_div;	/* passed in */
     67 	uint8_t		sc_pcm_ord;	/* passed in */
     68 	uint8_t		sc_pcm_18;	/* passed in */
     69 	uint8_t		sc_dif;	/* passed in */
     70 };
     71 
     72 /* prototypes */
     73 
     74 void tms320av110_attach_mi(struct tav_softc *);
     75 int tms320av110_intr(void *);
     76 
     77 static void tav_write_short(bus_space_tag_t, bus_space_handle_t,
     78     bus_size_t, uint16_t);
     79 
     80 /* access functions/macros: */
     81 /* XXX shouldn't these be in the reg.h file? */
     82 
     83 #define tav_read_byte(ioh, iot, off) bus_space_read_1(ioh, iot, off)
     84 
     85 #define tav_read_short(ioh, iot, off)	(		\
     86 	bus_space_read_1((ioh), (iot), (off))	|	\
     87 	bus_space_read_1((ioh), (iot), (off)+1) << 8)
     88 
     89 #define tav_read_long(ioh, iot, off)	(		\
     90 	bus_space_read_1((ioh), (iot), (off))	|	\
     91 	bus_space_read_1((ioh), (iot), (off)+1) << 8 |	\
     92 	bus_space_read_1((ioh), (iot), (off)+2) << 16 |	\
     93 	bus_space_read_1((ioh), (iot), (off)+3))
     94 
     95 #define tav_read_time(ioh, iot, off)	(		\
     96 	bus_space_read_1((ioh), (iot), (off))	|	\
     97 	bus_space_read_1((ioh), (iot), (off)+1) << 8 |	\
     98 	bus_space_read_1((ioh), (iot), (off)+2) << 16 |	\
     99 	bus_space_read_1((ioh), (iot), (off)+3) << 24 |	\
    100 	bus_space_read_1((ioh), (iot), (off)+4) << 32)
    101 
    102 #define tav_write_byte(ioh, iot, off, v) bus_space_write_1(ioh, iot, off, v)
    103 
    104 static __inline void
    105 tav_write_short(bus_space_tag_t iot, bus_space_handle_t ioh,
    106     bus_size_t off, uint16_t val)
    107 {
    108 
    109 	bus_space_write_1(iot, ioh, off+1, (val)>>8);
    110 	bus_space_write_1(iot, ioh, off,  (uint8_t)val);
    111 }
    112 
    113 #endif /* _TMS320AV110_VAR_H_ */
    114