2 Copyright 2007-2011 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
9 #ifndef DRIVERINTERFACE_H
10 #define DRIVERINTERFACE_H
13 #include <Accelerant.h>
14 #include <GraphicsDefs.h>
17 #include <video_overlay.h>
20 // This file contains info that is shared between the kernel driver and the
21 // accelerant, and info that is shared among the source files of the accelerant.
24 #define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog
31 status_t
Init(const char* name
)
34 sem
= create_sem(0, name
);
35 return sem
< 0 ? sem
: B_OK
;
40 if (atomic_add(&count
, 1) > 0)
41 return acquire_sem(sem
);
47 if (atomic_add(&count
, -1) > 1)
48 return release_sem(sem
);
52 void Delete() { delete_sem(sem
); }
57 ATI_GET_SHARED_DATA
= B_DEVICE_OP_CODES_END
+ 123,
61 ATI_SET_VESA_DISPLAY_MODE
65 // Chip type numbers. These are used to group the chips into related
66 // groups. See table chipTable in driver.c
67 // Note that the order of the Mach64 chip types must not be changed because
68 // < or > comparisons of the chip types are made. They should be in the order
69 // of the evolution of the chips.
87 Mach64_ChipsEnd
, // marks end of Mach64's
97 #define MACH64_FAMILY(chipType) (chipType < Mach64_ChipsEnd)
98 #define RAGE128_FAMILY(chipType) (chipType > Mach64_ChipsEnd)
103 MT_VGA
, // monitor with analog VGA interface
104 MT_DVI
, // monitor with DVI interface
105 MT_LAPTOP
// laptop video display
109 // Mach64 parameters for computing register vaules and other parameters.
113 uint8 clockNumberToProgram
; // obtained from video BIOS
114 uint32 maxPixelClock
; // obtained from video BIOS
115 int refFreq
; // obtained from video BIOS
116 int refDivider
; // obtained from video BIOS
117 uint8 xClkPostDivider
;
118 uint8 xClkRefDivider
;
119 uint16 xClkPageFaultDelay
;
120 uint16 xClkMaxRASDelay
;
121 uint16 displayFIFODepth
;
122 uint16 displayLoopLatency
;
123 uint8 vClkPostDivider
;
124 uint8 vClkFeedbackDivider
;
128 struct R128_PLLParams
{
129 uint16 reference_freq
;
130 uint16 reference_div
;
137 struct R128_RAMSpec
{ // All values in XCLKS
138 int memReadLatency
; // Memory Read Latency
139 int memBurstLen
; // Memory Burst Length
140 int rasToCasDelay
; // RAS to CAS delay
141 int rasPercentage
; // RAS percentage
142 int writeRecovery
; // Write Recovery
143 int casLatency
; // CAS Latency
144 int readToWriteDelay
; // Read to Write Delay
145 int loopLatency
; // Loop Latency
146 int loopFudgeFactor
; // Add to memReadLatency to get loopLatency
152 uint16 mode
; // VESA mode number
159 struct DisplayModeEx
: display_mode
{
161 uint16 bytesPerRow
; // number of bytes in one line/row
165 struct OverlayBuffer
: overlay_buffer
{
166 OverlayBuffer
* nextBuffer
; // pointer to next buffer in chain, NULL = none
167 uint32 size
; // size of overlay buffer
173 uint16 vendorID
; // PCI vendor ID, from pci_info
174 uint16 deviceID
; // PCI device ID, from pci_info
175 uint8 revision
; // PCI device revsion, from pci_info
176 ChipType chipType
; // indicates group in which chip belongs (a group has similar functionality)
177 char chipName
[32]; // user recognizable name of chip
179 bool bAccelerantInUse
; // true = accelerant has been initialized
180 bool bInterruptAssigned
; // card has a useable interrupt assigned to it
182 sem_id vertBlankSem
; // vertical blank semaphore; if < 0, there is no semaphore
185 area_id regsArea
; // area_id for the memory mapped registers. It will
186 // be cloned into accelerant's address space.
187 area_id videoMemArea
; // video memory area_id. The addresses are shared with all teams.
188 addr_t videoMemAddr
; // video memory addr as viewed from virtual memory
189 phys_addr_t videoMemPCI
; // video memory addr as viewed from the PCI bus (for DMA)
190 uint32 videoMemSize
; // video memory size in bytes.
192 uint32 cursorOffset
; // offset of cursor in video memory
193 uint32 frameBufferOffset
; // offset of frame buffer in video memory
194 uint32 maxFrameBufferSize
; // max available video memory for frame buffer
196 // Color spaces supported by current video chip/driver.
197 color_space colorSpaces
[6];
198 uint32 colorSpaceCount
; // number of color spaces in array colorSpaces
200 // List of screen modes.
201 area_id modeArea
; // area containing list of display modes the driver supports
202 uint32 modeCount
; // number of display modes in the list
204 DisplayModeEx displayMode
; // current display mode configuration
206 // List of VESA modes supported by current chip.
207 uint32 vesaModeTableOffset
; // offset of table in shared info
208 uint32 vesaModeCount
;
210 uint16 cursorHotX
; // Cursor hot spot. Top left corner of the cursor
211 uint16 cursorHotY
; // is 0,0
214 bool bHaveEDID
; // true = EDID info from device is in edidInfo
216 Benaphore engineLock
; // for serializing access to the acceleration engine
217 Benaphore overlayLock
; // for overlay operations
219 int32 overlayAllocated
; // non-zero if overlay is allocated
221 OverlayBuffer
* overlayBuffer
; // pointer to linked list of buffers; NULL = none
223 MonitorType displayType
;
225 uint16 panelX
; // laptop LCD width
226 uint16 panelY
; // laptop LCD height
227 uint16 panelPowerDelay
;
229 // Data members for Mach64 chips.
230 //-------------------------------
232 M64_Params m64Params
; // parameters for Mach64 chips
234 // Data members for Rage128 chips.
235 //--------------------------------
237 R128_RAMSpec r128MemSpec
; // Rage128 memory timing spec's
238 R128_PLLParams r128PLLParams
; // Rage128 PLL parameters from video BIOS ROM
240 uint32 r128_dpGuiMasterCntl
; // flags for accelerated drawing
244 #endif // DRIVERINTERFACE_H