xref: /netbsd-src/sys/dev/pci/tgavar.h (revision 95d875fb90b1458e4f1de6950286ddcd6644bc61)
1 /* $NetBSD: tgavar.h,v 1.4 1998/08/18 08:23:46 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 #include <dev/pci/tgareg.h>
31 #include <dev/rcons/raster.h>
32 #include <dev/wscons/wsconsio.h>
33 #include <dev/wscons/wscons_raster.h>
34 
35 struct tga_devconfig;
36 struct fbcmap;
37 struct fbcursor;
38 struct fbcurpos;
39 
40 struct tga_ramdac_conf {
41 	char	*tgar_name;
42 	void	(*tgar_init) __P((struct tga_devconfig *, int));
43 	int	(*tgar_intr) __P((void *));
44 	int	(*tgar_set_cmap) __P((struct tga_devconfig *,
45 		    struct wsdisplay_cmap *));
46 	int	(*tgar_get_cmap) __P((struct tga_devconfig *,
47 		    struct wsdisplay_cmap *));
48 	int	(*tgar_set_cursor) __P((struct tga_devconfig *,
49 		    struct wsdisplay_cursor *));
50 	int	(*tgar_get_cursor) __P((struct tga_devconfig *,
51 		    struct wsdisplay_cursor *));
52 	int	(*tgar_set_curpos) __P((struct tga_devconfig *,
53 		    struct wsdisplay_curpos *));
54 	int	(*tgar_get_curpos) __P((struct tga_devconfig *,
55 		    struct wsdisplay_curpos *));
56 	int	(*tgar_get_curmax) __P((struct tga_devconfig *,
57 		    struct wsdisplay_curpos *));
58 
59 	/* Only called from the TGA built-in cursor handling code. */
60 	int	(*tgar_check_curcmap) __P((struct tga_devconfig *,
61 		    struct wsdisplay_cursor *));
62 	void	(*tgar_set_curcmap) __P((struct tga_devconfig *,
63 		    struct wsdisplay_cursor *));
64 	int	(*tgar_get_curcmap) __P((struct tga_devconfig *,
65 		    struct wsdisplay_cursor *));
66 };
67 
68 struct tga_conf {
69 	char	    *tgac_name;		/* name for this board type */
70 
71 	const struct tga_ramdac_conf
72 		    *tgac_ramdac;	/* the RAMDAC type; see above */
73 	int	    tgac_phys_depth;	/* physical frame buffer depth */
74 	vsize_t   tgac_cspace_size;	/* core space size */
75 	vsize_t   tgac_vvbr_units;	/* what '1' in the VVBR means */
76 
77 	int	    tgac_ndbuf;		/* number of display buffers */
78 	vaddr_t tgac_dbuf[2];	/* display buffer offsets/addresses */
79 	vsize_t   tgac_dbufsz[2];	/* display buffer sizes */
80 
81 	int	    tgac_nbbuf;		/* number of display buffers */
82 	vaddr_t tgac_bbuf[2];	/* back buffer offsets/addresses */
83 	vsize_t   tgac_bbufsz[2];	/* back buffer sizes */
84 };
85 
86 struct tga_devconfig {
87 	bus_space_tag_t dc_memt;
88 	pci_chipset_tag_t dc_pc;
89 
90 	pcitag_t   	 dc_pcitag;	/* PCI tag */
91 	bus_addr_t	 dc_pcipaddr;	/* PCI phys addr. */
92 
93 	tga_reg_t   *dc_regs;		/* registers; XXX: need aliases */
94 
95 	int	    dc_tga_type;	/* the device type; see below */
96 	const struct tga_conf *dc_tgaconf; /* device buffer configuration */
97 
98 	vaddr_t dc_vaddr;		/* memory space virtual base address */
99 	paddr_t dc_paddr;		/* memory space physical base address */
100 
101 	int	    dc_wid;		/* width of frame buffer */
102 	int	    dc_ht;		/* height of frame buffer */
103 	int	    dc_rowbytes;	/* bytes in a FB scan line */
104 
105 	vaddr_t dc_videobase;	/* base of flat frame buffer */
106 
107 	struct raster	dc_raster;	/* raster description */
108 	struct rcons	dc_rcons;	/* raster blitter control info */
109 
110 	int	    dc_blanked;		/* currently had video disabled */
111 	void	    *dc_ramdac_private; /* RAMDAC private storage */
112 };
113 
114 struct tga_softc {
115 	struct	device sc_dev;
116 
117 	struct	tga_devconfig *sc_dc;	/* device configuration */
118 	void	*sc_intr;		/* interrupt handler info */
119 	/* XXX should record intr fns/arg */
120 
121 	int nscreens;
122 };
123 
124 #define	TGA_TYPE_T8_01		0	/* 8bpp, 1MB */
125 #define	TGA_TYPE_T8_02		1	/* 8bpp, 2MB */
126 #define	TGA_TYPE_T8_22		2	/* 8bpp, 4MB */
127 #define	TGA_TYPE_T8_44		3	/* 8bpp, 8MB */
128 #define	TGA_TYPE_T32_04		4	/* 32bpp, 4MB */
129 #define	TGA_TYPE_T32_08		5	/* 32bpp, 8MB */
130 #define	TGA_TYPE_T32_88		6	/* 32bpp, 16MB */
131 #define	TGA_TYPE_UNKNOWN	7	/* unknown */
132 
133 #define	DEVICE_IS_TGA(class, id)					\
134 	    ((PCI_VENDOR(id) == PCI_VENDOR_DEC &&			\
135 	     PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) ? 10 : 0)
136 
137 int tga_cnattach __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
138 		      int, int, int));
139 
140 int	tga_identify __P((tga_reg_t *));
141 const struct tga_conf *tga_getconf __P((int));
142 
143 extern const struct tga_ramdac_conf tga_ramdac_bt463;
144 extern const struct tga_ramdac_conf tga_ramdac_bt485;
145 
146 int     tga_builtin_set_cursor __P((struct tga_devconfig *,
147 	    struct wsdisplay_cursor *));
148 int     tga_builtin_get_cursor __P((struct tga_devconfig *,
149 	    struct wsdisplay_cursor *));
150 int     tga_builtin_set_curpos __P((struct tga_devconfig *,
151 	    struct wsdisplay_curpos *));
152 int     tga_builtin_get_curpos __P((struct tga_devconfig *,
153 	    struct wsdisplay_curpos *));
154 int     tga_builtin_get_curmax __P((struct tga_devconfig *,
155 	    struct wsdisplay_curpos *));
156