CURSOR.NOTES 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. CURSOR.NOTES
  2. This file describes how to add hardware cursor support to a chipset
  3. driver. Though the cursor support itself is in the ramdac module,
  4. cursor management is separate from the rest of the module.
  5. 1) CURSOR INITIALIZATION AND SHUTDOWN
  6. All relevant prototypes and defines are in xf86Cursor.h.
  7. To initialize the cursor, the driver should allocate an
  8. xf86CursorInfoRec via xf86CreateCursorInfoRec(), fill it out as described
  9. later in this document and pass it to xf86InitCursor(). xf86InitCursor()
  10. must be called _after_ the software cursor initialization (usually
  11. miDCInitialize).
  12. When shutting down, the driver should free the xf86CursorInfoRec
  13. structure in its CloseScreen function via xf86DestroyCursorInfoRec().
  14. 2) FILLING OUT THE xf86CursorInfoRec
  15. The driver informs the ramdac module of it's hardware cursor capablities by
  16. filling out an xf86CursorInfoRec structure and passing it to xf86InitCursor().
  17. The xf86CursorInfoRec contains the following function pointers:
  18. /**** These functions are required ****/
  19. void ShowCursor(ScrnInfoPtr pScrn)
  20. ShowCursor should display the current cursor.
  21. void HideCursor(ScrnInfoPtr pScrn)
  22. HideCursor should hide the current cursor.
  23. void SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
  24. Set the cursor position to (x,y). X and/or y may be negative
  25. indicating that the cursor image is partially offscreen on
  26. the left and/or top edges of the screen. It is up to the
  27. driver to trap for this and deal with that situation.
  28. void SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
  29. Set the cursor foreground and background colors. In 8bpp, fg and
  30. bg are indicies into the current colormap unless the
  31. HARDWARE_CURSOR_TRUECOLOR_AT_8BPP flag is set. In that case
  32. and in all other bpps the fg and bg are in 8-8-8 RGB format.
  33. void LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits)
  34. LoadCursorImage is how the hardware cursor bits computed by the
  35. RealizeCursor function will be passed to the driver when the cursor
  36. shape needs to be changed.
  37. /**** These functions are optional ****/
  38. unsigned char* RealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
  39. If RealizeCursor is not provided by the driver, one will be provided
  40. for you based on the Flags field described below. The driver must
  41. provide this function if the hardware cursor format is not one of
  42. the common ones supported by this module.
  43. Bool UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
  44. If the driver is unable to use a hardware cursor for reasons
  45. other than the cursor being larger than the maximum specified
  46. in the MaxWidth or MaxHeight field below, it can supply the
  47. UseHWCursor function. If UseHWCursor is provided by the driver,
  48. it will be called whenever the cursor shape changes or the video
  49. mode changes. This is useful for when the hardware cursor cannot
  50. be used in interlaced or doublescan modes.
  51. /**** The following fields are required ****/
  52. MaxWidth
  53. MaxHeight
  54. These indicate the largest sized cursor that can be a hardware
  55. cursor. It will fall back to a software cursor when a cursor
  56. exceeding this size needs to be used.
  57. Flags
  58. /* Color related flags */
  59. HARDWARE_CURSOR_TRUECOLOR_AT_8BPP
  60. This indicates that the colors passed to the SetCursorColors
  61. function should not be in 8-8-8 RGB format in 8bpp but rather,
  62. they should be the pixel values from the current colormap.
  63. /* Cursor data loading flags */
  64. HARDWARE_CURSOR_SHOW_TRANSPARENT
  65. The HideCursor entry will normally be called instead of displaying a
  66. completely transparent cursor, or when a switch to a software cursor
  67. needs to occur. This flag prevents this behaviour, thus causing the
  68. LoadCursorImage entry to be called with transparent cursor data.
  69. NOTE: If you use this flag and provide your own RealizeCursor() entry,
  70. ensure this entry returns transparent cursor data when called
  71. with a NULL pCurs parameter.
  72. HARDWARE_CURSOR_UPDATE_UNHIDDEN
  73. This flag prevents the HideCursor call that would normally occur just before
  74. the LoadCursorImage entry is to be called to load a new hardware cursor
  75. image.
  76. /* Cursor data packing flags */
  77. Hardware cursor data consists of two pieces, a source and a mask.
  78. The mask is a bitmap indicating which parts of the cursor are
  79. transparent and which parts are drawn. The source is a bitmap
  80. indicating which parts of the non-transparent portion of the the
  81. cursor should be painted in the foreground color and which should
  82. be painted in the background color.
  83. HARDWARE_CURSOR_INVERT_MASK
  84. By default, set bits indicate the opaque part of the mask bitmap
  85. and clear bits indicate the transparent part. If your hardware
  86. wants this the opposite way, this flag will invert the mask.
  87. HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK
  88. By default, RealizeCursor will store the source first and then
  89. the mask. If the hardware needs this order reversed then this
  90. flag should be set.
  91. HARDWARE_CURSOR_AND_SOURCE_WITH_MASK
  92. This flag will have the module logical AND the source with the mask to make
  93. sure there are no source bits set if the corresponding mask bits
  94. aren't set. Some hardware will not care if source bits are set where
  95. there are supposed to be transparent areas, but some hardware will
  96. interpret this as a third cursor color or similar. That type of
  97. hardware will need this flag set.
  98. HARDWARE_CURSOR_BIT_ORDER_MSBFIRST
  99. By default, it is assumed that the least significant bit in each byte
  100. corresponds to the leftmost pixel on the screen. If your hardware
  101. has this reversed you should set this flag.
  102. HARDWARE_CURSOR_NIBBLE_SWAPPED
  103. If your hardware requires byte swapping of the hardware cursor, enable
  104. this option.
  105. /* Source-Mask interleaving flags */
  106. By default the source and mask data are inlined (source first unless
  107. the HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK flag is set). Some hardware
  108. will require the source and mask to be interleaved, that is, X number
  109. of source bits should packed and then X number of mask bits repeating
  110. until the entire pattern is stored. The following flags describe the
  111. bit interleave.
  112. HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED
  113. This one is the default.
  114. The following are for interleaved cursors.
  115. HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1
  116. HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8
  117. HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16
  118. HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32
  119. HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64
  120. And once again, if your hardware requires something different than
  121. these packing styles, your driver can supply its own RealizeCursor
  122. function.
  123. $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/CURSOR.NOTES,v 1.4tsi Exp $