The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/fb/creator.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2003 Jake Burkholder.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/6.4/sys/dev/fb/creator.c 161668 2006-08-27 12:42:55Z marius $");
   29 
   30 #include <sys/param.h>
   31 #include <sys/systm.h>
   32 #include <sys/bus.h>
   33 #include <sys/consio.h>
   34 #include <sys/fbio.h>
   35 #include <sys/kernel.h>
   36 #include <sys/module.h>
   37 
   38 #include <machine/bus.h>
   39 #include <machine/ofw_upa.h>
   40 #include <machine/sc_machdep.h>
   41 
   42 #include <dev/fb/fbreg.h>
   43 #include <dev/fb/gallant12x22.h>
   44 #include <dev/syscons/syscons.h>
   45 
   46 #include <dev/ofw/openfirm.h>
   47 
   48 #include <sparc64/creator/creator.h>
   49 
   50 static int creator_configure(int flags);
   51 
   52 static vi_probe_t creator_probe;
   53 static vi_init_t creator_init;
   54 static vi_get_info_t creator_get_info;
   55 static vi_query_mode_t creator_query_mode;
   56 static vi_set_mode_t creator_set_mode;
   57 static vi_save_font_t creator_save_font;
   58 static vi_load_font_t creator_load_font;
   59 static vi_show_font_t creator_show_font;
   60 static vi_save_palette_t creator_save_palette;
   61 static vi_load_palette_t creator_load_palette;
   62 static vi_set_border_t creator_set_border;
   63 static vi_save_state_t creator_save_state;
   64 static vi_load_state_t creator_load_state;
   65 static vi_set_win_org_t creator_set_win_org;
   66 static vi_read_hw_cursor_t creator_read_hw_cursor;
   67 static vi_set_hw_cursor_t creator_set_hw_cursor;
   68 static vi_set_hw_cursor_shape_t creator_set_hw_cursor_shape;
   69 static vi_blank_display_t creator_blank_display;
   70 static vi_mmap_t creator_mmap;
   71 static vi_ioctl_t creator_ioctl;
   72 static vi_clear_t creator_clear;
   73 static vi_fill_rect_t creator_fill_rect;
   74 static vi_bitblt_t creator_bitblt;
   75 static vi_diag_t creator_diag;
   76 static vi_save_cursor_palette_t creator_save_cursor_palette;
   77 static vi_load_cursor_palette_t creator_load_cursor_palette;
   78 static vi_copy_t creator_copy;
   79 static vi_putp_t creator_putp;
   80 static vi_putc_t creator_putc;
   81 static vi_puts_t creator_puts;
   82 static vi_putm_t creator_putm;
   83 
   84 static void creator_cursor_enable(struct creator_softc *sc, int onoff);
   85 static void creator_cursor_install(struct creator_softc *sc);
   86 
   87 static video_switch_t creatorvidsw = {
   88         .probe                  = creator_probe,
   89         .init                   = creator_init,
   90         .get_info               = creator_get_info,
   91         .query_mode             = creator_query_mode,
   92         .set_mode               = creator_set_mode,
   93         .save_font              = creator_save_font,
   94         .load_font              = creator_load_font,
   95         .show_font              = creator_show_font,
   96         .save_palette           = creator_save_palette,
   97         .load_palette           = creator_load_palette,
   98         .set_border             = creator_set_border,
   99         .save_state             = creator_save_state,
  100         .load_state             = creator_load_state,
  101         .set_win_org            = creator_set_win_org,
  102         .read_hw_cursor         = creator_read_hw_cursor,
  103         .set_hw_cursor          = creator_set_hw_cursor,
  104         .set_hw_cursor_shape    = creator_set_hw_cursor_shape,
  105         .blank_display          = creator_blank_display,
  106         .mmap                   = creator_mmap,
  107         .ioctl                  = creator_ioctl,
  108         .clear                  = creator_clear,
  109         .fill_rect              = creator_fill_rect,
  110         .bitblt                 = creator_bitblt,
  111         NULL,                                           /* XXX brain damage */
  112         NULL,                                           /* XXX brain damage */
  113         .diag                   = creator_diag,
  114         .save_cursor_palette    = creator_save_cursor_palette,
  115         .load_cursor_palette    = creator_load_cursor_palette,
  116         .copy                   = creator_copy,
  117         .putp                   = creator_putp,
  118         .putc                   = creator_putc,
  119         .puts                   = creator_puts,
  120         .putm                   = creator_putm
  121 };
  122 
  123 VIDEO_DRIVER(creator, creatorvidsw, creator_configure);
  124 
  125 extern sc_rndr_sw_t txtrndrsw;
  126 RENDERER(creator, 0, txtrndrsw, gfb_set);
  127 
  128 RENDERER_MODULE(creator, gfb_set);
  129 
  130 extern struct bus_space_tag nexus_bustag;
  131 
  132 #define C(r, g, b)      ((b << 16) | (g << 8) | (r))
  133 static const int cmap[] = {
  134         C(0x00, 0x00, 0x00),            /* black */
  135         C(0x00, 0x00, 0xff),            /* blue */
  136         C(0x00, 0xff, 0x00),            /* green */
  137         C(0x00, 0xc0, 0xc0),            /* cyan */
  138         C(0xff, 0x00, 0x00),            /* red */
  139         C(0xc0, 0x00, 0xc0),            /* magenta */
  140         C(0xc0, 0xc0, 0x00),            /* brown */
  141         C(0xc0, 0xc0, 0xc0),            /* light grey */
  142         C(0x80, 0x80, 0x80),            /* dark grey */
  143         C(0x80, 0x80, 0xff),            /* light blue */
  144         C(0x80, 0xff, 0x80),            /* light green */
  145         C(0x80, 0xff, 0xff),            /* light cyan */
  146         C(0xff, 0x80, 0x80),            /* light red */
  147         C(0xff, 0x80, 0xff),            /* light magenta */
  148         C(0xff, 0xff, 0x80),            /* yellow */
  149         C(0xff, 0xff, 0xff),            /* white */
  150 };
  151 
  152 static const u_char creator_mouse_pointer[64][8] __aligned(8) = {
  153         { 0x00, 0x00, },        /* ............ */
  154         { 0x80, 0x00, },        /* *........... */
  155         { 0xc0, 0x00, },        /* **.......... */
  156         { 0xe0, 0x00, },        /* ***......... */
  157         { 0xf0, 0x00, },        /* ****........ */
  158         { 0xf8, 0x00, },        /* *****....... */
  159         { 0xfc, 0x00, },        /* ******...... */
  160         { 0xfe, 0x00, },        /* *******..... */
  161         { 0xff, 0x00, },        /* ********.... */
  162         { 0xff, 0x80, },        /* *********... */
  163         { 0xfc, 0xc0, },        /* ******..**.. */
  164         { 0xdc, 0x00, },        /* **.***...... */
  165         { 0x8e, 0x00, },        /* *...***..... */
  166         { 0x0e, 0x00, },        /* ....***..... */
  167         { 0x07, 0x00, },        /* .....***.... */
  168         { 0x04, 0x00, },        /* .....*...... */
  169         { 0x00, 0x00, },        /* ............ */
  170         { 0x00, 0x00, },        /* ............ */
  171         { 0x00, 0x00, },        /* ............ */
  172         { 0x00, 0x00, },        /* ............ */
  173         { 0x00, 0x00, },        /* ............ */
  174         { 0x00, 0x00, },        /* ............ */
  175 };
  176 
  177 static struct creator_softc creator_softc;
  178 
  179 static inline void creator_ras_fifo_wait(struct creator_softc *sc, int n);
  180 static inline void creator_ras_setfontinc(struct creator_softc *sc, int fontinc);
  181 static inline void creator_ras_setfontw(struct creator_softc *sc, int fontw);
  182 static inline void creator_ras_setbg(struct creator_softc *sc, int bg);
  183 static inline void creator_ras_setfg(struct creator_softc *sc, int fg);
  184 static inline void creator_ras_setpmask(struct creator_softc *sc, int pmask);
  185 static inline void creator_ras_wait(struct creator_softc *sc);
  186 
  187 static inline void
  188 creator_ras_wait(struct creator_softc *sc)
  189 {
  190         int ucsr;
  191         int r;
  192 
  193         for (;;) {
  194                 ucsr = FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR);
  195                 if ((ucsr & (FBC_UCSR_FB_BUSY | FBC_UCSR_RP_BUSY)) == 0)
  196                         break;
  197                 r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL);
  198                 if (r != 0)
  199                         FFB_WRITE(sc, FFB_FBC, FFB_FBC_UCSR, r);
  200         }
  201 }
  202 
  203 static inline void
  204 creator_ras_fifo_wait(struct creator_softc *sc, int n)
  205 {
  206         int cache;
  207 
  208         cache = sc->sc_fifo_cache;
  209         while (cache < n)
  210                 cache = (FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR) &
  211                     FBC_UCSR_FIFO_MASK) - 8;
  212         sc->sc_fifo_cache = cache - n;
  213 }
  214 
  215 static inline void
  216 creator_ras_setfontinc(struct creator_softc *sc, int fontinc)
  217 {
  218 
  219         if (fontinc == sc->sc_fontinc_cache)
  220                 return;
  221         sc->sc_fontinc_cache = fontinc;
  222         creator_ras_fifo_wait(sc, 1);
  223         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTINC, fontinc);
  224         creator_ras_wait(sc);
  225 }
  226 
  227 static inline void
  228 creator_ras_setfontw(struct creator_softc *sc, int fontw)
  229 {
  230 
  231         if (fontw == sc->sc_fontw_cache)
  232                 return;
  233         sc->sc_fontw_cache = fontw;
  234         creator_ras_fifo_wait(sc, 1);
  235         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTW, fontw);
  236         creator_ras_wait(sc);
  237 }
  238 
  239 static inline void
  240 creator_ras_setbg(struct creator_softc *sc, int bg)
  241 {
  242 
  243         if (bg == sc->sc_bg_cache)
  244                 return;
  245         sc->sc_bg_cache = bg;
  246         creator_ras_fifo_wait(sc, 1);
  247         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BG, bg);
  248         creator_ras_wait(sc);
  249 }
  250 
  251 static inline void
  252 creator_ras_setfg(struct creator_softc *sc, int fg)
  253 {
  254 
  255         if (fg == sc->sc_fg_cache)
  256                 return;
  257         sc->sc_fg_cache = fg;
  258         creator_ras_fifo_wait(sc, 1);
  259         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FG, fg);
  260         creator_ras_wait(sc);
  261 }
  262 
  263 static inline void
  264 creator_ras_setpmask(struct creator_softc *sc, int pmask)
  265 {
  266 
  267         if (pmask == sc->sc_pmask_cache)
  268                 return;
  269         sc->sc_pmask_cache = pmask;
  270         creator_ras_fifo_wait(sc, 1);
  271         FFB_WRITE(sc, FFB_FBC, FFB_FBC_PMASK, pmask);
  272         creator_ras_wait(sc);
  273 }
  274 
  275 static int
  276 creator_configure(int flags)
  277 {
  278         struct upa_regs reg[FFB_NREG];
  279         struct creator_softc *sc;
  280         phandle_t chosen;
  281         phandle_t output;
  282         ihandle_t stdout;
  283         char buf[32];
  284         int i;
  285 
  286         /*
  287          * For the high-level console probing return the number of
  288          * registered adapters.
  289          */
  290         if (!(flags & VIO_PROBE_ONLY)) {
  291                 for (i = 0; vid_find_adapter(CREATOR_DRIVER_NAME, i) >= 0; i++)
  292                         ;
  293                 return (i);
  294         }
  295 
  296         /* Low-level console probing and initialization. */
  297 
  298         sc = &creator_softc;
  299         if (sc->sc_va.va_flags & V_ADP_REGISTERED)
  300                 goto found;
  301 
  302         if ((chosen = OF_finddevice("/chosen")) == -1)
  303                 return (0);
  304         if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
  305                 return (0);
  306         if ((output = OF_instance_to_package(stdout)) == -1)
  307                 return (0);
  308         if (OF_getprop(output, "name", buf, sizeof(buf)) == -1)
  309                 return (0);
  310         if (strcmp(buf, "SUNW,ffb") == 0 || strcmp(buf, "SUNW,afb") == 0) {
  311                 sc->sc_flags = CREATOR_CONSOLE;
  312                 if (strcmp(buf, "SUNW,afb") == 0)
  313                         sc->sc_flags |= CREATOR_AFB;
  314                 sc->sc_node = output;
  315         } else
  316                 return (0);
  317 
  318         if (OF_getprop(output, "reg", reg, sizeof(reg)) == -1)
  319                 return (0);
  320         for (i = 0; i < FFB_NREG; i++) {
  321                 sc->sc_bt[i] = &nexus_bustag;
  322                 sc->sc_bh[i] = UPA_REG_PHYS(reg + i);
  323         }
  324 
  325         if (creator_init(0, &sc->sc_va, 0) < 0)
  326                 return (0);
  327 
  328  found:
  329         /* Return number of found adapters. */
  330         return (1);
  331 }
  332 
  333 static int
  334 creator_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
  335 {
  336 
  337         return (0);
  338 }
  339 
  340 static int
  341 creator_init(int unit, video_adapter_t *adp, int flags)
  342 {
  343         struct creator_softc *sc;
  344         phandle_t options;
  345         video_info_t *vi;
  346         char buf[32];
  347 
  348         sc = (struct creator_softc *)adp;
  349         vi = &adp->va_info;
  350 
  351         vid_init_struct(adp, CREATOR_DRIVER_NAME, -1, unit);
  352 
  353         if (OF_getprop(sc->sc_node, "height", &sc->sc_height,
  354             sizeof(sc->sc_height)) == -1)
  355                 return (ENXIO);
  356         if (OF_getprop(sc->sc_node, "width", &sc->sc_width,
  357             sizeof(sc->sc_width)) == -1)
  358                 return (ENXIO);
  359         if ((options = OF_finddevice("/options")) == -1)
  360                 return (ENXIO);
  361         if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1)
  362                 return (ENXIO);
  363         vi->vi_height = strtol(buf, NULL, 10);
  364         if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1)
  365                 return (ENXIO);
  366         vi->vi_width = strtol(buf, NULL, 10);
  367         vi->vi_cwidth = 12;
  368         vi->vi_cheight = 22;
  369         vi->vi_flags = V_INFO_COLOR;
  370         vi->vi_mem_model = V_INFO_MM_OTHER;
  371 
  372         sc->sc_font = gallant12x22_data;
  373         sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
  374         sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2;
  375 
  376         creator_set_mode(adp, 0);
  377 
  378         if (!(sc->sc_flags & CREATOR_AFB)) {
  379                 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_DID);
  380                 if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
  381                     FFB_DAC_CFG_DID_PNUM) >> 12) != 0x236e) {
  382                         sc->sc_flags |= CREATOR_PAC1;
  383                         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_UCTRL);
  384                         if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
  385                             FFB_DAC_UCTRL_MANREV) >> 8) <= 2)
  386                                 sc->sc_flags |= CREATOR_CURINV;
  387                 }
  388         }
  389 
  390         creator_blank_display(adp, V_DISPLAY_ON);
  391         creator_clear(adp);
  392 
  393         /*
  394          * Setting V_ADP_MODECHANGE serves as hack so creator_set_mode()
  395          * (which will invalidate our caches and restore our settings) is
  396          * called when the X server shuts down. Otherwise screen corruption
  397          * happens most of the time.
  398          */
  399         adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_BORDER |
  400             V_ADP_INITIALIZED;
  401         if (vid_register(adp) < 0)
  402                 return (ENXIO);
  403         adp->va_flags |= V_ADP_REGISTERED;
  404 
  405         return (0);
  406 }
  407 
  408 static int
  409 creator_get_info(video_adapter_t *adp, int mode, video_info_t *info)
  410 {
  411 
  412         bcopy(&adp->va_info, info, sizeof(*info));
  413         return (0);
  414 }
  415 
  416 static int
  417 creator_query_mode(video_adapter_t *adp, video_info_t *info)
  418 {
  419 
  420         return (ENODEV);
  421 }
  422 
  423 static int
  424 creator_set_mode(video_adapter_t *adp, int mode)
  425 {
  426         struct creator_softc *sc;
  427 
  428         sc = (struct creator_softc *)adp;
  429         sc->sc_bg_cache = -1;
  430         sc->sc_fg_cache = -1;
  431         sc->sc_fontinc_cache = -1;
  432         sc->sc_fontw_cache = -1;
  433         sc->sc_pmask_cache = -1;
  434 
  435         creator_ras_wait(sc);
  436         sc->sc_fifo_cache = 0;
  437         creator_ras_fifo_wait(sc, 2);
  438         FFB_WRITE(sc, FFB_FBC, FFB_FBC_PPC, FBC_PPC_VCE_DIS |
  439             FBC_PPC_TBE_OPAQUE | FBC_PPC_APE_DIS | FBC_PPC_CS_CONST);
  440         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FBC, FFB_FBC_WB_A | FFB_FBC_RB_A |
  441             FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK);
  442         return (0);
  443 }
  444 
  445 static int
  446 creator_save_font(video_adapter_t *adp, int page, int size, int width,
  447     u_char *data, int c, int count)
  448 {
  449 
  450         return (ENODEV);
  451 }
  452 
  453 static int
  454 creator_load_font(video_adapter_t *adp, int page, int size, int width,
  455     u_char *data, int c, int count)
  456 {
  457 
  458         return (ENODEV);
  459 }
  460 
  461 static int
  462 creator_show_font(video_adapter_t *adp, int page)
  463 {
  464 
  465         return (ENODEV);
  466 }
  467 
  468 static int
  469 creator_save_palette(video_adapter_t *adp, u_char *palette)
  470 {
  471 
  472         return (ENODEV);
  473 }
  474 
  475 static int
  476 creator_load_palette(video_adapter_t *adp, u_char *palette)
  477 {
  478 
  479         return (ENODEV);
  480 }
  481 
  482 static int
  483 creator_set_border(video_adapter_t *adp, int border)
  484 {
  485         struct creator_softc *sc;
  486 
  487         sc = (struct creator_softc *)adp;
  488         creator_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin);
  489         creator_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin,
  490             sc->sc_width, sc->sc_ymargin);
  491         creator_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height);
  492         creator_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0,
  493             sc->sc_xmargin, sc->sc_height);
  494         return (0);
  495 }
  496 
  497 static int
  498 creator_save_state(video_adapter_t *adp, void *p, size_t size)
  499 {
  500 
  501         return (ENODEV);
  502 }
  503 
  504 static int
  505 creator_load_state(video_adapter_t *adp, void *p)
  506 {
  507 
  508         return (ENODEV);
  509 }
  510 
  511 static int
  512 creator_set_win_org(video_adapter_t *adp, off_t offset)
  513 {
  514 
  515         return (ENODEV);
  516 }
  517 
  518 static int
  519 creator_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
  520 {
  521 
  522         *col = 0;
  523         *row = 0;
  524         return (0);
  525 }
  526 
  527 static int
  528 creator_set_hw_cursor(video_adapter_t *adp, int col, int row)
  529 {
  530 
  531         return (ENODEV);
  532 }
  533 
  534 static int
  535 creator_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
  536     int celsize, int blink)
  537 {
  538 
  539         return (ENODEV);
  540 }
  541 
  542 static int
  543 creator_blank_display(video_adapter_t *adp, int mode)
  544 {
  545         struct creator_softc *sc;
  546         uint32_t v;
  547         int i;
  548 
  549         sc = (struct creator_softc *)adp;
  550         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
  551         v = FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
  552         switch (mode) {
  553         case V_DISPLAY_ON:
  554                 v |= FFB_DAC_CFG_TGEN_VIDE;
  555                 break;
  556         case V_DISPLAY_BLANK:
  557         case V_DISPLAY_STAND_BY:
  558         case V_DISPLAY_SUSPEND:
  559                 v &= ~FFB_DAC_CFG_TGEN_VIDE;
  560                 break;
  561         }
  562         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
  563         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE, v);
  564         for (i = 0; i < 10; i++) {
  565                 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
  566                 (void)FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
  567         }
  568         return (0);
  569 }
  570 
  571 static int
  572 creator_mmap(video_adapter_t *adp, vm_offset_t offset, vm_paddr_t *paddr,
  573     int prot)
  574 {
  575 
  576         return (EINVAL);
  577 }
  578 
  579 static int
  580 creator_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
  581 {
  582         struct creator_softc *sc;
  583         struct fbcursor *fbc;
  584         struct fbtype *fb;
  585 
  586         sc = (struct creator_softc *)adp;
  587         switch (cmd) {
  588         case FBIOGTYPE:
  589                 fb = (struct fbtype *)data;
  590                 fb->fb_type = FBTYPE_CREATOR;
  591                 fb->fb_height = sc->sc_height;
  592                 fb->fb_width = sc->sc_width;
  593                 fb->fb_depth = fb->fb_cmsize = fb->fb_size = 0;
  594                 break;
  595         case FBIOSCURSOR:
  596                 fbc = (struct fbcursor *)data;
  597                 if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) {
  598                         creator_cursor_enable(sc, 0);
  599                         sc->sc_flags &= ~CREATOR_CUREN;
  600                 } else
  601                         return (ENODEV);
  602                 break;
  603                 break;
  604         default:
  605                 return (fb_commonioctl(adp, cmd, data));
  606         }
  607         return (0);
  608 }
  609 
  610 static int
  611 creator_clear(video_adapter_t *adp)
  612 {
  613         struct creator_softc *sc;
  614 
  615         sc = (struct creator_softc *)adp;
  616         creator_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width,
  617             sc->sc_height);
  618         return (0);
  619 }
  620 
  621 static int
  622 creator_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
  623 {
  624         struct creator_softc *sc;
  625 
  626         sc = (struct creator_softc *)adp;
  627         creator_ras_setpmask(sc, 0xffffffff);
  628         creator_ras_fifo_wait(sc, 2);
  629         FFB_WRITE(sc, FFB_FBC, FFB_FBC_ROP, FBC_ROP_NEW);
  630         FFB_WRITE(sc, FFB_FBC, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
  631         creator_ras_setfg(sc, cmap[val & 0xf]);
  632         /*
  633          * Note that at least the Elite3D cards are sensitive to the order
  634          * of operations here.
  635          */
  636         creator_ras_fifo_wait(sc, 4);
  637         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BY, y);
  638         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BX, x);
  639         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BH, cy);
  640         FFB_WRITE(sc, FFB_FBC, FFB_FBC_BW, cx);
  641         creator_ras_wait(sc);
  642         return (0);
  643 }
  644 
  645 static int
  646 creator_bitblt(video_adapter_t *adp, ...)
  647 {
  648 
  649         return (ENODEV);
  650 }
  651 
  652 static int
  653 creator_diag(video_adapter_t *adp, int level)
  654 {
  655         video_info_t info;
  656 
  657         fb_dump_adp_info(adp->va_name, adp, level);
  658         creator_get_info(adp, 0, &info);
  659         fb_dump_mode_info(adp->va_name, adp, &info, level);
  660         return (0);
  661 }
  662 
  663 static int
  664 creator_save_cursor_palette(video_adapter_t *adp, u_char *palette)
  665 {
  666 
  667         return (ENODEV);
  668 }
  669 
  670 static int
  671 creator_load_cursor_palette(video_adapter_t *adp, u_char *palette)
  672 {
  673 
  674         return (ENODEV);
  675 }
  676 
  677 static int
  678 creator_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n)
  679 {
  680 
  681         return (ENODEV);
  682 }
  683 
  684 static int
  685 creator_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a,
  686     int size, int bpp, int bit_ltor, int byte_ltor)
  687 {
  688 
  689         return (ENODEV);
  690 }
  691 
  692 static int
  693 creator_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a)
  694 {
  695         struct creator_softc *sc;
  696         uint16_t *p;
  697         int row;
  698         int col;
  699         int i;
  700 
  701         sc = (struct creator_softc *)adp;
  702         row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
  703         col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
  704         p = (uint16_t *)sc->sc_font + (c * adp->va_info.vi_cheight);
  705         creator_ras_setfg(sc, cmap[a & 0xf]);
  706         creator_ras_setbg(sc, cmap[(a >> 4) & 0xf]);
  707         creator_ras_fifo_wait(sc, 1 + adp->va_info.vi_cheight);
  708         FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTXY,
  709             ((row + sc->sc_ymargin) << 16) | (col + sc->sc_xmargin));
  710         creator_ras_setfontw(sc, adp->va_info.vi_cwidth);
  711         creator_ras_setfontinc(sc, 0x10000);
  712         for (i = 0; i < adp->va_info.vi_cheight; i++) {
  713                 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONT, *p++ << 16);
  714         }
  715         return (0);
  716 }
  717 
  718 static int
  719 creator_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
  720 {
  721         int i;
  722 
  723         for (i = 0; i < len; i++) {
  724                 (*vidsw[adp->va_index]->putc)(adp, off + i, s[i] & 0xff,
  725                     (s[i] & 0xff00) >> 8);
  726         }
  727         return (0);
  728 }
  729 
  730 static int
  731 creator_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
  732     u_int32_t pixel_mask, int size, int width)
  733 {
  734         struct creator_softc *sc;
  735 
  736         sc = (struct creator_softc *)adp;
  737         if (!(sc->sc_flags & CREATOR_CUREN)) {
  738                 creator_cursor_install(sc);
  739                 creator_cursor_enable(sc, 1);
  740                 sc->sc_flags |= CREATOR_CUREN;
  741         }
  742         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_POS);
  743         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
  744             ((y + sc->sc_ymargin) << 16) | (x + sc->sc_xmargin));
  745         return (0);
  746 }
  747 
  748 static void
  749 creator_cursor_enable(struct creator_softc *sc, int onoff)
  750 {
  751         int v;
  752 
  753         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_CTRL);
  754         if (sc->sc_flags & CREATOR_CURINV)
  755                 v = onoff ? FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1 : 0;
  756         else
  757                 v = onoff ? 0 : FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1;
  758         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, v);
  759 }
  760 
  761 static void
  762 creator_cursor_install(struct creator_softc *sc)
  763 {
  764         int i, j;
  765 
  766         creator_cursor_enable(sc, 0);
  767         FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_COLOR1);
  768         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0xffffff);
  769         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0x0);
  770         for (i = 0; i < 2; i++) {
  771                 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2,
  772                     i ? FFB_DAC_CUR_BITMAP_P0 : FFB_DAC_CUR_BITMAP_P1);
  773                 for (j = 0; j < 64; j++) {
  774                         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
  775                             *(const uint32_t *)(&creator_mouse_pointer[j][0]));
  776                         FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 
  777                             *(const uint32_t *)(&creator_mouse_pointer[j][4]));
  778                 }
  779         }
  780 }

Cache object: ccf3f323d2e0f43f7c628c634eeacb9e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.