943N/A/* Copyright (c) 1993, 1996, Oracle and/or its affiliates. All rights reserved.
830N/A *
830N/A * Permission is hereby granted, free of charge, to any person obtaining a
919N/A * copy of this software and associated documentation files (the "Software"),
919N/A * to deal in the Software without restriction, including without limitation
919N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A * and/or sell copies of the Software, and to permit persons to whom the
919N/A * Software is furnished to do so, subject to the following conditions:
830N/A *
919N/A * The above copyright notice and this permission notice (including the next
919N/A * paragraph) shall be included in all copies or substantial portions of the
919N/A * Software.
830N/A *
919N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919N/A * DEALINGS IN THE SOFTWARE.
830N/A */
830N/A
830N/A
830N/A/*
830N/A * cmap_grab.h - colormap grabber structures and information
830N/A */
830N/A
830N/A#ifndef _CMAP_GRAB_H
830N/A#define _CMAP_GRAB_H
830N/A
830N/A
830N/A
830N/A/****
830N/A *
830N/A * Colormap grabber header file.
830N/A *
830N/A *
830N/A *
830N/A * Macros defined here:
830N/A *
830N/A * sh_cm_lock(infop)
830N/A * sh_cm_unlock(infop)
830N/A * lock and unlock colormap info page. 'infop' is the Grabbedcmap
830N/A * pointer returned by cmapgrab_grab()
830N/A *
830N/A * sh_cmapgrab_cookie(infop)
830N/A * returns the colormap info page cookie used to map the info page.
830N/A * this is the value that should be returned to the requesting
830N/A * client.
830N/A *
830N/A ****/
830N/A
830N/A
830N/A#include <sys/types.h>
830N/A#ifdef MT
830N/A#include <synch.h>
830N/A#endif
830N/A
830N/A#include "dga.h"
830N/A#include "dga_internal.h"
830N/A
830N/A
830N/A/* method to use to load colormaps */
830N/A
830N/Atypedef enum {
830N/A SUNWINDOWS_IOCTL=0, /* use /dev/winxx SunWindows device driver */
830N/A HW_DEVICE_IOCTL=1, /* use graphics hardware device driver */
830N/A HW_DEVICE_DIRECT=2 /* access hardware colormap directly */
830N/A} cmap_load_method;
830N/A
830N/A
830N/A#define CMMAGIC 0x434d4150 /* "CMAP" */
830N/A#define CMVERS 0
830N/A
830N/A#define MAX_CM_DEVNAME 40 /* better not have long device names */
830N/A#define DGA_CM_DEV_INFO_SZ 132
830N/A
830N/A /* device types, from sh_scr_dev.h */
830N/A
830N/A#define SCR_DEV_GENERIC 0 /* generic class implementations */
830N/A#define SCR_DEV_MEM1 1 /* depth 1 memory framebuffer */
830N/A#define SCR_DEV_MEM8 2 /* depth 8 memory framebuffer */
830N/A#define SCR_DEV_MEM32 3 /* depth 32 memory framebuffer */
830N/A
830N/A#define SCR_DEV_CG2 4 /* Sun CG2 framebuffer (depth 8) */
830N/A#define SCR_DEV_BW2 5 /* Sun BW2 framebuffer (depth 1) */
830N/A#define SCR_DEV_CG4 6 /* Sun CG4 framebuffer (1 or 8) */
830N/A#define SCR_DEV_CG6 7 /* Sun CG6 (Lego) */
830N/A#define SCR_DEV_CG3 8 /* Sun CG3 (Color RoadRunner) */
830N/A#define SCR_DEV_GPFB 9 /* GP1/GP+/GP2 framebuffer (depth 8) */
830N/A#define SCR_DEV_GP 10 /* GP1/GP+/GP2 accelerator */
830N/A#define SCR_DEV_CG5 11 /* Sun CG5 framebuffer (depth 8) */
830N/A#define SCR_DEV_CG8 12 /* Sun CG8 framebuffer (depth 8, 24 bit color)*/
830N/A#define SCR_DEV_GT 13 /* Sun GT (Hawk) depth 1, 8, and 24 bit */
830N/A#define SCR_DEV_CG12 14 /* Sun CG12 (Egret) depth 1, 8, and 24 bit */
830N/A#define SCR_DEV_REC 15 /* Recording device type */
830N/A#define SCR_DEV_SMC 16 /* Sun SMC/MDI (SPAM) depth 1, 8, 24-bit */
830N/A
830N/A#define SCR_DEV_LAST 16
830N/A
830N/A
830N/A/* info in shared memory */
830N/A
830N/Atypedef struct _grabbedcmap
830N/A{
830N/A /* version 0 info starts here */
830N/A long cm_magic ; /* "CMAP" = 0x434d4150 ("PAMC" on 386i) */
830N/A long cm_version ; /* 0 */
830N/A int cm_count ; /* change count */
830N/A struct _grabbedcmap *cm_ptr ; /* self-reference */
830N/A u_long cm_cmap ; /* X11 colormap ID */
830N/A
830N/A u_long cm_cookie ; /* lock-page cookie */
830N/A
830N/A /* server-specific info, not meaningful to client */
830N/A int cm_sinfofd ;
830N/A int cm_sdevfd ;
830N/A u_long *cm_slockp ;
830N/A u_long *cm_sunlockp ;
830N/A int cm_slockcnt ;
830N/A int cm_clientcnt ;
830N/A int cm_filesuffix ;
830N/A caddr_t cm_shras ;
830N/A
830N/A char cm_devname[MAX_CM_DEVNAME] ;
830N/A char cm_lockdevname[MAX_CM_DEVNAME] ;
830N/A int cm_default ; /* is it the default colormap for this screen */
830N/A int cm_installed ; /* flag: colormap is installed in HW */
830N/A cmap_load_method cm_load_method ; /* see typedef above */
830N/A char cm_sunwindows_def_devname[MAX_CM_DEVNAME] ; /* device name, */
830N/A char cm_sunwindows_def_cmapname[MAX_CM_DEVNAME] ;/* cmap name, and */
830N/A int cm_sunwindows_def_cmapsize; /* size of server's SunWindows
830N/A color map "xnews_default" */
830N/A char cm_sunwindows_inst_devname[MAX_CM_DEVNAME] ; /* device name, */
830N/A char cm_sunwindows_inst_cmapname[MAX_CM_DEVNAME];/* cmap name, and */
830N/A int cm_sunwindows_inst_cmapsize; /* size of server's SunWindows
830N/A color map "xnews_installed" */
830N/A int cm_fbtype ; /* reserved */
830N/A int cm_reallen ; /* colormap hardware size */
830N/A int cm_start ; /* first valid location */
830N/A int cm_len ; /* number of valid locations */
830N/A int cm_cmapnum ; /* [0]cmap number - FB's with multiple maps */
830N/A int cm_ioctlbits ; /* [0]high-order bits for FBIOPUTCMAP */
830N/A int cm_devtype ; /* device hardware type */
830N/A int cm_reserved[5] ;/* reserved */
830N/A
830N/A long cm_shadowofs ; /* byte offset relative to cm_magic of
830N/A the start of the shadow colormap */
830N/A
830N/A /* version 1 info starts here */
830N/A int cm_scount ; /* server's last remembered count */
830N/A int cm_locktype ; /* using /dev/winlock? see below. */
830N/A
830N/A /* version 2 info starts here */
830N/A u_int device_offset; /* offset to device specific section */
830N/A
830N/A /* Do NOT add any fields below dev_info */
830N/A u_char dev_info[DGA_CM_DEV_INFO_SZ];/* device specific information */
830N/A} Grabbedcmap ;
830N/A
830N/A
830N/A /* followed by three arrays of u_shorts, length cm_len, for
830N/A red, green and blue and one array of bytes which are
830N/A the change flags for their respective colors:
830N/A
830N/A rr
830N/A rr
830N/A rr
830N/A :
830N/A gg
830N/A gg
830N/A gg
830N/A :
830N/A bb
830N/A bb
830N/A bb
830N/A :
830N/A f
830N/A f
830N/A f
830N/A :
830N/A
830N/A Clients set a flag to non-zero to indicate that the color
830N/A has been changed. The server clears these when the chagnes
830N/A have been seen. */
830N/A
830N/A#define CM_LOCKDEV 0 /* use GRABPAGEALLOC from device */
830N/A#define CM_WINLOCK 1 /* use winlock functions */
830N/A
830N/A
830N/A
830N/A
830N/Atypedef struct cmap_devlist{
830N/A int fd;
830N/A int refcnt;
830N/A char devname[MAX_CM_DEVNAME];
830N/A struct cmap_devlist *next;
830N/A} Cmap_Devlist;
830N/A
830N/A
830N/A#define CM_PAGESZ (8*1024)
830N/A#define CM_LOCK(x) (*(x)) = 1
830N/A#define CM_UNLOCK(x) (*(x)) = 0
830N/A
830N/A
830N/A#define wx_cm_lock(infop) \
830N/A do { \
830N/A if( (infop)->cm_lockcnt++ == 0 ) \
830N/A *(infop)->cm_lockp = 1 ; \
830N/A } while (0)
830N/A
830N/A#define wx_cm_unlock(infop) \
830N/A do { \
830N/A if( --(infop)->cm_lockcnt == 0 ) \
830N/A *(infop)->cm_unlockp = 0 ; \
830N/A } while (0)
830N/A
830N/A
830N/A#define CM_INFOP(clientp) ((Grabbedcmap *) ((clientp)->cm_info))
830N/A
830N/ADga_cmap wx_cm_grab() ;
830N/A
830N/A#endif /* _CMAP_GRAB_H */