1 /* 2 Copyright 2007-2008 Haiku, Inc. All rights reserved. 3 Distributed under the terms of the MIT license. 4 5 Authors: 6 Gerald Zajac 2007-2008 7 */ 8 9 #ifndef _ACCEL_H 10 #define _ACCEL_H 11 12 #include "DriverInterface.h" 13 #include "register_io.h" 14 15 16 #if defined(__cplusplus) 17 extern "C" { 18 #endif 19 20 21 22 #undef TRACE 23 24 #ifdef ENABLE_DEBUG_TRACE 25 extern "C" void _sPrintf(const char* format, ...); 26 # define TRACE(x...) _sPrintf("S3: " x) 27 #else 28 # define TRACE(x...) ; 29 #endif 30 31 32 // Global data used by various source files of the accelerant. 33 34 struct AccelerantInfo { 35 int deviceFileDesc; // file descriptor of kernel driver 36 37 SharedInfo* sharedInfo; // address of info shared between accelerants & driver 38 area_id sharedInfoArea; // shared info area ID 39 40 uint8* regs; // base address of MMIO register area 41 area_id regsArea; // MMIO register area ID 42 43 display_mode* modeList; // list of standard display modes 44 area_id modeListArea; // mode list area ID 45 46 bool bAccelerantIsClone;// true if this is a cloned accelerant 47 48 // Pointers to wait handlers. 49 void (*WaitQueue)(uint32); 50 void (*WaitIdleEmpty)(); 51 52 // Pointers to DPMS functions. 53 uint32 (*DPMSCapabilities)(void); 54 uint32 (*DPMSMode)(void); 55 status_t (*SetDPMSMode)(uint32 dpms_flags); 56 57 // Pointers to cursor functions. 58 bool (*LoadCursorImage)(int width, int height, uint8* and_mask, uint8* xor_mask); 59 void (*SetCursorPosition)(int x, int y); 60 void (*ShowCursor)(bool bShow); 61 62 // Pointers to 2D acceleration functions. 63 void (*FillRectangle)(engine_token*, uint32 color, fill_rect_params*, uint32 count); 64 void (*FillSpan)(engine_token*, uint32 color, uint16* list, uint32 count); 65 void (*InvertRectangle)(engine_token*, fill_rect_params*, uint32 count); 66 void (*ScreenToScreenBlit)(engine_token*, blit_params*, uint32 count); 67 68 // Pointers to other functions. 69 void (*AdjustFrame)(const DisplayModeEx& mode); 70 status_t (*ChipInit)(void); 71 bool (*GetColorSpaceParams)(int colorSpace, uint32& bpp, uint32& maxPixelClk); 72 bool (*SetDisplayMode)(const DisplayModeEx& mode); 73 void (*SetIndexedColors)(uint count, uint8 first, uint8* color_data, uint32 flags); 74 }; 75 76 extern AccelerantInfo gInfo; 77 78 79 // Prototypes of the interface functions called by the app_server. Note that 80 // the functions that are unique to a particular chip family, will be prefixed 81 // with the name of the family, and the functions that are applicable to all 82 // chips will have no prefix. 83 //================================================================ 84 85 // General 86 status_t InitAccelerant(int fd); 87 ssize_t AccelerantCloneInfoSize(void); 88 void GetAccelerantCloneInfo(void* data); 89 status_t CloneAccelerant(void* data); 90 void UninitAccelerant(void); 91 status_t GetAccelerantDeviceInfo(accelerant_device_info* adi); 92 sem_id AccelerantRetraceSemaphore(void); 93 94 // Mode Configuration 95 uint32 AccelerantModeCount(void); 96 status_t GetModeList(display_mode* dm); 97 status_t ProposeDisplayMode(display_mode* target, const display_mode* low, const display_mode* high); 98 status_t SetDisplayMode(display_mode* mode_to_set); 99 status_t GetDisplayMode(display_mode* current_mode); 100 status_t GetFrameBufferConfig(frame_buffer_config* a_frame_buffer); 101 status_t GetPixelClockLimits(display_mode* dm, uint32* low, uint32* high); 102 status_t MoveDisplay(uint16 h_display_start, uint16 v_display_start); 103 status_t GetTimingConstraints(display_timing_constraints* dtc); 104 void Savage_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); 105 void Trio64_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); 106 void Virge_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); 107 status_t GetPreferredDisplayMode(display_mode* preferredMode); 108 status_t GetEdidInfo(void* info, size_t size, uint32* _version); 109 110 // DPMS 111 uint32 Savage_DPMSCapabilities(void); 112 uint32 Savage_DPMSMode(void); 113 status_t Savage_SetDPMSMode(uint32 dpms_flags); 114 115 uint32 Trio64_DPMSCapabilities(void); 116 uint32 Trio64_DPMSMode(void); 117 status_t Trio64_SetDPMSMode(uint32 dpms_flags); 118 119 uint32 Virge_DPMSCapabilities(void); 120 uint32 Virge_DPMSMode(void); 121 status_t Virge_SetDPMSMode(uint32 dpms_flags); 122 123 // Cursor 124 status_t SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, 125 uint8* andMask, uint8* xorMask); 126 void MoveCursor(uint16 x, uint16 y); 127 void Savage_ShowCursor(bool bShow); 128 void Trio64_ShowCursor(bool bShow); 129 void Virge_ShowCursor(bool bShow); 130 131 // Engine Management 132 uint32 AccelerantEngineCount(void); 133 status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st, engine_token** et); 134 status_t ReleaseEngine(engine_token* et, sync_token* st); 135 void WaitEngineIdle(void); 136 status_t GetSyncToken(engine_token* et, sync_token* st); 137 status_t SyncToToken(sync_token* st); 138 139 // 2D acceleration 140 void Savage_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); 141 void Savage_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); 142 void Savage_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); 143 void Savage_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); 144 145 void Trio64_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); 146 void Trio64_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); 147 void Trio64_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); 148 void Trio64_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); 149 150 void Virge_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); 151 void Virge_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); 152 void Virge_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); 153 void Virge_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); 154 155 156 157 // Prototypes for other functions that are called from source files other than 158 // where they are defined. 159 //============================================================================ 160 161 status_t CreateModeList(bool (*checkMode)(const display_mode* mode)); 162 void InitCrtcTimingValues(const DisplayModeEx& mode, int horzScaleFactor, uint8 crtc[], 163 uint8& cr3b, uint8& cr3c, uint8& cr5d, uint8& cr5e); 164 bool IsModeUsable(const display_mode* mode); 165 166 // Savage functions. 167 168 bool Savage_GetEdidInfo(void); 169 170 bool Savage_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); 171 void Savage_SetCursorPosition(int x, int y); 172 173 void Savage_AdjustFrame(const DisplayModeEx& mode); 174 bool Savage_SetDisplayMode(const DisplayModeEx& mode); 175 void Savage_SetFunctionPointers(void); 176 177 // Trio64 functions. 178 179 bool Trio64_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); 180 void Trio64_SetCursorPosition(int x, int y); 181 182 void Trio64_AdjustFrame(const DisplayModeEx& mode); 183 bool Trio64_SetDisplayMode(const DisplayModeEx& mode); 184 void Trio64_SetFunctionPointers(void); 185 186 // Virge functions. 187 188 bool Virge_GetEdidInfo(void); 189 190 bool Virge_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); 191 void Virge_SetCursorPosition(int x, int y); 192 193 void Virge_AdjustFrame(const DisplayModeEx& mode); 194 bool Virge_SetDisplayMode(const DisplayModeEx& mode); 195 void Virge_SetFunctionPointers(void); 196 197 198 #if defined(__cplusplus) 199 } 200 #endif 201 202 #endif // _ACCEL_H 203