1 /* 2 * Copyright 2007-2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Gerald Zajac 7 */ 8 #ifndef DRIVERINTERFACE_H 9 #define DRIVERINTERFACE_H 10 11 12 #include <Accelerant.h> 13 #include <GraphicsDefs.h> 14 #include <Drivers.h> 15 #include <edid.h> 16 17 18 // This file contains info that is shared between the kernel driver and the 19 // accelerant, and info that is shared among the source files of the 20 // accelerant. 21 22 23 #define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog 24 25 26 struct Benaphore { 27 sem_id sem; 28 int32 count; 29 30 status_t Init(const char* name) 31 { 32 count = 0; 33 sem = create_sem(0, name); 34 return sem < 0 ? sem : B_OK; 35 } 36 37 status_t Acquire() 38 { 39 if (atomic_add(&count, 1) > 0) 40 return acquire_sem(sem); 41 return B_OK; 42 } 43 44 status_t Release() 45 { 46 if (atomic_add(&count, -1) > 1) 47 return release_sem(sem); 48 return B_OK; 49 } 50 51 void Delete() { delete_sem(sem); } 52 }; 53 54 55 56 enum { 57 INTEL_GET_SHARED_DATA = B_DEVICE_OP_CODES_END + 234, 58 INTEL_DEVICE_NAME, 59 INTEL_GET_EDID, 60 }; 61 62 63 struct DisplayModeEx : display_mode { 64 uint8 bitsPerPixel; 65 uint8 bytesPerPixel; 66 uint16 bytesPerRow; // number of bytes in one line/row 67 }; 68 69 70 struct SharedInfo { 71 // Device ID info. 72 uint16 vendorID; // PCI vendor ID, from pci_info 73 uint16 deviceID; // PCI device ID, from pci_info 74 uint8 revision; // PCI device revsion, from pci_info 75 char chipName[32]; // user recognizable name of chip 76 77 bool bAccelerantInUse; // true = accelerant has been initialized 78 79 // Memory mappings. 80 area_id regsArea; // area_id for the memory mapped registers. It 81 // will be cloned into accelerant address space. 82 area_id videoMemArea; // addr shared with all teams. 83 addr_t videoMemAddr; // virtual video memory addr 84 phys_addr_t videoMemPCI; // physical video memory addr 85 uint32 videoMemSize; // video memory size in bytes (for frame buffer) 86 87 uint32 maxFrameBufferSize; // max available video memory for frame buffer 88 89 // Color spaces supported by current video chip/driver. 90 color_space colorSpaces[6]; 91 uint32 colorSpaceCount; // number of color spaces in array colorSpaces 92 93 // List of screen modes. 94 area_id modeArea; // area containing list of display modes 95 uint32 modeCount; // number of display modes in the list 96 97 DisplayModeEx displayMode; // current display mode configuration 98 99 edid1_info edidInfo; 100 bool bHaveEDID; // true = EDID info from device is in edidInfo 101 102 Benaphore engineLock; // serializing access to the acceleration engine 103 }; 104 105 106 #endif // DRIVERINTERFACE_H 107