1 /* Copyright (c) 1993, 1996, Oracle and/or its affiliates. All rights reserved.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
25 * cmap_grab.h - colormap grabber structures and information
35 * Colormap grabber header file.
39 * Macros defined here:
43 * lock and unlock colormap info page. 'infop' is the Grabbedcmap
44 * pointer returned by cmapgrab_grab()
46 * sh_cmapgrab_cookie(infop)
47 * returns the colormap info page cookie used to map the info page.
48 * this is the value that should be returned to the requesting
54 #include <sys/types.h>
60 #include "dga_internal.h"
63 /* method to use to load colormaps */
66 SUNWINDOWS_IOCTL
=0, /* use /dev/winxx SunWindows device driver */
67 HW_DEVICE_IOCTL
=1, /* use graphics hardware device driver */
68 HW_DEVICE_DIRECT
=2 /* access hardware colormap directly */
72 #define CMMAGIC 0x434d4150 /* "CMAP" */
75 #define MAX_CM_DEVNAME 40 /* better not have long device names */
76 #define DGA_CM_DEV_INFO_SZ 132
78 /* device types, from sh_scr_dev.h */
80 #define SCR_DEV_GENERIC 0 /* generic class implementations */
81 #define SCR_DEV_MEM1 1 /* depth 1 memory framebuffer */
82 #define SCR_DEV_MEM8 2 /* depth 8 memory framebuffer */
83 #define SCR_DEV_MEM32 3 /* depth 32 memory framebuffer */
85 #define SCR_DEV_CG2 4 /* Sun CG2 framebuffer (depth 8) */
86 #define SCR_DEV_BW2 5 /* Sun BW2 framebuffer (depth 1) */
87 #define SCR_DEV_CG4 6 /* Sun CG4 framebuffer (1 or 8) */
88 #define SCR_DEV_CG6 7 /* Sun CG6 (Lego) */
89 #define SCR_DEV_CG3 8 /* Sun CG3 (Color RoadRunner) */
90 #define SCR_DEV_GPFB 9 /* GP1/GP+/GP2 framebuffer (depth 8) */
91 #define SCR_DEV_GP 10 /* GP1/GP+/GP2 accelerator */
92 #define SCR_DEV_CG5 11 /* Sun CG5 framebuffer (depth 8) */
93 #define SCR_DEV_CG8 12 /* Sun CG8 framebuffer (depth 8, 24 bit color)*/
94 #define SCR_DEV_GT 13 /* Sun GT (Hawk) depth 1, 8, and 24 bit */
95 #define SCR_DEV_CG12 14 /* Sun CG12 (Egret) depth 1, 8, and 24 bit */
96 #define SCR_DEV_REC 15 /* Recording device type */
97 #define SCR_DEV_SMC 16 /* Sun SMC/MDI (SPAM) depth 1, 8, 24-bit */
99 #define SCR_DEV_LAST 16
102 /* info in shared memory */
104 typedef struct _grabbedcmap
106 /* version 0 info starts here */
107 long cm_magic
; /* "CMAP" = 0x434d4150 ("PAMC" on 386i) */
108 long cm_version
; /* 0 */
109 int cm_count
; /* change count */
110 struct _grabbedcmap
*cm_ptr
; /* self-reference */
111 u_long cm_cmap
; /* X11 colormap ID */
113 u_long cm_cookie
; /* lock-page cookie */
115 /* server-specific info, not meaningful to client */
119 u_long
*cm_sunlockp
;
125 char cm_devname
[MAX_CM_DEVNAME
] ;
126 char cm_lockdevname
[MAX_CM_DEVNAME
] ;
127 int cm_default
; /* is it the default colormap for this screen */
128 int cm_installed
; /* flag: colormap is installed in HW */
129 cmap_load_method cm_load_method
; /* see typedef above */
130 char cm_sunwindows_def_devname
[MAX_CM_DEVNAME
] ; /* device name, */
131 char cm_sunwindows_def_cmapname
[MAX_CM_DEVNAME
] ;/* cmap name, and */
132 int cm_sunwindows_def_cmapsize
; /* size of server's SunWindows
133 color map "xnews_default" */
134 char cm_sunwindows_inst_devname
[MAX_CM_DEVNAME
] ; /* device name, */
135 char cm_sunwindows_inst_cmapname
[MAX_CM_DEVNAME
];/* cmap name, and */
136 int cm_sunwindows_inst_cmapsize
; /* size of server's SunWindows
137 color map "xnews_installed" */
138 int cm_fbtype
; /* reserved */
139 int cm_reallen
; /* colormap hardware size */
140 int cm_start
; /* first valid location */
141 int cm_len
; /* number of valid locations */
142 int cm_cmapnum
; /* [0]cmap number - FB's with multiple maps */
143 int cm_ioctlbits
; /* [0]high-order bits for FBIOPUTCMAP */
144 int cm_devtype
; /* device hardware type */
145 int cm_reserved
[5] ;/* reserved */
147 long cm_shadowofs
; /* byte offset relative to cm_magic of
148 the start of the shadow colormap */
150 /* version 1 info starts here */
151 int cm_scount
; /* server's last remembered count */
152 int cm_locktype
; /* using /dev/winlock? see below. */
154 /* version 2 info starts here */
155 u_int device_offset
; /* offset to device specific section */
157 /* Do NOT add any fields below dev_info */
158 u_char dev_info
[DGA_CM_DEV_INFO_SZ
];/* device specific information */
162 /* followed by three arrays of u_shorts, length cm_len, for
163 red, green and blue and one array of bytes which are
164 the change flags for their respective colors:
183 Clients set a flag to non-zero to indicate that the color
184 has been changed. The server clears these when the chagnes
187 #define CM_LOCKDEV 0 /* use GRABPAGEALLOC from device */
188 #define CM_WINLOCK 1 /* use winlock functions */
193 typedef struct cmap_devlist
{
196 char devname
[MAX_CM_DEVNAME
];
197 struct cmap_devlist
*next
;
201 #define CM_PAGESZ (8*1024)
202 #define CM_LOCK(x) (*(x)) = 1
203 #define CM_UNLOCK(x) (*(x)) = 0
206 #define wx_cm_lock(infop) \
208 if( (infop)->cm_lockcnt++ == 0 ) \
209 *(infop)->cm_lockp = 1 ; \
212 #define wx_cm_unlock(infop) \
214 if( --(infop)->cm_lockcnt == 0 ) \
215 *(infop)->cm_unlockp = 0 ; \
219 #define CM_INFOP(clientp) ((Grabbedcmap *) ((clientp)->cm_info))
221 Dga_cmap
wx_cm_grab() ;
223 #endif /* _CMAP_GRAB_H */