xref: /haiku/src/add-ons/accelerants/intel_extreme/hooks.cpp (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
1 /*
2  * Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Axel Dörfler, axeld@pinc-software.de
7  */
8 
9 
10 #include "accelerant_protos.h"
11 #include "accelerant.h"
12 
13 
14 extern "C" void*
15 get_accelerant_hook(uint32 feature, void* data)
16 {
17 	switch (feature) {
18 		/* general */
19 		case B_INIT_ACCELERANT:
20 			return (void*)intel_init_accelerant;
21 		case B_UNINIT_ACCELERANT:
22 			return (void*)intel_uninit_accelerant;
23 		case B_CLONE_ACCELERANT:
24 			return (void*)intel_clone_accelerant;
25 		case B_ACCELERANT_CLONE_INFO_SIZE:
26 			return (void*)intel_accelerant_clone_info_size;
27 		case B_GET_ACCELERANT_CLONE_INFO:
28 			return (void*)intel_get_accelerant_clone_info;
29 		case B_GET_ACCELERANT_DEVICE_INFO:
30 			return (void*)intel_get_accelerant_device_info;
31 		case B_ACCELERANT_RETRACE_SEMAPHORE:
32 			return (void*)intel_accelerant_retrace_semaphore;
33 
34 		/* mode configuration */
35 		case B_ACCELERANT_MODE_COUNT:
36 			return (void*)intel_accelerant_mode_count;
37 		case B_GET_MODE_LIST:
38 			return (void*)intel_get_mode_list;
39 		case B_PROPOSE_DISPLAY_MODE:
40 			return (void*)intel_propose_display_mode;
41 		case B_GET_PREFERRED_DISPLAY_MODE:
42 			return (void*)intel_get_preferred_mode;
43 		case B_SET_DISPLAY_MODE:
44 			return (void*)intel_set_display_mode;
45 		case B_GET_DISPLAY_MODE:
46 			return (void*)intel_get_display_mode;
47 #ifdef __HAIKU__
48 		case B_GET_EDID_INFO:
49 			return (void*)intel_get_edid_info;
50 
51 		/* laptop panel backlight */
52 		case B_SET_BRIGHTNESS:
53 			if (gInfo->shared_info->device_type.IsMobile())
54 				return (void*)intel_set_brightness;
55 		case B_GET_BRIGHTNESS:
56 			if (gInfo->shared_info->device_type.IsMobile())
57 				return (void*)intel_get_brightness;
58 
59 			return NULL;
60 #endif
61 		case B_GET_FRAME_BUFFER_CONFIG:
62 			return (void*)intel_get_frame_buffer_config;
63 		case B_GET_PIXEL_CLOCK_LIMITS:
64 			return (void*)intel_get_pixel_clock_limits;
65 		case B_MOVE_DISPLAY:
66 			return (void*)intel_move_display;
67 		case B_SET_INDEXED_COLORS:
68 			return (void*)intel_set_indexed_colors;
69 		case B_GET_TIMING_CONSTRAINTS:
70 			return (void*)intel_get_timing_constraints;
71 
72 		/* DPMS */
73 		case B_DPMS_CAPABILITIES:
74 			return (void*)intel_dpms_capabilities;
75 		case B_DPMS_MODE:
76 			return (void*)intel_dpms_mode;
77 		case B_SET_DPMS_MODE:
78 			return (void*)intel_set_dpms_mode;
79 
80 		/* cursor managment */
81 		case B_SET_CURSOR_SHAPE:
82 			if (gInfo->shared_info->cursor_memory != NULL)
83 				return (void*)intel_set_cursor_shape;
84 		case B_MOVE_CURSOR:
85 			if (gInfo->shared_info->cursor_memory != NULL)
86 				return (void*)intel_move_cursor;
87 		case B_SHOW_CURSOR:
88 			if (gInfo->shared_info->cursor_memory != NULL)
89 				return (void*)intel_show_cursor;
90 
91 			return NULL;
92 
93 		/* engine/synchronization */
94 		case B_ACCELERANT_ENGINE_COUNT:
95 			return (void*)intel_accelerant_engine_count;
96 		case B_ACQUIRE_ENGINE:
97 			return (void*)intel_acquire_engine;
98 		case B_RELEASE_ENGINE:
99 			return (void*)intel_release_engine;
100 		case B_WAIT_ENGINE_IDLE:
101 			return (void*)intel_wait_engine_idle;
102 		case B_GET_SYNC_TOKEN:
103 			return (void*)intel_get_sync_token;
104 		case B_SYNC_TO_TOKEN:
105 			return (void*)intel_sync_to_token;
106 
107 		/* 2D acceleration */
108 		case B_SCREEN_TO_SCREEN_BLIT:
109 			return (void*)intel_screen_to_screen_blit;
110 		case B_FILL_RECTANGLE:
111 			return (void*)intel_fill_rectangle;
112 		case B_INVERT_RECTANGLE:
113 			return (void*)intel_invert_rectangle;
114 		case B_FILL_SPAN:
115 			return NULL;//(void*)intel_fill_span;
116 
117 		// overlay
118 		case B_OVERLAY_COUNT:
119 			return (void*)intel_overlay_count;
120 		case B_OVERLAY_SUPPORTED_SPACES:
121 			return (void*)intel_overlay_supported_spaces;
122 		case B_OVERLAY_SUPPORTED_FEATURES:
123 			return (void*)intel_overlay_supported_features;
124 		case B_ALLOCATE_OVERLAY_BUFFER:
125 			// TODO: overlay doesn't seem to work on these chips
126 			if (gInfo->shared_info->device_type.InGroup(INTEL_GROUP_91x)
127 				|| gInfo->shared_info->device_type.InGroup(INTEL_GROUP_94x)
128 				|| gInfo->shared_info->device_type.IsModel(INTEL_MODEL_965M)
129 				|| gInfo->shared_info->device_type.InGroup(INTEL_GROUP_G4x)
130 				|| gInfo->shared_info->device_type.InGroup(INTEL_GROUP_PIN)
131 				|| gInfo->shared_info->device_type.InGroup(INTEL_GROUP_ILK)
132 				|| gInfo->shared_info->device_type.InFamily(INTEL_FAMILY_SER5)
133 				|| gInfo->shared_info->device_type.InFamily(INTEL_FAMILY_SOC0))
134 				return NULL;
135 
136 			return (void*)intel_allocate_overlay_buffer;
137 		case B_RELEASE_OVERLAY_BUFFER:
138 			return (void*)intel_release_overlay_buffer;
139 		case B_GET_OVERLAY_CONSTRAINTS:
140 			return (void*)intel_get_overlay_constraints;
141 		case B_ALLOCATE_OVERLAY:
142 			return (void*)intel_allocate_overlay;
143 		case B_RELEASE_OVERLAY:
144 			return (void*)intel_release_overlay;
145 		case B_CONFIGURE_OVERLAY:
146 			return (void*)intel_configure_overlay;
147 	}
148 
149 	return NULL;
150 }
151 
152