Home | History | Annotate | Line # | Download | only in pci
      1  1.1  macallan /*	$NetBSD: mgafbvar.h,v 1.1 2026/03/17 10:03:02 macallan Exp $	*/
      2  1.1  macallan 
      3  1.1  macallan /*
      4  1.1  macallan  * Copyright (c) 2024 The NetBSD Foundation, Inc.
      5  1.1  macallan  * All rights reserved.
      6  1.1  macallan  *
      7  1.1  macallan  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  macallan  * by Radoslaw Kujawa.
      9  1.1  macallan  *
     10  1.1  macallan  * Redistribution and use in source and binary forms, with or without
     11  1.1  macallan  * modification, are permitted provided that the following conditions
     12  1.1  macallan  * are met:
     13  1.1  macallan  * 1. Redistributions of source code must retain the above copyright
     14  1.1  macallan  *    notice, this list of conditions and the following disclaimer.
     15  1.1  macallan  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  macallan  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  macallan  *    documentation and/or other materials provided with the distribution.
     18  1.1  macallan  *
     19  1.1  macallan  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  1.1  macallan  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  1.1  macallan  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  1.1  macallan  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  1.1  macallan  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  1.1  macallan  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  1.1  macallan  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  1.1  macallan  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  1.1  macallan  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  1.1  macallan  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  1.1  macallan  */
     30  1.1  macallan 
     31  1.1  macallan #ifndef MGAFBVAR_H
     32  1.1  macallan #define MGAFBVAR_H
     33  1.1  macallan 
     34  1.1  macallan #include "opt_mgafb.h"
     35  1.1  macallan 
     36  1.1  macallan #include <dev/videomode/videomode.h>
     37  1.1  macallan #include <dev/videomode/edidvar.h>
     38  1.1  macallan 
     39  1.1  macallan #include <dev/i2c/i2cvar.h>
     40  1.1  macallan 
     41  1.1  macallan #include <dev/wscons/wsdisplayvar.h>
     42  1.1  macallan #include <dev/wscons/wsconsio.h>
     43  1.1  macallan #include <dev/wsfont/wsfont.h>
     44  1.1  macallan #include <dev/rasops/rasops.h>
     45  1.1  macallan #include <dev/wscons/wsdisplay_vconsvar.h>
     46  1.1  macallan #include <dev/wscons/wsdisplay_glyphcachevar.h>
     47  1.1  macallan 
     48  1.1  macallan enum mgafb_chip {
     49  1.1  macallan 	MGAFB_CHIP_2064W,	/* MGA-2064W (Millennium) */
     50  1.1  macallan 	MGAFB_CHIP_2164W,	/* MGA-2164W (Millennium II) */
     51  1.1  macallan 	MGAFB_CHIP_1064SG,	/* MGA-1064SG (Mystique) */
     52  1.1  macallan };
     53  1.1  macallan 
     54  1.1  macallan struct mgafb_chip_info {
     55  1.1  macallan 	const char	*ci_name;	/* short chip name for messages */
     56  1.1  macallan 	uint32_t	ci_max_pclk;	/* default max pixel clock (kHz) */
     57  1.1  macallan 	uint32_t	ci_vram_default;/* fallback VRAM if probe skipped */
     58  1.1  macallan 	bool		ci_has_tvp3026;	/* external TVP3026 DAC? */
     59  1.1  macallan 	bool		ci_has_wram;	/* WRAM (vs SGRAM/SDRAM)? */
     60  1.1  macallan 	bool		ci_probe_vram;	/* can we probe VRAM size? */
     61  1.1  macallan };
     62  1.1  macallan 
     63  1.1  macallan struct mgafb_softc {
     64  1.1  macallan 	device_t		sc_dev;
     65  1.1  macallan 	pci_chipset_tag_t	sc_pc;
     66  1.1  macallan 	pcitag_t		sc_pcitag;
     67  1.1  macallan 
     68  1.1  macallan 	enum mgafb_chip		sc_chip;
     69  1.1  macallan 	const struct mgafb_chip_info *sc_ci;
     70  1.1  macallan 
     71  1.1  macallan 	/*
     72  1.1  macallan 	 * PInS data read from the card's ROM during attach.
     73  1.1  macallan 	 */
     74  1.1  macallan 	bool			sc_pins_valid;
     75  1.1  macallan 	uint32_t		sc_pins_mclk_khz;	/* system / MCLK target */
     76  1.1  macallan 	uint32_t		sc_pins_maxdac_khz;	/* max pixel clock */
     77  1.1  macallan 
     78  1.1  macallan 	bus_space_tag_t		sc_regt;
     79  1.1  macallan 	bus_space_handle_t	sc_regh;
     80  1.1  macallan 	bus_addr_t		sc_reg_pa;
     81  1.1  macallan 	bus_size_t		sc_reg_size;
     82  1.1  macallan 
     83  1.1  macallan 	bus_space_tag_t		sc_fbt;
     84  1.1  macallan 	bus_space_handle_t	sc_fbh;
     85  1.1  macallan 	bus_addr_t		sc_fb_pa;
     86  1.1  macallan 	bus_size_t		sc_fb_size;
     87  1.1  macallan 
     88  1.1  macallan 	bus_size_t		sc_vram_size;
     89  1.1  macallan 
     90  1.1  macallan 	const struct videomode	*sc_videomode;	/* selected video mode */
     91  1.1  macallan 
     92  1.1  macallan 	int			sc_width;
     93  1.1  macallan 	int			sc_height;
     94  1.1  macallan 	int			sc_depth;
     95  1.1  macallan 	int			sc_stride;	/* bytes per line */
     96  1.1  macallan 	int			sc_mode;
     97  1.1  macallan 	int			sc_video;	/* WSDISPLAYIO_VIDEO_ON/OFF */
     98  1.1  macallan 
     99  1.1  macallan 	struct vcons_data	vd;
    100  1.1  macallan 	struct vcons_screen	sc_console_screen;
    101  1.1  macallan 	struct wsscreen_descr	sc_defaultscreen_descr;
    102  1.1  macallan 	const struct wsscreen_descr *sc_screens[1];
    103  1.1  macallan 	struct wsscreen_list	sc_screenlist;
    104  1.1  macallan 
    105  1.1  macallan 	uint8_t			sc_cmap_red[256];
    106  1.1  macallan 	uint8_t			sc_cmap_green[256];
    107  1.1  macallan 	uint8_t			sc_cmap_blue[256];
    108  1.1  macallan 
    109  1.1  macallan 	glyphcache		sc_gc;
    110  1.1  macallan 
    111  1.1  macallan 	struct mgafb_cursor {
    112  1.1  macallan 		bool		mc_enabled;
    113  1.1  macallan 		uint8_t		mc_r[2];	/* [0]=bg, [1]=fg */
    114  1.1  macallan 		uint8_t		mc_g[2];
    115  1.1  macallan 		uint8_t		mc_b[2];
    116  1.1  macallan 	}			sc_cursor;
    117  1.1  macallan 
    118  1.1  macallan 	struct i2c_controller	sc_i2c;
    119  1.1  macallan 	uint8_t			sc_ddc_ctl;
    120  1.1  macallan 	bool			sc_edid_valid;
    121  1.1  macallan 	uint8_t			sc_edid[128];
    122  1.1  macallan 	struct edid_info	sc_edid_info;
    123  1.1  macallan };
    124  1.1  macallan 
    125  1.1  macallan #endif /* MGAFBVAR_H */
    126