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