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