kernel - Add lock debugging
[dragonfly.git] / sys / sys / fbio.h
1 /*
2  * Copyright (c) 1992, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software developed by the Computer Systems
6  * Engineering group at Lawrence Berkeley Laboratory under DARPA
7  * contract BG 91-66 and contributed to Berkeley.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      @(#)fbio.h      8.2 (Berkeley) 10/30/93
34  *
35  * $FreeBSD: src/sys/sys/fbio.h,v 1.9.2.1 2000/05/05 09:16:16 nyan Exp $
36  */
37
38 #ifndef _SYS_FBIO_H_
39 #define _SYS_FBIO_H_
40
41 #ifndef _SYS_TYPES_H_
42 #include <sys/types.h>
43 #endif
44 #ifndef _SYS_IOCCOM_H_
45 #include <sys/ioccom.h>
46 #endif
47
48 /*
49  * Frame buffer ioctls (from Sprite, trimmed to essentials for X11).
50  */
51
52 /*
53  * Frame buffer type codes.
54  */
55 #define FBTYPE_SUN1BW           0       /* multibus mono */
56 #define FBTYPE_SUN1COLOR        1       /* multibus color */
57 #define FBTYPE_SUN2BW           2       /* memory mono */
58 #define FBTYPE_SUN2COLOR        3       /* color w/rasterop chips */
59 #define FBTYPE_SUN2GP           4       /* GP1/GP2 */
60 #define FBTYPE_SUN5COLOR        5       /* RoadRunner accelerator */
61 #define FBTYPE_SUN3COLOR        6       /* memory color */
62 #define FBTYPE_MEMCOLOR         7       /* memory 24-bit */
63 #define FBTYPE_SUN4COLOR        8       /* memory color w/overlay */
64
65 #define FBTYPE_NOTSUN1          9       /* reserved for customer */
66 #define FBTYPE_NOTSUN2          10      /* reserved for customer */
67 #define FBTYPE_NOTSUN3          11      /* reserved for customer */
68
69 #define FBTYPE_SUNFAST_COLOR    12      /* accelerated 8bit */
70 #define FBTYPE_SUNROP_COLOR     13      /* MEMCOLOR with rop h/w */
71 #define FBTYPE_SUNFB_VIDEO      14      /* Simple video mixing */
72 #define FBTYPE_RESERVED5        15      /* reserved, do not use */
73 #define FBTYPE_RESERVED4        16      /* reserved, do not use */
74 #define FBTYPE_RESERVED3        17      /* reserved, do not use */
75 #define FBTYPE_RESERVED2        18      /* reserved, do not use */
76 #define FBTYPE_RESERVED1        19      /* reserved, do not use */
77
78 #define FBTYPE_MDA              20
79 #define FBTYPE_HERCULES         21
80 #define FBTYPE_CGA              22
81 #define FBTYPE_EGA              23
82 #define FBTYPE_VGA              24
83 #define FBTYPE_TGA              26
84
85 #define FBTYPE_LASTPLUSONE      27      /* max number of fbs (change as add) */
86
87 /*
88  * Frame buffer descriptor as returned by FBIOGTYPE.
89  */
90 struct fbtype {
91         int     fb_type;        /* as defined above */
92         int     fb_height;      /* in pixels */
93         int     fb_width;       /* in pixels */
94         int     fb_depth;       /* bits per pixel */
95         int     fb_cmsize;      /* size of color map (entries) */
96         int     fb_size;        /* total size in bytes */
97 };
98 #define FBIOGTYPE       _IOR('F', 0, struct fbtype)
99
100 #ifdef notdef
101 /*
102  * General purpose structure for passing info in and out of frame buffers
103  * (used for gp1) -- unsupported.
104  */
105 struct fbinfo {
106         int     fb_physaddr;    /* physical frame buffer address */
107         int     fb_hwwidth;     /* fb board width */
108         int     fb_hwheight;    /* fb board height */
109         int     fb_addrdelta;   /* phys addr diff between boards */
110         u_char  *fb_ropaddr;    /* fb virtual addr */
111         int     fb_unit;        /* minor devnum of fb */
112 };
113 #define FBIOGINFO       _IOR('F', 2, struct fbinfo)
114 #endif
115
116 /*
117  * Color map I/O.
118  */
119 struct fbcmap {
120         int     index;          /* first element (0 origin) */
121         int     count;          /* number of elements */
122         u_char  *red;           /* red color map elements */
123         u_char  *green;         /* green color map elements */
124         u_char  *blue;          /* blue color map elements */
125 };
126 #define FBIOPUTCMAP     _IOW('F', 3, struct fbcmap)
127 #define FBIOGETCMAP     _IOW('F', 4, struct fbcmap)
128
129 /*
130  * Set/get attributes.
131  */
132 #define FB_ATTR_NDEVSPECIFIC    8       /* no. of device specific values */
133 #define FB_ATTR_NEMUTYPES       4       /* no. of emulation types */
134
135 struct fbsattr {
136         int     flags;                  /* flags; see below */
137         int     emu_type;               /* emulation type (-1 if unused) */
138         int     dev_specific[FB_ATTR_NDEVSPECIFIC];     /* catchall */
139 };
140 #define FB_ATTR_AUTOINIT        1       /* emulation auto init flag */
141 #define FB_ATTR_DEVSPECIFIC     2       /* dev. specific stuff valid flag */
142
143 struct fbgattr {
144         int     real_type;              /* real device type */
145         int     owner;                  /* PID of owner, 0 if myself */
146         struct  fbtype fbtype;          /* fbtype info for real device */
147         struct  fbsattr sattr;          /* see above */
148         int     emu_types[FB_ATTR_NEMUTYPES];   /* possible emulations */
149                                                 /* (-1 if unused) */
150 };
151 /*      FBIOSATTR       _IOW('F', 5, struct fbsattr) -- unsupported */
152 #define FBIOGATTR       _IOR('F', 6, struct fbgattr)
153
154 /*
155  * Video control.
156  */
157 #define FBVIDEO_OFF             0
158 #define FBVIDEO_ON              1
159
160 #define FBIOSVIDEO      _IOW('F', 7, int)
161 #define FBIOGVIDEO      _IOR('F', 8, int)
162
163 /*
164  * Hardware cursor control (for, e.g., CG6).  A rather complex and icky
165  * interface that smells like VMS, but there it is....
166  */
167 struct fbcurpos {
168         short   x;
169         short   y;
170 };
171
172 struct fbcursor {
173         short   set;            /* flags; see below */
174         short   enable;         /* nonzero => cursor on, 0 => cursor off */
175         struct  fbcurpos pos;   /* position on display */
176         struct  fbcurpos hot;   /* hot-spot within cursor */
177         struct  fbcmap cmap;    /* cursor color map */
178         struct  fbcurpos size;  /* number of valid bits in image & mask */
179         caddr_t image;          /* cursor image bits */
180         caddr_t mask;           /* cursor mask bits */
181 };
182 #define FB_CUR_SETCUR   0x01    /* set on/off (i.e., obey fbcursor.enable) */
183 #define FB_CUR_SETPOS   0x02    /* set position */
184 #define FB_CUR_SETHOT   0x04    /* set hot-spot */
185 #define FB_CUR_SETCMAP  0x08    /* set cursor color map */
186 #define FB_CUR_SETSHAPE 0x10    /* set size & bits */
187 #define FB_CUR_SETALL   (FB_CUR_SETCUR | FB_CUR_SETPOS | FB_CUR_SETHOT | \
188                          FB_CUR_SETCMAP | FB_CUR_SETSHAPE)
189
190 /* controls for cursor attributes & shape (including position) */
191 #define FBIOSCURSOR     _IOW('F', 24, struct fbcursor)
192 #define FBIOGCURSOR     _IOWR('F', 25, struct fbcursor)
193
194 /* controls for cursor position only */
195 #define FBIOSCURPOS     _IOW('F', 26, struct fbcurpos)
196 #define FBIOGCURPOS     _IOW('F', 27, struct fbcurpos)
197
198 /* get maximum cursor size */
199 #define FBIOGCURMAX     _IOR('F', 28, struct fbcurpos)
200
201 /* The new style frame buffer ioctls. */
202
203 /* video mode information block */
204 struct video_info {
205     int                 vi_mode;        /* mode number, see below */
206     int                 vi_flags;
207 #define V_INFO_COLOR    (1 << 0)
208 #define V_INFO_GRAPHICS (1 << 1)
209 #define V_INFO_LINEAR   (1 << 2)
210     int                 vi_width;
211     int                 vi_height;
212     int                 vi_cwidth;
213     int                 vi_cheight;
214     int                 vi_depth;
215     int                 vi_planes;
216     u_int               vi_window;      /* physical address */
217     size_t              vi_window_size;
218     size_t              vi_window_gran;
219     u_int               vi_buffer;      /* physical address */
220     size_t              vi_buffer_size;
221     int                 vi_mem_model;
222 #define V_INFO_MM_OTHER  (-1)
223 #define V_INFO_MM_TEXT   0
224 #define V_INFO_MM_PLANAR 1
225 #define V_INFO_MM_PACKED 2
226 #define V_INFO_MM_DIRECT 3
227 #define V_INFO_MM_CGA    100
228 #define V_INFO_MM_HGC    101
229 #define V_INFO_MM_VGAX   102
230     /* for MM_PACKED and MM_DIRECT only */
231     int                 vi_pixel_size;  /* in bytes */
232     /* for MM_DIRECT only */
233     int                 vi_pixel_fields[4];     /* RGB and reserved fields */
234     int                 vi_pixel_fsizes[4];
235     /* reserved */
236     u_char              vi_reserved[64];
237 };
238 typedef struct video_info video_info_t;
239
240 /* adapter infromation block */
241 struct video_adapter {
242     int                 va_index;
243     int                 va_type;
244 #define KD_OTHER        0               /* unknown */
245 #define KD_MONO         1               /* monochrome adapter */
246 #define KD_HERCULES     2               /* hercules adapter */
247 #define KD_CGA          3               /* color graphics adapter */
248 #define KD_EGA          4               /* enhanced graphics adapter */
249 #define KD_VGA          5               /* video graphics adapter */
250 #define KD_TGA          7               /* TGA */
251     char                *va_name;
252     int                 va_unit;
253     int                 va_minor;
254     int                 va_flags;
255 #define V_ADP_COLOR     (1 << 0)
256 #define V_ADP_MODECHANGE (1 << 1)
257 #define V_ADP_STATESAVE (1 << 2)
258 #define V_ADP_STATELOAD (1 << 3)
259 #define V_ADP_FONT      (1 << 4)
260 #define V_ADP_PALETTE   (1 << 5)
261 #define V_ADP_BORDER    (1 << 6)
262 #define V_ADP_PROBED    (1 << 16)
263 #define V_ADP_INITIALIZED (1 << 17)
264 #define V_ADP_REGISTERED (1 << 18)
265     int                 va_io_base;
266     int                 va_io_size;
267     int                 va_mem_base;
268     int                 va_mem_size;
269     vm_offset_t         va_window;      /* virtual address */
270     size_t              va_window_size;
271     size_t              va_window_gran;
272     u_int               va_window_orig;
273     vm_offset_t         va_buffer;      /* virtual address */
274     size_t              va_buffer_size;
275     int                 va_initial_mode;
276     int                 va_initial_bios_mode;
277     int                 va_mode;
278     u_char              va_palette_regs[16];
279     struct video_info   va_info;
280     int                 va_line_width;
281     struct {
282         int             x;
283         int             y;
284     }                   va_disp_start;
285     void                *va_token;
286 };
287 typedef struct video_adapter video_adapter_t;
288
289 struct video_adapter_info {
290     int                 va_index;
291     int                 va_type;
292     char                va_name[16];
293     int                 va_unit;
294     int                 va_flags;
295     int                 va_io_base;
296     int                 va_io_size;
297     int                 va_mem_base;
298     int                 va_mem_size;
299     u_int               va_window;      /* virtual address */
300     size_t              va_window_size;
301     size_t              va_window_gran;
302     u_int               va_unused0;
303     size_t              va_buffer_size;
304     int                 va_initial_mode;
305     int                 va_initial_bios_mode;
306     int                 va_mode;
307     int                 va_line_width;
308     struct {
309         int             x;
310         int             y;
311     }                   va_disp_start;
312     u_int               va_window_orig;
313     /* reserved */
314     u_char              va_reserved[64];
315 };
316 typedef struct video_adapter_info video_adapter_info_t;
317
318 /* video mode numbers */
319
320 #define M_B40x25        0       /* black & white 40 columns */
321 #define M_C40x25        1       /* color 40 columns */
322 #define M_B80x25        2       /* black & white 80 columns */
323 #define M_C80x25        3       /* color 80 columns */
324 #define M_BG320         4       /* black & white graphics 320x200 */
325 #define M_CG320         5       /* color graphics 320x200 */
326 #define M_BG640         6       /* black & white graphics 640x200 hi-res */
327 #define M_EGAMONO80x25  7       /* ega-mono 80x25 */
328 #define M_CG320_D       13      /* ega mode D */
329 #define M_CG640_E       14      /* ega mode E */
330 #define M_EGAMONOAPA    15      /* ega mode F */
331 #define M_CG640x350     16      /* ega mode 10 */
332 #define M_ENHMONOAPA2   17      /* ega mode F with extended memory */
333 #define M_ENH_CG640     18      /* ega mode 10* */
334 #define M_ENH_B40x25    19      /* ega enhanced black & white 40 columns */
335 #define M_ENH_C40x25    20      /* ega enhanced color 40 columns */
336 #define M_ENH_B80x25    21      /* ega enhanced black & white 80 columns */
337 #define M_ENH_C80x25    22      /* ega enhanced color 80 columns */
338 #define M_VGA_C40x25    23      /* vga 8x16 font on color */
339 #define M_VGA_C80x25    24      /* vga 8x16 font on color */
340 #define M_VGA_M80x25    25      /* vga 8x16 font on mono */
341
342 #define M_VGA11         26      /* vga 640x480 2 colors */
343 #define M_BG640x480     26
344 #define M_VGA12         27      /* vga 640x480 16 colors */
345 #define M_CG640x480     27
346 #define M_VGA13         28      /* vga 320x200 256 colors */
347 #define M_VGA_CG320     28
348
349 #define M_VGA_C80x50    30      /* vga 8x8 font on color */
350 #define M_VGA_M80x50    31      /* vga 8x8 font on color */
351 #define M_VGA_C80x30    32      /* vga 8x16 font on color */
352 #define M_VGA_M80x30    33      /* vga 8x16 font on color */
353 #define M_VGA_C80x60    34      /* vga 8x8 font on color */
354 #define M_VGA_M80x60    35      /* vga 8x8 font on color */
355 #define M_VGA_CG640     36      /* vga 640x400 256 color */
356 #define M_VGA_MODEX     37      /* vga 320x240 256 color */
357
358 #define M_VGA_C90x25    40      /* vga 8x16 font on color */
359 #define M_VGA_M90x25    41      /* vga 8x16 font on mono */
360 #define M_VGA_C90x30    42      /* vga 8x16 font on color */
361 #define M_VGA_M90x30    43      /* vga 8x16 font on mono */
362 #define M_VGA_C90x43    44      /* vga 8x8 font on color */
363 #define M_VGA_M90x43    45      /* vga 8x8 font on mono */
364 #define M_VGA_C90x50    46      /* vga 8x8 font on color */
365 #define M_VGA_M90x50    47      /* vga 8x8 font on mono */
366 #define M_VGA_C90x60    48      /* vga 8x8 font on color */
367 #define M_VGA_M90x60    49      /* vga 8x8 font on mono */
368
369 #define M_ENH_B80x43    0x70    /* ega black & white 80x43 */
370 #define M_ENH_C80x43    0x71    /* ega color 80x43 */
371
372 #define M_HGC_P0        0xe0    /* hercules graphics - page 0 @ B0000 */
373 #define M_HGC_P1        0xe1    /* hercules graphics - page 1 @ B8000 */
374 #define M_MCA_MODE      0xff    /* monochrome adapter mode */
375
376 struct video_display_start {
377         int             x;
378         int             y;
379 };
380 typedef struct video_display_start video_display_start_t;
381
382 struct video_color_palette {
383         int             index;          /* first element (zero-based) */
384         int             count;          /* number of elements */
385         u_char          *red;           /* red */
386         u_char          *green;         /* green */
387         u_char          *blue;          /* blue */
388         u_char          *transparent;   /* may be NULL */
389 };
390 typedef struct video_color_palette video_color_palette_t;
391
392 /* adapter info. */
393 #define FBIO_ADAPTER    _IOR('F', 100, int)
394 #define FBIO_ADPTYPE    _IOR('F', 101, int)
395 #define FBIO_ADPINFO    _IOR('F', 102, struct video_adapter_info)
396
397 /* video mode control */
398 #define FBIO_MODEINFO   _IOWR('F', 103, struct video_info)
399 #define FBIO_FINDMODE   _IOWR('F', 104, struct video_info)
400 #define FBIO_GETMODE    _IOR('F', 105, int)
401 #define FBIO_SETMODE    _IOW('F', 106, int)
402
403 /* get/set frame buffer window origin */
404 #define FBIO_GETWINORG  _IOR('F', 107, u_int)
405 #define FBIO_SETWINORG  _IOW('F', 108, u_int)
406
407 /* get/set display start address */
408 #define FBIO_GETDISPSTART       _IOR('F', 109, video_display_start_t) 
409 #define FBIO_SETDISPSTART       _IOW('F', 110, video_display_start_t)
410
411 /* get/set scan line width */
412 #define FBIO_GETLINEWIDTH       _IOR('F', 111, u_int) 
413 #define FBIO_SETLINEWIDTH       _IOW('F', 112, u_int)
414
415 /* color palette control */
416 #define FBIO_GETPALETTE _IOW('F', 113, video_color_palette_t)
417 #define FBIO_SETPALETTE _IOW('F', 114, video_color_palette_t)
418
419 #endif /* !_SYS_FBIO_H_ */