Home | History | Annotate | Line # | Download | only in pci
      1  1.18        he /* $NetBSD: tgavar.h,v 1.18 2009/05/18 00:14:27 he Exp $ */
      2   1.1  drochner 
      3   1.1  drochner /*
      4   1.1  drochner  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5   1.1  drochner  * All rights reserved.
      6   1.1  drochner  *
      7   1.1  drochner  * Author: Chris G. Demetriou
      8  1.14     perry  *
      9   1.1  drochner  * Permission to use, copy, modify and distribute this software and
     10   1.1  drochner  * its documentation is hereby granted, provided that both the copyright
     11   1.1  drochner  * notice and this permission notice appear in all copies of the
     12   1.1  drochner  * software, derivative works or modified versions, and any portions
     13   1.1  drochner  * thereof, and that both notices appear in supporting documentation.
     14  1.14     perry  *
     15  1.14     perry  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  1.14     perry  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17   1.1  drochner  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  1.14     perry  *
     19   1.1  drochner  * Carnegie Mellon requests users of this software to return to
     20   1.1  drochner  *
     21   1.1  drochner  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22   1.1  drochner  *  School of Computer Science
     23   1.1  drochner  *  Carnegie Mellon University
     24   1.1  drochner  *  Pittsburgh PA 15213-3890
     25   1.1  drochner  *
     26   1.1  drochner  * any improvements or extensions that they make and grant Carnegie the
     27   1.1  drochner  * rights to redistribute these changes.
     28   1.1  drochner  */
     29   1.1  drochner 
     30   1.5     elric #include <dev/ic/ramdac.h>
     31   1.1  drochner #include <dev/pci/tgareg.h>
     32   1.1  drochner #include <dev/wscons/wsconsio.h>
     33   1.1  drochner #include <dev/wscons/wscons_raster.h>
     34   1.9   nathanw #include <dev/wscons/wsdisplayvar.h>
     35   1.9   nathanw #include <dev/rasops/rasops.h>
     36   1.1  drochner 
     37   1.1  drochner struct tga_devconfig;
     38   1.1  drochner struct fbcmap;
     39   1.1  drochner struct fbcursor;
     40   1.1  drochner struct fbcurpos;
     41   1.1  drochner 
     42   1.1  drochner struct tga_conf {
     43  1.15  drochner 	const char	    *tgac_name;		/* name for this board type */
     44   1.1  drochner 
     45  1.13     perry 	struct ramdac_funcs *(*ramdac_funcs)(void);
     46   1.8   nathanw 
     47   1.1  drochner 	int	    tgac_phys_depth;	/* physical frame buffer depth */
     48   1.2       eeh 	vsize_t   tgac_cspace_size;	/* core space size */
     49   1.2       eeh 	vsize_t   tgac_vvbr_units;	/* what '1' in the VVBR means */
     50   1.1  drochner 
     51   1.1  drochner 	int	    tgac_ndbuf;		/* number of display buffers */
     52   1.2       eeh 	vaddr_t tgac_dbuf[2];	/* display buffer offsets/addresses */
     53   1.2       eeh 	vsize_t   tgac_dbufsz[2];	/* display buffer sizes */
     54   1.1  drochner 
     55   1.1  drochner 	int	    tgac_nbbuf;		/* number of display buffers */
     56   1.2       eeh 	vaddr_t tgac_bbuf[2];	/* back buffer offsets/addresses */
     57   1.2       eeh 	vsize_t   tgac_bbufsz[2];	/* back buffer sizes */
     58   1.1  drochner };
     59   1.1  drochner 
     60   1.1  drochner struct tga_devconfig {
     61   1.1  drochner 	bus_space_tag_t dc_memt;
     62   1.7   nathanw 	bus_space_handle_t dc_memh;
     63   1.1  drochner 
     64  1.17     ahoka 	pci_chipset_tag_t dc_pc;	/* PCI chipset tag */
     65   1.1  drochner 	pcitag_t   	 dc_pcitag;	/* PCI tag */
     66   1.1  drochner 	bus_addr_t	 dc_pcipaddr;	/* PCI phys addr. */
     67   1.1  drochner 
     68   1.7   nathanw 	bus_space_handle_t dc_regs;	/* registers; XXX: need aliases */
     69   1.1  drochner 
     70   1.1  drochner 	int	    dc_tga_type;	/* the device type; see below */
     71   1.6     elric 	int	    dc_tga2;		/* True if it is a TGA2 */
     72   1.1  drochner 	const struct tga_conf *dc_tgaconf; /* device buffer configuration */
     73   1.1  drochner 
     74   1.5     elric 	struct ramdac_funcs
     75   1.5     elric 		    *dc_ramdac_funcs;	/* The RAMDAC functions */
     76   1.5     elric 	struct ramdac_cookie
     77   1.5     elric 		    *dc_ramdac_cookie;	/* the RAMDAC type; see above */
     78   1.5     elric 
     79   1.2       eeh 	vaddr_t dc_vaddr;		/* memory space virtual base address */
     80   1.1  drochner 
     81   1.1  drochner 	int	    dc_wid;		/* width of frame buffer */
     82   1.1  drochner 	int	    dc_ht;		/* height of frame buffer */
     83   1.1  drochner 	int	    dc_rowbytes;	/* bytes in a FB scan line */
     84   1.1  drochner 
     85   1.2       eeh 	vaddr_t dc_videobase;	/* base of flat frame buffer */
     86   1.1  drochner 
     87   1.9   nathanw 	struct rasops_info dc_rinfo;	/* raster display data */
     88   1.1  drochner 
     89   1.1  drochner 	int	    dc_blanked;		/* currently had video disabled */
     90   1.1  drochner 	void	    *dc_ramdac_private; /* RAMDAC private storage */
     91   1.5     elric 
     92  1.13     perry 	void	    (*dc_ramdac_intr)(void *);
     93   1.8   nathanw 	int		dc_intrenabled; /* can we depend on interrupts yet? */
     94   1.1  drochner };
     95  1.14     perry 
     96   1.1  drochner struct tga_softc {
     97  1.18        he 	device_t	 sc_dev;
     98   1.1  drochner 
     99   1.1  drochner 	struct	tga_devconfig *sc_dc;	/* device configuration */
    100   1.1  drochner 	void	*sc_intr;		/* interrupt handler info */
    101   1.1  drochner 	/* XXX should record intr fns/arg */
    102   1.1  drochner 
    103   1.1  drochner 	int nscreens;
    104   1.1  drochner };
    105   1.1  drochner 
    106   1.1  drochner #define	TGA_TYPE_T8_01		0	/* 8bpp, 1MB */
    107   1.1  drochner #define	TGA_TYPE_T8_02		1	/* 8bpp, 2MB */
    108   1.1  drochner #define	TGA_TYPE_T8_22		2	/* 8bpp, 4MB */
    109   1.1  drochner #define	TGA_TYPE_T8_44		3	/* 8bpp, 8MB */
    110   1.1  drochner #define	TGA_TYPE_T32_04		4	/* 32bpp, 4MB */
    111   1.1  drochner #define	TGA_TYPE_T32_08		5	/* 32bpp, 8MB */
    112   1.1  drochner #define	TGA_TYPE_T32_88		6	/* 32bpp, 16MB */
    113  1.12     elric #define	TGA_TYPE_POWERSTORM_4D20	7	/* unknown */
    114  1.12     elric #define	TGA_TYPE_UNKNOWN	8	/* unknown */
    115   1.1  drochner 
    116   1.1  drochner #define	DEVICE_IS_TGA(class, id)					\
    117   1.6     elric 	    (((PCI_VENDOR(id) == PCI_VENDOR_DEC &&			\
    118   1.6     elric 	       PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) ||		\
    119   1.6     elric 	       PCI_PRODUCT(id) == PCI_PRODUCT_DEC_PBXGB) ? 10 : 0)
    120   1.1  drochner 
    121  1.13     perry int tga_cnmatch(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t, pcitag_t);
    122  1.13     perry int tga_cnattach(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
    123  1.13     perry 		      int, int, int);
    124  1.13     perry 
    125  1.13     perry int tga_identify(struct tga_devconfig *);
    126  1.13     perry const struct tga_conf *tga_getconf(int);
    127  1.13     perry 
    128  1.13     perry int tga_builtin_set_cursor(struct tga_devconfig *, struct wsdisplay_cursor *);
    129  1.13     perry int tga_builtin_get_cursor(struct tga_devconfig *, struct wsdisplay_cursor *);
    130  1.13     perry int tga_builtin_set_curpos(struct tga_devconfig *, struct wsdisplay_curpos *);
    131  1.13     perry int tga_builtin_get_curpos(struct tga_devconfig *, struct wsdisplay_curpos *);
    132  1.13     perry int tga_builtin_get_curmax(struct tga_devconfig *, struct wsdisplay_curpos *);
    133   1.7   nathanw 
    134   1.7   nathanw /* Read a TGA register */
    135   1.7   nathanw #define TGARREG(dc,reg) (bus_space_read_4((dc)->dc_memt, (dc)->dc_regs, \
    136   1.7   nathanw 	(reg) << 2))
    137   1.7   nathanw 
    138   1.7   nathanw /* Write a TGA register */
    139   1.7   nathanw #define TGAWREG(dc,reg,val) bus_space_write_4((dc)->dc_memt, (dc)->dc_regs, \
    140   1.7   nathanw 	(reg) << 2, (val))
    141   1.7   nathanw 
    142   1.7   nathanw /* Write a TGA register at an alternate aliased location */
    143   1.7   nathanw #define TGAWALREG(dc,reg,alias,val) bus_space_write_4( \
    144   1.7   nathanw 	(dc)->dc_memt, (dc)->dc_regs, \
    145   1.7   nathanw 	((alias) * TGA_CREGS_ALIAS) + ((reg) << 2), \
    146   1.7   nathanw 	(val))
    147   1.7   nathanw 
    148   1.7   nathanw /* Insert a write barrier */
    149   1.7   nathanw #define TGAREGWB(dc,reg, nregs) bus_space_barrier( \
    150   1.7   nathanw 	(dc)->dc_memt, (dc)->dc_regs, \
    151   1.7   nathanw 	((reg) << 2), 4 * (nregs), BUS_SPACE_BARRIER_WRITE)
    152   1.7   nathanw 
    153   1.7   nathanw /* Insert a read barrier */
    154   1.7   nathanw #define TGAREGRB(dc,reg, nregs) bus_space_barrier( \
    155   1.7   nathanw 	(dc)->dc_memt, (dc)->dc_regs, \
    156   1.7   nathanw 	((reg) << 2), 4 * (nregs), BUS_SPACE_BARRIER_READ)
    157   1.7   nathanw 
    158   1.7   nathanw /* Insert a read/write barrier */
    159   1.7   nathanw #define TGAREGRWB(dc,reg, nregs) bus_space_barrier( \
    160   1.7   nathanw 	(dc)->dc_memt, (dc)->dc_regs, \
    161   1.7   nathanw 	((reg) << 2), 4 * (nregs), \
    162   1.7   nathanw 	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
    163