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 #define ARRAY_SIZE(a) (int(sizeof(a) / sizeof(a[0]))) // get number of elements in an array 26 27 28 struct Benaphore { 29 sem_id sem; 30 int32 count; 31 32 status_t Init(const char* name) 33 { 34 count = 0; 35 sem = create_sem(0, name); 36 return sem < 0 ? sem : B_OK; 37 } 38 39 status_t Acquire() 40 { 41 if (atomic_add(&count, 1) > 0) 42 return acquire_sem(sem); 43 return B_OK; 44 } 45 46 status_t Release() 47 { 48 if (atomic_add(&count, -1) > 1) 49 return release_sem(sem); 50 return B_OK; 51 } 52 53 void Delete() { delete_sem(sem); } 54 }; 55 56 57 58 enum { 59 INTEL_GET_SHARED_DATA = B_DEVICE_OP_CODES_END + 234, 60 INTEL_DEVICE_NAME, 61 INTEL_GET_EDID, 62 }; 63 64 65 struct DisplayModeEx : display_mode { 66 uint8 bitsPerPixel; 67 uint8 bytesPerPixel; 68 uint16 bytesPerRow; // number of bytes in one line/row 69 }; 70 71 72 struct SharedInfo { 73 // Device ID info. 74 uint16 vendorID; // PCI vendor ID, from pci_info 75 uint16 deviceID; // PCI device ID, from pci_info 76 uint8 revision; // PCI device revsion, from pci_info 77 char chipName[32]; // user recognizable name of chip 78 79 bool bAccelerantInUse; // true = accelerant has been initialized 80 81 // Memory mappings. 82 area_id regsArea; // area_id for the memory mapped registers. It 83 // will be cloned into accelerant address space. 84 area_id videoMemArea; // addr shared with all teams. 85 addr_t videoMemAddr; // virtual video memory addr 86 phys_addr_t videoMemPCI; // physical video memory addr 87 uint32 videoMemSize; // video memory size in bytes (for frame buffer) 88 89 uint32 maxFrameBufferSize; // max available video memory for frame buffer 90 91 // Color spaces supported by current video chip/driver. 92 color_space colorSpaces[6]; 93 uint32 colorSpaceCount; // number of color spaces in array colorSpaces 94 95 // List of screen modes. 96 area_id modeArea; // area containing list of display modes 97 uint32 modeCount; // number of display modes in the list 98 99 DisplayModeEx displayMode; // current display mode configuration 100 101 edid1_info edidInfo; 102 bool bHaveEDID; // true = EDID info from device is in edidInfo 103 104 Benaphore engineLock; // serializing access to the acceleration engine 105 }; 106 107 108 #endif // DRIVERINTERFACE_H 109