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/fbreg.h

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) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
    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 as
   10  *    the first lines of this file unmodified.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/8.4/sys/dev/fb/fbreg.h 238556 2012-07-17 19:14:12Z kib $
   27  */
   28 
   29 #ifndef _DEV_FB_FBREG_H_
   30 #define _DEV_FB_FBREG_H_
   31 
   32 #ifdef _KERNEL
   33 
   34 #define V_MAX_ADAPTERS          8               /* XXX */
   35 
   36 /* some macros */
   37 #if defined(__amd64__) || defined(__i386__)
   38 
   39 static __inline void
   40 copyw(uint16_t *src, uint16_t *dst, size_t size)
   41 {
   42         size >>= 1;
   43         while (size--)
   44                 *dst++ = *src++;
   45 }
   46 #define bcopy_io(s, d, c)       copyw((void*)(s), (void*)(d), (c))
   47 #define bcopy_toio(s, d, c)     copyw((void*)(s), (void*)(d), (c))
   48 #define bcopy_fromio(s, d, c)   copyw((void*)(s), (void*)(d), (c))
   49 #define bzero_io(d, c)          bzero((void *)(d), (c))
   50 #define fill_io(p, d, c)        fill((p), (void *)(d), (c))
   51 #define fillw_io(p, d, c)       fillw((p), (void *)(d), (c))
   52 #elif defined(__ia64__) || defined(__sparc64__)
   53 #if defined(__ia64__)
   54 #include <machine/bus.h>
   55 #define bcopy_fromio(s, d, c)   \
   56         bus_space_read_region_1(IA64_BUS_SPACE_MEM, s, 0, (void*)(d), c)
   57 #define bcopy_io(s, d, c)       \
   58         bus_space_copy_region_1(IA64_BUS_SPACE_MEM, s, 0, d, 0, c)
   59 #define bcopy_toio(s, d, c)     \
   60         bus_space_write_region_1(IA64_BUS_SPACE_MEM, d, 0, (void*)(s), c)
   61 #define bzero_io(d, c)          \
   62         bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, 0, c)
   63 #define fill_io(p, d, c)        \
   64         bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c)
   65 #define fillw_io(p, d, c)       \
   66         bus_space_set_region_2(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c)
   67 #define readb(a)                bus_space_read_1(IA64_BUS_SPACE_MEM, a, 0)
   68 #define readw(a)                bus_space_read_2(IA64_BUS_SPACE_MEM, a, 0)
   69 #define writeb(a, v)            bus_space_write_1(IA64_BUS_SPACE_MEM, a, 0, v)
   70 #define writew(a, v)            bus_space_write_2(IA64_BUS_SPACE_MEM, a, 0, v)
   71 #define writel(a, v)            bus_space_write_4(IA64_BUS_SPACE_MEM, a, 0, v)
   72 #endif /* __ia64__ */
   73 static __inline void
   74 fillw(int val, uint16_t *buf, size_t size)
   75 {
   76         while (size--)
   77                 *buf++ = val;
   78 }
   79 #elif defined(__powerpc__)
   80 
   81 #define bcopy_io(s, d, c)       ofwfb_bcopy((void *)(s), (void *)(d), (c))
   82 #define bcopy_toio(s, d, c)     ofwfb_bcopy((void *)(s), (void *)(d), (c))
   83 #define bcopy_fromio(s, d, c)   ofwfb_bcopy((void *)(s), (void *)(d), (c))
   84 #define bzero_io(d, c)          ofwfb_bzero((void *)(d), (c))
   85 #define fillw(p, d, c)          ofwfb_fillw((p), (void *)(d), (c))
   86 #define fillw_io(p, d, c)       ofwfb_fillw((p), (void *)(d), (c))
   87 #define readw(a)                ofwfb_readw((u_int16_t *)(a))
   88 #define writew(a, v)            ofwfb_writew((u_int16_t *)(a), (v))
   89 void ofwfb_bcopy(const void *s, void *d, size_t c);
   90 void ofwfb_bzero(void *d, size_t c);
   91 void ofwfb_fillw(int pat, void *base, size_t cnt);
   92 u_int16_t ofwfb_readw(u_int16_t *addr);
   93 void ofwfb_writew(u_int16_t *addr, u_int16_t val);
   94 
   95 #else /* !__i386__ && !__amd64__ && !__ia64__ && !__sparc64__ && !__powerpc__ */
   96 #define bcopy_io(s, d, c)       memcpy_io((d), (s), (c))
   97 #define bcopy_toio(s, d, c)     memcpy_toio((d), (void *)(s), (c))
   98 #define bcopy_fromio(s, d, c)   memcpy_fromio((void *)(d), (s), (c))
   99 #define bzero_io(d, c)          memset_io((d), 0, (c))
  100 #define fill_io(p, d, c)        memset_io((d), (p), (c))
  101 #define fillw(p, d, c)          memsetw((d), (p), (c))
  102 #define fillw_io(p, d, c)       memsetw_io((d), (p), (c))
  103 #endif /* !__i386__ */
  104 
  105 /* video function table */
  106 typedef int vi_probe_t(int unit, video_adapter_t **adpp, void *arg, int flags);
  107 typedef int vi_init_t(int unit, video_adapter_t *adp, int flags);
  108 typedef int vi_get_info_t(video_adapter_t *adp, int mode, video_info_t *info);
  109 typedef int vi_query_mode_t(video_adapter_t *adp, video_info_t *info);
  110 typedef int vi_set_mode_t(video_adapter_t *adp, int mode);
  111 typedef int vi_save_font_t(video_adapter_t *adp, int page, int size, int width,
  112                            u_char *data, int c, int count);
  113 typedef int vi_load_font_t(video_adapter_t *adp, int page, int size, int width,
  114                            u_char *data, int c, int count);
  115 typedef int vi_show_font_t(video_adapter_t *adp, int page);
  116 typedef int vi_save_palette_t(video_adapter_t *adp, u_char *palette);
  117 typedef int vi_load_palette_t(video_adapter_t *adp, u_char *palette);
  118 typedef int vi_set_border_t(video_adapter_t *adp, int border);
  119 typedef int vi_save_state_t(video_adapter_t *adp, void *p, size_t size);
  120 typedef int vi_load_state_t(video_adapter_t *adp, void *p);
  121 typedef int vi_set_win_org_t(video_adapter_t *adp, off_t offset);
  122 typedef int vi_read_hw_cursor_t(video_adapter_t *adp, int *col, int *row);
  123 typedef int vi_set_hw_cursor_t(video_adapter_t *adp, int col, int row);
  124 typedef int vi_set_hw_cursor_shape_t(video_adapter_t *adp, int base,
  125                                      int height, int celsize, int blink);
  126 typedef int vi_blank_display_t(video_adapter_t *adp, int mode);
  127 /* defined in sys/fbio.h
  128 #define V_DISPLAY_ON            0
  129 #define V_DISPLAY_BLANK         1
  130 #define V_DISPLAY_STAND_BY      2
  131 #define V_DISPLAY_SUSPEND       3
  132 */
  133 typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset,
  134                       vm_paddr_t *paddr, int prot);
  135 typedef int vi_ioctl_t(video_adapter_t *adp, u_long cmd, caddr_t data);
  136 typedef int vi_clear_t(video_adapter_t *adp);
  137 typedef int vi_fill_rect_t(video_adapter_t *adp, int val, int x, int y,
  138                            int cx, int cy);
  139 typedef int vi_bitblt_t(video_adapter_t *adp, ...);
  140 typedef int vi_diag_t(video_adapter_t *adp, int level);
  141 typedef int vi_save_cursor_palette_t(video_adapter_t *adp, u_char *palette);
  142 typedef int vi_load_cursor_palette_t(video_adapter_t *adp, u_char *palette);
  143 typedef int vi_copy_t(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst,
  144                       int n);
  145 typedef int vi_putp_t(video_adapter_t *adp, vm_offset_t off, u_int32_t p,
  146                        u_int32_t a, int size, int bpp, int bit_ltor,
  147                        int byte_ltor);
  148 typedef int vi_putc_t(video_adapter_t *adp, vm_offset_t off, u_int8_t c,
  149                       u_int8_t a);
  150 typedef int vi_puts_t(video_adapter_t *adp, vm_offset_t off, u_int16_t *s,
  151                        int len);
  152 typedef int vi_putm_t(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
  153                       u_int32_t pixel_mask, int size, int width);
  154 
  155 typedef struct video_switch {
  156     vi_probe_t          *probe;
  157     vi_init_t           *init;
  158     vi_get_info_t       *get_info;
  159     vi_query_mode_t     *query_mode;
  160     vi_set_mode_t       *set_mode;
  161     vi_save_font_t      *save_font;
  162     vi_load_font_t      *load_font;
  163     vi_show_font_t      *show_font;
  164     vi_save_palette_t   *save_palette;
  165     vi_load_palette_t   *load_palette;
  166     vi_set_border_t     *set_border;
  167     vi_save_state_t     *save_state;
  168     vi_load_state_t     *load_state;
  169     vi_set_win_org_t    *set_win_org;
  170     vi_read_hw_cursor_t *read_hw_cursor;
  171     vi_set_hw_cursor_t  *set_hw_cursor;
  172     vi_set_hw_cursor_shape_t *set_hw_cursor_shape;
  173     vi_blank_display_t  *blank_display;
  174     vi_mmap_t           *mmap;
  175     vi_ioctl_t          *ioctl;
  176     vi_clear_t          *clear;
  177     vi_fill_rect_t      *fill_rect;
  178     vi_bitblt_t         *bitblt;
  179     int                 (*reserved1)(void);
  180     int                 (*reserved2)(void);
  181     vi_diag_t           *diag;
  182     vi_save_cursor_palette_t    *save_cursor_palette;
  183     vi_load_cursor_palette_t    *load_cursor_palette;
  184     vi_copy_t           *copy;
  185     vi_putp_t           *putp;
  186     vi_putc_t           *putc;
  187     vi_puts_t           *puts;
  188     vi_putm_t           *putm;
  189 } video_switch_t;
  190 
  191 #define vidd_probe(unit, adpp, arg, flags)                              \
  192         (*vidsw[(adp)->va_index]->probe)((unit), (adpp), (arg), (flags))
  193 #define vidd_init(unit, adp, flags)                                     \
  194         (*vidsw[(adp)->va_index]->init)((unit), (adp), (flags))
  195 #define vidd_get_info(adp, mode, info)                                  \
  196         (*vidsw[(adp)->va_index]->get_info)((adp), (mode), (info))
  197 #define vidd_query_mode(adp, mode)                                      \
  198         (*vidsw[(adp)->va_index]->query_mode)((adp), (mode))
  199 #define vidd_set_mode(adp, mode)                                        \
  200         (*vidsw[(adp)->va_index]->set_mode)((adp), (mode))
  201 #define vidd_save_font(adp, page, size, width, data, c, count)          \
  202         (*vidsw[(adp)->va_index]->save_font)((adp), (page), (size),     \
  203             (width), (data), (c), (count))
  204 #define vidd_load_font(adp, page, size, width, data, c, count)          \
  205         (*vidsw[(adp)->va_index]->load_font)((adp), (page), (size),     \
  206             (width), (data), (c), (count))
  207 #define vidd_show_font(adp, page)                                       \
  208         (*vidsw[(adp)->va_index]->show_font)((adp), (page))
  209 #define vidd_save_palette(adp, pallete)                                 \
  210         (*vidsw[(adp)->va_index]->save_palette)((adp), (pallete))
  211 #define vidd_load_palette(adp, pallete)                                 \
  212         (*vidsw[(adp)->va_index]->load_palette)((adp), (pallete))
  213 #define vidd_set_border(adp, border)                                    \
  214         (*vidsw[(adp)->va_index]->set_border)((adp), (border))
  215 #define vidd_save_state(adp, p, size)                                   \
  216         (*vidsw[(adp)->va_index]->save_state)((adp), (p), (size))
  217 #define vidd_load_state(adp, p)                                         \
  218         (*vidsw[(adp)->va_index]->load_state)((adp), (p))
  219 #define vidd_set_win_org(adp, offset)                                   \
  220         (*vidsw[(adp)->va_index]->set_win_org)((adp), (offset))
  221 #define vidd_read_hw_cursor(adp, col, row)                              \
  222         (*vidsw[(adp)->va_index]->read_hw_cursor)((adp), (col), (row))
  223 #define vidd_set_hw_cursor(adp, col, row)                               \
  224         (*vidsw[(adp)->va_index]->set_hw_cursor)((adp), (col), (row))
  225 #define vidd_set_hw_cursor_shape(adp, base, height, celsize, blink)     \
  226         (*vidsw[(adp)->va_index]->set_hw_cursor_shape)((adp), (base),   \
  227             (height), (celsize), (blink))
  228 #define vidd_blank_display(adp, mode)                                   \
  229         (*vidsw[(adp)->va_index]->blank_display)((adp), (mode))
  230 #define vidd_mmap(adp, offset, paddr, prot)                             \
  231         (*vidsw[(adp)->va_index]->mmap)((adp), (offset), (paddr), (prot))
  232 #define vidd_ioctl(adp, cmd, data)                                      \
  233         (*vidsw[(adp)->va_index]->ioctl)((adp), (cmd), (data))
  234 #define vidd_clear(adp)                                                 \
  235         (*vidsw[(adp)->va_index]->clear)((adp))
  236 #define vidd_fill_rect(adp, val, x, y, cx, cy)                          \
  237         (*vidsw[(adp)->va_index]->fill_rect)((adp), (val), (x), (y),    \
  238             (cx), (cy))
  239 #define vidd_bitblt(adp, ...)                                           \
  240         (*vidsw[(adp)->va_index]->bitblt)(adp, __VA_ARGS__)
  241 #define vidd_diag(adp, level)                                           \
  242         (*vidsw[(adp)->va_index]->diag)((adp), (level))
  243 #define vidd_save_cursor_palette(adp, palette)                          \
  244         (*vidsw[(adp)->va_index]->save_cursor_palette)((adp), (palette))
  245 #define vidd_load_cursor_palette(adp, palette)                          \
  246         (*vidsw[(adp)->va_index]->load_cursor_palette)((adp), (palette))
  247 #define vidd_copy(adp, src, dst, n)                                     \
  248         (*vidsw[(adp)->va_index]->copy)((adp), (src), (dst), (n))
  249 #define vidd_putp(adp, offset, p, a, size, bpp, bit_ltor1, byte_ltor2)  \
  250         (*vidsw[(adp)->va_index]->putp)((adp), (offset), (p), (a),      \
  251             (size), (bpp), (bit_ltor1), (bit_ltor2))
  252 #define vidd_putc(adp, offset, c, a)                                    \
  253         (*vidsw[(adp)->va_index]->putc)((adp), (offset), (c), (a))
  254 #define vidd_puts(adp, offset, s, len)                                  \
  255         (*vidsw[(adp)->va_index]->puts)((adp), (offset), (s), (len))
  256 #define vidd_putm(adp, x, y, pixel_image, pixel_mask, size, width)      \
  257         (*vidsw[(adp)->va_index]->putm)((adp), (x), (y), (pixel_image), \
  258             (pixel_mask), (size), (width))
  259 
  260 /* video driver */
  261 typedef struct video_driver {
  262     char                *name;
  263     video_switch_t      *vidsw;
  264     int                 (*configure)(int); /* backdoor for the console driver */
  265 } video_driver_t;
  266 
  267 #define VIDEO_DRIVER(name, sw, config)                  \
  268         static struct video_driver name##_driver = {    \
  269                 #name, &sw, config                      \
  270         };                                              \
  271         DATA_SET(videodriver_set, name##_driver);
  272 
  273 /* global variables */
  274 extern struct video_switch **vidsw;
  275 
  276 /* functions for the video card driver */
  277 int             vid_register(video_adapter_t *adp);
  278 int             vid_unregister(video_adapter_t *adp);
  279 video_switch_t  *vid_get_switch(char *name);
  280 void            vid_init_struct(video_adapter_t *adp, char *name, int type,
  281                                 int unit);
  282 
  283 /* functions for the video card client */
  284 int             vid_allocate(char *driver, int unit, void *id);
  285 int             vid_release(video_adapter_t *adp, void *id);
  286 int             vid_find_adapter(char *driver, int unit);
  287 video_adapter_t *vid_get_adapter(int index);
  288 
  289 /* a backdoor for the console driver to tickle the video driver XXX */
  290 int             vid_configure(int flags);
  291 #define VIO_PROBE_ONLY  (1 << 0)        /* probe only, don't initialize */
  292 
  293 #ifdef FB_INSTALL_CDEV
  294 
  295 /* virtual frame buffer driver functions */
  296 int             fb_attach(int unit, video_adapter_t *adp,
  297                           struct cdevsw *cdevsw);
  298 int             fb_detach(int unit, video_adapter_t *adp,
  299                           struct cdevsw *cdevsw);
  300 
  301 /* generic frame buffer cdev driver functions */
  302 
  303 typedef struct genfb_softc {
  304         int             gfb_flags;      /* flag/status bits */
  305 #define FB_OPEN         (1 << 0)
  306 } genfb_softc_t;
  307 
  308 int             genfbopen(genfb_softc_t *sc, video_adapter_t *adp,
  309                           int flag, int mode, struct thread *td);
  310 int             genfbclose(genfb_softc_t *sc, video_adapter_t *adp,
  311                            int flag, int mode, struct thread *td);
  312 int             genfbread(genfb_softc_t *sc, video_adapter_t *adp,
  313                           struct uio *uio, int flag);
  314 int             genfbwrite(genfb_softc_t *sc, video_adapter_t *adp,
  315                            struct uio *uio, int flag);
  316 int             genfbioctl(genfb_softc_t *sc, video_adapter_t *adp,
  317                            u_long cmd, caddr_t arg, int flag, struct thread *td);
  318 int             genfbmmap(genfb_softc_t *sc, video_adapter_t *adp,
  319                           vm_offset_t offset, vm_offset_t *paddr, int prot);
  320 
  321 #endif /* FB_INSTALL_CDEV */
  322 
  323 /* generic low-level driver functions */
  324 
  325 void            fb_dump_adp_info(char *driver, video_adapter_t *adp, int level);
  326 void            fb_dump_mode_info(char *driver, video_adapter_t *adp,
  327                                   video_info_t *info, int level);
  328 int             fb_type(int adp_type);
  329 int             fb_commonioctl(video_adapter_t *adp, u_long cmd, caddr_t arg);
  330 
  331 #endif /* _KERNEL */
  332 
  333 #endif /* !_DEV_FB_FBREG_H_ */

Cache object: d85210fa29fd6e06514d882f8fac4f21


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