xref: /netbsd-src/sys/dev/ic/igsfbvar.h (revision fbae48b901b55c2671f81f494926889226fd3ffe)
1*fbae48b9Sperry /*	$NetBSD: igsfbvar.h,v 1.12 2006/02/16 20:17:16 perry Exp $ */
2782296b5Suwe 
3782296b5Suwe /*
42866542aSuwe  * Copyright (c) 2002, 2003 Valeriy E. Ushakov
5782296b5Suwe  * All rights reserved.
6782296b5Suwe  *
7782296b5Suwe  * Redistribution and use in source and binary forms, with or without
8782296b5Suwe  * modification, are permitted provided that the following conditions
9782296b5Suwe  * are met:
10782296b5Suwe  * 1. Redistributions of source code must retain the above copyright
11782296b5Suwe  *    notice, this list of conditions and the following disclaimer.
12782296b5Suwe  * 2. Redistributions in binary form must reproduce the above copyright
13782296b5Suwe  *    notice, this list of conditions and the following disclaimer in the
14782296b5Suwe  *    documentation and/or other materials provided with the distribution.
15782296b5Suwe  * 3. The name of the author may not be used to endorse or promote products
16782296b5Suwe  *    derived from this software without specific prior written permission
17782296b5Suwe  *
18782296b5Suwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19782296b5Suwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20782296b5Suwe  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21782296b5Suwe  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22782296b5Suwe  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23782296b5Suwe  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24782296b5Suwe  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25782296b5Suwe  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26782296b5Suwe  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27782296b5Suwe  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28782296b5Suwe  */
29782296b5Suwe 
30782296b5Suwe /*
31fee27e72Suwe  * Integraphics Systems IGA 168x and CyberPro series.
32782296b5Suwe  */
33782296b5Suwe #ifndef _DEV_IC_IGSFBVAR_H_
34782296b5Suwe #define _DEV_IC_IGSFBVAR_H_
35782296b5Suwe 
36782296b5Suwe #define	IGS_CMAP_SIZE	256	/* 256 R/G/B entries */
37782296b5Suwe struct igs_hwcmap {
38520a24eaSuwe 	uint8_t r[IGS_CMAP_SIZE];
39520a24eaSuwe 	uint8_t g[IGS_CMAP_SIZE];
40520a24eaSuwe 	uint8_t b[IGS_CMAP_SIZE];
41782296b5Suwe };
42782296b5Suwe 
43782296b5Suwe 
44782296b5Suwe #define IGS_CURSOR_MAX_SIZE 64	/* 64x64 sprite */
45782296b5Suwe struct igs_hwcursor {
46782296b5Suwe 	struct wsdisplay_curpos cc_pos;
47782296b5Suwe 	struct wsdisplay_curpos cc_hot;
48782296b5Suwe 	struct wsdisplay_curpos cc_size;
49520a24eaSuwe 	uint8_t cc_image[512];		/* save copy of image for GCURSOR */
50520a24eaSuwe 	uint8_t cc_mask[512];		/* save copy of mask for GCURSOR */
51520a24eaSuwe 	uint16_t cc_sprite[512];	/* sprite in device 2bpp format */
52520a24eaSuwe 	uint8_t cc_color[6];		/* 2 colors, 3 rgb components */
53782296b5Suwe };
54782296b5Suwe 
55782296b5Suwe 
562866542aSuwe struct igsfb_devconfig {
572866542aSuwe 	/* io space, may be memory mapped */
582866542aSuwe 	bus_space_tag_t dc_iot;
592866542aSuwe 	bus_addr_t dc_iobase;
602866542aSuwe 	int dc_ioflags;
61782296b5Suwe 
62782296b5Suwe 	/* io registers */
632866542aSuwe 	bus_space_handle_t dc_ioh;
64782296b5Suwe 
6597e817d0Suwe 	/* graphic coprocessor */
6697e817d0Suwe 	bus_space_handle_t dc_coph;
6797e817d0Suwe 
68782296b5Suwe 	/* linear memory */
692866542aSuwe 	bus_space_tag_t dc_memt;
702866542aSuwe 	bus_addr_t dc_memaddr;
712866542aSuwe 	bus_size_t dc_memsz; /* size of linear address space including mmio */
722866542aSuwe 	int dc_memflags;
73782296b5Suwe 
7497e817d0Suwe 	/* video memory size */
752866542aSuwe 	bus_size_t dc_vmemsz;
76fee27e72Suwe 
772866542aSuwe 	/* resolution */
782866542aSuwe 	int dc_width, dc_height, dc_depth;
79782296b5Suwe 
802866542aSuwe 	/* part of video memory mapped for wsscreen */
812866542aSuwe 	bus_space_handle_t dc_fbh;
822866542aSuwe 	bus_size_t dc_fbsz;
83782296b5Suwe 
842866542aSuwe 	/* 1KB of cursor sprite data */
852866542aSuwe 	bus_space_handle_t dc_crh;
862866542aSuwe 
872866542aSuwe 	/* product id: IGA 168x, CyberPro 2k &c */
882866542aSuwe 	int dc_id;
89782296b5Suwe 
90782296b5Suwe 	/* flags that control driver operation */
912866542aSuwe 	int dc_hwflags;
92fee27e72Suwe #define IGSFB_HW_BSWAP			0x1 /* endianness mismatch */
932866542aSuwe #define IGSFB_HW_BE_SELECT		0x2 /* big endian magic (cyberpro) */
94a3e1bfb0Suwe #define IGSFB_HW_TEXT_CURSOR		0x4 /* do text cursor in hardware */
95782296b5Suwe 
962866542aSuwe /* do we need to do bswap in software? */
972866542aSuwe #define IGSFB_HW_SOFT_BSWAP(dc)						\
982866542aSuwe 	((((dc)->dc_hwflags) & (IGSFB_HW_BSWAP | IGSFB_HW_BE_SELECT))	\
992866542aSuwe 		== IGSFB_HW_BSWAP)
100782296b5Suwe 
101a3e1bfb0Suwe 	int dc_nscreens;		/* can do only a single screen */
102a3e1bfb0Suwe 
103a3e1bfb0Suwe 	int dc_blanked;			/* screen is currently blanked */
104a3e1bfb0Suwe 	int dc_curenb;			/* cursor sprite enabled */
105a3e1bfb0Suwe 	int dc_mapped;			/* currently in mapped mode */
106a3e1bfb0Suwe 
1072866542aSuwe 	struct rasops_info dc_ri;
1082866542aSuwe 
10997e817d0Suwe 	/* saved dc_ri.ri_ops.putchar */
11097e817d0Suwe 	void (*dc_ri_putchar)(void *, int, int, u_int, long);
11197e817d0Suwe 
1122866542aSuwe 	struct igs_hwcmap dc_cmap;	/* software copy of colormap */
1132866542aSuwe 	struct igs_hwcursor dc_cursor;	/* software copy of cursor sprite */
114782296b5Suwe 
1156311425dSuwe 	/* precomputed bit table for cursor sprite 1bpp -> 2bpp conversion */
116520a24eaSuwe 	uint16_t dc_bexpand[256];
117782296b5Suwe };
118782296b5Suwe 
119fee27e72Suwe 
1202866542aSuwe struct igsfb_softc {
1212866542aSuwe 	struct device sc_dev;
1222866542aSuwe 	struct igsfb_devconfig *sc_dc;
1232866542aSuwe };
1242866542aSuwe 
1252866542aSuwe 
1262866542aSuwe 
127fee27e72Suwe /*
128fee27e72Suwe  * Access sugar for indexed registers
129fee27e72Suwe  */
130fee27e72Suwe 
131*fbae48b9Sperry static __inline uint8_t
132520a24eaSuwe igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t);
133*fbae48b9Sperry static __inline void
134520a24eaSuwe igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t, uint8_t);
135fee27e72Suwe 
136*fbae48b9Sperry static __inline uint8_t
137fee27e72Suwe igs_idx_read(t, h, idxport, idx)
138fee27e72Suwe 	bus_space_tag_t t;
139fee27e72Suwe 	bus_space_handle_t h;
140fee27e72Suwe 	u_int idxport;
141520a24eaSuwe 	uint8_t idx;
142fee27e72Suwe {
143fee27e72Suwe 	bus_space_write_1(t, h, idxport, idx);
144fee27e72Suwe 	return (bus_space_read_1(t, h, idxport + 1));
145fee27e72Suwe }
146fee27e72Suwe 
147*fbae48b9Sperry static __inline void
148fee27e72Suwe igs_idx_write(t, h, idxport, idx, val)
149fee27e72Suwe 	bus_space_tag_t t;
150fee27e72Suwe 	bus_space_handle_t h;
151fee27e72Suwe 	u_int idxport;
152520a24eaSuwe 	uint8_t idx, val;
153fee27e72Suwe {
154fee27e72Suwe 	bus_space_write_1(t, h, idxport, idx);
155fee27e72Suwe 	bus_space_write_1(t, h, idxport + 1, val);
156fee27e72Suwe }
157fee27e72Suwe 
158be3f67caSuwe 
159be3f67caSuwe /* sugar for sequencer controller */
160be3f67caSuwe #define igs_seq_read(t,h,x)	\
161be3f67caSuwe 	(igs_idx_read((t),(h),IGS_SEQ_IDX,(x)))
162be3f67caSuwe #define igs_seq_write(t,h,x,v)	\
163be3f67caSuwe 	(igs_idx_write((t),(h),IGS_SEQ_IDX,(x),(v)))
164be3f67caSuwe 
165be3f67caSuwe 
166be3f67caSuwe /* sugar for CRT controller */
167be3f67caSuwe #define igs_crtc_read(t,h,x)	\
168be3f67caSuwe 	(igs_idx_read((t),(h),IGS_CRTC_IDX,(x)))
169be3f67caSuwe #define igs_crtc_write(t,h,x,v)	\
170be3f67caSuwe 	(igs_idx_write((t),(h),IGS_CRTC_IDX,(x),(v)))
171be3f67caSuwe 
172be3f67caSuwe 
173be3f67caSuwe /* sugar for attribute controller */
174be3f67caSuwe #define igs_attr_flip_flop(t,h)	\
175be3f67caSuwe 	((void)bus_space_read_1((t),(h),IGS_INPUT_STATUS1));
176be3f67caSuwe #define igs_attr_read(t,h,x)	\
177be3f67caSuwe 	(igs_idx_read((t),(h),IGS_ATTR_IDX,(x)))
178be3f67caSuwe 
179*fbae48b9Sperry static __inline void
180520a24eaSuwe igs_attr_write(bus_space_tag_t, bus_space_handle_t, uint8_t, uint8_t);
181be3f67caSuwe 
182*fbae48b9Sperry static __inline void
183be3f67caSuwe igs_attr_write(t, h, idx, val)
184be3f67caSuwe 	bus_space_tag_t t;
185be3f67caSuwe 	bus_space_handle_t h;
186520a24eaSuwe 	uint8_t idx, val;
187be3f67caSuwe {
188be3f67caSuwe 	bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
189be3f67caSuwe 	bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
190be3f67caSuwe }
191be3f67caSuwe 
192be3f67caSuwe 
193be3f67caSuwe /* sugar for graphics controller registers */
194be3f67caSuwe #define igs_grfx_read(t,h,x)	(igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
195be3f67caSuwe #define igs_grfx_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
196be3f67caSuwe 
197be3f67caSuwe 
198be3f67caSuwe /* sugar for extended registers */
199fee27e72Suwe #define igs_ext_read(t,h,x)	(igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
200fee27e72Suwe #define igs_ext_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
201782296b5Suwe 
202782296b5Suwe 
203be3f67caSuwe /* igsfb_subr.c */
2042866542aSuwe int	igsfb_enable(bus_space_tag_t, bus_addr_t, int);
2052866542aSuwe void	igsfb_hw_setup(struct igsfb_devconfig *);
2062866542aSuwe void	igsfb_1024x768_8bpp_60Hz(struct igsfb_devconfig *);
207be3f67caSuwe 
208be3f67caSuwe /* igsfb.c */
2092866542aSuwe int	igsfb_cnattach_subr(struct igsfb_devconfig *);
2102866542aSuwe void	igsfb_attach_subr(struct igsfb_softc *, int);
2112866542aSuwe 
2122866542aSuwe 
2132866542aSuwe extern struct igsfb_devconfig igsfb_console_dc;
214782296b5Suwe 
215782296b5Suwe #endif /* _DEV_IC_IGSFBVAR_H_ */
216