igsfbvar.h revision 1.17 1 1.17 macallan /* $NetBSD: igsfbvar.h,v 1.17 2009/11/10 22:23:22 macallan Exp $ */
2 1.1 uwe
3 1.1 uwe /*
4 1.5 uwe * Copyright (c) 2002, 2003 Valeriy E. Ushakov
5 1.1 uwe * All rights reserved.
6 1.1 uwe *
7 1.1 uwe * Redistribution and use in source and binary forms, with or without
8 1.1 uwe * modification, are permitted provided that the following conditions
9 1.1 uwe * are met:
10 1.1 uwe * 1. Redistributions of source code must retain the above copyright
11 1.1 uwe * notice, this list of conditions and the following disclaimer.
12 1.1 uwe * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 uwe * notice, this list of conditions and the following disclaimer in the
14 1.1 uwe * documentation and/or other materials provided with the distribution.
15 1.1 uwe * 3. The name of the author may not be used to endorse or promote products
16 1.1 uwe * derived from this software without specific prior written permission
17 1.1 uwe *
18 1.1 uwe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 uwe * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 uwe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 uwe * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 uwe * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1 uwe * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1 uwe * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1 uwe * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1 uwe * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1 uwe * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 uwe */
29 1.1 uwe
30 1.1 uwe /*
31 1.2 uwe * Integraphics Systems IGA 168x and CyberPro series.
32 1.1 uwe */
33 1.1 uwe #ifndef _DEV_IC_IGSFBVAR_H_
34 1.1 uwe #define _DEV_IC_IGSFBVAR_H_
35 1.1 uwe
36 1.1 uwe #define IGS_CMAP_SIZE 256 /* 256 R/G/B entries */
37 1.1 uwe struct igs_hwcmap {
38 1.9 uwe uint8_t r[IGS_CMAP_SIZE];
39 1.9 uwe uint8_t g[IGS_CMAP_SIZE];
40 1.9 uwe uint8_t b[IGS_CMAP_SIZE];
41 1.1 uwe };
42 1.1 uwe
43 1.1 uwe
44 1.1 uwe #define IGS_CURSOR_MAX_SIZE 64 /* 64x64 sprite */
45 1.1 uwe struct igs_hwcursor {
46 1.1 uwe struct wsdisplay_curpos cc_pos;
47 1.1 uwe struct wsdisplay_curpos cc_hot;
48 1.1 uwe struct wsdisplay_curpos cc_size;
49 1.9 uwe uint8_t cc_image[512]; /* save copy of image for GCURSOR */
50 1.9 uwe uint8_t cc_mask[512]; /* save copy of mask for GCURSOR */
51 1.9 uwe uint16_t cc_sprite[512]; /* sprite in device 2bpp format */
52 1.9 uwe uint8_t cc_color[6]; /* 2 colors, 3 rgb components */
53 1.1 uwe };
54 1.1 uwe
55 1.1 uwe
56 1.5 uwe struct igsfb_devconfig {
57 1.5 uwe /* io space, may be memory mapped */
58 1.5 uwe bus_space_tag_t dc_iot;
59 1.5 uwe bus_addr_t dc_iobase;
60 1.5 uwe int dc_ioflags;
61 1.1 uwe
62 1.1 uwe /* io registers */
63 1.5 uwe bus_space_handle_t dc_ioh;
64 1.1 uwe
65 1.8 uwe /* graphic coprocessor */
66 1.8 uwe bus_space_handle_t dc_coph;
67 1.8 uwe
68 1.1 uwe /* linear memory */
69 1.5 uwe bus_space_tag_t dc_memt;
70 1.5 uwe bus_addr_t dc_memaddr;
71 1.5 uwe bus_size_t dc_memsz; /* size of linear address space including mmio */
72 1.5 uwe int dc_memflags;
73 1.5 uwe
74 1.8 uwe /* video memory size */
75 1.5 uwe bus_size_t dc_vmemsz;
76 1.1 uwe
77 1.5 uwe /* resolution */
78 1.14 uwe int dc_width, dc_height, dc_depth, dc_stride;
79 1.1 uwe
80 1.5 uwe /* part of video memory mapped for wsscreen */
81 1.5 uwe bus_space_handle_t dc_fbh;
82 1.5 uwe bus_size_t dc_fbsz;
83 1.5 uwe
84 1.5 uwe /* 1KB of cursor sprite data */
85 1.5 uwe bus_space_handle_t dc_crh;
86 1.5 uwe
87 1.5 uwe /* product id: IGA 168x, CyberPro 2k &c */
88 1.5 uwe int dc_id;
89 1.1 uwe
90 1.1 uwe /* flags that control driver operation */
91 1.5 uwe int dc_hwflags;
92 1.5 uwe #define IGSFB_HW_BSWAP 0x1 /* endianness mismatch */
93 1.5 uwe #define IGSFB_HW_BE_SELECT 0x2 /* big endian magic (cyberpro) */
94 1.7 uwe #define IGSFB_HW_TEXT_CURSOR 0x4 /* do text cursor in hardware */
95 1.5 uwe
96 1.5 uwe /* do we need to do bswap in software? */
97 1.5 uwe #define IGSFB_HW_SOFT_BSWAP(dc) \
98 1.5 uwe ((((dc)->dc_hwflags) & (IGSFB_HW_BSWAP | IGSFB_HW_BE_SELECT)) \
99 1.5 uwe == IGSFB_HW_BSWAP)
100 1.1 uwe
101 1.7 uwe int dc_blanked; /* screen is currently blanked */
102 1.7 uwe int dc_curenb; /* cursor sprite enabled */
103 1.7 uwe int dc_mapped; /* currently in mapped mode */
104 1.7 uwe
105 1.8 uwe /* saved dc_ri.ri_ops.putchar */
106 1.8 uwe void (*dc_ri_putchar)(void *, int, int, u_int, long);
107 1.1 uwe
108 1.17 macallan /* optional MD mmap() method */
109 1.17 macallan paddr_t (*dc_mmap)(void *, void *, off_t, int);
110 1.17 macallan
111 1.5 uwe struct igs_hwcmap dc_cmap; /* software copy of colormap */
112 1.5 uwe struct igs_hwcursor dc_cursor; /* software copy of cursor sprite */
113 1.1 uwe
114 1.6 uwe /* precomputed bit table for cursor sprite 1bpp -> 2bpp conversion */
115 1.9 uwe uint16_t dc_bexpand[256];
116 1.16 uwe
117 1.13 macallan /* virtual console support */
118 1.13 macallan struct vcons_data dc_vd;
119 1.13 macallan struct vcons_screen dc_console;
120 1.5 uwe };
121 1.1 uwe
122 1.1 uwe
123 1.5 uwe struct igsfb_softc {
124 1.5 uwe struct device sc_dev;
125 1.5 uwe struct igsfb_devconfig *sc_dc;
126 1.1 uwe };
127 1.1 uwe
128 1.2 uwe
129 1.5 uwe
130 1.2 uwe /*
131 1.2 uwe * Access sugar for indexed registers
132 1.2 uwe */
133 1.2 uwe
134 1.12 perry static __inline uint8_t
135 1.9 uwe igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t);
136 1.12 perry static __inline void
137 1.9 uwe igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t, uint8_t);
138 1.2 uwe
139 1.12 perry static __inline uint8_t
140 1.15 uwe igs_idx_read(bus_space_tag_t t, bus_space_handle_t h,
141 1.15 uwe u_int idxport, uint8_t idx)
142 1.2 uwe {
143 1.2 uwe bus_space_write_1(t, h, idxport, idx);
144 1.2 uwe return (bus_space_read_1(t, h, idxport + 1));
145 1.2 uwe }
146 1.2 uwe
147 1.12 perry static __inline void
148 1.15 uwe igs_idx_write(bus_space_tag_t t, bus_space_handle_t h,
149 1.15 uwe u_int idxport, uint8_t idx, uint8_t val)
150 1.2 uwe {
151 1.2 uwe bus_space_write_1(t, h, idxport, idx);
152 1.2 uwe bus_space_write_1(t, h, idxport + 1, val);
153 1.2 uwe }
154 1.2 uwe
155 1.3 uwe
156 1.3 uwe /* sugar for sequencer controller */
157 1.3 uwe #define igs_seq_read(t,h,x) \
158 1.3 uwe (igs_idx_read((t),(h),IGS_SEQ_IDX,(x)))
159 1.3 uwe #define igs_seq_write(t,h,x,v) \
160 1.3 uwe (igs_idx_write((t),(h),IGS_SEQ_IDX,(x),(v)))
161 1.3 uwe
162 1.3 uwe
163 1.3 uwe /* sugar for CRT controller */
164 1.3 uwe #define igs_crtc_read(t,h,x) \
165 1.3 uwe (igs_idx_read((t),(h),IGS_CRTC_IDX,(x)))
166 1.3 uwe #define igs_crtc_write(t,h,x,v) \
167 1.3 uwe (igs_idx_write((t),(h),IGS_CRTC_IDX,(x),(v)))
168 1.3 uwe
169 1.3 uwe
170 1.3 uwe /* sugar for attribute controller */
171 1.3 uwe #define igs_attr_flip_flop(t,h) \
172 1.3 uwe ((void)bus_space_read_1((t),(h),IGS_INPUT_STATUS1));
173 1.3 uwe #define igs_attr_read(t,h,x) \
174 1.3 uwe (igs_idx_read((t),(h),IGS_ATTR_IDX,(x)))
175 1.3 uwe
176 1.12 perry static __inline void
177 1.9 uwe igs_attr_write(bus_space_tag_t, bus_space_handle_t, uint8_t, uint8_t);
178 1.3 uwe
179 1.12 perry static __inline void
180 1.15 uwe igs_attr_write(bus_space_tag_t t, bus_space_handle_t h,
181 1.15 uwe uint8_t idx, uint8_t val)
182 1.3 uwe {
183 1.3 uwe bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
184 1.3 uwe bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
185 1.3 uwe }
186 1.3 uwe
187 1.3 uwe
188 1.3 uwe /* sugar for graphics controller registers */
189 1.3 uwe #define igs_grfx_read(t,h,x) (igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
190 1.3 uwe #define igs_grfx_write(t,h,x,v) (igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
191 1.3 uwe
192 1.3 uwe
193 1.3 uwe /* sugar for extended registers */
194 1.2 uwe #define igs_ext_read(t,h,x) (igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
195 1.2 uwe #define igs_ext_write(t,h,x,v) (igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
196 1.1 uwe
197 1.1 uwe
198 1.3 uwe /* igsfb_subr.c */
199 1.5 uwe int igsfb_enable(bus_space_tag_t, bus_addr_t, int);
200 1.5 uwe void igsfb_hw_setup(struct igsfb_devconfig *);
201 1.5 uwe void igsfb_1024x768_8bpp_60Hz(struct igsfb_devconfig *);
202 1.3 uwe
203 1.3 uwe /* igsfb.c */
204 1.5 uwe int igsfb_cnattach_subr(struct igsfb_devconfig *);
205 1.5 uwe void igsfb_attach_subr(struct igsfb_softc *, int);
206 1.5 uwe
207 1.5 uwe
208 1.5 uwe extern struct igsfb_devconfig igsfb_console_dc;
209 1.1 uwe
210 1.1 uwe #endif /* _DEV_IC_IGSFBVAR_H_ */
211