tcp: Add APICall trace entry and move TRACEs into locked parts.
[haiku.git] / src / add-ons / accelerants / nvidia_gpgpu / GetAccelerantHook.c
blobd55042ab7063f5f7e2a0525e79b72ce76a0783ad
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 10/2002-6/2008
8 */
10 #define MODULE_BIT 0x08000000
12 #include "acc_std.h"
15 The standard entry point. Given a uint32 feature identifier, this routine
16 returns a pointer to the function that implements the feature. Some features
17 require more information than just the identifier to select the proper
18 function. The extra information (which is specific to the feature) is
19 pointed at by the void *data parameter. By default, no extra information
20 is available. Any extra information available to choose the function will be
21 noted on a case by case below.
25 These definitions are out of pure lazyness.
27 #define CHKA(x) case B_##x: \
28 if (check_acc_capability(B_##x) == B_OK) \
29 return (void *)x##_DMA; \
30 else \
31 return (void *)0
32 #define CHKS(x) case B_##x: return (void *)x##_DMA
33 #define HOOK(x) case B_##x: return (void *)x
34 #define ZERO(x) case B_##x: return (void *)0
35 #define HRDC(x) case B_##x: return si->settings.hardcursor? (void *)x: (void *)0; // apsed
37 void * get_accelerant_hook(uint32 feature, void *data)
39 switch (feature)
42 One of either B_INIT_ACCELERANT or B_CLONE_ACCELERANT will be requested and
43 subsequently called before any other hook is requested. All other feature
44 hook selections can be predicated on variables assigned during the accelerant
45 initialization process.
48 /* initialization */
49 HOOK(INIT_ACCELERANT);
50 HOOK(CLONE_ACCELERANT);
52 HOOK(ACCELERANT_CLONE_INFO_SIZE);
53 HOOK(GET_ACCELERANT_CLONE_INFO);
54 HOOK(UNINIT_ACCELERANT);
55 HOOK(GET_ACCELERANT_DEVICE_INFO);
56 HOOK(ACCELERANT_RETRACE_SEMAPHORE);
58 /* mode configuration */
59 HOOK(ACCELERANT_MODE_COUNT);
60 HOOK(GET_MODE_LIST);
61 HOOK(PROPOSE_DISPLAY_MODE);
62 HOOK(SET_DISPLAY_MODE);
63 HOOK(GET_DISPLAY_MODE);
64 HOOK(GET_FRAME_BUFFER_CONFIG);
65 HOOK(GET_PIXEL_CLOCK_LIMITS);
66 HOOK(MOVE_DISPLAY);
67 HOOK(SET_INDEXED_COLORS);
68 HOOK(GET_TIMING_CONSTRAINTS);
70 HOOK(DPMS_CAPABILITIES);
71 HOOK(DPMS_MODE);
72 HOOK(SET_DPMS_MODE);
74 /* cursor managment */
75 //HRDC(SET_CURSOR_SHAPE);
76 //HRDC(MOVE_CURSOR);
77 //HRDC(SHOW_CURSOR);
79 /* synchronization */
80 HOOK(ACCELERANT_ENGINE_COUNT);
81 CHKS(ACQUIRE_ENGINE);
82 HOOK(RELEASE_ENGINE);
83 HOOK(WAIT_ENGINE_IDLE);
84 HOOK(GET_SYNC_TOKEN);
85 HOOK(SYNC_TO_TOKEN);
88 Depending on the engine architecture, you may choose to provide a different
89 function to be used with each bit-depth for example.
91 Note: These hooks are re-acquired by the app_server after each mode switch.
94 /* video overlay functions are not supported */
97 When requesting an acceleration hook, the calling application provides a
98 pointer to the display_mode for which the acceleration function will be used.
99 Depending on the engine architecture, you may choose to provide a different
100 function to be used with each bit-depth. In the sample driver we return
101 the same function all the time.
103 Note: These hooks are re-acquired by the app_server after each mode switch.
106 /* only export 2D acceleration functions in modes that are capable of it */
107 /* used by the app_server and applications (BWindowScreen) */
108 //CHKA(SCREEN_TO_SCREEN_BLIT);
109 //CHKA(FILL_RECTANGLE);
110 //CHKA(INVERT_RECTANGLE);
111 //CHKA(FILL_SPAN);
112 /* not (yet) used by the app_server:
113 * so just for application use (BWindowScreen) */
114 // CHKA(SCREEN_TO_SCREEN_TRANSPARENT_BLIT);
115 //CHKA(SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT);
118 /* Return a null pointer for any feature we don't understand. */
119 return 0;
121 #undef CHKA
122 #undef CHKD
123 #undef HOOK
124 #undef ZERO
125 #undef HRDC
127 status_t check_acc_capability(uint32 feature)
129 char *msg = "";
131 /* setup logmessage text */
132 switch (feature)
134 case B_SCREEN_TO_SCREEN_BLIT:
135 msg = "B_SCREEN_TO_SCREEN_BLIT";
136 break;
137 case B_FILL_RECTANGLE:
138 msg = "B_FILL_RECTANGLE";
139 break;
140 case B_INVERT_RECTANGLE:
141 msg = "B_INVERT_RECTANGLE";
142 break;
143 case B_FILL_SPAN:
144 msg = "B_FILL_SPAN";
145 break;
146 case B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT:
147 msg = "B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT";
148 break;
149 case B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT:
150 msg = "B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT";
151 /* this function doesn't support the B_CMAP8 colorspace */
152 //fixme: checkout B_CMAP8 support sometime, as some cards seem to support it?
153 if (si->dm.space == B_CMAP8)
155 LOG(4, ("Acc: Not exporting hook %s.\n", msg));
156 return B_ERROR;
158 break;
159 default:
160 msg = "UNKNOWN";
161 break;
164 /* hardware acceleration is only supported in modes with upto a certain
165 * memory pitch.. */
166 if (si->acc_mode)
168 LOG(4, ("Acc: Exporting hook %s.\n", msg));
169 return B_OK;
171 else
173 LOG(4, ("Acc: Not exporting hook %s.\n", msg));
174 return B_ERROR;