Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Redo attachment to support proper cnattach.



details:   https://anonhg.NetBSD.org/src/rev/6c78440d63b4
branches:  trunk
changeset: 546960:6c78440d63b4
user:      uwe <uwe%NetBSD.org@localhost>
date:      Sat May 10 01:51:56 2003 +0000

description:
Redo attachment to support proper cnattach.
wscons on netwinder almost works now.

diffstat:

 sys/dev/ic/igsfb.c         |  674 +++++++++++++++++++++++---------------------
 sys/dev/ic/igsfb_subr.c    |  166 ++++------
 sys/dev/ic/igsfbvar.h      |   95 +++--
 sys/dev/pci/igsfb_pci.c    |  242 ++++++++++-----
 sys/dev/pci/igsfb_pcivar.h |   40 ++
 5 files changed, 680 insertions(+), 537 deletions(-)

diffs (truncated from 1933 to 300 lines):

diff -r f72dcb742e29 -r 6c78440d63b4 sys/dev/ic/igsfb.c
--- a/sys/dev/ic/igsfb.c        Sat May 10 00:06:09 2003 +0000
+++ b/sys/dev/ic/igsfb.c        Sat May 10 01:51:56 2003 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: igsfb.c,v 1.7 2003/01/12 21:37:59 uwe Exp $ */
+/*     $NetBSD: igsfb.c,v 1.8 2003/05/10 01:51:56 uwe Exp $ */
 
 /*
- * Copyright (c) 2002 Valeriy E. Ushakov
+ * Copyright (c) 2002, 2003 Valeriy E. Ushakov
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,10 +29,9 @@
 
 /*
  * Integraphics Systems IGA 168x and CyberPro series.
- * Only tested on IGA 1682 in Krups JavaStation-NC.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.7 2003/01/12 21:37:59 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.8 2003/05/10 01:51:56 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -46,14 +45,16 @@
 #include <machine/bus.h>
 
 #include <dev/wscons/wsdisplayvar.h>
-#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsconsio.h>
 #include <dev/wsfont/wsfont.h>
-#include <dev/wscons/wsconsio.h>
+#include <dev/rasops/rasops.h>
 
 #include <dev/ic/igsfbreg.h>
 #include <dev/ic/igsfbvar.h>
 
 
+struct igsfb_devconfig igsfb_console_dc;
+
 /*
  * wsscreen
  */
@@ -103,74 +104,131 @@
 /*
  * internal functions
  */
