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