1 /* 2 Copyright 1999, Be Incorporated. All Rights Reserved. 3 This file may be used under the terms of the Be Sample Code License. 4 5 Other authors: 6 Mark Watson, 7 Rudolf Cornelissen 10/2002-3/2009 8 */ 9 10 #define MODULE_BIT 0x08000000 11 12 #include "acc_std.h" 13 14 /* 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. 22 */ 23 24 /* 25 These definitions are out of pure lazyness. 26 */ 27 #define CHKO(x) case B_##x: \ 28 if (check_overlay_capability(B_##x) == B_OK) return (void *)x; else return (void *)0 29 #define CHKA(x) case B_##x: \ 30 if (check_acc_capability(B_##x) == B_OK) \ 31 {if(!si->settings.dma_acc) return (void *)x##_PIO; else return (void *)x##_DMA;} \ 32 else return (void *)0 33 #define CHKS(x) case B_##x: \ 34 if(!si->settings.dma_acc) return (void *)x##_PIO; else return (void *)x##_DMA 35 #define HOOK(x) case B_##x: return (void *)x 36 #define ZERO(x) case B_##x: return (void *)0 37 #define HRDC(x) case B_##x: return si->settings.hardcursor? (void *)x: (void *)0; // apsed 38 39 void * get_accelerant_hook(uint32 feature, void *data) 40 { 41 switch (feature) 42 { 43 /* 44 One of either B_INIT_ACCELERANT or B_CLONE_ACCELERANT will be requested and 45 subsequently called before any other hook is requested. All other feature 46 hook selections can be predicated on variables assigned during the accelerant 47 initialization process. 48 */ 49 50 /* initialization */ 51 HOOK(INIT_ACCELERANT); 52 HOOK(CLONE_ACCELERANT); 53 54 HOOK(ACCELERANT_CLONE_INFO_SIZE); 55 HOOK(GET_ACCELERANT_CLONE_INFO); 56 HOOK(UNINIT_ACCELERANT); 57 HOOK(GET_ACCELERANT_DEVICE_INFO); 58 HOOK(ACCELERANT_RETRACE_SEMAPHORE); 59 60 /* mode configuration */ 61 HOOK(ACCELERANT_MODE_COUNT); 62 HOOK(GET_MODE_LIST); 63 HOOK(PROPOSE_DISPLAY_MODE); 64 HOOK(SET_DISPLAY_MODE); 65 HOOK(GET_DISPLAY_MODE); 66 HOOK(GET_FRAME_BUFFER_CONFIG); 67 HOOK(GET_PIXEL_CLOCK_LIMITS); 68 HOOK(MOVE_DISPLAY); 69 HOOK(SET_INDEXED_COLORS); 70 HOOK(GET_TIMING_CONSTRAINTS); 71 72 HOOK(DPMS_CAPABILITIES); 73 HOOK(DPMS_MODE); 74 HOOK(SET_DPMS_MODE); 75 76 /* cursor managment */ 77 HRDC(SET_CURSOR_SHAPE); 78 HRDC(MOVE_CURSOR); 79 HRDC(SHOW_CURSOR); 80 81 /* synchronization */ 82 HOOK(ACCELERANT_ENGINE_COUNT); 83 CHKS(ACQUIRE_ENGINE); 84 HOOK(RELEASE_ENGINE); 85 HOOK(WAIT_ENGINE_IDLE); 86 HOOK(GET_SYNC_TOKEN); 87 HOOK(SYNC_TO_TOKEN); 88 89 /* 90 Depending on the engine architecture, you may choose to provide a different 91 function to be used with each bit-depth for example. 92 93 Note: These hooks are re-acquired by the app_server after each mode switch. 94 */ 95 96 /* only export video overlay functions if card is capable of it */ 97 CHKO(OVERLAY_COUNT); 98 CHKO(OVERLAY_SUPPORTED_SPACES); 99 CHKO(OVERLAY_SUPPORTED_FEATURES); 100 CHKO(ALLOCATE_OVERLAY_BUFFER); 101 CHKO(RELEASE_OVERLAY_BUFFER); 102 CHKO(GET_OVERLAY_CONSTRAINTS); 103 CHKO(ALLOCATE_OVERLAY); 104 CHKO(RELEASE_OVERLAY); 105 CHKO(CONFIGURE_OVERLAY); 106 107 /* 108 When requesting an acceleration hook, the calling application provides a 109 pointer to the display_mode for which the acceleration function will be used. 110 Depending on the engine architecture, you may choose to provide a different 111 function to be used with each bit-depth. In the sample driver we return 112 the same function all the time. 113 114 Note: These hooks are re-acquired by the app_server after each mode switch. 115 */ 116 117 /* only export 2D acceleration functions in modes that are capable of it */ 118 /* used by the app_server and applications (BWindowScreen) */ 119 CHKA(SCREEN_TO_SCREEN_BLIT); 120 CHKA(FILL_RECTANGLE); 121 CHKA(INVERT_RECTANGLE); 122 CHKA(FILL_SPAN); 123 /* not (yet) used by the app_server: 124 * so just for application use (BWindowScreen) */ 125 // CHKA(SCREEN_TO_SCREEN_TRANSPARENT_BLIT); 126 CHKA(SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT); 127 } 128 129 /* Return a null pointer for any feature we don't understand. */ 130 return 0; 131 } 132 #undef CHKO 133 #undef CHKA 134 #undef CHKD 135 #undef HOOK 136 #undef ZERO 137 #undef HRDC 138 139 status_t check_overlay_capability(uint32 feature) 140 { 141 char *msg = ""; 142 143 /* setup logmessage text */ 144 switch (feature) 145 { 146 case B_OVERLAY_COUNT: 147 msg = "B_OVERLAY_COUNT"; 148 break; 149 case B_OVERLAY_SUPPORTED_SPACES: 150 msg = "B_OVERLAY_SUPPORTED_SPACES"; 151 break; 152 case B_OVERLAY_SUPPORTED_FEATURES: 153 msg = "B_OVERLAY_SUPPORTED_FEATURES"; 154 break; 155 case B_ALLOCATE_OVERLAY_BUFFER: 156 msg = "B_ALLOCATE_OVERLAY_BUFFER"; 157 break; 158 case B_RELEASE_OVERLAY_BUFFER: 159 msg = "B_RELEASE_OVERLAY_BUFFER"; 160 break; 161 case B_GET_OVERLAY_CONSTRAINTS: 162 msg = "B_GET_OVERLAY_CONSTRAINTS"; 163 break; 164 case B_ALLOCATE_OVERLAY: 165 msg = "B_ALLOCATE_OVERLAY"; 166 break; 167 case B_RELEASE_OVERLAY: 168 msg = "B_RELEASE_OVERLAY"; 169 break; 170 case B_CONFIGURE_OVERLAY: 171 msg = "B_CONFIGURE_OVERLAY"; 172 break; 173 default: 174 msg = "UNKNOWN"; 175 break; 176 } 177 178 /* all older cards have a supported bes */ 179 if ((si->ps.card_type <= NV40) || (si->ps.card_type == NV45)) 180 { 181 LOG(4, ("Overlay: Exporting hook %s.\n", msg)); 182 return B_OK; 183 } 184 185 /* all newer NV40 architecture cards have a new HDTV capable bes except for 186 * GeForce 6800's. Unfortunately we have no info about the new bes yet. */ 187 LOG(4, ("Overlay: Not exporting hook %s.\n", msg)); 188 return B_ERROR; 189 } 190 191 status_t check_acc_capability(uint32 feature) 192 { 193 char *msg = ""; 194 195 /* setup logmessage text */ 196 switch (feature) 197 { 198 case B_SCREEN_TO_SCREEN_BLIT: 199 msg = "B_SCREEN_TO_SCREEN_BLIT"; 200 break; 201 case B_FILL_RECTANGLE: 202 msg = "B_FILL_RECTANGLE"; 203 break; 204 case B_INVERT_RECTANGLE: 205 msg = "B_INVERT_RECTANGLE"; 206 break; 207 case B_FILL_SPAN: 208 msg = "B_FILL_SPAN"; 209 break; 210 case B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT: 211 msg = "B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT"; 212 break; 213 case B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT: 214 msg = "B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT"; 215 /* this function is only defined for DMA acceleration, 216 * but doesn't support the B_CMAP8 colorspace */ 217 //fixme: checkout B_CMAP8 support sometime, as some cards seem to support it? 218 if (!si->settings.dma_acc || (si->dm.space == B_CMAP8)) 219 { 220 LOG(4, ("Acc: Not exporting hook %s.\n", msg)); 221 return B_ERROR; 222 } 223 break; 224 default: 225 msg = "UNKNOWN"; 226 break; 227 } 228 229 /* hardware acceleration is only supported in modes with upto a certain 230 * memory pitch.. and acceleration must not be blocked */ 231 if (si->acc_mode && !si->settings.block_acc) 232 { 233 LOG(4, ("Acc: Exporting hook %s.\n", msg)); 234 return B_OK; 235 } 236 else 237 { 238 LOG(4, ("Acc: Not exporting hook %s.\n", msg)); 239 return B_ERROR; 240 } 241 } 242