BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / accelerants / 3dfx / accelerant.h
blob09760aed8f4b2775e59227d2d276b6956261dbe5
1 /*
2 * Copyright 2007-2010 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Gerald Zajac
7 */
9 #ifndef _ACCELERANT_H
10 #define _ACCELERANT_H
12 #include "DriverInterface.h"
16 #undef TRACE
18 #ifdef ENABLE_DEBUG_TRACE
19 extern "C" void _sPrintf(const char* format, ...);
20 # define TRACE(x...) _sPrintf("3dfx: " x)
21 #else
22 # define TRACE(x...) ;
23 #endif
26 #define CURSOR_BYTES 1024 // bytes used for cursor image in video memory
29 // Global data used by various source files of the accelerant.
31 struct AccelerantInfo {
32 int deviceFileDesc; // file descriptor of kernel driver
34 SharedInfo* sharedInfo; // address of info shared between
35 // accelerants & driver
36 area_id sharedInfoArea; // shared info area ID
38 uint8* regs; // base address of MMIO register area
39 area_id regsArea; // MMIO register area ID
41 display_mode* modeList; // list of standard display modes
42 area_id modeListArea; // mode list area ID
44 bool bAccelerantIsClone; // true if this is a cloned accelerant
47 extern AccelerantInfo gInfo;
50 // Prototypes of the interface functions called by the app_server. Note that
51 // the functions that are unique to a particular chip family, will be prefixed
52 // with the name of the family, and the functions that are applicable to all
53 // chips will have no prefix.
54 //================================================================
56 #if defined(__cplusplus)
57 extern "C" {
58 #endif
60 // General
61 status_t InitAccelerant(int fd);
62 ssize_t AccelerantCloneInfoSize(void);
63 void GetAccelerantCloneInfo(void* data);
64 status_t CloneAccelerant(void* data);
65 void UninitAccelerant(void);
66 status_t GetAccelerantDeviceInfo(accelerant_device_info* adi);
68 // Mode Configuration
69 uint32 AccelerantModeCount(void);
70 status_t GetModeList(display_mode* dm);
71 status_t ProposeDisplayMode(display_mode* target, const display_mode* low,
72 const display_mode* high);
73 status_t SetDisplayMode(display_mode* mode_to_set);
74 status_t GetDisplayMode(display_mode* current_mode);
75 status_t GetFrameBufferConfig(frame_buffer_config* a_frame_buffer);
76 status_t GetPixelClockLimits(display_mode* dm, uint32* low, uint32* high);
77 status_t MoveDisplay(uint16 h_display_start, uint16 v_display_start);
78 void TDFX_SetIndexedColors(uint count, uint8 first, uint8* color_data,
79 uint32 flags);
80 status_t GetEdidInfo(void* info, size_t size, uint32* _version);
82 // DPMS
83 uint32 TDFX_DPMSCapabilities(void);
84 uint32 TDFX_GetDPMSMode(void);
85 status_t TDFX_SetDPMSMode(uint32 dpms_flags);
87 // Cursor
88 status_t SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y,
89 uint8* andMask, uint8* xorMask);
90 void MoveCursor(uint16 x, uint16 y);
91 void TDFX_ShowCursor(bool bShow);
93 // Engine Management
94 uint32 AccelerantEngineCount(void);
95 status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st,
96 engine_token** et);
97 status_t ReleaseEngine(engine_token* et, sync_token* st);
98 void WaitEngineIdle(void);
99 status_t GetSyncToken(engine_token* et, sync_token* st);
100 status_t SyncToToken(sync_token* st);
102 // 2D acceleration
103 void TDFX_FillRectangle(engine_token* et, uint32 color,
104 fill_rect_params* list, uint32 count);
105 void TDFX_FillSpan(engine_token* et, uint32 color, uint16* list,
106 uint32 count);
107 void TDFX_InvertRectangle(engine_token* et, fill_rect_params* list,
108 uint32 count);
109 void TDFX_ScreenToScreenBlit(engine_token* et, blit_params* list,
110 uint32 count);
112 // Video_overlay
113 uint32 OverlayCount(const display_mode* dm);
114 const uint32* OverlaySupportedSpaces(const display_mode *dm);
115 uint32 OverlaySupportedFeatures(uint32 a_color_space);
116 const overlay_buffer* AllocateOverlayBuffer(color_space cs, uint16 width,
117 uint16 height);
118 status_t ReleaseOverlayBuffer(const overlay_buffer* ob);
119 status_t GetOverlayConstraints(const display_mode* dm,
120 const overlay_buffer* ob, overlay_constraints* oc);
121 overlay_token AllocateOverlay(void);
122 status_t ReleaseOverlay(overlay_token ot);
123 status_t ConfigureOverlay(overlay_token ot, const overlay_buffer* ob,
124 const overlay_window* ow, const overlay_view* ov);
126 #if defined(__cplusplus)
128 #endif
132 // Prototypes for other functions that are called from source files other than
133 // where they are defined.
134 //============================================================================
136 status_t CreateModeList(bool (*checkMode)(const display_mode* mode));
137 uint16 GetVesaModeNumber(const display_mode& mode, uint8 bitsPerPixel);
138 bool IsModeUsable(const display_mode* mode);
140 // 3dfx functions.
142 bool TDFX_DisplayOverlay(const overlay_window* window,
143 const overlay_buffer* buffer, const overlay_view* view);
144 void TDFX_StopOverlay(void);
146 status_t TDFX_Init(void);
147 bool TDFX_GetColorSpaceParams(int colorSpace, uint8& bpp);
148 bool TDFX_GetEdidInfo(edid1_info& edidInfo);
150 void TDFX_EngineReset(void);
151 void TDFX_EngineInit(const DisplayModeEx& mode);
153 bool TDFX_LoadCursorImage(int width, int height, uint8* and_mask,
154 uint8* xor_mask);
155 void TDFX_SetCursorPosition(int x, int y);
157 void TDFX_AdjustFrame(const DisplayModeEx& mode);
158 status_t TDFX_SetDisplayMode(const DisplayModeEx& mode);
160 void TDFX_WaitForFifo(uint32);
161 void TDFX_WaitForIdle();
164 // Address of various VGA registers.
166 #define MISC_OUT_R 0x3cc // read
167 #define MISC_OUT_W 0x3c2 // write
168 #define CRTC_INDEX 0x3d4
169 #define CRTC_DATA 0x3d5
170 #define SEQ_INDEX 0x3c4
171 #define SEQ_DATA 0x3c5
174 // Macros for memory mapped I/O.
175 //===============================
177 #define INREG8(addr) *((vuint8*)(gInfo.regs + addr))
178 #define INREG16(addr) *((vuint16*)(gInfo.regs + addr))
179 #define INREG32(addr) *((vuint32*)(gInfo.regs + addr))
181 #define OUTREG8(addr, val) *((vuint8*)(gInfo.regs + addr)) = val
182 #define OUTREG16(addr, val) *((vuint16*)(gInfo.regs + addr)) = val
183 #define OUTREG32(addr, val) *((vuint32*)(gInfo.regs + addr)) = val
185 // Write a value to an 32-bit reg using a mask. The mask selects the
186 // bits to be modified.
187 #define OUTREGM(addr, value, mask) \
188 (OUTREG(addr, (INREG(addr) & ~(mask)) | ((value) & (mask))))
191 #endif // _ACCELERANT_H