2 * Copyright 2007-2010 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
); }
56 #define TDFX_PRIVATE_DATA_MAGIC 0x5042
60 TDFX_GET_SHARED_DATA
= B_DEVICE_OP_CODES_END
+ 123,
67 // Chip type numbers. These are used to group the chips into related
68 // groups. See table chipTable in driver.c
80 uint32 magic
; // magic number
81 uint32 offset
; // offset of register in PIO register area
82 int16 index
; // index of value to read/write; < 0 if not indexed reg
83 uint8 value
; // value to write or value that was read
87 struct DisplayModeEx
: display_mode
{
90 uint16 bytesPerRow
; // number of bytes in one line/row
94 struct OverlayBuffer
: overlay_buffer
{
95 OverlayBuffer
* nextBuffer
; // pointer to next buffer in chain, NULL = none
96 uint32 size
; // size of overlay buffer
102 uint16 vendorID
; // PCI vendor ID, from pci_info
103 uint16 deviceID
; // PCI device ID, from pci_info
104 uint8 revision
; // PCI device revsion, from pci_info
105 ChipType chipType
; // indicates group in which chip belongs (a group has similar functionality)
106 char chipName
[32]; // user recognizable name of chip
108 bool bAccelerantInUse
; // true = accelerant has been initialized
111 area_id regsArea
; // area_id for the memory mapped registers. It will
112 // be cloned into accelerant's address space.
113 area_id videoMemArea
; // video memory area_id. The addresses are shared with all teams.
114 addr_t videoMemAddr
; // video memory addr as viewed from virtual memory
115 phys_addr_t videoMemPCI
; // video memory addr as viewed from the PCI bus (for DMA)
116 uint32 videoMemSize
; // video memory size in bytes.
118 uint32 cursorOffset
; // offset of cursor in video memory
119 uint32 frameBufferOffset
; // offset of frame buffer in video memory
120 uint32 maxFrameBufferSize
; // max available video memory for frame buffer
122 // Color spaces supported by current video chip/driver.
123 color_space colorSpaces
[6];
124 uint32 colorSpaceCount
; // number of color spaces in array colorSpaces
126 uint32 maxPixelClock
; // max pixel clock of current chip in KHz
128 // List of screen modes.
129 area_id modeArea
; // area containing list of display modes the driver supports
130 uint32 modeCount
; // number of display modes in the list
132 DisplayModeEx displayMode
; // current display mode configuration
134 uint16 cursorHotX
; // Cursor hot spot. Top left corner of the cursor
135 uint16 cursorHotY
; // is 0,0
138 bool bHaveEDID
; // true = EDID info from device is in edidInfo
140 Benaphore engineLock
; // for access to the acceleration engine
141 Benaphore overlayLock
; // for overlay operations
143 int32 overlayAllocated
; // non-zero if overlay is allocated
145 OverlayBuffer
* overlayBuffer
; // pointer to linked list of buffers; NULL = none
149 #endif // DRIVERINTERFACE_H