- Timestamp:
- Sep 22, 2012 4:53:18 PM (12 years ago)
- Location:
- trunk/src/VBox/Additions/haiku/VBoxVideo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/haiku/VBoxVideo/accelerant/accelerant.cpp
r43364 r43408 45 45 */ 46 46 47 /******************************************************************************* 48 * Header Files * 49 *******************************************************************************/ 47 50 #include <Accelerant.h> 48 51 #include "accelerant.h" … … 51 54 #include <errno.h> 52 55 53 #define TRACE(x...) do { FILE* logfile = fopen("/var/log/vboxvideo.accelerant.log", "a"); fprintf(logfile, x); fflush(logfile); fsync(fileno(logfile)); fclose(logfile); sync(); } while(0) 56 /******************************************************************************* 57 * Global Variables * 58 *******************************************************************************/ 59 AccelerantInfo gInfo; 60 static engine_token sEngineToken = { 1, 0 /*B_2D_ACCELERATION*/, NULL }; 61 62 /** @todo r=ramshankar: get rid of this and replace with IPRT logging. */ 63 #define TRACE(x...) do { \ 64 FILE* logfile = fopen("/var/log/vboxvideo.accelerant.log", "a"); \ 65 fprintf(logfile, x); \ 66 fflush(logfile); \ 67 fsync(fileno(logfile)); \ 68 fclose(logfile); \ 69 sync(); \ 70 } while(0) 54 71 55 72 class AreaCloner 56 73 { 57 74 public: 58 AreaCloner() : fArea(-1) { } 75 AreaCloner() 76 : fArea(-1) 77 { 78 } 79 59 80 ~AreaCloner() 60 81 { … … 69 90 } 70 91 71 status_t InitCheck() { return fArea < B_OK ? (status_t)fArea : B_OK; } 72 void Keep() { fArea = -1; } 92 status_t InitCheck() 93 { 94 return fArea < B_OK ? (status_t)fArea : B_OK; 95 } 96 97 void Keep() 98 { 99 fArea = -1; 100 } 73 101 74 102 private: 75 area_id 103 area_id fArea; 76 104 }; 77 78 AccelerantInfo gInfo;79 80 static engine_token sEngineToken = { 1, 0 /*B_2D_ACCELERATION*/, NULL };81 105 82 106 extern "C" … … 86 110 switch (feature) 87 111 { 88 /* general */112 /* General */ 89 113 case B_INIT_ACCELERANT: 90 114 return (void *)vboxvideo_init_accelerant; … … 102 126 return (void *)vboxvideo_accelerant_retrace_semaphore; 103 127 104 /* mode configuration */128 /* Mode configuration */ 105 129 case B_ACCELERANT_MODE_COUNT: 106 130 return (void *)vboxvideo_accelerant_mode_count; … … 118 142 return (void *)vboxvideo_get_pixel_clock_limits; 119 143 144 #if 0 120 145 /* cursor managment */ 121 /*case B_SET_CURSOR_SHAPE:146 case B_SET_CURSOR_SHAPE: 122 147 return (void*)vboxvideo_set_cursor_shape; 123 148 case B_MOVE_CURSOR: 124 149 return (void*)vboxvideo_move_cursor; 125 150 case B_SHOW_CURSOR: 126 return (void*)vboxvideo_show_cursor;*/ 127 128 /* engine/synchronization */ 151 return (void*)vboxvideo_show_cursor; 152 #endif 153 154 /* Engine/synchronization */ 129 155 case B_ACCELERANT_ENGINE_COUNT: 130 156 return (void *)vboxvideo_accelerant_engine_count; … … 162 188 163 189 AreaCloner sharedCloner; 164 gInfo.sharedInfoArea = sharedCloner.Clone("vboxvideo shared info", 165 (void **)&gInfo.sharedInfo, B_ANY_ADDRESS, 190 gInfo.sharedInfoArea = sharedCloner.Clone("vboxvideo shared info", (void **)&gInfo.sharedInfo, B_ANY_ADDRESS, 166 191 B_READ_AREA | B_WRITE_AREA, sharedArea); 167 192 status_t status = sharedCloner.InitCheck(); … … 176 201 } 177 202 203 178 204 status_t vboxvideo_init_accelerant(int fd) 179 205 { … … 181 207 } 182 208 209 183 210 ssize_t vboxvideo_accelerant_clone_info_size(void) 184 211 { … … 187 214 } 188 215 216 189 217 void vboxvideo_get_accelerant_clone_info(void *data) 190 218 { … … 193 221 } 194 222 223 195 224 status_t vboxvideo_clone_accelerant(void *data) 196 225 { 197 226 TRACE("%s\n", __FUNCTION__); 198 227 199 / / create full device name228 /* Create full device name */ 200 229 char path[MAXPATHLEN]; 201 230 strcpy(path, "/dev/"); … … 209 238 } 210 239 240 211 241 void vboxvideo_uninit_accelerant(void) 212 242 { … … 220 250 TRACE("%s\n", __FUNCTION__); 221 251 } 252 222 253 223 254 status_t vboxvideo_get_accelerant_device_info(accelerant_device_info *adi) … … 231 262 } 232 263 264 233 265 sem_id vboxvideo_accelerant_retrace_semaphore(void) 234 266 { … … 236 268 return -1; 237 269 } 270 238 271 239 272 // modes & constraints … … 244 277 } 245 278 279 246 280 status_t vboxvideo_get_mode_list(display_mode *dm) 247 281 { … … 250 284 return vboxvideo_get_display_mode(dm); 251 285 } 286 252 287 253 288 status_t vboxvideo_set_display_mode(display_mode *modeToSet) … … 258 293 } 259 294 295 260 296 status_t vboxvideo_get_display_mode(display_mode *currentMode) 261 297 { … … 266 302 } 267 303 304 268 305 status_t vboxvideo_get_edid_info(void *info, size_t size, uint32 *_version) 269 306 { 270 307 TRACE("%s\n", __FUNCTION__); 271 308 272 / / copied from the X11 implementation:309 /* Copied from the X11 implementation: */ 273 310 static const uint8 edid_data[128] = { 274 311 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, /* header */ … … 307 344 return B_BUFFER_OVERFLOW; 308 345 309 *_version = 1; /* EDID_VERSION_1*/346 *_version = 1; /* EDID_VERSION_1 */ 310 347 memcpy(info, edid_data, 128); 311 348 return B_OK; 312 349 } 350 313 351 314 352 status_t vboxvideo_get_frame_buffer_config(frame_buffer_config *config) … … 322 360 } 323 361 362 324 363 status_t vboxvideo_get_pixel_clock_limits(display_mode *dm, uint32 *low, uint32 *high) 325 364 { … … 331 370 } 332 371 333 // cursor 372 373 /* Cursor */ 334 374 status_t vboxvideo_set_cursor_shape(uint16 width, uint16 height, uint16 hotX, uint16 hotY, uint8 *andMask, uint8 *xorMask) 335 375 { … … 339 379 } 340 380 381 341 382 void vboxvideo_move_cursor(uint16 x, uint16 y) 342 383 { … … 344 385 } 345 386 387 346 388 void vboxvideo_show_cursor(bool is_visible) 347 389 { … … 349 391 } 350 392 351 // accelerant engine 393 394 /* Accelerant engine */ 352 395 uint32 vboxvideo_accelerant_engine_count(void) 353 396 { … … 362 405 return B_OK; 363 406 } 407 364 408 365 409 status_t vboxvideo_release_engine(engine_token *et, sync_token *st) … … 372 416 } 373 417 418 374 419 void vboxvideo_wait_engine_idle(void) 375 420 { … … 377 422 } 378 423 424 379 425 status_t vboxvideo_get_sync_token(engine_token *et, sync_token *st) 380 426 { … … 383 429 } 384 430 431 385 432 status_t vboxvideo_sync_to_token(sync_token *st) 386 433 { … … 389 436 } 390 437 391 // 2D acceleration 438 439 /* 2D acceleration */ 392 440 void vboxvideo_screen_to_screen_blit(engine_token *et, blit_params *list, uint32 count) 393 441 { … … 395 443 } 396 444 445 397 446 void vboxvideo_fill_rectangle(engine_token *et, uint32 color, fill_rect_params *list, uint32 count) 398 447 { … … 400 449 } 401 450 451 402 452 void vboxvideo_invert_rectangle(engine_token *et, fill_rect_params *list, uint32 count) 403 453 { … … 405 455 } 406 456 457 407 458 void vboxvideo_fill_span(engine_token *et, uint32 color, uint16 *list, uint32 count) 408 459 { -
trunk/src/VBox/Additions/haiku/VBoxVideo/accelerant/accelerant.h
r43364 r43408 45 45 */ 46 46 47 #ifndef _ ACCELERANT_H48 #define _ ACCELERANT_H47 #ifndef ___VBOX_ACCELERANT_H 48 #define ___VBOX_ACCELERANT_H 49 49 50 50 #include <Accelerant.h> … … 53 53 struct AccelerantInfo 54 54 { 55 int deviceFD; 56 bool isClone; 55 /** @todo doxygen document these fields */ 56 int deviceFD; 57 bool isClone; 57 58 58 59 59 SharedInfo *sharedInfo; 60 area_id sharedInfoArea; 60 61 }; 61 62 extern AccelerantInfo gInfo; 62 63 63 / / general64 /* General */ 64 65 status_t vboxvideo_init_accelerant(int fd); 65 66 ssize_t vboxvideo_accelerant_clone_info_size(void); … … 70 71 sem_id vboxvideo_accelerant_retrace_semaphore(void); 71 72 72 / / modes & constraints73 /* Modes & constraints */ 73 74 uint32 vboxvideo_accelerant_mode_count(void); 74 75 status_t vboxvideo_get_mode_list(display_mode *dm); … … 79 80 status_t vboxvideo_get_pixel_clock_limits(display_mode *dm, uint32 *low, uint32 *high); 80 81 81 / / cursor82 /* Cursor */ 82 83 status_t vboxvideo_set_cursor_shape(uint16 width, uint16 height, uint16 hotX, uint16 hotY, uint8 *andMask, uint8 *xorMask); 83 84 void vboxvideo_move_cursor(uint16 x, uint16 y); 84 85 void vboxvideo_show_cursor(bool is_visible); 85 86 86 / / accelerant engine87 /* Accelerant engine */ 87 88 uint32 vboxvideo_accelerant_engine_count(void); 88 89 status_t vboxvideo_acquire_engine(uint32 capabilities, uint32 maxWait, sync_token *st, engine_token **et); … … 92 93 status_t vboxvideo_sync_to_token(sync_token *st); 93 94 94 / / 2D acceleration95 /* 2D acceleration */ 95 96 void vboxvideo_screen_to_screen_blit(engine_token *et, blit_params *list, uint32 count); 96 97 void vboxvideo_fill_rectangle(engine_token *et, uint32 color, fill_rect_params *list, uint32 count); … … 98 99 void vboxvideo_fill_span(engine_token *et, uint32 color, uint16 *list, uint32 count); 99 100 100 #endif /* _ACCELERANT_PROTOS_H */ 101 #endif /* ___VBOX_ACCELERANT_H */ 102 -
trunk/src/VBox/Additions/haiku/VBoxVideo/common/VBoxVideo_common.h
r43364 r43408 45 45 */ 46 46 47 #ifndef _ VBOXVIDEO_COMMON_H48 #define _ VBOXVIDEO_COMMON_H47 #ifndef ___VBOXVIDEO_COMMON_H 48 #define ___VBOXVIDEO_COMMON_H 49 49 50 50 #include <Drivers.h> … … 54 54 struct SharedInfo 55 55 { 56 57 58 56 display_mode currentMode; 57 area_id framebufferArea; 58 void *framebuffer; 59 59 }; 60 60 … … 72 72 case 1: return B_GRAY1; 73 73 case 4: return B_GRAY8; 74 // the app_server is smart enough to translate this to VGA mode 74 /* The app_server is smart enough to translate this to VGA mode */ 75 75 case 8: return B_CMAP8; 76 76 case 15: return B_RGB15; … … 98 98 } 99 99 100 #endif /* _ VBOXVIDEO_COMMON_H */100 #endif /* ___VBOXVIDEO_COMMON_H */ 101 101 -
trunk/src/VBox/Additions/haiku/VBoxVideo/driver/driver.cpp
r43366 r43408 45 45 */ 46 46 47 /******************************************************************************* 48 * Header Files * 49 *******************************************************************************/ 47 50 #include <KernelExport.h> 48 51 #include <PCI.h> … … 57 60 #define VENDOR_ID 0x80ee 58 61 #define DEVICE_ID 0xbeef 59 60 #define DEVICE_FORMAT "vd_%04X_%04X_%02X%02X%02X" 61 62 #define DRIVER_NAME "VBoxVideoDriver" 63 #define DEVICE_FORMAT "vd_%04X_%04X_%02X%02X%02X" 64 65 /** @todo r=ramshankar: pretty sure IPRT has something for page rounding, 66 * replace with IPRT version later. */ 62 67 #define ROUND_TO_PAGE_SIZE(x) (((x) + (B_PAGE_SIZE) - 1) & ~((B_PAGE_SIZE) - 1)) 63 68 … … 109 114 struct DeviceInfo 110 115 { 111 uint32 openCount; / / count of how many times device has been opened112 uint32 flags; / / device flags113 area_id sharedArea; / / area shared between driver and all accelerants114 SharedInfo *sharedInfo; / / pointer to shared info area memory115 pci_info pciInfo; / / copy of pci info for this device116 char name[B_OS_NAME_LENGTH]; / / name of device116 uint32 openCount; /* Count of how many times device has been opened */ 117 uint32 flags; /* Device flags */ 118 area_id sharedArea; /* Area shared between driver and all accelerants */ 119 SharedInfo *sharedInfo; /* Pointer to shared info area memory */ 120 pci_info pciInfo; /* Copy of pci info for this device */ 121 char name[B_OS_NAME_LENGTH]; /* Name of device */ 117 122 }; 118 123 119 // at most one virtual video card ever appears, no reason for this to be an array 120 static DeviceInfo gDeviceInfo; 121 static char *gDeviceNames[2] = { gDeviceInfo.name, NULL }; 122 static bool gCanHasDevice = false; // is the device present? 123 static Benaphore gLock; 124 static pci_module_info *gPCI; 125 124 /******************************************************************************* 125 * Internal Functions * 126 *******************************************************************************/ 126 127 status_t device_open(const char *name, uint32 flags, void **cookie); 127 128 status_t device_close(void *dev); … … 132 133 static uint32 get_color_space_for_depth(uint32 depth); 133 134 135 /******************************************************************************* 136 * Globals * 137 *******************************************************************************/ 138 /* At most one virtual video card ever appears, no reason for this to be an array */ 139 static DeviceInfo gDeviceInfo; 140 static char *gDeviceNames[2] = { gDeviceInfo.name, NULL }; 141 static bool gCanHasDevice = false; /* is the device present? */ 142 static Benaphore gLock; 143 static pci_module_info *gPCI; 144 134 145 static device_hooks gDeviceHooks = 135 146 { 136 device_open, // open137 device_close, // close138 device_free, // free139 device_ioctl, // control140 device_read, // read141 device_write, // write142 NULL, // select143 NULL, // deselect144 NULL, // read_pages145 NULL // write_pages147 device_open, 148 device_close, 149 device_free, 150 device_ioctl, 151 device_read, 152 device_write, 153 NULL, /* select */ 154 NULL, /* deselect */ 155 NULL, /* read_pages */ 156 NULL /* write_pages */ 146 157 }; 147 158 159 148 160 status_t init_hardware() 149 161 { 150 TRACE("init_hardware\n");151 152 if (get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest) != B_OK)153 {154 dprintf("get_module(%s) failed\n", VBOXGUEST_MODULE_NAME);155 return B_ERROR;156 }157 158 if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI) != B_OK) 159 {160 dprintf("get_module(%s) failed\n", B_PCI_MODULE_NAME);161 return B_ERROR;162 }163 164 return B_OK; 165 } 162 LogFlowFunc(("init_hardware\n")); 163 164 status_t err = get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest) 165 if (err == B_OK) 166 { 167 err = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI); 168 if (err == B_OK) 169 return B_OK; 170 171 LogRel((DRIVER_NAME ":_init_hardware() get_module(%s) failed. err=%08lx\n", B_PCI_MODULE_NAME)); 172 } 173 else 174 LogRel((DRIVER_NAME ":_init_hardware() get_module(%s) failed. err=%08lx\n", VBOXGUEST_MODULE_NAME, err)); 175 return B_ERROR; 176 } 177 166 178 167 179 status_t init_driver() 168 180 { 169 TRACE("init_driver\n");181 LogFlowFunc(("init_driver\n")); 170 182 171 183 gLock.Init("VBoxVideo driver lock"); … … 202 214 gDeviceInfo.sharedInfo->currentMode.timing.h_display = width; 203 215 gDeviceInfo.sharedInfo->currentMode.timing.v_display = height; 204 / / not used, but this makes a reasonable-sounding refresh rate show in screen prefs:216 /* Not used, but this makes a reasonable-sounding refresh rate show in screen prefs: */ 205 217 gDeviceInfo.sharedInfo->currentMode.timing.h_total = 1000; 206 218 gDeviceInfo.sharedInfo->currentMode.timing.v_total = 1; 207 219 gDeviceInfo.sharedInfo->currentMode.timing.pixel_clock = 850; 208 220 209 / / map the PCI memory space221 /* Map the PCI memory space */ 210 222 uint32 command_reg = gPCI->read_pci_config(gDeviceInfo.pciInfo.bus, 211 223 gDeviceInfo.pciInfo.device, gDeviceInfo.pciInfo.function, PCI_command, 2); … … 232 244 const char** publish_devices() 233 245 { 234 TRACE("publish_devices\n");246 LogFlowFunc(("publish_devices\n")); 235 247 if (gCanHasDevice) 236 248 return (const char **)gDeviceNames; … … 241 253 device_hooks* find_device(const char *name) 242 254 { 243 TRACE("find_device\n");255 LogFlowFunc(a("find_device\n")); 244 256 if (gCanHasDevice && strcmp(name, gDeviceInfo.name) == 0) 245 257 return &gDeviceHooks; … … 251 263 void uninit_driver() 252 264 { 253 TRACE("uninit_driver\n");265 LogFlowFunc(("uninit_driver\n")); 254 266 gLock.Delete(); 255 267 put_module(VBOXGUEST_MODULE_NAME); … … 258 270 status_t device_open(const char *name, uint32 flags, void **cookie) 259 271 { 260 TRACE("device_open\n");272 LogFlowFunc(("device_open\n")); 261 273 262 274 if (!gCanHasDevice || strcmp(name, gDeviceInfo.name) != 0) 263 275 return B_BAD_VALUE; 264 276 265 / / TODO init device!277 /* @todo init device! */ 266 278 267 279 *cookie = (void *)&gDeviceInfo; … … 272 284 status_t device_close(void *dev) 273 285 { 274 TRACE("device_close\n");286 LogFlowFunc(("device_close\n")); 275 287 return B_ERROR; 276 288 } … … 279 291 status_t device_free(void *dev) 280 292 { 281 TRACE("device_free\n");293 LogFlowFunc(("device_free\n")); 282 294 283 295 DeviceInfo& di = *(DeviceInfo *)dev; … … 303 315 status_t device_read(void *dev, off_t pos, void *buf, size_t *len) 304 316 { 305 TRACE("device_read\n");317 LogFlowFunc(("device_read\n")); 306 318 return B_NOT_ALLOWED; 307 319 } … … 310 322 status_t device_write(void *dev, off_t pos, const void *buf, size_t *len) 311 323 { 312 TRACE("device_write\n");324 LogFlowFunc(("device_write\n")); 313 325 return B_NOT_ALLOWED; 314 326 } … … 317 329 status_t device_ioctl(void *cookie, uint32 msg, void *buf, size_t len) 318 330 { 319 TRACE("device_ioctl\n");331 LogFlowFunc(("device_ioctl\n")); 320 332 321 333 DeviceInfo *dev = (DeviceInfo *)cookie; … … 324 336 { 325 337 case B_GET_ACCELERANT_SIGNATURE: 338 { 326 339 strcpy((char *)buf, "vboxvideo.accelerant"); 327 340 return B_OK; 341 } 328 342 329 343 case VBOXVIDEO_GET_PRIVATE_DATA: 344 { 345 /** @todo r=ramshankar: implement RTR0MemUserCopyFrom for haiku. */ 330 346 return user_memcpy(buf, &dev->sharedArea, sizeof(area_id)); 347 } 331 348 332 349 case VBOXVIDEO_GET_DEVICE_NAME: 350 { 351 /** @todo r=ramshankar: implement RTR0MemUserCopyFrom for haiku. */ 333 352 if (user_strlcpy((char *)buf, gDeviceInfo.name, len) < B_OK) 334 353 return B_BAD_ADDRESS; 335 else336 return B_OK;354 return B_OK; 355 } 337 356 338 357 case VBOXVIDEO_SET_DISPLAY_MODE: … … 347 366 return B_BAD_VALUE; 348 367 } 349 350 } 351 368 } 369
Note:
See TracChangeset
for help on using the changeset viewer.