-static void    igsfb_common_init(struct igsfb_softc *);
-static void    igsfb_init_bit_tables(struct igsfb_softc *);
-static void    igsfb_blank_screen(struct igsfb_softc *, int);
-static int     igsfb_get_cmap(struct igsfb_softc *, struct wsdisplay_cmap *);
-static int     igsfb_set_cmap(struct igsfb_softc *, struct wsdisplay_cmap *);
-static void    igsfb_update_cmap(struct igsfb_softc *sc, u_int, u_int);
-static void    igsfb_set_curpos(struct igsfb_softc *,
+static int     igsfb_init_video(struct igsfb_devconfig *);
+static void    igsfb_init_cmap(struct igsfb_devconfig *);
+static u_int16_t igsfb_spread_bits_8(u_int8_t);
+static void    igsfb_init_bit_tables(struct igsfb_devconfig *);
+static void    igsfb_init_wsdisplay(struct igsfb_devconfig *);
+
+static void    igsfb_blank_screen(struct igsfb_devconfig *, int);
+static int     igsfb_get_cmap(struct igsfb_devconfig *,
+                              struct wsdisplay_cmap *);
+static int     igsfb_set_cmap(struct igsfb_devconfig *,
+                              struct wsdisplay_cmap *);
+static void    igsfb_update_cmap(struct igsfb_devconfig *, u_int, u_int);
+static void    igsfb_set_curpos(struct igsfb_devconfig *,
                                 struct wsdisplay_curpos *);
-static void    igsfb_update_curpos(struct igsfb_softc *);
-static int     igsfb_get_cursor(struct igsfb_softc *,
+static void    igsfb_update_curpos(struct igsfb_devconfig *);
+static int     igsfb_get_cursor(struct igsfb_devconfig *,
+                                struct wsdisplay_cursor *);
+static int     igsfb_set_cursor(struct igsfb_devconfig *,
                                 struct wsdisplay_cursor *);
-static int     igsfb_set_cursor(struct igsfb_softc *,
-                                struct wsdisplay_cursor *);
-static void    igsfb_update_cursor(struct igsfb_softc *, u_int);
-static void    igsfb_convert_cursor_data(struct igsfb_softc *, u_int, u_int);
+static void    igsfb_update_cursor(struct igsfb_devconfig *, u_int);
+static void    igsfb_convert_cursor_data(struct igsfb_devconfig *,
+                                         u_int, u_int);
+
+
+int
+igsfb_cnattach_subr(dc)
+       struct igsfb_devconfig *dc;
+{
+       struct rasops_info *ri;
+       long defattr;
+
+       KASSERT(dc == &igsfb_console_dc);
 
-/*
- * bit expanders
- */
-static u_int16_t igsfb_spread_bits_8(u_int8_t);
+       igsfb_init_video(dc);
+       igsfb_init_wsdisplay(dc);
 
-static struct igs_bittab *igsfb_bittab = NULL;
-static struct igs_bittab *igsfb_bittab_bswap = NULL;
+       ri = &dc->dc_ri;
+       (*ri->ri_ops.allocattr)(ri,
+                               WSCOL_BLACK, /* fg */
+                               WSCOL_BLACK, /* bg */
+                               0,           /* wsattrs */
+                               &defattr);
+
+       wsdisplay_cnattach(&igsfb_stdscreen,
+                          ri,   /* emulcookie */
+                          0, 0, /* cursor position */
+                          defattr);
+       return (0);
+}
 
 
 /*
  * Finish off the attach.  Bus specific attach method should have
- * enabled io and memory accesses and mapped io and cop registers.
+ * enabled io and memory accesses and mapped io (and cop?) registers.
  */
 void
-igsfb_common_attach(sc, isconsole)
+igsfb_attach_subr(sc, isconsole)
        struct igsfb_softc *sc;
        int isconsole;
 {
+       struct igsfb_devconfig *dc = sc->sc_dc;
+       struct wsemuldisplaydev_attach_args waa;
+
+       KASSERT(dc != NULL);
+
+       if (!isconsole) {
+               igsfb_init_video(dc);
+               igsfb_init_wsdisplay(dc);
+       }
+
+       printf("%s: %dMB, %s%dx%d, %dbpp\n",
+              sc->sc_dev.dv_xname,
+              (u_int32_t)(dc->dc_vmemsz >> 20),
+              (dc->dc_hwflags & IGSFB_HW_BSWAP)
+                  ? (dc->dc_hwflags & IGSFB_HW_BE_SELECT)
+                      ? "hardware bswap, " : "software bswap, "
+                  : "",
+              dc->dc_width, dc->dc_height, dc->dc_depth);
+
+       /* attach wsdisplay */
+       waa.console = isconsole;
+       waa.scrdata = &igsfb_screenlist;
+       waa.accessops = &igsfb_accessops;
+       waa.accesscookie = dc;
+
+       config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
+}
+
+
+static int
+igsfb_init_video(dc)
+       struct igsfb_devconfig *dc;
+{
        bus_space_handle_t tmph;
        u_int8_t *p;
        int need_bswap;
-       char *bswap_msg;
-       bus_addr_t fbaddr;
-       bus_addr_t craddr;
+       bus_addr_t fbaddr, craddr;
        off_t croffset;
-       struct rasops_info *ri;
-       struct wsemuldisplaydev_attach_args waa;
        u_int8_t busctl, curctl;
 
-       busctl = igs_ext_read(sc->sc_iot, sc->sc_ioh, IGS_EXT_BUS_CTL);
+       /* Total amount of video memory. */
+       busctl = igs_ext_read(dc->dc_iot, dc->dc_ioh, IGS_EXT_BUS_CTL);
        if (busctl & 0x2)
-               sc->sc_vmemsz = 4 << 20;
+               dc->dc_vmemsz = 4;
        else if (busctl & 0x1)
-               sc->sc_vmemsz = 2 << 20;
+               dc->dc_vmemsz = 2;
        else
-               sc->sc_vmemsz = 1 << 20;
+               dc->dc_vmemsz = 1;
+       dc->dc_vmemsz <<= 20;   /* megabytes -> bytes */
 
        /*
-        * Check for endianness mismatch by writing a word at the end
-        * of video memory (off-screen) and reading it back byte-by-byte.
+        * Check for endianness mismatch by writing a word at the end of
+        * the video memory (off-screen) and reading it back byte-by-byte.
         */
-       if (bus_space_map(sc->sc_memt,
-                         sc->sc_memaddr + sc->sc_vmemsz - sizeof(u_int32_t),
+       if (bus_space_map(dc->dc_memt,
+                         dc->dc_memaddr + dc->dc_vmemsz - sizeof(u_int32_t),
                          sizeof(u_int32_t),
-                         sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
+                         dc->dc_memflags | BUS_SPACE_MAP_LINEAR,
                          &tmph) != 0)
        {
                printf("unable to map video memory for endianness test\n");
-               return;
+               return (1);
        }
 
-       p = bus_space_vaddr(sc->sc_memt, tmph);
+       p = bus_space_vaddr(dc->dc_memt, tmph);
 #if BYTE_ORDER == BIG_ENDIAN
        *((u_int32_t *)p) = 0x12345678;
 #else
@@ -181,112 +239,183 @@
        else
                need_bswap = 1;
 
-       bus_space_unmap(sc->sc_memt, tmph, sizeof(u_int32_t));
+       bus_space_unmap(dc->dc_memt, tmph, sizeof(u_int32_t));
 
        /*
         * On CyberPro we can use magic bswap bit in linear address.
         */
-       fbaddr = sc->sc_memaddr;
-       if (need_bswap)
-               if (sc->sc_is2k) {
+       fbaddr = dc->dc_memaddr;
+       if (need_bswap) {
+               dc->dc_hwflags |= IGSFB_HW_BSWAP;
+               if (dc->dc_id >= 0x2000) {
+                       dc->dc_hwflags |= IGSFB_HW_BE_SELECT;
                        fbaddr |= IGS_MEM_BE_SELECT;
-                       bswap_msg = ", hw bswap";
-               } else {
-                       sc->sc_hwflags |= IGSFB_HW_BSWAP;
-                       bswap_msg = ", sw bswap"; /* sic! */
                }
-       else
-               bswap_msg = "";
-
-       /*
-        * Don't map in all N megs, just the amount we need for wsscreen
-        */
-       sc->sc_fbsz = 1024 * 768; /* XXX: 8bpp specific */
-       if (bus_space_map(sc->sc_memt, fbaddr, sc->sc_fbsz,
-                         sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
-                         &sc->sc_fbh) != 0)
-       {
-               bus_space_unmap(sc->sc_iot, sc->sc_ioh, IGS_REG_SIZE);
-               printf("unable to map framebuffer\n");
-               return;
        }
 
        /*
-        * 1Kb for cursor sprite data at the very end of video memory
+        * XXX: TODO: make it possible to select the desired video mode.
+        * For now - hardcode to 1024x768/8bpp.  This is what Krups OFW uses.
+        */
+       igsfb_hw_setup(dc);
+
+       dc->dc_width = 1024;
+       dc->dc_height = 768;
+       dc->dc_depth = 8;
+
+       /*
+        * Don't map in all N megs, just the amount we need for the wsscreen.
         */
-       croffset = sc->sc_vmemsz - IGS_CURSOR_DATA_SIZE;
+       dc->dc_fbsz = dc->dc_width * dc->dc_height; /* XXX: 8bpp specific */
+       if (bus_space_map(dc->dc_memt, fbaddr, dc->dc_fbsz,
+                         dc->dc_memflags | BUS_SPACE_MAP_LINEAR,
+                         &dc->dc_fbh) != 0)
+       {
+               bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE);
+               printf("unable to map framebuffer\n");
+               return (1);
+       }
+
+       igsfb_init_cmap(dc);
+
+       /*
+        * 1KB for cursor sprite data at the very end of the video memory.
+        */
+       croffset = dc->dc_vmemsz - IGS_CURSOR_DATA_SIZE;
        craddr = fbaddr + croffset;
-       if (bus_space_map(sc->sc_memt, craddr, IGS_CURSOR_DATA_SIZE,
-                         sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
-                         &sc->sc_crh) != 0)
+       if (bus_space_map(dc->dc_memt, craddr, IGS_CURSOR_DATA_SIZE,
+                         dc->dc_memflags | BUS_SPACE_MAP_LINEAR,
+                         &dc->dc_crh) != 0)
        {
-               bus_space_unmap(sc->sc_iot, sc->sc_ioh, IGS_REG_SIZE);
-               bus_space_unmap(sc->sc_memt, sc->sc_fbh, sc->sc_fbsz);
+               bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE);
+               bus_space_unmap(dc->dc_memt, dc->dc_fbh, dc->dc_fbsz);
                printf("unable to map cursor sprite region\n");
-               return;
+               return (1);
        }



Home | Main Index | Thread Index | Old Index