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