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