tcp: Add APICall trace entry and move TRACEs into locked parts.
[haiku.git] / src / add-ons / accelerants / matrox / Cursor.c
blobadd1b4d3d707d71500060d14014654cec325c031
1 /*
2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
5 Other authors:
6 Mark Watson,
7 Rudolf Cornelissen 4/2003-11/2004
8 */
10 #define MODULE_BIT 0x20000000
12 /*DUALHEAD notes -
13 No hardware cursor possible on the secondary head :(
14 Reasons:
15 CRTC1 has a cursor, can be displayed on DAC or MAVEN
16 CRTC2 has no cursor
17 Can not switch CRTC in one vblank (has to resync)
18 CRTC2 does not support split screen
19 app_server does not support some modes with and some without cursor
20 virtual not supported, because of MAVEN blanking issues
23 #include "acc_std.h"
25 status_t SET_CURSOR_SHAPE(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, uint8 *andMask, uint8 *xorMask)
27 LOG(4,("SET_CURSOR_SHAPE: width %d, height %d\n", width, height));
28 if ((width != 16) || (height != 16))
30 return B_ERROR;
32 else if ((hot_x >= width) || (hot_y >= height))
34 return B_ERROR;
36 else
38 gx00_crtc_cursor_define(andMask,xorMask);
40 /* Update cursor variables appropriately. */
41 si->cursor.width = width;
42 si->cursor.height = height;
43 si->cursor.hot_x = hot_x;
44 si->cursor.hot_y = hot_y;
47 return B_OK;
50 /* Move the cursor to the specified position on the desktop, taking account of virtual/dual issues */
51 void MOVE_CURSOR(uint16 x, uint16 y)
53 uint16 hds = si->dm.h_display_start; /* the current horizontal starting pixel */
54 uint16 vds = si->dm.v_display_start; /* the current vertical starting line */
55 uint16 h_adjust;
57 /* clamp cursor to display */
58 if (x >= si->dm.virtual_width) x = si->dm.virtual_width - 1;
59 if (y >= si->dm.virtual_height) y = si->dm.virtual_height - 1;
61 /* store, for our info */
62 si->cursor.x = x;
63 si->cursor.y = y;
65 /*set up minimum amount to scroll*/
66 if (si->dm.flags & DUALHEAD_BITS)
68 switch(si->dm.space)
70 case B_RGB16_LITTLE:
71 h_adjust = 0x1f;
72 break;
73 case B_RGB32_LITTLE:
74 h_adjust = 0x0f;
75 break;
76 default:
77 h_adjust = 0x1f;
78 break;
81 else
83 switch(si->dm.space)
85 case B_CMAP8:
86 h_adjust = 0x07;
87 break;
88 case B_RGB15_LITTLE:case B_RGB16_LITTLE:
89 h_adjust = 0x03;
90 break;
91 case B_RGB32_LITTLE:
92 h_adjust = 0x01;
93 break;
94 default:
95 h_adjust = 0x07;
96 break;
100 /* adjust h/v_display_start to move cursor onto screen */
101 switch (si->dm.flags & DUALHEAD_BITS)
103 case DUALHEAD_ON:
104 case DUALHEAD_SWITCH:
105 if (x >= ((si->dm.timing.h_display * 2) + hds))
107 hds = ((x - (si->dm.timing.h_display * 2)) + 1 + h_adjust) & ~h_adjust;
108 /* make sure we stay within the display! */
109 if ((hds + (si->dm.timing.h_display * 2)) > si->dm.virtual_width)
110 hds -= (h_adjust + 1);
112 else if (x < hds)
113 hds = x & ~h_adjust;
114 break;
115 default:
116 if (x >= (si->dm.timing.h_display + hds))
118 hds = ((x - si->dm.timing.h_display) + 1 + h_adjust) & ~h_adjust;
119 /* make sure we stay within the display! */
120 if ((hds + si->dm.timing.h_display) > si->dm.virtual_width)
121 hds -= (h_adjust + 1);
123 else if (x < hds)
124 hds = x & ~h_adjust;
125 break;
128 if (y >= (si->dm.timing.v_display + vds))
129 vds = y - si->dm.timing.v_display + 1;
130 else if (y < vds)
131 vds = y;
133 /* reposition the desktop _and_ the overlay on the display if required */
134 if ((hds!=si->dm.h_display_start) || (vds!=si->dm.v_display_start))
136 MOVE_DISPLAY(hds,vds);
137 gx00_bes_move_overlay();
140 /* put cursor in correct physical position */
141 x -= hds + si->cursor.hot_x;
142 y -= vds + si->cursor.hot_y;
144 /* account for switched CRTC's */
145 if (si->switched_crtcs) x -= si->dm.timing.h_display;
147 /* position the cursor on the display */
148 gx00_crtc_cursor_position(x,y);
151 void SHOW_CURSOR(bool is_visible)
153 /* record for our info */
154 si->cursor.is_visible = is_visible;
156 if (is_visible)
157 gx00_crtc_cursor_show();
158 else
159 gx00_crtc_cursor_hide();