1706f2543Smrg CURSOR.NOTES 2706f2543Smrg 3706f2543Smrg This file describes how to add hardware cursor support to a chipset 4706f2543Smrgdriver. Though the cursor support itself is in the ramdac module, 5706f2543Smrgcursor management is separate from the rest of the module. 6706f2543Smrg 7706f2543Smrg 8706f2543Smrg1) CURSOR INITIALIZATION AND SHUTDOWN 9706f2543Smrg 10706f2543Smrg All relevant prototypes and defines are in xf86Cursor.h. 11706f2543Smrg 12706f2543Smrg To initialize the cursor, the driver should allocate an 13706f2543Smrgxf86CursorInfoRec via xf86CreateCursorInfoRec(), fill it out as described 14706f2543Smrglater in this document and pass it to xf86InitCursor(). xf86InitCursor() 15706f2543Smrgmust be called _after_ the software cursor initialization (usually 16706f2543SmrgmiDCInitialize). 17706f2543Smrg 18706f2543Smrg When shutting down, the driver should free the xf86CursorInfoRec 19706f2543Smrgstructure in its CloseScreen function via xf86DestroyCursorInfoRec(). 20706f2543Smrg 21706f2543Smrg 22706f2543Smrg2) FILLING OUT THE xf86CursorInfoRec 23706f2543Smrg 24706f2543Smrg The driver informs the ramdac module of it's hardware cursor capablities by 25706f2543Smrgfilling out an xf86CursorInfoRec structure and passing it to xf86InitCursor(). 26706f2543SmrgThe xf86CursorInfoRec contains the following function pointers: 27706f2543Smrg 28706f2543Smrg 29706f2543Smrg/**** These functions are required ****/ 30706f2543Smrg 31706f2543Smrgvoid ShowCursor(ScrnInfoPtr pScrn) 32706f2543Smrg 33706f2543Smrg ShowCursor should display the current cursor. 34706f2543Smrg 35706f2543Smrgvoid HideCursor(ScrnInfoPtr pScrn) 36706f2543Smrg 37706f2543Smrg HideCursor should hide the current cursor. 38706f2543Smrg 39706f2543Smrgvoid SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) 40706f2543Smrg 41706f2543Smrg Set the cursor position to (x,y). X and/or y may be negative 42706f2543Smrg indicating that the cursor image is partially offscreen on 43706f2543Smrg the left and/or top edges of the screen. It is up to the 44706f2543Smrg driver to trap for this and deal with that situation. 45706f2543Smrg 46706f2543Smrgvoid SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) 47706f2543Smrg 48706f2543Smrg Set the cursor foreground and background colors. In 8bpp, fg and 49706f2543Smrg bg are indicies into the current colormap unless the 50706f2543Smrg HARDWARE_CURSOR_TRUECOLOR_AT_8BPP flag is set. In that case 51706f2543Smrg and in all other bpps the fg and bg are in 8-8-8 RGB format. 52706f2543Smrg 53706f2543Smrgvoid LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits) 54706f2543Smrg 55706f2543Smrg LoadCursorImage is how the hardware cursor bits computed by the 56706f2543Smrg RealizeCursor function will be passed to the driver when the cursor 57706f2543Smrg shape needs to be changed. 58706f2543Smrg 59706f2543Smrg 60706f2543Smrg/**** These functions are optional ****/ 61706f2543Smrg 62706f2543Smrg 63706f2543Smrgunsigned char* RealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) 64706f2543Smrg 65706f2543Smrg If RealizeCursor is not provided by the driver, one will be provided 66706f2543Smrg for you based on the Flags field described below. The driver must 67706f2543Smrg provide this function if the hardware cursor format is not one of 68706f2543Smrg the common ones supported by this module. 69706f2543Smrg 70706f2543Smrg 71706f2543SmrgBool UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) 72706f2543Smrg 73706f2543Smrg If the driver is unable to use a hardware cursor for reasons 74706f2543Smrg other than the cursor being larger than the maximum specified 75706f2543Smrg in the MaxWidth or MaxHeight field below, it can supply the 76706f2543Smrg UseHWCursor function. If UseHWCursor is provided by the driver, 77706f2543Smrg it will be called whenever the cursor shape changes or the video 78706f2543Smrg mode changes. This is useful for when the hardware cursor cannot 79706f2543Smrg be used in interlaced or doublescan modes. 80706f2543Smrg 81706f2543Smrg 82706f2543Smrg/**** The following fields are required ****/ 83706f2543Smrg 84706f2543SmrgMaxWidth 85706f2543SmrgMaxHeight 86706f2543Smrg 87706f2543Smrg These indicate the largest sized cursor that can be a hardware 88706f2543Smrg cursor. It will fall back to a software cursor when a cursor 89706f2543Smrg exceeding this size needs to be used. 90706f2543Smrg 91706f2543Smrg 92706f2543SmrgFlags 93706f2543Smrg 94706f2543Smrg /* Color related flags */ 95706f2543Smrg 96706f2543Smrg HARDWARE_CURSOR_TRUECOLOR_AT_8BPP 97706f2543Smrg 98706f2543Smrg This indicates that the colors passed to the SetCursorColors 99706f2543Smrg function should not be in 8-8-8 RGB format in 8bpp but rather, 100706f2543Smrg they should be the pixel values from the current colormap. 101706f2543Smrg 102706f2543Smrg 103706f2543Smrg /* Cursor data loading flags */ 104706f2543Smrg 105706f2543Smrg HARDWARE_CURSOR_SHOW_TRANSPARENT 106706f2543Smrg 107706f2543Smrg The HideCursor entry will normally be called instead of displaying a 108706f2543Smrg completely transparent cursor, or when a switch to a software cursor 109706f2543Smrg needs to occur. This flag prevents this behaviour, thus causing the 110706f2543Smrg LoadCursorImage entry to be called with transparent cursor data. 111706f2543Smrg NOTE: If you use this flag and provide your own RealizeCursor() entry, 112706f2543Smrg ensure this entry returns transparent cursor data when called 113706f2543Smrg with a NULL pCurs parameter. 114706f2543Smrg 115706f2543Smrg HARDWARE_CURSOR_UPDATE_UNHIDDEN 116706f2543Smrg 117706f2543Smrg This flag prevents the HideCursor call that would normally occur just before 118706f2543Smrg the LoadCursorImage entry is to be called to load a new hardware cursor 119706f2543Smrg image. 120706f2543Smrg 121706f2543Smrg 122706f2543Smrg /* Cursor data packing flags */ 123706f2543Smrg 124706f2543Smrg Hardware cursor data consists of two pieces, a source and a mask. 125706f2543Smrg The mask is a bitmap indicating which parts of the cursor are 126706f2543Smrg transparent and which parts are drawn. The source is a bitmap 127706f2543Smrg indicating which parts of the non-transparent portion of the the 128706f2543Smrg cursor should be painted in the foreground color and which should 129706f2543Smrg be painted in the background color. 130706f2543Smrg 131706f2543Smrg HARDWARE_CURSOR_INVERT_MASK 132706f2543Smrg 133706f2543Smrg By default, set bits indicate the opaque part of the mask bitmap 134706f2543Smrg and clear bits indicate the transparent part. If your hardware 135706f2543Smrg wants this the opposite way, this flag will invert the mask. 136706f2543Smrg 137706f2543Smrg HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK 138706f2543Smrg 139706f2543Smrg By default, RealizeCursor will store the source first and then 140706f2543Smrg the mask. If the hardware needs this order reversed then this 141706f2543Smrg flag should be set. 142706f2543Smrg 143706f2543Smrg HARDWARE_CURSOR_AND_SOURCE_WITH_MASK 144706f2543Smrg 145706f2543Smrg This flag will have the module logical AND the source with the mask to make 146706f2543Smrg sure there are no source bits set if the corresponding mask bits 147706f2543Smrg aren't set. Some hardware will not care if source bits are set where 148706f2543Smrg there are supposed to be transparent areas, but some hardware will 149706f2543Smrg interpret this as a third cursor color or similar. That type of 150706f2543Smrg hardware will need this flag set. 151706f2543Smrg 152706f2543Smrg HARDWARE_CURSOR_BIT_ORDER_MSBFIRST 153706f2543Smrg 154706f2543Smrg By default, it is assumed that the least significant bit in each byte 155706f2543Smrg corresponds to the leftmost pixel on the screen. If your hardware 156706f2543Smrg has this reversed you should set this flag. 157706f2543Smrg 158706f2543Smrg HARDWARE_CURSOR_NIBBLE_SWAPPED 159706f2543Smrg 160706f2543Smrg If your hardware requires byte swapping of the hardware cursor, enable 161706f2543Smrg this option. 162706f2543Smrg 163706f2543Smrg 164706f2543Smrg /* Source-Mask interleaving flags */ 165706f2543Smrg 166706f2543Smrg By default the source and mask data are inlined (source first unless 167706f2543Smrg the HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK flag is set). Some hardware 168706f2543Smrg will require the source and mask to be interleaved, that is, X number 169706f2543Smrg of source bits should packed and then X number of mask bits repeating 170706f2543Smrg until the entire pattern is stored. The following flags describe the 171706f2543Smrg bit interleave. 172706f2543Smrg 173706f2543Smrg HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED 174706f2543Smrg 175706f2543Smrg This one is the default. 176706f2543Smrg 177706f2543Smrg The following are for interleaved cursors. 178706f2543Smrg 179706f2543Smrg HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 180706f2543Smrg HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 181706f2543Smrg HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 182706f2543Smrg HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 183706f2543Smrg HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 184706f2543Smrg 185706f2543Smrg And once again, if your hardware requires something different than 186706f2543Smrg these packing styles, your driver can supply its own RealizeCursor 187706f2543Smrg function. 188706f2543Smrg 189706f2543Smrg 190706f2543Smrg 191706f2543Smrg$XFree86: xc/programs/Xserver/hw/xfree86/ramdac/CURSOR.NOTES,v 1.4tsi Exp $ 192