FreeBSD/Linux Kernel Cross Reference
sys/dev/fb/fbreg.h
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/5.1/sys/dev/fb/fbreg.h 114383 2003-05-01 04:21:05Z peter $
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_io(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c))
39 #define bcopy_toio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c))
40 #define bcopy_fromio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c))
41 #define bzero_io(d, c) generic_bzero((void *)(d), (c))
42 #define fill_io(p, d, c) fill((p), (void *)(d), (c))
43 #define fillw_io(p, d, c) fillw((p), (void *)(d), (c))
44 void generic_bcopy(const void *s, void *d, size_t c);
45 void generic_bzero(void *d, size_t c);
46 #elif __amd64__
47 #define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c))
48 #define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c))
49 #define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c))
50 #define bzero_io(d, c) bzero((void *)(d), (c))
51 #define fill_io(p, d, c) fill((p), (void *)(d), (c))
52 #define fillw_io(p, d, c) fillw((p), (void *)(d), (c))
53 #elif __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, d, 0, 0, c)
63 #define fill_io(p, d, c) \
64 bus_space_set_region_1(IA64_BUS_SPACE_MEM, d, 0, p, c)
65 #define fillw_io(p, d, c) \
66 bus_space_set_region_2(IA64_BUS_SPACE_MEM, d, 0, p, c)
67 #define readw(a) \
68 bus_space_read_2(IA64_BUS_SPACE_MEM, a, 0)
69 #define writew(a, v) \
70 bus_space_write_2(IA64_BUS_SPACE_MEM, a, 0, v)
71 #define writel(a, v) \
72 bus_space_write_4(IA64_BUS_SPACE_MEM, a, 0, v)
73 static __inline void
74 fillw(int val, uint16_t *buf, size_t size)
75 {
76 while (size--)
77 *buf++ = val;
78 }
79 #else /* !__i386__ && !__ia64__ && !__amd64__ */
80 #define bcopy_io(s, d, c) memcpy_io((d), (s), (c))
81 #define bcopy_toio(s, d, c) memcpy_toio((d), (void *)(s), (c))
82 #define bcopy_fromio(s, d, c) memcpy_fromio((void *)(d), (s), (c))
83 #define bzero_io(d, c) memset_io((d), 0, (c))
84 #define fill_io(p, d, c) memset_io((d), (p), (c))
85 #define fillw(p, d, c) memsetw((d), (p), (c))
86 #define fillw_io(p, d, c) memsetw_io((d), (p), (c))
87 #endif /* !__i386__ */
88
89 /* video function table */
90 typedef int vi_probe_t(int unit, video_adapter_t **adpp, void *arg, int flags);
91 typedef int vi_init_t(int unit, video_adapter_t *adp, int flags);
92 typedef int vi_get_info_t(video_adapter_t *adp, int mode, video_info_t *info);
93 typedef int vi_query_mode_t(video_adapter_t *adp, video_info_t *info);
94 typedef int vi_set_mode_t(video_adapter_t *adp, int mode);
95 typedef int vi_save_font_t(video_adapter_t *adp, int page, int size,
96 u_char *data, int c, int count);
97 typedef int vi_load_font_t(video_adapter_t *adp, int page, int size,
98 u_char *data, int c, int count);
99 typedef int vi_show_font_t(video_adapter_t *adp, int page);
100 typedef int vi_save_palette_t(video_adapter_t *adp, u_char *palette);
101 typedef int vi_load_palette_t(video_adapter_t *adp, u_char *palette);
102 typedef int vi_set_border_t(video_adapter_t *adp, int border);
103 typedef int vi_save_state_t(video_adapter_t *adp, void *p, size_t size);
104 typedef int vi_load_state_t(video_adapter_t *adp, void *p);
105 typedef int vi_set_win_org_t(video_adapter_t *adp, off_t offset);
106 typedef int vi_read_hw_cursor_t(video_adapter_t *adp, int *col, int *row);
107 typedef int vi_set_hw_cursor_t(video_adapter_t *adp, int col, int row);
108 typedef int vi_set_hw_cursor_shape_t(video_adapter_t *adp, int base,
109 int height, int celsize, int blink);
110 typedef int vi_blank_display_t(video_adapter_t *adp, int mode);
111 /* defined in sys/fbio.h
112 #define V_DISPLAY_ON 0
113 #define V_DISPLAY_BLANK 1
114 #define V_DISPLAY_STAND_BY 2
115 #define V_DISPLAY_SUSPEND 3
116 */
117 typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset,
118 vm_paddr_t *paddr, int prot);
119 typedef int vi_ioctl_t(video_adapter_t *adp, u_long cmd, caddr_t data);
120 typedef int vi_clear_t(video_adapter_t *adp);
121 typedef int vi_fill_rect_t(video_adapter_t *adp, int val, int x, int y,
122 int cx, int cy);
123 typedef int vi_bitblt_t(video_adapter_t *adp, ...);
124 typedef int vi_diag_t(video_adapter_t *adp, int level);
125 typedef int vi_save_cursor_palette_t(video_adapter_t *adp, u_char *palette);
126 typedef int vi_load_cursor_palette_t(video_adapter_t *adp, u_char *palette);
127 typedef int vi_copy_t(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst,
128 int n);
129 typedef int vi_putp_t(video_adapter_t *adp, vm_offset_t off, u_int32_t p,
130 u_int32_t a, int size, int bpp, int bit_ltor,
131 int byte_ltor);
132 typedef int vi_putc_t(video_adapter_t *adp, vm_offset_t off, u_int8_t c,
133 u_int8_t a);
134 typedef int vi_puts_t(video_adapter_t *adp, vm_offset_t off, u_int16_t *s,
135 int len);
136 typedef int vi_putm_t(video_adapter_t *adp, int x, int y,
137 u_int8_t *pixel_image, u_int32_t pixel_mask, int size);
138
139 typedef struct video_switch {
140 vi_probe_t *probe;
141 vi_init_t *init;
142 vi_get_info_t *get_info;
143 vi_query_mode_t *query_mode;
144 vi_set_mode_t *set_mode;
145 vi_save_font_t *save_font;
146 vi_load_font_t *load_font;
147 vi_show_font_t *show_font;
148 vi_save_palette_t *save_palette;
149 vi_load_palette_t *load_palette;
150 vi_set_border_t *set_border;
151 vi_save_state_t *save_state;
152 vi_load_state_t *load_state;
153 vi_set_win_org_t *set_win_org;
154 vi_read_hw_cursor_t *read_hw_cursor;
155 vi_set_hw_cursor_t *set_hw_cursor;
156 vi_set_hw_cursor_shape_t *set_hw_cursor_shape;
157 vi_blank_display_t *blank_display;
158 vi_mmap_t *mmap;
159 vi_ioctl_t *ioctl;
160 vi_clear_t *clear;
161 vi_fill_rect_t *fill_rect;
162 vi_bitblt_t *bitblt;
163 int (*reserved1)(void);
164 int (*reserved2)(void);
165 vi_diag_t *diag;
166 vi_save_cursor_palette_t *save_cursor_palette;
167 vi_load_cursor_palette_t *load_cursor_palette;
168 vi_copy_t *copy;
169 vi_putp_t *putp;
170 vi_putc_t *putc;
171 vi_puts_t *puts;
172 vi_putm_t *putm;
173 } video_switch_t;
174
175 #define save_palette(adp, pal) \
176 (*vidsw[(adp)->va_index]->save_palette)((adp), (pal))
177 #define load_palette(adp, pal) \
178 (*vidsw[(adp)->va_index]->load_palette)((adp), (pal))
179 #define get_mode_info(adp, mode, buf) \
180 (*vidsw[(adp)->va_index]->get_info)((adp), (mode), (buf))
181 #define set_video_mode(adp, mode) \
182 (*vidsw[(adp)->va_index]->set_mode)((adp), (mode))
183 #define set_border(adp, border) \
184 (*vidsw[(adp)->va_index]->set_border)((adp), (border))
185 #define set_origin(adp, o) \
186 (*vidsw[(adp)->va_index]->set_win_org)(adp, o)
187
188 /* XXX - add more macros */
189
190 /* video driver */
191 typedef struct video_driver {
192 char *name;
193 video_switch_t *vidsw;
194 int (*configure)(int); /* backdoor for the console driver */
195 } video_driver_t;
196
197 #define VIDEO_DRIVER(name, sw, config) \
198 static struct video_driver name##_driver = { \
199 #name, &sw, config \
200 }; \
201 DATA_SET(videodriver_set, name##_driver);
202
203 /* global variables */
204 extern struct video_switch **vidsw;
205
206 /* functions for the video card driver */
207 int vid_register(video_adapter_t *adp);
208 int vid_unregister(video_adapter_t *adp);
209 video_switch_t *vid_get_switch(char *name);
210 void vid_init_struct(video_adapter_t *adp, char *name, int type,
211 int unit);
212
213 /* functions for the video card client */
214 int vid_allocate(char *driver, int unit, void *id);
215 int vid_release(video_adapter_t *adp, void *id);
216 int vid_find_adapter(char *driver, int unit);
217 video_adapter_t *vid_get_adapter(int index);
218
219 /* a backdoor for the console driver to tickle the video driver XXX */
220 int vid_configure(int flags);
221 #define VIO_PROBE_ONLY (1 << 0) /* probe only, don't initialize */
222
223 #ifdef FB_INSTALL_CDEV
224
225 /* virtual frame buffer driver functions */
226 int fb_attach(dev_t dev, video_adapter_t *adp,
227 struct cdevsw *cdevsw);
228 int fb_detach(dev_t dev, video_adapter_t *adp,
229 struct cdevsw *cdevsw);
230
231 /* generic frame buffer cdev driver functions */
232
233 typedef struct genfb_softc {
234 int gfb_flags; /* flag/status bits */
235 #define FB_OPEN (1 << 0)
236 } genfb_softc_t;
237
238 int genfbopen(genfb_softc_t *sc, video_adapter_t *adp,
239 int flag, int mode, struct thread *td);
240 int genfbclose(genfb_softc_t *sc, video_adapter_t *adp,
241 int flag, int mode, struct thread *td);
242 int genfbread(genfb_softc_t *sc, video_adapter_t *adp,
243 struct uio *uio, int flag);
244 int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp,
245 struct uio *uio, int flag);
246 int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp,
247 u_long cmd, caddr_t arg, int flag, struct thread *td);
248 int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp,
249 vm_offset_t offset, vm_offset_t *paddr, int prot);
250
251 #endif /* FB_INSTALL_CDEV */
252
253 /* generic low-level driver functions */
254
255 void fb_dump_adp_info(char *driver, video_adapter_t *adp, int level);
256 void fb_dump_mode_info(char *driver, video_adapter_t *adp,
257 video_info_t *info, int level);
258 int fb_type(int adp_type);
259 int fb_commonioctl(video_adapter_t *adp, u_long cmd, caddr_t arg);
260
261 #endif /* _KERNEL */
262
263 #endif /* !_DEV_FB_FBREG_H_ */
Cache object: e277e023ac973fe751e480f7107dca68
|