1 /* Written by Rudolf Cornelissen 05-2002/4-2006 */ 2 3 /* Note on 'missing features' in BeOS 5.0.3 and DANO: 4 * BeOS needs to define more colorspaces! It would be nice if BeOS would support the FourCC 'definitions' 5 * of colorspaces. These colorspaces are 32bit words, so it could be simply done (or is it already so?) 6 */ 7 8 #define MODULE_BIT 0x00000400 9 10 #include "acc_std.h" 11 12 /* define the supported overlay input colorspaces */ 13 /* Note: 14 * G200-G550 can all do YUV4:2:0 2-plane colorspace as well, 15 * G200 does not support RGB modes while > G200 do (but with limited scaling and without filtering), 16 * G200 does not support YUV4:2:0 3-plane mode while > G200 do. 17 * It would be nice to have the YUV4:2:0 2-plane mode implemented also later on, but the Be colorspace 18 * definitions (in GraphicsDefs.h, R5.0.3 and DANO5.1d0) do not include this one... */ 19 static uint32 overlay_colorspaces [] = { (uint32)B_YCbCr422, (uint32)B_NO_COLOR_SPACE }; 20 21 uint32 OVERLAY_COUNT(const display_mode *dm) 22 // This method is never used AFAIK though it *is* exported on R5.0.3 and DANO. 23 // Does someone know howto invoke it? 24 { 25 LOG(4,("Overlay: count called\n")); 26 27 /* check for NULL pointer */ 28 if (dm == NULL) 29 { 30 LOG(4,("Overlay: No display mode specified!\n")); 31 } 32 /* apparantly overlay count should report the number of 'overlay units' on the card */ 33 return 1; 34 } 35 36 const uint32 *OVERLAY_SUPPORTED_SPACES(const display_mode *dm) 37 // This method is never used AFAIK though it *is* exported on R5.0.3 and DANO. 38 // Does someone know howto invoke it? 39 { 40 LOG(4,("Overlay: supported_spaces called.\n")); 41 42 /* check for NULL pointer */ 43 if (dm == NULL) 44 { 45 LOG(4,("Overlay: No display mode specified!\n")); 46 return NULL; 47 } 48 49 /* interlaced VGA is not supported by G200-G550 BES */ 50 if (dm->timing.flags & B_TIMING_INTERLACED) 51 { 52 return NULL; 53 } 54 /* return a B_NO_COLOR_SPACE terminated list */ 55 return &overlay_colorspaces[0]; 56 } 57 58 uint32 OVERLAY_SUPPORTED_FEATURES(uint32 a_color_space) 59 // This method is never used AFAIK. On R5.0.3 and DANO it is not even exported! 60 { 61 LOG(4,("Overlay: supported_features: color_space $%08x\n",a_color_space)); 62 63 /* check what features (like the keying method) are supported on the current 64 * Desktop colorspace */ 65 //fixme? Or are we talking about the overlay input bitmap's colorspace? 66 switch (a_color_space) 67 { 68 default: 69 /* fixme: for now 'direct 32bit' desktop colorspace assumed */ 70 return 71 ( B_OVERLAY_KEYING_USES_ALPHA | 72 B_OVERLAY_COLOR_KEY | 73 B_OVERLAY_HORIZONTAL_FILTERING | 74 B_OVERLAY_VERTICAL_FILTERING ); 75 } 76 } 77 78 const overlay_buffer *ALLOCATE_OVERLAY_BUFFER(color_space cs, uint16 width, uint16 height) 79 { 80 int offset = 0; /* used to determine next buffer to create */ 81 uint32 adress, adress2, temp32; /* used to calculate buffer adresses */ 82 uint32 oldsize = 0; /* used to 'squeeze' new buffers between already existing ones */ 83 int cnt; /* loopcounter */ 84 85 /* acquire the shared benaphore */ 86 AQUIRE_BEN(si->overlay.lock) 87 88 LOG(4,("Overlay: cardRAM_start = $%08x\n",(uint32)((uint8*)si->framebuffer))); 89 LOG(4,("Overlay: cardRAM_start_DMA = $%08x\n",(uint32)((uint8*)si->framebuffer_pci))); 90 LOG(4,("Overlay: cardRAM_size = %dMb\n",si->ps.memory_size)); 91 92 /* find first empty slot (room for another buffer?) */ 93 for (offset = 0; offset < MAXBUFFERS; offset++) 94 { 95 if (si->overlay.myBuffer[offset].buffer == NULL) break; 96 } 97 98 LOG(4,("Overlay: Allocate_buffer offset = %d\n",offset)); 99 100 if (offset < MAXBUFFERS) 101 /* setup new scaler input buffer */ 102 { 103 switch (cs) 104 { 105 case B_YCbCr422: 106 /* check if slopspace is needed: compatible settings choosen for now: 107 * G200 can do with ~0x0003 while > G200 need ~x0007. 108 * Optimized settings for G200 could reduce CPU load a tiny little bit there... */ 109 /* fixme: update needed for DVDmax support to adhere to CRTC2 constraints: 110 * case display_mode == B_RGB16: multiple = 32 111 * case display_mode == B_RGB32: multiple = 16 */ 112 if (width == (width & ~0x0007)) 113 { 114 si->overlay.myBuffer[offset].width = width; 115 } 116 else 117 { 118 si->overlay.myBuffer[offset].width = (width & ~0x0007) + 8; 119 } 120 si->overlay.myBuffer[offset].bytes_per_row = 2 * si->overlay.myBuffer[offset].width; 121 122 /* check if the requested horizontal pitch is supported: 123 * G200 max. pitch is 4092 pixels, > G200 max pitch is 4088 pixels for this colorspace. 124 * Compatible check done, has no downside consequences here. */ 125 if (si->overlay.myBuffer[offset].width > 4088) 126 { 127 LOG(4,("Overlay: Sorry, requested buffer pitch not supported, aborted\n")); 128 129 /* release the shared benaphore */ 130 RELEASE_BEN(si->overlay.lock) 131 132 return NULL; 133 } 134 break; 135 136 // case 0xffff://fixme: which one(s)? 137 //fixme: 4:2:0 2-plane supported format, should be selected only if detected 138 /* check if slopspace is needed: compatible settings choosen for now: 139 * G200 can do with ~0x0007 while > G200 need ~x001f. 140 * Optimized settings for G200 could reduce CPU load a tiny little bit there... */ 141 /* if (width == (width & ~0x001f)) 142 { 143 si->overlay.myBuffer[offset].width = width; 144 } 145 else 146 { 147 si->overlay.myBuffer[offset].width = (width & ~0x001f) + 32; 148 } 149 */ /* assuming Y-plane only bytes_per_row are requested here */ 150 /* si->overlay.myBuffer[offset].bytes_per_row = si->overlay.myBuffer[offset].width; 151 */ 152 /* check if the requested horizontal pitch is supported: 153 * G200 max. pitch is 4088 pixels, > G200 max pitch is 4064 pixels for this colorspace. 154 * Compatible check done, has no real downside consequences here. */ 155 /* if (si->overlay.myBuffer[offset].width > 4064) 156 { 157 LOG(4,("Overlay: Sorry, requested buffer pitch not supported, aborted\n"); 158 */ 159 /* release the shared benaphore */ 160 /* RELEASE_BEN(si->overlay.lock) 161 162 return NULL; 163 } 164 break; 165 */ 166 default: 167 /* unsupported colorspace! */ 168 LOG(4,("Overlay: Sorry, colorspace $%08x not supported, aborted\n",cs)); 169 170 /* release the shared benaphore */ 171 RELEASE_BEN(si->overlay.lock) 172 173 return NULL; 174 break; 175 } 176 177 /* check if the requested buffer width is supported */ 178 if (si->overlay.myBuffer[offset].width > 1024) 179 { 180 LOG(4,("Overlay: Sorry, requested buffer width not supported, aborted\n")); 181 182 /* release the shared benaphore */ 183 RELEASE_BEN(si->overlay.lock) 184 185 return NULL; 186 } 187 /* check if the requested buffer height is supported */ 188 if (height > 1024) 189 { 190 LOG(4,("Overlay: Sorry, requested buffer height not supported, aborted\n")); 191 192 /* release the shared benaphore */ 193 RELEASE_BEN(si->overlay.lock) 194 195 return NULL; 196 } 197 198 /* store slopspace (in pixels) for each bitmap for use by 'overlay unit' (BES) */ 199 si->overlay.myBufInfo[offset].slopspace = si->overlay.myBuffer[offset].width - width; 200 201 si->overlay.myBuffer[offset].space = cs; 202 si->overlay.myBuffer[offset].height = height; 203 204 /* we define the overlay buffers to reside 'in the back' of the cards RAM */ 205 /* NOTE to app programmers: 206 * Beware that an app using overlay needs to track workspace switches and screenprefs 207 * changes. If such an action is detected, the app needs to reset it's pointers to the 208 * newly created overlay bitmaps, which will be assigned by BeOS automatically after such 209 * an event. (Also the app needs to respect the new overlay_constraints that will be applicable!) 210 * 211 * It is entirely possible that new bitmaps may *not* be re-setup at all, or less of them 212 * than previously setup by the app might be re-setup. This is due to cardRAM restraints then. 213 * This means that the app should also check for NULL pointers returned by the bitmaps, 214 * and if this happens, it needs to fallback to single buffered overlay or even fallback to 215 * bitmap output for the new situation. */ 216 217 /* Another NOTE for app programmers: 218 * A *positive* side-effect of assigning the first overlay buffer exactly at the end of the 219 * cardRAM is that apps that try to write beyond the buffer's space get a segfault immediately. 220 * This *greatly* simplifies tracking such errors! 221 * Of course such errors may lead to strange effects in the app or driver behaviour if they are 222 * not hunted down and removed.. */ 223 224 /* calculate first free RAM adress in card: 225 * Driver setup is as follows: 226 * card base: - hardware cursor bitmap (if used), 227 * directly above - screen memory for both heads */ 228 adress2 = (((uint32)((uint8*)si->fbc.frame_buffer)) + /* cursor already included here */ 229 (si->fbc.bytes_per_row * si->dm.virtual_height)); /* size in bytes of screen(s) */ 230 LOG(4,("Overlay: first free cardRAM virtual adress $%08x\n", adress2)); 231 232 /* calculate 'preliminary' buffer size including slopspace */ 233 oldsize = si->overlay.myBufInfo[offset].size; 234 si->overlay.myBufInfo[offset].size = 235 si->overlay.myBuffer[offset].bytes_per_row * si->overlay.myBuffer[offset].height; 236 237 /* calculate virtual memory adress that would be needed for a new bitmap */ 238 /* NOTE to app programmers: 239 * For testing app behaviour regarding workspace switches or screen prefs changes to settings 240 * that do not have enough cardRAM left for allocation of overlay bitmaps, you need a card with 241 * a low amount of RAM. Or you can set in the file matrox.settings for example: 242 * memory 8 #8Mb RAM on card 243 * and reboot (this simulates 8Mb RAM on the card). 244 * 245 * If you switch now to settings: 1600x1200x32bit (single head) the app needs to fallback to 246 * bitmap output or maybe single buffered overlay output if small bitmaps are used. */ 247 248 adress = (((uint32)((uint8*)si->framebuffer)) + (si->ps.memory_size * 1024 * 1024)); 249 for (cnt = 0; cnt <= offset; cnt++) 250 { 251 adress -= si->overlay.myBufInfo[cnt].size; 252 } 253 254 /* the > G200 scalers require buffers to be aligned to 16 byte pages cardRAM offset, G200 can do with 255 * 8 byte pages cardRAM offset. Compatible settings used, has no real downside consequences here */ 256 257 /* Check if we need to modify the buffers starting adress and thus the size */ 258 /* calculate 'would be' cardRAM offset */ 259 temp32 = (adress - ((uint32)((vuint32 *)si->framebuffer))); 260 /* check if it is aligned */ 261 if (temp32 != (temp32 & 0xfffffff0)) 262 { 263 /* update the (already calculated) buffersize to get it aligned */ 264 si->overlay.myBufInfo[offset].size += (temp32 - (temp32 & 0xfffffff0)); 265 /* update the (already calculated) adress to get it aligned */ 266 adress -= (temp32 - (temp32 & 0xfffffff0)); 267 } 268 LOG(4,("Overlay: new buffer needs virtual adress $%08x\n", adress)); 269 270 /* First check now if buffer to be defined is 'last one' in memory (speaking backwards): 271 * this is done to prevent a large buffer getting created in the space a small buffer 272 * occupied earlier, if not all buffers created were deleted. 273 * Note also that the app can delete the buffers in any order desired. */ 274 275 /* NOTE to app programmers: 276 * If you are going to delete a overlay buffer you created, you should delete them *all* and 277 * then re-create only the new ones needed. This way you are sure not to get unused memory- 278 * space in between your overlay buffers for instance, so cardRAM is used 'to the max'. 279 * If you don't, you might not get a buffer at all if you are trying to set up a larger one 280 * than before. 281 * (Indeed: not all buffers *have* to be of the same type and size...) */ 282 283 for (cnt = offset; cnt < MAXBUFFERS; cnt++) 284 { 285 if (si->overlay.myBuffer[cnt].buffer != NULL) 286 { 287 /* Check if the new buffer would fit into the space the single old one used here */ 288 if (si->overlay.myBufInfo[offset].size <= oldsize) 289 { 290 /* It does, so we reset to the old size and adresses to prevent the space from shrinking 291 * if we get here again... */ 292 adress -= (oldsize - si->overlay.myBufInfo[offset].size); 293 si->overlay.myBufInfo[offset].size = oldsize; 294 LOG(4,("Overlay: 'squeezing' in buffer:\n" 295 "Overlay: resetting it to virtual adress $%08x and size $%08x\n", adress,oldsize)); 296 /* force exiting the FOR loop */ 297 cnt = MAXBUFFERS; 298 } 299 else 300 { 301 /* nogo, sorry */ 302 LOG(4,("Overlay: Other buffer(s) exist after this one:\n" 303 "Overlay: not enough space to 'squeeze' this one in, aborted\n")); 304 305 /* Reset to the old size to prevent the space from 'growing' if we get here again... */ 306 si->overlay.myBufInfo[offset].size = oldsize; 307 308 /* release the shared benaphore */ 309 RELEASE_BEN(si->overlay.lock) 310 311 return NULL; 312 } 313 } 314 } 315 316 /* check if we have enough space to setup this new bitmap 317 * (preventing overlap of desktop RAMspace & overlay bitmap RAMspace here) */ 318 if (adress < adress2) 319 /* nope, sorry */ 320 { 321 LOG(4,("Overlay: Sorry, no more space for buffers: aborted\n")); 322 323 /* release the shared benaphore */ 324 RELEASE_BEN(si->overlay.lock) 325 326 return NULL; 327 } 328 /* continue buffer setup */ 329 si->overlay.myBuffer[offset].buffer = (void *) adress; 330 331 /* calculate physical memory adress (for dma use) */ 332 /* NOTE to app programmers: 333 * For testing app behaviour regarding workspace switches or screen prefs changes to settings 334 * that do not have enough cardRAM left for allocation of overlay bitmaps, you need a card with 335 * a low amount of RAM. Or you can set in the file matrox.settings for example: 336 * memory 8 #8Mb RAM on card 337 * and reboot (this simulates 8Mb RAM on the card). 338 * 339 * If you switch now to settings: 1600x1200x32bit (single head) the app needs to fallback to 340 * bitmap output or maybe single buffered overlay output if small bitmaps are used. */ 341 342 adress = (((uint32)((uint8*)si->framebuffer_pci)) + (si->ps.memory_size * 1024 * 1024)); 343 for (cnt = 0; cnt <= offset; cnt++) 344 { 345 adress -= si->overlay.myBufInfo[cnt].size; 346 } 347 /* this adress is already aligned to the scaler's requirements (via the already modified sizes) */ 348 si->overlay.myBuffer[offset].buffer_dma = (void *) adress; 349 350 LOG(4,("Overlay: New buffer: addr $%08x, dma_addr $%08x, color space $%08x\n", 351 (uint32)((uint8*)si->overlay.myBuffer[offset].buffer), 352 (uint32)((uint8*)si->overlay.myBuffer[offset].buffer_dma), cs)); 353 LOG(4,("Overlay: New buffer's size is $%08x\n", si->overlay.myBufInfo[offset].size)); 354 355 /* release the shared benaphore */ 356 RELEASE_BEN(si->overlay.lock) 357 358 return &si->overlay.myBuffer[offset]; 359 } 360 else 361 /* sorry, no more room for buffers */ 362 { 363 LOG(4,("Overlay: Sorry, no more space for buffers: aborted\n")); 364 365 /* release the shared benaphore */ 366 RELEASE_BEN(si->overlay.lock) 367 368 return NULL; 369 } 370 } 371 372 status_t RELEASE_OVERLAY_BUFFER(const overlay_buffer *ob) 373 /* Note that the user can delete the buffers in any order desired! */ 374 { 375 int offset = 0; 376 377 if (ob != NULL) 378 { 379 /* find the buffer */ 380 for (offset = 0; offset < MAXBUFFERS; offset++) 381 { 382 if (si->overlay.myBuffer[offset].buffer == ob->buffer) break; 383 } 384 385 if (offset < MAXBUFFERS) 386 /* delete current buffer */ 387 { 388 si->overlay.myBuffer[offset].buffer = NULL; 389 si->overlay.myBuffer[offset].buffer_dma = NULL; 390 391 LOG(4,("Overlay: Release_buffer offset = %d, buffer released\n",offset)); 392 393 return B_OK; 394 } 395 else 396 { 397 /* this is no buffer of ours! */ 398 LOG(4,("Overlay: Release_overlay_buffer: not ours, aborted!\n")); 399 400 return B_ERROR; 401 } 402 } 403 else 404 /* no buffer specified! */ 405 { 406 LOG(4,("Overlay: Release_overlay_buffer: no buffer specified, aborted!\n")); 407 408 return B_ERROR; 409 } 410 } 411 412 status_t GET_OVERLAY_CONSTRAINTS 413 (const display_mode *dm, const overlay_buffer *ob, overlay_constraints *oc) 414 { 415 int offset = 0; 416 417 LOG(4,("Overlay: Get_overlay_constraints called\n")); 418 419 /* check for NULL pointers */ 420 if ((dm == NULL) || (ob == NULL) || (oc == NULL)) 421 { 422 LOG(4,("Overlay: Get_overlay_constraints: Null pointer(s) detected!\n")); 423 return B_ERROR; 424 } 425 426 /* find the buffer */ 427 for (offset = 0; offset < MAXBUFFERS; offset++) 428 { 429 if (si->overlay.myBuffer[offset].buffer == ob->buffer) break; 430 } 431 432 if (offset < MAXBUFFERS) 433 { 434 /* scaler input (values are in pixels) */ 435 oc->view.h_alignment = 0; 436 oc->view.v_alignment = 0; 437 438 switch (ob->space) 439 { 440 case B_YCbCr422: 441 /* G200 can work with 3, > G200 need 7. Compatible setting returned for now. 442 * Note: this has to be in sync with the slopspace setup during buffer allocation.. */ 443 oc->view.width_alignment = 7; 444 break; 445 446 // case 0xffff://fixme: which one(s)? (4:2:0 supported formats. Not yet used...) 447 /* G200 can work with 7, > G200 need 31. Compatible setting returned for now. 448 * Note: this has to be in sync with the slopspace setup during buffer allocation.. */ 449 /* oc->view.width_alignment = 31; 450 break; 451 */ 452 default: 453 /* we should not be here, but set the worst-case value just to be safe anyway */ 454 oc->view.width_alignment = 31; 455 break; 456 } 457 458 oc->view.height_alignment = 0; 459 oc->view.width.min = 1; 460 oc->view.height.min = 2; /* two fields */ 461 oc->view.width.max = ob->width; 462 oc->view.height.max = ob->height; 463 464 /* scaler output restrictions */ 465 oc->window.h_alignment = 0; 466 oc->window.v_alignment = 0; 467 oc->window.width_alignment = 0; 468 oc->window.height_alignment = 0; 469 oc->window.width.min = 2; 470 /* G200-G550 can output upto and including 2048 pixels in width */ 471 if (dm->virtual_width > 2048) 472 { 473 oc->window.width.max = 2048; 474 } 475 else 476 { 477 oc->window.width.max = dm->virtual_width; 478 } 479 oc->window.height.min = 2; 480 /* G200-G550 can output upto and including 2048 pixels in height */ 481 if (dm->virtual_height > 2048) 482 { 483 oc->window.height.max = 2048; 484 } 485 else 486 { 487 oc->window.height.max = dm->virtual_height; 488 } 489 490 /* G200-G550 scaling restrictions */ 491 /* Adjust horizontal restrictions if pixelclock is above BES max. speed! */ 492 /* Note: If RGB32 is implemented no scaling is supported! */ 493 if (si->dm.timing.pixel_clock > BESMAXSPEED) 494 { 495 oc->h_scale.min = (1 * 2) / (32 - (1 / (float)16384)); 496 oc->h_scale.max = (16384 * 2)/(float)(ob->width - si->overlay.myBufInfo[offset].slopspace); 497 } 498 else 499 { 500 oc->h_scale.min = 1 / (32 - (1 / (float)16384)); 501 oc->h_scale.max = 16384/(float)(ob->width - si->overlay.myBufInfo[offset].slopspace); 502 } 503 oc->v_scale.min = 1 / (32 - (1 / (float)16384)); 504 oc->v_scale.max = 16384/(float)ob->height; 505 506 return B_OK; 507 } 508 else 509 { 510 /* this is no buffer of ours! */ 511 LOG(4,("Overlay: Get_overlay_constraints: buffer is not ours, aborted!\n")); 512 513 return B_ERROR; 514 } 515 } 516 517 overlay_token ALLOCATE_OVERLAY(void) 518 { 519 uint32 tmpToken; 520 LOG(4,("Overlay: Allocate_overlay called: ")); 521 522 /* come up with a token */ 523 tmpToken = 0x12345678; 524 525 /* acquire the shared benaphore */ 526 AQUIRE_BEN(si->overlay.lock) 527 528 /* overlay unit already in use? */ 529 if (si->overlay.myToken == NULL) 530 /* overlay unit is available */ 531 { 532 LOG(4,("succesfull\n")); 533 534 si->overlay.myToken = &tmpToken; 535 536 /* release the shared benaphore */ 537 RELEASE_BEN(si->overlay.lock) 538 539 return si->overlay.myToken; 540 } 541 else 542 /* sorry, overlay unit is occupied */ 543 { 544 LOG(4,("failed: already in use!\n")); 545 546 /* release the shared benaphore */ 547 RELEASE_BEN(si->overlay.lock) 548 549 return NULL; 550 } 551 } 552 553 status_t RELEASE_OVERLAY(overlay_token ot) 554 { 555 LOG(4,("Overlay: Release_overlay called: ")); 556 557 /* is this call for real? */ 558 if ((ot == NULL) || (si->overlay.myToken == NULL) || (ot != si->overlay.myToken)) 559 /* nope, abort */ 560 { 561 LOG(4,("failed, not in use!\n")); 562 563 return B_ERROR; 564 } 565 else 566 /* call is for real */ 567 { 568 569 gx00_release_bes(); 570 571 LOG(4,("succesfull\n")); 572 573 si->overlay.myToken = NULL; 574 return B_OK; 575 } 576 } 577 578 status_t CONFIGURE_OVERLAY 579 (overlay_token ot, const overlay_buffer *ob, const overlay_window *ow, const overlay_view *ov) 580 { 581 int offset = 0; /* used for buffer index */ 582 583 LOG(4,("Overlay: Configure_overlay called: ")); 584 585 /* Note: 586 * When a Workspace switch, screen prefs change, or overlay app shutdown occurs, BeOS will 587 * release all overlay buffers. The buffer currently displayed at that moment, may need some 588 * 'hardware releasing' in the CONFIGURE_OVERLAY routine. This is why CONFIGURE_OVERLAY gets 589 * called one more time then, with a null pointer for overlay_window and overlay_view, while 590 * the currently displayed overlay_buffer is given. 591 * The G200-G550 do not need to do anything on such an occasion, so we simply return if we 592 * get called then. */ 593 if ((ow == NULL) || (ov == NULL)) 594 { 595 LOG(4,("output properties changed\n")); 596 597 return B_OK; 598 } 599 600 /* Note: 601 * If during overlay use the screen prefs are changed, or the workspace has changed, it 602 * may be that we were not able to re-allocate the requested overlay buffers (or only partly) 603 * due to lack of cardRAM. If the app does not respond properly to this, we might end up 604 * with a NULL pointer instead of a overlay_buffer to work with here. 605 * Of course, we need to abort then to prevent the system from 'going down'. 606 * The app will probably crash because it will want to write into this non-existant buffer 607 * at some point. */ 608 if (ob == NULL) 609 { 610 LOG(4,("no overlay buffer specified\n")); 611 612 return B_ERROR; 613 } 614 615 /* is this call done by the app that owns us? */ 616 if ((ot == NULL) || (si->overlay.myToken == NULL) || (ot != si->overlay.myToken)) 617 /* nope, abort */ 618 { 619 LOG(4,("failed\n")); 620 621 return B_ERROR; 622 } 623 else 624 /* call is for real */ 625 { 626 /* find the buffer's offset */ 627 for (offset = 0; offset < MAXBUFFERS; offset++) 628 { 629 if (si->overlay.myBuffer[offset].buffer == ob->buffer) break; 630 } 631 632 if (offset < MAXBUFFERS) 633 { 634 LOG(4,("succesfull, switching to buffer %d\n", offset)); 635 636 gx00_configure_bes(ob, ow, ov, offset); 637 638 return B_OK; 639 } 640 else 641 { 642 /* this is no buffer of ours! */ 643 LOG(4,("buffer is not ours, aborted!\n")); 644 645 return B_ERROR; 646 } 647 } 648 } 649