Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci the framebuffer part lives on in voyager/voyager...



details:   https://anonhg.NetBSD.org/src/rev/2b426d4190c1
branches:  trunk
changeset: 769110:2b426d4190c1
user:      macallan <macallan%NetBSD.org@localhost>
date:      Wed Aug 31 16:48:29 2011 +0000

description:
the framebuffer part lives on in voyager/voyagerfb.c

diffstat:

 sys/dev/pci/voyagerfb.c |  836 ------------------------------------------------
 1 files changed, 0 insertions(+), 836 deletions(-)

diffs (truncated from 840 to 300 lines):

diff -r a256ad547636 -r 2b426d4190c1 sys/dev/pci/voyagerfb.c
--- a/sys/dev/pci/voyagerfb.c   Wed Aug 31 16:47:31 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,836 +0,0 @@
-/*     $NetBSD: voyagerfb.c,v 1.9 2011/08/30 02:53:01 macallan Exp $   */
-
-/*
- * Copyright (c) 2009 Michael Lorenz
- * 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 ``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.
- */
-
-/*
- * A console driver for Silicon Motion SM502 / Voyager GX  graphics controllers
- * tested on GDIUM only so far
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.9 2011/08/30 02:53:01 macallan Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/lwp.h>
-#include <sys/kauth.h>
-
-#include <dev/videomode/videomode.h>
-
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcidevs.h>
-#include <dev/pci/pciio.h>
-#include <dev/ic/sm502reg.h>
-
-#include <dev/wscons/wsdisplayvar.h>
-#include <dev/wscons/wsconsio.h>
-#include <dev/wsfont/wsfont.h>
-#include <dev/rasops/rasops.h>
-#include <dev/wscons/wsdisplay_vconsvar.h>
-#include <dev/pci/wsdisplay_pci.h>
-
-#include <dev/i2c/i2cvar.h>
-
-struct voyagerfb_softc {
-       device_t sc_dev;
-
-       pci_chipset_tag_t sc_pc;
-       pcitag_t sc_pcitag;
-
-       bus_space_tag_t sc_memt;
-       bus_space_tag_t sc_iot;
-
-       bus_space_handle_t sc_fbh;
-       bus_space_handle_t sc_regh;
-       bus_addr_t sc_fb, sc_reg;
-       bus_size_t sc_fbsize, sc_regsize;
-
-       int sc_width, sc_height, sc_depth, sc_stride;
-       int sc_locked;
-       void *sc_fbaddr;
-       struct vcons_screen sc_console_screen;
-       struct wsscreen_descr sc_defaultscreen_descr;
-       const struct wsscreen_descr *sc_screens[1];
-       struct wsscreen_list sc_screenlist;
-       struct vcons_data vd;
-       uint8_t *sc_dataport;
-       int sc_mode;
-       u_char sc_cmap_red[256];
-       u_char sc_cmap_green[256];
-       u_char sc_cmap_blue[256];
-};
-
-static int     voyagerfb_match(device_t, cfdata_t, void *);
-static void    voyagerfb_attach(device_t, device_t, void *);
-
-CFATTACH_DECL_NEW(voyagerfb, sizeof(struct voyagerfb_softc),
-    voyagerfb_match, voyagerfb_attach, NULL, NULL);
-
-extern const u_char rasops_cmap[768];
-
-static int     voyagerfb_ioctl(void *, void *, u_long, void *, int,
-                            struct lwp *);
-static paddr_t voyagerfb_mmap(void *, void *, off_t, int);
-static void    voyagerfb_init_screen(void *, struct vcons_screen *, int,
-                long *);
-
-static int     voyagerfb_putcmap(struct voyagerfb_softc *,
-                struct wsdisplay_cmap *);
-static int     voyagerfb_getcmap(struct voyagerfb_softc *,
-                struct wsdisplay_cmap *);
-static void    voyagerfb_restore_palette(struct voyagerfb_softc *);
-static int     voyagerfb_putpalreg(struct voyagerfb_softc *, int, uint8_t,
-                           uint8_t, uint8_t);
-
-static void    voyagerfb_init(struct voyagerfb_softc *);
-
-static void    voyagerfb_rectfill(struct voyagerfb_softc *, int, int, int, int,
-                           uint32_t);
-static void    voyagerfb_bitblt(struct voyagerfb_softc *, int, int, int, int,
-                           int, int, int);
-
-static void    voyagerfb_cursor(void *, int, int, int);
-static void    voyagerfb_putchar(void *, int, int, u_int, long);
-static void    voyagerfb_copycols(void *, int, int, int, int);
-static void    voyagerfb_erasecols(void *, int, int, int, long);
-static void    voyagerfb_copyrows(void *, int, int, int);
-static void    voyagerfb_eraserows(void *, int, int, long);
-
-struct wsdisplay_accessops voyagerfb_accessops = {
-       voyagerfb_ioctl,
-       voyagerfb_mmap,
-       NULL,   /* alloc_screen */
-       NULL,   /* free_screen */
-       NULL,   /* show_screen */
-       NULL,   /* load_font */
-       NULL,   /* pollc */
-       NULL    /* scroll */
-};
-
-/* wait for FIFO empty so we can feed it another command */
-static inline void
-voyagerfb_ready(struct voyagerfb_softc *sc)
-{
-       do {} while ((bus_space_read_4(sc->sc_memt, sc->sc_regh, 
-           SM502_SYSTEM_CTRL) & SM502_SYSCTL_FIFO_EMPTY) == 0);
-}
-
-/* wait for the drawing engine to be idle */
-static inline void
-voyagerfb_wait(struct voyagerfb_softc *sc)
-{
-       do {} while ((bus_space_read_4(sc->sc_memt, sc->sc_regh, 
-           SM502_SYSTEM_CTRL) & SM502_SYSCTL_ENGINE_BUSY) != 0);
-}
-
-static int
-voyagerfb_match(device_t parent, cfdata_t match, void *aux)
-{
-       struct pci_attach_args *pa = (struct pci_attach_args *)aux;
-
-       if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY)
-               return 0;
-       if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_SILMOTION)
-               return 0;
-
-       /* only chip tested on so far - may need a list */
-       if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SILMOTION_SM502)
-               return 100;
-       return (0);
-}
-
-static void
-voyagerfb_attach(device_t parent, device_t self, void *aux)
-{
-       struct voyagerfb_softc  *sc = device_private(self);
-       struct pci_attach_args  *pa = aux;
-       struct rasops_info      *ri;
-       char devinfo[256];
-       struct wsemuldisplaydev_attach_args aa;
-       prop_dictionary_t       dict;
-       unsigned long           defattr;
-       uint32_t                reg;
-       bool                    is_console;
-       int i, j;
-
-       sc->sc_pc = pa->pa_pc;
-       sc->sc_pcitag = pa->pa_tag;
-       sc->sc_memt = pa->pa_memt;
-       sc->sc_iot = pa->pa_iot;
-       sc->sc_dev = self;
-
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-       aprint_normal(": %s\n", devinfo);
-
-       dict = device_properties(self);
-       prop_dictionary_get_bool(dict, "is_console", &is_console);
-
-       if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_MEM,
-           BUS_SPACE_MAP_LINEAR,
-           &sc->sc_memt, &sc->sc_fbh, &sc->sc_fb, &sc->sc_fbsize)) {
-               aprint_error("%s: failed to map the frame buffer.\n",
-                   device_xname(sc->sc_dev));
-       }
-       sc->sc_fbaddr = bus_space_vaddr(sc->sc_memt, sc->sc_fbh);
-
-       if (pci_mapreg_map(pa, 0x14, PCI_MAPREG_TYPE_MEM, 0,
-           &sc->sc_memt, &sc->sc_regh, &sc->sc_reg, &sc->sc_regsize)) {
-               aprint_error("%s: failed to map registers.\n",
-                   device_xname(sc->sc_dev));
-       }
-       sc->sc_dataport = bus_space_vaddr(sc->sc_memt, sc->sc_regh);
-       sc->sc_dataport += SM502_DATAPORT;
-
-       reg = bus_space_read_4(sc->sc_memt, sc->sc_regh, SM502_PANEL_DISP_CRTL);
-       switch (reg & SM502_PDC_DEPTH_MASK) {
-               case SM502_PDC_8BIT:
-                       sc->sc_depth = 8;
-                       break;
-               case SM502_PDC_16BIT:
-                       sc->sc_depth = 16;
-                       break;
-               case SM502_PDC_32BIT:
-                       sc->sc_depth = 24;
-                       break;
-               default:
-                       panic("%s: unsupported depth", device_xname(self));
-       }
-       sc->sc_stride = (bus_space_read_4(sc->sc_memt, sc->sc_regh,     
-               SM502_PANEL_FB_OFFSET) & SM502_FBA_WIN_STRIDE_MASK) >> 16;
-       sc->sc_width = (bus_space_read_4(sc->sc_memt, sc->sc_regh,      
-               SM502_PANEL_FB_WIDTH) & SM502_FBW_WIN_WIDTH_MASK) >> 16;
-       sc->sc_height = (bus_space_read_4(sc->sc_memt, sc->sc_regh,     
-               SM502_PANEL_FB_HEIGHT) & SM502_FBH_WIN_HEIGHT_MASK) >> 16;
-
-       printf("%s: %d x %d, %d bit, stride %d\n", device_xname(self), 
-               sc->sc_width, sc->sc_height, sc->sc_depth, sc->sc_stride);
-       /*
-        * XXX yeah, casting the fb address to uint32_t is formally wrong
-        * but as far as I know there are no SM502 with 64bit BARs
-        */
-       aprint_normal("%s: %d MB aperture at 0x%08x\n", device_xname(self),
-           (int)(sc->sc_fbsize >> 20), (uint32_t)sc->sc_fb);
-
-       sc->sc_defaultscreen_descr = (struct wsscreen_descr){
-               "default",
-               0, 0,
-               NULL,
-               8, 16,
-               WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
-               NULL
-       };
-       sc->sc_screens[0] = &sc->sc_defaultscreen_descr;
-       sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens};
-       sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
-       sc->sc_locked = 0;
-
-       vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr,
-           &voyagerfb_accessops);
-       sc->vd.init_screen = voyagerfb_init_screen;
-
-       /* init engine here */
-       voyagerfb_init(sc);
-
-       ri = &sc->sc_console_screen.scr_ri;
-
-       if (is_console) {
-               vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
-                   &defattr);
-               sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
-
-               sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
-               sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
-               sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
-               sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
-               wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
-                   defattr);
-       } else {
-               /*
-                * since we're not the console we can postpone the rest
-                * until someone actually allocates a screen for us
-                */
-               (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
-       }
-
-       j = 0;
-       if (sc->sc_depth <= 8) {
-               for (i = 0; i < (1 << sc->sc_depth); i++) {
-
-                       sc->sc_cmap_red[i] = rasops_cmap[j];
-                       sc->sc_cmap_green[i] = rasops_cmap[j + 1];
-                       sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
-                       voyagerfb_putpalreg(sc, i, rasops_cmap[j],
-                           rasops_cmap[j + 1], rasops_cmap[j + 2]);
-                       j += 3;
-               }
-       }
-
-       voyagerfb_rectfill(sc, 0, 0, sc->sc_width, sc->sc_height,
-           ri->ri_devcmap[(defattr >> 16) & 0xff]);



Home | Main Index | Thread Index | Old Index