1 /* 2 * Copyright 2009-2012, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _ACCELERANT_H_ 6 #define _ACCELERANT_H_ 7 8 9 #include <GraphicsDefs.h> 10 #include <OS.h> 11 12 13 #if defined(__cplusplus) 14 extern "C" { 15 #endif 16 17 18 #define B_ACCELERANT_ENTRY_POINT "get_accelerant_hook" 19 #define B_ACCELERANT_VERSION 1 20 21 22 typedef void* (*GetAccelerantHook)(uint32, void*); 23 24 void* get_accelerant_hook(uint32 feature, void* data); 25 26 27 enum { 28 /* initialization */ 29 B_INIT_ACCELERANT = 0, /* required */ 30 B_ACCELERANT_CLONE_INFO_SIZE, /* required */ 31 B_GET_ACCELERANT_CLONE_INFO, /* required */ 32 B_CLONE_ACCELERANT, /* required */ 33 B_UNINIT_ACCELERANT, /* required */ 34 B_GET_ACCELERANT_DEVICE_INFO, /* required */ 35 B_ACCELERANT_RETRACE_SEMAPHORE, /* optional */ 36 37 /* mode configuration */ 38 B_ACCELERANT_MODE_COUNT = 0x100, /* required */ 39 B_GET_MODE_LIST, /* required */ 40 B_PROPOSE_DISPLAY_MODE, /* optional */ 41 B_SET_DISPLAY_MODE, /* required */ 42 B_GET_DISPLAY_MODE, /* required */ 43 B_GET_FRAME_BUFFER_CONFIG, /* required */ 44 B_GET_PIXEL_CLOCK_LIMITS, /* required */ 45 B_GET_TIMING_CONSTRAINTS, /* optional */ 46 B_MOVE_DISPLAY, /* optional */ 47 B_SET_INDEXED_COLORS, /* required if driver supports 8bit */ 48 /* indexed modes */ 49 B_DPMS_CAPABILITIES, /* required if driver supports DPMS */ 50 B_DPMS_MODE, /* required if driver supports DPMS */ 51 B_SET_DPMS_MODE, /* required if driver supports DPMS */ 52 B_GET_PREFERRED_DISPLAY_MODE, /* optional */ 53 B_GET_MONITOR_INFO, /* optional */ 54 B_GET_EDID_INFO, /* optional */ 55 56 /* cursor managment */ 57 B_MOVE_CURSOR = 0x200, /* optional */ 58 B_SET_CURSOR_SHAPE, /* optional */ 59 B_SHOW_CURSOR, /* optional */ 60 B_SET_CURSOR_BITMAP, /* optional */ 61 62 /* synchronization */ 63 B_ACCELERANT_ENGINE_COUNT = 0x300, /* required */ 64 B_ACQUIRE_ENGINE, /* required */ 65 B_RELEASE_ENGINE, /* required */ 66 B_WAIT_ENGINE_IDLE, /* required */ 67 B_GET_SYNC_TOKEN, /* required */ 68 B_SYNC_TO_TOKEN, /* required */ 69 70 /* 2D acceleration */ 71 B_SCREEN_TO_SCREEN_BLIT = 0x400, /* optional */ 72 B_FILL_RECTANGLE, /* optional */ 73 B_INVERT_RECTANGLE, /* optional */ 74 B_FILL_SPAN, /* optional */ 75 B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT, /* optional */ 76 B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT, /* optional. 77 NOTE: source and dest may NOT overlap */ 78 79 /* 3D acceleration */ 80 B_ACCELERANT_PRIVATE_START = (int)0x80000000 81 }; 82 83 84 typedef struct { 85 uint32 version; /* structure version number */ 86 char name[32]; /* a name the user will recognize */ 87 /* the device by */ 88 char chipset[32]; /* the chipset used by the device */ 89 char serial_no[32]; /* serial number for the device */ 90 uint32 memory; /* amount of memory on the device, */ 91 /* in bytes */ 92 uint32 dac_speed; /* nominal DAC speed, in MHz */ 93 } accelerant_device_info; 94 95 96 typedef struct { 97 uint32 pixel_clock; /* kHz */ 98 uint16 h_display; /* in pixels (not character clocks) */ 99 uint16 h_sync_start; 100 uint16 h_sync_end; 101 uint16 h_total; 102 uint16 v_display; /* in lines */ 103 uint16 v_sync_start; 104 uint16 v_sync_end; 105 uint16 v_total; 106 uint32 flags; /* sync polarity, etc. */ 107 } display_timing; 108 109 110 typedef struct { 111 display_timing timing; /* CTRC info */ 112 uint32 space; /* pixel configuration */ 113 uint16 virtual_width; /* in pixels */ 114 uint16 virtual_height; /* in lines */ 115 uint16 h_display_start; /* first displayed pixel in line */ 116 uint16 v_display_start; /* first displayed line */ 117 uint32 flags; /* mode flags (Some drivers use this */ 118 /* for dual head related options.) */ 119 } display_mode; 120 121 typedef struct { 122 void* frame_buffer; /* pointer to first byte of frame */ 123 /* buffer in virtual memory */ 124 125 void* frame_buffer_dma; /* pointer to first byte of frame */ 126 /* buffer in physical memory for DMA */ 127 128 uint32 bytes_per_row; /* number of bytes in one */ 129 /* virtual_width line */ 130 /* not neccesarily the same as */ 131 /* virtual_width * byte_per_pixel */ 132 } frame_buffer_config; 133 134 135 typedef struct { 136 uint16 h_res; /* minimum effective change in */ 137 /* horizontal pixels, usually 8 */ 138 139 uint16 h_sync_min; /* min/max horizontal sync pulse */ 140 /* width in pixels, a multiple of */ 141 /* h_res */ 142 uint16 h_sync_max; 143 uint16 h_blank_min; /* min/max horizontal blank pulse */ 144 /* width in pixels, a multiple of */ 145 /* h_res */ 146 uint16 h_blank_max; 147 uint16 v_res; /* minimum effective change in */ 148 /* vertical lines, usually 1 */ 149 150 uint16 v_sync_min; /* min/max vertical sync pulse */ 151 /* width in lines, a multiple of */ 152 /* v_res */ 153 uint16 v_sync_max; 154 uint16 v_blank_min; /* min/max vertical blank pulse */ 155 /* width in linex, a multiple of */ 156 /* v_res */ 157 uint16 v_blank_max; 158 } display_timing_constraints; 159 160 161 // WARNING: This is experimental new Haiku API 162 typedef struct { 163 uint32 version; 164 char vendor[128]; 165 char name[128]; 166 char serial_number[128]; 167 uint32 product_id; 168 struct { 169 uint16 week; 170 uint16 year; 171 } produced; 172 float width; 173 float height; 174 uint32 min_horizontal_frequency; /* in kHz */ 175 uint32 max_horizontal_frequency; 176 uint32 min_vertical_frequency; /* in Hz */ 177 uint32 max_vertical_frequency; 178 uint32 max_pixel_clock; /* in kHz */ 179 } monitor_info; 180 181 182 /* mode flags */ 183 enum { 184 B_SCROLL = 1 << 0, 185 B_8_BIT_DAC = 1 << 1, 186 B_HARDWARE_CURSOR = 1 << 2, 187 B_PARALLEL_ACCESS = 1 << 3, 188 B_DPMS = 1 << 4, 189 B_IO_FB_NA = 1 << 5 190 }; 191 192 193 /* power saver flags */ 194 enum { 195 B_DPMS_ON = 1 << 0, 196 B_DPMS_STAND_BY = 1 << 1, 197 B_DPMS_SUSPEND = 1 << 2, 198 B_DPMS_OFF = 1 << 3 199 }; 200 201 202 /* timing flags */ 203 enum { 204 B_BLANK_PEDESTAL = 1 << 27, 205 B_TIMING_INTERLACED = 1 << 28, 206 B_POSITIVE_HSYNC = 1 << 29, 207 B_POSITIVE_VSYNC = 1 << 30, 208 B_SYNC_ON_GREEN = 1 << 31 209 }; 210 211 212 typedef struct { 213 uint16 src_left; /* guaranteed constrained to */ 214 /* virtual width and height */ 215 uint16 src_top; 216 uint16 dest_left; 217 uint16 dest_top; 218 uint16 width; /* 0 to N, where zero means */ 219 /* one pixel, one means two pixels, */ 220 /* etc. */ 221 uint16 height; /* 0 to M, where zero means one */ 222 /* line, one means two lines, etc. */ 223 } blit_params; 224 225 226 typedef struct { 227 uint16 src_left; /* guaranteed constrained to */ 228 /* virtual width and height */ 229 uint16 src_top; 230 uint16 src_width; /* 0 to N, where zero means one */ 231 /* pixel, one means two pixels, */ 232 /* etc. */ 233 uint16 src_height; /* 0 to M, where zero means one */ 234 /* line, one means two lines, etc. */ 235 uint16 dest_left; 236 uint16 dest_top; 237 uint16 dest_width; /* 0 to N, where zero means one */ 238 /* pixel, one means two pixels, etc. */ 239 uint16 dest_height; /* 0 to M, where zero means one */ 240 /* line, one means two lines, etc. */ 241 } scaled_blit_params; 242 243 244 typedef struct { 245 uint16 left; /* guaranteed constrained to */ 246 /* virtual width and height */ 247 uint16 top; 248 uint16 right; 249 uint16 bottom; 250 } fill_rect_params; 251 252 253 typedef struct { 254 uint32 engine_id; /* 0 == no engine, 1,2,3 etc */ 255 /* individual engines */ 256 uint32 capability_mask; /* features this engine supports */ 257 void* opaque; /* optional pointer to engine */ 258 /* private storage */ 259 } engine_token; 260 261 262 enum { /* engine capabilities */ 263 B_2D_ACCELERATION = 1 << 0, 264 B_3D_ACCELERATION = 1 << 1 265 }; 266 267 268 typedef struct { 269 uint64 counter; /* counts issued primatives */ 270 uint32 engine_id; /* what engine the counter is for */ 271 char opaque[12]; /* 12 bytes of private storage */ 272 } sync_token; 273 274 275 /* Masks for color info */ 276 /* B_CMAP8 - 0x000000ff */ 277 /* B_RGB15/16 - 0x0000ffff */ 278 /* B_RGB24 - 0x00ffffff */ 279 /* B_RGB32 - 0xffffffff */ 280 281 typedef status_t (*init_accelerant)(int fd); 282 typedef ssize_t (*accelerant_clone_info_size)(void); 283 typedef void (*get_accelerant_clone_info)(void* data); 284 typedef status_t (*clone_accelerant)(void* data); 285 typedef void (*uninit_accelerant)(void); 286 typedef status_t (*get_accelerant_device_info)(accelerant_device_info* adi); 287 288 typedef uint32 (*accelerant_mode_count)(void); 289 typedef status_t (*get_mode_list)(display_mode*); 290 typedef status_t (*propose_display_mode)(display_mode* target, 291 display_mode* low, display_mode* high); 292 typedef status_t (*set_display_mode)(display_mode* modeToSet); 293 typedef status_t (*get_display_mode)(display_mode* currentMode); 294 typedef status_t (*get_frame_buffer_config)(frame_buffer_config* frameBuffer); 295 typedef status_t (*get_pixel_clock_limits)(display_mode* dm, uint32* low, 296 uint32* high); 297 typedef status_t (*move_display_area)(uint16 hDisplayStart, 298 uint16 vDisplayStart); 299 typedef status_t (*get_timing_constraints)(display_timing_constraints* dtc); 300 typedef void (*set_indexed_colors)(uint count, uint8 first, 301 const uint8* colorData, uint32 flags); 302 typedef uint32 (*dpms_capabilities)(void); 303 typedef uint32 (*dpms_mode)(void); 304 typedef status_t (*set_dpms_mode)(uint32 dpms_flags); 305 typedef status_t (*get_preferred_display_mode)(display_mode* preferredMode); 306 typedef status_t (*get_monitor_info)(monitor_info* info); 307 typedef status_t (*get_edid_info)(void* info, uint32 size, uint32* _version); 308 typedef sem_id (*accelerant_retrace_semaphore)(void); 309 310 typedef status_t (*set_cursor_shape)(uint16 width, uint16 height, 311 uint16 hotX, uint16 hotY, const uint8* andMask, const uint8* xorMask); 312 typedef status_t (*set_cursor_bitmap)(uint16 width, uint16 height, 313 uint16 hotX, uint16 hotY, color_space colorSpace, uint16 bytesPerRow, 314 const uint8* bitmapData); 315 typedef void (*move_cursor)(uint16 x, uint16 y); 316 typedef void (*show_cursor)(bool isVisible); 317 318 typedef uint32 (*accelerant_engine_count)(void); 319 typedef status_t (*acquire_engine)(uint32 capabilities, uint32 maxWait, 320 sync_token* st, engine_token** et); 321 typedef status_t (*release_engine)(engine_token* et, sync_token* st); 322 typedef void (*wait_engine_idle)(void); 323 typedef status_t (*get_sync_token)(engine_token* et, sync_token* st); 324 typedef status_t (*sync_to_token)(sync_token* st); 325 326 typedef void (*screen_to_screen_blit)(engine_token* et, blit_params* list, 327 uint32 count); 328 typedef void (*fill_rectangle)(engine_token* et, uint32 color, 329 fill_rect_params* list, uint32 count); 330 typedef void (*invert_rectangle)(engine_token* et, fill_rect_params* list, 331 uint32 count); 332 typedef void (*screen_to_screen_transparent_blit)(engine_token* et, 333 uint32 transparent_color, blit_params* list, uint32 count); 334 typedef void (*screen_to_screen_scaled_filtered_blit)(engine_token* et, 335 scaled_blit_params* list, uint32 count); 336 337 typedef void (*fill_span)(engine_token* et, uint32 color, uint16* list, 338 uint32 count); 339 /* 340 The uint16* list points to a list of tripples: 341 list[N+0] Y co-ordinate of span 342 list[N+1] Left x co-ordinate of span 343 list[N+2] Right x co-ordinate of span 344 where N is in the range 0 to count-1. 345 */ 346 347 348 #if defined(__cplusplus) 349 } 350 #endif 351 352 #endif 353