xref: /illumos-gate/usr/src/uts/common/sys/fbio.h (revision 3b8e64428fecd54234c133286f9c0009ad8940b0)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1986,1997-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_FBIO_H
28 #define	_SYS_FBIO_H
29 
30 #include <sys/types.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifndef ASM
37 /*
38  * Frame buffer descriptor.
39  * Returned by FBIOGTYPE ioctl on frame buffer devices.
40  */
41 struct	fbtype {
42 	int	fb_type;	/* as defined below */
43 	int	fb_height;	/* in pixels */
44 	int	fb_width;	/* in pixels */
45 	int	fb_depth;	/* bits per pixel */
46 	int	fb_cmsize;	/* size of color map (entries) */
47 	int	fb_size;	/* total size in bytes */
48 };
49 
50 #define	FIOC		('F'<<8)
51 #define	FBIOGTYPE	(FIOC|0)
52 
53 #ifdef	_KERNEL
54 struct	fbpixrect {
55 	struct	pixrect *fbpr_pixrect;	/* Pixrect of dev returned here */
56 };
57 
58 #define	FBIOGPIXRECT	(FIOC|1)
59 #endif /* _KERNEL */
60 
61 /*
62  * General purpose structure for passing info in and out of frame buffers
63  * (used for gp1)
64  */
65 struct	fbinfo {
66 	int		fb_physaddr;	/* physical frame buffer address */
67 	int		fb_hwwidth;	/* fb board width */
68 	int		fb_hwheight;	/* fb board height */
69 	int		fb_addrdelta;	/* phys addr diff between boards */
70 	unsigned char	*fb_ropaddr;	/* fb va thru kernelmap */
71 	int		fb_unit;	/* minor devnum of fb */
72 };
73 
74 #define	FBIOGINFO	(FIOC|2)
75 
76 /*
77  * Color map I/O.  See also fbcmap_i below.
78  */
79 struct	fbcmap {
80 	int		index;		/* first element (0 origin) */
81 	int		count;		/* number of elements */
82 	unsigned char	*red;		/* red color map elements */
83 	unsigned char	*green;		/* green color map elements */
84 	unsigned char	*blue;		/* blue color map elements */
85 };
86 
87 #ifdef _SYSCALL32
88 
89 struct	fbcmap32 {
90 	int32_t		index;		/* first element (0 origin) */
91 	int32_t		count;		/* number of elements */
92 	caddr32_t	red;		/* red color map elements */
93 	caddr32_t	green;		/* green color map elements */
94 	caddr32_t	blue;		/* blue color map elements */
95 };
96 
97 #endif	/* _SYSCALL32 */
98 
99 #define	FBIOPUTCMAP	(FIOC|3)
100 #define	FBIOGETCMAP	(FIOC|4)
101 
102 /*
103  * Set/Get attributes
104  */
105 #define	FB_ATTR_NDEVSPECIFIC	8	/* no. of device specific values */
106 #define	FB_ATTR_NEMUTYPES	4	/* no. of emulation types */
107 
108 struct fbsattr {
109 	int	flags;			/* misc flags */
110 #define	FB_ATTR_AUTOINIT	1	/* emulation auto init flag */
111 #define	FB_ATTR_DEVSPECIFIC	2	/* dev. specific stuff valid flag */
112 	int	emu_type;		/* emulation type (-1 if unused) */
113 	int	dev_specific[FB_ATTR_NDEVSPECIFIC];	/* catchall */
114 };
115 
116 struct fbgattr {
117 	int	real_type;		/* real device type */
118 	int	owner;			/* PID of owner, 0 if myself */
119 	struct fbtype fbtype;		/* fbtype info for real device */
120 	struct fbsattr sattr;		/* see above */
121 	int	emu_types[FB_ATTR_NEMUTYPES];	/* possible emulations */
122 						/* (-1 if unused) */
123 };
124 
125 #define	FBIOSATTR	(FIOC|5)
126 #define	FBIOGATTR	(FIOC|6)
127 
128 
129 /*
130  * Video control
131  * (the unused bits are reserved for future use)
132  */
133 #define	FBVIDEO_OFF	0
134 #define	FBVIDEO_ON	1
135 
136 #define	FBIOSVIDEO	(FIOC|7)
137 #define	FBIOGVIDEO	(FIOC|8)
138 
139 /* Vertical retrace support. */
140 #define	FBIOVERTICAL	(FIOC|9)
141 #define	GRABPAGEALLOC	(FIOC|10)
142 #define	GRABPAGEFREE	(FIOC|11)
143 #define	GRABATTACH	(FIOC|12)
144 
145 #define	FBIOGPLNGRP	(FIOC|13)
146 #define	FBIOGCMSIZE	(FIOC|14)
147 #define	FBIOSCMSIZE	(FIOC|15)
148 #define	FBIOSCMS	(FIOC|16)
149 #define	FBIOAVAILPLNGRP (FIOC|17)
150 
151 
152 /*
153  * Structure to pass double buffering state back and forth the device.
154  */
155 
156 /* used in devstate */
157 #define	FBDBL_AVAIL	0x80000000
158 #define	FBDBL_DONT_BLOCK 0x40000000
159 #define	FBDBL_AVAIL_PG	0x20000000
160 
161 /* used in read/write/display */
162 #define	FBDBL_A	 0x1
163 #define	FBDBL_B	 0x2
164 #define	FBDBL_BOTH	(FBDBL_A | FBDBL_B)
165 #define	FBDBL_NONE	0x4
166 
167 struct fbdblinfo {
168 	unsigned int	dbl_devstate;
169 	unsigned int	dbl_read;
170 	unsigned int	dbl_write;
171 	unsigned int	dbl_display;
172 	int		dbl_depth;
173 	char		dbl_wid;
174 };
175 
176 #define	FBIODBLGINFO	(FIOC|18)
177 #define	FBIODBLSINFO	(FIOC|19)
178 
179 /* 8-bit emulation in 24-bit ioctls */
180 
181 #define	FBIOSWINFD	(FIOC|20)
182 #define	FBIOSAVWINFD	(FIOC|21)
183 #define	FBIORESWINFD	(FIOC|22)
184 #define	FBIOSRWINFD	(FIOC|23)
185 
186 /*
187  * hardware cursor control
188  */
189 
190 struct fbcurpos {
191 	short x, y;
192 };
193 
194 struct fbcursor {
195 	short set;		/* what to set */
196 #define	FB_CUR_SETCUR	0x01
197 #define	FB_CUR_SETPOS	0x02
198 #define	FB_CUR_SETHOT	0x04
199 #define	FB_CUR_SETCMAP	0x08
200 #define	FB_CUR_SETSHAPE 0x10
201 #define	FB_CUR_SETALL	0x1F
202 	short enable;		/* cursor on/off */
203 	struct fbcurpos pos;	/* cursor position */
204 	struct fbcurpos hot;	/* cursor hot spot */
205 	struct fbcmap cmap;	/* color map info */
206 	struct fbcurpos size;	/* cursor bit map size */
207 	char *image;		/* cursor image bits */
208 	char *mask;		/* cursor mask bits */
209 };
210 
211 #ifdef _SYSCALL32
212 struct fbcursor32 {
213 	short set;		/* what to set */
214 	short enable;		/* cursor on/off */
215 	struct fbcurpos pos;	/* cursor position */
216 	struct fbcurpos hot;	/* cursor hot spot */
217 	struct fbcmap32 cmap;	/* color map info */
218 	struct fbcurpos size;	/* cursor bit map size */
219 	caddr32_t image;	/* cursor image bits */
220 	caddr32_t mask;		/* cursor mask bits */
221 };
222 #endif	/* _SYSCALL32 */
223 
224 /* set/get cursor attributes/shape */
225 #define	FBIOSCURSOR	(FIOC|24)
226 #define	FBIOGCURSOR	(FIOC|25)
227 
228 /* set/get cursor position */
229 #define	FBIOSCURPOS	(FIOC|26)
230 #define	FBIOGCURPOS	(FIOC|27)
231 
232 /* get max cursor size */
233 #define	FBIOGCURMAX	(FIOC|28)
234 
235 /* Window Grabber info ioctl */
236 #define	GRABLOCKINFO	(FIOC|29)
237 
238 /*
239  * Window Identification (wid) defines, structures, and ioctls.
240  *
241  * Some wids need to be unique when used for things such as double
242  * buffering or rendering clipping.  Some wids can be shared when
243  * used for display attributes only.  What can be shared and how
244  * may be device dependent.  The fb_wid_alloc.wa_type and fb_wid_item
245  * structure members will be left to device specific interpretation.
246  */
247 
248 #define	FB_WID_SHARED_8		0
249 #define	FB_WID_SHARED_24	1
250 #define	FB_WID_DBL_8		2
251 #define	FB_WID_DBL_24		3
252 
253 struct fb_wid_alloc {
254 	unsigned int	wa_type;	/* special attributes		*/
255 	int		wa_index;	/* base wid returned		*/
256 	unsigned int	wa_count;	/* how many contiguous wids	*/
257 };
258 
259 struct fb_wid_item {
260 	unsigned int	wi_type;	/* special attributes		*/
261 	int		wi_index;	/* which lut			*/
262 	unsigned int	wi_attrs;	/* which attributes		*/
263 	unsigned int	wi_values[NBBY*sizeof (int)]; /* the attr values */
264 };
265 
266 struct fb_wid_list {
267 	unsigned int	wl_flags;
268 	unsigned int	wl_count;
269 	struct fb_wid_item	*wl_list;
270 };
271 
272 #ifdef _SYSCALL32
273 
274 struct fb_wid_list32 {
275 	uint32_t	wl_flags;
276 	uint32_t	wl_count;
277 	caddr32_t	wl_list;
278 };
279 
280 #endif /* _SYSCALL32 */
281 
282 struct fb_wid_dbl_info {
283 	struct fb_wid_alloc dbl_wid;
284 	char		dbl_fore;
285 	char		dbl_back;
286 	char		dbl_read_state;
287 	char		dbl_write_state;
288 };
289 
290 #define	FBIO_WID_ALLOC	(FIOC|30)
291 #define	FBIO_WID_FREE	(FIOC|31)
292 #define	FBIO_WID_PUT	(FIOC|32)
293 #define	FBIO_WID_GET	(FIOC|33)
294 
295 #define	FBIO_DEVID	(FIOC|34)
296 #define	FBIO_U_RST	(FIOC|35)
297 #define	FBIO_FULLSCREEN_ELIMINATION_GROUPS	(FIOC|36)
298 #define	FBIO_WID_DBL_SET	(FIOC|37)
299 #define	FBIOVRTOFFSET	(FIOC|38)
300 
301 struct gfxfb_info {
302 	uint16_t terminal_origin_x;
303 	uint16_t terminal_origin_y;
304 	uint32_t pitch;
305 	uint16_t font_width;
306 	uint16_t font_height;
307 	uint8_t red_mask_size;
308 	uint8_t red_field_position;
309 	uint8_t green_mask_size;
310 	uint8_t green_field_position;
311 	uint8_t blue_mask_size;
312 	uint8_t blue_field_position;
313 };
314 
315 struct cg6_info {
316 	ushort_t  accessible_width;	/* accessible bytes in scanline */
317 	ushort_t  accessible_height;	/* number of accessible scanlines */
318 	ushort_t  line_bytes;		/* number of bytes/scanline */
319 	ushort_t  hdb_capable;		/* can this thing hardware db? */
320 	ushort_t  vmsize;		/* this is Mb of video memory */
321 	uchar_t	  boardrev;		/* board revision # */
322 	uchar_t	  slot;			/* sbus slot # */
323 	uint_t	  pad1;			/* expansion */
324 };
325 
326 struct s3_info {
327 	ushort_t  accessible_width;	/* accessible bytes in scanline */
328 	ushort_t  accessible_height;	/* number of accessible scanlines */
329 	ushort_t  line_bytes;		/* number of bytes/scanline */
330 	ushort_t  hdb_capable;		/* can this thing hardware db? */
331 	ushort_t  vmsize;		/* this is Mb of video memory */
332 	uchar_t	  boardrev;		/* board revision # */
333 	uchar_t	  slot;			/* sbus slot # */
334 	uint_t	  pad1;			/* expansion */
335 };
336 
337 struct p9000_info {
338 	ushort_t  accessible_width;	/* accessible bytes in scanline */
339 	ushort_t  accessible_height;	/* number of accessible scanlines */
340 	ushort_t  line_bytes;		/* number of bytes/scanline */
341 	ushort_t  hdb_capable;		/* can this thing hardware db? */
342 	ushort_t  vmsize;		/* this is Mb of video memory */
343 	uchar_t	  boardrev;		/* board revision # */
344 	uchar_t	  slot;			/* sbus slot # */
345 	uint_t	  pad1;			/* expansion */
346 };
347 
348 struct p9100_info {
349 	ushort_t  accessible_width;	/* accessible bytes in scanline */
350 	ushort_t  accessible_height;	/* number of accessible scanlines */
351 	ushort_t  line_bytes;		/* number of bytes/scanline */
352 	ushort_t  hdb_capable;		/* can this thing hardware db? */
353 	ushort_t  vmsize;		/* this is Mb of video memory */
354 	uchar_t	  boardrev;		/* board revision # */
355 	uchar_t	  slot;			/* sbus slot # */
356 	uint_t	  pad1;			/* expansion */
357 };
358 
359 struct wd90c24a2_info {
360 	ushort_t  accessible_width;	/* accessible bytes in scanline */
361 	ushort_t  accessible_height;	/* number of accessible scanlines */
362 	ushort_t  line_bytes;		/* number of bytes/scanline */
363 	ushort_t  hdb_capable;		/* can this thing hardware db? */
364 	ushort_t  vmsize;		/* this is Mb of video memory */
365 	uchar_t	  boardrev;		/* board revision # */
366 	uchar_t	  slot;			/* sbus slot # */
367 	uint_t	  pad1;			/* expansion */
368 };
369 
370 #define	MON_TYPE_STEREO		0x8	/* stereo display */
371 #define	MON_TYPE_0_OFFSET	0x4	/* black level 0 ire instead of 7.5 */
372 #define	MON_TYPE_OVERSCAN	0x2	/* overscan */
373 #define	MON_TYPE_GRAY		0x1	/* greyscale monitor */
374 
375 struct mon_info {
376 	uint_t	  mon_type;		/* bit array: defined above */
377 	uint_t	  pixfreq;		/* pixel frequency in Hz */
378 	uint_t	  hfreq;		/* horizontal freq in Hz */
379 	uint_t	  vfreq;		/* vertical freq in Hz */
380 	uint_t	  vsync;		/* vertical sync in scanlines */
381 	uint_t	  hsync;		/* horizontal sync in pixels */
382 					/* these are in pixel units */
383 	ushort_t  hfporch;		/* horizontal front porch */
384 	ushort_t  hbporch;		/* horizontal back porch */
385 	ushort_t  vfporch;		/* vertical front porch */
386 	ushort_t  vbporch;		/* vertical back porch */
387 };
388 
389 
390 #define	FBIOGXINFO	(FIOC|39)
391 #define	FBIOMONINFO	(FIOC|40)
392 
393 /*
394  * Color map I/O.
395  */
396 struct	fbcmap_i {
397 	unsigned int	flags;		/* see below */
398 	int		id;		/* colormap id for multiple cmaps */
399 	int		index;		/* first element (0 origin) */
400 	int		count;		/* number of elements */
401 	unsigned char	*red;		/* red color map elements */
402 	unsigned char	*green;		/* green color map elements */
403 	unsigned char	*blue;		/* blue color map elements */
404 };
405 
406 #ifdef _SYSCALL32
407 
408 struct	fbcmap_i32 {
409 	uint32_t	flags;		/* see below */
410 	int32_t		id;		/* colormap id for multiple cmaps */
411 	int32_t		index;		/* first element (0 origin) */
412 	int32_t		count;		/* number of elements */
413 	caddr32_t	red;		/* red color map elements */
414 	caddr32_t	green;		/* green color map elements */
415 	caddr32_t	blue;		/* blue color map elements */
416 };
417 
418 #endif	/* _SYSCALL32 */
419 
420 #define	FB_CMAP_BLOCK	0x1	/* wait for vrt before returning */
421 #define	FB_CMAP_KERNEL	0x2	/* called within kernel */
422 
423 #define	FBIOPUTCMAPI	(FIOC|41)
424 #define	FBIOGETCMAPI	(FIOC|42)
425 
426 /* assigning a given window id to a pixrect - special for PHIGS */
427 #define	FBIO_ASSIGNWID	(FIOC|43)
428 
429 /* assigning a given window to be stereo */
430 #define	FBIO_STEREO	(FIOC|44)
431 #define	FB_WIN_STEREO	    0x2
432 
433 #endif	/* !ASM */
434 
435 /* frame buffer type codes */
436 #define	FBTYPE_NOTYPE		(-1)	/* for backwards compatibility */
437 #define	FBTYPE_SUN1BW		0	/* Multibus mono */
438 #define	FBTYPE_SUN1COLOR	1	/* Multibus color */
439 #define	FBTYPE_SUN2BW		2	/* memory mono */
440 #define	FBTYPE_SUN2COLOR	3	/* color w/rasterop chips */
441 #define	FBTYPE_SUN2GP		4	/* GP1/GP2 */
442 #define	FBTYPE_SUN5COLOR	5	/* RoadRunner accelerator */
443 #define	FBTYPE_SUN3COLOR	6	/* memory color */
444 #define	FBTYPE_MEMCOLOR		7	/* memory 24-bit */
445 #define	FBTYPE_SUN4COLOR	8	/* memory color w/overlay */
446 
447 #define	FBTYPE_NOTSUN1		9	/* reserved for customer */
448 #define	FBTYPE_NOTSUN2		10	/* reserved for customer */
449 #define	FBTYPE_NOTSUN3		11	/* reserved for customer */
450 
451 #define	FBTYPE_SUNFAST_COLOR	12	/* accelerated 8bit */
452 #define	FBTYPE_SUNROP_COLOR	13	/* MEMCOLOR with rop h/w */
453 #define	FBTYPE_SUNFB_VIDEO	14	/* Simple video mixing */
454 #define	FBTYPE_SUNGIFB		15	/* medical image */
455 #define	FBTYPE_SUNGPLAS		16	/* plasma panel */
456 #define	FBTYPE_SUNGP3		17	/* cg12 running gpsi microcode */
457 #define	FBTYPE_SUNGT		18	/* gt graphics accelerator */
458 #define	FBTYPE_SUNLEO		19	/* zx graphics accelerator */
459 #define	FBTYPE_MDICOLOR		20	/* cgfourteen framebuffer */
460 
461 #define	FBTYPE_LASTPLUSONE	21	/* max number of fbs (change as add) */
462 
463 #ifdef	__cplusplus
464 }
465 #endif
466 
467 #endif	/* _SYS_FBIO_H */
468