1/* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23#ifndef _IOKIT_IOFRAMEBUFFERSHARED_H 24#define _IOKIT_IOFRAMEBUFFERSHARED_H 25 26#include <IOKit/hidsystem/IOHIDTypes.h> 27#include <IOKit/graphics/IOGraphicsTypes.h> 28#include <libkern/OSAtomic.h> 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34/*! @header IOFramebufferShared 35The IOFramebufferShared.h header contains definitions of objects and types shared between a kernel level IOFrameBuffer service and a non-kernel window server. In Mac OS X this structure is used by the CoreGraphics server and IOGraphics Family, and is not available to other clients. IOFramebuffer subclasses and IOFramebuffer clients within the kernel should also not rely on this structure definition and constants. It is public only for use on Darwin based window servers. Cursor and window server state data is exchanged by kernel and non-kernel tasks through a slice of shared memory containing a StdFBShmem_t structure.<br> 36For a non-kernel task to get access to this slice of shared memory, a connection to an IOFramebuffer service must be made. A connection is made with the IOServiceOpen() function described in IOKitLib.h. A connection type of kIOFBServerConnectType or kIOFBSharedConnectType (for read-only access) should be specified. An io_connect_t handle is returned by IOServiceOpen(). This handle must be passed to IOFBCreateSharedCursor() to create the slice of shared memory. Then IOConnectMapMemory() may be called with a memory type of kIOFBCursorMemory to map the shared memory into the non-kernel task. 37*/ 38 39#ifdef KERNEL 40// CGS use optional 41/*! @defined IOFB_ARBITRARY_SIZE_CURSOR 42 @discussion When IOFB_ARBITRARY_SIZE_CURSOR is not defined, the maximum cursor size is assumed to be CURSORWIDTH x CURSORHEIGHT and this header file will define a number of structures for storing cursor images accordingly. A non-kernel task may define IOFB_ARBITRARY_SIZE_CURSOR and use cursors up to the size specified when IOFBCreateSharedCursor() was called. In this case appropriate structures for storing cursor images must be defined elsewhere. In the kernel, IOFB_ARBITRARY_SIZE_CURSOR is always defined. 43*/ 44#define IOFB_ARBITRARY_SIZE_CURSOR 45#define IOFB_ARBITRARY_FRAMES_CURSOR 1 46#endif 47 48#define IOFB_SUPPORTS_XOR_CURSOR 49#define IOFB_SUPPORTS_HW_SHIELD 50#define IOFB_SUPPORTS_ARBITRARY_FRAMES_CURSOR 51 52// 53// Cursor and Window Server state data, occupying a slice of shared memory 54// between the kernel and WindowServer. 55// 56/*! @enum CursorParameters 57 @constant kIOFBNumCursorFrames The number of cursor images stored in the StdFBShmem_t structure. 58 @constant kIOFBNumCursorFramesShift Used with waiting cursors. 59 @constant kIOFBMaxCursorDepth The maximum cursor pixel depth. 60*/ 61enum { 62#if IOFB_ARBITRARY_FRAMES_CURSOR 63 kIOFBMainCursorIndex = 0, 64 kIOFBWaitCursorIndex = 1, 65 kIOFBNumCursorIndex = 4, 66#else 67 kIOFBNumCursorFrames = 4, 68 kIOFBNumCursorFramesShift = 2, 69#endif 70 kIOFBMaxCursorDepth = 32 71}; 72 73#ifndef IOFB_ARBITRARY_SIZE_CURSOR 74 75/*! @defined CURSORWIDTH 76 @discussion The maximum width of the cursor image in pixels. This is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. 77*/ 78#define CURSORWIDTH 16 /* width in pixels */ 79 80/*! @defined CURSORHEIGHT 81 @discussion The maximum height of the cursor image in pixels. This is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. 82*/ 83#define CURSORHEIGHT 16 /* height in pixels */ 84 85/*! @struct bm12Cursor 86 @abstract Cursor image for 1-bit cursor. 87 @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 1-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. 88 @field image This array contains the cursor images. 89 @field mask This array contains the cursor mask. 90 @field save This array stores the pixel values of the region underneath the cursor in its last drawn position. 91*/ 92struct bm12Cursor { 93 unsigned int image[4][16]; 94 unsigned int mask[4][16]; 95 unsigned int save[16]; 96}; 97 98/*! @struct bm18Cursor 99 @abstract Cursor image for 8-bit cursor. 100 @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 8-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. 101 @field image This array contains cursor color values, which are converted to displayed colors through the color table. The array is two dimensional and its first index is the cursor frame and the second index is the cursor pixel. 102 @field mask This array contains the cursor alpha mask. The array is two dimensional with the same indexing as the image. If an alpha mask pixel is 0 and the corresponding image pixel is set to white for the display, then this cursor pixel will invert pixels on the display. 103 @field save This array stores the color values of the region underneath the cursor in its last drawn position. 104*/ 105struct bm18Cursor { 106 unsigned char image[4][256]; 107 unsigned char mask[4][256]; 108 unsigned char save[256]; 109}; 110 111/*! @struct bm34Cursor 112 @abstract Cursor image for 15-bit cursor. 113 @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 15-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. 114 @field image This array defines the cursor color values and transparency. The array is two dimensional and its first index is the cursor frame and the second index is the cursor pixel. A value of 0 means the pixel is transparent. Non-zero values are stored with the red, green, blue, and alpha values encoded with the following masks:<BR> 115 red mask = 0xF000<br> 116 blue mask 0x0F00<br> 117 green mask 0x00F0<br> 118 alpha mask = 0x000F<br> 119Note, only 4 bits are allocated for each color component. 120 @field save This array stores the color values of the region underneath the cursor in its last drawn position. 121*/ 122struct bm34Cursor { 123 unsigned short image[4][256]; 124 unsigned short save[256]; 125}; 126 127/*! @struct bm38Cursor 128 @abstract Cursor image for 24-bit cursor. 129 @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 24-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. 130 @field image This array defines the cursor color values and transparency. The array is two dimensional and its first index is the cursor frame and the second index is the cursor pixel. The lower 24 bits of a pixel's value contain the RGB color, while the upper 8 bits contain the alpha value. 131 @field save This array stores the color values of the region underneath the cursor in its last drawn position. 132*/ 133struct bm38Cursor { 134 unsigned int image[4][256]; 135 unsigned int save[256]; 136}; 137 138#endif /* IOFB_ARBITRARY_SIZE_CURSOR */ 139 140enum { 141 kIOFBCursorImageNew = 0x01, 142 kIOFBCursorHWCapable = 0x02 143}; 144enum { 145 kIOFBHardwareCursorActive = 0x01, 146 kIOFBHardwareCursorInVRAM = 0x02 147}; 148 149/*! @struct StdFBShmem_t 150 @discussion This structure contains cursor and window server state data and occupies a slice of shared memory between the kernel and window server. Several elements of this structure are only used in software cursor mode. Unless otherwise indicated, the coordinates in this structure are given in display space. Display space is the coordinate space that encompasses all the screens. The positions of the screens within display space indicate their location relative to each other as the cursor moves between them. If there is only one screen, the screen coordinates and display space coordinates will be the same. 151 @field cursorSema Semaphore lock for write access to the shared data in this structure. 152 @field frame The current cursor frame index. 153 @field cursorShow The cursor is displayed when cursorShow is 0. 154 @field cursorObscured If this is true, the cursor has been obscured and cursorShow should not be 0. The cursor will be shown again the next time it is moved. 155 @field shieldFlag When this is set to true the cursor will not be displayed in the region specified by shieldRect. 156 @field shielded True if the cursor has been hidden because it entered the shielded region. 157 @field saveRect The region that is saved underneath the cursor in software cursor mode. 158 @field shieldRect The region that the cursor will not be displayed in if shieldFlag is true. 159 @field cursorLoc The location of the cursor hot spot. 160 @field cursorRect The region that the cursor image currently occupies in software cursor mode. 161 @field oldCursorRect The region that the cursor image occupied the last time the cursor was drawn in software cursor mode. 162 @field screenBounds The region that the current screen occupies. 163 @field version Contains kIOFBCurrentShmemVersion so that a user client can ensure it is using the same version of this structure as the kernel. 164 @field structSize Contains the size of this structure. 165 @field vblTime The time of the most recent vertical blanking. 166 @field vblDelta The interval between the two most recent vertical blankings. 167 @field vblCount A running count of vertical blank interrupts. 168 @field reservedC Reserved for future use. 169 @field hardwareCursorCapable True if the hardware is capable of using hardware cursor mode. 170 @field hardwareCursorActive True if currently using the hardware cursor mode. 171 @field reservedB Reserved for future use. 172 @field cursorSize This array contains the cursor sizes indexed by frame. 173 @field hotSpot This array contains the location of the cursor hot spots indexed by frame. The hot spots coordinates are given relative to the top left corner of the cursor image. 174 @field cursor A union of structures that define the cursor images. The structure used depends on the framebuffer's bit depth. These structures are defined above. 175*/ 176 177struct StdFBShmem_t { 178 OSSpinLock cursorSema; 179 int frame; 180 char cursorShow; 181 char cursorObscured; 182 char shieldFlag; 183 char shielded; 184 IOGBounds saveRect; 185 IOGBounds shieldRect; 186 IOGPoint cursorLoc; 187 IOGBounds cursorRect; 188 IOGBounds oldCursorRect; 189 IOGBounds screenBounds; 190 int version; 191 int structSize; 192 AbsoluteTime vblTime; 193 AbsoluteTime vblDelta; 194 unsigned long long int vblCount; 195#if IOFB_ARBITRARY_FRAMES_CURSOR 196 unsigned long long int vblDrift; 197 unsigned long long int vblDeltaMeasured; 198 unsigned int reservedC[24]; 199#else 200 unsigned int reservedC[27]; 201 unsigned char hardwareCursorFlags[kIOFBNumCursorFrames]; 202#endif 203 unsigned char hardwareCursorCapable; 204 unsigned char hardwareCursorActive; 205 unsigned char hardwareCursorShields; 206 unsigned char reservedB[1]; 207#if IOFB_ARBITRARY_FRAMES_CURSOR 208 IOGSize cursorSize[kIOFBNumCursorIndex]; 209 IOGPoint hotSpot[kIOFBNumCursorIndex]; 210#else 211 IOGSize cursorSize[kIOFBNumCursorFrames]; 212 IOGPoint hotSpot[kIOFBNumCursorFrames]; 213#endif 214#ifndef IOFB_ARBITRARY_SIZE_CURSOR 215 union { 216 struct bm12Cursor bw; 217 struct bm18Cursor bw8; 218 struct bm34Cursor rgb; 219 struct bm38Cursor rgb24; 220 } cursor; 221#else /* IOFB_ARBITRARY_SIZE_CURSOR */ 222 unsigned char cursor[0]; 223#endif /* IOFB_ARBITRARY_SIZE_CURSOR */ 224}; 225#ifndef __cplusplus 226typedef volatile struct StdFBShmem_t StdFBShmem_t; 227#endif 228 229 230/*! @enum FramebufferConstants 231 @constant kIOFBCurrentShmemVersion The current version of the slice of shared memory that contains the cursor and window server state data in the StdFBShmem_t structure. 232 @constant kIOFBCursorMemory The memory type for IOConnectMapMemory() to get a slice of shared memory that contains the StdFBShmem_t structure. 233*/ 234enum { 235 // version for IOFBCreateSharedCursor 236 kIOFBShmemVersionMask = 0x000000ff, 237 kIOFBTenPtOneShmemVersion = 2, 238 kIOFBTenPtTwoShmemVersion = 3, 239 kIOFBCurrentShmemVersion = 2, 240 241 // number of frames in animating cursor (if > kIOFBTenPtTwoShmemVersion) 242 kIOFBShmemCursorNumFramesMask = 0x00ff0000, 243 kIOFBShmemCursorNumFramesShift = 16, 244 245 // memory types for IOConnectMapMemory. 246 kIOFBCursorMemory = 100 247}; 248 249/*! @defined IOFRAMEBUFFER_CONFORMSTO 250 @discussion The class name of the framebuffer service. 251*/ 252#define IOFRAMEBUFFER_CONFORMSTO "IOFramebuffer" 253 254#ifdef __cplusplus 255} 256#endif 257 258#endif /* ! _IOKIT_IOFRAMEBUFFERSHARED_H */ 259