igsfbvar.h revision 1.19 1 1.19 macallan /* $NetBSD: igsfbvar.h,v 1.19 2009/11/18 21:59:38 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.18 macallan #include <dev/videomode/videomode.h>
37 1.18 macallan
38 1.1 uwe #define IGS_CMAP_SIZE 256 /* 256 R/G/B entries */
39 1.1 uwe struct igs_hwcmap {
40 1.9 uwe uint8_t r[IGS_CMAP_SIZE];
41 1.9 uwe uint8_t g[IGS_CMAP_SIZE];
42 1.9 uwe uint8_t b[IGS_CMAP_SIZE];
43 1.1 uwe };
44 1.1 uwe
45 1.1 uwe
46 1.1 uwe #define IGS_CURSOR_MAX_SIZE 64 /* 64x64 sprite */
47 1.1 uwe struct igs_hwcursor {
48 1.1 uwe struct wsdisplay_curpos cc_pos;
49 1.1 uwe struct wsdisplay_curpos cc_hot;
50 1.1 uwe struct wsdisplay_curpos cc_size;
51 1.9 uwe uint8_t cc_image[512]; /* save copy of image for GCURSOR */
52 1.9 uwe uint8_t cc_mask[512]; /* save copy of mask for GCURSOR */
53 1.9 uwe uint16_t cc_sprite[512]; /* sprite in device 2bpp format */
54 1.9 uwe uint8_t cc_color[6]; /* 2 colors, 3 rgb components */
55 1.1 uwe };
56 1.1 uwe
57 1.1 uwe
58 1.5 uwe struct igsfb_devconfig {
59 1.5 uwe /* io space, may be memory mapped */
60 1.5 uwe bus_space_tag_t dc_iot;
61 1.5 uwe bus_addr_t dc_iobase;
62 1.5 uwe int dc_ioflags;
63 1.1 uwe
64 1.1 uwe /* io registers */
65 1.5 uwe bus_space_handle_t dc_ioh;
66 1.1 uwe
67 1.8 uwe /* graphic coprocessor */
68 1.8 uwe bus_space_handle_t dc_coph;
69 1.8 uwe
70 1.1 uwe /* linear memory */
71 1.5 uwe bus_space_tag_t dc_memt;
72 1.5 uwe bus_addr_t dc_memaddr;
73 1.5 uwe bus_size_t dc_memsz; /* size of linear address space including mmio */
74 1.5 uwe int dc_memflags;
75 1.5 uwe
76 1.8 uwe /* video memory size */
77 1.5 uwe bus_size_t dc_vmemsz;
78 1.1 uwe
79 1.5 uwe /* resolution */
80 1.14 uwe int dc_width, dc_height, dc_depth, dc_stride;
81 1.19 macallan int dc_maxdepth;
82 1.19 macallan const struct videomode *dc_mode;
83 1.1 uwe
84 1.18 macallan char dc_modestring[128];
85 1.18 macallan
86 1.5 uwe /* part of video memory mapped for wsscreen */
87 1.5 uwe bus_space_handle_t dc_fbh;
88 1.5 uwe bus_size_t dc_fbsz;
89 1.5 uwe
90 1.5 uwe /* 1KB of cursor sprite data */
91 1.5 uwe bus_space_handle_t dc_crh;
92 1.5 uwe
93 1.5 uwe /* product id: IGA 168x, CyberPro 2k &c */
94 1.5 uwe int dc_id;
95 1.1 uwe
96 1.1 uwe /* flags that control driver operation */
97 1.5 uwe int dc_hwflags;
98 1.5 uwe #define IGSFB_HW_BSWAP 0x1 /* endianness mismatch */
99 1.5 uwe #define IGSFB_HW_BE_SELECT 0x2 /* big endian magic (cyberpro) */
100 1.7 uwe #define IGSFB_HW_TEXT_CURSOR 0x4 /* do text cursor in hardware */
101 1.5 uwe
102 1.5 uwe /* do we need to do bswap in software? */
103 1.5 uwe #define IGSFB_HW_SOFT_BSWAP(dc) \
104 1.5 uwe ((((dc)->dc_hwflags) & (IGSFB_HW_BSWAP | IGSFB_HW_BE_SELECT)) \
105 1.5 uwe == IGSFB_HW_BSWAP)
106 1.1 uwe
107 1.7 uwe int dc_blanked; /* screen is currently blanked */
108 1.7 uwe int dc_curenb; /* cursor sprite enabled */
109 1.7 uwe int dc_mapped; /* currently in mapped mode */
110 1.7 uwe
111 1.8 uwe /* saved dc_ri.ri_ops.putchar */
112 1.8 uwe void (*dc_ri_putchar)(void *, int, int, u_int, long);
113 1.1 uwe
114 1.17 macallan /* optional MD mmap() method */
115 1.17 macallan paddr_t (*dc_mmap)(void *, void *, off_t, int);
116 1.17 macallan
117 1.5 uwe struct igs_hwcmap dc_cmap; /* software copy of colormap */
118 1.5 uwe struct igs_hwcursor dc_cursor; /* software copy of cursor sprite */
119 1.1 uwe
120 1.6 uwe /* precomputed bit table for cursor sprite 1bpp -> 2bpp conversion */
121 1.9 uwe uint16_t dc_bexpand[256];
122 1.16 uwe
123 1.13 macallan /* virtual console support */
124 1.13 macallan struct vcons_data dc_vd;
125 1.13 macallan struct vcons_screen dc_console;
126 1.5 uwe };
127 1.1 uwe
128 1.1 uwe
129 1.5 uwe struct igsfb_softc {
130 1.5 uwe struct device sc_dev;
131 1.5 uwe struct igsfb_devconfig *sc_dc;
132 1.1 uwe };
133 1.1 uwe
134 1.2 uwe
135 1.5 uwe
136 1.2 uwe /*
137 1.2 uwe * Access sugar for indexed registers
138 1.2 uwe */
139 1.2 uwe
140 1.12 perry static __inline uint8_t
141 1.9 uwe igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t);
142 1.12 perry static __inline void
143 1.9 uwe igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t, uint8_t);
144 1.2 uwe
145 1.12 perry static __inline uint8_t
146 1.15 uwe igs_idx_read(bus_space_tag_t t, bus_space_handle_t h,
147 1.15 uwe u_int idxport, uint8_t idx)
148 1.2 uwe {
149 1.2 uwe bus_space_write_1(t, h, idxport, idx);
150 1.2 uwe return (bus_space_read_1(t, h, idxport + 1));
151 1.2 uwe }
152 1.2 uwe
153 1.12 perry static __inline void
154 1.15 uwe igs_idx_write(bus_space_tag_t t, bus_space_handle_t h,
155 1.15 uwe u_int idxport, uint8_t idx, uint8_t val)
156 1.2 uwe {
157 1.2 uwe bus_space_write_1(t, h, idxport, idx);
158 1.2 uwe bus_space_write_1(t, h, idxport + 1, val);
159 1.2 uwe }
160 1.2 uwe
161 1.3 uwe
162 1.3 uwe /* sugar for sequencer controller */
163 1.3 uwe #define igs_seq_read(t,h,x) \
164 1.3 uwe (igs_idx_read((t),(h),IGS_SEQ_IDX,(x)))
165 1.3 uwe #define igs_seq_write(t,h,x,v) \
166 1.3 uwe (igs_idx_write((t),(h),IGS_SEQ_IDX,(x),(v)))
167 1.3 uwe
168 1.3 uwe
169 1.3 uwe /* sugar for CRT controller */
170 1.3 uwe #define igs_crtc_read(t,h,x) \
171 1.3 uwe (igs_idx_read((t),(h),IGS_CRTC_IDX,(x)))
172 1.3 uwe #define igs_crtc_write(t,h,x,v) \
173 1.3 uwe (igs_idx_write((t),(h),IGS_CRTC_IDX,(x),(v)))
174 1.3 uwe
175 1.3 uwe
176 1.3 uwe /* sugar for attribute controller */
177 1.3 uwe #define igs_attr_flip_flop(t,h) \
178 1.3 uwe ((void)bus_space_read_1((t),(h),IGS_INPUT_STATUS1));
179 1.3 uwe #define igs_attr_read(t,h,x) \
180 1.3 uwe (igs_idx_read((t),(h),IGS_ATTR_IDX,(x)))
181 1.3 uwe
182 1.12 perry static __inline void
183 1.9 uwe igs_attr_write(bus_space_tag_t, bus_space_handle_t, uint8_t, uint8_t);
184 1.3 uwe
185 1.12 perry static __inline void
186 1.15 uwe igs_attr_write(bus_space_tag_t t, bus_space_handle_t h,
187 1.15 uwe uint8_t idx, uint8_t val)
188 1.3 uwe {
189 1.3 uwe bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
190 1.3 uwe bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
191 1.3 uwe }
192 1.3 uwe
193 1.3 uwe
194 1.3 uwe /* sugar for graphics controller registers */
195 1.3 uwe #define igs_grfx_read(t,h,x) (igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
196 1.3 uwe #define igs_grfx_write(t,h,x,v) (igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
197 1.3 uwe
198 1.3 uwe
199 1.3 uwe /* sugar for extended registers */
200 1.2 uwe #define igs_ext_read(t,h,x) (igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
201 1.2 uwe #define igs_ext_write(t,h,x,v) (igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
202 1.1 uwe
203 1.1 uwe
204 1.3 uwe /* igsfb_subr.c */
205 1.5 uwe int igsfb_enable(bus_space_tag_t, bus_addr_t, int);
206 1.5 uwe void igsfb_hw_setup(struct igsfb_devconfig *);
207 1.5 uwe void igsfb_1024x768_8bpp_60Hz(struct igsfb_devconfig *);
208 1.18 macallan void igsfb_set_mode(struct igsfb_devconfig *, const struct videomode *, int);
209 1.3 uwe
210 1.3 uwe /* igsfb.c */
211 1.5 uwe int igsfb_cnattach_subr(struct igsfb_devconfig *);
212 1.5 uwe void igsfb_attach_subr(struct igsfb_softc *, int);
213 1.5 uwe
214 1.5 uwe
215 1.5 uwe extern struct igsfb_devconfig igsfb_console_dc;
216 1.1 uwe
217 1.1 uwe #endif /* _DEV_IC_IGSFBVAR_H_ */
218