Ticket #5314: ATI_AddOverlayPatch.diff
File ATI_AddOverlayPatch.diff, 48.9 KB (added by , 13 years ago) |
---|
-
headers/private/graphics/ati/DriverInterface.h
1 1 /* 2 Copyright 2007-20 09Haiku, Inc. All rights reserved.2 Copyright 2007-2011 Haiku, Inc. All rights reserved. 3 3 Distributed under the terms of the MIT license. 4 4 5 5 Authors: 6 Gerald Zajac 2007-20096 Gerald Zajac 7 7 */ 8 8 9 9 #ifndef DRIVERINTERFACE_H … … 14 14 #include <GraphicsDefs.h> 15 15 #include <Drivers.h> 16 16 #include <edid.h> 17 #include <video_overlay.h> 17 18 18 19 19 20 // This file contains info that is shared between the kernel driver and the … … 163 164 }; 164 165 165 166 167 struct OverlayBuffer : overlay_buffer { 168 OverlayBuffer* nextBuffer; // pointer to next buffer in chain, NULL = none 169 uint32 size; // size of overlay buffer 170 }; 171 172 166 173 struct SharedInfo { 167 174 // Device ID info. 168 175 uint16 vendorID; // PCI vendor ID, from pci_info … … 180 187 area_id regsArea; // area_id for the memory mapped registers. It will 181 188 // be cloned into accelerant's address space. 182 189 area_id videoMemArea; // video memory area_id. The addresses are shared with all teams. 183 void*videoMemAddr; // video memory addr as viewed from virtual memory184 void* videoMemPCI;// video memory addr as viewed from the PCI bus (for DMA)190 addr_t videoMemAddr; // video memory addr as viewed from virtual memory 191 phys_addr_t videoMemPCI; // video memory addr as viewed from the PCI bus (for DMA) 185 192 uint32 videoMemSize; // video memory size in bytes. 186 193 187 194 uint32 cursorOffset; // offset of cursor in video memory … … 209 216 bool bHaveEDID; // true = EDID info from device is in edidInfo 210 217 211 218 Benaphore engineLock; // for serializing access to the acceleration engine 219 Benaphore overlayLock; // for overlay operations 212 220 221 int32 overlayAllocated; // non-zero if overlay is allocated 222 uint32 overlayToken; 223 OverlayBuffer* overlayBuffer; // pointer to linked list of buffers; NULL = none 224 213 225 MonitorType displayType; 214 226 215 227 uint16 panelX; // laptop LCD width … … 227 239 R128_RAMSpec r128MemSpec; // Rage128 memory timing spec's 228 240 R128_PLLParams r128PLLParams; // Rage128 PLL parameters from video BIOS ROM 229 241 230 uint32 242 uint32 r128_dpGuiMasterCntl; // flags for accelerated drawing 231 243 }; 232 244 233 245 -
src/add-ons/kernel/drivers/graphics/ati/driver.cpp
1 1 /* 2 Copyright 2007-20 09Haiku, Inc. All rights reserved.2 Copyright 2007-2011 Haiku, Inc. All rights reserved. 3 3 Distributed under the terms of the MIT license. 4 4 5 5 Authors: 6 Gerald Zajac 2007-20096 Gerald Zajac 7 7 */ 8 8 9 9 #include <KernelExport.h> … … 20 20 21 21 #undef TRACE 22 22 23 //#define ENABLE_DEBUG_TRACE24 23 #ifdef ENABLE_DEBUG_TRACE 25 24 # define TRACE(x...) dprintf("ati: " x) 26 25 #else … … 41 40 #define M64_BIOS_SIZE 0x10000 // 64KB 42 41 #define R128_BIOS_SIZE 0x10000 // 64KB 43 42 44 int32 api_version = B_CUR_DRIVER_API_VERSION; // revision of driver API we support43 int32 api_version = B_CUR_DRIVER_API_VERSION; // revision of driver API used 45 44 46 45 #define VENDOR_ID 0x1002 // ATI vendor ID 47 46 … … 54 53 struct ChipInfo { 55 54 uint16 chipID; // PCI device id of the chip 56 55 ChipType chipType; // assigned chip type identifier 57 const char* chipName; // user recognizable name for chip (must be < 32 chars) 56 const char* chipName; // user recognizable name for chip 57 // (must be < 32 chars) 58 58 }; 59 59 60 60 … … 199 199 static inline uint32 200 200 GetPCI(pci_info& info, uint8 offset, uint8 size) 201 201 { 202 return gPCI->read_pci_config(info.bus, info.device, info.function, offset, size); 202 return gPCI->read_pci_config(info.bus, info.device, info.function, offset, 203 size); 203 204 } 204 205 205 206 206 207 static inline void 207 208 SetPCI(pci_info& info, uint8 offset, uint8 size, uint32 value) 208 209 { 209 gPCI->write_pci_config(info.bus, info.device, info.function, offset, size, value); 210 gPCI->write_pci_config(info.bus, info.device, info.function, offset, size, 211 value); 210 212 } 211 213 212 214 … … 251 253 252 254 status_t status = vm86_prepare(&vmState, 0x2000); 253 255 if (status != B_OK) { 254 TRACE("GetEdidFromBIOS(); vm86_prepare() failed, status: 0x%lx\n", status); 256 TRACE("GetEdidFromBIOS(); vm86_prepare() failed, status: 0x%lx\n", 257 status); 255 258 return status; 256 259 } 257 260 … … 337 340 338 341 status_t status = vm86_prepare(&vmState, 0x2000); 339 342 if (status != B_OK) { 340 TRACE("SetVesaDisplayMode(); vm86_prepare() failed, status: 0x%lx\n", status); 343 TRACE("SetVesaDisplayMode(); vm86_prepare() failed, status: 0x%lx\n", 344 status); 341 345 return status; 342 346 } 343 347 … … 505 509 pll.max_pll_freq = BIOS32(pllInfoBlock + 0x16); 506 510 pll.xclk = BIOS16(pllInfoBlock + 0x08); 507 511 508 TRACE("PLL parameters: rf=%d rd=%d min=%ld max=%ld; xclk=%d\n", pll.reference_freq, 509 pll.reference_div, pll.min_pll_freq, pll.max_pll_freq, pll.xclk); 512 TRACE("PLL parameters: rf=%d rd=%d min=%ld max=%ld; xclk=%d\n", 513 pll.reference_freq, pll.reference_div, pll.min_pll_freq, 514 pll.max_pll_freq, pll.xclk); 510 515 511 516 // If Mobility chip, get the LCD panel width & height and a few other 512 517 // related parameters. … … 537 542 si.panelY = BIOS16(fpStart + 27); 538 543 si.panelPowerDelay = BIOS8(fpStart + 56); 539 544 TRACE("LCD Panel size: %dx%d Panel type: 0x%x power delay: %d\n", 540 si.panelX, si.panelY, BIOS16(fpStart + 29), si.panelPowerDelay); 545 si.panelX, si.panelY, BIOS16(fpStart + 29), 546 si.panelPowerDelay); 541 547 break; 542 548 } 543 549 } … … 566 572 567 573 // Map the video memory. 568 574 569 uint32videoRamAddr = pciInfo.u.h0.base_registers[0];575 phys_addr_t videoRamAddr = pciInfo.u.h0.base_registers[0]; 570 576 uint32 videoRamSize = pciInfo.u.h0.base_register_sizes[0]; 571 si.videoMemPCI = (void *)videoRamAddr;577 si.videoMemPCI = videoRamAddr; 572 578 char frameBufferAreaName[] = "ATI frame buffer"; 573 579 574 580 si.videoMemArea = map_physical_memory( … … 577 583 videoRamSize, 578 584 B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC, 579 585 B_READ_AREA + B_WRITE_AREA, 580 &(si.videoMemAddr));586 (void**)&(si.videoMemAddr)); 581 587 582 588 if (si.videoMemArea < 0) { 583 589 // Try to map this time without write combining. … … 587 593 videoRamSize, 588 594 B_ANY_KERNEL_BLOCK_ADDRESS, 589 595 B_READ_AREA + B_WRITE_AREA, 590 &(si.videoMemAddr));596 (void**)&(si.videoMemAddr)); 591 597 } 592 598 593 599 if (si.videoMemArea < 0) … … 595 601 596 602 // Map the MMIO register area. 597 603 598 uint32regsBase = pciInfo.u.h0.base_registers[2];604 phys_addr_t regsBase = pciInfo.u.h0.base_registers[2]; 599 605 uint32 regAreaSize = pciInfo.u.h0.base_register_sizes[2]; 600 606 601 607 // If the register area address or size is not in the PCI info, it should … … 619 625 620 626 regsBase = videoRamAddr + regsOffset; 621 627 regAreaSize = 0x1000; 622 TRACE("Register address is at end of frame buffer memory at 0x%lx\n", regsBase); 628 TRACE("Register address is at end of frame buffer memory at 0x%lx\n", 629 uint32(regsBase)); 623 630 } 624 631 625 632 si.regsArea = map_physical_memory("ATI mmio registers", … … 627 634 regAreaSize, 628 635 B_ANY_KERNEL_ADDRESS, 629 636 0, // neither read nor write, to hide it from user space apps 630 (void**) (&(di.regs)));637 (void**)&di.regs); 631 638 632 639 // If there was an error, delete other areas. 633 640 if (si.regsArea < 0) { … … 650 657 delete_area(si.videoMemArea); 651 658 652 659 si.regsArea = si.videoMemArea = -1; 653 si.videoMemAddr = NULL;660 si.videoMemAddr = (addr_t)NULL; 654 661 di.regs = NULL; 655 662 } 656 663 … … 768 775 si.vesaModeTableOffset = sharedSize; 769 776 si.vesaModeCount = vesaModeTableSize / sizeof(VesaMode); 770 777 771 memcpy((uint8*)&si + si.vesaModeTableOffset, vesaModes, vesaModeTableSize); 778 memcpy((uint8*)&si + si.vesaModeTableOffset, vesaModes, 779 vesaModeTableSize); 772 780 } 773 781 774 782 pci_info& pciInfo = di.pciInfo; … … 892 900 pci_info pciInfo; 893 901 const ChipInfo* pDevice = GetNextSupportedDevice(pciIndex, pciInfo); 894 902 895 TRACE("init_hardware() - %s\n", pDevice == NULL ? "no supported devices" : "device supported"); 903 TRACE("init_hardware() - %s\n", 904 pDevice == NULL ? "no supported devices" : "device supported"); 896 905 897 906 put_module(B_PCI_MODULE_NAME); // put away the module manager 898 907 … … 900 909 } 901 910 902 911 903 status_t init_driver(void) 912 status_t 913 init_driver(void) 904 914 { 905 915 // Get handle for the pci bus. 906 916 … … 1011 1021 *cookie = &di; // send cookie to opener 1012 1022 } 1013 1023 1014 TRACE("device_open() returning 0x%lx, open count: %ld\n", status, di.openCount); 1024 TRACE("device_open() returning 0x%lx, open count: %ld\n", status, 1025 di.openCount); 1015 1026 return status; 1016 1027 } 1017 1028 … … 1019 1030 static status_t 1020 1031 device_read(void* dev, off_t pos, void* buf, size_t* len) 1021 1032 { 1022 // Following 3 lines of code are here to eliminate "unused parameter" warnings. 1033 // Following 3 lines of code are here to eliminate "unused parameter" 1034 // warnings. 1023 1035 (void)dev; 1024 1036 (void)pos; 1025 1037 (void)buf; … … 1032 1044 static status_t 1033 1045 device_write(void* dev, off_t pos, const void* buf, size_t* len) 1034 1046 { 1035 // Following 3 lines of code are here to eliminate "unused parameter" warnings. 1047 // Following 3 lines of code are here to eliminate "unused parameter" 1048 // warnings. 1036 1049 (void)dev; 1037 1050 (void)pos; 1038 1051 (void)buf; … … 1068 1081 DisableVBI(); // disable & clear any pending interrupts 1069 1082 1070 1083 if (si.bInterruptAssigned) { 1071 remove_io_interrupt_handler(pciInfo.u.h0.interrupt_line, InterruptHandler, &di); 1084 remove_io_interrupt_handler(pciInfo.u.h0.interrupt_line, 1085 InterruptHandler, &di); 1072 1086 } 1073 1087 1074 // Delete the semaphores, ignoring any errors because the owning team may have died. 1088 // Delete the semaphores, ignoring any errors because the owning team 1089 // may have died. 1075 1090 if (si.vertBlankSem >= 0) 1076 1091 delete_sem(si.vertBlankSem); 1077 1092 si.vertBlankSem = -1; … … 1098 1113 { 1099 1114 DeviceInfo& di = *((DeviceInfo*)dev); 1100 1115 1101 // TRACE("device_ioctl(); ioctl: %lu, buffer: 0x%08lx, bufLen: %lu\n", msg, (uint32)buffer, bufferLength); 1116 // TRACE("device_ioctl(); ioctl: %lu, buffer: 0x%08lx, bufLen: %lu\n", msg, 1117 // (uint32)buffer, bufferLength); 1102 1118 1103 1119 switch (msg) { 1104 1120 case B_GET_ACCELERANT_SIGNATURE: -
src/add-ons/accelerants/ati/accelerant.h
1 1 /* 2 Copyright 2007-20 09Haiku, Inc. All rights reserved.2 Copyright 2007-2011 Haiku, Inc. All rights reserved. 3 3 Distributed under the terms of the MIT license. 4 4 5 5 Authors: 6 Gerald Zajac 2007-20096 Gerald Zajac 7 7 */ 8 8 9 9 #ifndef _ACCELERANT_H … … 52 52 status_t (*SetDPMSMode)(uint32 dpms_flags); 53 53 54 54 // Pointers to cursor functions. 55 bool (*LoadCursorImage)(int width, int height, uint8* and_mask, uint8* xor_mask); 55 bool (*LoadCursorImage)(int width, int height, uint8* and_mask, 56 uint8* xor_mask); 56 57 void (*SetCursorPosition)(int x, int y); 57 58 void (*ShowCursor)(bool bShow); 58 59 59 60 // Pointers to 2D acceleration functions. 60 void (*FillRectangle)(engine_token*, uint32 color, fill_rect_params*, uint32 count); 61 void (*FillSpan)(engine_token*, uint32 color, uint16* list, uint32 count); 61 void (*FillRectangle)(engine_token*, uint32 color, fill_rect_params*, 62 uint32 count); 63 void (*FillSpan)(engine_token*, uint32 color, uint16* list, 64 uint32 count); 62 65 void (*InvertRectangle)(engine_token*, fill_rect_params*, uint32 count); 63 66 void (*ScreenToScreenBlit)(engine_token*, blit_params*, uint32 count); 64 67 65 68 // Pointers to other functions. 66 69 void (*AdjustFrame)(const DisplayModeEx& mode); 67 70 status_t (*ChipInit)(void); 68 bool (*GetColorSpaceParams)(int colorSpace, uint8& bpp, uint32& maxPixelClk); 71 bool (*GetColorSpaceParams)(int colorSpace, uint8& bpp, 72 uint32& maxPixelClk); 69 73 status_t (*SetDisplayMode)(const DisplayModeEx& mode); 70 void (*SetIndexedColors)(uint count, uint8 first, uint8* color_data, uint32 flags); 74 void (*SetIndexedColors)(uint count, uint8 first, uint8* color_data, 75 uint32 flags); 71 76 }; 72 77 73 78 extern AccelerantInfo gInfo; … … 95 100 // Mode Configuration 96 101 uint32 AccelerantModeCount(void); 97 102 status_t GetModeList(display_mode* dm); 98 status_t ProposeDisplayMode(display_mode* target, const display_mode* low, const display_mode* high); 103 status_t ProposeDisplayMode(display_mode* target, const display_mode* low, 104 const display_mode* high); 99 105 status_t SetDisplayMode(display_mode* mode_to_set); 100 106 status_t GetDisplayMode(display_mode* current_mode); 101 107 status_t GetFrameBufferConfig(frame_buffer_config* a_frame_buffer); 102 108 status_t GetPixelClockLimits(display_mode* dm, uint32* low, uint32* high); 103 109 status_t MoveDisplay(uint16 h_display_start, uint16 v_display_start); 104 110 status_t GetTimingConstraints(display_timing_constraints* dtc); 105 void Mach64_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); 106 void Rage128_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); 111 void Mach64_SetIndexedColors(uint count, uint8 first, uint8* color_data, 112 uint32 flags); 113 void Rage128_SetIndexedColors(uint count, uint8 first, uint8* color_data, 114 uint32 flags); 107 115 status_t GetPreferredDisplayMode(display_mode* preferredMode); 108 116 status_t GetEdidInfo(void* info, size_t size, uint32* _version); 109 117 … … 118 126 119 127 // Cursor 120 128 status_t SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, 121 129 uint8* andMask, uint8* xorMask); 122 130 void MoveCursor(uint16 x, uint16 y); 123 131 124 132 // Engine Management 125 133 uint32 AccelerantEngineCount(void); 126 status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st, engine_token** et); 134 status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st, 135 engine_token** et); 127 136 status_t ReleaseEngine(engine_token* et, sync_token* st); 128 137 void WaitEngineIdle(void); 129 138 status_t GetSyncToken(engine_token* et, sync_token* st); 130 139 status_t SyncToToken(sync_token* st); 131 140 132 141 // 2D acceleration 133 void Mach64_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); 134 void Mach64_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); 135 void Mach64_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); 136 void Mach64_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); 142 void Mach64_FillRectangle(engine_token* et, uint32 color, 143 fill_rect_params* list, uint32 count); 144 void Mach64_FillSpan(engine_token* et, uint32 color, uint16* list, 145 uint32 count); 146 void Mach64_InvertRectangle(engine_token* et, fill_rect_params* list, 147 uint32 count); 148 void Mach64_ScreenToScreenBlit(engine_token* et, blit_params* list, 149 uint32 count); 137 150 138 void Rage128_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); 139 void Rage128_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); 140 void Rage128_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); 141 void Rage128_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); 151 void Rage128_FillRectangle(engine_token* et, uint32 color, 152 fill_rect_params* list, uint32 count); 153 void Rage128_FillSpan(engine_token* et, uint32 color, uint16* list, 154 uint32 count); 155 void Rage128_InvertRectangle(engine_token* et, fill_rect_params* list, 156 uint32 count); 157 void Rage128_ScreenToScreenBlit(engine_token* et, blit_params* list, 158 uint32 count); 142 159 160 // Video_overlay 161 uint32 OverlayCount(const display_mode* dm); 162 const uint32* OverlaySupportedSpaces(const display_mode* dm); 163 uint32 OverlaySupportedFeatures(uint32 a_color_space); 164 const overlay_buffer* AllocateOverlayBuffer(color_space cs, uint16 width, 165 uint16 height); 166 status_t ReleaseOverlayBuffer(const overlay_buffer* ob); 167 status_t GetOverlayConstraints(const display_mode* dm, 168 const overlay_buffer* ob, overlay_constraints* oc); 169 overlay_token AllocateOverlay(void); 170 status_t ReleaseOverlay(overlay_token ot); 171 status_t ConfigureOverlay(overlay_token ot, const overlay_buffer* ob, 172 const overlay_window* ow, const overlay_view* ov); 173 143 174 #if defined(__cplusplus) 144 175 } 145 176 #endif … … 156 187 157 188 // Mach64 functions. 158 189 190 bool Mach64_DisplayOverlay(const overlay_window* window, 191 const overlay_buffer* buffer); 192 void Mach64_StopOverlay(void); 193 159 194 void Mach64_EngineReset(void); 160 195 void Mach64_EngineInit(const DisplayModeEx& mode); 161 196 162 bool Mach64_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); 197 bool Mach64_LoadCursorImage(int width, int height, uint8* and_mask, 198 uint8* xor_mask); 163 199 void Mach64_SetCursorPosition(int x, int y); 164 200 void Mach64_ShowCursor(bool bShow); 165 201 … … 167 203 status_t Mach64_SetDisplayMode(const DisplayModeEx& mode); 168 204 void Mach64_SetFunctionPointers(void); 169 205 170 int Mach64_Divide(int numerator, int denom, int shift, const int roundingKind); 171 void Mach64_ReduceRatio(int *numerator, int *denominator); 206 int Mach64_Divide(int numerator, int denom, int shift, 207 const int roundingKind); 208 void Mach64_ReduceRatio(int* numerator, int* denominator); 172 209 173 210 174 211 // Rage128 functions. 175 212 213 bool Rage128_DisplayOverlay(const overlay_window* window, 214 const overlay_buffer* buffer); 215 void Rage128_StopOverlay(void); 216 176 217 void Rage128_EngineFlush(void); 177 218 void Rage128_EngineReset(void); 178 219 void Rage128_EngineInit(const DisplayModeEx& mode); 179 220 180 221 bool Rage128_GetEdidInfo(void); 181 222 182 bool Rage128_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); 223 bool Rage128_LoadCursorImage(int width, int height, uint8* and_mask, 224 uint8* xor_mask); 183 225 void Rage128_SetCursorPosition(int x, int y); 184 226 void Rage128_ShowCursor(bool bShow); 185 227 -
src/add-ons/accelerants/ati/rage128_overlay.cpp
1 /* 2 Haiku ATI video driver adapted from the X.org ATI driver which has the 3 following copyright: 4 5 Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, 6 Precision Insight, Inc., Cedar Park, Texas, and 7 VA Linux Systems Inc., Fremont, California. 8 9 Copyright 2011 Haiku, Inc. All rights reserved. 10 Distributed under the terms of the MIT license. 11 12 Authors: 13 Gerald Zajac 14 */ 15 16 #include "accelerant.h" 17 #include "rage128.h" 18 19 20 static uint32 sCurrentKeyColor = 0; 21 static uint32 sCurrentKeyMask = 0; 22 23 24 25 bool 26 Rage128_DisplayOverlay(const overlay_window* window, 27 const overlay_buffer* buffer) 28 { 29 // Return true if setup is successful. 30 31 SharedInfo& si = *gInfo.sharedInfo; 32 33 if (window == NULL || buffer == NULL) 34 return false; 35 36 if (buffer->space != B_YCbCr422) 37 return false; // color space not supported 38 39 uint32 keyColor = 0; 40 uint32 keyMask = 0; 41 42 switch (si.displayMode.bitsPerPixel) { 43 case 15: 44 keyMask = 0x7fff; 45 keyColor = (window->blue.value & window->blue.mask) << 0 46 | (window->green.value & window->green.mask) << 5 47 | (window->red.value & window->red.mask) << 10; 48 // 15 bit color has no alpha bits 49 break; 50 case 16: 51 keyMask = 0xffff; 52 keyColor = (window->blue.value & window->blue.mask) << 0 53 | (window->green.value & window->green.mask) << 5 54 | (window->red.value & window->red.mask) << 11; 55 // 16 bit color has no alpha bits 56 break; 57 default: 58 keyMask = 0xffffffff; 59 keyColor = (window->blue.value & window->blue.mask) << 0 60 | (window->green.value & window->green.mask) << 8 61 | (window->red.value & window->red.mask) << 16 62 | (window->alpha.value & window->alpha.mask) << 24; 63 break; 64 } 65 66 // If the key color or key mask has changed since the overlay was 67 // previously initialized, initialize it again. This is to avoid 68 // initializing the overlay video everytime the overlay buffer is 69 // switched which causes artifacts in the overlay display. 70 71 if (keyColor != sCurrentKeyColor || keyMask != sCurrentKeyMask) 72 { 73 TRACE("Rage128_DisplayOverlay() initializing overlay video\n"); 74 75 // Initialize the overlay video by first resetting the video. 76 77 OUTREG(R128_OV0_SCALE_CNTL, 0); 78 OUTREG(R128_OV0_EXCLUSIVE_HORZ, 0); 79 OUTREG(R128_OV0_AUTO_FLIP_CNTL, 0); 80 OUTREG(R128_OV0_FILTER_CNTL, 0x0000000f); 81 82 const uint32 brightness = 0; 83 const uint32 saturation = 16; 84 OUTREG(R128_OV0_COLOUR_CNTL, brightness | saturation << 8 85 | saturation << 16); 86 87 OUTREG(R128_OV0_GRAPHICS_KEY_MSK, keyMask); 88 OUTREG(R128_OV0_GRAPHICS_KEY_CLR, keyColor); 89 OUTREG(R128_OV0_KEY_CNTL, R128_GRAPHIC_KEY_FN_NE); 90 OUTREG(R128_OV0_TEST, 0); 91 92 sCurrentKeyColor = keyColor; 93 sCurrentKeyMask = keyMask; 94 } 95 96 uint32 ecpDiv; 97 if (si.displayMode.timing.pixel_clock < 125000) 98 ecpDiv = 0; 99 else if (si.displayMode.timing.pixel_clock < 250000) 100 ecpDiv = 1; 101 else 102 ecpDiv = 2; 103 104 SetPLLReg(R128_VCLK_ECP_CNTL, ecpDiv << 8, R128_ECP_DIV_MASK); 105 106 int32 vertInc = (buffer->height << 20) / window->height; 107 int32 horzInc = (buffer->width << (12 + ecpDiv)) / window->width; 108 int32 stepBy = 1; 109 110 while (horzInc >= (2 << 12)) { 111 stepBy++; 112 horzInc >>= 1; 113 } 114 115 int32 x1 = window->h_start; 116 int32 y1 = window->v_start; 117 118 int32 x2 = window->h_start + window->width; 119 int32 y2 = window->v_start + window->height; 120 121 int32 left = x1; 122 int32 tmp = (left & 0x0003ffff) + 0x00028000 + (horzInc << 3); 123 int32 p1_h_accum_init = ((tmp << 4) & 0x000f8000) | 124 ((tmp << 12) & 0xf0000000); 125 126 tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (horzInc << 2); 127 int32 p23_h_accum_init = ((tmp << 4) & 0x000f8000) | 128 ((tmp << 12) & 0x70000000); 129 130 tmp = (y1 & 0x0000ffff) + 0x00018000; 131 int32 p1_v_accum_init = ((tmp << 4) & 0x03ff8000) | 0x00000001; 132 133 // Compute offset of overlay buffer in the video memory. 134 uint32 offset = uint32(buffer->buffer) - si.videoMemAddr; 135 136 OUTREG(R128_OV0_REG_LOAD_CNTL, 1); 137 while (!(INREG(R128_OV0_REG_LOAD_CNTL) & (1 << 3))) 138 ; 139 140 OUTREG(R128_OV0_H_INC, horzInc | ((horzInc >> 1) << 16)); 141 OUTREG(R128_OV0_STEP_BY, stepBy | (stepBy << 8)); 142 OUTREG(R128_OV0_Y_X_START, x1 | y1 << 16); 143 OUTREG(R128_OV0_Y_X_END, x2 | y2 << 16); 144 OUTREG(R128_OV0_V_INC, vertInc); 145 OUTREG(R128_OV0_P1_BLANK_LINES_AT_TOP, 146 0x00000fff | ((buffer->height - 1) << 16)); 147 OUTREG(R128_OV0_VID_BUF_PITCH0_VALUE, buffer->bytes_per_row); 148 149 int32 width = window->width; 150 left = 0; 151 OUTREG(R128_OV0_P1_X_START_END, (width - 1) | (left << 16)); 152 width >>= 1; 153 OUTREG(R128_OV0_P2_X_START_END, (width - 1) | (left << 16)); 154 OUTREG(R128_OV0_P3_X_START_END, (width - 1) | (left << 16)); 155 OUTREG(R128_OV0_VID_BUF0_BASE_ADRS, offset); 156 OUTREG(R128_OV0_P1_V_ACCUM_INIT, p1_v_accum_init); 157 OUTREG(R128_OV0_P23_V_ACCUM_INIT, 0); 158 OUTREG(R128_OV0_P1_H_ACCUM_INIT, p1_h_accum_init); 159 OUTREG(R128_OV0_P23_H_ACCUM_INIT, p23_h_accum_init); 160 161 OUTREG(R128_OV0_SCALE_CNTL, 0x41FF8B03); 162 OUTREG(R128_OV0_REG_LOAD_CNTL, 0); 163 164 return true; 165 } 166 167 168 void 169 Rage128_StopOverlay(void) 170 { 171 OUTREG(R128_OV0_SCALE_CNTL, 0); // reset the video 172 173 // Reset the key color and mask so that when the overlay is started again 174 // it will be initialized. 175 176 sCurrentKeyColor = 0; 177 sCurrentKeyMask = 0; 178 } -
src/add-ons/accelerants/ati/rage128.h
1 1 /* 2 Haiku ATI video driver adapted from the X.org ATI driver. 2 Haiku ATI video driver adapted from the X.org ATI driver which has the 3 following copyright: 3 4 4 5 Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, 5 6 Precision Insight, Inc., Cedar Park, Texas, and 6 7 VA Linux Systems Inc., Fremont, California. 7 8 8 Copyright 2009 Haiku, Inc. All rights reserved.9 Copyright 2009, 2011 Haiku, Inc. All rights reserved. 9 10 Distributed under the terms of the MIT license. 10 11 11 12 Authors: 12 Gerald Zajac 200913 Gerald Zajac 13 14 */ 14 15 15 16 … … 17 18 #define __RAGE128_H__ 18 19 19 20 20 #define CURSOR_BYTES 1024 21 #define CURSOR_BYTES 1024 // bytes used for cursor image in video memory 21 22 22 23 #define R128_TIMEOUT 2000000 // Fall out of wait loops after this count 23 24 … … 203 204 #define R128_OVR_CLR 0x0230 204 205 #define R128_OVR_WID_LEFT_RIGHT 0x0234 205 206 #define R128_OVR_WID_TOP_BOTTOM 0x0238 206 #define R128_OV0_SCALE_CNTL 0x0420207 207 208 208 #define R128_PALETTE_DATA 0x00b4 209 209 #define R128_PALETTE_INDEX 0x00b0 … … 231 231 232 232 #define R128_TMDS_CRC 0x02a0 233 233 234 #define R128_VCLK_ECP_CNTL 0x0008 // PLL 235 # define R128_VCLK_SRC_SEL_MASK 0x03 236 # define R128_VCLK_SRC_SEL_CPUCLK 0x00 237 # define R128_VCLK_SRC_SEL_PPLLCLK 0x03 234 #define R128_VCLK_ECP_CNTL 0x0008 // PLL 235 # define R128_VCLK_SRC_SEL_MASK 0x03 236 # define R128_VCLK_SRC_SEL_CPUCLK 0x00 237 # define R128_VCLK_SRC_SEL_PPLLCLK 0x03 238 # define R128_ECP_DIV_MASK (3 << 8) 238 239 #define R128_VIPH_CONTROL 0x01D0 // ? 239 240 240 241 242 // Definitions used for overlays. 243 //=============================== 241 244 245 #define R128_OV0_Y_X_START 0x0400 246 #define R128_OV0_Y_X_END 0x0404 247 #define R128_OV0_EXCLUSIVE_HORZ 0x0408 248 #define R128_OV0_REG_LOAD_CNTL 0x0410 249 #define R128_OV0_SCALE_CNTL 0x0420 250 #define R128_OV0_V_INC 0x0424 251 #define R128_OV0_P1_V_ACCUM_INIT 0x0428 252 #define R128_OV0_P23_V_ACCUM_INIT 0x042C 253 #define R128_OV0_P1_BLANK_LINES_AT_TOP 0x0430 254 #define R128_OV0_VID_BUF0_BASE_ADRS 0x0440 255 #define R128_OV0_VID_BUF_PITCH0_VALUE 0x0460 256 #define R128_OV0_AUTO_FLIP_CNTL 0x0470 257 #define R128_OV0_H_INC 0x0480 258 #define R128_OV0_STEP_BY 0x0484 259 #define R128_OV0_P1_H_ACCUM_INIT 0x0488 260 #define R128_OV0_P23_H_ACCUM_INIT 0x048C 261 #define R128_OV0_P1_X_START_END 0x0494 262 #define R128_OV0_P2_X_START_END 0x0498 263 #define R128_OV0_P3_X_START_END 0x049C 264 #define R128_OV0_FILTER_CNTL 0x04A0 265 #define R128_OV0_COLOUR_CNTL 0x04E0 266 #define R128_OV0_GRAPHICS_KEY_CLR 0x04EC 267 #define R128_OV0_GRAPHICS_KEY_MSK 0x04F0 268 #define R128_OV0_KEY_CNTL 0x04F4 269 # define R128_GRAPHIC_KEY_FN_EQ 0x00000040L 270 # define R128_GRAPHIC_KEY_FN_NE 0x00000050L 271 #define R128_OV0_TEST 0x04F8 272 273 274 242 275 // Functions to get/set PLL registers. 243 276 //======================================= 244 277 -
src/add-ons/accelerants/ati/overlay.cpp
1 /* 2 Copyright 2011 Haiku, Inc. All rights reserved. 3 Distributed under the terms of the MIT license. 4 5 Authors: 6 Gerald Zajac 7 */ 8 9 #include "accelerant.h" 10 #include "rage128.h" 11 12 #include <stdlib.h> 13 14 15 16 uint32 17 OverlayCount(const display_mode* mode) 18 { 19 (void)mode; // avoid compiler warning for unused arg 20 21 return 1; 22 } 23 24 25 const uint32* 26 OverlaySupportedSpaces(const display_mode* mode) 27 { 28 (void)mode; // avoid compiler warning for unused arg 29 30 static const uint32 kSupportedSpaces[] = {B_YCbCr422, 0}; 31 32 return kSupportedSpaces; 33 } 34 35 36 uint32 37 OverlaySupportedFeatures(uint32 colorSpace) 38 { 39 (void)colorSpace; // avoid compiler warning for unused arg 40 41 return B_OVERLAY_COLOR_KEY 42 | B_OVERLAY_HORIZONTAL_FILTERING 43 | B_OVERLAY_VERTICAL_FILTERING; 44 } 45 46 47 const overlay_buffer* 48 AllocateOverlayBuffer(color_space colorSpace, uint16 width, uint16 height) 49 { 50 SharedInfo& si = *gInfo.sharedInfo; 51 52 TRACE("AllocateOverlayBuffer() width %u, height %u, colorSpace 0x%lx\n", 53 width, height, colorSpace); 54 55 // If Mach 64 chip, check hardware limits. 56 57 if (MACH64_FAMILY(si.chipType)) { 58 if (height > 2048 || width > 768 59 || (width > 384 && si.chipType < MACH64_264VTB) 60 || (width > 720 && (si.chipType < MACH64_264GTPRO 61 || si.chipType > MACH64_264LTPRO))) 62 return NULL; 63 } 64 65 si.overlayLock.Acquire(); 66 67 // Note: When allocating buffers, buffer allocation starts at the end of 68 // video memory, and works backward to the end of the video frame buffer. 69 // The allocated buffers are recorded in a linked list of OverlayBuffer 70 // objects which are ordered by the buffer address with the first object 71 // in the list having the highest buffer address. 72 73 if (colorSpace != B_YCbCr422) { 74 si.overlayLock.Release(); 75 TRACE("AllocateOverlayBuffer() unsupported color space 0x%x\n", 76 colorSpace); 77 return NULL; 78 } 79 80 uint32 bytesPerPixel = 2; // B_YCbCr422 uses 2 bytes per pixel 81 82 // Calculate required buffer size as a multiple of 1K. 83 uint32 buffSize = (width * bytesPerPixel * height + 0x3ff) & ~0x3ff; 84 85 OverlayBuffer* ovBuff = si.overlayBuffer; 86 OverlayBuffer* prevOvBuff = NULL; 87 88 // If no buffers have been allocated, prevBuffAddr calculated here will be 89 // the address where the buffer area will start. Leave a gap of about 4K 90 // between where the overlay buffers will start and the cursor image; 91 // thus, if the overlay buffer overflows it will be less apt to affect the 92 // cursor. 93 94 uint32 prevBuffAddr = (si.videoMemAddr + si.cursorOffset - 0xfff) & ~0xfff; 95 96 while (ovBuff != NULL) { 97 // Test if there is sufficient space between the end of the current 98 // buffer and the start of the previous buffer to allocate the new 99 // buffer. 100 101 uint32 currentBuffEndAddr = (addr_t)ovBuff->buffer + ovBuff->size; 102 if ((prevBuffAddr - currentBuffEndAddr) >= buffSize) 103 break; // sufficient space for the new buffer 104 105 prevBuffAddr = (uint32)ovBuff->buffer; 106 prevOvBuff = ovBuff; 107 ovBuff = ovBuff->nextBuffer; 108 } 109 110 OverlayBuffer* nextOvBuff = ovBuff; 111 112 if (ovBuff == NULL) { 113 // No space between any current buffers of the required size was found; 114 // thus space must be allocated between the last buffer and the end of 115 // the video frame buffer. Compute where current video frame buffer 116 // ends so that it can be determined if there is sufficient space for 117 // the new buffer to be created. 118 119 uint32 fbEndAddr = si.videoMemAddr + si.frameBufferOffset 120 + (si.displayMode.virtual_width 121 * ((si.displayMode.bitsPerPixel + 7) / 8) // bytes per pixel 122 * si.displayMode.virtual_height); 123 124 if (buffSize > prevBuffAddr - fbEndAddr) { 125 si.overlayLock.Release(); 126 TRACE("AllocateOverlayBuffer() insuffcient space for %ld (0x%lx) " 127 "byte buffer\n", buffSize, buffSize); 128 return NULL; // insufficient space for buffer 129 } 130 131 nextOvBuff = NULL; 132 } 133 134 ovBuff = (OverlayBuffer*)malloc(sizeof(OverlayBuffer)); 135 if (ovBuff == NULL) { 136 si.overlayLock.Release(); 137 return NULL; // memory not available for OverlayBuffer struct 138 } 139 140 ovBuff->nextBuffer = nextOvBuff; 141 ovBuff->size = buffSize; 142 ovBuff->space = colorSpace; 143 ovBuff->width = width; 144 ovBuff->height = height; 145 ovBuff->bytes_per_row = width * bytesPerPixel; 146 ovBuff->buffer = (void*)(prevBuffAddr - buffSize); 147 ovBuff->buffer_dma = (void*)(si.videoMemPCI 148 + ((addr_t)ovBuff->buffer - si.videoMemAddr)); 149 150 if (prevOvBuff == NULL) 151 si.overlayBuffer = ovBuff; 152 else 153 prevOvBuff->nextBuffer = ovBuff; 154 155 si.overlayLock.Release(); 156 TRACE("AllocateOverlayBuffer() allocated %ld (0x%lx) byte buffer at 0x%lx\n", 157 buffSize, buffSize, ovBuff->buffer); 158 return ovBuff; 159 } 160 161 162 status_t 163 ReleaseOverlayBuffer(const overlay_buffer* buffer) 164 { 165 SharedInfo& si = *gInfo.sharedInfo; 166 167 if (buffer == NULL) 168 return B_BAD_VALUE; 169 170 // Find the buffer to be released. 171 172 OverlayBuffer* ovBuff = si.overlayBuffer; 173 OverlayBuffer* prevOvBuff = NULL; 174 175 while (ovBuff != NULL) { 176 if (ovBuff->buffer == buffer->buffer) { 177 // Buffer to be released has been found. Remove the OverlayBuffer 178 // object from the chain of overlay buffers. 179 180 if (prevOvBuff == NULL) 181 si.overlayBuffer = ovBuff->nextBuffer; 182 else 183 prevOvBuff->nextBuffer = ovBuff->nextBuffer; 184 185 free(ovBuff); 186 return B_OK; 187 } 188 189 prevOvBuff = ovBuff; 190 ovBuff = ovBuff->nextBuffer; 191 } 192 193 TRACE("ReleaseOverlayBuffer() buffer to release at 0x%lx not found\n", 194 buffer->buffer); 195 return B_ERROR; // buffer to be released not found in chain of buffers 196 } 197 198 199 status_t 200 GetOverlayConstraints(const display_mode* mode, const overlay_buffer* buffer, 201 overlay_constraints* constraints) 202 { 203 if ((mode == NULL) || (buffer == NULL) || (constraints == NULL)) 204 return B_ERROR; 205 206 // Position (values are in pixels) 207 constraints->view.h_alignment = 0; 208 constraints->view.v_alignment = 0; 209 210 if (buffer->space == B_YCbCr422) 211 constraints->view.width_alignment = 7; 212 else { 213 TRACE("GetOverlayConstraints() color space 0x%x out of range\n", 214 buffer->space); 215 return B_BAD_VALUE; 216 } 217 218 constraints->view.height_alignment = 0; 219 220 //Size 221 constraints->view.width.min = 4; 222 constraints->view.height.min = 4; 223 constraints->view.width.max = buffer->width; 224 constraints->view.height.max = buffer->height; 225 226 // Scaler output restrictions 227 constraints->window.h_alignment = 0; 228 constraints->window.v_alignment = 0; 229 constraints->window.width_alignment = 0; 230 constraints->window.height_alignment = 0; 231 constraints->window.width.min = 2; 232 constraints->window.width.max = mode->virtual_width; 233 constraints->window.height.min = 2; 234 constraints->window.height.max = mode->virtual_height; 235 236 constraints->h_scale.min = 1.0; 237 constraints->h_scale.max = 8.0; 238 constraints->v_scale.min = 1.0; 239 constraints->v_scale.max = 8.0; 240 241 return B_OK; 242 } 243 244 245 overlay_token 246 AllocateOverlay(void) 247 { 248 SharedInfo& si = *gInfo.sharedInfo; 249 250 // There is only a single overlay channel; thus, check if it is already 251 // allocated. 252 253 if (atomic_or(&si.overlayAllocated, 1) != 0) { 254 TRACE("AllocateOverlay() overlay channel already in use\n"); 255 return NULL; 256 } 257 258 return (overlay_token)++si.overlayToken; 259 } 260 261 262 status_t 263 ReleaseOverlay(overlay_token overlayToken) 264 { 265 SharedInfo& si = *gInfo.sharedInfo; 266 267 if (overlayToken != (overlay_token)si.overlayToken) { 268 TRACE("ReleaseOverlay() error - no overlay previously allocated\n"); 269 return B_BAD_VALUE; 270 } 271 272 if (MACH64_FAMILY(si.chipType)) 273 Mach64_StopOverlay(); 274 else 275 Rage128_StopOverlay(); 276 277 atomic_and(&si.overlayAllocated, 0); // mark overlay as unallocated 278 return B_OK; 279 } 280 281 282 status_t 283 ConfigureOverlay(overlay_token overlayToken, const overlay_buffer* buffer, 284 const overlay_window* window, const overlay_view* view) 285 { 286 SharedInfo& si = *gInfo.sharedInfo; 287 288 if (overlayToken != (overlay_token)si.overlayToken) 289 return B_BAD_VALUE; 290 291 if (buffer == NULL) 292 return B_BAD_VALUE; 293 294 if (window == NULL || view == NULL) { 295 if (MACH64_FAMILY(si.chipType)) 296 Mach64_StopOverlay(); 297 else 298 Rage128_StopOverlay(); 299 300 return B_OK; 301 } 302 303 // Program the overlay hardware. 304 if (MACH64_FAMILY(si.chipType)) { 305 if (!Mach64_DisplayOverlay(window, buffer)) { 306 TRACE("ConfigureOverlay(), call to Mach64_DisplayOverlay() " 307 "returned error\n"); 308 return B_ERROR; 309 } 310 } else { 311 if (!Rage128_DisplayOverlay(window, buffer)) { 312 TRACE("ConfigureOverlay(), call to Rage128_DisplayOverlay() " 313 "returned error\n"); 314 return B_ERROR; 315 } 316 } 317 318 return B_OK; 319 } -
src/add-ons/accelerants/ati/mach64_overlay.cpp
1 /* 2 Haiku ATI video driver adapted from the X.org ATI driver which has the 3 following copyright: 4 5 Copyright 2003 through 2004 by Marc Aurele La France, tsi@xfree86.org 6 7 Copyright 2011 Haiku, Inc. All rights reserved. 8 Distributed under the terms of the MIT license. 9 10 Authors: 11 Gerald Zajac 12 */ 13 14 #include "accelerant.h" 15 #include "mach64.h" 16 17 18 19 bool 20 Mach64_DisplayOverlay(const overlay_window* window, 21 const overlay_buffer* buffer) 22 { 23 // Return true if setup is successful. 24 25 SharedInfo& si = *gInfo.sharedInfo; 26 27 if (window == NULL || buffer == NULL) 28 return false; 29 30 uint32 videoFormat; 31 32 if (buffer->space == B_YCbCr422) 33 videoFormat = SCALE_IN_VYUY422; 34 else 35 return false; // color space not supported 36 37 int32 x1 = (window->h_start < 0) ? 0 : window->h_start; 38 int32 y1 = (window->v_start < 0) ? 0 : window->v_start; 39 40 int32 x2 = window->h_start + window->width - 1; 41 int32 y2 = window->v_start + window->height - 1; 42 43 if (x2 > si.displayMode.timing.h_display) 44 x2 = si.displayMode.timing.h_display; 45 46 if (y2 > si.displayMode.timing.v_display) 47 y2 = si.displayMode.timing.v_display; 48 49 // If window is moved beyond edge of screen, do not allow width < 4 or 50 // height < 4; otherwise there is a possibilty of divide by zero when 51 // computing the scale factors.. 52 if (x2 < x1 + 4) 53 x2 = x1 + 4; 54 55 if (y2 < y1 + 4) 56 y2 = y1 + 4; 57 58 // Calculate overlay scale factors. 59 uint32 horzScale = (buffer->width << 12) / (x2 - x1 + 1); 60 uint32 vertScale = (buffer->height << 12) / (y2 - y1 + 1); 61 62 if (horzScale > 0xffff) // only 16 bits are used for scale factors 63 horzScale = 0xffff; 64 if (vertScale > 0xffff) 65 vertScale = 0xffff; 66 67 gInfo.WaitForFifo(2); 68 OUTREG(BUS_CNTL, INREG(BUS_CNTL) | BUS_EXT_REG_EN); // enable reg block 1 69 OUTREG(OVERLAY_SCALE_CNTL, SCALE_EN); // reset the video 70 71 if (si.chipType >= MACH64_264GTPRO) { 72 const uint32 brightness = 0; 73 const uint32 saturation = 12; 74 75 gInfo.WaitForFifo(6); 76 OUTREG(SCALER_COLOUR_CNTL, brightness | saturation << 8 77 | saturation << 16); 78 OUTREG(SCALER_H_COEFF0, 0x0002000); 79 OUTREG(SCALER_H_COEFF1, 0xd06200d); 80 OUTREG(SCALER_H_COEFF2, 0xd0a1c0d); 81 OUTREG(SCALER_H_COEFF3, 0xc0e1a0c); 82 OUTREG(SCALER_H_COEFF4, 0xc14140c); 83 } 84 85 uint32 keyColor = 0; 86 uint32 keyMask = 0; 87 88 switch (si.displayMode.bitsPerPixel) { 89 case 15: 90 keyMask = 0x7fff; 91 keyColor = (window->blue.value & window->blue.mask) << 0 92 | (window->green.value & window->green.mask) << 5 93 | (window->red.value & window->red.mask) << 10; 94 // 15 bit color has no alpha bits 95 break; 96 case 16: 97 keyMask = 0xffff; 98 keyColor = (window->blue.value & window->blue.mask) << 0 99 | (window->green.value & window->green.mask) << 5 100 | (window->red.value & window->red.mask) << 11; 101 // 16 bit color has no alpha bits 102 break; 103 default: 104 keyMask = 0xffffffff; 105 keyColor = (window->blue.value & window->blue.mask) << 0 106 | (window->green.value & window->green.mask) << 8 107 | (window->red.value & window->red.mask) << 16 108 | (window->alpha.value & window->alpha.mask) << 24; 109 break; 110 } 111 112 gInfo.WaitForFifo(3); 113 OUTREG(OVERLAY_GRAPHICS_KEY_MSK, keyMask); 114 OUTREG(OVERLAY_GRAPHICS_KEY_CLR, keyColor); 115 OUTREG(OVERLAY_KEY_CNTL, OVERLAY_MIX_FALSE | OVERLAY_MIX_EQUAL); 116 117 gInfo.WaitForFifo(8); 118 OUTREG(OVERLAY_Y_X_START, OVERLAY_LOCK_START | (x1 << 16) | y1); 119 OUTREG(OVERLAY_Y_X_END, (x2 << 16) | y2); 120 OUTREG(OVERLAY_SCALE_INC, (horzScale << 16) | vertScale); 121 OUTREG(SCALER_HEIGHT_WIDTH, (buffer->width << 16) | buffer->height); 122 OUTREG(VIDEO_FORMAT, videoFormat); 123 124 // Compute offset of overlay buffer in the video memory. 125 uint32 offset = uint32(buffer->buffer) - si.videoMemAddr; 126 127 if (si.chipType < MACH64_264VTB) { 128 OUTREG(BUF0_OFFSET, offset); 129 OUTREG(BUF0_PITCH, buffer->width); 130 } else { 131 OUTREG(SCALER_BUF0_OFFSET, offset); 132 OUTREG(SCALER_BUF0_PITCH, buffer->width); 133 } 134 135 OUTREG(OVERLAY_SCALE_CNTL, SCALE_PIX_EXPAND | OVERLAY_EN | SCALE_EN); 136 137 return true; 138 } 139 140 141 void 142 Mach64_StopOverlay(void) 143 { 144 OUTREG(OVERLAY_SCALE_CNTL, SCALE_EN); // reset the video 145 } -
src/add-ons/accelerants/ati/hooks.cpp
1 1 /* 2 Copyright 2008 Haiku, Inc. All rights reserved.2 Copyright 2008, 2011 Haiku, Inc. All rights reserved. 3 3 Distributed under the terms of the MIT license. 4 4 5 5 Authors: 6 Gerald Zajac 20086 Gerald Zajac 7 7 */ 8 8 9 9 #include "accelerant.h" … … 16 16 17 17 switch (feature) { 18 18 // General 19 case B_INIT_ACCELERANT: return (void*)InitAccelerant; 20 case B_UNINIT_ACCELERANT: return (void*)UninitAccelerant; 21 case B_CLONE_ACCELERANT: return (void*)CloneAccelerant; 22 case B_ACCELERANT_CLONE_INFO_SIZE: return (void*)AccelerantCloneInfoSize; 23 case B_GET_ACCELERANT_CLONE_INFO: return (void*)GetAccelerantCloneInfo; 24 case B_GET_ACCELERANT_DEVICE_INFO: return (void*)GetAccelerantDeviceInfo; 25 case B_ACCELERANT_RETRACE_SEMAPHORE: return (void*)AccelerantRetraceSemaphore; 19 case B_INIT_ACCELERANT: 20 return (void*)InitAccelerant; 21 case B_UNINIT_ACCELERANT: 22 return (void*)UninitAccelerant; 23 case B_CLONE_ACCELERANT: 24 return (void*)CloneAccelerant; 25 case B_ACCELERANT_CLONE_INFO_SIZE: 26 return (void*)AccelerantCloneInfoSize; 27 case B_GET_ACCELERANT_CLONE_INFO: 28 return (void*)GetAccelerantCloneInfo; 29 case B_GET_ACCELERANT_DEVICE_INFO: 30 return (void*)GetAccelerantDeviceInfo; 31 case B_ACCELERANT_RETRACE_SEMAPHORE: 32 return (void*)AccelerantRetraceSemaphore; 26 33 27 34 // Mode Configuration 28 case B_ACCELERANT_MODE_COUNT: return (void*)AccelerantModeCount; 29 case B_GET_MODE_LIST: return (void*)GetModeList; 30 case B_PROPOSE_DISPLAY_MODE: return (void*)ProposeDisplayMode; 31 case B_SET_DISPLAY_MODE: return (void*)SetDisplayMode; 32 case B_GET_DISPLAY_MODE: return (void*)GetDisplayMode; 33 case B_GET_PREFERRED_DISPLAY_MODE: return (void*)GetPreferredDisplayMode; 34 case B_GET_EDID_INFO: return (void*)GetEdidInfo; 35 case B_GET_FRAME_BUFFER_CONFIG: return (void*)GetFrameBufferConfig; 36 case B_GET_PIXEL_CLOCK_LIMITS: return (void*)GetPixelClockLimits; 37 case B_MOVE_DISPLAY: return (void*)MoveDisplay; 38 case B_SET_INDEXED_COLORS: return (void*)(gInfo.SetIndexedColors); 39 case B_GET_TIMING_CONSTRAINTS: return (void*)GetTimingConstraints; 35 case B_ACCELERANT_MODE_COUNT: 36 return (void*)AccelerantModeCount; 37 case B_GET_MODE_LIST: 38 return (void*)GetModeList; 39 case B_PROPOSE_DISPLAY_MODE: 40 return (void*)ProposeDisplayMode; 41 case B_SET_DISPLAY_MODE: 42 return (void*)SetDisplayMode; 43 case B_GET_DISPLAY_MODE: 44 return (void*)GetDisplayMode; 45 case B_GET_PREFERRED_DISPLAY_MODE: 46 return (void*)GetPreferredDisplayMode; 47 case B_GET_EDID_INFO: 48 return (void*)GetEdidInfo; 49 case B_GET_FRAME_BUFFER_CONFIG: 50 return (void*)GetFrameBufferConfig; 51 case B_GET_PIXEL_CLOCK_LIMITS: 52 return (void*)GetPixelClockLimits; 53 case B_MOVE_DISPLAY: 54 return (void*)MoveDisplay; 55 case B_SET_INDEXED_COLORS: 56 return (void*)(gInfo.SetIndexedColors); 57 case B_GET_TIMING_CONSTRAINTS: 58 return (void*)GetTimingConstraints; 40 59 41 60 // DPMS 42 case B_DPMS_CAPABILITIES: return (void*)(gInfo.DPMSCapabilities); 43 case B_DPMS_MODE: return (void*)(gInfo.GetDPMSMode); 44 case B_SET_DPMS_MODE: return (void*)(gInfo.SetDPMSMode); 61 case B_DPMS_CAPABILITIES: 62 return (void*)(gInfo.DPMSCapabilities); 63 case B_DPMS_MODE: 64 return (void*)(gInfo.GetDPMSMode); 65 case B_SET_DPMS_MODE: 66 return (void*)(gInfo.SetDPMSMode); 45 67 46 68 // Cursor 47 case B_SET_CURSOR_SHAPE: return (void*)SetCursorShape; 48 case B_MOVE_CURSOR: return (void*)MoveCursor; 49 case B_SHOW_CURSOR: return (void*)(gInfo.ShowCursor); 69 case B_SET_CURSOR_SHAPE: 70 return (void*)SetCursorShape; 71 case B_MOVE_CURSOR: 72 return (void*)MoveCursor; 73 case B_SHOW_CURSOR: 74 return (void*)(gInfo.ShowCursor); 50 75 51 76 // Engine Management 52 case B_ACCELERANT_ENGINE_COUNT: return (void*)AccelerantEngineCount; 53 case B_ACQUIRE_ENGINE: return (void*)AcquireEngine; 54 case B_RELEASE_ENGINE: return (void*)ReleaseEngine; 55 case B_WAIT_ENGINE_IDLE: return (void*)WaitEngineIdle; 56 case B_GET_SYNC_TOKEN: return (void*)GetSyncToken; 57 case B_SYNC_TO_TOKEN: return (void*)SyncToToken; 77 case B_ACCELERANT_ENGINE_COUNT: 78 return (void*)AccelerantEngineCount; 79 case B_ACQUIRE_ENGINE: 80 return (void*)AcquireEngine; 81 case B_RELEASE_ENGINE: 82 return (void*)ReleaseEngine; 83 case B_WAIT_ENGINE_IDLE: 84 return (void*)WaitEngineIdle; 85 case B_GET_SYNC_TOKEN: 86 return (void*)GetSyncToken; 87 case B_SYNC_TO_TOKEN: 88 return (void*)SyncToToken; 58 89 59 90 // 2D acceleration 60 case B_SCREEN_TO_SCREEN_BLIT: return (void*)(gInfo.ScreenToScreenBlit); 61 case B_FILL_RECTANGLE: return (void*)(gInfo.FillRectangle); 62 case B_INVERT_RECTANGLE: return (void*)(gInfo.InvertRectangle); 63 case B_FILL_SPAN: return (void*)(gInfo.FillSpan); 91 case B_SCREEN_TO_SCREEN_BLIT: 92 return (void*)(gInfo.ScreenToScreenBlit); 93 case B_FILL_RECTANGLE: 94 return (void*)(gInfo.FillRectangle); 95 case B_INVERT_RECTANGLE: 96 return (void*)(gInfo.InvertRectangle); 97 case B_FILL_SPAN: 98 return (void*)(gInfo.FillSpan); 99 100 // Overlay 101 case B_OVERLAY_COUNT: 102 return (void*)OverlayCount; 103 case B_OVERLAY_SUPPORTED_SPACES: 104 return (void*)OverlaySupportedSpaces; 105 case B_OVERLAY_SUPPORTED_FEATURES: 106 return (void*)OverlaySupportedFeatures; 107 case B_ALLOCATE_OVERLAY_BUFFER: 108 return (void*)AllocateOverlayBuffer; 109 case B_RELEASE_OVERLAY_BUFFER: 110 return (void*)ReleaseOverlayBuffer; 111 case B_GET_OVERLAY_CONSTRAINTS: 112 return (void*)GetOverlayConstraints; 113 case B_ALLOCATE_OVERLAY: 114 return (void*)AllocateOverlay; 115 case B_RELEASE_OVERLAY: 116 return (void*)ReleaseOverlay; 117 case B_CONFIGURE_OVERLAY: 118 return (void*)ConfigureOverlay; 64 119 } 65 120 66 121 return NULL; // Return null pointer for any feature not handled above -
src/add-ons/accelerants/ati/Jamfile
10 10 engine.cpp 11 11 hooks.cpp 12 12 mode.cpp 13 overlay.cpp 13 14 14 15 mach64_cursor.cpp 15 16 mach64_dpms.cpp 16 17 mach64_draw.cpp 17 18 mach64_init.cpp 18 19 mach64_mode.cpp 20 mach64_overlay.cpp 19 21 mach64_util.cpp 20 22 21 23 rage128_cursor.cpp … … 23 25 rage128_draw.cpp 24 26 rage128_init.cpp 25 27 rage128_mode.cpp 28 rage128_overlay.cpp 26 29 27 30 : be libaccelerantscommon.a 28 31 ; -
src/add-ons/accelerants/ati/mach64.h
1 1 /* 2 Haiku ATI video driver adapted from the X.org ATI driver. 2 Haiku ATI video driver adapted from the X.org ATI driver which has the 3 following copyright: 3 4 4 5 Copyright 1992,1993,1994,1995,1996,1997 by Kevin E. Martin, Chapel Hill, North Carolina. 5 6 6 Copyright 2009 Haiku, Inc. All rights reserved.7 Copyright 2009, 2011 Haiku, Inc. All rights reserved. 7 8 Distributed under the terms of the MIT license. 8 9 9 10 Authors: 10 Gerald Zajac 200911 Gerald Zajac 11 12 */ 12 13 13 14 #ifndef __MACH64_H__ … … 178 179 #define GUI_STAT (0x0c00 + 0x0338) // Dword offset CE 179 180 180 181 182 // Definitions used for overlays. 183 //=============================== 184 185 #define REG_BLOCK_1 0x0800 // offset of register block 1 in register area 186 187 #define OVERLAY_Y_X_START (REG_BLOCK_1 + 0x0000) // Dword offset 00 188 #define OVERLAY_LOCK_START 0x80000000ul 189 #define OVERLAY_Y_X_END (REG_BLOCK_1 + 0x0004) // Dword offset 01 190 #define OVERLAY_GRAPHICS_KEY_CLR (REG_BLOCK_1 + 0x0010) // Dword offset 04 191 #define OVERLAY_GRAPHICS_KEY_MSK (REG_BLOCK_1 + 0x0014) // Dword offset 05 192 #define OVERLAY_KEY_CNTL (REG_BLOCK_1 + 0x0018) // Dword offset 06 193 #define OVERLAY_MIX_FALSE 0x00 194 #define OVERLAY_MIX_EQUAL 0x50 195 #define OVERLAY_SCALE_INC (REG_BLOCK_1 + 0x0020) // Dword offset 08 196 #define OVERLAY_SCALE_CNTL (REG_BLOCK_1 + 0x0024) // Dword offset 09 197 #define SCALE_PIX_EXPAND 0x00000001 198 #define OVERLAY_EN 0x40000000 199 #define SCALE_EN 0x80000000 200 #define SCALER_HEIGHT_WIDTH (REG_BLOCK_1 + 0x0028) // Dword offset 0a 201 #define SCALER_BUF0_OFFSET (REG_BLOCK_1 + 0x0034) // Dword offset 0d 202 #define SCALER_BUF0_PITCH (REG_BLOCK_1 + 0x003c) // Dword offset 0f 203 #define VIDEO_FORMAT (REG_BLOCK_1 + 0x0048) // Dword offset 12 204 #define SCALE_IN_VYUY422 0x000b0000 205 #define BUF0_OFFSET (REG_BLOCK_1 + 0x0080) // Dword offset 20 206 #define BUF0_PITCH (REG_BLOCK_1 + 0x008c) // Dword offset 23 207 #define SCALER_COLOUR_CNTL (REG_BLOCK_1 + 0x0150) // Dword offset 54 208 #define SCALER_H_COEFF0 (REG_BLOCK_1 + 0x0154) // Dword offset 55 209 #define SCALER_H_COEFF1 (REG_BLOCK_1 + 0x0158) // Dword offset 56 210 #define SCALER_H_COEFF2 (REG_BLOCK_1 + 0x015c) // Dword offset 57 211 #define SCALER_H_COEFF3 (REG_BLOCK_1 + 0x0160) // Dword offset 58 212 #define SCALER_H_COEFF4 (REG_BLOCK_1 + 0x0164) // Dword offset 59 213 214 181 215 // CRTC control values. 182 216 183 217 #define CRTC_H_SYNC_NEG 0x00200000 … … 225 259 #define CRTC_PITCH 0xffc00000 226 260 227 261 // DAC control values. 228 229 262 #define DAC_8BIT_EN 0x00000100 230 263 264 231 265 // Mix control values. 232 233 266 #define MIX_NOT_DST 0x0000 234 267 #define MIX_0 0x0001 235 268 #define MIX_1 0x0002 … … 250 283 // BUS_CNTL register constants. 251 284 #define BUS_FIFO_ERR_ACK 0x00200000 252 285 #define BUS_HOST_ERR_ACK 0x00800000 253 #define BUS_ APER_REG_DIS 0x00000010286 #define BUS_EXT_REG_EN 0x08000000 254 287 255 288 // GEN_TEST_CNTL register constants. 256 289 #define GEN_OVR_OUTPUT_EN 0x20 … … 361 394 #define BYTE_ORDER_LSB_TO_MSB 0x1000000 362 395 363 396 // DP_SRC register constants. 364 #define BKGD_SRC_BKGD_CLR 365 #define FRGD_SRC_FRGD_CLR 366 #define FRGD_SRC_BLIT 367 #define MONO_SRC_ONE 397 #define BKGD_SRC_BKGD_CLR 0 398 #define FRGD_SRC_FRGD_CLR 0x100 399 #define FRGD_SRC_BLIT 0x300 400 #define MONO_SRC_ONE 0 368 401 369 402 // GUI_STAT register constants. 370 #define ENGINE_BUSY 403 #define ENGINE_BUSY 1 371 404 372 405 // LCD Index register constants. 373 406 #define LCD_REG_INDEX 0x0000003F