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 * $Id: $ 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 #ifdef __i386__ 38 #define bcopy_toio(s, d, c) generic_bcopy(s, d, c) 39 #define bcopy_fromio(s, d, c) generic_bcopy(s, d, c) 40 #define bzero_io(d, c) generic_bzero(d, c) 41 void generic_bcopy(const void *s, void *d, size_t c); 42 void generic_bzero(void *d, size_t c); 43 #else /* !__i386__ */ 44 #define bcopy_toio(s, d, c) memcpy_toio(d, s, c) 45 #define bcopy_fromio(s, d, c) memcpy_fromio(d, s, c) 46 #define bzero_io(d, c) memset_io(d, 0, c) 47 #endif /* !__i386__ */ 48 49 /* video function table */ 50 typedef int vi_probe_t(int unit, video_adapter_t **adpp, void *arg, int flags); 51 typedef int vi_init_t(int unit, video_adapter_t *adp, int flags); 52 typedef int vi_get_info_t(video_adapter_t *adp, int mode, video_info_t *info); 53 typedef int vi_query_mode_t(video_adapter_t *adp, video_info_t *info); 54 typedef int vi_set_mode_t(video_adapter_t *adp, int mode); 55 typedef int vi_save_font_t(video_adapter_t *adp, int page, int size, 56 u_char *data, int c, int count); 57 typedef int vi_load_font_t(video_adapter_t *adp, int page, int size, 58 u_char *data, int c, int count); 59 typedef int vi_show_font_t(video_adapter_t *adp, int page); 60 typedef int vi_save_palette_t(video_adapter_t *adp, u_char *palette); 61 typedef int vi_load_palette_t(video_adapter_t *adp, u_char *palette); 62 typedef int vi_set_border_t(video_adapter_t *adp, int border); 63 typedef int vi_save_state_t(video_adapter_t *adp, void *p, size_t size); 64 typedef int vi_load_state_t(video_adapter_t *adp, void *p); 65 typedef int vi_set_win_org_t(video_adapter_t *adp, off_t offset); 66 typedef int vi_read_hw_cursor_t(video_adapter_t *adp, int *col, int *row); 67 typedef int vi_set_hw_cursor_t(video_adapter_t *adp, int col, int row); 68 typedef int vi_set_hw_cursor_shape_t(video_adapter_t *adp, int base, 69 int height, int celsize, int blink); 70 typedef int vi_blank_display_t(video_adapter_t *adp, int mode); 71 #define V_DISPLAY_POWER_ON 0 72 #define V_DISPLAY_SUSPEND 1 73 #define V_DISPLAY_SUSPEND1 1 74 #define V_DISPLAY_SUSPEND2 2 75 #define V_DISPLAY_POWER_OFF 3 76 typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset); 77 typedef int vi_diag_t(video_adapter_t *adp, int level); 78 79 typedef struct video_switch { 80 vi_probe_t *probe; 81 vi_init_t *init; 82 vi_get_info_t *get_info; 83 vi_query_mode_t *query_mode; 84 vi_set_mode_t *set_mode; 85 vi_save_font_t *save_font; 86 vi_load_font_t *load_font; 87 vi_show_font_t *show_font; 88 vi_save_palette_t *save_palette; 89 vi_load_palette_t *load_palette; 90 vi_set_border_t *set_border; 91 vi_save_state_t *save_state; 92 vi_load_state_t *load_state; 93 vi_set_win_org_t *set_win_org; 94 vi_read_hw_cursor_t *read_hw_cursor; 95 vi_set_hw_cursor_t *set_hw_cursor; 96 vi_set_hw_cursor_shape_t *set_hw_cursor_shape; 97 vi_blank_display_t *blank_display; 98 vi_mmap_t *mmap; 99 vi_diag_t *diag; 100 } video_switch_t; 101 102 /* video driver */ 103 typedef struct video_driver { 104 char *name; 105 video_switch_t *vidsw; 106 int (*configure)(int); /* backdoor for the console driver */ 107 } video_driver_t; 108 109 #define VIDEO_DRIVER(name, sw, config) \ 110 static struct video_driver name##_driver = { \ 111 #name, &sw, config \ 112 }; \ 113 DATA_SET(videodriver_set, name##_driver); 114 115 /* global variables */ 116 extern struct video_switch **vidsw; 117 extern struct linker_set videodriver_set; 118 119 /* functions for the video card driver */ 120 int vid_register(video_adapter_t *adp); 121 int vid_unregister(video_adapter_t *adp); 122 video_switch_t *vid_get_switch(char *name); 123 void vid_init_struct(video_adapter_t *adp, char *name, int type, 124 int unit); 125 126 /* functions for the video card client */ 127 int vid_allocate(char *driver, int unit, void *id); 128 int vid_release(video_adapter_t *adp, void *id); 129 int vid_find_adapter(char *driver, int unit); 130 video_adapter_t *vid_get_adapter(int index); 131 132 /* a backdoor for the console driver to tickle the video driver XXX */ 133 int vid_configure(int flags); 134 #define VIO_PROBE_ONLY (1 << 0) /* probe only, don't initialize */ 135 136 #ifdef FB_INSTALL_CDEV 137 138 /* virtual frame buffer driver functions */ 139 int fb_attach(dev_t dev, video_adapter_t *adp, 140 struct cdevsw *cdevsw); 141 int fb_detach(dev_t dev, video_adapter_t *adp, 142 struct cdevsw *cdevsw); 143 144 #endif /* FB_INSTALL_CDEV */ 145 146 /* generic low-level driver functions */ 147 148 void fb_dump_adp_info(char *driver, video_adapter_t *adp, int level); 149 void fb_dump_mode_info(char *driver, video_adapter_t *adp, 150 video_info_t *info, int level); 151 152 #endif /* KERNEL */ 153 154 #endif /* !_DEV_FB_FBREG_H_ */ 155