Home | History | Annotate | Line # | Download | only in ic
igsfbvar.h revision 1.6
      1 /*	$NetBSD: igsfbvar.h,v 1.6 2003/05/10 16:20:23 uwe Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2002, 2003 Valeriy E. Ushakov
      5  * All rights reserved.
      6  *
      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
     17  *
     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.
     28  */
     29 
     30 /*
     31  * Integraphics Systems IGA 168x and CyberPro series.
     32  */
     33 #ifndef _DEV_IC_IGSFBVAR_H_
     34 #define _DEV_IC_IGSFBVAR_H_
     35 
     36 #define	IGS_CMAP_SIZE	256	/* 256 R/G/B entries */
     37 struct igs_hwcmap {
     38 	u_int8_t r[IGS_CMAP_SIZE];
     39 	u_int8_t g[IGS_CMAP_SIZE];
     40 	u_int8_t b[IGS_CMAP_SIZE];
     41 };
     42 
     43 
     44 #define IGS_CURSOR_MAX_SIZE 64	/* 64x64 sprite */
     45 struct igs_hwcursor {
     46 	struct wsdisplay_curpos cc_pos;
     47 	struct wsdisplay_curpos cc_hot;
     48 	struct wsdisplay_curpos cc_size;
     49 	u_int8_t cc_image[512];		/* save copy of image for GCURSOR */
     50 	u_int8_t cc_mask[512];		/* save copy of mask for GCURSOR */
     51 	u_int16_t cc_sprite[512];	/* sprite in device 2bpp format */
     52 	u_int8_t cc_color[6];		/* 2 colors, 3 rgb components */
     53 };
     54 
     55 
     56 struct igsfb_devconfig {
     57 	/* io space, may be memory mapped */
     58 	bus_space_tag_t dc_iot;
     59 	bus_addr_t dc_iobase;
     60 	int dc_ioflags;
     61 
     62 	/* io registers */
     63 	bus_space_handle_t dc_ioh;
     64 
     65 	/* linear memory */
     66 	bus_space_tag_t dc_memt;
     67 	bus_addr_t dc_memaddr;
     68 	bus_size_t dc_memsz; /* size of linear address space including mmio */
     69 	int dc_memflags;
     70 
     71 	/* actual video memory size */
     72 	bus_size_t dc_vmemsz;
     73 
     74 	/* resolution */
     75 	int dc_width, dc_height, dc_depth;
     76 
     77 	/* part of video memory mapped for wsscreen */
     78 	bus_space_handle_t dc_fbh;
     79 	bus_size_t dc_fbsz;
     80 
     81 	/* 1KB of cursor sprite data */
     82 	bus_space_handle_t dc_crh;
     83 
     84 	/* XXX: notyet
     85 	 * graphic coprocessor can be accessed either via i/o space
     86 	 * or via memory-mapped i/o access through memory space
     87 	 */
     88 	bus_space_tag_t dc_copt;
     89 	bus_space_handle_t dc_coph;
     90 
     91 	/* product id: IGA 168x, CyberPro 2k &c */
     92 	int dc_id;
     93 
     94 	/* flags that control driver operation */
     95 	int dc_hwflags;
     96 #define IGSFB_HW_BSWAP			0x1 /* endianness mismatch */
     97 #define IGSFB_HW_BE_SELECT		0x2 /* big endian magic (cyberpro) */
     98 
     99 /* do we need to do bswap in software? */
    100 #define IGSFB_HW_SOFT_BSWAP(dc)						\
    101 	((((dc)->dc_hwflags) & (IGSFB_HW_BSWAP | IGSFB_HW_BE_SELECT))	\
    102 		== IGSFB_HW_BSWAP)
    103 
    104 	struct rasops_info dc_ri;
    105 
    106 	struct igs_hwcmap dc_cmap;	/* software copy of colormap */
    107 	struct igs_hwcursor dc_cursor;	/* software copy of cursor sprite */
    108 
    109 	/* precomputed bit table for cursor sprite 1bpp -> 2bpp conversion */
    110 	u_int16_t dc_bexpand[256];
    111 
    112 	int dc_nscreens;		/* can do only a single screen */
    113 
    114 	int dc_blanked;			/* screen is currently blanked */
    115 	int dc_curenb;			/* cursor sprite enabled */
    116 };
    117 
    118 
    119 struct igsfb_softc {
    120 	struct device sc_dev;
    121 	struct igsfb_devconfig *sc_dc;
    122 };
    123 
    124 
    125 
    126 /*
    127  * Access sugar for indexed registers
    128  */
    129 
    130 static __inline__ u_int8_t
    131 igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, u_int8_t);
    132 static __inline__ void
    133 igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, u_int8_t, u_int8_t);
    134 
    135 static __inline__ u_int8_t
    136 igs_idx_read(t, h, idxport, idx)
    137 	bus_space_tag_t t;
    138 	bus_space_handle_t h;
    139 	u_int idxport;
    140 	u_int8_t idx;
    141 {
    142 	bus_space_write_1(t, h, idxport, idx);
    143 	return (bus_space_read_1(t, h, idxport + 1));
    144 }
    145 
    146 static __inline__ void
    147 igs_idx_write(t, h, idxport, idx, val)
    148 	bus_space_tag_t t;
    149 	bus_space_handle_t h;
    150 	u_int idxport;
    151 	u_int8_t idx, val;
    152 {
    153 	bus_space_write_1(t, h, idxport, idx);
    154 	bus_space_write_1(t, h, idxport + 1, val);
    155 }
    156 
    157 
    158 /* sugar for sequencer controller */
    159 #define igs_seq_read(t,h,x)	\
    160 	(igs_idx_read((t),(h),IGS_SEQ_IDX,(x)))
    161 #define igs_seq_write(t,h,x,v)	\
    162 	(igs_idx_write((t),(h),IGS_SEQ_IDX,(x),(v)))
    163 
    164 
    165 /* sugar for CRT controller */
    166 #define igs_crtc_read(t,h,x)	\
    167 	(igs_idx_read((t),(h),IGS_CRTC_IDX,(x)))
    168 #define igs_crtc_write(t,h,x,v)	\
    169 	(igs_idx_write((t),(h),IGS_CRTC_IDX,(x),(v)))
    170 
    171 
    172 /* sugar for attribute controller */
    173 #define igs_attr_flip_flop(t,h)	\
    174 	((void)bus_space_read_1((t),(h),IGS_INPUT_STATUS1));
    175 #define igs_attr_read(t,h,x)	\
    176 	(igs_idx_read((t),(h),IGS_ATTR_IDX,(x)))
    177 
    178 static __inline__ void
    179 igs_attr_write(bus_space_tag_t, bus_space_handle_t, u_int8_t, u_int8_t);
    180 
    181 static __inline__ void
    182 igs_attr_write(t, h, idx, val)
    183 	bus_space_tag_t t;
    184 	bus_space_handle_t h;
    185 	u_int8_t idx, val;
    186 {
    187 	bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
    188 	bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
    189 }
    190 
    191 
    192 /* sugar for graphics controller registers */
    193 #define igs_grfx_read(t,h,x)	(igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
    194 #define igs_grfx_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
    195 
    196 
    197 /* sugar for extended registers */
    198 #define igs_ext_read(t,h,x)	(igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
    199 #define igs_ext_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
    200 
    201 
    202 /* igsfb_subr.c */
    203 int	igsfb_enable(bus_space_tag_t, bus_addr_t, int);
    204 void	igsfb_hw_setup(struct igsfb_devconfig *);
    205 void	igsfb_1024x768_8bpp_60Hz(struct igsfb_devconfig *);
    206 
    207 /* igsfb.c */
    208 int	igsfb_cnattach_subr(struct igsfb_devconfig *);
    209 void	igsfb_attach_subr(struct igsfb_softc *, int);
    210 
    211 
    212 extern struct igsfb_devconfig igsfb_console_dc;
    213 
    214 #endif /* _DEV_IC_IGSFBVAR_H_ */
    215