xref: /haiku/src/add-ons/accelerants/radeon/GetAccelerantHook.c (revision b24bb37c3b8f11dfd069ab23f7af61860d95c7d6)
1409f1731Sshadow303 /*
29ee4f3c8SAxel Dörfler  * Copyright (c) 2002, Thomas Kurschel
39ee4f3c8SAxel Dörfler  * Distributed under the terms of the MIT License.
49ee4f3c8SAxel Dörfler  */
5409f1731Sshadow303 
69ee4f3c8SAxel Dörfler /*!
7409f1731Sshadow303 	Contains entry point to get public functions.
8409f1731Sshadow303 	(directly copied from sample driver)
9409f1731Sshadow303 */
10409f1731Sshadow303 
11409f1731Sshadow303 #include "generic.h"
12409f1731Sshadow303 
13409f1731Sshadow303 /*
14409f1731Sshadow303 
15409f1731Sshadow303 The standard entry point.  Given a uint32 feature identifier, this routine
16409f1731Sshadow303 returns a pointer to the function that implements the feature.  Some features
17409f1731Sshadow303 require more information than just the identifier to select the proper
18409f1731Sshadow303 function.  The extra information (which is specific to the feature) is
19409f1731Sshadow303 pointed at by the void *data parameter.  By default, no extra information
20409f1731Sshadow303 is available.  Any extra information available to choose the function will be
21409f1731Sshadow303 noted on a case by case below.
22409f1731Sshadow303 
23409f1731Sshadow303 */
249ee4f3c8SAxel Dörfler void *
259ee4f3c8SAxel Dörfler get_accelerant_hook(uint32 feature, void *data)
269ee4f3c8SAxel Dörfler {
272a37e4c1Sshadow303 	(void)data;
282a37e4c1Sshadow303 
29409f1731Sshadow303 	switch (feature) {
30409f1731Sshadow303 /*
31409f1731Sshadow303 These definitions are out of pure lazyness.
32409f1731Sshadow303 */
33409f1731Sshadow303 #define HOOK(x) case B_##x: return (void *)x
34409f1731Sshadow303 #define ZERO(x) case B_##x: return (void *)0
35409f1731Sshadow303 
36409f1731Sshadow303 /*
37409f1731Sshadow303 One of either B_INIT_ACCELERANT or B_CLONE_ACCELERANT will be requested and
38409f1731Sshadow303 subsequently called before any other hook is requested.  All other feature
39409f1731Sshadow303 hook selections can be predicated on variables assigned during the accelerant
40409f1731Sshadow303 initialization process.
41409f1731Sshadow303 */
42409f1731Sshadow303 		/* initialization */
43409f1731Sshadow303 		HOOK(INIT_ACCELERANT);
44409f1731Sshadow303 		HOOK(CLONE_ACCELERANT);
45409f1731Sshadow303 
46409f1731Sshadow303 		HOOK(ACCELERANT_CLONE_INFO_SIZE);
47409f1731Sshadow303 		HOOK(GET_ACCELERANT_CLONE_INFO);
48409f1731Sshadow303 		HOOK(UNINIT_ACCELERANT);
49409f1731Sshadow303 		HOOK(GET_ACCELERANT_DEVICE_INFO);
50409f1731Sshadow303 		HOOK(ACCELERANT_RETRACE_SEMAPHORE);
51409f1731Sshadow303 
52409f1731Sshadow303 		/* mode configuration */
53409f1731Sshadow303 		HOOK(ACCELERANT_MODE_COUNT);
54409f1731Sshadow303 		HOOK(GET_MODE_LIST);
55409f1731Sshadow303 		HOOK(PROPOSE_DISPLAY_MODE);
56409f1731Sshadow303 		HOOK(SET_DISPLAY_MODE);
57409f1731Sshadow303 		HOOK(GET_DISPLAY_MODE);
58409f1731Sshadow303 		HOOK(GET_FRAME_BUFFER_CONFIG);
59409f1731Sshadow303 		HOOK(GET_PIXEL_CLOCK_LIMITS);
60409f1731Sshadow303 		HOOK(MOVE_DISPLAY);
61409f1731Sshadow303 		HOOK(SET_INDEXED_COLORS);
62409f1731Sshadow303 		//HOOK(GET_TIMING_CONSTRAINTS);
63a9f57acdSAxel Dörfler #ifdef __HAIKU__
64*b24bb37cSAxel Dörfler 		case B_GET_PREFERRED_DISPLAY_MODE:
65*b24bb37cSAxel Dörfler 			return (void*)radeon_get_preferred_display_mode;
669ee4f3c8SAxel Dörfler 		case B_GET_EDID_INFO:
679ee4f3c8SAxel Dörfler 			return (void*)radeon_get_edid_info;
68a9f57acdSAxel Dörfler #endif
69409f1731Sshadow303 
70409f1731Sshadow303 		HOOK(DPMS_CAPABILITIES);
71409f1731Sshadow303 		HOOK(DPMS_MODE);
72409f1731Sshadow303 		HOOK(SET_DPMS_MODE);
73409f1731Sshadow303 
74409f1731Sshadow303 		/* cursor managment */
75409f1731Sshadow303 		HOOK(SET_CURSOR_SHAPE);
76409f1731Sshadow303 		HOOK(MOVE_CURSOR);
77409f1731Sshadow303 		HOOK(SHOW_CURSOR);
78409f1731Sshadow303 
79409f1731Sshadow303 		/* synchronization */
80409f1731Sshadow303 		HOOK(ACCELERANT_ENGINE_COUNT);
81409f1731Sshadow303 		HOOK(ACQUIRE_ENGINE);
82409f1731Sshadow303 		HOOK(RELEASE_ENGINE);
83409f1731Sshadow303 		HOOK(WAIT_ENGINE_IDLE);
84409f1731Sshadow303 		HOOK(GET_SYNC_TOKEN);
85409f1731Sshadow303 		HOOK(SYNC_TO_TOKEN);
86409f1731Sshadow303 
87409f1731Sshadow303 /*
88409f1731Sshadow303 When requesting an acceleration hook, the calling application provides a
89409f1731Sshadow303 pointer to the display_mode for which the acceleration function will be used.
90409f1731Sshadow303 Depending on the engine architecture, you may choose to provide a different
91409f1731Sshadow303 function to be used with each bit-depth.  In the sample driver we return
92409f1731Sshadow303 the same function all the time.
93409f1731Sshadow303 */
94409f1731Sshadow303 		/* 2D acceleration */
95409f1731Sshadow303 		HOOK(SCREEN_TO_SCREEN_BLIT);
96409f1731Sshadow303 		HOOK(FILL_RECTANGLE);
97409f1731Sshadow303 		HOOK(INVERT_RECTANGLE);
98409f1731Sshadow303 		HOOK(FILL_SPAN);
99409f1731Sshadow303 
100409f1731Sshadow303 		// overlay
101409f1731Sshadow303 		HOOK(OVERLAY_COUNT);
102409f1731Sshadow303 		HOOK(OVERLAY_SUPPORTED_SPACES);
103409f1731Sshadow303 		HOOK(OVERLAY_SUPPORTED_FEATURES);
104409f1731Sshadow303 		HOOK(ALLOCATE_OVERLAY_BUFFER);
105409f1731Sshadow303 		HOOK(RELEASE_OVERLAY_BUFFER);
106409f1731Sshadow303 		HOOK(GET_OVERLAY_CONSTRAINTS);
107409f1731Sshadow303 		HOOK(ALLOCATE_OVERLAY);
108409f1731Sshadow303 		HOOK(RELEASE_OVERLAY);
109409f1731Sshadow303 		HOOK(CONFIGURE_OVERLAY);
110409f1731Sshadow303 #undef HOOK
111409f1731Sshadow303 #undef ZERO
112409f1731Sshadow303 	}
1139ee4f3c8SAxel Dörfler 
1149ee4f3c8SAxel Dörfler 	return NULL;
115409f1731Sshadow303 }
116