Home | History | Annotate | Line # | Download | only in ic
igsfbvar.h revision 1.3
      1 /*	$NetBSD: igsfbvar.h,v 1.3 2002/09/24 18:17:25 uwe Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2002 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  * Only tested on IGA 1682 in Krups JavaStation-NC.
     33  */
     34 #ifndef _DEV_IC_IGSFBVAR_H_
     35 #define _DEV_IC_IGSFBVAR_H_
     36 
     37 
     38 #define	IGS_CMAP_SIZE	256	/* 256 R/G/B entries */
     39 struct igs_hwcmap {
     40 	u_int8_t r[IGS_CMAP_SIZE];
     41 	u_int8_t g[IGS_CMAP_SIZE];
     42 	u_int8_t b[IGS_CMAP_SIZE];
     43 };
     44 
     45 
     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 	u_int8_t cc_image[512];		/* save copy of image for GCURSOR */
     52 	u_int8_t cc_mask[512];		/* save copy of mask for GCURSOR */
     53 	u_int16_t cc_sprite[512];	/* sprite in device 2bpp format */
     54 	u_int8_t cc_color[6];		/* 2 colors, 3 rgb components */
     55 };
     56 
     57 
     58 /*
     59  * Precomputed bit tables to convert 1bpp image/mask to 2bpp hw cursor
     60  * sprite.  For IGSFB_HW_BSWAP attachments they are pre-bswapped as well.
     61  */
     62 struct igs_bittab {
     63 	u_int16_t iexpand[256];	/* image: 0 -> 00, 1 -> 01 */
     64 	u_int16_t mexpand[256];	/* mask:  0 -> 00, 1 -> 11 */
     65 };
     66 
     67 
     68 struct igsfb_softc {
     69 	struct device sc_dev;
     70 
     71 	/* io registers */
     72 	bus_space_tag_t sc_iot;
     73 	bus_space_handle_t sc_ioh;
     74 	bus_space_handle_t sc_crtch;
     75 
     76 	/* linear memory */
     77 	bus_space_tag_t sc_memt;
     78 	bus_addr_t sc_memaddr;
     79 	bus_size_t sc_memsz; /* size of linear address space including mmio */
     80 	int sc_memflags;
     81 
     82 	/* video memory size */
     83 	bus_size_t sc_vmemsz;
     84 
     85 	/* fb part actually mapped for wsdisplay */
     86 	bus_space_handle_t sc_fbh;
     87 	bus_size_t sc_fbsz;
     88 
     89 	/* 1k of cursor sprite data */
     90 	bus_space_handle_t sc_crh;
     91 
     92 	/*
     93 	 * graphic coprocessor can be accessed either via i/o space
     94 	 * or via memory-mapped i/o access through memory space
     95 	 */
     96 	bus_space_tag_t sc_copt;
     97 	bus_space_handle_t sc_coph;
     98 
     99 	/* IGA1682 vs CyberPro 2k (use version num. for finer distinction?) */
    100 	int sc_is2k;
    101 
    102 	/* flags that control driver operation */
    103 	int sc_hwflags;
    104 #define IGSFB_HW_BSWAP		0x1	/* endianness mismatch */
    105 
    106 	struct rasops_info *sc_ri;
    107 
    108 	struct igs_hwcmap sc_cmap;	/* software copy of colormap */
    109 	struct igs_hwcursor sc_cursor;	/* software copy of cursor sprite */
    110 
    111 	/* precomputed bit tables for cursor sprite 1bpp -> 2bpp conversion */
    112 	struct igs_bittab *sc_bittab;
    113 
    114 	int nscreens;
    115 
    116 	int sc_blanked;			/* screen is currently blanked */
    117 	int sc_curenb;			/* cursor sprite enabled */
    118 };
    119 
    120 
    121 /*
    122  * Access sugar for indexed registers
    123  */
    124 
    125 static __inline__ u_int8_t
    126 igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, u_int8_t);
    127 static __inline__ void
    128 igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, u_int8_t, u_int8_t);
    129 
    130 static __inline__ u_int8_t
    131 igs_idx_read(t, h, idxport, idx)
    132 	bus_space_tag_t t;
    133 	bus_space_handle_t h;
    134 	u_int idxport;
    135 	u_int8_t idx;
    136 {
    137 	bus_space_write_1(t, h, idxport, idx);
    138 	return (bus_space_read_1(t, h, idxport + 1));
    139 }
    140 
    141 static __inline__ void
    142 igs_idx_write(t, h, idxport, idx, val)
    143 	bus_space_tag_t t;
    144 	bus_space_handle_t h;
    145 	u_int idxport;
    146 	u_int8_t idx, val;
    147 {
    148 	bus_space_write_1(t, h, idxport, idx);
    149 	bus_space_write_1(t, h, idxport + 1, val);
    150 }
    151 
    152 
    153 /* sugar for sequencer controller */
    154 #define igs_seq_read(t,h,x)	\
    155 	(igs_idx_read((t),(h),IGS_SEQ_IDX,(x)))
    156 #define igs_seq_write(t,h,x,v)	\
    157 	(igs_idx_write((t),(h),IGS_SEQ_IDX,(x),(v)))
    158 
    159 
    160 /* sugar for CRT controller */
    161 #define igs_crtc_read(t,h,x)	\
    162 	(igs_idx_read((t),(h),IGS_CRTC_IDX,(x)))
    163 #define igs_crtc_write(t,h,x,v)	\
    164 	(igs_idx_write((t),(h),IGS_CRTC_IDX,(x),(v)))
    165 
    166 
    167 /* sugar for attribute controller */
    168 #define igs_attr_flip_flop(t,h)	\
    169 	((void)bus_space_read_1((t),(h),IGS_INPUT_STATUS1));
    170 #define igs_attr_read(t,h,x)	\
    171 	(igs_idx_read((t),(h),IGS_ATTR_IDX,(x)))
    172 
    173 static __inline__ void
    174 igs_attr_write(bus_space_tag_t, bus_space_handle_t, u_int8_t, u_int8_t);
    175 
    176 static __inline__ void
    177 igs_attr_write(t, h, idx, val)
    178 	bus_space_tag_t t;
    179 	bus_space_handle_t h;
    180 	u_int8_t idx, val;
    181 {
    182 	bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
    183 	bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
    184 }
    185 
    186 
    187 /* sugar for graphics controller registers */
    188 #define igs_grfx_read(t,h,x)	(igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
    189 #define igs_grfx_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
    190 
    191 
    192 /* sugar for extended registers */
    193 #define igs_ext_read(t,h,x)	(igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
    194 #define igs_ext_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
    195 
    196 
    197 /* igsfb_subr.c */
    198 int	igsfb_enable(bus_space_tag_t);
    199 void	igsfb_hw_setup(struct igsfb_softc *);
    200 void	igsfb_1024x768_8bpp_60Hz(struct igsfb_softc *);
    201 
    202 /* igsfb.c */
    203 void	igsfb_common_attach(struct igsfb_softc *, int);
    204 
    205 #endif /* _DEV_IC_IGSFBVAR_H_ */
    206