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