LINT build test. Aggregated source code adjustments to bring most of the
[dragonfly.git] / sys / dev / video / fb / fbreg.h
... / ...
CommitLineData
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: src/sys/dev/fb/fbreg.h,v 1.6 1999/12/29 04:35:36 peter Exp $
27 * $DragonFly: src/sys/dev/video/fb/fbreg.h,v 1.3 2003/07/21 07:57:40 dillon Exp $
28 */
29
30#ifndef _DEV_FB_FBREG_H_
31#define _DEV_FB_FBREG_H_
32
33#ifdef _KERNEL
34
35#define V_MAX_ADAPTERS 8 /* XXX */
36
37/* some macros */
38#ifdef __i386__
39#define bcopy_io(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c))
40#define bcopy_toio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c))
41#define bcopy_fromio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c))
42#define bzero_io(d, c) generic_bzero((void *)(d), (c))
43#define fill_io(p, d, c) fill((p), (void *)(d), (c))
44#define fillw_io(p, d, c) fillw((p), (void *)(d), (c))
45void generic_bcopy(const void *s, void *d, size_t c);
46void generic_bzero(void *d, size_t c);
47#else /* !__i386__ */
48#define bcopy_io(s, d, c) memcpy_io((d), (s), (c))
49#define bcopy_toio(s, d, c) memcpy_toio((d), (void *)(s), (c))
50#define bcopy_fromio(s, d, c) memcpy_fromio((void *)(d), (s), (c))
51#define bzero_io(d, c) memset_io((d), 0, (c))
52#define fill_io(p, d, c) memset_io((d), (p), (c))
53#define fillw(p, d, c) memsetw((d), (p), (c))
54#define fillw_io(p, d, c) memsetw_io((d), (p), (c))
55#endif /* !__i386__ */
56
57/* video function table */
58typedef int vi_probe_t(int unit, video_adapter_t **adpp, void *arg, int flags);
59typedef int vi_init_t(int unit, video_adapter_t *adp, int flags);
60typedef int vi_get_info_t(video_adapter_t *adp, int mode, video_info_t *info);
61typedef int vi_query_mode_t(video_adapter_t *adp, video_info_t *info);
62typedef int vi_set_mode_t(video_adapter_t *adp, int mode);
63typedef int vi_save_font_t(video_adapter_t *adp, int page, int size,
64 u_char *data, int c, int count);
65typedef int vi_load_font_t(video_adapter_t *adp, int page, int size,
66 u_char *data, int c, int count);
67typedef int vi_show_font_t(video_adapter_t *adp, int page);
68typedef int vi_save_palette_t(video_adapter_t *adp, u_char *palette);
69typedef int vi_load_palette_t(video_adapter_t *adp, u_char *palette);
70typedef int vi_set_border_t(video_adapter_t *adp, int border);
71typedef int vi_save_state_t(video_adapter_t *adp, void *p, size_t size);
72typedef int vi_load_state_t(video_adapter_t *adp, void *p);
73typedef int vi_set_win_org_t(video_adapter_t *adp, off_t offset);
74typedef int vi_read_hw_cursor_t(video_adapter_t *adp, int *col, int *row);
75typedef int vi_set_hw_cursor_t(video_adapter_t *adp, int col, int row);
76typedef int vi_set_hw_cursor_shape_t(video_adapter_t *adp, int base,
77 int height, int celsize, int blink);
78typedef int vi_blank_display_t(video_adapter_t *adp, int mode);
79#define V_DISPLAY_ON 0
80#define V_DISPLAY_BLANK 1
81#define V_DISPLAY_STAND_BY 2
82#define V_DISPLAY_SUSPEND 3
83typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset, int prot);
84typedef int vi_ioctl_t(video_adapter_t *adp, u_long cmd, caddr_t data);
85typedef int vi_clear_t(video_adapter_t *adp);
86typedef int vi_fill_rect_t(video_adapter_t *adp, int val, int x, int y,
87 int cx, int cy);
88typedef int vi_bitblt_t(video_adapter_t *adp,...);
89typedef int vi_diag_t(video_adapter_t *adp, int level);
90
91typedef struct video_switch {
92 vi_probe_t *probe;
93 vi_init_t *init;
94 vi_get_info_t *get_info;
95 vi_query_mode_t *query_mode;
96 vi_set_mode_t *set_mode;
97 vi_save_font_t *save_font;
98 vi_load_font_t *load_font;
99 vi_show_font_t *show_font;
100 vi_save_palette_t *save_palette;
101 vi_load_palette_t *load_palette;
102 vi_set_border_t *set_border;
103 vi_save_state_t *save_state;
104 vi_load_state_t *load_state;
105 vi_set_win_org_t *set_win_org;
106 vi_read_hw_cursor_t *read_hw_cursor;
107 vi_set_hw_cursor_t *set_hw_cursor;
108 vi_set_hw_cursor_shape_t *set_hw_cursor_shape;
109 vi_blank_display_t *blank_display;
110 vi_mmap_t *mmap;
111 vi_ioctl_t *ioctl;
112 vi_clear_t *clear;
113 vi_fill_rect_t *fill_rect;
114 vi_bitblt_t *bitblt;
115 int (*reserved1)(void);
116 int (*reserved2)(void);
117 vi_diag_t *diag;
118} video_switch_t;
119
120#define save_palette(adp, pal) \
121 (*vidsw[(adp)->va_index]->save_palette)((adp), (pal))
122#define load_palette(adp, pal) \
123 (*vidsw[(adp)->va_index]->load_palette)((adp), (pal))
124#define get_mode_info(adp, mode, buf) \
125 (*vidsw[(adp)->va_index]->get_info)((adp), (mode), (buf))
126#define set_video_mode(adp, mode) \
127 (*vidsw[(adp)->va_index]->set_mode)((adp), (mode))
128#if 0 /* XXX conflicts with syscons' set_border() */
129#define set_border(adp, border) \
130 (*vidsw[(adp)->va_index]->set_border)((adp), (border))
131#endif
132#define set_origin(adp, o) \
133 (*vidsw[(adp)->va_index]->set_win_org)(adp, o)
134
135/* XXX - add more macros */
136
137/* video driver */
138typedef struct video_driver {
139 char *name;
140 video_switch_t *vidsw;
141 int (*configure)(int); /* backdoor for the console driver */
142} video_driver_t;
143
144#define VIDEO_DRIVER(name, sw, config) \
145 static struct video_driver name##_driver = { \
146 #name, &sw, config \
147 }; \
148 DATA_SET(videodriver_set, name##_driver);
149
150/* global variables */
151extern struct video_switch **vidsw;
152extern struct linker_set videodriver_set;
153
154/* functions for the video card driver */
155int vid_register(video_adapter_t *adp);
156int vid_unregister(video_adapter_t *adp);
157video_switch_t *vid_get_switch(char *name);
158void vid_init_struct(video_adapter_t *adp, char *name, int type,
159 int unit);
160
161/* functions for the video card client */
162int vid_allocate(char *driver, int unit, void *id);
163int vid_release(video_adapter_t *adp, void *id);
164int vid_find_adapter(char *driver, int unit);
165video_adapter_t *vid_get_adapter(int index);
166
167/* a backdoor for the console driver to tickle the video driver XXX */
168int vid_configure(int flags);
169#define VIO_PROBE_ONLY (1 << 0) /* probe only, don't initialize */
170
171#ifdef FB_INSTALL_CDEV
172
173/* virtual frame buffer driver functions */
174int fb_attach(dev_t dev, video_adapter_t *adp,
175 struct cdevsw *cdevsw);
176int fb_detach(dev_t dev, video_adapter_t *adp,
177 struct cdevsw *cdevsw);
178
179/* generic frame buffer cdev driver functions */
180
181typedef struct genfb_softc {
182 int gfb_flags; /* flag/status bits */
183#define FB_OPEN (1 << 0)
184} genfb_softc_t;
185
186int genfbopen(genfb_softc_t *sc, video_adapter_t *adp,
187 int flag, int mode, struct thread *td);
188int genfbclose(genfb_softc_t *sc, video_adapter_t *adp,
189 int flag, int mode, struct thread *td);
190int genfbread(genfb_softc_t *sc, video_adapter_t *adp,
191 struct uio *uio, int flag);
192int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp,
193 struct uio *uio, int flag);
194int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp,
195 u_long cmd, caddr_t arg, int flag, struct thread *td);
196int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp,
197 vm_offset_t offset, int prot);
198
199#endif /* FB_INSTALL_CDEV */
200
201/* generic low-level driver functions */
202
203void fb_dump_adp_info(char *driver, video_adapter_t *adp, int level);
204void fb_dump_mode_info(char *driver, video_adapter_t *adp,
205 video_info_t *info, int level);
206int fb_type(int adp_type);
207int fb_commonioctl(video_adapter_t *adp, u_long cmd, caddr_t arg);
208
209#endif /* _KERNEL */
210
211#endif /* !_DEV_FB_FBREG_H_ */