xref: /netbsd-src/sys/dev/pci/cxdtvvar.h (revision fb95eabd74c965e490597bf91f39a01341be3517)
1 /* $NetBSD: cxdtvvar.h,v 1.4 2011/08/09 01:42:24 jmcneill Exp $ */
2 
3 /*
4  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _DEV_PCI_CXDTVVAR_H
30 #define _DEV_PCI_CXDTVVAR_H
31 
32 #include <dev/pci/pcivar.h>
33 #include <dev/pci/pcireg.h>
34 #include <dev/pci/cxdtv_boards.h>
35 
36 #define	KERNADDR(p)	((void *)((p)->addr))
37 #define	DMAADDR(p)	((p)->map->dm_segs[0].ds_addr)
38 
39 #ifdef CXDTV_DEBUG
40 #define CX_DPRINTF(x)   if (cxdtv_mpeg_debug) printf x
41 static int cxdtv_mpeg_debug = 0;
42 #else
43 #define CX_DPRINTF(x)
44 #endif
45 
46 struct cxdtv_sram_ch {
47 	uint32_t		csc_cmds;
48 	uint32_t		csc_iq;
49 	uint32_t		csc_iqsz;
50 	uint32_t		csc_cdt;
51 	uint32_t		csc_cdtsz;
52 	uint32_t		csc_fifo;
53 	uint32_t		csc_fifosz;
54 	uint32_t		csc_risc;
55 	uint32_t		csc_riscsz;
56 	uint32_t		csc_ptr1;
57 	uint32_t		csc_ptr2;
58 	uint32_t		csc_cnt1;
59 	uint32_t		csc_cnt2;
60 };
61 
62 struct cxdtv_dma {
63 	bus_dmamap_t		map;
64 	void *			addr;
65 	bus_dma_segment_t	segs[1];
66 	int			nsegs;
67 	size_t			size;
68 	struct cxdtv_dma *	next;
69 };
70 
71 struct cxdtv_softc {
72 	device_t		sc_dev;
73 	device_t		sc_dtvdev;
74 
75 	pci_chipset_tag_t	sc_pc;
76 
77 	bus_space_tag_t		sc_memt;
78 	bus_space_handle_t	sc_memh;
79 	bus_size_t		sc_mems;
80 	bus_dma_tag_t		sc_dmat;
81 
82 	void *			sc_ih;
83 
84 	struct i2c_controller	sc_i2c;
85 	kmutex_t		sc_i2c_buslock;
86 
87 	struct cxdtv_sram_ch	sc_mpeg_sch;
88 
89 	struct cxdtv_dma *	sc_dma;
90 	struct cxdtv_dma *	sc_tsbuf;
91 
92 	uint32_t *		sc_riscbuf;
93 	uint32_t		sc_riscbufsz;
94 
95 	void			*sc_tuner;
96 	void 			*sc_demod;
97 
98 	void			(*sc_dtvsubmitcb)(void *,
99 				    const struct dtv_payload *);
100 	void			*sc_dtvsubmitarg;
101 
102 	const struct cxdtv_board *sc_board;
103 	pci_vendor_id_t		sc_vendor;
104 	pci_product_id_t	sc_product;
105 };
106 
107 #endif /* !_DEV_PCI_CXDTVVAR_H */
108