1 /*****************************************************************************\ 2 * Tseng Labs ET6000, ET6100 and ET6300 graphics driver for BeOS 5. 3 * Copyright (c) 2003-2004, Evgeniy Vladimirovich Bobkov. 4 \*****************************************************************************/ 5 6 #ifndef _DRIVERINTERFACE_H_ 7 #define _DRIVERINTERFACE_H_ 8 9 #include <Accelerant.h> 10 #include <Drivers.h> 11 #include <PCI.h> 12 #include <OS.h> 13 14 15 #if defined(__cplusplus) 16 extern "C" { 17 #endif 18 19 /* 20 * This is the info that needs to be shared between the kernel driver and 21 * the accelerant for the et6000 driver. 22 */ 23 24 /*****************************************************************************/ 25 typedef struct { 26 sem_id sem; 27 int32 ben; 28 } benaphore; 29 30 #define INIT_BEN(x) x.sem = create_sem(0, "ET6000 "#x" benaphore"); x.ben = 0; 31 #define AQUIRE_BEN(x) if((atomic_add(&(x.ben), 1)) >= 1) acquire_sem(x.sem); 32 #define RELEASE_BEN(x) if((atomic_add(&(x.ben), -1)) > 1) release_sem(x.sem); 33 #define DELETE_BEN(x) delete_sem(x.sem); 34 /*****************************************************************************/ 35 #define ET6000_PRIVATE_DATA_MAGIC 0x100CC001 36 /*****************************************************************************/ 37 #define ET6000_HANDLER_INSTALLED 0x80000000 38 /*****************************************************************************/ 39 /* 40 * How many bytes of memory the accelerator (ACL) takes from the off-screen 41 * part of the adapter onboard memory to perform some of its operations. 42 */ 43 #define ET6000_ACL_NEEDS_MEMORY 4 44 /*****************************************************************************/ 45 enum { 46 ET6000_GET_PRIVATE_DATA = B_DEVICE_OP_CODES_END + 1, 47 ET6000_GET_PCI, 48 ET6000_SET_PCI, 49 ET6000_DEVICE_NAME, 50 ET6000_PROPOSE_DISPLAY_MODE, 51 ET6000_SET_DISPLAY_MODE 52 }; 53 /*****************************************************************************/ 54 typedef struct { 55 uint16 vendor_id; /* PCI vendor ID, from pci_info */ 56 uint16 device_id; /* PCI device ID, from pci_info */ 57 uint8 revision; /* PCI device revsion, from pci_info */ 58 area_id memoryArea; /* Onboard memory's area_id. The addresses 59 * are shared with all teams. */ 60 void *framebuffer; /* Start of the mapped framebuffer */ 61 void *physFramebuffer; /* Physical address of start of framebuffer */ 62 void *memory; /* Start of the mapped adapter onboard memory */ 63 void *physMemory; /* Physical address of start of onboard memory */ 64 uint32 memSize; /* Size of available onboard memory, bytes. */ 65 uint16 pciConfigSpace; /* PCI header base I/O address */ 66 void *mmRegs; /* memory mapped registers */ 67 void *emRegs; /* external mapped registers */ 68 area_id modesArea; /* Contains the list of display modes the driver supports */ 69 uint32 modesNum; /* Number of display modes in the list */ 70 int32 flags; 71 72 display_mode dm; /* current display mode configuration */ 73 uint8 bytesPerPixel; /* bytes(!) per pixel at current display mode */ 74 frame_buffer_config fbc; /* bytes_per_row and start of frame buffer */ 75 76 struct { 77 uint64 count; /* last fifo slot used */ 78 uint64 lastIdle; /* last fifo slot we *know* the engine was idle after */ 79 benaphore lock; /* for serializing access to the acceleration engine */ 80 } engine; 81 82 uint32 pixelClockMax16; /* The maximum speed the pixel clock should run */ 83 uint32 pixelClockMax24; /* at for a given pixel width. Usually a function */ 84 /* of memory and DAC bandwidths. */ 85 } ET6000SharedInfo; 86 /*****************************************************************************/ 87 /* Read or write a value in PCI configuration space */ 88 typedef struct { 89 uint32 magic; /* magic number to make sure the caller groks us */ 90 uint32 offset; /* Offset to read/write */ 91 uint32 size; /* Number of bytes to transfer */ 92 uint32 value; /* The value read or written */ 93 } ET6000GetSetPCI; 94 /*****************************************************************************/ 95 /* Retrieve the area_id of the kernel/accelerant shared info */ 96 typedef struct { 97 uint32 magic; /* magic number to make sure the caller groks us */ 98 area_id sharedInfoArea; /* area_id containing the shared information */ 99 } ET6000GetPrivateData; 100 /*****************************************************************************/ 101 /* 102 * Retrieve the device name. Usefull for when we have a file handle, but 103 * want to know the device name (like when we are cloning the accelerant). 104 */ 105 typedef struct { 106 uint32 magic; /* magic number to make sure the caller groks us */ 107 char *name; /* The name of the device, less the /dev root */ 108 } ET6000DeviceName; 109 /*****************************************************************************/ 110 typedef struct { 111 uint32 magic; /* magic number to make sure the caller groks us */ 112 display_mode mode; /* Proposed mode or mode to set */ 113 uint16 pciConfigSpace; /* For setting the mode */ 114 uint32 memSize; /* For proposing the mode */ 115 } ET6000DisplayMode; 116 /*****************************************************************************/ 117 118 #if defined(__cplusplus) 119 } 120 #endif 121 122 123 #endif /* _DRIVERINTERFACE_H_ */ 124