xref: /haiku/src/add-ons/accelerants/radeon/GetAccelerantHook.c (revision 25a7b01d15612846f332751841da3579db313082)
1 /*
2  * Copyright (c) 2002, Thomas Kurschel
3  * Distributed under the terms of the MIT License.
4  */
5 
6 /*!
7 	Contains entry point to get public functions.
8 	(directly copied from sample driver)
9 */
10 
11 #include "generic.h"
12 
13 /*
14 
15 The standard entry point.  Given a uint32 feature identifier, this routine
16 returns a pointer to the function that implements the feature.  Some features
17 require more information than just the identifier to select the proper
18 function.  The extra information (which is specific to the feature) is
19 pointed at by the void *data parameter.  By default, no extra information
20 is available.  Any extra information available to choose the function will be
21 noted on a case by case below.
22 
23 */
24 void *
get_accelerant_hook(uint32 feature,void * data)25 get_accelerant_hook(uint32 feature, void *data)
26 {
27 	(void)data;
28 
29 	switch (feature) {
30 /*
31 These definitions are out of pure lazyness.
32 */
33 #define HOOK(x) case B_##x: return (void *)x
34 #define ZERO(x) case B_##x: return (void *)0
35 
36 /*
37 One of either B_INIT_ACCELERANT or B_CLONE_ACCELERANT will be requested and
38 subsequently called before any other hook is requested.  All other feature
39 hook selections can be predicated on variables assigned during the accelerant
40 initialization process.
41 */
42 		/* initialization */
43 		HOOK(INIT_ACCELERANT);
44 		HOOK(CLONE_ACCELERANT);
45 
46 		HOOK(ACCELERANT_CLONE_INFO_SIZE);
47 		HOOK(GET_ACCELERANT_CLONE_INFO);
48 		HOOK(UNINIT_ACCELERANT);
49 		HOOK(GET_ACCELERANT_DEVICE_INFO);
50 		HOOK(ACCELERANT_RETRACE_SEMAPHORE);
51 
52 		/* mode configuration */
53 		HOOK(ACCELERANT_MODE_COUNT);
54 		HOOK(GET_MODE_LIST);
55 		HOOK(PROPOSE_DISPLAY_MODE);
56 		HOOK(SET_DISPLAY_MODE);
57 		HOOK(GET_DISPLAY_MODE);
58 		HOOK(GET_FRAME_BUFFER_CONFIG);
59 		HOOK(GET_PIXEL_CLOCK_LIMITS);
60 		HOOK(MOVE_DISPLAY);
61 		HOOK(SET_INDEXED_COLORS);
62 		//HOOK(GET_TIMING_CONSTRAINTS);
63 #ifdef __HAIKU__
64 		case B_GET_PREFERRED_DISPLAY_MODE:
65 			return (void*)radeon_get_preferred_display_mode;
66 		case B_GET_EDID_INFO:
67 			return (void*)radeon_get_edid_info;
68 #endif
69 
70 		HOOK(DPMS_CAPABILITIES);
71 		HOOK(DPMS_MODE);
72 		HOOK(SET_DPMS_MODE);
73 
74 		/* cursor managment */
75 // TODO: fix
76 //		HOOK(SET_CURSOR_SHAPE);
77 //		HOOK(MOVE_CURSOR);
78 //		HOOK(SHOW_CURSOR);
79 
80 		/* synchronization */
81 		HOOK(ACCELERANT_ENGINE_COUNT);
82 		HOOK(ACQUIRE_ENGINE);
83 		HOOK(RELEASE_ENGINE);
84 		HOOK(WAIT_ENGINE_IDLE);
85 		HOOK(GET_SYNC_TOKEN);
86 		HOOK(SYNC_TO_TOKEN);
87 
88 /*
89 When requesting an acceleration hook, the calling application provides a
90 pointer to the display_mode for which the acceleration function will be used.
91 Depending on the engine architecture, you may choose to provide a different
92 function to be used with each bit-depth.  In the sample driver we return
93 the same function all the time.
94 */
95 		/* 2D acceleration */
96 		HOOK(SCREEN_TO_SCREEN_BLIT);
97 		HOOK(FILL_RECTANGLE);
98 		HOOK(INVERT_RECTANGLE);
99 		HOOK(FILL_SPAN);
100 
101 		// overlay
102 		HOOK(OVERLAY_COUNT);
103 		HOOK(OVERLAY_SUPPORTED_SPACES);
104 		HOOK(OVERLAY_SUPPORTED_FEATURES);
105 		HOOK(ALLOCATE_OVERLAY_BUFFER);
106 		HOOK(RELEASE_OVERLAY_BUFFER);
107 		HOOK(GET_OVERLAY_CONSTRAINTS);
108 		HOOK(ALLOCATE_OVERLAY);
109 		HOOK(RELEASE_OVERLAY);
110 		HOOK(CONFIGURE_OVERLAY);
111 #undef HOOK
112 #undef ZERO
113 	}
114 
115 	return NULL;
116 }
117