2 * Copyright 2006-2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
7 * Alexander von Gluck, kallisti5@unixzen.com
9 #ifndef RADEON_HD_ACCELERANT_H
10 #define RADEON_HD_ACCELERANT_H
13 #include <ByteOrder.h>
21 #include "radeon_hd.h"
22 #include "ringqueue.h"
26 // Maximum displays (more then two requires AtomBIOS)
27 #define MAX_GPIO_PINS 64
28 // Maximum possible GPIO pins in gGPIOInfo
33 uint32 vgaRenderControl
;
53 struct accelerant_info
{
57 radeon_shared_info
* shared_info
;
58 area_id shared_info_area
;
60 display_mode
* mode_list
; // cloned list of standard display modes
61 area_id mode_list_area
;
72 struct fb_info fb
; // used for frame buffer info within MC
74 volatile uint32 dpms_mode
; // current driver dpms mode
76 uint32 maximumPixelClock
;
77 uint32 displayClockFrequency
;
78 uint32 dpExternalClock
;
80 uint32 lvdsSpreadSpectrumID
;
82 RingQueue
* ringQueue
[RADEON_QUEUE_MAX
]; // Ring buffer command processor
86 struct register_info
{
91 uint16 grphSwapControl
;
92 uint16 grphPrimarySurfaceAddr
;
93 uint16 grphSecondarySurfaceAddr
;
94 uint16 grphPrimarySurfaceAddrHigh
;
95 uint16 grphSecondarySurfaceAddrHigh
;
97 uint16 grphSurfaceOffsetX
;
98 uint16 grphSurfaceOffsetY
;
103 uint16 modeDesktopHeight
;
104 uint16 modeDataFormat
;
105 uint16 viewportStart
;
113 uint32 hwPin
; // GPIO hardware pin on GPU
114 uint32 hwReg
; // GPIO register
115 uint32 hwMask
; // GPIO pin mask
119 bool hwCapable
; // can do hw assisted i2c
143 struct encoder_info
{
148 uint32 linkEnumeration
; // ex. linkb == GRAPH_OBJECT_ENUM_ID2
161 uint16 i2cPinIndex
; // id of gpio pin for i2c communications
162 uint16 hpdPinIndex
; // id of gpio pin for hotplug detection
163 struct encoder_info encoder
;
164 struct encoder_info encoderExternal
;
172 uint32 connectorIndex
; // matches connector id in connector_info
180 display_mode preferredMode
;
181 display_mode currentMode
;
185 // register MMIO modes
186 #define OUT 0x1 // Direct MMIO calls
187 #define CRT 0x2 // Crt controller calls
188 #define VGA 0x3 // Vga calls
189 #define PLL 0x4 // PLL calls
190 #define MC 0x5 // Memory controller calls
193 extern accelerant_info
* gInfo
;
194 extern atom_context
* gAtomContext
;
195 extern display_info
* gDisplay
[MAX_DISPLAY
];
196 extern connector_info
* gConnector
[ATOM_MAX_SUPPORTED_DEVICE
];
197 extern gpio_info
* gGPIOInfo
[MAX_GPIO_PINS
];
203 _read32(uint32 offset
)
205 return *(volatile uint32
*)(gInfo
->regs
+ offset
);
210 _write32(uint32 offset
, uint32 value
)
212 *(volatile uint32
*)(gInfo
->regs
+ offset
) = value
;
216 // AtomBIOS cail register calls (are *4... no clue why)
218 Read32Cail(uint32 offset
)
220 return _read32(offset
* 4);
225 Write32Cail(uint32 offset
, uint32 value
)
227 _write32(offset
* 4, value
);
232 Read32(uint32 subsystem
, uint32 offset
)
240 return _read32(offset
);
242 return _read32(offset
);
248 Write32(uint32 subsystem
, uint32 offset
, uint32 value
)
256 _write32(offset
, value
);
259 _write32(offset
, value
);
266 Write32Mask(uint32 subsystem
, uint32 offset
, uint32 value
, uint32 mask
)
274 temp
= _read32(offset
);
277 temp
= _read32(offset
);
280 temp
= _read32(offset
);
281 //temp = _read32PLL(offset);
287 temp
|= value
& mask
;
294 _write32(offset
, temp
);
297 _write32(offset
, temp
);
300 _write32(offset
, temp
);
301 //_write32PLL(offset, temp);
307 #endif /* RADEON_HD_ACCELERANT_H */