Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Add machfb, ATI Mach64/Rage framebuffer display ...
details: https://anonhg.NetBSD.org/src/rev/4add72e2e3e5
branches: trunk
changeset: 538654:4add72e2e3e5
user: junyoung <junyoung%NetBSD.org@localhost>
date: Thu Oct 24 18:15:57 2002 +0000
description:
Add machfb, ATI Mach64/Rage framebuffer display driver.
XXX this version is not fully functional yet. More to come shortly.
diffstat:
sys/dev/pci/files.pci | 7 +-
sys/dev/pci/machfb.c | 1267 +++++++++++++++++++++++++++++++++++++++++++++++
sys/dev/pci/machfbreg.h | 409 +++++++++++++++
3 files changed, 1682 insertions(+), 1 deletions(-)
diffs (truncated from 1702 to 300 lines):
diff -r e5c557b3ae43 -r 4add72e2e3e5 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci Thu Oct 24 16:41:00 2002 +0000
+++ b/sys/dev/pci/files.pci Thu Oct 24 18:15:57 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pci,v 1.181 2002/10/11 00:57:59 thorpej Exp $
+# $NetBSD: files.pci,v 1.182 2002/10/24 18:15:57 junyoung Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@@ -580,3 +580,8 @@
# Game adapter (joystick)
attach joy at pci with joy_pci
file dev/pci/joy_pci.c joy_pci
+
+# ATI Mach64 framebuffer console driver
+device machfb: wsemuldisplaydev, rasops8
+attach machfb at pci
+file dev/pci/machfb.c machfb
diff -r e5c557b3ae43 -r 4add72e2e3e5 sys/dev/pci/machfb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/machfb.c Thu Oct 24 18:15:57 2002 +0000
@@ -0,0 +1,1267 @@
+/* $NetBSD: machfb.c,v 1.1 2002/10/24 18:15:57 junyoung Exp $ */
+
+/*
+ * Copyright (c) 2002 Bang Jun-Young
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Some code is derived from ATI Rage Pro and Derivatives Programmer's Guide.
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/callout.h>
+
+#include <dev/ic/videomode.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pciio.h>
+#include <dev/pci/machfbreg.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+
+#define MACH64_REG_SIZE 1024
+
+#define NBARS 3 /* number of Mach64 PCI BARs */
+
+struct vga_bar {
+ bus_addr_t vb_base;
+ bus_size_t vb_size;
+ pcireg_t vb_type;
+ int vb_flags;
+};
+
+struct mach64_softc {
+ struct device sc_dev;
+ pci_chipset_tag_t sc_pc;
+ pcitag_t sc_pcitag;
+
+ struct vga_bar sc_bars[NBARS];
+ struct vga_bar sc_rom;
+
+#define sc_aperbase sc_bars[0].vb_base
+#define sc_apersize sc_bars[0].vb_size
+
+#define sc_iobase sc_bars[1].vb_base
+#define sc_iosize sc_bars[1].vb_size
+
+#define sc_regbase sc_bars[2].vb_base
+#define sc_regsize sc_bars[2].vb_size
+
+ bus_space_handle_t sc_regh;
+ bus_space_handle_t sc_memh;
+
+ u_int aperbase;
+ size_t apersize;
+ u_int regbase;
+ size_t regsize;
+ size_t memsize;
+ int memtype;
+
+ int has_dsp;
+ int bits_per_pixel;
+ int max_x, max_y;
+ int virt_x, virt_y;
+ int color_depth;
+
+ int mem_freq;
+ int ramdac_freq;
+ int ref_freq;
+
+ int ref_div;
+ int log2_vclk_post_div;
+ int vclk_post_div;
+ int vclk_fb_div;
+ int mclk_post_div;
+ int mclk_fb_div;
+
+ struct mach64screen *wanted;
+ struct mach64screen *active;
+ void (*switchcb)(void *, int, int);
+ void *switchcbarg;
+ struct callout switch_callout;
+ int nscreens;
+ LIST_HEAD(, mach64screen) screens;
+ const struct wsscreen_descr *currenttype;
+};
+
+struct mach64screen {
+ LIST_ENTRY(mach64screen) next;
+ struct mach64_softc *sc;
+ const struct wsscreen_descr *type;
+ int active;
+ u_int16_t *mem;
+ int dispoffset;
+ int mindispoffset;
+ int maxdispoffset;
+
+ int cursoron;
+ int cursorcol;
+ int cursorrow;
+ u_int16_t cursortmp;
+};
+
+struct mach64_crtcregs {
+ u_int32_t h_total_disp;
+ u_int32_t h_sync_strt_wid;
+ u_int32_t v_total_disp;
+ u_int32_t v_sync_strt_wid;
+ u_int32_t gen_cntl;
+ u_int32_t clock_cntl;
+ u_int32_t color_depth;
+ u_int32_t dot_clock;
+};
+
+struct {
+ u_int16_t chip_id;
+ u_int32_t ramdac_freq;
+} mach64_info[] = {
+ { PCI_PRODUCT_ATI_MACH64_CT, 135000 },
+ { PCI_PRODUCT_ATI_RAGE_PRO_AGP, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_PRO_AGP1X, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_PRO_PCI_B, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_XL_AGP, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_PRO_PCI_P, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_PRO_PCI_L, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_XL_PCI, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_II, 135000 },
+ { PCI_PRODUCT_ATI_RAGE_IIP, 200000 },
+ { PCI_PRODUCT_ATI_RAGE_IIC_PCI, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_IIC_AGP_B, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_IIC_AGP_P, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_LT_PRO_AGP, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_MOB_M3_PCI, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_MOB_M3_AGP, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_LT, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_LT_PRO_PCI, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_MOBILITY, 230000 },
+ { PCI_PRODUCT_ATI_RAGE_LT_PRO, 230000 },
+ { PCI_PRODUCT_ATI_MACH64_VT, 170000 },
+ { PCI_PRODUCT_ATI_MACH64_VTB, 200000 },
+ { PCI_PRODUCT_ATI_MACH64_VT4, 230000 }
+};
+
+static int mach64_chip_id, mach64_chip_rev;
+static struct videomode default_mode;
+struct rasops_info mach64_rasops_info;
+static struct mach64screen mach64_console_screen;
+
+static char *mach64_memtype_names[] = {
+ "(N/A)", "DRAM", "EDO DRAM", "EDO DRAM", "SDRAM", "SGRAM", "WRAM",
+ "(unknown type)"
+};
+
+struct videomode mach64_modes[] = {
+ /* 640x400 @ 70 Hz, 31.5 kHz */
+ { 25175, 640, 664, 760, 800, 400, 409, 411, 450, 0 },
+ /* 640x480 @ 72 Hz, 36.5 kHz */
+ { 25175, 640, 664, 760, 800, 480, 491, 493, 525, 0 },
+ /* 800x600 @ 72 Hz, 48.0 kHz */
+ { 50000, 800, 856, 976, 1040, 600, 637, 643, 666,
+ VID_PHSYNC | VID_PVSYNC },
+ /* 1024x768 @ 70 Hz, 56.5 kHz */
+ { 75000, 1024, 1048, 1184, 1328, 768, 771, 777, 806,
+ VID_NHSYNC | VID_NVSYNC },
+ /* 1152x864 @ 70 Hz, 62.4 kHz */
+ { 92000, 1152, 1208, 1368, 1474, 864, 865, 875, 895, 0 },
+ /* 1280x1024 @ 70 Hz, 74.59 kHz */
+ { 126500, 1280, 1312, 1472, 1696, 1024, 1032, 1040, 1068,
+ VID_NHSYNC | VID_NVSYNC }
+};
+
+/* FIXME values are wrong! */
+const u_char mach64_cmap[16 * 3] = {
+ 0x00, 0x00, 0x00, /* black */
+ 0x7f, 0x00, 0x00, /* red */
+ 0x00, 0x7f, 0x00, /* green */
+ 0x7f, 0x7f, 0x00, /* brown */
+ 0x00, 0x00, 0x7f, /* blue */
+ 0x7f, 0x00, 0x7f, /* magenta */
+ 0x00, 0x7f, 0x7f, /* cyan */
+ 0xff, 0xff, 0xff, /* white */
+
+ 0x7f, 0x7f, 0x7f, /* black */
+ 0xff, 0x00, 0x00, /* red */
+ 0x00, 0xff, 0x00, /* green */
+ 0xff, 0xff, 0x00, /* brown */
+ 0x00, 0x00, 0xff, /* blue */
+ 0xff, 0x00, 0xff, /* magenta */
+ 0x00, 0xff, 0xff, /* cyan */
+ 0xff, 0xff, 0xff, /* white */
+};
+
+int mach64_match(struct device *, struct cfdata *, void *);
+void mach64_attach(struct device *, struct device *, void *);
+
+CFATTACH_DECL(machfb, sizeof(struct mach64_softc), mach64_match, mach64_attach,
+ NULL, NULL);
+
+void mach64_init(struct mach64_softc *, bus_space_tag_t);
+int mach64_get_memsize(struct mach64_softc *);
+int mach64_get_max_ramdac(struct mach64_softc *);
+void mach64_get_mode(struct mach64_softc *, struct videomode *);
+int mach64_calc_crtcregs(struct mach64_softc *, struct mach64_crtcregs *,
+ struct videomode *);
+void mach64_set_crtcregs(struct mach64_softc *, struct mach64_crtcregs *);
+int mach64_modeswitch(struct mach64_softc *, struct videomode *);
+void mach64_set_dsp(struct mach64_softc *);
+void mach64_set_pll(struct mach64_softc *, int);
+void mach64_reset_engine(struct mach64_softc *);
+void mach64_init_engine(struct mach64_softc *);
+void mach64_adjust_frame(struct mach64_softc *, int, int);
+void mach64_init_lut(struct mach64_softc *);
+void mach64_switch_screen(struct mach64_softc *);
+void mach64_init_screen(struct mach64_softc *, struct mach64screen *,
+ const struct wsscreen_descr *, int, long *);
+void mach64_restore_screen(struct mach64screen *,
+ const struct wsscreen_descr *, u_int16_t *);
+void mach64_set_screentype(struct mach64_softc *,
+ const struct wsscreen_descr *);
+
+void mach64_cursor(void *, int, int, int);
+int mach64_mapchar(void *, int, u_int *);
+void mach64_putchar(void *, int, int, u_int, long);
+void mach64_copycols(void *, int, int, int, int);
+void mach64_erasecols(void *, int, int, int, long);
+void mach64_copyrows(void *, int, int, int);
+void mach64_eraserows(void *, int, int, long);
+int mach64_allocattr(void *, int, int, int, long *);
+
+const struct wsdisplay_emulops mach64_emulops = {
+ mach64_cursor,
+ mach64_mapchar,
+ mach64_putchar,
+ mach64_copycols,
+ mach64_erasecols,
+ mach64_copyrows,
+ mach64_eraserows,
+ mach64_allocattr,
+};
+
+struct wsscreen_descr mach64_defaultscreen = {
+ "default",
+ 0, 0,
+ &mach64_rasops_info.ri_ops,
+ 8, 16,
Home |
Main Index |
Thread Index |
Old Index