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/i386/xbox/xboxfb.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) 2005, 2006 Rink Springer <rink@il.fontys.nl>
    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  * 3. The name of the author may not be used to endorse or promote products
   14  *    derived from this software without specific prior written permission
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  */
   27 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD$");
   30 
   31 /*
   32  * This is the syscon(4)-ized version of the Xbox Frame Buffer driver. It
   33  * supports about all features required, such as mouse support.
   34  *
   35  * A lot of functions that are not useful to us have not been implemented.
   36  * It appears that some functions are never called, but these implementations
   37  * are here nevertheless.
   38  */
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <vm/vm_param.h>
   42 #include <sys/kernel.h>
   43 #include <sys/bus.h>
   44 #include <sys/cons.h>
   45 #include <sys/module.h>
   46 #include <sys/conf.h>
   47 #include <sys/consio.h>
   48 #include <sys/limits.h>
   49 #include <sys/tty.h>
   50 #include <sys/kbio.h>
   51 #include <sys/fbio.h>
   52 #include <dev/kbd/kbdreg.h>
   53 #include <vm/vm.h>
   54 #include <vm/pmap.h>
   55 #include <machine/bus.h>
   56 #include <machine/xbox.h>
   57 #include <machine/legacyvar.h>
   58 #include <dev/fb/fbreg.h>
   59 #include <dev/fb/gfb.h>
   60 #include <dev/syscons/syscons.h>
   61 
   62 struct xboxfb_softc {
   63         video_adapter_t sc_va;
   64 
   65         /* screen height (pixels) */
   66         uint32_t sc_height;
   67 
   68         /* screen width (pixels) */
   69         uint32_t sc_width;
   70 
   71         /* pointer to the actual XBOX video memory */
   72         char* sc_framebuffer;
   73 
   74         /* pointer to the font used */
   75         const struct gfb_font* sc_font;
   76 };
   77 
   78 #define SCREEN_WIDTH    640
   79 #define SCREEN_HEIGHT   480
   80 
   81 #define XBOXFB_DRIVER_NAME "xboxsc"
   82 
   83 extern const struct gfb_font bold8x16;
   84 
   85 static vi_probe_t xboxfb_probe;
   86 static vi_init_t xboxfb_init;
   87 static vi_get_info_t xboxfb_get_info;
   88 static vi_query_mode_t xboxfb_query_mode;
   89 static vi_set_mode_t xboxfb_set_mode;
   90 static vi_save_font_t xboxfb_save_font;
   91 static vi_load_font_t xboxfb_load_font;
   92 static vi_show_font_t xboxfb_show_font;
   93 static vi_save_palette_t xboxfb_save_palette;
   94 static vi_load_palette_t xboxfb_load_palette;
   95 static vi_set_border_t xboxfb_set_border;
   96 static vi_save_state_t xboxfb_save_state;
   97 static vi_load_state_t xboxfb_load_state;
   98 static vi_set_win_org_t xboxfb_set_win_org;
   99 static vi_read_hw_cursor_t xboxfb_read_hw_cursor;
  100 static vi_set_hw_cursor_t xboxfb_set_hw_cursor;
  101 static vi_set_hw_cursor_shape_t xboxfb_set_hw_cursor_shape;
  102 static vi_blank_display_t xboxfb_blank_display;
  103 static vi_mmap_t xboxfb_mmap;
  104 static vi_ioctl_t xboxfb_ioctl;
  105 static vi_clear_t xboxfb_clear;
  106 static vi_fill_rect_t xboxfb_fill_rect;
  107 static vi_bitblt_t xboxfb_bitblt;
  108 static vi_diag_t xboxfb_diag;
  109 static vi_save_cursor_palette_t xboxfb_save_cursor_palette;
  110 static vi_load_cursor_palette_t xboxfb_load_cursor_palette;
  111 static vi_copy_t xboxfb_copy;
  112 static vi_putp_t xboxfb_putp;
  113 static vi_putc_t xboxfb_putc;
  114 static vi_puts_t xboxfb_puts;
  115 static vi_putm_t xboxfb_putm;
  116 
  117 static video_switch_t xboxvidsw = {
  118         .probe                = xboxfb_probe,
  119         .init                 = xboxfb_init,
  120         .get_info             = xboxfb_get_info,
  121         .query_mode           = xboxfb_query_mode,
  122         .set_mode             = xboxfb_set_mode,
  123         .save_font            = xboxfb_save_font,
  124         .load_font            = xboxfb_load_font,
  125         .show_font            = xboxfb_show_font,
  126         .save_palette         = xboxfb_save_palette,
  127         .load_palette         = xboxfb_load_palette,
  128         .set_border           = xboxfb_set_border,
  129         .save_state           = xboxfb_save_state,
  130         .load_state           = xboxfb_load_state,
  131         .set_win_org          = xboxfb_set_win_org,
  132         .read_hw_cursor       = xboxfb_read_hw_cursor,
  133         .set_hw_cursor        = xboxfb_set_hw_cursor,
  134         .set_hw_cursor_shape  = xboxfb_set_hw_cursor_shape,
  135         .blank_display        = xboxfb_blank_display,
  136         .mmap                 = xboxfb_mmap,
  137         .ioctl                = xboxfb_ioctl,
  138         .clear                = xboxfb_clear,
  139         .fill_rect            = xboxfb_fill_rect,
  140         .bitblt               = xboxfb_bitblt,
  141         NULL,
  142         NULL,
  143         .diag                 = xboxfb_diag,
  144         .save_cursor_palette  = xboxfb_save_cursor_palette,
  145         .load_cursor_palette  = xboxfb_load_cursor_palette,
  146         .copy                 = xboxfb_copy,
  147         .putp                 = xboxfb_putp,
  148         .putc                 = xboxfb_putc,
  149         .puts                 = xboxfb_puts,
  150         .putm                 = xboxfb_putm
  151 };
  152 
  153 static int xboxfb_configure(int flags);
  154 VIDEO_DRIVER(xboxsc, xboxvidsw, xboxfb_configure);
  155 
  156 static vr_init_t xbr_init;
  157 static vr_clear_t xbr_clear;
  158 static vr_draw_border_t xbr_draw_border;
  159 static vr_draw_t xbr_draw;
  160 static vr_set_cursor_t xbr_set_cursor;
  161 static vr_draw_cursor_t xbr_draw_cursor;
  162 static vr_blink_cursor_t xbr_blink_cursor;
  163 static vr_set_mouse_t xbr_set_mouse;
  164 static vr_draw_mouse_t xbr_draw_mouse;
  165 
  166 /*
  167  * We use our own renderer; this is because we must emulate a hardware
  168  * cursor.
  169  */
  170 static sc_rndr_sw_t xboxrend = {
  171         xbr_init,
  172         xbr_clear,
  173         xbr_draw_border,
  174         xbr_draw,
  175         xbr_set_cursor,
  176         xbr_draw_cursor,
  177         xbr_blink_cursor,
  178         xbr_set_mouse,
  179         xbr_draw_mouse
  180 };
  181 RENDERER(xboxsc, 0, xboxrend, gfb_set);
  182 
  183 static struct xboxfb_softc xboxfb_sc;
  184 
  185 /* color mappings, from dev/fb/creator.c */
  186 static const uint32_t cmap[] = {
  187         0x00000000,                     /* black */
  188         0x000000ff,                     /* blue */
  189         0x0000ff00,                     /* green */
  190         0x0000c0c0,                     /* cyan */
  191         0x00ff0000,                     /* red */
  192         0x00c000c0,                     /* magenta */
  193         0x00c0c000,                     /* brown */
  194         0x00c0c0c0,                     /* light grey */
  195         0x00808080,                     /* dark grey */
  196         0x008080ff,                     /* light blue */
  197         0x0080ff80,                     /* light green */
  198         0x0080ffff,                     /* light cyan */
  199         0x00ff8080,                     /* light red */
  200         0x00ff80ff,                     /* light magenta */
  201         0x00ffff80,                     /* yellow */
  202         0x00ffffff                      /* white */
  203 };
  204 
  205 /* mouse pointer from dev/syscons/scgfbrndr.c */
  206 static u_char mouse_pointer[16] = {
  207         0x00, 0x40, 0x60, 0x70, 0x78, 0x7c, 0x7e, 0x68,
  208         0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
  209 };
  210 
  211 static int
  212 xboxfb_init(int unit, video_adapter_t* adp, int flags)
  213 {
  214         struct xboxfb_softc* sc = &xboxfb_sc;
  215         video_info_t* vi;
  216         int i;
  217         int* iptr;
  218 
  219         vi = &adp->va_info;
  220 
  221         vid_init_struct (adp, XBOXFB_DRIVER_NAME, -1, unit);
  222         sc->sc_height = SCREEN_HEIGHT;
  223         sc->sc_width = SCREEN_WIDTH;
  224         sc->sc_font = &bold8x16;
  225         if (!(adp->va_flags & V_ADP_INITIALIZED)) {
  226                 /*
  227                  * We must make a mapping from video framebuffer memory
  228                  * to real. This is very crude:  we map the entire
  229                  * videomemory to PAGE_SIZE! Since our kernel lives at
  230                  * it's relocated address range (0xc0xxxxxx), it won't
  231                  * care.
  232                  *
  233                  * We use address PAGE_SIZE and up so we can still trap
  234                  * NULL pointers.  Once the real init is called, the
  235                  * mapping will be done via the OS and stored in a more
  236                  * sensible location ... but since we're not fully
  237                  * initialized, this is our only way to go :-(
  238                  */
  239                 for (i = 0; i < (XBOX_FB_SIZE / PAGE_SIZE); i++) {
  240                         pmap_kenter (((i + 1) * PAGE_SIZE), XBOX_FB_START + (i * PAGE_SIZE));
  241                 }
  242                 pmap_kenter ((i + 1) * PAGE_SIZE, XBOX_FB_START_PTR - XBOX_FB_START_PTR % PAGE_SIZE);
  243                 sc->sc_framebuffer = (char*)PAGE_SIZE;
  244 
  245                 /* ensure the framebuffer is where we want it to be */
  246                 *(uint32_t*)((i + 1) * PAGE_SIZE + XBOX_FB_START_PTR % PAGE_SIZE) = XBOX_FB_START;
  247 
  248                 /* clear the screen */
  249                 iptr = (uint32_t*)sc->sc_framebuffer;
  250                 for (i = 0; i < sc->sc_height * sc->sc_width; i++)
  251                         *iptr++ = cmap[0];
  252 
  253                 /* don't ever do this again! */
  254                 adp->va_flags |= V_ADP_INITIALIZED;
  255         }
  256 
  257         vi->vi_mode = M_TEXT_80x25;
  258         vi->vi_cwidth = sc->sc_font->width;
  259         vi->vi_cheight = sc->sc_font->height;
  260         vi->vi_height = (sc->sc_height / vi->vi_cheight);
  261         vi->vi_width = (sc->sc_width / vi->vi_cwidth);
  262         vi->vi_flags = V_INFO_COLOR | V_INFO_LINEAR;
  263         vi->vi_mem_model = V_INFO_MM_DIRECT;
  264 
  265         adp->va_flags |= V_ADP_COLOR;
  266 
  267         if (vid_register(adp) < 0)
  268                 return (ENXIO);
  269 
  270         adp->va_flags |= V_ADP_REGISTERED;
  271 
  272         return 0;
  273 }
  274 
  275 static int
  276 xboxfb_probe(int unit, video_adapter_t** adp, void* arg, int flags)
  277 {
  278         return 0;
  279 }
  280 
  281 static int
  282 xboxfb_configure(int flags)
  283 {
  284         struct xboxfb_softc* sc = &xboxfb_sc;
  285 
  286         /* Don't init the framebuffer on non-XBOX-es */
  287         if (!arch_i386_is_xbox)
  288                 return 0;
  289 
  290         /*
  291          * If we do only a probe, we are in such an early boot stadium
  292          * that we cannot yet do a 'clean' initialization.
  293          */
  294         if (flags & VIO_PROBE_ONLY) {
  295                 xboxfb_init(0, &sc->sc_va, 0);
  296                 return 1;
  297         }
  298 
  299         /* Do a clean mapping of the framebuffer memory */
  300         sc->sc_framebuffer = pmap_mapdev (XBOX_FB_START, XBOX_FB_SIZE);
  301         return 1;
  302 }
  303 
  304 static void
  305 sc_identify(driver_t* driver, device_t parent)
  306 {
  307         BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0);
  308 }
  309 
  310 static int
  311 sc_probe(device_t dev)
  312 {
  313         device_set_desc(dev, "XBox System console");
  314         return (sc_probe_unit(device_get_unit(dev), device_get_flags(dev) | SC_AUTODETECT_KBD));
  315 }
  316 
  317 static int sc_attach(device_t dev)
  318 {
  319         return (sc_attach_unit(device_get_unit(dev), device_get_flags(dev) | SC_AUTODETECT_KBD));
  320 }
  321 
  322 static device_method_t sc_methods[] = {
  323         /* Device interface */
  324         DEVMETHOD(device_identify,      sc_identify),
  325         DEVMETHOD(device_probe,         sc_probe),
  326         DEVMETHOD(device_attach,        sc_attach),
  327         { 0, 0 }
  328 };
  329 
  330 static driver_t xboxfb_sc_driver = {
  331         SC_DRIVER_NAME,
  332         sc_methods,
  333         sizeof(sc_softc_t)
  334 };
  335 
  336 static devclass_t sc_devclass;
  337 
  338 DRIVER_MODULE(sc, legacy, xboxfb_sc_driver, sc_devclass, 0, 0);
  339 
  340 static void
  341 xbr_init(scr_stat* scp)
  342 {
  343 }
  344 
  345 static void
  346 xbr_clear(scr_stat* scp, int c, int attr)
  347 {
  348 }
  349 
  350 static void
  351 xbr_draw_border(scr_stat* scp, int color)
  352 {
  353 }
  354 
  355 static void
  356 xbr_draw(scr_stat* scp, int from, int count, int flip)
  357 {
  358         video_adapter_t* adp = scp->sc->adp;
  359         int i, c, a;
  360 
  361         if (!flip) {
  362                 /* Normal printing */
  363                 (*vidsw[scp->sc->adapter]->puts)(adp, from, (uint16_t*)sc_vtb_pointer(&scp->vtb, from), count);
  364         } else {        
  365                 /* This is for selections and such: invert the color attribute */
  366                 for (i = count; i-- > 0; ++from) {
  367                         c = sc_vtb_getc(&scp->vtb, from);
  368                         a = sc_vtb_geta(&scp->vtb, from) >> 8;
  369                         (*vidsw[scp->sc->adapter]->putc)(adp, from, c, (a >> 4) | ((a & 0xf) << 4));
  370                 }
  371         }
  372 }
  373 
  374 static void
  375 xbr_set_cursor(scr_stat* scp, int base, int height, int blink)
  376 {
  377 }
  378 
  379 static void
  380 xbr_draw_cursor(scr_stat* scp, int at, int blink, int on, int flip)
  381 {
  382         struct xboxfb_softc* sc = &xboxfb_sc;
  383         video_adapter_t* adp = scp->sc->adp;
  384         uint32_t* ptri = (uint32_t*)sc->sc_framebuffer;
  385         int row, col, i, j;
  386 
  387         if (scp->curs_attr.height <= 0)
  388                 return;
  389 
  390         /* calculate the coordinates in the video buffer */
  391         row = (at / adp->va_info.vi_width) * adp->va_info.vi_cheight;
  392         col = (at % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
  393         ptri += (row * sc->sc_width) + col;
  394 
  395         /* our cursor consists of simply inverting the char under it */
  396         for (i = 0; i < adp->va_info.vi_cheight; i++) {
  397                 for (j = 0; j < adp->va_info.vi_cwidth; j++) {
  398                         *ptri++ ^= 0x00FFFFFF;
  399                 }
  400                 ptri += (sc->sc_width - adp->va_info.vi_cwidth);
  401         }
  402 }
  403 
  404 static void
  405 xbr_blink_cursor(scr_stat* scp, int at, int flip)
  406 {
  407 }
  408 
  409 static void
  410 xbr_set_mouse(scr_stat* scp)
  411 {
  412 }
  413 
  414 static void
  415 xbr_draw_mouse(scr_stat* scp, int x, int y, int on)
  416 {
  417         (*vidsw[scp->sc->adapter]->putm)(scp->sc->adp, x, y, mouse_pointer, 0xffffffff, 16, 8);
  418 
  419 }
  420 
  421 static int
  422 xboxfb_get_info(video_adapter_t *adp, int mode, video_info_t *info)
  423 {
  424         bcopy(&adp->va_info, info, sizeof(*info));
  425         return (0);
  426 }
  427 
  428 static int
  429 xboxfb_query_mode(video_adapter_t *adp, video_info_t *info)
  430 {
  431         return (ENODEV);
  432 }
  433 
  434 static int
  435 xboxfb_set_mode(video_adapter_t *adp, int mode)
  436 {
  437         return (0);
  438 }
  439 
  440 static int
  441 xboxfb_save_font(video_adapter_t *adp, int page, int size, int width,
  442     u_char *data, int c, int count)
  443 {
  444         return (ENODEV);
  445 }
  446 
  447 static int
  448 xboxfb_load_font(video_adapter_t *adp, int page, int size, int width,
  449     u_char *data, int c, int count)
  450 {
  451         return (ENODEV);
  452 }
  453 
  454 static int
  455 xboxfb_show_font(video_adapter_t *adp, int page)
  456 {
  457         return (ENODEV);
  458 }
  459 
  460 static int
  461 xboxfb_save_palette(video_adapter_t *adp, u_char *palette)
  462 {
  463         return (ENODEV);
  464 }
  465 
  466 static int
  467 xboxfb_load_palette(video_adapter_t *adp, u_char *palette)
  468 {
  469         return (ENODEV);
  470 }
  471 
  472 static int
  473 xboxfb_set_border(video_adapter_t *adp, int border)
  474 {
  475         return (0);
  476 }
  477 
  478 static int
  479 xboxfb_save_state(video_adapter_t *adp, void *p, size_t size)
  480 {
  481         return (ENODEV);
  482 }
  483 
  484 static int
  485 xboxfb_load_state(video_adapter_t *adp, void *p)
  486 {
  487         return (ENODEV);
  488 }
  489 
  490 static int
  491 xboxfb_set_win_org(video_adapter_t *adp, off_t offset)
  492 {
  493         return (ENODEV);
  494 }
  495 
  496 static int
  497 xboxfb_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
  498 {
  499         *col = 0;
  500         *row = 0;
  501         return (0);
  502 }
  503 
  504 static int
  505 xboxfb_set_hw_cursor(video_adapter_t *adp, int col, int row)
  506 {
  507         return (ENODEV);
  508 }
  509 
  510 static int
  511 xboxfb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
  512     int celsize, int blink)
  513 {
  514         return (ENODEV);
  515 }
  516 
  517 static int
  518 xboxfb_blank_display(video_adapter_t *adp, int mode)
  519 {
  520         return (0);
  521 }
  522 
  523 static int
  524 xboxfb_mmap(video_adapter_t *adp, vm_offset_t offset, vm_paddr_t *paddr,
  525     int prot)
  526 {
  527         return (EINVAL);
  528 }
  529 
  530 static int
  531 xboxfb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
  532 {
  533         return (fb_commonioctl(adp, cmd, data));
  534 }
  535 
  536 static int
  537 xboxfb_clear(video_adapter_t *adp)
  538 {
  539         return (0);
  540 }
  541 
  542 static int
  543 xboxfb_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
  544 {
  545         return (0);
  546 }
  547 
  548 static int
  549 xboxfb_bitblt(video_adapter_t *adp, ...)
  550 {
  551         return (ENODEV);
  552 }
  553 
  554 static int
  555 xboxfb_diag(video_adapter_t *adp, int level)
  556 {
  557         video_info_t info;
  558 
  559         fb_dump_adp_info(adp->va_name, adp, level);
  560         xboxfb_get_info(adp, 0, &info);
  561         fb_dump_mode_info(adp->va_name, adp, &info, level);
  562         return (0);
  563 }
  564 
  565 static int
  566 xboxfb_save_cursor_palette(video_adapter_t *adp, u_char *palette)
  567 {
  568         return (ENODEV);
  569 }
  570 
  571 static int
  572 xboxfb_load_cursor_palette(video_adapter_t *adp, u_char *palette)
  573 {
  574         return (ENODEV);
  575 }
  576 
  577 static int
  578 xboxfb_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n)
  579 {
  580         return (ENODEV);
  581 }
  582 
  583 static int
  584 xboxfb_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a,
  585     int size, int bpp, int bit_ltor, int byte_ltor)
  586 {
  587         return (ENODEV);
  588 }
  589 
  590 static int
  591 xboxfb_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a)
  592 {
  593         int row, col;
  594         int i, j;
  595         struct xboxfb_softc* sc = &xboxfb_sc;
  596         uint32_t* ptri = (uint32_t*)sc->sc_framebuffer;
  597         const uint8_t* fontdata;
  598         uint32_t clr;
  599         uint8_t mask;
  600 
  601         /* calculate the position in the frame buffer */
  602         row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
  603         col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
  604         fontdata = &sc->sc_font->data[c * adp->va_info.vi_cheight];
  605         ptri += (row * sc->sc_width) + col;
  606 
  607         /* Place the character on the screen, pixel by pixel */
  608         for (j = 0; j < adp->va_info.vi_cheight; j++) {
  609                 mask = 0x80;
  610                 for (i = 0; i < adp->va_info.vi_cwidth; i++) {
  611                         clr = (*fontdata & mask) ? cmap[a & 0xf] : cmap[(a >> 4) & 0xf];
  612                         *ptri++ = clr;
  613                         mask >>= 1;
  614                 }
  615                 ptri += (sc->sc_width - adp->va_info.vi_cwidth);
  616                 fontdata++;
  617         }
  618         return (0);
  619 }
  620 
  621 static int
  622 xboxfb_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
  623 {
  624         int i;
  625 
  626         for (i = 0; i < len; i++) {
  627                 (*vidsw[adp->va_index]->putc)(adp, off + i, s[i] & 0xff,
  628                     (s[i] & 0xff00) >> 8);
  629         }
  630         return (0);
  631 }
  632 
  633 static int
  634 xboxfb_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
  635     u_int32_t pixel_mask, int size, int width)
  636 {
  637         struct xboxfb_softc* sc = &xboxfb_sc;
  638         uint32_t* ptri = (uint32_t*)sc->sc_framebuffer;
  639         int i, j;       
  640 
  641         if (x < 0 || y < 0 || x + width > sc->sc_width || y + (2 * size) > sc->sc_height)
  642                 return 0;
  643 
  644         ptri += (y * sc->sc_width) + x;
  645 
  646         /* plot the mousecursor wherever the user wants it */
  647         for (j = 0; j < size; j++) {
  648                 for (i = width; i > 0; i--) {
  649                         if (pixel_image[j] & (1 << i))
  650                                 *ptri = cmap[0xf];
  651                         ptri++;
  652                 }
  653                 ptri += (sc->sc_width - width);
  654         }
  655         return (0);
  656 }

Cache object: 51555664c3a784559df4e695a915856a


[ 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.