1/*
2	Copyright 2008 Haiku, Inc.  All rights reserved.
3	Distributed under the terms of the MIT license.
4
5	Authors:
6	Gerald Zajac 2008
7*/
8
9#include "accel.h"
10
11
12extern "C" void*
13get_accelerant_hook(uint32 feature, void* data)
14{
15	(void)data;		// avoid compiler warning for unused arg
16
17	SharedInfo& si = *gInfo.sharedInfo;
18
19	switch (feature) {
20		// General
21		case B_INIT_ACCELERANT:				return (void*)InitAccelerant;
22		case B_UNINIT_ACCELERANT:			return (void*)UninitAccelerant;
23		case B_CLONE_ACCELERANT:			return (void*)CloneAccelerant;
24		case B_ACCELERANT_CLONE_INFO_SIZE:	return (void*)AccelerantCloneInfoSize;
25		case B_GET_ACCELERANT_CLONE_INFO:	return (void*)GetAccelerantCloneInfo;
26		case B_GET_ACCELERANT_DEVICE_INFO:	return (void*)GetAccelerantDeviceInfo;
27		case B_ACCELERANT_RETRACE_SEMAPHORE: return (void*)AccelerantRetraceSemaphore;
28
29		// Mode Configuration
30		case B_ACCELERANT_MODE_COUNT:	return (void*)AccelerantModeCount;
31		case B_GET_MODE_LIST:			return (void*)GetModeList;
32		case B_PROPOSE_DISPLAY_MODE:	return (void*)ProposeDisplayMode;
33		case B_SET_DISPLAY_MODE:		return (void*)SetDisplayMode;
34		case B_GET_DISPLAY_MODE:		return (void*)GetDisplayMode;
35#ifdef __HAIKU__
36		case B_GET_PREFERRED_DISPLAY_MODE: return (void*)GetPreferredDisplayMode;
37		case B_GET_EDID_INFO:			return (void*)GetEdidInfo;
38#endif
39		case B_GET_FRAME_BUFFER_CONFIG:	return (void*)GetFrameBufferConfig;
40		case B_GET_PIXEL_CLOCK_LIMITS:	return (void*)GetPixelClockLimits;
41		case B_MOVE_DISPLAY:			return (void*)MoveDisplay;
42		case B_SET_INDEXED_COLORS:		return (void*)(gInfo.SetIndexedColors);
43		case B_GET_TIMING_CONSTRAINTS:	return (void*)GetTimingConstraints;
44
45		// DPMS
46		case B_DPMS_CAPABILITIES:		return (void*)(gInfo.DPMSCapabilities);
47		case B_DPMS_MODE:				return (void*)(gInfo.GetDPMSMode);
48		case B_SET_DPMS_MODE:			return (void*)(gInfo.SetDPMSMode);
49
50		// Cursor
51		case B_SET_CURSOR_SHAPE:
52			return (void*)(si.bDisableHdwCursor ? NULL : SetCursorShape);
53		case B_MOVE_CURSOR:
54			return (void*)(si.bDisableHdwCursor ? NULL : MoveCursor);
55		case B_SHOW_CURSOR:
56			return (void*)(si.bDisableHdwCursor ? NULL : gInfo.ShowCursor);
57
58		// Engine Management
59		case B_ACCELERANT_ENGINE_COUNT:	return (void*)AccelerantEngineCount;
60		case B_ACQUIRE_ENGINE:			return (void*)AcquireEngine;
61		case B_RELEASE_ENGINE:			return (void*)ReleaseEngine;
62		case B_WAIT_ENGINE_IDLE:		return (void*)WaitEngineIdle;
63		case B_GET_SYNC_TOKEN:			return (void*)GetSyncToken;
64		case B_SYNC_TO_TOKEN:			return (void*)SyncToToken;
65
66		// 2D acceleration
67		case B_SCREEN_TO_SCREEN_BLIT:
68			return (void*)(si.bDisableAccelDraw ? NULL : gInfo.ScreenToScreenBlit);
69		case B_FILL_RECTANGLE:
70			return (void*)(si.bDisableAccelDraw ? NULL : gInfo.FillRectangle);
71		case B_INVERT_RECTANGLE:
72			return (void*)(si.bDisableAccelDraw ? NULL : gInfo.InvertRectangle);
73		case B_FILL_SPAN:
74			return (void*)(si.bDisableAccelDraw ? NULL : gInfo.FillSpan);
75	}
76
77	return NULL;	// Return null pointer for any feature not handled above
78}
79