xref: /haiku/src/add-ons/accelerants/radeon/GetAccelerantHook.c (revision 2600324b57fa31cdea1627d584d314f2a579c4a8)
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 *
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 		HOOK(SET_CURSOR_SHAPE);
76 		HOOK(MOVE_CURSOR);
77 		HOOK(SHOW_CURSOR);
78 
79 		/* synchronization */
80 		HOOK(ACCELERANT_ENGINE_COUNT);
81 		HOOK(ACQUIRE_ENGINE);
82 		HOOK(RELEASE_ENGINE);
83 		HOOK(WAIT_ENGINE_IDLE);
84 		HOOK(GET_SYNC_TOKEN);
85 		HOOK(SYNC_TO_TOKEN);
86 
87 /*
88 When requesting an acceleration hook, the calling application provides a
89 pointer to the display_mode for which the acceleration function will be used.
90 Depending on the engine architecture, you may choose to provide a different
91 function to be used with each bit-depth.  In the sample driver we return
92 the same function all the time.
93 */
94 		/* 2D acceleration */
95 		HOOK(SCREEN_TO_SCREEN_BLIT);
96 		HOOK(FILL_RECTANGLE);
97 		HOOK(INVERT_RECTANGLE);
98 		HOOK(FILL_SPAN);
99 
100 		// overlay
101 		HOOK(OVERLAY_COUNT);
102 		HOOK(OVERLAY_SUPPORTED_SPACES);
103 		HOOK(OVERLAY_SUPPORTED_FEATURES);
104 		HOOK(ALLOCATE_OVERLAY_BUFFER);
105 		HOOK(RELEASE_OVERLAY_BUFFER);
106 		HOOK(GET_OVERLAY_CONSTRAINTS);
107 		HOOK(ALLOCATE_OVERLAY);
108 		HOOK(RELEASE_OVERLAY);
109 		HOOK(CONFIGURE_OVERLAY);
110 #undef HOOK
111 #undef ZERO
112 	}
113 
114 	return NULL;
115 }
116