tgavar.h revision 1.14 1 1.14 perry /* $NetBSD: tgavar.h,v 1.14 2005/02/27 00:27:34 perry Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 1.1 drochner * All rights reserved.
6 1.1 drochner *
7 1.1 drochner * Author: Chris G. Demetriou
8 1.14 perry *
9 1.1 drochner * Permission to use, copy, modify and distribute this software and
10 1.1 drochner * its documentation is hereby granted, provided that both the copyright
11 1.1 drochner * notice and this permission notice appear in all copies of the
12 1.1 drochner * software, derivative works or modified versions, and any portions
13 1.1 drochner * thereof, and that both notices appear in supporting documentation.
14 1.14 perry *
15 1.14 perry * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.14 perry * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.1 drochner * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.14 perry *
19 1.1 drochner * Carnegie Mellon requests users of this software to return to
20 1.1 drochner *
21 1.1 drochner * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.1 drochner * School of Computer Science
23 1.1 drochner * Carnegie Mellon University
24 1.1 drochner * Pittsburgh PA 15213-3890
25 1.1 drochner *
26 1.1 drochner * any improvements or extensions that they make and grant Carnegie the
27 1.1 drochner * rights to redistribute these changes.
28 1.1 drochner */
29 1.1 drochner
30 1.5 elric #include <dev/ic/ramdac.h>
31 1.1 drochner #include <dev/pci/tgareg.h>
32 1.1 drochner #include <dev/wscons/wsconsio.h>
33 1.1 drochner #include <dev/wscons/wscons_raster.h>
34 1.9 nathanw #include <dev/wscons/wsdisplayvar.h>
35 1.9 nathanw #include <dev/rasops/rasops.h>
36 1.1 drochner
37 1.1 drochner struct tga_devconfig;
38 1.1 drochner struct fbcmap;
39 1.1 drochner struct fbcursor;
40 1.1 drochner struct fbcurpos;
41 1.1 drochner
42 1.1 drochner struct tga_conf {
43 1.1 drochner char *tgac_name; /* name for this board type */
44 1.1 drochner
45 1.13 perry struct ramdac_funcs *(*ramdac_funcs)(void);
46 1.8 nathanw
47 1.1 drochner int tgac_phys_depth; /* physical frame buffer depth */
48 1.2 eeh vsize_t tgac_cspace_size; /* core space size */
49 1.2 eeh vsize_t tgac_vvbr_units; /* what '1' in the VVBR means */
50 1.1 drochner
51 1.1 drochner int tgac_ndbuf; /* number of display buffers */
52 1.2 eeh vaddr_t tgac_dbuf[2]; /* display buffer offsets/addresses */
53 1.2 eeh vsize_t tgac_dbufsz[2]; /* display buffer sizes */
54 1.1 drochner
55 1.1 drochner int tgac_nbbuf; /* number of display buffers */
56 1.2 eeh vaddr_t tgac_bbuf[2]; /* back buffer offsets/addresses */
57 1.2 eeh vsize_t tgac_bbufsz[2]; /* back buffer sizes */
58 1.1 drochner };
59 1.1 drochner
60 1.1 drochner struct tga_devconfig {
61 1.1 drochner bus_space_tag_t dc_memt;
62 1.7 nathanw bus_space_handle_t dc_memh;
63 1.1 drochner
64 1.1 drochner pcitag_t dc_pcitag; /* PCI tag */
65 1.1 drochner bus_addr_t dc_pcipaddr; /* PCI phys addr. */
66 1.1 drochner
67 1.7 nathanw bus_space_handle_t dc_regs; /* registers; XXX: need aliases */
68 1.1 drochner
69 1.1 drochner int dc_tga_type; /* the device type; see below */
70 1.6 elric int dc_tga2; /* True if it is a TGA2 */
71 1.1 drochner const struct tga_conf *dc_tgaconf; /* device buffer configuration */
72 1.1 drochner
73 1.5 elric struct ramdac_funcs
74 1.5 elric *dc_ramdac_funcs; /* The RAMDAC functions */
75 1.5 elric struct ramdac_cookie
76 1.5 elric *dc_ramdac_cookie; /* the RAMDAC type; see above */
77 1.5 elric
78 1.2 eeh vaddr_t dc_vaddr; /* memory space virtual base address */
79 1.1 drochner
80 1.1 drochner int dc_wid; /* width of frame buffer */
81 1.1 drochner int dc_ht; /* height of frame buffer */
82 1.1 drochner int dc_rowbytes; /* bytes in a FB scan line */
83 1.1 drochner
84 1.2 eeh vaddr_t dc_videobase; /* base of flat frame buffer */
85 1.1 drochner
86 1.9 nathanw struct rasops_info dc_rinfo; /* raster display data */
87 1.1 drochner
88 1.1 drochner int dc_blanked; /* currently had video disabled */
89 1.1 drochner void *dc_ramdac_private; /* RAMDAC private storage */
90 1.5 elric
91 1.13 perry void (*dc_ramdac_intr)(void *);
92 1.8 nathanw int dc_intrenabled; /* can we depend on interrupts yet? */
93 1.1 drochner };
94 1.14 perry
95 1.1 drochner struct tga_softc {
96 1.1 drochner struct device sc_dev;
97 1.1 drochner
98 1.1 drochner struct tga_devconfig *sc_dc; /* device configuration */
99 1.1 drochner void *sc_intr; /* interrupt handler info */
100 1.1 drochner /* XXX should record intr fns/arg */
101 1.1 drochner
102 1.1 drochner int nscreens;
103 1.1 drochner };
104 1.1 drochner
105 1.1 drochner #define TGA_TYPE_T8_01 0 /* 8bpp, 1MB */
106 1.1 drochner #define TGA_TYPE_T8_02 1 /* 8bpp, 2MB */
107 1.1 drochner #define TGA_TYPE_T8_22 2 /* 8bpp, 4MB */
108 1.1 drochner #define TGA_TYPE_T8_44 3 /* 8bpp, 8MB */
109 1.1 drochner #define TGA_TYPE_T32_04 4 /* 32bpp, 4MB */
110 1.1 drochner #define TGA_TYPE_T32_08 5 /* 32bpp, 8MB */
111 1.1 drochner #define TGA_TYPE_T32_88 6 /* 32bpp, 16MB */
112 1.12 elric #define TGA_TYPE_POWERSTORM_4D20 7 /* unknown */
113 1.12 elric #define TGA_TYPE_UNKNOWN 8 /* unknown */
114 1.1 drochner
115 1.1 drochner #define DEVICE_IS_TGA(class, id) \
116 1.6 elric (((PCI_VENDOR(id) == PCI_VENDOR_DEC && \
117 1.6 elric PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) || \
118 1.6 elric PCI_PRODUCT(id) == PCI_PRODUCT_DEC_PBXGB) ? 10 : 0)
119 1.1 drochner
120 1.13 perry int tga_cnmatch(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t, pcitag_t);
121 1.13 perry int tga_cnattach(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
122 1.13 perry int, int, int);
123 1.13 perry
124 1.13 perry int tga_identify(struct tga_devconfig *);
125 1.13 perry const struct tga_conf *tga_getconf(int);
126 1.13 perry
127 1.13 perry int tga_builtin_set_cursor(struct tga_devconfig *, struct wsdisplay_cursor *);
128 1.13 perry int tga_builtin_get_cursor(struct tga_devconfig *, struct wsdisplay_cursor *);
129 1.13 perry int tga_builtin_set_curpos(struct tga_devconfig *, struct wsdisplay_curpos *);
130 1.13 perry int tga_builtin_get_curpos(struct tga_devconfig *, struct wsdisplay_curpos *);
131 1.13 perry int tga_builtin_get_curmax(struct tga_devconfig *, struct wsdisplay_curpos *);
132 1.7 nathanw
133 1.7 nathanw /* Read a TGA register */
134 1.7 nathanw #define TGARREG(dc,reg) (bus_space_read_4((dc)->dc_memt, (dc)->dc_regs, \
135 1.7 nathanw (reg) << 2))
136 1.7 nathanw
137 1.7 nathanw /* Write a TGA register */
138 1.7 nathanw #define TGAWREG(dc,reg,val) bus_space_write_4((dc)->dc_memt, (dc)->dc_regs, \
139 1.7 nathanw (reg) << 2, (val))
140 1.7 nathanw
141 1.7 nathanw /* Write a TGA register at an alternate aliased location */
142 1.7 nathanw #define TGAWALREG(dc,reg,alias,val) bus_space_write_4( \
143 1.7 nathanw (dc)->dc_memt, (dc)->dc_regs, \
144 1.7 nathanw ((alias) * TGA_CREGS_ALIAS) + ((reg) << 2), \
145 1.7 nathanw (val))
146 1.7 nathanw
147 1.7 nathanw /* Insert a write barrier */
148 1.7 nathanw #define TGAREGWB(dc,reg, nregs) bus_space_barrier( \
149 1.7 nathanw (dc)->dc_memt, (dc)->dc_regs, \
150 1.7 nathanw ((reg) << 2), 4 * (nregs), BUS_SPACE_BARRIER_WRITE)
151 1.7 nathanw
152 1.7 nathanw /* Insert a read barrier */
153 1.7 nathanw #define TGAREGRB(dc,reg, nregs) bus_space_barrier( \
154 1.7 nathanw (dc)->dc_memt, (dc)->dc_regs, \
155 1.7 nathanw ((reg) << 2), 4 * (nregs), BUS_SPACE_BARRIER_READ)
156 1.7 nathanw
157 1.7 nathanw /* Insert a read/write barrier */
158 1.7 nathanw #define TGAREGRWB(dc,reg, nregs) bus_space_barrier( \
159 1.7 nathanw (dc)->dc_memt, (dc)->dc_regs, \
160 1.7 nathanw ((reg) << 2), 4 * (nregs), \
161 1.7 nathanw BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
162