summaryrefslogtreecommitdiff
path: root/sys/dev/fb
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2020-02-03 17:35:11 +0000
committerWarner Losh <imp@FreeBSD.org>2020-02-03 17:35:11 +0000
commit58aa35d42975c298ca0adba705c042596303c9f5 (patch)
tree2558d2b720cda9c2799970cabc266e2ce4e3a8d3 /sys/dev/fb
parenteb24e1491f9900e922c78e53af588f22a3e9535f (diff)
Notes
Diffstat (limited to 'sys/dev/fb')
-rw-r--r--sys/dev/fb/creator.c1130
-rw-r--r--sys/dev/fb/creator_vt.c274
-rw-r--r--sys/dev/fb/creatorreg.h249
-rw-r--r--sys/dev/fb/fbreg.h9
-rw-r--r--sys/dev/fb/machfb.c1581
-rw-r--r--sys/dev/fb/machfbreg.h458
6 files changed, 1 insertions, 3700 deletions
diff --git a/sys/dev/fb/creator.c b/sys/dev/fb/creator.c
deleted file mode 100644
index 0c0f083aaaf7..000000000000
--- a/sys/dev/fb/creator.c
+++ /dev/null
@@ -1,1130 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2003 Jake Burkholder.
- * Copyright (c) 2005 - 2006 Marius Strobl <marius@FreeBSD.org>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/consio.h>
-#include <sys/eventhandler.h>
-#include <sys/fbio.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/resource.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/openfirm.h>
-
-#include <machine/bus.h>
-#include <machine/bus_private.h>
-#include <machine/ofw_machdep.h>
-#include <machine/resource.h>
-#include <machine/sc_machdep.h>
-
-#include <sys/rman.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/creatorreg.h>
-#include <dev/fb/gfb.h>
-#include <dev/syscons/syscons.h>
-
-#define CREATOR_DRIVER_NAME "creator"
-
-struct creator_softc {
- video_adapter_t sc_va; /* XXX must be first */
-
- phandle_t sc_node;
-
- struct cdev *sc_si;
-
- struct resource *sc_reg[FFB_NREG];
- bus_space_tag_t sc_bt[FFB_NREG];
- bus_space_handle_t sc_bh[FFB_NREG];
- u_long sc_reg_size;
-
- u_int sc_height;
- u_int sc_width;
-
- u_int sc_xmargin;
- u_int sc_ymargin;
-
- const u_char *sc_font;
-
- int sc_bg_cache;
- int sc_fg_cache;
- int sc_fifo_cache;
- int sc_fontinc_cache;
- int sc_fontw_cache;
- int sc_pmask_cache;
-
- u_int sc_flags;
-#define CREATOR_AFB (1 << 0)
-#define CREATOR_CONSOLE (1 << 1)
-#define CREATOR_CUREN (1 << 2)
-#define CREATOR_CURINV (1 << 3)
-#define CREATOR_PAC1 (1 << 4)
-};
-
-#define FFB_READ(sc, reg, off) \
- bus_space_read_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off))
-#define FFB_WRITE(sc, reg, off, val) \
- bus_space_write_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off), (val))
-
-#define C(r, g, b) ((b << 16) | (g << 8) | (r))
-static const uint32_t creator_cmap[] = {
- C(0x00, 0x00, 0x00), /* black */
- C(0x00, 0x00, 0xff), /* blue */
- C(0x00, 0xff, 0x00), /* green */
- C(0x00, 0xc0, 0xc0), /* cyan */
- C(0xff, 0x00, 0x00), /* red */
- C(0xc0, 0x00, 0xc0), /* magenta */
- C(0xc0, 0xc0, 0x00), /* brown */
- C(0xc0, 0xc0, 0xc0), /* light grey */
- C(0x80, 0x80, 0x80), /* dark grey */
- C(0x80, 0x80, 0xff), /* light blue */
- C(0x80, 0xff, 0x80), /* light green */
- C(0x80, 0xff, 0xff), /* light cyan */
- C(0xff, 0x80, 0x80), /* light red */
- C(0xff, 0x80, 0xff), /* light magenta */
- C(0xff, 0xff, 0x80), /* yellow */
- C(0xff, 0xff, 0xff), /* white */
-};
-#undef C
-
-static const struct {
- vm_offset_t virt;
- vm_paddr_t phys;
- vm_size_t size;
-} creator_fb_map[] = {
- { FFB_VIRT_SFB8R, FFB_PHYS_SFB8R, FFB_SIZE_SFB8R },
- { FFB_VIRT_SFB8G, FFB_PHYS_SFB8G, FFB_SIZE_SFB8G },
- { FFB_VIRT_SFB8B, FFB_PHYS_SFB8B, FFB_SIZE_SFB8B },
- { FFB_VIRT_SFB8X, FFB_PHYS_SFB8X, FFB_SIZE_SFB8X },
- { FFB_VIRT_SFB32, FFB_PHYS_SFB32, FFB_SIZE_SFB32 },
- { FFB_VIRT_SFB64, FFB_PHYS_SFB64, FFB_SIZE_SFB64 },
- { FFB_VIRT_FBC, FFB_PHYS_FBC, FFB_SIZE_FBC },
- { FFB_VIRT_FBC_BM, FFB_PHYS_FBC_BM, FFB_SIZE_FBC_BM },
- { FFB_VIRT_DFB8R, FFB_PHYS_DFB8R, FFB_SIZE_DFB8R },
- { FFB_VIRT_DFB8G, FFB_PHYS_DFB8G, FFB_SIZE_DFB8G },
- { FFB_VIRT_DFB8B, FFB_PHYS_DFB8B, FFB_SIZE_DFB8B },
- { FFB_VIRT_DFB8X, FFB_PHYS_DFB8X, FFB_SIZE_DFB8X },
- { FFB_VIRT_DFB24, FFB_PHYS_DFB24, FFB_SIZE_DFB24 },
- { FFB_VIRT_DFB32, FFB_PHYS_DFB32, FFB_SIZE_DFB32 },
- { FFB_VIRT_DFB422A, FFB_PHYS_DFB422A, FFB_SIZE_DFB422A },
- { FFB_VIRT_DFB422AD, FFB_PHYS_DFB422AD, FFB_SIZE_DFB422AD },
- { FFB_VIRT_DFB24B, FFB_PHYS_DFB24B, FFB_SIZE_DFB24B },
- { FFB_VIRT_DFB422B, FFB_PHYS_DFB422B, FFB_SIZE_DFB422B },
- { FFB_VIRT_DFB422BD, FFB_PHYS_DFB422BD, FFB_SIZE_DFB422BD },
- { FFB_VIRT_SFB16Z, FFB_PHYS_SFB16Z, FFB_SIZE_SFB16Z },
- { FFB_VIRT_SFB8Z, FFB_PHYS_SFB8Z, FFB_SIZE_SFB8Z },
- { FFB_VIRT_SFB422, FFB_PHYS_SFB422, FFB_SIZE_SFB422 },
- { FFB_VIRT_SFB422D, FFB_PHYS_SFB422D, FFB_SIZE_SFB422D },
- { FFB_VIRT_FBC_KREG, FFB_PHYS_FBC_KREG, FFB_SIZE_FBC_KREG },
- { FFB_VIRT_DAC, FFB_PHYS_DAC, FFB_SIZE_DAC },
- { FFB_VIRT_PROM, FFB_PHYS_PROM, FFB_SIZE_PROM },
- { FFB_VIRT_EXP, FFB_PHYS_EXP, FFB_SIZE_EXP },
-};
-
-#define CREATOR_FB_MAP_SIZE nitems(creator_fb_map)
-
-extern const struct gfb_font gallant12x22;
-
-static struct creator_softc creator_softc;
-static struct bus_space_tag creator_bst_store[FFB_FBC];
-
-static device_probe_t creator_bus_probe;
-static device_attach_t creator_bus_attach;
-
-static device_method_t creator_bus_methods[] = {
- DEVMETHOD(device_probe, creator_bus_probe),
- DEVMETHOD(device_attach, creator_bus_attach),
-
- { 0, 0 }
-};
-
-static devclass_t creator_devclass;
-
-DEFINE_CLASS_0(creator, creator_bus_driver, creator_bus_methods,
- sizeof(struct creator_softc));
-DRIVER_MODULE(creator, nexus, creator_bus_driver, creator_devclass, 0, 0);
-DRIVER_MODULE(creator, upa, creator_bus_driver, creator_devclass, 0, 0);
-
-static d_open_t creator_fb_open;
-static d_close_t creator_fb_close;
-static d_ioctl_t creator_fb_ioctl;
-static d_mmap_t creator_fb_mmap;
-
-static struct cdevsw creator_fb_devsw = {
- .d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
- .d_open = creator_fb_open,
- .d_close = creator_fb_close,
- .d_ioctl = creator_fb_ioctl,
- .d_mmap = creator_fb_mmap,
- .d_name = "fb",
-};
-
-static void creator_cursor_enable(struct creator_softc *sc, int onoff);
-static void creator_cursor_install(struct creator_softc *sc);
-static void creator_shutdown(void *xsc);
-
-static int creator_configure(int flags);
-
-static vi_probe_t creator_probe;
-static vi_init_t creator_init;
-static vi_get_info_t creator_get_info;
-static vi_query_mode_t creator_query_mode;
-static vi_set_mode_t creator_set_mode;
-static vi_save_font_t creator_save_font;
-static vi_load_font_t creator_load_font;
-static vi_show_font_t creator_show_font;
-static vi_save_palette_t creator_save_palette;
-static vi_load_palette_t creator_load_palette;
-static vi_set_border_t creator_set_border;
-static vi_save_state_t creator_save_state;
-static vi_load_state_t creator_load_state;
-static vi_set_win_org_t creator_set_win_org;
-static vi_read_hw_cursor_t creator_read_hw_cursor;
-static vi_set_hw_cursor_t creator_set_hw_cursor;
-static vi_set_hw_cursor_shape_t creator_set_hw_cursor_shape;
-static vi_blank_display_t creator_blank_display;
-static vi_mmap_t creator_mmap;
-static vi_ioctl_t creator_ioctl;
-static vi_clear_t creator_clear;
-static vi_fill_rect_t creator_fill_rect;
-static vi_bitblt_t creator_bitblt;
-static vi_diag_t creator_diag;
-static vi_save_cursor_palette_t creator_save_cursor_palette;
-static vi_load_cursor_palette_t creator_load_cursor_palette;
-static vi_copy_t creator_copy;
-static vi_putp_t creator_putp;
-static vi_putc_t creator_putc;
-static vi_puts_t creator_puts;
-static vi_putm_t creator_putm;
-
-static video_switch_t creatorvidsw = {
- .probe = creator_probe,
- .init = creator_init,
- .get_info = creator_get_info,
- .query_mode = creator_query_mode,
- .set_mode = creator_set_mode,
- .save_font = creator_save_font,
- .load_font = creator_load_font,
- .show_font = creator_show_font,
- .save_palette = creator_save_palette,
- .load_palette = creator_load_palette,
- .set_border = creator_set_border,
- .save_state = creator_save_state,
- .load_state = creator_load_state,
- .set_win_org = creator_set_win_org,
- .read_hw_cursor = creator_read_hw_cursor,
- .set_hw_cursor = creator_set_hw_cursor,
- .set_hw_cursor_shape = creator_set_hw_cursor_shape,
- .blank_display = creator_blank_display,
- .mmap = creator_mmap,
- .ioctl = creator_ioctl,
- .clear = creator_clear,
- .fill_rect = creator_fill_rect,
- .bitblt = creator_bitblt,
- .diag = creator_diag,
- .save_cursor_palette = creator_save_cursor_palette,
- .load_cursor_palette = creator_load_cursor_palette,
- .copy = creator_copy,
- .putp = creator_putp,
- .putc = creator_putc,
- .puts = creator_puts,
- .putm = creator_putm
-};
-
-VIDEO_DRIVER(creator, creatorvidsw, creator_configure);
-
-extern sc_rndr_sw_t txtrndrsw;
-RENDERER(creator, 0, txtrndrsw, gfb_set);
-
-RENDERER_MODULE(creator, gfb_set);
-
-static const u_char creator_mouse_pointer[64][8] __aligned(8) = {
- { 0x00, 0x00, }, /* ............ */
- { 0x80, 0x00, }, /* *........... */
- { 0xc0, 0x00, }, /* **.......... */
- { 0xe0, 0x00, }, /* ***......... */
- { 0xf0, 0x00, }, /* ****........ */
- { 0xf8, 0x00, }, /* *****....... */
- { 0xfc, 0x00, }, /* ******...... */
- { 0xfe, 0x00, }, /* *******..... */
- { 0xff, 0x00, }, /* ********.... */
- { 0xff, 0x80, }, /* *********... */
- { 0xfc, 0xc0, }, /* ******..**.. */
- { 0xdc, 0x00, }, /* **.***...... */
- { 0x8e, 0x00, }, /* *...***..... */
- { 0x0e, 0x00, }, /* ....***..... */
- { 0x07, 0x00, }, /* .....***.... */
- { 0x04, 0x00, }, /* .....*...... */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
-};
-
-static inline void creator_ras_fifo_wait(struct creator_softc *sc, int n);
-static inline void creator_ras_setfontinc(struct creator_softc *sc, int fontinc);
-static inline void creator_ras_setfontw(struct creator_softc *sc, int fontw);
-static inline void creator_ras_setbg(struct creator_softc *sc, int bg);
-static inline void creator_ras_setfg(struct creator_softc *sc, int fg);
-static inline void creator_ras_setpmask(struct creator_softc *sc, int pmask);
-static inline void creator_ras_wait(struct creator_softc *sc);
-
-static inline void
-creator_ras_wait(struct creator_softc *sc)
-{
- int ucsr;
- int r;
-
- for (;;) {
- ucsr = FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR);
- if ((ucsr & (FBC_UCSR_FB_BUSY | FBC_UCSR_RP_BUSY)) == 0)
- break;
- r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL);
- if (r != 0)
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_UCSR, r);
- }
-}
-
-static inline void
-creator_ras_fifo_wait(struct creator_softc *sc, int n)
-{
- int cache;
-
- cache = sc->sc_fifo_cache;
- while (cache < n)
- cache = (FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR) &
- FBC_UCSR_FIFO_MASK) - 8;
- sc->sc_fifo_cache = cache - n;
-}
-
-static inline void
-creator_ras_setfontinc(struct creator_softc *sc, int fontinc)
-{
-
- if (fontinc == sc->sc_fontinc_cache)
- return;
- sc->sc_fontinc_cache = fontinc;
- creator_ras_fifo_wait(sc, 1);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTINC, fontinc);
- creator_ras_wait(sc);
-}
-
-static inline void
-creator_ras_setfontw(struct creator_softc *sc, int fontw)
-{
-
- if (fontw == sc->sc_fontw_cache)
- return;
- sc->sc_fontw_cache = fontw;
- creator_ras_fifo_wait(sc, 1);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTW, fontw);
- creator_ras_wait(sc);
-}
-
-static inline void
-creator_ras_setbg(struct creator_softc *sc, int bg)
-{
-
- if (bg == sc->sc_bg_cache)
- return;
- sc->sc_bg_cache = bg;
- creator_ras_fifo_wait(sc, 1);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_BG, bg);
- creator_ras_wait(sc);
-}
-
-static inline void
-creator_ras_setfg(struct creator_softc *sc, int fg)
-{
-
- if (fg == sc->sc_fg_cache)
- return;
- sc->sc_fg_cache = fg;
- creator_ras_fifo_wait(sc, 1);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_FG, fg);
- creator_ras_wait(sc);
-}
-
-static inline void
-creator_ras_setpmask(struct creator_softc *sc, int pmask)
-{
-
- if (pmask == sc->sc_pmask_cache)
- return;
- sc->sc_pmask_cache = pmask;
- creator_ras_fifo_wait(sc, 1);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_PMASK, pmask);
- creator_ras_wait(sc);
-}
-
-/*
- * video driver interface
- */
-static int
-creator_configure(int flags)
-{
- struct creator_softc *sc;
- phandle_t chosen;
- phandle_t output;
- ihandle_t stdout;
- bus_addr_t addr;
- char buf[sizeof("SUNW,ffb")];
- int i;
- int space;
-
- /*
- * For the high-level console probing return the number of
- * registered adapters.
- */
- if (!(flags & VIO_PROBE_ONLY)) {
- for (i = 0; vid_find_adapter(CREATOR_DRIVER_NAME, i) >= 0; i++)
- ;
- return (i);
- }
-
- /* Low-level console probing and initialization. */
-
- sc = &creator_softc;
- if (sc->sc_va.va_flags & V_ADP_REGISTERED)
- goto found;
-
- if ((chosen = OF_finddevice("/chosen")) == -1)
- return (0);
- if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
- return (0);
- if ((output = OF_instance_to_package(stdout)) == -1)
- return (0);
- if (OF_getprop(output, "name", buf, sizeof(buf)) == -1)
- return (0);
- if (strcmp(buf, "SUNW,ffb") == 0 || strcmp(buf, "SUNW,afb") == 0) {
- sc->sc_flags = CREATOR_CONSOLE;
- if (strcmp(buf, "SUNW,afb") == 0)
- sc->sc_flags |= CREATOR_AFB;
- sc->sc_node = output;
- } else
- return (0);
-
- for (i = FFB_DAC; i <= FFB_FBC; i++) {
- if (OF_decode_addr(output, i, &space, &addr) != 0)
- return (0);
- sc->sc_bt[i] = &creator_bst_store[i - FFB_DAC];
- sc->sc_bh[i] = sparc64_fake_bustag(space, addr, sc->sc_bt[i]);
- }
-
- if (creator_init(0, &sc->sc_va, 0) < 0)
- return (0);
-
- found:
- /* Return number of found adapters. */
- return (1);
-}
-
-static int
-creator_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
-{
-
- return (0);
-}
-
-static int
-creator_init(int unit, video_adapter_t *adp, int flags)
-{
- struct creator_softc *sc;
- phandle_t options;
- video_info_t *vi;
- char buf[sizeof("screen-#columns")];
-
- sc = (struct creator_softc *)adp;
- vi = &adp->va_info;
-
- vid_init_struct(adp, CREATOR_DRIVER_NAME, -1, unit);
-
- if (OF_getprop(sc->sc_node, "height", &sc->sc_height,
- sizeof(sc->sc_height)) == -1)
- return (ENXIO);
- if (OF_getprop(sc->sc_node, "width", &sc->sc_width,
- sizeof(sc->sc_width)) == -1)
- return (ENXIO);
- if ((options = OF_finddevice("/options")) == -1)
- return (ENXIO);
- if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1)
- return (ENXIO);
- vi->vi_height = strtol(buf, NULL, 10);
- if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1)
- return (ENXIO);
- vi->vi_width = strtol(buf, NULL, 10);
- vi->vi_cwidth = gallant12x22.width;
- vi->vi_cheight = gallant12x22.height;
- vi->vi_flags = V_INFO_COLOR;
- vi->vi_mem_model = V_INFO_MM_OTHER;
-
- sc->sc_font = gallant12x22.data;
- sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
- sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2;
-
- creator_set_mode(adp, 0);
-
- if (!(sc->sc_flags & CREATOR_AFB)) {
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_DID);
- if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
- FFB_DAC_CFG_DID_PNUM) >> 12) != 0x236e) {
- sc->sc_flags |= CREATOR_PAC1;
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_UCTRL);
- if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
- FFB_DAC_UCTRL_MANREV) >> 8) <= 2)
- sc->sc_flags |= CREATOR_CURINV;
- }
- }
-
- creator_blank_display(adp, V_DISPLAY_ON);
- creator_clear(adp);
-
- /*
- * Setting V_ADP_MODECHANGE serves as hack so creator_set_mode()
- * (which will invalidate our caches and restore our settings) is
- * called when the X server shuts down. Otherwise screen corruption
- * happens most of the time.
- */
- adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_BORDER |
- V_ADP_INITIALIZED;
- if (vid_register(adp) < 0)
- return (ENXIO);
- adp->va_flags |= V_ADP_REGISTERED;
-
- return (0);
-}
-
-static int
-creator_get_info(video_adapter_t *adp, int mode, video_info_t *info)
-{
-
- bcopy(&adp->va_info, info, sizeof(*info));
- return (0);
-}
-
-static int
-creator_query_mode(video_adapter_t *adp, video_info_t *info)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_set_mode(video_adapter_t *adp, int mode)
-{
- struct creator_softc *sc;
-
- sc = (struct creator_softc *)adp;
- sc->sc_bg_cache = -1;
- sc->sc_fg_cache = -1;
- sc->sc_fontinc_cache = -1;
- sc->sc_fontw_cache = -1;
- sc->sc_pmask_cache = -1;
-
- creator_ras_wait(sc);
- sc->sc_fifo_cache = 0;
- creator_ras_fifo_wait(sc, 2);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_PPC, FBC_PPC_VCE_DIS |
- FBC_PPC_TBE_OPAQUE | FBC_PPC_APE_DIS | FBC_PPC_CS_CONST);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_FBC, FFB_FBC_WB_A | FFB_FBC_RB_A |
- FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK);
- return (0);
-}
-
-static int
-creator_save_font(video_adapter_t *adp, int page, int size, int width,
- u_char *data, int c, int count)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_load_font(video_adapter_t *adp, int page, int size, int width,
- u_char *data, int c, int count)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_show_font(video_adapter_t *adp, int page)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_save_palette(video_adapter_t *adp, u_char *palette)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_load_palette(video_adapter_t *adp, u_char *palette)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_set_border(video_adapter_t *adp, int border)
-{
- struct creator_softc *sc;
-
- sc = (struct creator_softc *)adp;
- creator_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin);
- creator_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin,
- sc->sc_width, sc->sc_ymargin);
- creator_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height);
- creator_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0,
- sc->sc_xmargin, sc->sc_height);
- return (0);
-}
-
-static int
-creator_save_state(video_adapter_t *adp, void *p, size_t size)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_load_state(video_adapter_t *adp, void *p)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_set_win_org(video_adapter_t *adp, off_t offset)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
-{
-
- *col = 0;
- *row = 0;
- return (0);
-}
-
-static int
-creator_set_hw_cursor(video_adapter_t *adp, int col, int row)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
- int celsize, int blink)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_blank_display(video_adapter_t *adp, int mode)
-{
- struct creator_softc *sc;
- uint32_t v;
- int i;
-
- sc = (struct creator_softc *)adp;
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
- v = FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
- switch (mode) {
- case V_DISPLAY_ON:
- v |= FFB_DAC_CFG_TGEN_VIDE;
- break;
- case V_DISPLAY_BLANK:
- case V_DISPLAY_STAND_BY:
- case V_DISPLAY_SUSPEND:
- v &= ~FFB_DAC_CFG_TGEN_VIDE;
- break;
- }
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE, v);
- for (i = 0; i < 10; i++) {
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
- (void)FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
- }
- return (0);
-}
-
-static int
-creator_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr,
- int prot, vm_memattr_t *memattr)
-{
-
- return (EINVAL);
-}
-
-static int
-creator_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
-{
- struct creator_softc *sc;
- struct fbcursor *fbc;
- struct fbtype *fb;
-
- sc = (struct creator_softc *)adp;
- switch (cmd) {
- case FBIOGTYPE:
- fb = (struct fbtype *)data;
- fb->fb_type = FBTYPE_CREATOR;
- fb->fb_height = sc->sc_height;
- fb->fb_width = sc->sc_width;
- fb->fb_depth = fb->fb_cmsize = fb->fb_size = 0;
- break;
- case FBIOSCURSOR:
- fbc = (struct fbcursor *)data;
- if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) {
- creator_cursor_enable(sc, 0);
- sc->sc_flags &= ~CREATOR_CUREN;
- } else
- return (ENODEV);
- break;
- break;
- default:
- return (fb_commonioctl(adp, cmd, data));
- }
- return (0);
-}
-
-static int
-creator_clear(video_adapter_t *adp)
-{
- struct creator_softc *sc;
-
- sc = (struct creator_softc *)adp;
- creator_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width,
- sc->sc_height);
- return (0);
-}
-
-static int
-creator_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
-{
- struct creator_softc *sc;
-
- sc = (struct creator_softc *)adp;
- creator_ras_setpmask(sc, 0xffffffff);
- creator_ras_fifo_wait(sc, 2);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_ROP, FBC_ROP_NEW);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
- creator_ras_setfg(sc, creator_cmap[val & 0xf]);
- /*
- * Note that at least the Elite3D cards are sensitive to the order
- * of operations here.
- */
- creator_ras_fifo_wait(sc, 4);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_BY, y);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_BX, x);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_BH, cy);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_BW, cx);
- creator_ras_wait(sc);
- return (0);
-}
-
-static int
-creator_bitblt(video_adapter_t *adp, ...)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_diag(video_adapter_t *adp, int level)
-{
- video_info_t info;
-
- fb_dump_adp_info(adp->va_name, adp, level);
- creator_get_info(adp, 0, &info);
- fb_dump_mode_info(adp->va_name, adp, &info, level);
- return (0);
-}
-
-static int
-creator_save_cursor_palette(video_adapter_t *adp, u_char *palette)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_load_cursor_palette(video_adapter_t *adp, u_char *palette)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a,
- int size, int bpp, int bit_ltor, int byte_ltor)
-{
-
- return (ENODEV);
-}
-
-static int
-creator_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a)
-{
- struct creator_softc *sc;
- const uint16_t *p;
- int row;
- int col;
- int i;
-
- sc = (struct creator_softc *)adp;
- row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
- col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
- p = (const uint16_t *)sc->sc_font + (c * adp->va_info.vi_cheight);
- creator_ras_setfg(sc, creator_cmap[a & 0xf]);
- creator_ras_setbg(sc, creator_cmap[(a >> 4) & 0xf]);
- creator_ras_fifo_wait(sc, 1 + adp->va_info.vi_cheight);
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTXY,
- ((row + sc->sc_ymargin) << 16) | (col + sc->sc_xmargin));
- creator_ras_setfontw(sc, adp->va_info.vi_cwidth);
- creator_ras_setfontinc(sc, 0x10000);
- for (i = 0; i < adp->va_info.vi_cheight; i++) {
- FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONT, *p++ << 16);
- }
- return (0);
-}
-
-static int
-creator_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- vidd_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8);
- }
-
- return (0);
-}
-
-static int
-creator_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
- u_int32_t pixel_mask, int size, int width)
-{
- struct creator_softc *sc;
-
- sc = (struct creator_softc *)adp;
- if (!(sc->sc_flags & CREATOR_CUREN)) {
- creator_cursor_install(sc);
- creator_cursor_enable(sc, 1);
- sc->sc_flags |= CREATOR_CUREN;
- }
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_POS);
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
- ((y + sc->sc_ymargin) << 16) | (x + sc->sc_xmargin));
- return (0);
-}
-
-/*
- * bus interface
- */
-static int
-creator_bus_probe(device_t dev)
-{
- const char *name;
- phandle_t node;
- int type;
-
- name = ofw_bus_get_name(dev);
- node = ofw_bus_get_node(dev);
- if (strcmp(name, "SUNW,ffb") == 0) {
- if (OF_getprop(node, "board_type", &type, sizeof(type)) == -1)
- return (ENXIO);
- switch (type & 7) {
- case 0x0:
- device_set_desc(dev, "Creator");
- break;
- case 0x3:
- device_set_desc(dev, "Creator3D");
- break;
- default:
- return (ENXIO);
- }
- } else if (strcmp(name, "SUNW,afb") == 0)
- device_set_desc(dev, "Elite3D");
- else
- return (ENXIO);
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-creator_bus_attach(device_t dev)
-{
- struct creator_softc *sc;
- video_adapter_t *adp;
- video_switch_t *sw;
- phandle_t node;
- int error;
- int rid;
- int unit;
- int i;
-
- node = ofw_bus_get_node(dev);
- if ((sc = (struct creator_softc *)vid_get_adapter(vid_find_adapter(
- CREATOR_DRIVER_NAME, 0))) != NULL && sc->sc_node == node) {
- device_printf(dev, "console\n");
- device_set_softc(dev, sc);
- } else {
- sc = device_get_softc(dev);
- sc->sc_node = node;
- }
- adp = &sc->sc_va;
-
- /*
- * Allocate resources regardless of whether we are the console
- * and already obtained the bus tags and handles for the FFB_DAC
- * and FFB_FBC register banks in creator_configure() or not so
- * the resources are marked as taken in the respective RMAN.
- * The supported cards use either 15 (Creator, Elite3D?) or 24
- * (Creator3D?) register banks. We make sure that we can also
- * allocate the resources for at least the FFB_DAC and FFB_FBC
- * banks here. We try but don't actually care whether we can
- * allocate more than these two resources and just limit the
- * range accessible via creator_fb_mmap() accordingly.
- */
- for (i = 0; i < FFB_NREG; i++) {
- rid = i;
- sc->sc_reg[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
- &rid, RF_ACTIVE);
- if (sc->sc_reg[i] == NULL) {
- if (i <= FFB_FBC) {
- device_printf(dev,
- "cannot allocate resources\n");
- error = ENXIO;
- goto fail;
- }
- break;
- }
- sc->sc_bt[i] = rman_get_bustag(sc->sc_reg[i]);
- sc->sc_bh[i] = rman_get_bushandle(sc->sc_reg[i]);
- }
- /*
- * The XFree86/X.Org sunffb(4) expects to be able to access the
- * memory spanned by the first and the last resource as one chunk
- * via creator_fb_mmap(), using offsets from the first resource,
- * even though the backing resources are actually non-continuous.
- * So make sure that the memory we provide is at least backed by
- * increasing resources.
- */
- for (i = 1; i < FFB_NREG && sc->sc_reg[i] != NULL &&
- rman_get_start(sc->sc_reg[i]) > rman_get_start(sc->sc_reg[i - 1]);
- i++)
- ;
- sc->sc_reg_size = rman_get_end(sc->sc_reg[i - 1]) -
- rman_get_start(sc->sc_reg[0]) + 1;
-
- if (!(sc->sc_flags & CREATOR_CONSOLE)) {
- if ((sw = vid_get_switch(CREATOR_DRIVER_NAME)) == NULL) {
- device_printf(dev, "cannot get video switch\n");
- error = ENODEV;
- goto fail;
- }
- /*
- * During device configuration we don't necessarily probe
- * the adapter which is the console first so we can't use
- * the device unit number for the video adapter unit. The
- * worst case would be that we use the video adapter unit
- * 0 twice. As it doesn't really matter which unit number
- * the corresponding video adapter has just use the next
- * unused one.
- */
- for (i = 0; i < devclass_get_maxunit(creator_devclass); i++)
- if (vid_find_adapter(CREATOR_DRIVER_NAME, i) < 0)
- break;
- if (strcmp(ofw_bus_get_name(dev), "SUNW,afb") == 0)
- sc->sc_flags |= CREATOR_AFB;
- if ((error = sw->init(i, adp, 0)) != 0) {
- device_printf(dev, "cannot initialize adapter\n");
- goto fail;
- }
- }
-
- if (bootverbose) {
- if (sc->sc_flags & CREATOR_PAC1)
- device_printf(dev,
- "BT9068/PAC1 RAMDAC (%s cursor control)\n",
- sc->sc_flags & CREATOR_CURINV ? "inverted" :
- "normal");
- else
- device_printf(dev, "BT498/PAC2 RAMDAC\n");
- }
- device_printf(dev, "resolution %dx%d\n", sc->sc_width, sc->sc_height);
-
- unit = device_get_unit(dev);
- sc->sc_si = make_dev(&creator_fb_devsw, unit, UID_ROOT, GID_WHEEL,
- 0600, "fb%d", unit);
- sc->sc_si->si_drv1 = sc;
-
- EVENTHANDLER_REGISTER(shutdown_final, creator_shutdown, sc,
- SHUTDOWN_PRI_DEFAULT);
-
- return (0);
-
- fail:
- for (i = 0; i < FFB_NREG && sc->sc_reg[i] != NULL; i++)
- bus_release_resource(dev, SYS_RES_MEMORY,
- rman_get_rid(sc->sc_reg[i]), sc->sc_reg[i]);
- return (error);
-}
-
-/*
- * /dev/fb interface
- */
-static int
-creator_fb_open(struct cdev *dev, int flags, int mode, struct thread *td)
-{
-
- return (0);
-}
-
-static int
-creator_fb_close(struct cdev *dev, int flags, int mode, struct thread *td)
-{
-
- return (0);
-}
-
-static int
-creator_fb_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
- struct thread *td)
-{
- struct creator_softc *sc;
-
- sc = dev->si_drv1;
- return (creator_ioctl(&sc->sc_va, cmd, data));
-}
-
-static int
-creator_fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
- int prot, vm_memattr_t *memattr)
-{
- struct creator_softc *sc;
- int i;
-
- /*
- * NB: This is a special implementation based on the /dev/fb
- * requirements of the XFree86/X.Org sunffb(4).
- */
- sc = dev->si_drv1;
- for (i = 0; i < CREATOR_FB_MAP_SIZE; i++) {
- if (offset >= creator_fb_map[i].virt &&
- offset < creator_fb_map[i].virt + creator_fb_map[i].size) {
- offset += creator_fb_map[i].phys -
- creator_fb_map[i].virt;
- if (offset >= sc->sc_reg_size)
- return (EINVAL);
- *paddr = sc->sc_bh[0] + offset;
- return (0);
- }
- }
- return (EINVAL);
-}
-
-/*
- * internal functions
- */
-static void
-creator_cursor_enable(struct creator_softc *sc, int onoff)
-{
- int v;
-
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_CTRL);
- if (sc->sc_flags & CREATOR_CURINV)
- v = onoff ? FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1 : 0;
- else
- v = onoff ? 0 : FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1;
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, v);
-}
-
-static void
-creator_cursor_install(struct creator_softc *sc)
-{
- int i, j;
-
- creator_cursor_enable(sc, 0);
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_COLOR1);
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0xffffff);
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0x0);
- for (i = 0; i < 2; i++) {
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2,
- i ? FFB_DAC_CUR_BITMAP_P0 : FFB_DAC_CUR_BITMAP_P1);
- for (j = 0; j < 64; j++) {
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
- *(const uint32_t *)(&creator_mouse_pointer[j][0]));
- FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
- *(const uint32_t *)(&creator_mouse_pointer[j][4]));
- }
- }
-}
-
-static void
-creator_shutdown(void *xsc)
-{
- struct creator_softc *sc = xsc;
-
- creator_cursor_enable(sc, 0);
- /*
- * In case this is the console set the cursor of the stdout
- * instance to the start of the last line so OFW output ends
- * up beneath what FreeBSD left on the screen.
- */
- if (sc->sc_flags & CREATOR_CONSOLE) {
- OF_interpret("stdout @ is my-self 0 to column#", 0);
- OF_interpret("stdout @ is my-self #lines 1 - to line#", 0);
- }
-}
diff --git a/sys/dev/fb/creator_vt.c b/sys/dev/fb/creator_vt.c
deleted file mode 100644
index f811f309b0fa..000000000000
--- a/sys/dev/fb/creator_vt.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/*-
- * Copyright (c) 2014 Nathan Whitehorn
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/fbio.h>
-
-#include <dev/vt/vt.h>
-#include <dev/vt/hw/fb/vt_fb.h>
-#include <dev/vt/colors/vt_termcolors.h>
-
-#include <machine/bus.h>
-#include <machine/bus_private.h>
-
-#include <dev/ofw/openfirm.h>
-#include "creatorreg.h"
-
-static vd_probe_t creatorfb_probe;
-static vd_init_t creatorfb_init;
-static vd_blank_t creatorfb_blank;
-static vd_bitblt_text_t creatorfb_bitblt_text;
-static vd_bitblt_bmp_t creatorfb_bitblt_bitmap;
-
-static const struct vt_driver vt_creatorfb_driver = {
- .vd_name = "creatorfb",
- .vd_probe = creatorfb_probe,
- .vd_init = creatorfb_init,
- .vd_blank = creatorfb_blank,
- .vd_bitblt_text = creatorfb_bitblt_text,
- .vd_bitblt_bmp = creatorfb_bitblt_bitmap,
- .vd_fb_ioctl = vt_fb_ioctl,
- .vd_fb_mmap = vt_fb_mmap,
- .vd_priority = VD_PRIORITY_SPECIFIC
-};
-
-struct creatorfb_softc {
- struct fb_info fb;
- struct bus_space_tag memt[1];
- bus_space_handle_t memh;
-};
-
-static struct creatorfb_softc creatorfb_conssoftc;
-VT_DRIVER_DECLARE(vt_creatorfb, vt_creatorfb_driver);
-
-static int
-creatorfb_probe(struct vt_device *vd)
-{
- phandle_t chosen, node;
- ihandle_t stdout;
- char type[64], name[64];
-
- chosen = OF_finddevice("/chosen");
- OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
- node = OF_instance_to_package(stdout);
- if (node == -1) {
- /*
- * The "/chosen/stdout" does not exist try
- * using "screen" directly.
- */
- node = OF_finddevice("screen");
- }
- OF_getprop(node, "device_type", type, sizeof(type));
- if (strcmp(type, "display") != 0)
- return (CN_DEAD);
-
- OF_getprop(node, "name", name, sizeof(name));
- if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0)
- return (CN_DEAD);
-
- /* Looks OK... */
- return (CN_INTERNAL);
-}
-
-static int
-creatorfb_init(struct vt_device *vd)
-{
- struct creatorfb_softc *sc;
- phandle_t chosen;
- phandle_t node;
- ihandle_t handle;
- uint32_t height, width;
- char type[64], name[64];
- bus_addr_t phys;
- int space;
-
- /* Initialize softc */
- vd->vd_softc = sc = &creatorfb_conssoftc;
-
- chosen = OF_finddevice("/chosen");
- OF_getprop(chosen, "stdout", &handle, sizeof(ihandle_t));
- node = OF_instance_to_package(handle);
- if (node == -1) {
- /*
- * The "/chosen/stdout" does not exist try
- * using "screen" directly.
- */
- node = OF_finddevice("screen");
- handle = OF_open("screen");
- }
- OF_getprop(node, "device_type", type, sizeof(type));
- if (strcmp(type, "display") != 0)
- return (CN_DEAD);
-
- OF_getprop(node, "name", name, sizeof(name));
- if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0)
- return (CN_DEAD);
-
- /* Make sure we have needed properties */
- if (OF_getproplen(node, "height") != sizeof(height) ||
- OF_getproplen(node, "width") != sizeof(width))
- return (CN_DEAD);
-
- OF_getprop(node, "height", &height, sizeof(height));
- OF_getprop(node, "width", &width, sizeof(width));
-
- sc->fb.fb_height = height;
- sc->fb.fb_width = width;
- sc->fb.fb_bpp = sc->fb.fb_depth = 32;
- sc->fb.fb_stride = 8192; /* Fixed */
- sc->fb.fb_size = sc->fb.fb_height * sc->fb.fb_stride;
-
- /* Map linear framebuffer */
- if (OF_decode_addr(node, FFB_DFB24, &space, &phys) != 0)
- return (CN_DEAD);
- sc->fb.fb_pbase = phys;
- sc->memh = sparc64_fake_bustag(space, phys, &sc->memt[0]);
-
- /* 32-bit VGA palette */
- vt_generate_cons_palette(sc->fb.fb_cmap, COLOR_FORMAT_RGB,
- 255, 0, 255, 8, 255, 16);
- sc->fb.fb_cmsize = 16;
-
- vt_fb_init(vd);
-
- return (CN_INTERNAL);
-}
-
-static void
-creatorfb_blank(struct vt_device *vd, term_color_t color)
-{
- struct creatorfb_softc *sc;
- uint32_t c;
- int i;
-
- sc = vd->vd_softc;
- c = sc->fb.fb_cmap[color];
-
- for (i = 0; i < sc->fb.fb_height; i++)
- bus_space_set_region_4(sc->memt, sc->memh, i*sc->fb.fb_stride,
- c, sc->fb.fb_width);
-}
-
-static void
-creatorfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
- const uint8_t *pattern, const uint8_t *mask,
- unsigned int width, unsigned int height,
- unsigned int x, unsigned int y, term_color_t fg, term_color_t bg)
-{
- struct creatorfb_softc *sc = vd->vd_softc;
- u_long line;
- uint32_t fgc, bgc;
- int c, l;
- uint8_t b, m;
-
- fgc = sc->fb.fb_cmap[fg];
- bgc = sc->fb.fb_cmap[bg];
- b = m = 0;
-
- line = (sc->fb.fb_stride * y) + 4*x;
- for (l = 0;
- l < height && y + l < vw->vw_draw_area.tr_end.tp_row;
- l++) {
- for (c = 0;
- c < width && x + c < vw->vw_draw_area.tr_end.tp_col;
- c++) {
- if (c % 8 == 0)
- b = *pattern++;
- else
- b <<= 1;
- if (mask != NULL) {
- if (c % 8 == 0)
- m = *mask++;
- else
- m <<= 1;
- /* Skip pixel write if mask not set. */
- if ((m & 0x80) == 0)
- continue;
- }
- bus_space_write_4(sc->memt, sc->memh, line + 4*c,
- (b & 0x80) ? fgc : bgc);
- }
- line += sc->fb.fb_stride;
- }
-}
-
-void
-creatorfb_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
- const term_rect_t *area)
-{
- unsigned int col, row, x, y;
- struct vt_font *vf;
- term_char_t c;
- term_color_t fg, bg;
- const uint8_t *pattern;
-
- vf = vw->vw_font;
-
- for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) {
- for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col;
- ++col) {
- x = col * vf->vf_width +
- vw->vw_draw_area.tr_begin.tp_col;
- y = row * vf->vf_height +
- vw->vw_draw_area.tr_begin.tp_row;
-
- c = VTBUF_GET_FIELD(&vw->vw_buf, row, col);
- pattern = vtfont_lookup(vf, c);
- vt_determine_colors(c,
- VTBUF_ISCURSOR(&vw->vw_buf, row, col), &fg, &bg);
-
- creatorfb_bitblt_bitmap(vd, vw,
- pattern, NULL, vf->vf_width, vf->vf_height,
- x, y, fg, bg);
- }
- }
-
-#ifndef SC_NO_CUTPASTE
- if (!vd->vd_mshown)
- return;
-
- term_rect_t drawn_area;
-
- drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width;
- drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height;
- drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width;
- drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height;
-
- if (vt_is_cursor_in_area(vd, &drawn_area)) {
- creatorfb_bitblt_bitmap(vd, vw,
- vd->vd_mcursor->map, vd->vd_mcursor->mask,
- vd->vd_mcursor->width, vd->vd_mcursor->height,
- vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col,
- vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row,
- vd->vd_mcursor_fg, vd->vd_mcursor_bg);
- }
-#endif
-}
diff --git a/sys/dev/fb/creatorreg.h b/sys/dev/fb/creatorreg.h
deleted file mode 100644
index 2cdb2dff1b93..000000000000
--- a/sys/dev/fb/creatorreg.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/*-
- * Copyright (C) 2000 David S. Miller (davem@redhat.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * from: XFree86: ffb_dac.h,v 1.1 2000/05/23 04:47:44 dawes Exp
- */
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2003 Jake Burkholder.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _DEV_FB_CREATORREG_H_
-#define _DEV_FB_CREATORREG_H_
-
-#define FFB_NREG 24
-
-#define FFB_PROM 0
-#define FFB_DAC 1
-#define FFB_FBC 2
-#define FFB_DFB8R 3
-#define FFB_DFB8G 4
-#define FFB_DFB8B 5
-#define FFB_DFB8X 6
-#define FFB_DFB24 7
-#define FFB_DFB32 8
-#define FFB_SFB8R 9
-#define FFB_SFB8G 10
-#define FFB_SFB8B 11
-#define FFB_SFB8X 12
-#define FFB_SFB32 13
-#define FFB_SFB64 14
-#define FFB_DFB422A 15
-
-#define FFB_DAC_TYPE 0x0
-#define FFB_DAC_VALUE 0x4
-#define FFB_DAC_TYPE2 0x8
-#define FFB_DAC_VALUE2 0xc
-
-/* FFB_DAC_TYPE configuration and palette register addresses */
-#define FFB_DAC_CFG_UCTRL 0x1001 /* User Control */
-#define FFB_DAC_CFG_TGEN 0x6000 /* Timing Generator Control */
-#define FFB_DAC_CFG_DID 0x8000 /* Device Identification */
-
-/* FFB_DAC_CFG_UCTRL register */
-#define FFB_DAC_UCTRL_IPDISAB 0x0001 /* Input Pullup Resistor Dis. */
-#define FFB_DAC_UCTRL_ABLANK 0x0002 /* Asynchronous Blank */
-#define FFB_DAC_UCTRL_DBENAB 0x0004 /* Double-Buffer Enable */
-#define FFB_DAC_UCTRL_OVENAB 0x0008 /* Overlay Enable */
-#define FFB_DAC_UCTRL_WMODE 0x0030 /* Window Mode */
-#define FFB_DAC_UCTRL_WM_COMB 0x0000 /* Window Mode Combined */
-#define FFB_DAC_UCTRL_WM_S4 0x0010 /* Window Mode Separate 4 */
-#define FFB_DAC_UCTRL_WM_S8 0x0020 /* Window Mode Separate 8 */
-#define FFB_DAC_UCTRL_WM_RESV 0x0030 /* Window Mode Reserved */
-#define FFB_DAC_UCTRL_MANREV 0x0f00 /* Manufacturing Revision */
-
-/* FFB_DAC_CFG_TGEN register */
-#define FFB_DAC_CFG_TGEN_VIDE 0x01 /* Video Enable */
-#define FFB_DAC_CFG_TGEN_TGE 0x02 /* Timing Generator Enable */
-#define FFB_DAC_CFG_TGEN_HSD 0x04 /* HSYNC* Disable */
-#define FFB_DAC_CFG_TGEN_VSD 0x08 /* VSYNC* Disable */
-#define FFB_DAC_CFG_TGEN_EQD 0x10 /* Equalization Disable */
-#define FFB_DAC_CFG_TGEN_MM 0x20 /* 0 = Slave, 1 = Master */
-#define FFB_DAC_CFG_TGEN_IM 0x40 /* 1 = Interlaced Mode */
-
-/* FFB_DAC_CFG_DID register */
-#define FFB_DAC_CFG_DID_ONE 0x00000001 /* Always Set */
-#define FFB_DAC_CFG_DID_MANUF 0x00000ffe /* DAC Manufacturer ID */
-#define FFB_DAC_CFG_DID_PNUM 0x0ffff000 /* DAC Part Number */
-#define FFB_DAC_CFG_DID_REV 0xf0000000 /* DAC Revision */
-
-/* FFB_DAC_TYPE2 cursor register addresses */
-#define FFB_DAC_CUR_BITMAP_P0 0x0 /* Plane 0 Cursor Bitmap */
-#define FFB_DAC_CUR_BITMAP_P1 0x80 /* Plane 1 Cursor Bitmap */
-#define FFB_DAC_CUR_CTRL 0x100 /* Cursor Control */
-#define FFB_DAC_CUR_COLOR0 0x101 /* Cursor Color 0 */
-#define FFB_DAC_CUR_COLOR1 0x102 /* Cursor Color 1 (bg) */
-#define FFB_DAC_CUR_COLOR2 0x103 /* Cursor Color 2 (fg) */
-#define FFB_DAC_CUR_POS 0x104 /* Active Cursor Position */
-
-/* FFB_DAC_CUR_CTRL register (might be inverted on PAC1 DACs) */
-#define FFB_DAC_CUR_CTRL_P0 0x1 /* Plane0 Display Disable */
-#define FFB_DAC_CUR_CTRL_P1 0x2 /* Plane1 Display Disable */
-
-#define FFB_FBC_BY 0x60
-#define FFB_FBC_BX 0x64
-#define FFB_FBC_DY 0x68
-#define FFB_FBC_DX 0x6c
-#define FFB_FBC_BH 0x70
-#define FFB_FBC_BW 0x74
-#define FFB_FBC_PPC 0x200 /* Pixel Processor Control */
-#define FFB_FBC_FG 0x208 /* Foreground */
-#define FFB_FBC_BG 0x20c /* Background */
-#define FFB_FBC_FBC 0x254 /* Frame Buffer Control */
-#define FFB_FBC_ROP 0x258 /* Raster Operation */
-#define FFB_FBC_PMASK 0x290 /* Pixel Mask */
-#define FFB_FBC_DRAWOP 0x300 /* Draw Operation */
-#define FFB_FBC_FONTXY 0x314 /* Font X/Y */
-#define FFB_FBC_FONTW 0x318 /* Font Width */
-#define FFB_FBC_FONTINC 0x31c /* Font Increment */
-#define FFB_FBC_FONT 0x320 /* Font Data */
-#define FFB_FBC_UCSR 0x900 /* User Control & Status */
-
-#define FBC_PPC_VCE_DIS 0x00001000
-#define FBC_PPC_APE_DIS 0x00000800
-#define FBC_PPC_TBE_OPAQUE 0x00000200
-#define FBC_PPC_CS_CONST 0x00000003
-
-#define FFB_FBC_WB_A 0x20000000
-#define FFB_FBC_RB_A 0x00004000
-#define FFB_FBC_SB_BOTH 0x00003000
-#define FFB_FBC_XE_OFF 0x00000040
-#define FFB_FBC_RGBE_MASK 0x0000003f
-
-#define FBC_ROP_NEW 0x83
-
-#define FBC_DRAWOP_RECTANGLE 0x08
-
-#define FBC_UCSR_FIFO_OVFL 0x80000000
-#define FBC_UCSR_READ_ERR 0x40000000
-#define FBC_UCSR_RP_BUSY 0x02000000
-#define FBC_UCSR_FB_BUSY 0x01000000
-#define FBC_UCSR_FIFO_MASK 0x00000fff
-
-#define FFB_VIRT_SFB8R 0x00000000
-#define FFB_VIRT_SFB8G 0x00400000
-#define FFB_VIRT_SFB8B 0x00800000
-#define FFB_VIRT_SFB8X 0x00c00000
-#define FFB_VIRT_SFB32 0x01000000
-#define FFB_VIRT_SFB64 0x02000000
-#define FFB_VIRT_FBC 0x04000000
-#define FFB_VIRT_FBC_BM 0x04002000
-#define FFB_VIRT_DFB8R 0x04004000
-#define FFB_VIRT_DFB8G 0x04404000
-#define FFB_VIRT_DFB8B 0x04804000
-#define FFB_VIRT_DFB8X 0x04c04000
-#define FFB_VIRT_DFB24 0x05004000
-#define FFB_VIRT_DFB32 0x06004000
-#define FFB_VIRT_DFB422A 0x07004000
-#define FFB_VIRT_DFB422AD 0x07804000
-#define FFB_VIRT_DFB24B 0x08004000
-#define FFB_VIRT_DFB422B 0x09004000
-#define FFB_VIRT_DFB422BD 0x09804000
-#define FFB_VIRT_SFB16Z 0x0a004000
-#define FFB_VIRT_SFB8Z 0x0a404000
-#define FFB_VIRT_SFB422 0x0ac04000
-#define FFB_VIRT_SFB422D 0x0b404000
-#define FFB_VIRT_FBC_KREG 0x0bc04000
-#define FFB_VIRT_DAC 0x0bc06000
-#define FFB_VIRT_PROM 0x0bc08000
-#define FFB_VIRT_EXP 0x0bc18000
-
-#define FFB_PHYS_SFB8R 0x04000000
-#define FFB_PHYS_SFB8G 0x04400000
-#define FFB_PHYS_SFB8B 0x04800000
-#define FFB_PHYS_SFB8X 0x04c00000
-#define FFB_PHYS_SFB32 0x05000000
-#define FFB_PHYS_SFB64 0x06000000
-#define FFB_PHYS_FBC 0x00600000
-#define FFB_PHYS_FBC_BM 0x00600000
-#define FFB_PHYS_DFB8R 0x01000000
-#define FFB_PHYS_DFB8G 0x01400000
-#define FFB_PHYS_DFB8B 0x01800000
-#define FFB_PHYS_DFB8X 0x01c00000
-#define FFB_PHYS_DFB24 0x02000000
-#define FFB_PHYS_DFB32 0x03000000
-#define FFB_PHYS_DFB422A 0x09000000
-#define FFB_PHYS_DFB422AD 0x09800000
-#define FFB_PHYS_DFB24B 0x0a000000
-#define FFB_PHYS_DFB422B 0x0b000000
-#define FFB_PHYS_DFB422BD 0x0b800000
-#define FFB_PHYS_SFB16Z 0x0c800000
-#define FFB_PHYS_SFB8Z 0x0c000000
-#define FFB_PHYS_SFB422 0x0d000000
-#define FFB_PHYS_SFB422D 0x0d800000
-#define FFB_PHYS_FBC_KREG 0x00610000
-#define FFB_PHYS_DAC 0x00400000
-#define FFB_PHYS_PROM 0x00000000
-#define FFB_PHYS_EXP 0x00200000
-
-#define FFB_SIZE_SFB8R 0x00400000
-#define FFB_SIZE_SFB8G 0x00400000
-#define FFB_SIZE_SFB8B 0x00400000
-#define FFB_SIZE_SFB8X 0x00400000
-#define FFB_SIZE_SFB32 0x01000000
-#define FFB_SIZE_SFB64 0x02000000
-#define FFB_SIZE_FBC 0x00002000
-#define FFB_SIZE_FBC_BM 0x00002000
-#define FFB_SIZE_DFB8R 0x00400000
-#define FFB_SIZE_DFB8G 0x00400000
-#define FFB_SIZE_DFB8B 0x00400000
-#define FFB_SIZE_DFB8X 0x00400000
-#define FFB_SIZE_DFB24 0x01000000
-#define FFB_SIZE_DFB32 0x01000000
-#define FFB_SIZE_DFB422A 0x00800000
-#define FFB_SIZE_DFB422AD 0x00800000
-#define FFB_SIZE_DFB24B 0x01000000
-#define FFB_SIZE_DFB422B 0x00800000
-#define FFB_SIZE_DFB422BD 0x00800000
-#define FFB_SIZE_SFB16Z 0x00800000
-#define FFB_SIZE_SFB8Z 0x00800000
-#define FFB_SIZE_SFB422 0x00800000
-#define FFB_SIZE_SFB422D 0x00800000
-#define FFB_SIZE_FBC_KREG 0x00002000
-#define FFB_SIZE_DAC 0x00002000
-#define FFB_SIZE_PROM 0x00010000
-#define FFB_SIZE_EXP 0x00002000
-
-#endif /* !_DEV_FB_CREATORREG_H_ */
diff --git a/sys/dev/fb/fbreg.h b/sys/dev/fb/fbreg.h
index d5bfd0daa0cd..7637f06a86b4 100644
--- a/sys/dev/fb/fbreg.h
+++ b/sys/dev/fb/fbreg.h
@@ -51,13 +51,6 @@ copyw(uint16_t *src, uint16_t *dst, size_t size)
#define bzero_io(d, c) bzero((void *)(d), (c))
#define fill_io(p, d, c) fill((p), (void *)(d), (c))
#define fillw_io(p, d, c) fillw((p), (void *)(d), (c))
-#elif defined(__sparc64__)
-static __inline void
-fillw(int val, uint16_t *buf, size_t size)
-{
- while (size--)
- *buf++ = val;
-}
#elif defined(__powerpc__)
#define bcopy_io(s, d, c) ofwfb_bcopy((void *)(s), (void *)(d), (c))
@@ -102,7 +95,7 @@ fillw(int val, uint16_t *buf, size_t size)
#define writew(a, v) (*(uint16_t*)(a) = (v))
#endif
-#else /* !__i386__ && !__amd64__ && !__sparc64__ && !__powerpc__ */
+#else /* !__i386__ && !__amd64__ && !__powerpc__ */
#define bcopy_io(s, d, c) memcpy_io((d), (s), (c))
#define bcopy_toio(s, d, c) memcpy_toio((d), (void *)(s), (c))
#define bcopy_fromio(s, d, c) memcpy_fromio((void *)(d), (s), (c))
diff --git a/sys/dev/fb/machfb.c b/sys/dev/fb/machfb.c
deleted file mode 100644
index 7c719bbe1cd9..000000000000
--- a/sys/dev/fb/machfb.c
+++ /dev/null
@@ -1,1581 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 2002 Bang Jun-Young
- * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
- * 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.
- *
- * from: NetBSD: machfb.c,v 1.23 2005/03/07 21:45:24 martin Exp
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Driver for ATI Mach64 graphics chips. Some code is derived from the
- * ATI Rage Pro and Derivatives Programmer's Guide.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/consio.h>
-#include <sys/endian.h>
-#include <sys/eventhandler.h>
-#include <sys/fbio.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/resource.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/openfirm.h>
-
-#include <machine/bus.h>
-#include <machine/bus_private.h>
-#include <machine/ofw_machdep.h>
-#include <machine/resource.h>
-#include <machine/sc_machdep.h>
-
-#include <sys/rman.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/gfb.h>
-#include <dev/fb/machfbreg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/syscons/syscons.h>
-
-/* #define MACHFB_DEBUG */
-
-#define MACHFB_DRIVER_NAME "machfb"
-
-#define MACH64_REG_OFF 0x7ffc00
-#define MACH64_REG_SIZE 1024
-
-struct machfb_softc {
- video_adapter_t sc_va; /* must be first */
-
- phandle_t sc_node;
- uint16_t sc_chip_id;
- uint8_t sc_chip_rev;
-
- struct resource *sc_memres;
- struct resource *sc_vmemres;
- bus_space_tag_t sc_memt;
- bus_space_tag_t sc_regt;
- bus_space_tag_t sc_vmemt;
- bus_space_handle_t sc_memh;
- bus_space_handle_t sc_vmemh;
- bus_space_handle_t sc_regh;
- u_long sc_mem;
- u_long sc_vmem;
-
- u_int sc_height;
- u_int sc_width;
- u_int sc_depth;
- u_int sc_xmargin;
- u_int sc_ymargin;
-
- size_t sc_memsize;
- u_int sc_memtype;
- u_int sc_mem_freq;
- u_int sc_ramdac_freq;
- u_int sc_ref_freq;
-
- u_int sc_ref_div;
- u_int sc_mclk_post_div;
- u_int sc_mclk_fb_div;
-
- const u_char *sc_font;
- u_int sc_cbwidth;
- vm_offset_t sc_curoff;
-
- int sc_bg_cache;
- int sc_fg_cache;
- u_int sc_draw_cache;
-#define MACHFB_DRAW_CHAR (1 << 0)
-#define MACHFB_DRAW_FILLRECT (1 << 1)
-
- u_int sc_flags;
-#define MACHFB_CONSOLE (1 << 0)
-#define MACHFB_CUREN (1 << 1)
-#define MACHFB_DSP (1 << 2)
-#define MACHFB_SWAP (1 << 3)
-};
-
-static const struct {
- uint16_t chip_id;
- const char *name;
- uint32_t ramdac_freq;
-} machfb_info[] = {
- { ATI_MACH64_CT, "ATI Mach64 CT", 135000 },
- { ATI_RAGE_PRO_AGP, "ATI 3D Rage Pro (AGP)", 230000 },
- { ATI_RAGE_PRO_AGP1X, "ATI 3D Rage Pro (AGP 1x)", 230000 },
- { ATI_RAGE_PRO_PCI_B, "ATI 3D Rage Pro Turbo", 230000 },
- { ATI_RAGE_XC_PCI66, "ATI Rage XL (PCI66)", 230000 },
- { ATI_RAGE_XL_AGP, "ATI Rage XL (AGP)", 230000 },
- { ATI_RAGE_XC_AGP, "ATI Rage XC (AGP)", 230000 },
- { ATI_RAGE_XL_PCI66, "ATI Rage XL (PCI66)", 230000 },
- { ATI_RAGE_PRO_PCI_P, "ATI 3D Rage Pro", 230000 },
- { ATI_RAGE_PRO_PCI_L, "ATI 3D Rage Pro (limited 3D)", 230000 },
- { ATI_RAGE_XL_PCI, "ATI Rage XL", 230000 },
- { ATI_RAGE_XC_PCI, "ATI Rage XC", 230000 },
- { ATI_RAGE_II, "ATI 3D Rage I/II", 135000 },
- { ATI_RAGE_IIP, "ATI 3D Rage II+", 200000 },
- { ATI_RAGE_IIC_PCI, "ATI 3D Rage IIC", 230000 },
- { ATI_RAGE_IIC_AGP_B, "ATI 3D Rage IIC (AGP)", 230000 },
- { ATI_RAGE_IIC_AGP_P, "ATI 3D Rage IIC (AGP)", 230000 },
- { ATI_RAGE_LT_PRO_AGP, "ATI 3D Rage LT Pro (AGP 133MHz)", 230000 },
- { ATI_RAGE_MOB_M3_PCI, "ATI Rage Mobility M3", 230000 },
- { ATI_RAGE_MOB_M3_AGP, "ATI Rage Mobility M3 (AGP)", 230000 },
- { ATI_RAGE_LT, "ATI 3D Rage LT", 230000 },
- { ATI_RAGE_LT_PRO_PCI, "ATI 3D Rage LT Pro", 230000 },
- { ATI_RAGE_MOBILITY, "ATI Rage Mobility", 230000 },
- { ATI_RAGE_L_MOBILITY, "ATI Rage L Mobility", 230000 },
- { ATI_RAGE_LT_PRO, "ATI 3D Rage LT Pro", 230000 },
- { ATI_RAGE_LT_PRO2, "ATI 3D Rage LT Pro", 230000 },
- { ATI_RAGE_MOB_M1_PCI, "ATI Rage Mobility M1 (PCI)", 230000 },
- { ATI_RAGE_L_MOB_M1_PCI, "ATI Rage L Mobility (PCI)", 230000 },
- { ATI_MACH64_VT, "ATI Mach64 VT", 170000 },
- { ATI_MACH64_VTB, "ATI Mach64 VTB", 200000 },
- { ATI_MACH64_VT4, "ATI Mach64 VT4", 230000 }
-};
-
-static const struct machfb_cmap {
- uint8_t red;
- uint8_t green;
- uint8_t blue;
-} machfb_default_cmap[16] = {
- {0x00, 0x00, 0x00}, /* black */
- {0x00, 0x00, 0xff}, /* blue */
- {0x00, 0xff, 0x00}, /* green */
- {0x00, 0xc0, 0xc0}, /* cyan */
- {0xff, 0x00, 0x00}, /* red */
- {0xc0, 0x00, 0xc0}, /* magenta */
- {0xc0, 0xc0, 0x00}, /* brown */
- {0xc0, 0xc0, 0xc0}, /* light grey */
- {0x80, 0x80, 0x80}, /* dark grey */
- {0x80, 0x80, 0xff}, /* light blue */
- {0x80, 0xff, 0x80}, /* light green */
- {0x80, 0xff, 0xff}, /* light cyan */
- {0xff, 0x80, 0x80}, /* light red */
- {0xff, 0x80, 0xff}, /* light magenta */
- {0xff, 0xff, 0x80}, /* yellow */
- {0xff, 0xff, 0xff} /* white */
-};
-
-#define MACHFB_CMAP_OFF 16
-
-static const u_char machfb_mouse_pointer_bits[64][8] = {
- { 0x00, 0x00, }, /* ............ */
- { 0x80, 0x00, }, /* *........... */
- { 0xc0, 0x00, }, /* **.......... */
- { 0xe0, 0x00, }, /* ***......... */
- { 0xf0, 0x00, }, /* ****........ */
- { 0xf8, 0x00, }, /* *****....... */
- { 0xfc, 0x00, }, /* ******...... */
- { 0xfe, 0x00, }, /* *******..... */
- { 0xff, 0x00, }, /* ********.... */
- { 0xff, 0x80, }, /* *********... */
- { 0xfc, 0xc0, }, /* ******..**.. */
- { 0xdc, 0x00, }, /* **.***...... */
- { 0x8e, 0x00, }, /* *...***..... */
- { 0x0e, 0x00, }, /* ....***..... */
- { 0x07, 0x00, }, /* .....***.... */
- { 0x04, 0x00, }, /* .....*...... */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
- { 0x00, 0x00, }, /* ............ */
-};
-
-/*
- * Lookup table to perform a bit-swap of the mouse pointer bits,
- * map set bits to CUR_CLR0 and unset bits to transparent.
- */
-static const u_char machfb_mouse_pointer_lut[] = {
- 0xaa, 0x2a, 0x8a, 0x0a, 0xa2, 0x22, 0x82, 0x02,
- 0xa8, 0x28, 0x88, 0x08, 0xa0, 0x20, 0x80, 0x00
-};
-
-static const char *const machfb_memtype_names[] = {
- "(N/A)", "DRAM", "EDO DRAM", "EDO DRAM", "SDRAM", "SGRAM", "WRAM",
- "(unknown type)"
-};
-
-extern const struct gfb_font gallant12x22;
-
-static struct machfb_softc machfb_softc;
-static struct bus_space_tag machfb_bst_store[1];
-
-static device_probe_t machfb_pci_probe;
-static device_attach_t machfb_pci_attach;
-static device_detach_t machfb_pci_detach;
-
-static device_method_t machfb_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, machfb_pci_probe),
- DEVMETHOD(device_attach, machfb_pci_attach),
- DEVMETHOD(device_detach, machfb_pci_detach),
-
- { 0, 0 }
-};
-
-static driver_t machfb_pci_driver = {
- MACHFB_DRIVER_NAME,
- machfb_methods,
- sizeof(struct machfb_softc),
-};
-
-static devclass_t machfb_devclass;
-
-DRIVER_MODULE(machfb, pci, machfb_pci_driver, machfb_devclass, 0, 0);
-MODULE_DEPEND(machfb, pci, 1, 1, 1);
-
-static void machfb_cursor_enable(struct machfb_softc *, int);
-static int machfb_cursor_install(struct machfb_softc *);
-static int machfb_get_memsize(struct machfb_softc *);
-static void machfb_reset_engine(struct machfb_softc *);
-static void machfb_init_engine(struct machfb_softc *);
-#if 0
-static void machfb_adjust_frame(struct machfb_softc *, int, int);
-#endif
-static void machfb_shutdown_final(void *);
-static void machfb_shutdown_reset(void *);
-
-static int machfb_configure(int);
-
-static vi_probe_t machfb_probe;
-static vi_init_t machfb_init;
-static vi_get_info_t machfb_get_info;
-static vi_query_mode_t machfb_query_mode;
-static vi_set_mode_t machfb_set_mode;
-static vi_save_font_t machfb_save_font;
-static vi_load_font_t machfb_load_font;
-static vi_show_font_t machfb_show_font;
-static vi_save_palette_t machfb_save_palette;
-static vi_load_palette_t machfb_load_palette;
-static vi_set_border_t machfb_set_border;
-static vi_save_state_t machfb_save_state;
-static vi_load_state_t machfb_load_state;
-static vi_set_win_org_t machfb_set_win_org;
-static vi_read_hw_cursor_t machfb_read_hw_cursor;
-static vi_set_hw_cursor_t machfb_set_hw_cursor;
-static vi_set_hw_cursor_shape_t machfb_set_hw_cursor_shape;
-static vi_blank_display_t machfb_blank_display;
-static vi_mmap_t machfb_mmap;
-static vi_ioctl_t machfb_ioctl;
-static vi_clear_t machfb_clear;
-static vi_fill_rect_t machfb_fill_rect;
-static vi_bitblt_t machfb_bitblt;
-static vi_diag_t machfb_diag;
-static vi_save_cursor_palette_t machfb_save_cursor_palette;
-static vi_load_cursor_palette_t machfb_load_cursor_palette;
-static vi_copy_t machfb_copy;
-static vi_putp_t machfb_putp;
-static vi_putc_t machfb_putc;
-static vi_puts_t machfb_puts;
-static vi_putm_t machfb_putm;
-
-static video_switch_t machfbvidsw = {
- .probe = machfb_probe,
- .init = machfb_init,
- .get_info = machfb_get_info,
- .query_mode = machfb_query_mode,
- .set_mode = machfb_set_mode,
- .save_font = machfb_save_font,
- .load_font = machfb_load_font,
- .show_font = machfb_show_font,
- .save_palette = machfb_save_palette,
- .load_palette = machfb_load_palette,
- .set_border = machfb_set_border,
- .save_state = machfb_save_state,
- .load_state = machfb_load_state,
- .set_win_org = machfb_set_win_org,
- .read_hw_cursor = machfb_read_hw_cursor,
- .set_hw_cursor = machfb_set_hw_cursor,
- .set_hw_cursor_shape = machfb_set_hw_cursor_shape,
- .blank_display = machfb_blank_display,
- .mmap = machfb_mmap,
- .ioctl = machfb_ioctl,
- .clear = machfb_clear,
- .fill_rect = machfb_fill_rect,
- .bitblt = machfb_bitblt,
- .diag = machfb_diag,
- .save_cursor_palette = machfb_save_cursor_palette,
- .load_cursor_palette = machfb_load_cursor_palette,
- .copy = machfb_copy,
- .putp = machfb_putp,
- .putc = machfb_putc,
- .puts = machfb_puts,
- .putm = machfb_putm
-};
-
-VIDEO_DRIVER(machfb, machfbvidsw, machfb_configure);
-
-extern sc_rndr_sw_t txtrndrsw;
-RENDERER(machfb, 0, txtrndrsw, gfb_set);
-
-RENDERER_MODULE(machfb, gfb_set);
-
-/*
- * Inline functions for getting access to register aperture.
- */
-static inline uint32_t regr(struct machfb_softc *, uint32_t);
-static inline uint8_t regrb(struct machfb_softc *, uint32_t);
-static inline void regw(struct machfb_softc *, uint32_t, uint32_t);
-static inline void regwb(struct machfb_softc *, uint32_t, uint8_t);
-static inline void regwb_pll(struct machfb_softc *, uint32_t, uint8_t);
-
-static inline uint32_t
-regr(struct machfb_softc *sc, uint32_t index)
-{
-
- return bus_space_read_4(sc->sc_regt, sc->sc_regh, index);
-}
-
-static inline uint8_t
-regrb(struct machfb_softc *sc, uint32_t index)
-{
-
- return bus_space_read_1(sc->sc_regt, sc->sc_regh, index);
-}
-
-static inline void
-regw(struct machfb_softc *sc, uint32_t index, uint32_t data)
-{
-
- bus_space_write_4(sc->sc_regt, sc->sc_regh, index, data);
- bus_space_barrier(sc->sc_regt, sc->sc_regh, index, 4,
- BUS_SPACE_BARRIER_WRITE);
-}
-
-static inline void
-regwb(struct machfb_softc *sc, uint32_t index, uint8_t data)
-{
-
- bus_space_write_1(sc->sc_regt, sc->sc_regh, index, data);
- bus_space_barrier(sc->sc_regt, sc->sc_regh, index, 1,
- BUS_SPACE_BARRIER_WRITE);
-}
-
-static inline void
-regwb_pll(struct machfb_softc *sc, uint32_t index, uint8_t data)
-{
-
- regwb(sc, CLOCK_CNTL + 1, (index << 2) | PLL_WR_EN);
- regwb(sc, CLOCK_CNTL + 2, data);
- regwb(sc, CLOCK_CNTL + 1, (index << 2) & ~PLL_WR_EN);
-}
-
-static inline void
-wait_for_fifo(struct machfb_softc *sc, uint8_t v)
-{
-
- while ((regr(sc, FIFO_STAT) & 0xffff) > (0x8000 >> v))
- ;
-}
-
-static inline void
-wait_for_idle(struct machfb_softc *sc)
-{
-
- wait_for_fifo(sc, 16);
- while ((regr(sc, GUI_STAT) & 1) != 0)
- ;
-}
-
-/*
- * Inline functions for setting the background and foreground colors.
- */
-static inline void machfb_setbg(struct machfb_softc *sc, int bg);
-static inline void machfb_setfg(struct machfb_softc *sc, int fg);
-
-static inline void
-machfb_setbg(struct machfb_softc *sc, int bg)
-{
-
- if (bg == sc->sc_bg_cache)
- return;
- sc->sc_bg_cache = bg;
- wait_for_fifo(sc, 1);
- regw(sc, DP_BKGD_CLR, bg + MACHFB_CMAP_OFF);
-}
-
-static inline void
-machfb_setfg(struct machfb_softc *sc, int fg)
-{
-
- if (fg == sc->sc_fg_cache)
- return;
- sc->sc_fg_cache = fg;
- wait_for_fifo(sc, 1);
- regw(sc, DP_FRGD_CLR, fg + MACHFB_CMAP_OFF);
-}
-
-/*
- * video driver interface
- */
-static int
-machfb_configure(int flags)
-{
- struct machfb_softc *sc;
- phandle_t chosen, output;
- ihandle_t stdout;
- bus_addr_t addr;
- uint32_t id;
- int i, space;
-
- /*
- * For the high-level console probing return the number of
- * registered adapters.
- */
- if (!(flags & VIO_PROBE_ONLY)) {
- for (i = 0; vid_find_adapter(MACHFB_DRIVER_NAME, i) >= 0; i++)
- ;
- return (i);
- }
-
- /* Low-level console probing and initialization. */
-
- sc = &machfb_softc;
- if (sc->sc_va.va_flags & V_ADP_REGISTERED)
- goto found;
-
- if ((chosen = OF_finddevice("/chosen")) == -1) /* Quis contra nos? */
- return (0);
- if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
- return (0);
- if ((output = OF_instance_to_package(stdout)) == -1)
- return (0);
- if ((OF_getprop(output, "vendor-id", &id, sizeof(id)) == -1) ||
- id != ATI_VENDOR)
- return (0);
- if (OF_getprop(output, "device-id", &id, sizeof(id)) == -1)
- return (0);
- for (i = 0; i < nitems(machfb_info); i++) {
- if (id == machfb_info[i].chip_id) {
- sc->sc_flags = MACHFB_CONSOLE;
- sc->sc_node = output;
- sc->sc_chip_id = id;
- break;
- }
- }
- if (!(sc->sc_flags & MACHFB_CONSOLE))
- return (0);
-
- if (OF_getprop(output, "revision-id", &sc->sc_chip_rev,
- sizeof(sc->sc_chip_rev)) == -1)
- return (0);
- if (OF_decode_addr(output, 0, &space, &addr) != 0)
- return (0);
- sc->sc_memt = &machfb_bst_store[0];
- sc->sc_memh = sparc64_fake_bustag(space, addr, sc->sc_memt);
- sc->sc_regt = sc->sc_memt;
- bus_space_subregion(sc->sc_regt, sc->sc_memh, MACH64_REG_OFF,
- MACH64_REG_SIZE, &sc->sc_regh);
-
- if (machfb_init(0, &sc->sc_va, 0) < 0)
- return (0);
-
- found:
- /* Return number of found adapters. */
- return (1);
-}
-
-static int
-machfb_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
-{
-
- return (0);
-}
-
-static int
-machfb_init(int unit, video_adapter_t *adp, int flags)
-{
- struct machfb_softc *sc;
- phandle_t options;
- video_info_t *vi;
- char buf[32];
- int i;
- uint8_t dac_mask, dac_rindex, dac_windex;
-
- sc = (struct machfb_softc *)adp;
- vi = &adp->va_info;
-
- if ((regr(sc, CONFIG_CHIP_ID) & 0xffff) != sc->sc_chip_id)
- return (ENXIO);
-
- sc->sc_ramdac_freq = 0;
- for (i = 0; i < nitems(machfb_info); i++) {
- if (sc->sc_chip_id == machfb_info[i].chip_id) {
- sc->sc_ramdac_freq = machfb_info[i].ramdac_freq;
- break;
- }
- }
- if (sc->sc_ramdac_freq == 0)
- return (ENXIO);
- if (sc->sc_chip_id == ATI_RAGE_II && sc->sc_chip_rev & 0x07)
- sc->sc_ramdac_freq = 170000;
-
- vid_init_struct(adp, MACHFB_DRIVER_NAME, -1, unit);
-
- if (OF_getprop(sc->sc_node, "height", &sc->sc_height,
- sizeof(sc->sc_height)) == -1)
- return (ENXIO);
- if (OF_getprop(sc->sc_node, "width", &sc->sc_width,
- sizeof(sc->sc_width)) == -1)
- return (ENXIO);
- if (OF_getprop(sc->sc_node, "depth", &sc->sc_depth,
- sizeof(sc->sc_depth)) == -1)
- return (ENXIO);
- if ((options = OF_finddevice("/options")) == -1)
- return (ENXIO);
- if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1)
- return (ENXIO);
- vi->vi_height = strtol(buf, NULL, 10);
- if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1)
- return (ENXIO);
- vi->vi_width = strtol(buf, NULL, 10);
- vi->vi_cwidth = gallant12x22.width;
- vi->vi_cheight = gallant12x22.height;
- vi->vi_flags = V_INFO_COLOR;
- vi->vi_mem_model = V_INFO_MM_OTHER;
-
- sc->sc_font = gallant12x22.data;
- sc->sc_cbwidth = howmany(vi->vi_cwidth, NBBY); /* width in bytes */
- sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
- sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2;
-
- if (sc->sc_chip_id != ATI_MACH64_CT &&
- !((sc->sc_chip_id == ATI_MACH64_VT ||
- sc->sc_chip_id == ATI_RAGE_II) &&
- (sc->sc_chip_rev & 0x07) == 0))
- sc->sc_flags |= MACHFB_DSP;
-
- sc->sc_memsize = machfb_get_memsize(sc);
- if (sc->sc_memsize == 8192)
- /* The last page is used as register aperture. */
- sc->sc_memsize -= 4;
- sc->sc_memtype = regr(sc, CONFIG_STAT0) & 0x07;
-
- if ((sc->sc_chip_id >= ATI_RAGE_XC_PCI66 &&
- sc->sc_chip_id <= ATI_RAGE_XL_PCI66) ||
- (sc->sc_chip_id >= ATI_RAGE_XL_PCI &&
- sc->sc_chip_id <= ATI_RAGE_XC_PCI))
- sc->sc_ref_freq = 29498;
- else
- sc->sc_ref_freq = 14318;
-
- regwb(sc, CLOCK_CNTL + 1, PLL_REF_DIV << 2);
- sc->sc_ref_div = regrb(sc, CLOCK_CNTL + 2);
- regwb(sc, CLOCK_CNTL + 1, MCLK_FB_DIV << 2);
- sc->sc_mclk_fb_div = regrb(sc, CLOCK_CNTL + 2);
- sc->sc_mem_freq = (2 * sc->sc_ref_freq * sc->sc_mclk_fb_div) /
- (sc->sc_ref_div * 2);
- sc->sc_mclk_post_div = (sc->sc_mclk_fb_div * 2 * sc->sc_ref_freq) /
- (sc->sc_mem_freq * sc->sc_ref_div);
-
- machfb_init_engine(sc);
-#if 0
- machfb_adjust_frame(0, 0);
-#endif
- machfb_set_mode(adp, 0);
-
- /*
- * Install our 16-color color map. This is done only once and with
- * an offset of 16 on sparc64 as there the OBP driver expects white
- * to be at index 0 and black at 255 (some versions also use 1 - 8
- * for color text support or the full palette for the boot banner
- * logo but no versions seems to use the ISO 6429-1983 color map).
- * Otherwise the colors are inverted when back in the OFW.
- */
- dac_rindex = regrb(sc, DAC_RINDEX);
- dac_windex = regrb(sc, DAC_WINDEX);
- dac_mask = regrb(sc, DAC_MASK);
- regwb(sc, DAC_MASK, 0xff);
- regwb(sc, DAC_WINDEX, MACHFB_CMAP_OFF);
- for (i = 0; i < 16; i++) {
- regwb(sc, DAC_DATA, machfb_default_cmap[i].red);
- regwb(sc, DAC_DATA, machfb_default_cmap[i].green);
- regwb(sc, DAC_DATA, machfb_default_cmap[i].blue);
- }
- regwb(sc, DAC_MASK, dac_mask);
- regwb(sc, DAC_RINDEX, dac_rindex);
- regwb(sc, DAC_WINDEX, dac_windex);
-
- machfb_blank_display(adp, V_DISPLAY_ON);
- machfb_clear(adp);
-
- /*
- * Setting V_ADP_MODECHANGE serves as hack so machfb_set_mode()
- * (which will invalidate our caches) is called as a precaution
- * when the X server shuts down.
- */
- adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_PALETTE |
- V_ADP_BORDER | V_ADP_INITIALIZED;
- if (vid_register(adp) < 0)
- return (ENXIO);
- adp->va_flags |= V_ADP_REGISTERED;
-
- return (0);
-}
-
-static int
-machfb_get_info(video_adapter_t *adp, int mode, video_info_t *info)
-{
-
- bcopy(&adp->va_info, info, sizeof(*info));
-
- return (0);
-}
-
-static int
-machfb_query_mode(video_adapter_t *adp, video_info_t *info)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_set_mode(video_adapter_t *adp, int mode)
-{
- struct machfb_softc *sc;
-
- sc = (struct machfb_softc *)adp;
-
- sc->sc_bg_cache = -1;
- sc->sc_fg_cache = -1;
- sc->sc_draw_cache = 0;
-
- return (0);
-}
-
-static int
-machfb_save_font(video_adapter_t *adp, int page, int size, int width,
- u_char *data, int c, int count)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_load_font(video_adapter_t *adp, int page, int size, int width,
- u_char *data, int c, int count)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_show_font(video_adapter_t *adp, int page)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_save_palette(video_adapter_t *adp, u_char *palette)
-{
- struct machfb_softc *sc;
- int i;
- uint8_t dac_mask, dac_rindex, dac_windex;
-
- sc = (struct machfb_softc *)adp;
-
- dac_rindex = regrb(sc, DAC_RINDEX);
- dac_windex = regrb(sc, DAC_WINDEX);
- dac_mask = regrb(sc, DAC_MASK);
- regwb(sc, DAC_MASK, 0xff);
- regwb(sc, DAC_RINDEX, 0x0);
- for (i = 0; i < 256 * 3; i++)
- palette[i] = regrb(sc, DAC_DATA);
- regwb(sc, DAC_MASK, dac_mask);
- regwb(sc, DAC_RINDEX, dac_rindex);
- regwb(sc, DAC_WINDEX, dac_windex);
-
- return (0);
-}
-
-static int
-machfb_load_palette(video_adapter_t *adp, u_char *palette)
-{
- struct machfb_softc *sc;
- int i;
- uint8_t dac_mask, dac_rindex, dac_windex;
-
- sc = (struct machfb_softc *)adp;
-
- dac_rindex = regrb(sc, DAC_RINDEX);
- dac_windex = regrb(sc, DAC_WINDEX);
- dac_mask = regrb(sc, DAC_MASK);
- regwb(sc, DAC_MASK, 0xff);
- regwb(sc, DAC_WINDEX, 0x0);
- for (i = 0; i < 256 * 3; i++)
- regwb(sc, DAC_DATA, palette[i]);
- regwb(sc, DAC_MASK, dac_mask);
- regwb(sc, DAC_RINDEX, dac_rindex);
- regwb(sc, DAC_WINDEX, dac_windex);
-
- return (0);
-}
-
-static int
-machfb_set_border(video_adapter_t *adp, int border)
-{
- struct machfb_softc *sc;
-
- sc = (struct machfb_softc *)adp;
-
- machfb_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin);
- machfb_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin,
- sc->sc_width, sc->sc_ymargin);
- machfb_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height);
- machfb_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0,
- sc->sc_xmargin, sc->sc_height);
-
- return (0);
-}
-
-static int
-machfb_save_state(video_adapter_t *adp, void *p, size_t size)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_load_state(video_adapter_t *adp, void *p)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_set_win_org(video_adapter_t *adp, off_t offset)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
-{
-
- *col = 0;
- *row = 0;
-
- return (0);
-}
-
-static int
-machfb_set_hw_cursor(video_adapter_t *adp, int col, int row)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
- int celsize, int blink)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_blank_display(video_adapter_t *adp, int mode)
-{
- struct machfb_softc *sc;
- uint32_t crtc_gen_cntl;
-
- sc = (struct machfb_softc *)adp;
-
- crtc_gen_cntl = (regr(sc, CRTC_GEN_CNTL) | CRTC_EXT_DISP_EN | CRTC_EN) &
- ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_DISPLAY_DIS);
- switch (mode) {
- case V_DISPLAY_ON:
- break;
- case V_DISPLAY_BLANK:
- crtc_gen_cntl |= CRTC_HSYNC_DIS | CRTC_VSYNC_DIS |
- CRTC_DISPLAY_DIS;
- break;
- case V_DISPLAY_STAND_BY:
- crtc_gen_cntl |= CRTC_HSYNC_DIS | CRTC_DISPLAY_DIS;
- break;
- case V_DISPLAY_SUSPEND:
- crtc_gen_cntl |= CRTC_VSYNC_DIS | CRTC_DISPLAY_DIS;
- break;
- }
- regw(sc, CRTC_GEN_CNTL, crtc_gen_cntl);
-
- return (0);
-}
-
-static int
-machfb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr,
- int prot, vm_memattr_t *memattr)
-{
- struct machfb_softc *sc;
- video_info_t *vi;
-
- sc = (struct machfb_softc *)adp;
- vi = &adp->va_info;
-
- /* BAR 2 - VGA memory */
- if (sc->sc_vmem != 0 && offset >= sc->sc_vmem &&
- offset < sc->sc_vmem + vi->vi_registers_size) {
- *paddr = vi->vi_registers + offset - sc->sc_vmem;
- return (0);
- }
-
- /* BAR 0 - framebuffer */
- if (offset >= sc->sc_mem &&
- offset < sc->sc_mem + vi->vi_buffer_size) {
- *paddr = vi->vi_buffer + offset - sc->sc_mem;
- return (0);
- }
-
- /* 'regular' framebuffer mmap()ing */
- if (offset < adp->va_window_size) {
- *paddr = vi->vi_window + offset;
- return (0);
- }
-
- return (EINVAL);
-}
-
-static int
-machfb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
-{
- struct machfb_softc *sc;
- struct fbcursor *fbc;
- struct fbtype *fb;
-
- sc = (struct machfb_softc *)adp;
-
- switch (cmd) {
- case FBIOGTYPE:
- fb = (struct fbtype *)data;
- fb->fb_type = FBTYPE_PCIMISC;
- fb->fb_height = sc->sc_height;
- fb->fb_width = sc->sc_width;
- fb->fb_depth = sc->sc_depth;
- if (sc->sc_depth <= 1 || sc->sc_depth > 8)
- fb->fb_cmsize = 0;
- else
- fb->fb_cmsize = 1 << sc->sc_depth;
- fb->fb_size = adp->va_buffer_size;
- break;
- case FBIOSCURSOR:
- fbc = (struct fbcursor *)data;
- if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) {
- machfb_cursor_enable(sc, 0);
- sc->sc_flags &= ~MACHFB_CUREN;
- } else
- return (ENODEV);
- break;
- default:
- return (fb_commonioctl(adp, cmd, data));
- }
-
- return (0);
-}
-
-static int
-machfb_clear(video_adapter_t *adp)
-{
- struct machfb_softc *sc;
-
- sc = (struct machfb_softc *)adp;
-
- machfb_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width,
- sc->sc_height);
-
- return (0);
-}
-
-static int
-machfb_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
-{
- struct machfb_softc *sc;
-
- sc = (struct machfb_softc *)adp;
-
- if (sc->sc_draw_cache != MACHFB_DRAW_FILLRECT) {
- wait_for_fifo(sc, 7);
- regw(sc, DP_WRITE_MASK, 0xff);
- regw(sc, DP_PIX_WIDTH, DST_8BPP | SRC_8BPP | HOST_8BPP);
- regw(sc, DP_SRC, FRGD_SRC_FRGD_CLR);
- regw(sc, DP_MIX, MIX_SRC << 16);
- regw(sc, CLR_CMP_CNTL, 0); /* no transparency */
- regw(sc, SRC_CNTL, SRC_LINE_X_LEFT_TO_RIGHT);
- regw(sc, DST_CNTL, DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM);
- sc->sc_draw_cache = MACHFB_DRAW_FILLRECT;
- }
- machfb_setfg(sc, val);
- wait_for_fifo(sc, 4);
- regw(sc, SRC_Y_X, (x << 16) | y);
- regw(sc, SRC_WIDTH1, cx);
- regw(sc, DST_Y_X, (x << 16) | y);
- regw(sc, DST_HEIGHT_WIDTH, (cx << 16) | cy);
-
- return (0);
-}
-
-static int
-machfb_bitblt(video_adapter_t *adp, ...)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_diag(video_adapter_t *adp, int level)
-{
- video_info_t info;
-
- fb_dump_adp_info(adp->va_name, adp, level);
- machfb_get_info(adp, 0, &info);
- fb_dump_mode_info(adp->va_name, adp, &info, level);
-
- return (0);
-}
-
-static int
-machfb_save_cursor_palette(video_adapter_t *adp, u_char *palette)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_load_cursor_palette(video_adapter_t *adp, u_char *palette)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_putp(video_adapter_t *adp, vm_offset_t off, uint32_t p, uint32_t a,
- int size, int bpp, int bit_ltor, int byte_ltor)
-{
-
- return (ENODEV);
-}
-
-static int
-machfb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a)
-{
- struct machfb_softc *sc;
- const uint8_t *p;
- int i;
-
- sc = (struct machfb_softc *)adp;
-
- if (sc->sc_draw_cache != MACHFB_DRAW_CHAR) {
- wait_for_fifo(sc, 8);
- regw(sc, DP_WRITE_MASK, 0xff); /* XXX only good for 8 bit */
- regw(sc, DP_PIX_WIDTH, DST_8BPP | SRC_1BPP | HOST_1BPP);
- regw(sc, DP_SRC, MONO_SRC_HOST | BKGD_SRC_BKGD_CLR |
- FRGD_SRC_FRGD_CLR);
- regw(sc, DP_MIX ,((MIX_SRC & 0xffff) << 16) | MIX_SRC);
- regw(sc, CLR_CMP_CNTL, 0); /* no transparency */
- regw(sc, SRC_CNTL, SRC_LINE_X_LEFT_TO_RIGHT);
- regw(sc, DST_CNTL, DST_Y_TOP_TO_BOTTOM | DST_X_LEFT_TO_RIGHT);
- regw(sc, HOST_CNTL, HOST_BYTE_ALIGN);
- sc->sc_draw_cache = MACHFB_DRAW_CHAR;
- }
- machfb_setbg(sc, (a >> 4) & 0xf);
- machfb_setfg(sc, a & 0xf);
- wait_for_fifo(sc, 4 + (adp->va_info.vi_cheight / sc->sc_cbwidth));
- regw(sc, SRC_Y_X, 0);
- regw(sc, SRC_WIDTH1, adp->va_info.vi_cwidth);
- regw(sc, DST_Y_X, ((((off % adp->va_info.vi_width) *
- adp->va_info.vi_cwidth) + sc->sc_xmargin) << 16) |
- (((off / adp->va_info.vi_width) * adp->va_info.vi_cheight) +
- sc->sc_ymargin));
- regw(sc, DST_HEIGHT_WIDTH, (adp->va_info.vi_cwidth << 16) |
- adp->va_info.vi_cheight);
- p = sc->sc_font + (c * adp->va_info.vi_cheight * sc->sc_cbwidth);
- for (i = 0; i < adp->va_info.vi_cheight * sc->sc_cbwidth; i += 4)
- regw(sc, HOST_DATA0 + i, (p[i + 3] << 24 | p[i + 2] << 16 |
- p[i + 1] << 8 | p[i]));
-
- return (0);
-}
-
-static int
-machfb_puts(video_adapter_t *adp, vm_offset_t off, uint16_t *s, int len)
-{
- struct machfb_softc *sc;
- int blanks, i, x1, x2, y1, y2;
- uint8_t a, c, color1, color2;
-
- sc = (struct machfb_softc *)adp;
-
-#define MACHFB_BLANK machfb_fill_rect(adp, color1, x1, y1, \
- blanks * adp->va_info.vi_cwidth, \
- adp->va_info.vi_cheight)
-
- blanks = color1 = x1 = y1 = 0;
- for (i = 0; i < len; i++) {
- /*
- * Accelerate continuous blanks by drawing a respective
- * rectangle instead. Drawing a rectangle of any size
- * takes about the same number of operations as drawing
- * a single character.
- */
- c = s[i] & 0xff;
- a = (s[i] & 0xff00) >> 8;
- if (c == 0x00 || c == 0x20 || c == 0xdb || c == 0xff) {
- color2 = (a >> (c == 0xdb ? 0 : 4) & 0xf);
- x2 = (((off + i) % adp->va_info.vi_width) *
- adp->va_info.vi_cwidth) + sc->sc_xmargin;
- y2 = (((off + i) / adp->va_info.vi_width) *
- adp->va_info.vi_cheight) + sc->sc_ymargin;
- if (blanks == 0) {
- color1 = color2;
- x1 = x2;
- y1 = y2;
- blanks++;
- } else if (color1 != color2 || y1 != y2) {
- MACHFB_BLANK;
- color1 = color2;
- x1 = x2;
- y1 = y2;
- blanks = 1;
- } else
- blanks++;
- } else {
- if (blanks != 0) {
- MACHFB_BLANK;
- blanks = 0;
- }
- vidd_putc(adp, off + i, c, a);
- }
- }
- if (blanks != 0)
- MACHFB_BLANK;
-
-#undef MACHFB_BLANK
-
- return (0);
-}
-
-static int
-machfb_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image,
- uint32_t pixel_mask, int size, int width)
-{
- struct machfb_softc *sc;
- int error;
-
- sc = (struct machfb_softc *)adp;
-
- if ((!(sc->sc_flags & MACHFB_CUREN)) &&
- (error = machfb_cursor_install(sc)) < 0)
- return (error);
- else {
- /*
- * The hardware cursor always must be disabled when
- * fiddling with its bits otherwise some artifacts
- * may appear on the screen.
- */
- machfb_cursor_enable(sc, 0);
- }
-
- regw(sc, CUR_HORZ_VERT_OFF, 0);
- if ((regr(sc, GEN_TEST_CNTL) & CRTC_DBL_SCAN_EN) != 0)
- y <<= 1;
- regw(sc, CUR_HORZ_VERT_POSN, ((y + sc->sc_ymargin) << 16) |
- (x + sc->sc_xmargin));
- machfb_cursor_enable(sc, 1);
- sc->sc_flags |= MACHFB_CUREN;
-
- return (0);
-}
-
-/*
- * PCI bus interface
- */
-static int
-machfb_pci_probe(device_t dev)
-{
- int i;
-
- if (pci_get_class(dev) != PCIC_DISPLAY ||
- pci_get_subclass(dev) != PCIS_DISPLAY_VGA)
- return (ENXIO);
-
- for (i = 0; i < nitems(machfb_info); i++) {
- if (pci_get_device(dev) == machfb_info[i].chip_id) {
- device_set_desc(dev, machfb_info[i].name);
- return (BUS_PROBE_DEFAULT);
- }
- }
-
- return (ENXIO);
-}
-
-static int
-machfb_pci_attach(device_t dev)
-{
- struct machfb_softc *sc;
- video_adapter_t *adp;
- video_switch_t *sw;
- video_info_t *vi;
- phandle_t node;
- int error, i, rid;
- uint32_t *p32, u32;
- uint8_t *p;
-
- node = ofw_bus_get_node(dev);
- if ((sc = (struct machfb_softc *)vid_get_adapter(vid_find_adapter(
- MACHFB_DRIVER_NAME, 0))) != NULL && sc->sc_node == node) {
- device_printf(dev, "console\n");
- device_set_softc(dev, sc);
- } else {
- sc = device_get_softc(dev);
-
- sc->sc_node = node;
- sc->sc_chip_id = pci_get_device(dev);
- sc->sc_chip_rev = pci_get_revid(dev);
- }
- adp = &sc->sc_va;
- vi = &adp->va_info;
-
- rid = PCIR_BAR(0);
- if ((sc->sc_memres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
- RF_ACTIVE)) == NULL) {
- device_printf(dev, "cannot allocate memory resources\n");
- return (ENXIO);
- }
- sc->sc_memt = rman_get_bustag(sc->sc_memres);
- sc->sc_memh = rman_get_bushandle(sc->sc_memres);
- sc->sc_mem = rman_get_start(sc->sc_memres);
- vi->vi_buffer = sc->sc_memh;
- vi->vi_buffer_size = rman_get_size(sc->sc_memres);
- if (OF_getprop(sc->sc_node, "address", &u32, sizeof(u32)) > 0 &&
- vtophys(u32) == sc->sc_memh)
- adp->va_mem_base = u32;
- else {
- if (bus_space_map(sc->sc_memt, vi->vi_buffer,
- vi->vi_buffer_size, BUS_SPACE_MAP_LINEAR,
- &sc->sc_memh) != 0) {
- device_printf(dev, "cannot map memory resources\n");
- error = ENXIO;
- goto fail_memres;
- }
- adp->va_mem_base =
- (vm_offset_t)rman_get_virtual(sc->sc_memres);
- }
- adp->va_mem_size = vi->vi_buffer_size;
- adp->va_buffer = adp->va_mem_base;
- adp->va_buffer_size = adp->va_mem_size;
- sc->sc_regt = sc->sc_memt;
- if (bus_space_subregion(sc->sc_regt, sc->sc_memh, MACH64_REG_OFF,
- MACH64_REG_SIZE, &sc->sc_regh) != 0) {
- device_printf(dev, "cannot allocate register resources\n");
- error = ENXIO;
- goto fail_memmap;
- }
-
- /*
- * Depending on the firmware version the VGA I/O and/or memory
- * resources of the Mach64 chips come up disabled. These will be
- * enabled by pci(4) when activating the resource in question but
- * this doesn't necessarily mean that the resource is valid.
- * Invalid resources seem to have in common that they start at
- * address 0. We don't allocate the VGA memory in this case in
- * order to avoid warnings in apb(4) and crashes when using this
- * invalid resources. X.Org is aware of this and doesn't use the
- * VGA memory resource in this case (but demands it if it's valid).
- */
- rid = PCIR_BAR(2);
- if (bus_get_resource_start(dev, SYS_RES_MEMORY, rid) != 0) {
- if ((sc->sc_vmemres = bus_alloc_resource_any(dev,
- SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) {
- device_printf(dev,
- "cannot allocate VGA memory resources\n");
- error = ENXIO;
- goto fail_memmap;
- }
- sc->sc_vmemt = rman_get_bustag(sc->sc_vmemres);
- sc->sc_vmemh = rman_get_bushandle(sc->sc_vmemres);
- sc->sc_vmem = rman_get_start(sc->sc_vmemres);
- vi->vi_registers = sc->sc_vmemh;
- vi->vi_registers_size = rman_get_size(sc->sc_vmemres);
- if (bus_space_map(sc->sc_vmemt, vi->vi_registers,
- vi->vi_registers_size, BUS_SPACE_MAP_LINEAR,
- &sc->sc_vmemh) != 0) {
- device_printf(dev,
- "cannot map VGA memory resources\n");
- error = ENXIO;
- goto fail_vmemres;
- }
- adp->va_registers =
- (vm_offset_t)rman_get_virtual(sc->sc_vmemres);
- adp->va_registers_size = vi->vi_registers_size;
- }
-
- if (!(sc->sc_flags & MACHFB_CONSOLE)) {
- if ((sw = vid_get_switch(MACHFB_DRIVER_NAME)) == NULL) {
- device_printf(dev, "cannot get video switch\n");
- error = ENODEV;
- goto fail_vmemmap;
- }
- /*
- * During device configuration we don't necessarily probe
- * the adapter which is the console first so we can't use
- * the device unit number for the video adapter unit. The
- * worst case would be that we use the video adapter unit
- * 0 twice. As it doesn't really matter which unit number
- * the corresponding video adapter has just use the next
- * unused one.
- */
- for (i = 0; i < devclass_get_maxunit(machfb_devclass); i++)
- if (vid_find_adapter(MACHFB_DRIVER_NAME, i) < 0)
- break;
- if ((error = sw->init(i, adp, 0)) != 0) {
- device_printf(dev, "cannot initialize adapter\n");
- goto fail_vmemmap;
- }
- }
-
- /*
- * Test whether the aperture is byte swapped or not, set
- * va_window and va_window_size as appropriate. Note that
- * the aperture could be mapped either big or little endian
- * independently of the endianness of the host so this has
- * to be a runtime test.
- */
- p32 = (uint32_t *)adp->va_buffer;
- u32 = *p32;
- p = (uint8_t *)adp->va_buffer;
- *p32 = 0x12345678;
- if (!(p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78)) {
- adp->va_window = adp->va_buffer + 0x800000;
- adp->va_window_size = adp->va_buffer_size - 0x800000;
- vi->vi_window = vi->vi_buffer + 0x800000;
- vi->vi_window_size = vi->vi_buffer_size - 0x800000;
- sc->sc_flags |= MACHFB_SWAP;
- } else {
- adp->va_window = adp->va_buffer;
- adp->va_window_size = adp->va_buffer_size;
- vi->vi_window = vi->vi_buffer;
- vi->vi_window_size = vi->vi_buffer_size;
- }
- *p32 = u32;
- adp->va_window_gran = adp->va_window_size;
-
- device_printf(dev,
- "%d MB aperture at %p %sswapped\n",
- (u_int)(adp->va_window_size / (1024 * 1024)),
- (void *)adp->va_window, (sc->sc_flags & MACHFB_SWAP) ?
- "" : "not ");
- device_printf(dev,
- "%ld KB %s %d.%d MHz, maximum RAMDAC clock %d MHz, %sDSP\n",
- (u_long)sc->sc_memsize, machfb_memtype_names[sc->sc_memtype],
- sc->sc_mem_freq / 1000, sc->sc_mem_freq % 1000,
- sc->sc_ramdac_freq / 1000,
- (sc->sc_flags & MACHFB_DSP) ? "" : "no ");
- device_printf(dev, "resolution %dx%d at %d bpp\n",
- sc->sc_width, sc->sc_height, sc->sc_depth);
-
- /*
- * Allocate one page for the mouse pointer image at the end of
- * the little endian aperture, right before the memory mapped
- * registers that might also reside there. Must be done after
- * sc_memsize was set and possibly adjusted to account for the
- * memory mapped registers.
- */
- sc->sc_curoff = (sc->sc_memsize * 1024) - PAGE_SIZE;
- sc->sc_memsize -= PAGE_SIZE / 1024;
- machfb_cursor_enable(sc, 0);
- /* Initialize with an all transparent image. */
- memset((void *)(adp->va_buffer + sc->sc_curoff), 0xaa, PAGE_SIZE);
-
- /*
- * Register a handler that performs some cosmetic surgery like
- * turning off the mouse pointer on halt in preparation for
- * handing the screen over to the OFW. Register another handler
- * that turns off the CRTC when resetting, otherwise the OFW
- * boot command issued by cpu_reset() just doesn't work.
- */
- EVENTHANDLER_REGISTER(shutdown_final, machfb_shutdown_final, sc,
- SHUTDOWN_PRI_DEFAULT);
- EVENTHANDLER_REGISTER(shutdown_reset, machfb_shutdown_reset, sc,
- SHUTDOWN_PRI_DEFAULT);
-
- return (0);
-
- fail_vmemmap:
- if (adp->va_registers != 0)
- bus_space_unmap(sc->sc_vmemt, sc->sc_vmemh,
- vi->vi_registers_size);
- fail_vmemres:
- if (sc->sc_vmemres != NULL)
- bus_release_resource(dev, SYS_RES_MEMORY,
- rman_get_rid(sc->sc_vmemres), sc->sc_vmemres);
- fail_memmap:
- bus_space_unmap(sc->sc_memt, sc->sc_memh, vi->vi_buffer_size);
- fail_memres:
- bus_release_resource(dev, SYS_RES_MEMORY,
- rman_get_rid(sc->sc_memres), sc->sc_memres);
-
- return (error);
-}
-
-static int
-machfb_pci_detach(device_t dev)
-{
-
- return (EINVAL);
-}
-
-/*
- * internal functions
- */
-static void
-machfb_cursor_enable(struct machfb_softc *sc, int onoff)
-{
-
- if (onoff)
- regw(sc, GEN_TEST_CNTL,
- regr(sc, GEN_TEST_CNTL) | HWCURSOR_ENABLE);
- else
- regw(sc, GEN_TEST_CNTL,
- regr(sc, GEN_TEST_CNTL) &~ HWCURSOR_ENABLE);
-}
-
-static int
-machfb_cursor_install(struct machfb_softc *sc)
-{
- uint16_t *p, v;
- uint8_t fg;
- int i, j;
-
- if (sc->sc_curoff == 0)
- return (ENODEV);
-
- machfb_cursor_enable(sc, 0);
- regw(sc, CUR_OFFSET, sc->sc_curoff >> 3);
- fg = SC_NORM_ATTR & 0xf;
- regw(sc, CUR_CLR0, machfb_default_cmap[fg].red << 24 |
- machfb_default_cmap[fg].green << 16 |
- machfb_default_cmap[fg].blue << 8);
- p = (uint16_t *)(sc->sc_va.va_buffer + sc->sc_curoff);
- for (i = 0; i < 64; i++) {
- for (j = 0; j < 8; j++) {
- v = machfb_mouse_pointer_lut[
- machfb_mouse_pointer_bits[i][j] >> 4] << 8 |
- machfb_mouse_pointer_lut[
- machfb_mouse_pointer_bits[i][j] & 0x0f];
- if (sc->sc_flags & MACHFB_SWAP)
- *(p++) = bswap16(v);
- else
- *(p++) = v;
- }
- }
-
- return (0);
-}
-
-static int
-machfb_get_memsize(struct machfb_softc *sc)
-{
- int tmp, memsize;
- const int mem_tab[] = {
- 512, 1024, 2048, 4096, 6144, 8192, 12288, 16384
- };
-
- tmp = regr(sc, MEM_CNTL);
-#ifdef MACHFB_DEBUG
- printf("memcntl=0x%08x\n", tmp);
-#endif
- if (sc->sc_flags & MACHFB_DSP) {
- tmp &= 0x0000000f;
- if (tmp < 8)
- memsize = (tmp + 1) * 512;
- else if (tmp < 12)
- memsize = (tmp - 3) * 1024;
- else
- memsize = (tmp - 7) * 2048;
- } else
- memsize = mem_tab[tmp & 0x07];
-
- return (memsize);
-}
-
-static void
-machfb_reset_engine(struct machfb_softc *sc)
-{
-
- /* Reset engine.*/
- regw(sc, GEN_TEST_CNTL, regr(sc, GEN_TEST_CNTL) & ~GUI_ENGINE_ENABLE);
-
- /* Enable engine. */
- regw(sc, GEN_TEST_CNTL, regr(sc, GEN_TEST_CNTL) | GUI_ENGINE_ENABLE);
-
- /*
- * Ensure engine is not locked up by clearing any FIFO or
- * host errors.
- */
- regw(sc, BUS_CNTL, regr(sc, BUS_CNTL) | BUS_HOST_ERR_ACK |
- BUS_FIFO_ERR_ACK);
-}
-
-static void
-machfb_init_engine(struct machfb_softc *sc)
-{
- uint32_t pitch_value;
-
- pitch_value = sc->sc_width;
-
- if (sc->sc_depth == 24)
- pitch_value *= 3;
-
- machfb_reset_engine(sc);
-
- wait_for_fifo(sc, 14);
-
- regw(sc, CONTEXT_MASK, 0xffffffff);
-
- regw(sc, DST_OFF_PITCH, (pitch_value / 8) << 22);
-
- regw(sc, DST_Y_X, 0);
- regw(sc, DST_HEIGHT, 0);
- regw(sc, DST_BRES_ERR, 0);
- regw(sc, DST_BRES_INC, 0);
- regw(sc, DST_BRES_DEC, 0);
-
- regw(sc, DST_CNTL, DST_LAST_PEL | DST_X_LEFT_TO_RIGHT |
- DST_Y_TOP_TO_BOTTOM);
-
- regw(sc, SRC_OFF_PITCH, (pitch_value / 8) << 22);
-
- regw(sc, SRC_Y_X, 0);
- regw(sc, SRC_HEIGHT1_WIDTH1, 1);
- regw(sc, SRC_Y_X_START, 0);
- regw(sc, SRC_HEIGHT2_WIDTH2, 1);
-
- regw(sc, SRC_CNTL, SRC_LINE_X_LEFT_TO_RIGHT);
-
- wait_for_fifo(sc, 13);
- regw(sc, HOST_CNTL, 0);
-
- regw(sc, PAT_REG0, 0);
- regw(sc, PAT_REG1, 0);
- regw(sc, PAT_CNTL, 0);
-
- regw(sc, SC_LEFT, 0);
- regw(sc, SC_TOP, 0);
- regw(sc, SC_BOTTOM, sc->sc_height - 1);
- regw(sc, SC_RIGHT, pitch_value - 1);
-
- regw(sc, DP_BKGD_CLR, 0);
- regw(sc, DP_FRGD_CLR, 0xffffffff);
- regw(sc, DP_WRITE_MASK, 0xffffffff);
- regw(sc, DP_MIX, (MIX_SRC << 16) | MIX_DST);
-
- regw(sc, DP_SRC, FRGD_SRC_FRGD_CLR);
-
- wait_for_fifo(sc, 3);
- regw(sc, CLR_CMP_CLR, 0);
- regw(sc, CLR_CMP_MASK, 0xffffffff);
- regw(sc, CLR_CMP_CNTL, 0);
-
- wait_for_fifo(sc, 2);
- switch (sc->sc_depth) {
- case 8:
- regw(sc, DP_PIX_WIDTH, HOST_8BPP | SRC_8BPP | DST_8BPP);
- regw(sc, DP_CHAIN_MASK, DP_CHAIN_8BPP);
- regw(sc, DAC_CNTL, regr(sc, DAC_CNTL) | DAC_8BIT_EN);
- break;
-#if 0
- case 32:
- regw(sc, DP_PIX_WIDTH, HOST_32BPP | SRC_32BPP | DST_32BPP);
- regw(sc, DP_CHAIN_MASK, DP_CHAIN_32BPP);
- regw(sc, DAC_CNTL, regr(sc, DAC_CNTL) | DAC_8BIT_EN);
- break;
-#endif
- }
-
- wait_for_fifo(sc, 2);
- regw(sc, CRTC_INT_CNTL, regr(sc, CRTC_INT_CNTL) & ~0x20);
- regw(sc, GUI_TRAJ_CNTL, DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM);
-
- wait_for_idle(sc);
-}
-
-#if 0
-static void
-machfb_adjust_frame(struct machfb_softc *sc, int x, int y)
-{
- int offset;
-
- offset = ((x + y * sc->sc_width) * (sc->sc_depth >> 3)) >> 3;
-
- regw(sc, CRTC_OFF_PITCH, (regr(sc, CRTC_OFF_PITCH) & 0xfff00000) |
- offset);
-}
-#endif
-
-static void
-machfb_shutdown_final(void *v)
-{
- struct machfb_softc *sc = v;
-
- machfb_cursor_enable(sc, 0);
- /*
- * In case this is the console set the cursor of the stdout
- * instance to the start of the last line so OFW output ends
- * up beneath what FreeBSD left on the screen.
- */
- if (sc->sc_flags & MACHFB_CONSOLE) {
- OF_interpret("stdout @ is my-self 0 to column#", 0);
- OF_interpret("stdout @ is my-self #lines 1 - to line#", 0);
- }
-}
-
-static void
-machfb_shutdown_reset(void *v)
-{
- struct machfb_softc *sc = v;
-
- machfb_blank_display(&sc->sc_va, V_DISPLAY_STAND_BY);
-}
diff --git a/sys/dev/fb/machfbreg.h b/sys/dev/fb/machfbreg.h
deleted file mode 100644
index 8990a4e3993a..000000000000
--- a/sys/dev/fb/machfbreg.h
+++ /dev/null
@@ -1,458 +0,0 @@
-/*-
- * Copyright 1992,1993,1994,1995,1996,1997 by Kevin E. Martin, Chapel Hill, North Carolina.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Kevin E. Martin not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. Kevin E. Martin
- * makes no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- * KEVIN E. MARTIN, RICKARD E. FAITH, AND TIAGO GONS DISCLAIM ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
- * AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
- * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
- * Modified for the Mach64 by Kevin E. Martin (martin@cs.unc.edu)
- *
- * from: NetBSD: machfbreg.h,v 1.1 2002/10/24 18:15:57 junyoung Exp
- *
- * $FreeBSD$
- */
-
-#ifndef _DEV_FB_MACHFB_H_
-#define _DEV_FB_MACHFB_H_
-
-/* NON-GUI MEMORY MAPPED Registers - expressed in BYTE offsets */
-
-#define CRTC_H_TOTAL_DISP 0x0000 /* Dword offset 00 */
-#define CRTC_H_SYNC_STRT_WID 0x0004 /* Dword offset 01 */
-#define CRTC_V_TOTAL_DISP 0x0008 /* Dword offset 02 */
-#define CRTC_V_SYNC_STRT_WID 0x000C /* Dword offset 03 */
-#define CRTC_VLINE_CRNT_VLINE 0x0010 /* Dword offset 04 */
-#define CRTC_OFF_PITCH 0x0014 /* Dword offset 05 */
-#define CRTC_INT_CNTL 0x0018 /* Dword offset 06 */
-#define CRTC_GEN_CNTL 0x001C /* Dword offset 07 */
-
-#define DSP_CONFIG 0x0020 /* Dword offset 08 */
-#define DSP_ON_OFF 0x0024 /* Dword offset 09 */
-
-#define SHARED_CNTL 0x0038 /* Dword offset 0E */
-
-#define OVR_CLR 0x0040 /* Dword offset 10 */
-#define OVR_WID_LEFT_RIGHT 0x0044 /* Dword offset 11 */
-#define OVR_WID_TOP_BOTTOM 0x0048 /* Dword offset 12 */
-
-#define CUR_CLR0 0x0060 /* Dword offset 18 */
-#define CUR_CLR1 0x0064 /* Dword offset 19 */
-#define CUR_OFFSET 0x0068 /* Dword offset 1A */
-#define CUR_HORZ_VERT_POSN 0x006C /* Dword offset 1B */
-#define CUR_HORZ_VERT_OFF 0x0070 /* Dword offset 1C */
-
-#define HW_DEBUG 0x007C /* Dword offset 1F */
-
-#define SCRATCH_REG0 0x0080 /* Dword offset 20 */
-#define SCRATCH_REG1 0x0084 /* Dword offset 21 */
-
-#define CLOCK_CNTL 0x0090 /* Dword offset 24 */
-
-#define BUS_CNTL 0x00A0 /* Dword offset 28 */
-
-#define LCD_INDEX 0x00A4 /* Dword offset 29 (LTPro) */
-#define LCD_DATA 0x00A8 /* Dword offset 2A (LTPro) */
-
-#define MEM_CNTL 0x00B0 /* Dword offset 2C */
-
-#define MEM_VGA_WP_SEL 0x00B4 /* Dword offset 2D */
-#define MEM_VGA_RP_SEL 0x00B8 /* Dword offset 2E */
-
-#define DAC_REGS 0x00C0 /* Dword offset 30 */
-#define DAC_WINDEX 0x00C0 /* Dword offset 30 */
-#define DAC_DATA 0x00C1 /* Dword offset 30 */
-#define DAC_MASK 0x00C2 /* Dword offset 30 */
-#define DAC_RINDEX 0x00C3 /* Dword offset 30 */
-#define DAC_CNTL 0x00C4 /* Dword offset 31 */
-
-#define HORZ_STRETCHING 0x00C8 /* Dword offset 32 (LT) */
-#define VERT_STRETCHING 0x00CC /* Dword offset 33 (LT) */
-
-#define GEN_TEST_CNTL 0x00D0 /* Dword offset 34 */
-
-#define LCD_GEN_CNTL 0x00D4 /* Dword offset 35 (LT) */
-#define POWER_MANAGEMENT 0x00D8 /* Dword offset 36 (LT) */
-
-#define CONFIG_CNTL 0x00DC /* Dword offset 37 (CT, ET, VT) */
-#define CONFIG_CHIP_ID 0x00E0 /* Dword offset 38 */
-#define CONFIG_STAT0 0x00E4 /* Dword offset 39 */
-#define CONFIG_STAT1 0x00E8 /* Dword offset 3A */
-
-
-/* GUI MEMORY MAPPED Registers */
-
-#define DST_OFF_PITCH 0x0100 /* Dword offset 40 */
-#define DST_X 0x0104 /* Dword offset 41 */
-#define DST_Y 0x0108 /* Dword offset 42 */
-#define DST_Y_X 0x010C /* Dword offset 43 */
-#define DST_WIDTH 0x0110 /* Dword offset 44 */
-#define DST_HEIGHT 0x0114 /* Dword offset 45 */
-#define DST_HEIGHT_WIDTH 0x0118 /* Dword offset 46 */
-#define DST_X_WIDTH 0x011C /* Dword offset 47 */
-#define DST_BRES_LNTH 0x0120 /* Dword offset 48 */
-#define DST_BRES_ERR 0x0124 /* Dword offset 49 */
-#define DST_BRES_INC 0x0128 /* Dword offset 4A */
-#define DST_BRES_DEC 0x012C /* Dword offset 4B */
-#define DST_CNTL 0x0130 /* Dword offset 4C */
-
-#define SRC_OFF_PITCH 0x0180 /* Dword offset 60 */
-#define SRC_X 0x0184 /* Dword offset 61 */
-#define SRC_Y 0x0188 /* Dword offset 62 */
-#define SRC_Y_X 0x018C /* Dword offset 63 */
-#define SRC_WIDTH1 0x0190 /* Dword offset 64 */
-#define SRC_HEIGHT1 0x0194 /* Dword offset 65 */
-#define SRC_HEIGHT1_WIDTH1 0x0198 /* Dword offset 66 */
-#define SRC_X_START 0x019C /* Dword offset 67 */
-#define SRC_Y_START 0x01A0 /* Dword offset 68 */
-#define SRC_Y_X_START 0x01A4 /* Dword offset 69 */
-#define SRC_WIDTH2 0x01A8 /* Dword offset 6A */
-#define SRC_HEIGHT2 0x01AC /* Dword offset 6B */
-#define SRC_HEIGHT2_WIDTH2 0x01B0 /* Dword offset 6C */
-#define SRC_CNTL 0x01B4 /* Dword offset 6D */
-
-#define HOST_DATA0 0x0200 /* Dword offset 80 */
-#define HOST_DATA1 0x0204 /* Dword offset 81 */
-#define HOST_DATA2 0x0208 /* Dword offset 82 */
-#define HOST_DATA3 0x020C /* Dword offset 83 */
-#define HOST_DATA4 0x0210 /* Dword offset 84 */
-#define HOST_DATA5 0x0214 /* Dword offset 85 */
-#define HOST_DATA6 0x0218 /* Dword offset 86 */
-#define HOST_DATA7 0x021C /* Dword offset 87 */
-#define HOST_DATA8 0x0220 /* Dword offset 88 */
-#define HOST_DATA9 0x0224 /* Dword offset 89 */
-#define HOST_DATAA 0x0228 /* Dword offset 8A */
-#define HOST_DATAB 0x022C /* Dword offset 8B */
-#define HOST_DATAC 0x0230 /* Dword offset 8C */
-#define HOST_DATAD 0x0234 /* Dword offset 8D */
-#define HOST_DATAE 0x0238 /* Dword offset 8E */
-#define HOST_DATAF 0x023C /* Dword offset 8F */
-#define HOST_CNTL 0x0240 /* Dword offset 90 */
-
-#define PAT_REG0 0x0280 /* Dword offset A0 */
-#define PAT_REG1 0x0284 /* Dword offset A1 */
-#define PAT_CNTL 0x0288 /* Dword offset A2 */
-
-#define SC_LEFT 0x02A0 /* Dword offset A8 */
-#define SC_RIGHT 0x02A4 /* Dword offset A9 */
-#define SC_LEFT_RIGHT 0x02A8 /* Dword offset AA */
-#define SC_TOP 0x02AC /* Dword offset AB */
-#define SC_BOTTOM 0x02B0 /* Dword offset AC */
-#define SC_TOP_BOTTOM 0x02B4 /* Dword offset AD */
-
-#define DP_BKGD_CLR 0x02C0 /* Dword offset B0 */
-#define DP_FRGD_CLR 0x02C4 /* Dword offset B1 */
-#define DP_WRITE_MASK 0x02C8 /* Dword offset B2 */
-#define DP_CHAIN_MASK 0x02CC /* Dword offset B3 */
-#define DP_PIX_WIDTH 0x02D0 /* Dword offset B4 */
-#define DP_MIX 0x02D4 /* Dword offset B5 */
-#define DP_SRC 0x02D8 /* Dword offset B6 */
-
-#define CLR_CMP_CLR 0x0300 /* Dword offset C0 */
-#define CLR_CMP_MASK 0x0304 /* Dword offset C1 */
-#define CLR_CMP_CNTL 0x0308 /* Dword offset C2 */
-
-#define FIFO_STAT 0x0310 /* Dword offset C4 */
-
-#define CONTEXT_MASK 0x0320 /* Dword offset C8 */
-#define CONTEXT_LOAD_CNTL 0x032C /* Dword offset CB */
-
-#define GUI_TRAJ_CNTL 0x0330 /* Dword offset CC */
-#define GUI_STAT 0x0338 /* Dword offset CE */
-
-
-/* CRTC control values */
-
-#define CRTC_HSYNC_NEG 0x00200000
-#define CRTC_VSYNC_NEG 0x00200000
-
-#define CRTC_DBL_SCAN_EN 0x00000001
-#define CRTC_INTERLACE_EN 0x00000002
-#define CRTC_HSYNC_DIS 0x00000004
-#define CRTC_VSYNC_DIS 0x00000008
-#define CRTC_CSYNC_EN 0x00000010
-#define CRTC_PIX_BY_2_EN 0x00000020
-#define CRTC_DISPLAY_DIS 0x00000040
-#define CRTC_VGA_XOVERSCAN 0x00000080
-
-#define CRTC_PIX_WIDTH 0x00000700
-#define CRTC_PIX_WIDTH_4BPP 0x00000100
-#define CRTC_PIX_WIDTH_8BPP 0x00000200
-#define CRTC_PIX_WIDTH_15BPP 0x00000300
-#define CRTC_PIX_WIDTH_16BPP 0x00000400
-#define CRTC_PIX_WIDTH_24BPP 0x00000500
-#define CRTC_PIX_WIDTH_32BPP 0x00000600
-
-#define CRTC_BYTE_PIX_ORDER 0x00000800
-#define CRTC_PIX_ORDER_MSN_LSN 0x00000000
-#define CRTC_PIX_ORDER_LSN_MSN 0x00000800
-
-#define CRTC_FIFO_LWM 0x000f0000
-#define CRTC_LOCK_REGS 0x00400000
-#define CRTC_EXT_DISP_EN 0x01000000
-#define CRTC_EN 0x02000000
-#define CRTC_DISP_REQ_EN 0x04000000
-#define CRTC_VGA_LINEAR 0x08000000
-#define CRTC_VSYNC_FALL_EDGE 0x10000000
-#define CRTC_VGA_TEXT_132 0x20000000
-#define CRTC_CNT_EN 0x40000000
-#define CRTC_CUR_B_TEST 0x80000000
-
-#define CRTC_CRNT_VLINE 0x07f00000
-#define CRTC_VBLANK 0x00000001
-
-/* DAC control values */
-
-#define DAC_EXT_SEL_RS2 0x01
-#define DAC_EXT_SEL_RS3 0x02
-#define DAC_8BIT_EN 0x00000100
-#define DAC_PIX_DLY_MASK 0x00000600
-#define DAC_PIX_DLY_0NS 0x00000000
-#define DAC_PIX_DLY_2NS 0x00000200
-#define DAC_PIX_DLY_4NS 0x00000400
-#define DAC_BLANK_ADJ_MASK 0x00001800
-#define DAC_BLANK_ADJ_0 0x00000000
-#define DAC_BLANK_ADJ_1 0x00000800
-#define DAC_BLANK_ADJ_2 0x00001000
-
-
-/* Mix control values */
-
-#define MIX_NOT_DST 0x0000
-#define MIX_0 0x0001
-#define MIX_1 0x0002
-#define MIX_DST 0x0003
-#define MIX_NOT_SRC 0x0004
-#define MIX_XOR 0x0005
-#define MIX_XNOR 0x0006
-#define MIX_SRC 0x0007
-#define MIX_NAND 0x0008
-#define MIX_NOT_SRC_OR_DST 0x0009
-#define MIX_SRC_OR_NOT_DST 0x000a
-#define MIX_OR 0x000b
-#define MIX_AND 0x000c
-#define MIX_SRC_AND_NOT_DST 0x000d
-#define MIX_NOT_SRC_AND_DST 0x000e
-#define MIX_NOR 0x000f
-
-/* Maximum engine dimensions */
-#define ENGINE_MIN_X 0
-#define ENGINE_MIN_Y 0
-#define ENGINE_MAX_X 4095
-#define ENGINE_MAX_Y 16383
-
-/* Mach64 engine bit constants - these are typically ORed together */
-
-/* HW_DEBUG register constants */
-/* For RagePro only... */
-#define AUTO_FF_DIS 0x000001000
-#define AUTO_BLKWRT_DIS 0x000002000
-
-/* BUS_CNTL register constants */
-#define BUS_FIFO_ERR_ACK 0x00200000
-#define BUS_HOST_ERR_ACK 0x00800000
-#define BUS_APER_REG_DIS 0x00000010
-
-/* GEN_TEST_CNTL register constants */
-#define GEN_OVR_OUTPUT_EN 0x20
-#define HWCURSOR_ENABLE 0x80
-#define GUI_ENGINE_ENABLE 0x100
-#define BLOCK_WRITE_ENABLE 0x200
-
-/* DSP_CONFIG register constants */
-#define DSP_XCLKS_PER_QW 0x00003fff
-#define DSP_LOOP_LATENCY 0x000f0000
-#define DSP_PRECISION 0x00700000
-
-/* DSP_ON_OFF register constants */
-#define DSP_OFF 0x000007ff
-#define DSP_ON 0x07ff0000
-
-/* SHARED_CNTL register constants */
-#define CTD_FIFO5 0x01000000
-
-/* CLOCK_CNTL register constants */
-#define CLOCK_SEL 0x0f
-#define CLOCK_DIV 0x30
-#define CLOCK_DIV1 0x00
-#define CLOCK_DIV2 0x10
-#define CLOCK_DIV4 0x20
-#define CLOCK_STROBE 0x40
-#define PLL_WR_EN 0x02
-
-/* PLL registers */
-#define PLL_MACRO_CNTL 0x01
-#define PLL_REF_DIV 0x02
-#define PLL_GEN_CNTL 0x03
-#define MCLK_FB_DIV 0x04
-#define PLL_VCLK_CNTL 0x05
-#define VCLK_POST_DIV 0x06
-#define VCLK0_FB_DIV 0x07
-#define VCLK1_FB_DIV 0x08
-#define VCLK2_FB_DIV 0x09
-#define VCLK3_FB_DIV 0x0A
-#define PLL_XCLK_CNTL 0x0B
-#define PLL_TEST_CTRL 0x0E
-#define PLL_TEST_COUNT 0x0F
-
-/* Memory types for CT, ET, VT, GT */
-#define DRAM 1
-#define EDO_DRAM 2
-#define PSEUDO_EDO 3
-#define SDRAM 4
-#define SGRAM 5
-#define SGRAM32 6
-
-#define DAC_INTERNAL 0x00
-#define DAC_IBMRGB514 0x01
-#define DAC_ATI68875 0x02
-#define DAC_TVP3026_A 0x72
-#define DAC_BT476 0x03
-#define DAC_BT481 0x04
-#define DAC_ATT20C491 0x14
-#define DAC_SC15026 0x24
-#define DAC_MU9C1880 0x34
-#define DAC_IMSG174 0x44
-#define DAC_ATI68860_B 0x05
-#define DAC_ATI68860_C 0x15
-#define DAC_TVP3026_B 0x75
-#define DAC_STG1700 0x06
-#define DAC_ATT498 0x16
-#define DAC_STG1702 0x07
-#define DAC_SC15021 0x17
-#define DAC_ATT21C498 0x27
-#define DAC_STG1703 0x37
-#define DAC_CH8398 0x47
-#define DAC_ATT20C408 0x57
-
-#define CLK_ATI18818_0 0
-#define CLK_ATI18818_1 1
-#define CLK_STG1703 2
-#define CLK_CH8398 3
-#define CLK_INTERNAL 4
-#define CLK_ATT20C408 5
-#define CLK_IBMRGB514 6
-
-/* DST_CNTL register constants */
-#define DST_X_RIGHT_TO_LEFT 0
-#define DST_X_LEFT_TO_RIGHT 1
-#define DST_Y_BOTTOM_TO_TOP 0
-#define DST_Y_TOP_TO_BOTTOM 2
-#define DST_X_MAJOR 0
-#define DST_Y_MAJOR 4
-#define DST_X_TILE 8
-#define DST_Y_TILE 0x10
-#define DST_LAST_PEL 0x20
-#define DST_POLYGON_ENABLE 0x40
-#define DST_24_ROTATION_ENABLE 0x80
-
-/* SRC_CNTL register constants */
-#define SRC_PATTERN_ENABLE 1
-#define SRC_ROTATION_ENABLE 2
-#define SRC_LINEAR_ENABLE 4
-#define SRC_BYTE_ALIGN 8
-#define SRC_LINE_X_RIGHT_TO_LEFT 0
-#define SRC_LINE_X_LEFT_TO_RIGHT 0x10
-
-/* HOST_CNTL register constants */
-#define HOST_BYTE_ALIGN 1
-
-/* DP_CHAIN_MASK register constants */
-#define DP_CHAIN_4BPP 0x8888
-#define DP_CHAIN_7BPP 0xD2D2
-#define DP_CHAIN_8BPP 0x8080
-#define DP_CHAIN_8BPP_RGB 0x9292
-#define DP_CHAIN_15BPP 0x4210
-#define DP_CHAIN_16BPP 0x8410
-#define DP_CHAIN_24BPP 0x8080
-#define DP_CHAIN_32BPP 0x8080
-
-/* DP_PIX_WIDTH register constants */
-#define DST_1BPP 0
-#define DST_4BPP 1
-#define DST_8BPP 2
-#define DST_15BPP 3
-#define DST_16BPP 4
-#define DST_32BPP 6
-#define SRC_1BPP 0
-#define SRC_4BPP 0x100
-#define SRC_8BPP 0x200
-#define SRC_15BPP 0x300
-#define SRC_16BPP 0x400
-#define SRC_32BPP 0x600
-#define HOST_1BPP 0
-#define HOST_4BPP 0x10000
-#define HOST_8BPP 0x20000
-#define HOST_15BPP 0x30000
-#define HOST_16BPP 0x40000
-#define HOST_32BPP 0x60000
-#define BYTE_ORDER_MSB_TO_LSB 0
-#define BYTE_ORDER_LSB_TO_MSB 0x1000000
-
-/* DP_SRC register constants */
-#define BKGD_SRC_BKGD_CLR 0
-#define BKGD_SRC_FRGD_CLR 1
-#define BKGD_SRC_HOST 2
-#define BKGD_SRC_BLIT 3
-#define BKGD_SRC_PATTERN 4
-#define FRGD_SRC_BKGD_CLR 0
-#define FRGD_SRC_FRGD_CLR 0x100
-#define FRGD_SRC_HOST 0x200
-#define FRGD_SRC_BLIT 0x300
-#define FRGD_SRC_PATTERN 0x400
-#define MONO_SRC_ONE 0
-#define MONO_SRC_PATTERN 0x10000
-#define MONO_SRC_HOST 0x20000
-#define MONO_SRC_BLIT 0x30000
-
-/* PCI IDs */
-#define ATI_VENDOR 0x1002
-#define ATI_MACH64_CT 0x4354 /* Mach64 CT */
-#define ATI_RAGE_PRO_AGP 0x4742 /* 3D Rage Pro (AGP) */
-#define ATI_RAGE_PRO_AGP1X 0x4744 /* 3D Rage Pro (AGP 1x) */
-#define ATI_RAGE_PRO_PCI_B 0x4749 /* 3D Rage Pro Turbo */
-#define ATI_RAGE_XC_PCI66 0x474c /* Rage XC (PCI66) */
-#define ATI_RAGE_XL_AGP 0x474d /* Rage XL (AGP) */
-#define ATI_RAGE_XC_AGP 0x474e /* Rage XC (AGP) */
-#define ATI_RAGE_XL_PCI66 0x474f /* Rage XL (PCI66) */
-#define ATI_RAGE_PRO_PCI_P 0x4750 /* 3D Rage Pro */
-#define ATI_RAGE_PRO_PCI_L 0x4751 /* 3D Rage Pro (limited 3D) */
-#define ATI_RAGE_XL_PCI 0x4752 /* Rage XL */
-#define ATI_RAGE_XC_PCI 0x4753 /* Rage XC */
-#define ATI_RAGE_II 0x4754 /* 3D Rage I/II */
-#define ATI_RAGE_IIP 0x4755 /* 3D Rage II+ */
-#define ATI_RAGE_IIC_PCI 0x4756 /* 3D Rage IIC */
-#define ATI_RAGE_IIC_AGP_B 0x4757 /* 3D Rage IIC (AGP) */
-#define ATI_RAGE_IIC_AGP_P 0x475a /* 3D Rage IIC (AGP) */
-#define ATI_RAGE_LT_PRO_AGP 0x4c42 /* 3D Rage LT Pro (AGP 133MHz) */
-#define ATI_RAGE_MOB_M3_PCI 0x4c45 /* Rage Mobility M3 */
-#define ATI_RAGE_MOB_M3_AGP 0x4c46 /* Rage Mobility M3 (AGP) */
-#define ATI_RAGE_LT 0x4c47 /* 3D Rage LT */
-#define ATI_RAGE_LT_PRO_PCI 0x4c49 /* 3D Rage LT Pro */
-#define ATI_RAGE_MOBILITY 0x4c4d /* Rage Mobility */
-#define ATI_RAGE_L_MOBILITY 0x4c4e /* Rage L Mobility */
-#define ATI_RAGE_LT_PRO 0x4c50 /* 3D Rage LT Pro */
-#define ATI_RAGE_LT_PRO2 0x4c51 /* 3D Rage LT Pro */
-#define ATI_RAGE_MOB_M1_PCI 0x4c52 /* Rage Mobility M1 (PCI) */
-#define ATI_RAGE_L_MOB_M1_PCI 0x4c53 /* Rage L Mobility (PCI) */
-#define ATI_MACH64_VT 0x5654 /* Mach64 VT */
-#define ATI_MACH64_VTB 0x5655 /* Mach64 VTB */
-#define ATI_MACH64_VT4 0x5656 /* Mach64 VT4 */
-
-#endif /* !_DEV_FB_MACHFB_H_ */