xref: /haiku/src/add-ons/kernel/drivers/graphics/radeon/radeon_driver.h (revision 67bce78b48ed6d01b5a8eef89f5694c372b7e0a1)
1 /*
2 	Copyright (c) 2002, Thomas Kurschel
3 
4 
5 	Part of Radeon kernel driver
6 
7 	Common header file
8 */
9 
10 #ifndef _RADEON_DRIVER_H
11 #define _RADEON_DRIVER_H
12 
13 #include <radeon_interface.h>
14 #include "memmgr.h"
15 
16 #include <KernelExport.h>
17 #include <GraphicsDefs.h>
18 
19 
20 // logging helpers
21 extern int debug_level_flow;
22 extern int debug_level_info;
23 extern int debug_level_error;
24 
25 /*#define DEBUG_WAIT_ON_MSG 1000000
26 #define DEBUG_WAIT_ON_ERROR 1000000*/
27 
28 #define DEBUG_MSG_PREFIX "Radeon - "
29 #include <debug_ext.h>
30 
31 #ifdef ENABLE_LOGGING
32 #include "log_coll.h"
33 #endif
34 
35 
36 #define MAX_DEVICES	8
37 
38 
39 // DMA buffer
40 typedef struct DMA_buffer {
41 	area_id buffer_area;
42 	size_t size;
43 	void *ptr;
44 
45 	area_id GART_area;
46 	uint32 *GART_ptr;
47 	uint32 GART_phys;
48 	area_id unaligned_area;
49 } DMA_buffer;
50 
51 // info about graphics RAM
52 typedef struct {
53 	int ml;
54 	int MB;
55 	int Trcd;
56 	int Trp;
57 	int Twr;
58 	int CL;
59 	int Tr2w;
60 	int loop_latency;
61 	int Rloop;
62 } ram_info;
63 
64 typedef struct {
65 	area_id		bios_area;
66 
67 	uint8		*bios_ptr;		// begin of entire BIOS
68 	uint8		*rom_ptr;		// begin of ROM containing hw info
69 } rom_info;
70 
71 
72 // timer for VBI emulation
73 typedef struct {
74 	timer		te;				/* timer entry for add_timer() */
75 	struct device_info	*di;	/* pointer to the owning device */
76 	bigtime_t	when_target;	/* when we're supposed to wake up */
77 } timer_info;
78 
79 
80 // info about one device
81 typedef struct device_info {
82 	uint32		is_open;
83 	area_id		shared_area;
84 	shared_info	*si;
85 
86 	area_id		virtual_card_area;
87 	virtual_card *vc;
88 	vuint8		*regs;
89 
90 	bool 		has_crtc2;
91 	radeon_type	asic;
92 	display_type_e disp_type[2];
93 	fp_info		fp_info;
94 
95 	pll_info	pll;
96 	ram_info	ram;
97 	char		ram_type[32];	// human-readable name of ram type
98 	uint32		local_mem_size;
99 
100 	rom_info	rom;
101 
102 	DMA_buffer	DMABuffer;
103 
104 	mem_info	*local_memmgr;
105 
106 	// VBI data
107 	uint32      interrupt_count;
108 	uint32		vbi_count[2];
109 	// VBI emulation
110 	int32		shutdown_virtual_irq;	// true, to shutdown virtual interrupts
111 	timer_info  ti_a;           /* a pool of two timer managment buffers */
112     timer_info  ti_b;
113     timer_info  *current_timer; /* the timer buffer that's currently in use */
114 
115 	uint32		dac2_cntl;		// original dac2_cntl register content
116 
117 	pci_info	pcii;
118 	char		name[MAX_RADEON_DEVICE_NAME_LENGTH];
119 } device_info;
120 
121 
122 // device list and some global data
123 typedef struct {
124 	uint32		count;
125 	benaphore	kernel;
126 	char		*device_names[MAX_DEVICES+1];
127 	device_info	di[MAX_DEVICES];
128 } radeon_devices;
129 
130 
131 extern pci_module_info *pci_bus;
132 extern radeon_devices *devices;
133 
134 
135 // detect.c
136 bool Radeon_CardDetect( void );
137 void Radeon_ProbeDevices( void );
138 
139 
140 // init.c
141 status_t Radeon_FirstOpen( device_info *di );
142 void Radeon_LastClose( device_info *di );
143 status_t Radeon_MapDevice( device_info *di, bool mmio_only );
144 void Radeon_UnmapDevice(device_info *di);
145 
146 
147 // bios.c
148 status_t Radeon_MapBIOS( pci_info *pcii, rom_info *ri );
149 void Radeon_UnmapBIOS( rom_info *ri );
150 status_t Radeon_ReadBIOSData( device_info *di );
151 
152 
153 // dma.c
154 void Radeon_CleanupDMA( device_info *di );
155 status_t Radeon_InitDMA( device_info *di );
156 
157 
158 // irq.c
159 status_t Radeon_SetupIRQ( device_info *di, char *buffer );
160 void Radeon_CleanupIRQ( device_info *di );
161 
162 
163 // agp.c
164 void Radeon_Fix_AGP();
165 
166 #endif
167