Sync usage with man page.
[netbsd-mini2440.git] / sys / dev / ic / igsfbvar.h
blob139362459f7166eb7cbf69397eebabdcbabd489e
1 /* $NetBSD: igsfbvar.h,v 1.18 2009/11/11 17:01:17 macallan Exp $ */
3 /*
4 * Copyright (c) 2002, 2003 Valeriy E. Ushakov
5 * All rights reserved.
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 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * Integraphics Systems IGA 168x and CyberPro series.
33 #ifndef _DEV_IC_IGSFBVAR_H_
34 #define _DEV_IC_IGSFBVAR_H_
36 #include <dev/videomode/videomode.h>
38 #define IGS_CMAP_SIZE 256 /* 256 R/G/B entries */
39 struct igs_hwcmap {
40 uint8_t r[IGS_CMAP_SIZE];
41 uint8_t g[IGS_CMAP_SIZE];
42 uint8_t b[IGS_CMAP_SIZE];
46 #define IGS_CURSOR_MAX_SIZE 64 /* 64x64 sprite */
47 struct igs_hwcursor {
48 struct wsdisplay_curpos cc_pos;
49 struct wsdisplay_curpos cc_hot;
50 struct wsdisplay_curpos cc_size;
51 uint8_t cc_image[512]; /* save copy of image for GCURSOR */
52 uint8_t cc_mask[512]; /* save copy of mask for GCURSOR */
53 uint16_t cc_sprite[512]; /* sprite in device 2bpp format */
54 uint8_t cc_color[6]; /* 2 colors, 3 rgb components */
58 struct igsfb_devconfig {
59 /* io space, may be memory mapped */
60 bus_space_tag_t dc_iot;
61 bus_addr_t dc_iobase;
62 int dc_ioflags;
64 /* io registers */
65 bus_space_handle_t dc_ioh;
67 /* graphic coprocessor */
68 bus_space_handle_t dc_coph;
70 /* linear memory */
71 bus_space_tag_t dc_memt;
72 bus_addr_t dc_memaddr;
73 bus_size_t dc_memsz; /* size of linear address space including mmio */
74 int dc_memflags;
76 /* video memory size */
77 bus_size_t dc_vmemsz;
79 /* resolution */
80 int dc_width, dc_height, dc_depth, dc_stride;
81 int dc_maxdepth;
82 const struct videomode *dc_mode;
84 char dc_modestring[128];
86 /* part of video memory mapped for wsscreen */
87 bus_space_handle_t dc_fbh;
88 bus_size_t dc_fbsz;
90 /* 1KB of cursor sprite data */
91 bus_space_handle_t dc_crh;
93 /* product id: IGA 168x, CyberPro 2k &c */
94 int dc_id;
96 /* flags that control driver operation */
97 int dc_hwflags;
98 #define IGSFB_HW_BSWAP 0x1 /* endianness mismatch */
99 #define IGSFB_HW_BE_SELECT 0x2 /* big endian magic (cyberpro) */
100 #define IGSFB_HW_TEXT_CURSOR 0x4 /* do text cursor in hardware */
102 /* do we need to do bswap in software? */
103 #define IGSFB_HW_SOFT_BSWAP(dc) \
104 ((((dc)->dc_hwflags) & (IGSFB_HW_BSWAP | IGSFB_HW_BE_SELECT)) \
105 == IGSFB_HW_BSWAP)
107 int dc_blanked; /* screen is currently blanked */
108 int dc_curenb; /* cursor sprite enabled */
109 int dc_mapped; /* currently in mapped mode */
111 /* saved dc_ri.ri_ops.putchar */
112 void (*dc_ri_putchar)(void *, int, int, u_int, long);
114 /* optional MD mmap() method */
115 paddr_t (*dc_mmap)(void *, void *, off_t, int);
117 struct igs_hwcmap dc_cmap; /* software copy of colormap */
118 struct igs_hwcursor dc_cursor; /* software copy of cursor sprite */
120 /* precomputed bit table for cursor sprite 1bpp -> 2bpp conversion */
121 uint16_t dc_bexpand[256];
123 /* virtual console support */
124 struct vcons_data dc_vd;
125 struct vcons_screen dc_console;
129 struct igsfb_softc {
130 struct device sc_dev;
131 struct igsfb_devconfig *sc_dc;
137 * Access sugar for indexed registers
140 static __inline uint8_t
141 igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t);
142 static __inline void
143 igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t, uint8_t);
145 static __inline uint8_t
146 igs_idx_read(bus_space_tag_t t, bus_space_handle_t h,
147 u_int idxport, uint8_t idx)
149 bus_space_write_1(t, h, idxport, idx);
150 return (bus_space_read_1(t, h, idxport + 1));
153 static __inline void
154 igs_idx_write(bus_space_tag_t t, bus_space_handle_t h,
155 u_int idxport, uint8_t idx, uint8_t val)
157 bus_space_write_1(t, h, idxport, idx);
158 bus_space_write_1(t, h, idxport + 1, val);
162 /* sugar for sequencer controller */
163 #define igs_seq_read(t,h,x) \
164 (igs_idx_read((t),(h),IGS_SEQ_IDX,(x)))
165 #define igs_seq_write(t,h,x,v) \
166 (igs_idx_write((t),(h),IGS_SEQ_IDX,(x),(v)))
169 /* sugar for CRT controller */
170 #define igs_crtc_read(t,h,x) \
171 (igs_idx_read((t),(h),IGS_CRTC_IDX,(x)))
172 #define igs_crtc_write(t,h,x,v) \
173 (igs_idx_write((t),(h),IGS_CRTC_IDX,(x),(v)))
176 /* sugar for attribute controller */
177 #define igs_attr_flip_flop(t,h) \
178 ((void)bus_space_read_1((t),(h),IGS_INPUT_STATUS1));
179 #define igs_attr_read(t,h,x) \
180 (igs_idx_read((t),(h),IGS_ATTR_IDX,(x)))
182 static __inline void
183 igs_attr_write(bus_space_tag_t, bus_space_handle_t, uint8_t, uint8_t);
185 static __inline void
186 igs_attr_write(bus_space_tag_t t, bus_space_handle_t h,
187 uint8_t idx, uint8_t val)
189 bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
190 bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
194 /* sugar for graphics controller registers */
195 #define igs_grfx_read(t,h,x) (igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
196 #define igs_grfx_write(t,h,x,v) (igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
199 /* sugar for extended registers */
200 #define igs_ext_read(t,h,x) (igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
201 #define igs_ext_write(t,h,x,v) (igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
204 /* igsfb_subr.c */
205 int igsfb_enable(bus_space_tag_t, bus_addr_t, int);
206 void igsfb_hw_setup(struct igsfb_devconfig *);
207 void igsfb_1024x768_8bpp_60Hz(struct igsfb_devconfig *);
208 void igsfb_set_mode(struct igsfb_devconfig *, const struct videomode *, int);
210 /* igsfb.c */
211 int igsfb_cnattach_subr(struct igsfb_devconfig *);
212 void igsfb_attach_subr(struct igsfb_softc *, int);
215 extern struct igsfb_devconfig igsfb_console_dc;
217 #endif /* _DEV_IC_IGSFBVAR_H_ */