Home | History | Annotate | Line # | Download | only in ic
igsfbvar.h revision 1.13.4.1
      1  1.13.4.1      elad /*	$NetBSD: igsfbvar.h,v 1.13.4.1 2006/04/19 03:24:39 elad Exp $ */
      2       1.1       uwe 
      3       1.1       uwe /*
      4       1.5       uwe  * Copyright (c) 2002, 2003 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.1       uwe  */
     33       1.1       uwe #ifndef _DEV_IC_IGSFBVAR_H_
     34       1.1       uwe #define _DEV_IC_IGSFBVAR_H_
     35       1.1       uwe 
     36       1.1       uwe #define	IGS_CMAP_SIZE	256	/* 256 R/G/B entries */
     37       1.1       uwe struct igs_hwcmap {
     38       1.9       uwe 	uint8_t r[IGS_CMAP_SIZE];
     39       1.9       uwe 	uint8_t g[IGS_CMAP_SIZE];
     40       1.9       uwe 	uint8_t b[IGS_CMAP_SIZE];
     41       1.1       uwe };
     42       1.1       uwe 
     43       1.1       uwe 
     44       1.1       uwe #define IGS_CURSOR_MAX_SIZE 64	/* 64x64 sprite */
     45       1.1       uwe struct igs_hwcursor {
     46       1.1       uwe 	struct wsdisplay_curpos cc_pos;
     47       1.1       uwe 	struct wsdisplay_curpos cc_hot;
     48       1.1       uwe 	struct wsdisplay_curpos cc_size;
     49       1.9       uwe 	uint8_t cc_image[512];		/* save copy of image for GCURSOR */
     50       1.9       uwe 	uint8_t cc_mask[512];		/* save copy of mask for GCURSOR */
     51       1.9       uwe 	uint16_t cc_sprite[512];	/* sprite in device 2bpp format */
     52       1.9       uwe 	uint8_t cc_color[6];		/* 2 colors, 3 rgb components */
     53       1.1       uwe };
     54       1.1       uwe 
     55       1.1       uwe 
     56       1.5       uwe struct igsfb_devconfig {
     57       1.5       uwe 	/* io space, may be memory mapped */
     58       1.5       uwe 	bus_space_tag_t dc_iot;
     59       1.5       uwe 	bus_addr_t dc_iobase;
     60       1.5       uwe 	int dc_ioflags;
     61       1.1       uwe 
     62       1.1       uwe 	/* io registers */
     63       1.5       uwe 	bus_space_handle_t dc_ioh;
     64       1.1       uwe 
     65       1.8       uwe 	/* graphic coprocessor */
     66       1.8       uwe 	bus_space_handle_t dc_coph;
     67       1.8       uwe 
     68       1.1       uwe 	/* linear memory */
     69       1.5       uwe 	bus_space_tag_t dc_memt;
     70       1.5       uwe 	bus_addr_t dc_memaddr;
     71       1.5       uwe 	bus_size_t dc_memsz; /* size of linear address space including mmio */
     72       1.5       uwe 	int dc_memflags;
     73       1.5       uwe 
     74       1.8       uwe 	/* video memory size */
     75       1.5       uwe 	bus_size_t dc_vmemsz;
     76       1.1       uwe 
     77       1.5       uwe 	/* resolution */
     78  1.13.4.1      elad 	int dc_width, dc_height, dc_depth, dc_stride;
     79       1.1       uwe 
     80       1.5       uwe 	/* part of video memory mapped for wsscreen */
     81       1.5       uwe 	bus_space_handle_t dc_fbh;
     82       1.5       uwe 	bus_size_t dc_fbsz;
     83       1.5       uwe 
     84       1.5       uwe 	/* 1KB of cursor sprite data */
     85       1.5       uwe 	bus_space_handle_t dc_crh;
     86       1.5       uwe 
     87       1.5       uwe 	/* product id: IGA 168x, CyberPro 2k &c */
     88       1.5       uwe 	int dc_id;
     89       1.1       uwe 
     90       1.1       uwe 	/* flags that control driver operation */
     91       1.5       uwe 	int dc_hwflags;
     92       1.5       uwe #define IGSFB_HW_BSWAP			0x1 /* endianness mismatch */
     93       1.5       uwe #define IGSFB_HW_BE_SELECT		0x2 /* big endian magic (cyberpro) */
     94       1.7       uwe #define IGSFB_HW_TEXT_CURSOR		0x4 /* do text cursor in hardware */
     95       1.5       uwe 
     96       1.5       uwe /* do we need to do bswap in software? */
     97       1.5       uwe #define IGSFB_HW_SOFT_BSWAP(dc)						\
     98       1.5       uwe 	((((dc)->dc_hwflags) & (IGSFB_HW_BSWAP | IGSFB_HW_BE_SELECT))	\
     99       1.5       uwe 		== IGSFB_HW_BSWAP)
    100       1.1       uwe 
    101       1.7       uwe 	int dc_blanked;			/* screen is currently blanked */
    102       1.7       uwe 	int dc_curenb;			/* cursor sprite enabled */
    103       1.7       uwe 	int dc_mapped;			/* currently in mapped mode */
    104       1.7       uwe 
    105       1.8       uwe 	/* saved dc_ri.ri_ops.putchar */
    106       1.8       uwe 	void (*dc_ri_putchar)(void *, int, int, u_int, long);
    107       1.1       uwe 
    108       1.5       uwe 	struct igs_hwcmap dc_cmap;	/* software copy of colormap */
    109       1.5       uwe 	struct igs_hwcursor dc_cursor;	/* software copy of cursor sprite */
    110       1.1       uwe 
    111       1.6       uwe 	/* precomputed bit table for cursor sprite 1bpp -> 2bpp conversion */
    112       1.9       uwe 	uint16_t dc_bexpand[256];
    113  1.13.4.1      elad 
    114      1.13  macallan 	/* virtual console support */
    115      1.13  macallan 	struct vcons_data dc_vd;
    116      1.13  macallan 	struct vcons_screen dc_console;
    117       1.5       uwe };
    118       1.1       uwe 
    119       1.1       uwe 
    120       1.5       uwe struct igsfb_softc {
    121       1.5       uwe 	struct device sc_dev;
    122       1.5       uwe 	struct igsfb_devconfig *sc_dc;
    123       1.1       uwe };
    124       1.1       uwe 
    125       1.2       uwe 
    126       1.5       uwe 
    127       1.2       uwe /*
    128       1.2       uwe  * Access sugar for indexed registers
    129       1.2       uwe  */
    130       1.2       uwe 
    131      1.12     perry static __inline uint8_t
    132       1.9       uwe igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t);
    133      1.12     perry static __inline void
    134       1.9       uwe igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, uint8_t, uint8_t);
    135       1.2       uwe 
    136      1.12     perry static __inline uint8_t
    137  1.13.4.1      elad igs_idx_read(bus_space_tag_t t, bus_space_handle_t h,
    138  1.13.4.1      elad 	     u_int idxport, uint8_t idx)
    139       1.2       uwe {
    140       1.2       uwe 	bus_space_write_1(t, h, idxport, idx);
    141       1.2       uwe 	return (bus_space_read_1(t, h, idxport + 1));
    142       1.2       uwe }
    143       1.2       uwe 
    144      1.12     perry static __inline void
    145  1.13.4.1      elad igs_idx_write(bus_space_tag_t t, bus_space_handle_t h,
    146  1.13.4.1      elad 	      u_int idxport, uint8_t idx, uint8_t 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.12     perry static __inline void
    174       1.9       uwe igs_attr_write(bus_space_tag_t, bus_space_handle_t, uint8_t, uint8_t);
    175       1.3       uwe 
    176      1.12     perry static __inline void
    177  1.13.4.1      elad igs_attr_write(bus_space_tag_t t, bus_space_handle_t h,
    178  1.13.4.1      elad 	       uint8_t idx, uint8_t val)
    179       1.3       uwe {
    180       1.3       uwe 	bus_space_write_1(t, h, IGS_ATTR_IDX, idx);
    181       1.3       uwe 	bus_space_write_1(t, h, IGS_ATTR_IDX, val); /* sic, same register */
    182       1.3       uwe }
    183       1.3       uwe 
    184       1.3       uwe 
    185       1.3       uwe /* sugar for graphics controller registers */
    186       1.3       uwe #define igs_grfx_read(t,h,x)	(igs_idx_read((t),(h),IGS_GRFX_IDX,(x)))
    187       1.3       uwe #define igs_grfx_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_GRFX_IDX,(x),(v)))
    188       1.3       uwe 
    189       1.3       uwe 
    190       1.3       uwe /* sugar for extended registers */
    191       1.2       uwe #define igs_ext_read(t,h,x)	(igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
    192       1.2       uwe #define igs_ext_write(t,h,x,v)	(igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
    193       1.1       uwe 
    194       1.1       uwe 
    195       1.3       uwe /* igsfb_subr.c */
    196       1.5       uwe int	igsfb_enable(bus_space_tag_t, bus_addr_t, int);
    197       1.5       uwe void	igsfb_hw_setup(struct igsfb_devconfig *);
    198       1.5       uwe void	igsfb_1024x768_8bpp_60Hz(struct igsfb_devconfig *);
    199       1.3       uwe 
    200       1.3       uwe /* igsfb.c */
    201       1.5       uwe int	igsfb_cnattach_subr(struct igsfb_devconfig *);
    202       1.5       uwe void	igsfb_attach_subr(struct igsfb_softc *, int);
    203       1.5       uwe 
    204       1.5       uwe 
    205       1.5       uwe extern struct igsfb_devconfig igsfb_console_dc;
    206       1.1       uwe 
    207       1.1       uwe #endif /* _DEV_IC_IGSFBVAR_H_ */
    208