Subversion Repositories Kolibri OS

Rev

Rev 3192 | Rev 5179 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3192 Rev 3764
1
/*
1
/*
2
 * Copyright 2008 Advanced Micro Devices, Inc.
2
 * Copyright 2008 Advanced Micro Devices, Inc.
3
 * Copyright 2008 Red Hat Inc.
3
 * Copyright 2008 Red Hat Inc.
4
 * Copyright 2009 Jerome Glisse.
4
 * Copyright 2009 Jerome Glisse.
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
12
 *
13
 * The above copyright notice and this permission notice shall be included in
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
14
 * all copies or substantial portions of the Software.
15
 *
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
 * OTHER DEALINGS IN THE SOFTWARE.
22
 * OTHER DEALINGS IN THE SOFTWARE.
23
 *
23
 *
24
 * Authors: Dave Airlie
24
 * Authors: Dave Airlie
25
 *          Alex Deucher
25
 *          Alex Deucher
26
 *          Jerome Glisse
26
 *          Jerome Glisse
27
 */
27
 */
28
#ifndef __RADEON_H__
28
#ifndef __RADEON_H__
29
#define __RADEON_H__
29
#define __RADEON_H__
30
 
30
 
31
/* TODO: Here are things that needs to be done :
31
/* TODO: Here are things that needs to be done :
32
 *	- surface allocator & initializer : (bit like scratch reg) should
32
 *	- surface allocator & initializer : (bit like scratch reg) should
33
 *	  initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
33
 *	  initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
34
 *	  related to surface
34
 *	  related to surface
35
 *	- WB : write back stuff (do it bit like scratch reg things)
35
 *	- WB : write back stuff (do it bit like scratch reg things)
36
 *	- Vblank : look at Jesse's rework and what we should do
36
 *	- Vblank : look at Jesse's rework and what we should do
37
 *	- r600/r700: gart & cp
37
 *	- r600/r700: gart & cp
38
 *	- cs : clean cs ioctl use bitmap & things like that.
38
 *	- cs : clean cs ioctl use bitmap & things like that.
39
 *	- power management stuff
39
 *	- power management stuff
40
 *	- Barrier in gart code
40
 *	- Barrier in gart code
41
 *	- Unmappabled vram ?
41
 *	- Unmappabled vram ?
42
 *	- TESTING, TESTING, TESTING
42
 *	- TESTING, TESTING, TESTING
43
 */
43
 */
44
 
44
 
45
/* Initialization path:
45
/* Initialization path:
46
 *  We expect that acceleration initialization might fail for various
46
 *  We expect that acceleration initialization might fail for various
47
 *  reasons even thought we work hard to make it works on most
47
 *  reasons even thought we work hard to make it works on most
48
 *  configurations. In order to still have a working userspace in such
48
 *  configurations. In order to still have a working userspace in such
49
 *  situation the init path must succeed up to the memory controller
49
 *  situation the init path must succeed up to the memory controller
50
 *  initialization point. Failure before this point are considered as
50
 *  initialization point. Failure before this point are considered as
51
 *  fatal error. Here is the init callchain :
51
 *  fatal error. Here is the init callchain :
52
 *      radeon_device_init  perform common structure, mutex initialization
52
 *      radeon_device_init  perform common structure, mutex initialization
53
 *      asic_init           setup the GPU memory layout and perform all
53
 *      asic_init           setup the GPU memory layout and perform all
54
 *                          one time initialization (failure in this
54
 *                          one time initialization (failure in this
55
 *                          function are considered fatal)
55
 *                          function are considered fatal)
56
 *      asic_startup        setup the GPU acceleration, in order to
56
 *      asic_startup        setup the GPU acceleration, in order to
57
 *                          follow guideline the first thing this
57
 *                          follow guideline the first thing this
58
 *                          function should do is setting the GPU
58
 *                          function should do is setting the GPU
59
 *                          memory controller (only MC setup failure
59
 *                          memory controller (only MC setup failure
60
 *                          are considered as fatal)
60
 *                          are considered as fatal)
61
 */
61
 */
62
 
62
 
63
#include 
63
#include 
64
#include 
64
#include 
65
#include 
65
#include 
66
#include 
66
#include 
67
#include 
67
#include 
68
 
68
 
69
#include 
69
#include 
70
#include 
70
#include 
71
#include 
71
#include 
72
#include 
72
#include 
73
 
73
 
74
#include 
74
#include 
75
#include 
75
#include 
76
 
76
 
77
#include 
77
#include 
78
 
78
 
79
#include "radeon_family.h"
79
#include "radeon_family.h"
80
#include "radeon_mode.h"
80
#include "radeon_mode.h"
81
#include "radeon_reg.h"
81
#include "radeon_reg.h"
82
 
82
 
83
#include 
83
#include 
84
 
84
 
85
/*
85
/*
86
 * Modules parameters.
86
 * Modules parameters.
87
 */
87
 */
88
extern int radeon_no_wb;
88
extern int radeon_no_wb;
89
extern int radeon_modeset;
89
extern int radeon_modeset;
90
extern int radeon_dynclks;
90
extern int radeon_dynclks;
91
extern int radeon_r4xx_atom;
91
extern int radeon_r4xx_atom;
92
extern int radeon_agpmode;
92
extern int radeon_agpmode;
93
extern int radeon_vram_limit;
93
extern int radeon_vram_limit;
94
extern int radeon_gart_size;
94
extern int radeon_gart_size;
95
extern int radeon_benchmarking;
95
extern int radeon_benchmarking;
96
extern int radeon_testing;
96
extern int radeon_testing;
97
extern int radeon_connector_table;
97
extern int radeon_connector_table;
98
extern int radeon_tv;
98
extern int radeon_tv;
99
extern int radeon_audio;
99
extern int radeon_audio;
100
extern int radeon_disp_priority;
100
extern int radeon_disp_priority;
101
extern int radeon_hw_i2c;
101
extern int radeon_hw_i2c;
102
extern int radeon_pcie_gen2;
102
extern int radeon_pcie_gen2;
103
extern int radeon_msi;
103
extern int radeon_msi;
104
extern int radeon_lockup_timeout;
104
extern int radeon_lockup_timeout;
105
 
-
 
-
 
105
extern int radeon_fastfb;
106
 
106
 
107
 
107
 
108
typedef struct pm_message {
108
typedef struct pm_message {
109
    int event;
109
    int event;
110
} pm_message_t;
110
} pm_message_t;
111
 
111
 
112
typedef struct
112
typedef struct
113
{
113
{
114
  int width;
114
  int width;
115
  int height;
115
  int height;
116
  int bpp;
116
  int bpp;
117
  int freq;
117
  int freq;
118
}videomode_t;
118
}videomode_t;
119
 
119
 
120
 
120
 
121
 
121
 
122
static inline u32 ioread32(const volatile void __iomem *addr)
122
static inline u32 ioread32(const volatile void __iomem *addr)
123
{
123
{
124
    return in32((u32)addr);
124
    return in32((u32)addr);
125
}
125
}
126
 
126
 
127
static inline void iowrite32(uint32_t b, volatile void __iomem *addr)
127
//static inline void iowrite32(uint32_t b, volatile void __iomem *addr)
128
{
128
//{
129
    out32((u32)addr, b);
129
//    out32((u32)addr, b);
130
}
130
//}
131
 
131
 
132
 
132
 
133
/*
133
/*
134
 * Copy from radeon_drv.h so we don't have to include both and have conflicting
134
 * Copy from radeon_drv.h so we don't have to include both and have conflicting
135
 * symbol;
135
 * symbol;
136
 */
136
 */
137
#define RADEON_MAX_USEC_TIMEOUT         100000  /* 100 ms */
137
#define RADEON_MAX_USEC_TIMEOUT         100000  /* 100 ms */
138
#define RADEON_FENCE_JIFFIES_TIMEOUT	(HZ / 2)
138
#define RADEON_FENCE_JIFFIES_TIMEOUT	(HZ / 2)
139
/* RADEON_IB_POOL_SIZE must be a power of 2 */
139
/* RADEON_IB_POOL_SIZE must be a power of 2 */
140
#define RADEON_IB_POOL_SIZE             16
140
#define RADEON_IB_POOL_SIZE             16
141
#define RADEON_DEBUGFS_MAX_COMPONENTS	32
141
#define RADEON_DEBUGFS_MAX_COMPONENTS	32
142
#define RADEONFB_CONN_LIMIT             4
142
#define RADEONFB_CONN_LIMIT             4
143
#define RADEON_BIOS_NUM_SCRATCH		8
143
#define RADEON_BIOS_NUM_SCRATCH		8
144
 
144
 
145
/* max number of rings */
145
/* max number of rings */
146
#define RADEON_NUM_RINGS			5
146
#define RADEON_NUM_RINGS			6
147
 
147
 
148
/* fence seq are set to this number when signaled */
148
/* fence seq are set to this number when signaled */
149
#define RADEON_FENCE_SIGNALED_SEQ		0LL
149
#define RADEON_FENCE_SIGNALED_SEQ		0LL
150
 
150
 
151
/* internal ring indices */
151
/* internal ring indices */
152
/* r1xx+ has gfx CP ring */
152
/* r1xx+ has gfx CP ring */
153
#define RADEON_RING_TYPE_GFX_INDEX  0
153
#define RADEON_RING_TYPE_GFX_INDEX  0
154
 
154
 
155
/* cayman has 2 compute CP rings */
155
/* cayman has 2 compute CP rings */
156
#define CAYMAN_RING_TYPE_CP1_INDEX 1
156
#define CAYMAN_RING_TYPE_CP1_INDEX 1
157
#define CAYMAN_RING_TYPE_CP2_INDEX 2
157
#define CAYMAN_RING_TYPE_CP2_INDEX 2
158
 
158
 
159
/* R600+ has an async dma ring */
159
/* R600+ has an async dma ring */
160
#define R600_RING_TYPE_DMA_INDEX		3
160
#define R600_RING_TYPE_DMA_INDEX		3
161
/* cayman add a second async dma ring */
161
/* cayman add a second async dma ring */
162
#define CAYMAN_RING_TYPE_DMA1_INDEX		4
162
#define CAYMAN_RING_TYPE_DMA1_INDEX		4
-
 
163
 
-
 
164
/* R600+ */
-
 
165
#define R600_RING_TYPE_UVD_INDEX	5
163
 
166
 
164
/* hardcode those limit for now */
167
/* hardcode those limit for now */
165
#define RADEON_VA_IB_OFFSET			(1 << 20)
168
#define RADEON_VA_IB_OFFSET			(1 << 20)
166
#define RADEON_VA_RESERVED_SIZE		(8 << 20)
169
#define RADEON_VA_RESERVED_SIZE		(8 << 20)
167
#define RADEON_IB_VM_MAX_SIZE		(64 << 10)
170
#define RADEON_IB_VM_MAX_SIZE		(64 << 10)
168
 
171
 
169
/* reset flags */
172
/* reset flags */
170
#define RADEON_RESET_GFX			(1 << 0)
173
#define RADEON_RESET_GFX			(1 << 0)
171
#define RADEON_RESET_COMPUTE			(1 << 1)
174
#define RADEON_RESET_COMPUTE			(1 << 1)
172
#define RADEON_RESET_DMA			(1 << 2)
175
#define RADEON_RESET_DMA			(1 << 2)
-
 
176
#define RADEON_RESET_CP				(1 << 3)
-
 
177
#define RADEON_RESET_GRBM			(1 << 4)
-
 
178
#define RADEON_RESET_DMA1			(1 << 5)
-
 
179
#define RADEON_RESET_RLC			(1 << 6)
-
 
180
#define RADEON_RESET_SEM			(1 << 7)
-
 
181
#define RADEON_RESET_IH				(1 << 8)
-
 
182
#define RADEON_RESET_VMC			(1 << 9)
-
 
183
#define RADEON_RESET_MC				(1 << 10)
-
 
184
#define RADEON_RESET_DISPLAY			(1 << 11)
173
 
185
 
174
/*
186
/*
175
 * Errata workarounds.
187
 * Errata workarounds.
176
 */
188
 */
177
enum radeon_pll_errata {
189
enum radeon_pll_errata {
178
    CHIP_ERRATA_R300_CG             = 0x00000001,
190
    CHIP_ERRATA_R300_CG             = 0x00000001,
179
    CHIP_ERRATA_PLL_DUMMYREADS      = 0x00000002,
191
    CHIP_ERRATA_PLL_DUMMYREADS      = 0x00000002,
180
    CHIP_ERRATA_PLL_DELAY           = 0x00000004
192
    CHIP_ERRATA_PLL_DELAY           = 0x00000004
181
};
193
};
182
 
194
 
183
 
195
 
184
struct radeon_device;
196
struct radeon_device;
185
 
197
 
186
 
198
 
187
/*
199
/*
188
 * BIOS.
200
 * BIOS.
189
 */
201
 */
190
bool radeon_get_bios(struct radeon_device *rdev);
202
bool radeon_get_bios(struct radeon_device *rdev);
191
 
203
 
192
/*
204
/*
193
 * Dummy page
205
 * Dummy page
194
 */
206
 */
195
struct radeon_dummy_page {
207
struct radeon_dummy_page {
196
	struct page	*page;
208
	struct page	*page;
197
	dma_addr_t	addr;
209
	dma_addr_t	addr;
198
};
210
};
199
int radeon_dummy_page_init(struct radeon_device *rdev);
211
int radeon_dummy_page_init(struct radeon_device *rdev);
200
void radeon_dummy_page_fini(struct radeon_device *rdev);
212
void radeon_dummy_page_fini(struct radeon_device *rdev);
201
 
213
 
202
 
214
 
203
/*
215
/*
204
 * Clocks
216
 * Clocks
205
 */
217
 */
206
struct radeon_clock {
218
struct radeon_clock {
207
	struct radeon_pll p1pll;
219
	struct radeon_pll p1pll;
208
	struct radeon_pll p2pll;
220
	struct radeon_pll p2pll;
209
	struct radeon_pll dcpll;
221
	struct radeon_pll dcpll;
210
	struct radeon_pll spll;
222
	struct radeon_pll spll;
211
	struct radeon_pll mpll;
223
	struct radeon_pll mpll;
212
	/* 10 Khz units */
224
	/* 10 Khz units */
213
	uint32_t default_mclk;
225
	uint32_t default_mclk;
214
	uint32_t default_sclk;
226
	uint32_t default_sclk;
215
	uint32_t default_dispclk;
227
	uint32_t default_dispclk;
216
	uint32_t dp_extclk;
228
	uint32_t dp_extclk;
217
	uint32_t max_pixel_clock;
229
	uint32_t max_pixel_clock;
218
};
230
};
219
 
231
 
220
/*
232
/*
221
 * Power management
233
 * Power management
222
 */
234
 */
223
int radeon_pm_init(struct radeon_device *rdev);
235
int radeon_pm_init(struct radeon_device *rdev);
224
void radeon_pm_fini(struct radeon_device *rdev);
236
void radeon_pm_fini(struct radeon_device *rdev);
225
void radeon_pm_compute_clocks(struct radeon_device *rdev);
237
void radeon_pm_compute_clocks(struct radeon_device *rdev);
226
void radeon_pm_suspend(struct radeon_device *rdev);
238
void radeon_pm_suspend(struct radeon_device *rdev);
227
void radeon_pm_resume(struct radeon_device *rdev);
239
void radeon_pm_resume(struct radeon_device *rdev);
228
void radeon_combios_get_power_modes(struct radeon_device *rdev);
240
void radeon_combios_get_power_modes(struct radeon_device *rdev);
229
void radeon_atombios_get_power_modes(struct radeon_device *rdev);
241
void radeon_atombios_get_power_modes(struct radeon_device *rdev);
-
 
242
int radeon_atom_get_clock_dividers(struct radeon_device *rdev,
-
 
243
				   u8 clock_type,
-
 
244
				   u32 clock,
-
 
245
				   bool strobe_mode,
-
 
246
				   struct atom_clock_dividers *dividers);
230
void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
247
void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
231
void rs690_pm_info(struct radeon_device *rdev);
248
void rs690_pm_info(struct radeon_device *rdev);
232
extern int rv6xx_get_temp(struct radeon_device *rdev);
249
extern int rv6xx_get_temp(struct radeon_device *rdev);
233
extern int rv770_get_temp(struct radeon_device *rdev);
250
extern int rv770_get_temp(struct radeon_device *rdev);
234
extern int evergreen_get_temp(struct radeon_device *rdev);
251
extern int evergreen_get_temp(struct radeon_device *rdev);
235
extern int sumo_get_temp(struct radeon_device *rdev);
252
extern int sumo_get_temp(struct radeon_device *rdev);
236
extern int si_get_temp(struct radeon_device *rdev);
253
extern int si_get_temp(struct radeon_device *rdev);
237
extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
254
extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
238
				    unsigned *bankh, unsigned *mtaspect,
255
				    unsigned *bankh, unsigned *mtaspect,
239
				    unsigned *tile_split);
256
				    unsigned *tile_split);
240
 
257
 
241
/*
258
/*
242
 * Fences.
259
 * Fences.
243
 */
260
 */
244
struct radeon_fence_driver {
261
struct radeon_fence_driver {
245
	uint32_t			scratch_reg;
262
	uint32_t			scratch_reg;
246
	uint64_t			gpu_addr;
263
	uint64_t			gpu_addr;
247
	volatile uint32_t		*cpu_addr;
264
	volatile uint32_t		*cpu_addr;
248
	/* sync_seq is protected by ring emission lock */
265
	/* sync_seq is protected by ring emission lock */
249
	uint64_t			sync_seq[RADEON_NUM_RINGS];
266
	uint64_t			sync_seq[RADEON_NUM_RINGS];
250
	atomic64_t			last_seq;
267
	atomic64_t			last_seq;
251
	unsigned long			last_activity;
268
	unsigned long			last_activity;
252
	bool				initialized;
269
	bool				initialized;
253
};
270
};
254
 
271
 
255
struct radeon_fence {
272
struct radeon_fence {
256
    struct radeon_device   *rdev;
273
    struct radeon_device   *rdev;
257
    struct kref             kref;
274
    struct kref             kref;
258
	/* protected by radeon_fence.lock */
275
	/* protected by radeon_fence.lock */
259
	uint64_t			seq;
276
	uint64_t			seq;
260
	/* RB, DMA, etc. */
277
	/* RB, DMA, etc. */
261
	unsigned			ring;
278
	unsigned			ring;
262
};
279
};
263
 
280
 
264
int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
281
int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
265
int radeon_fence_driver_init(struct radeon_device *rdev);
282
int radeon_fence_driver_init(struct radeon_device *rdev);
266
void radeon_fence_driver_fini(struct radeon_device *rdev);
283
void radeon_fence_driver_fini(struct radeon_device *rdev);
267
void radeon_fence_driver_force_completion(struct radeon_device *rdev);
284
void radeon_fence_driver_force_completion(struct radeon_device *rdev);
268
int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
285
int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
269
void radeon_fence_process(struct radeon_device *rdev, int ring);
286
void radeon_fence_process(struct radeon_device *rdev, int ring);
270
bool radeon_fence_signaled(struct radeon_fence *fence);
287
bool radeon_fence_signaled(struct radeon_fence *fence);
271
int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
288
int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
272
int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring);
289
int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring);
273
int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring);
290
int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring);
274
int radeon_fence_wait_any(struct radeon_device *rdev,
291
int radeon_fence_wait_any(struct radeon_device *rdev,
275
			  struct radeon_fence **fences,
292
			  struct radeon_fence **fences,
276
			  bool intr);
293
			  bool intr);
277
struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
294
struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
278
void radeon_fence_unref(struct radeon_fence **fence);
295
void radeon_fence_unref(struct radeon_fence **fence);
279
unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
296
unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
280
bool radeon_fence_need_sync(struct radeon_fence *fence, int ring);
297
bool radeon_fence_need_sync(struct radeon_fence *fence, int ring);
281
void radeon_fence_note_sync(struct radeon_fence *fence, int ring);
298
void radeon_fence_note_sync(struct radeon_fence *fence, int ring);
282
static inline struct radeon_fence *radeon_fence_later(struct radeon_fence *a,
299
static inline struct radeon_fence *radeon_fence_later(struct radeon_fence *a,
283
						      struct radeon_fence *b)
300
						      struct radeon_fence *b)
284
{
301
{
285
	if (!a) {
302
	if (!a) {
286
		return b;
303
		return b;
287
	}
304
	}
288
 
305
 
289
	if (!b) {
306
	if (!b) {
290
		return a;
307
		return a;
291
	}
308
	}
292
 
309
 
293
	BUG_ON(a->ring != b->ring);
310
	BUG_ON(a->ring != b->ring);
294
 
311
 
295
	if (a->seq > b->seq) {
312
	if (a->seq > b->seq) {
296
		return a;
313
		return a;
297
	} else {
314
	} else {
298
		return b;
315
		return b;
299
	}
316
	}
300
}
317
}
301
 
318
 
302
static inline bool radeon_fence_is_earlier(struct radeon_fence *a,
319
static inline bool radeon_fence_is_earlier(struct radeon_fence *a,
303
					   struct radeon_fence *b)
320
					   struct radeon_fence *b)
304
{
321
{
305
	if (!a) {
322
	if (!a) {
306
		return false;
323
		return false;
307
	}
324
	}
308
 
325
 
309
	if (!b) {
326
	if (!b) {
310
		return true;
327
		return true;
311
	}
328
	}
312
 
329
 
313
	BUG_ON(a->ring != b->ring);
330
	BUG_ON(a->ring != b->ring);
314
 
331
 
315
	return a->seq < b->seq;
332
	return a->seq < b->seq;
316
}
333
}
317
 
334
 
318
/*
335
/*
319
 * Tiling registers
336
 * Tiling registers
320
 */
337
 */
321
struct radeon_surface_reg {
338
struct radeon_surface_reg {
322
	struct radeon_bo *bo;
339
	struct radeon_bo *bo;
323
};
340
};
324
 
341
 
325
#define RADEON_GEM_MAX_SURFACES 8
342
#define RADEON_GEM_MAX_SURFACES 8
326
 
343
 
327
/*
344
/*
328
 * TTM.
345
 * TTM.
329
 */
346
 */
330
struct radeon_mman {
347
struct radeon_mman {
331
	struct ttm_bo_global_ref        bo_global_ref;
348
	struct ttm_bo_global_ref        bo_global_ref;
332
//	struct drm_global_reference	mem_global_ref;
349
	struct drm_global_reference	mem_global_ref;
333
	struct ttm_bo_device		bdev;
350
	struct ttm_bo_device		bdev;
334
	bool				mem_global_referenced;
351
	bool				mem_global_referenced;
335
	bool				initialized;
352
	bool				initialized;
336
};
353
};
337
 
354
 
338
/* bo virtual address in a specific vm */
355
/* bo virtual address in a specific vm */
339
struct radeon_bo_va {
356
struct radeon_bo_va {
340
	/* protected by bo being reserved */
357
	/* protected by bo being reserved */
341
	struct list_head		bo_list;
358
	struct list_head		bo_list;
342
	uint64_t			soffset;
359
	uint64_t			soffset;
343
	uint64_t			eoffset;
360
	uint64_t			eoffset;
344
	uint32_t			flags;
361
	uint32_t			flags;
345
	bool				valid;
362
	bool				valid;
346
	unsigned			ref_count;
363
	unsigned			ref_count;
347
 
364
 
348
	/* protected by vm mutex */
365
	/* protected by vm mutex */
349
	struct list_head		vm_list;
366
	struct list_head		vm_list;
350
 
367
 
351
	/* constant after initialization */
368
	/* constant after initialization */
352
	struct radeon_vm		*vm;
369
	struct radeon_vm		*vm;
353
	struct radeon_bo		*bo;
370
	struct radeon_bo		*bo;
354
};
371
};
355
 
372
 
356
struct radeon_bo {
373
struct radeon_bo {
357
	/* Protected by gem.mutex */
374
	/* Protected by gem.mutex */
358
	struct list_head		list;
375
	struct list_head		list;
359
	/* Protected by tbo.reserved */
376
	/* Protected by tbo.reserved */
360
	u32				placements[3];
377
	u32				placements[3];
361
	u32				busy_placements[3];
378
    u32             domain;
362
	struct ttm_placement		placement;
379
	struct ttm_placement		placement;
363
	struct ttm_buffer_object	tbo;
380
	struct ttm_buffer_object	tbo;
364
	struct ttm_bo_kmap_obj		kmap;
381
	struct ttm_bo_kmap_obj		kmap;
365
    unsigned                    pin_count;
382
    unsigned                    pin_count;
366
    void                       *kptr;
383
    void                       *kptr;
367
    void                       *uptr;
384
    void                       *uptr;
368
    u32                         cpu_addr;
385
    u32                         cpu_addr;
369
    u32                         tiling_flags;
386
    u32                         tiling_flags;
370
    u32                         pitch;
387
    u32                         pitch;
371
    int                         surface_reg;
388
    int                         surface_reg;
372
	/* list of all virtual address to which this bo
389
	/* list of all virtual address to which this bo
373
	 * is associated to
390
	 * is associated to
374
	 */
391
	 */
375
	struct list_head		va;
392
	struct list_head		va;
376
	/* Constant after initialization */
393
	/* Constant after initialization */
377
	struct radeon_device		*rdev;
394
	struct radeon_device		*rdev;
378
	struct drm_gem_object		gem_base;
395
	struct drm_gem_object		gem_base;
379
 
396
 
380
    u32                          domain;
-
 
381
	int vmapping_count;
397
	struct ttm_bo_kmap_obj dma_buf_vmap;
382
};
398
};
383
#define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
399
#define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
384
 
400
 
385
struct radeon_bo_list {
401
struct radeon_bo_list {
386
	struct radeon_bo	*bo;
402
	struct radeon_bo	*bo;
387
	uint64_t		gpu_offset;
403
	uint64_t		gpu_offset;
388
	unsigned		rdomain;
404
	unsigned		rdomain;
389
	unsigned		wdomain;
405
	unsigned		wdomain;
390
	u32			tiling_flags;
406
	u32			tiling_flags;
391
};
407
};
-
 
408
 
-
 
409
int radeon_gem_debugfs_init(struct radeon_device *rdev);
392
 
410
 
393
/* sub-allocation manager, it has to be protected by another lock.
411
/* sub-allocation manager, it has to be protected by another lock.
394
 * By conception this is an helper for other part of the driver
412
 * By conception this is an helper for other part of the driver
395
 * like the indirect buffer or semaphore, which both have their
413
 * like the indirect buffer or semaphore, which both have their
396
 * locking.
414
 * locking.
397
 *
415
 *
398
 * Principe is simple, we keep a list of sub allocation in offset
416
 * Principe is simple, we keep a list of sub allocation in offset
399
 * order (first entry has offset == 0, last entry has the highest
417
 * order (first entry has offset == 0, last entry has the highest
400
 * offset).
418
 * offset).
401
 *
419
 *
402
 * When allocating new object we first check if there is room at
420
 * When allocating new object we first check if there is room at
403
 * the end total_size - (last_object_offset + last_object_size) >=
421
 * the end total_size - (last_object_offset + last_object_size) >=
404
 * alloc_size. If so we allocate new object there.
422
 * alloc_size. If so we allocate new object there.
405
 *
423
 *
406
 * When there is not enough room at the end, we start waiting for
424
 * When there is not enough room at the end, we start waiting for
407
 * each sub object until we reach object_offset+object_size >=
425
 * each sub object until we reach object_offset+object_size >=
408
 * alloc_size, this object then become the sub object we return.
426
 * alloc_size, this object then become the sub object we return.
409
 *
427
 *
410
 * Alignment can't be bigger than page size.
428
 * Alignment can't be bigger than page size.
411
 *
429
 *
412
 * Hole are not considered for allocation to keep things simple.
430
 * Hole are not considered for allocation to keep things simple.
413
 * Assumption is that there won't be hole (all object on same
431
 * Assumption is that there won't be hole (all object on same
414
 * alignment).
432
 * alignment).
415
 */
433
 */
416
struct radeon_sa_manager {
434
struct radeon_sa_manager {
417
	wait_queue_head_t	wq;
435
	wait_queue_head_t	wq;
418
	struct radeon_bo	*bo;
436
	struct radeon_bo	*bo;
419
	struct list_head	*hole;
437
	struct list_head	*hole;
420
	struct list_head	flist[RADEON_NUM_RINGS];
438
	struct list_head	flist[RADEON_NUM_RINGS];
421
	struct list_head	olist;
439
	struct list_head	olist;
422
	unsigned		size;
440
	unsigned		size;
423
	uint64_t		gpu_addr;
441
	uint64_t		gpu_addr;
424
	void			*cpu_ptr;
442
	void			*cpu_ptr;
425
	uint32_t		domain;
443
	uint32_t		domain;
426
};
444
};
427
 
445
 
428
struct radeon_sa_bo;
446
struct radeon_sa_bo;
429
 
447
 
430
/* sub-allocation buffer */
448
/* sub-allocation buffer */
431
struct radeon_sa_bo {
449
struct radeon_sa_bo {
432
	struct list_head		olist;
450
	struct list_head		olist;
433
	struct list_head		flist;
451
	struct list_head		flist;
434
	struct radeon_sa_manager	*manager;
452
	struct radeon_sa_manager	*manager;
435
	unsigned			soffset;
453
	unsigned			soffset;
436
	unsigned			eoffset;
454
	unsigned			eoffset;
437
	struct radeon_fence		*fence;
455
	struct radeon_fence		*fence;
438
};
456
};
439
 
457
 
440
/*
458
/*
441
 * GEM objects.
459
 * GEM objects.
442
 */
460
 */
443
struct radeon_gem {
461
struct radeon_gem {
444
	struct mutex		mutex;
462
	struct mutex		mutex;
445
	struct list_head	objects;
463
	struct list_head	objects;
446
};
464
};
447
 
465
 
448
int radeon_gem_init(struct radeon_device *rdev);
466
int radeon_gem_init(struct radeon_device *rdev);
449
void radeon_gem_fini(struct radeon_device *rdev);
467
void radeon_gem_fini(struct radeon_device *rdev);
450
int radeon_gem_object_create(struct radeon_device *rdev, int size,
468
int radeon_gem_object_create(struct radeon_device *rdev, int size,
451
			     int alignment, int initial_domain,
469
			     int alignment, int initial_domain,
452
			     bool discardable, bool kernel,
470
			     bool discardable, bool kernel,
453
			     struct drm_gem_object **obj);
471
			     struct drm_gem_object **obj);
454
 
472
 
455
int radeon_mode_dumb_create(struct drm_file *file_priv,
473
int radeon_mode_dumb_create(struct drm_file *file_priv,
456
			    struct drm_device *dev,
474
			    struct drm_device *dev,
457
			    struct drm_mode_create_dumb *args);
475
			    struct drm_mode_create_dumb *args);
458
int radeon_mode_dumb_mmap(struct drm_file *filp,
476
int radeon_mode_dumb_mmap(struct drm_file *filp,
459
			  struct drm_device *dev,
477
			  struct drm_device *dev,
460
			  uint32_t handle, uint64_t *offset_p);
478
			  uint32_t handle, uint64_t *offset_p);
461
int radeon_mode_dumb_destroy(struct drm_file *file_priv,
479
int radeon_mode_dumb_destroy(struct drm_file *file_priv,
462
			     struct drm_device *dev,
480
			     struct drm_device *dev,
463
			     uint32_t handle);
481
			     uint32_t handle);
464
 
482
 
465
/*
483
/*
466
 * Semaphores.
484
 * Semaphores.
467
 */
485
 */
468
/* everything here is constant */
486
/* everything here is constant */
469
struct radeon_semaphore {
487
struct radeon_semaphore {
470
	struct radeon_sa_bo		*sa_bo;
488
	struct radeon_sa_bo		*sa_bo;
471
	signed				waiters;
489
	signed				waiters;
472
	uint64_t			gpu_addr;
490
	uint64_t			gpu_addr;
473
};
491
};
474
 
492
 
475
int radeon_semaphore_create(struct radeon_device *rdev,
493
int radeon_semaphore_create(struct radeon_device *rdev,
476
			    struct radeon_semaphore **semaphore);
494
			    struct radeon_semaphore **semaphore);
477
void radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring,
495
void radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring,
478
				  struct radeon_semaphore *semaphore);
496
				  struct radeon_semaphore *semaphore);
479
void radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring,
497
void radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring,
480
				struct radeon_semaphore *semaphore);
498
				struct radeon_semaphore *semaphore);
481
int radeon_semaphore_sync_rings(struct radeon_device *rdev,
499
int radeon_semaphore_sync_rings(struct radeon_device *rdev,
482
				struct radeon_semaphore *semaphore,
500
				struct radeon_semaphore *semaphore,
483
				int signaler, int waiter);
501
				int signaler, int waiter);
484
void radeon_semaphore_free(struct radeon_device *rdev,
502
void radeon_semaphore_free(struct radeon_device *rdev,
485
			   struct radeon_semaphore **semaphore,
503
			   struct radeon_semaphore **semaphore,
486
			   struct radeon_fence *fence);
504
			   struct radeon_fence *fence);
487
 
505
 
488
/*
506
/*
489
 * GART structures, functions & helpers
507
 * GART structures, functions & helpers
490
 */
508
 */
491
struct radeon_mc;
509
struct radeon_mc;
492
 
510
 
493
#define RADEON_GPU_PAGE_SIZE 4096
511
#define RADEON_GPU_PAGE_SIZE 4096
494
#define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
512
#define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
495
#define RADEON_GPU_PAGE_SHIFT 12
513
#define RADEON_GPU_PAGE_SHIFT 12
496
#define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK)
514
#define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK)
497
 
515
 
498
struct radeon_gart {
516
struct radeon_gart {
499
    dma_addr_t          table_addr;
517
    dma_addr_t          table_addr;
500
	struct radeon_bo		*robj;
518
	struct radeon_bo		*robj;
501
	void				*ptr;
519
	void				*ptr;
502
    unsigned            num_gpu_pages;
520
    unsigned            num_gpu_pages;
503
    unsigned            num_cpu_pages;
521
    unsigned            num_cpu_pages;
504
    unsigned            table_size;
522
    unsigned            table_size;
505
    struct page         **pages;
523
    struct page         **pages;
506
    dma_addr_t          *pages_addr;
524
    dma_addr_t          *pages_addr;
507
    bool                ready;
525
    bool                ready;
508
};
526
};
509
 
527
 
510
int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
528
int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
511
void radeon_gart_table_ram_free(struct radeon_device *rdev);
529
void radeon_gart_table_ram_free(struct radeon_device *rdev);
512
int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
530
int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
513
void radeon_gart_table_vram_free(struct radeon_device *rdev);
531
void radeon_gart_table_vram_free(struct radeon_device *rdev);
514
int radeon_gart_table_vram_pin(struct radeon_device *rdev);
532
int radeon_gart_table_vram_pin(struct radeon_device *rdev);
515
void radeon_gart_table_vram_unpin(struct radeon_device *rdev);
533
void radeon_gart_table_vram_unpin(struct radeon_device *rdev);
516
int radeon_gart_init(struct radeon_device *rdev);
534
int radeon_gart_init(struct radeon_device *rdev);
517
void radeon_gart_fini(struct radeon_device *rdev);
535
void radeon_gart_fini(struct radeon_device *rdev);
518
void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
536
void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
519
			int pages);
537
			int pages);
520
int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
538
int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
521
             int pages, u32 *pagelist,
539
             int pages, u32 *pagelist,
522
		     dma_addr_t *dma_addr);
540
		     dma_addr_t *dma_addr);
523
void radeon_gart_restore(struct radeon_device *rdev);
541
void radeon_gart_restore(struct radeon_device *rdev);
524
 
542
 
525
 
543
 
526
/*
544
/*
527
 * GPU MC structures, functions & helpers
545
 * GPU MC structures, functions & helpers
528
 */
546
 */
529
struct radeon_mc {
547
struct radeon_mc {
530
    resource_size_t     aper_size;
548
    resource_size_t     aper_size;
531
    resource_size_t     aper_base;
549
    resource_size_t     aper_base;
532
    resource_size_t     agp_base;
550
    resource_size_t     agp_base;
533
	/* for some chips with <= 32MB we need to lie
551
	/* for some chips with <= 32MB we need to lie
534
	 * about vram size near mc fb location */
552
	 * about vram size near mc fb location */
535
	u64			mc_vram_size;
553
	u64			mc_vram_size;
536
	u64			visible_vram_size;
554
	u64			visible_vram_size;
537
	u64			gtt_size;
555
	u64			gtt_size;
538
	u64			gtt_start;
556
	u64			gtt_start;
539
	u64			gtt_end;
557
	u64			gtt_end;
540
	u64			vram_start;
558
	u64			vram_start;
541
	u64			vram_end;
559
	u64			vram_end;
542
    unsigned            vram_width;
560
    unsigned            vram_width;
543
	u64			real_vram_size;
561
	u64			real_vram_size;
544
    int                 vram_mtrr;
562
    int                 vram_mtrr;
545
    bool                vram_is_ddr;
563
    bool                vram_is_ddr;
546
	bool                    igp_sideport_enabled;
564
	bool                    igp_sideport_enabled;
547
	u64                     gtt_base_align;
565
	u64                     gtt_base_align;
-
 
566
	u64                     mc_mask;
548
};
567
};
549
 
568
 
550
bool radeon_combios_sideport_present(struct radeon_device *rdev);
569
bool radeon_combios_sideport_present(struct radeon_device *rdev);
551
bool radeon_atombios_sideport_present(struct radeon_device *rdev);
570
bool radeon_atombios_sideport_present(struct radeon_device *rdev);
552
 
571
 
553
/*
572
/*
554
 * GPU scratch registers structures, functions & helpers
573
 * GPU scratch registers structures, functions & helpers
555
 */
574
 */
556
struct radeon_scratch {
575
struct radeon_scratch {
557
    unsigned        num_reg;
576
    unsigned        num_reg;
558
	uint32_t                reg_base;
577
	uint32_t                reg_base;
559
    bool            free[32];
578
    bool            free[32];
560
    uint32_t        reg[32];
579
    uint32_t        reg[32];
561
};
580
};
562
 
581
 
563
int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
582
int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
564
void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
583
void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
565
 
584
 
566
 
585
 
567
/*
586
/*
568
 * IRQS.
587
 * IRQS.
569
 */
588
 */
570
struct r500_irq_stat_regs {
589
struct r500_irq_stat_regs {
571
	u32 disp_int;
590
	u32 disp_int;
572
	u32 hdmi0_status;
591
	u32 hdmi0_status;
573
};
592
};
574
 
593
 
575
struct r600_irq_stat_regs {
594
struct r600_irq_stat_regs {
576
	u32 disp_int;
595
	u32 disp_int;
577
	u32 disp_int_cont;
596
	u32 disp_int_cont;
578
	u32 disp_int_cont2;
597
	u32 disp_int_cont2;
579
	u32 d1grph_int;
598
	u32 d1grph_int;
580
	u32 d2grph_int;
599
	u32 d2grph_int;
581
	u32 hdmi0_status;
600
	u32 hdmi0_status;
582
	u32 hdmi1_status;
601
	u32 hdmi1_status;
583
};
602
};
584
 
603
 
585
struct evergreen_irq_stat_regs {
604
struct evergreen_irq_stat_regs {
586
	u32 disp_int;
605
	u32 disp_int;
587
	u32 disp_int_cont;
606
	u32 disp_int_cont;
588
	u32 disp_int_cont2;
607
	u32 disp_int_cont2;
589
	u32 disp_int_cont3;
608
	u32 disp_int_cont3;
590
	u32 disp_int_cont4;
609
	u32 disp_int_cont4;
591
	u32 disp_int_cont5;
610
	u32 disp_int_cont5;
592
	u32 d1grph_int;
611
	u32 d1grph_int;
593
	u32 d2grph_int;
612
	u32 d2grph_int;
594
	u32 d3grph_int;
613
	u32 d3grph_int;
595
	u32 d4grph_int;
614
	u32 d4grph_int;
596
	u32 d5grph_int;
615
	u32 d5grph_int;
597
	u32 d6grph_int;
616
	u32 d6grph_int;
598
	u32 afmt_status1;
617
	u32 afmt_status1;
599
	u32 afmt_status2;
618
	u32 afmt_status2;
600
	u32 afmt_status3;
619
	u32 afmt_status3;
601
	u32 afmt_status4;
620
	u32 afmt_status4;
602
	u32 afmt_status5;
621
	u32 afmt_status5;
603
	u32 afmt_status6;
622
	u32 afmt_status6;
604
};
623
};
605
 
624
 
606
union radeon_irq_stat_regs {
625
union radeon_irq_stat_regs {
607
	struct r500_irq_stat_regs r500;
626
	struct r500_irq_stat_regs r500;
608
	struct r600_irq_stat_regs r600;
627
	struct r600_irq_stat_regs r600;
609
	struct evergreen_irq_stat_regs evergreen;
628
	struct evergreen_irq_stat_regs evergreen;
610
};
629
};
611
 
630
 
612
#define RADEON_MAX_HPD_PINS 6
631
#define RADEON_MAX_HPD_PINS 6
613
#define RADEON_MAX_CRTCS 6
632
#define RADEON_MAX_CRTCS 6
614
#define RADEON_MAX_AFMT_BLOCKS 6
633
#define RADEON_MAX_AFMT_BLOCKS 6
615
 
634
 
616
struct radeon_irq {
635
struct radeon_irq {
617
	bool		installed;
636
	bool		installed;
618
	spinlock_t			lock;
637
	spinlock_t			lock;
619
	atomic_t			ring_int[RADEON_NUM_RINGS];
638
	atomic_t			ring_int[RADEON_NUM_RINGS];
620
	bool				crtc_vblank_int[RADEON_MAX_CRTCS];
639
	bool				crtc_vblank_int[RADEON_MAX_CRTCS];
621
	atomic_t			pflip[RADEON_MAX_CRTCS];
640
	atomic_t			pflip[RADEON_MAX_CRTCS];
622
    wait_queue_head_t   vblank_queue;
641
    wait_queue_head_t   vblank_queue;
623
	bool				hpd[RADEON_MAX_HPD_PINS];
642
	bool				hpd[RADEON_MAX_HPD_PINS];
624
	bool				afmt[RADEON_MAX_AFMT_BLOCKS];
643
	bool				afmt[RADEON_MAX_AFMT_BLOCKS];
625
	union radeon_irq_stat_regs stat_regs;
644
	union radeon_irq_stat_regs stat_regs;
626
};
645
};
627
 
646
 
628
int radeon_irq_kms_init(struct radeon_device *rdev);
647
int radeon_irq_kms_init(struct radeon_device *rdev);
629
void radeon_irq_kms_fini(struct radeon_device *rdev);
648
void radeon_irq_kms_fini(struct radeon_device *rdev);
630
void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring);
649
void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring);
631
void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring);
650
void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring);
632
void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc);
651
void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc);
633
void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
652
void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
634
void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block);
653
void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block);
635
void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block);
654
void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block);
636
void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask);
655
void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask);
637
void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask);
656
void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask);
638
 
657
 
639
/*
658
/*
640
 * CP & rings.
659
 * CP & rings.
641
 */
660
 */
642
 
661
 
643
struct radeon_ib {
662
struct radeon_ib {
644
	struct radeon_sa_bo		*sa_bo;
663
	struct radeon_sa_bo		*sa_bo;
645
	uint32_t		length_dw;
664
	uint32_t		length_dw;
646
    uint64_t            gpu_addr;
665
    uint64_t            gpu_addr;
647
	uint32_t		*ptr;
666
	uint32_t		*ptr;
648
	int				ring;
667
	int				ring;
649
	struct radeon_fence	*fence;
668
	struct radeon_fence	*fence;
650
	struct radeon_vm		*vm;
669
	struct radeon_vm		*vm;
651
	bool			is_const_ib;
670
	bool			is_const_ib;
652
	struct radeon_fence		*sync_to[RADEON_NUM_RINGS];
671
	struct radeon_fence		*sync_to[RADEON_NUM_RINGS];
653
	struct radeon_semaphore		*semaphore;
672
	struct radeon_semaphore		*semaphore;
654
};
673
};
655
 
674
 
656
struct radeon_ring {
675
struct radeon_ring {
657
	struct radeon_bo	*ring_obj;
676
	struct radeon_bo	*ring_obj;
658
	volatile uint32_t	*ring;
677
	volatile uint32_t	*ring;
659
    unsigned            rptr;
678
    unsigned            rptr;
660
	unsigned		rptr_offs;
679
	unsigned		rptr_offs;
661
	unsigned		rptr_reg;
680
	unsigned		rptr_reg;
662
	unsigned		rptr_save_reg;
681
	unsigned		rptr_save_reg;
663
	u64			next_rptr_gpu_addr;
682
	u64			next_rptr_gpu_addr;
664
	volatile u32		*next_rptr_cpu_addr;
683
	volatile u32		*next_rptr_cpu_addr;
665
    unsigned            wptr;
684
    unsigned            wptr;
666
    unsigned            wptr_old;
685
    unsigned            wptr_old;
667
	unsigned		wptr_reg;
686
	unsigned		wptr_reg;
668
    unsigned            ring_size;
687
    unsigned            ring_size;
669
    unsigned            ring_free_dw;
688
    unsigned            ring_free_dw;
670
    int                 count_dw;
689
    int                 count_dw;
671
	unsigned long		last_activity;
690
	unsigned long		last_activity;
672
	unsigned		last_rptr;
691
	unsigned		last_rptr;
673
    uint64_t            gpu_addr;
692
    uint64_t            gpu_addr;
674
    uint32_t            align_mask;
693
    uint32_t            align_mask;
675
    uint32_t            ptr_mask;
694
    uint32_t            ptr_mask;
676
    bool                ready;
695
    bool                ready;
677
	u32			ptr_reg_shift;
696
	u32			ptr_reg_shift;
678
	u32			ptr_reg_mask;
697
	u32			ptr_reg_mask;
679
	u32			nop;
698
	u32			nop;
680
	u32			idx;
699
	u32			idx;
-
 
700
	u64			last_semaphore_signal_addr;
-
 
701
	u64			last_semaphore_wait_addr;
681
};
702
};
682
 
703
 
683
/*
704
/*
684
 * VM
705
 * VM
685
 */
706
 */
686
 
707
 
687
/* maximum number of VMIDs */
708
/* maximum number of VMIDs */
688
#define RADEON_NUM_VM	16
709
#define RADEON_NUM_VM	16
689
 
710
 
690
/* defines number of bits in page table versus page directory,
711
/* defines number of bits in page table versus page directory,
691
 * a page is 4KB so we have 12 bits offset, 9 bits in the page
712
 * a page is 4KB so we have 12 bits offset, 9 bits in the page
692
 * table and the remaining 19 bits are in the page directory */
713
 * table and the remaining 19 bits are in the page directory */
693
#define RADEON_VM_BLOCK_SIZE   9
714
#define RADEON_VM_BLOCK_SIZE   9
694
 
715
 
695
/* number of entries in page table */
716
/* number of entries in page table */
696
#define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
717
#define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
697
 
718
 
698
struct radeon_vm {
719
struct radeon_vm {
699
	struct list_head		list;
720
	struct list_head		list;
700
	struct list_head		va;
721
	struct list_head		va;
701
	unsigned			id;
722
	unsigned			id;
702
 
723
 
703
	/* contains the page directory */
724
	/* contains the page directory */
704
	struct radeon_sa_bo		*page_directory;
725
	struct radeon_sa_bo		*page_directory;
705
	uint64_t			pd_gpu_addr;
726
	uint64_t			pd_gpu_addr;
706
 
727
 
707
	/* array of page tables, one for each page directory entry */
728
	/* array of page tables, one for each page directory entry */
708
	struct radeon_sa_bo		**page_tables;
729
	struct radeon_sa_bo		**page_tables;
709
 
730
 
710
	struct mutex			mutex;
731
	struct mutex			mutex;
711
	/* last fence for cs using this vm */
732
	/* last fence for cs using this vm */
712
	struct radeon_fence		*fence;
733
	struct radeon_fence		*fence;
713
	/* last flush or NULL if we still need to flush */
734
	/* last flush or NULL if we still need to flush */
714
	struct radeon_fence		*last_flush;
735
	struct radeon_fence		*last_flush;
715
};
736
};
716
 
737
 
717
struct radeon_vm_manager {
738
struct radeon_vm_manager {
718
	struct mutex			lock;
739
	struct mutex			lock;
719
	struct list_head		lru_vm;
740
	struct list_head		lru_vm;
720
	struct radeon_fence		*active[RADEON_NUM_VM];
741
	struct radeon_fence		*active[RADEON_NUM_VM];
721
	struct radeon_sa_manager	sa_manager;
742
	struct radeon_sa_manager	sa_manager;
722
	uint32_t			max_pfn;
743
	uint32_t			max_pfn;
723
	/* number of VMIDs */
744
	/* number of VMIDs */
724
	unsigned			nvm;
745
	unsigned			nvm;
725
	/* vram base address for page table entry  */
746
	/* vram base address for page table entry  */
726
	u64				vram_base_offset;
747
	u64				vram_base_offset;
727
	/* is vm enabled? */
748
	/* is vm enabled? */
728
	bool				enabled;
749
	bool				enabled;
729
};
750
};
730
 
751
 
731
/*
752
/*
732
 * file private structure
753
 * file private structure
733
 */
754
 */
734
struct radeon_fpriv {
755
struct radeon_fpriv {
735
	struct radeon_vm		vm;
756
	struct radeon_vm		vm;
736
};
757
};
737
 
758
 
738
/*
759
/*
739
 * R6xx+ IH ring
760
 * R6xx+ IH ring
740
 */
761
 */
741
struct r600_ih {
762
struct r600_ih {
742
	struct radeon_bo	*ring_obj;
763
	struct radeon_bo	*ring_obj;
743
	volatile uint32_t	*ring;
764
	volatile uint32_t	*ring;
744
    unsigned            rptr;
765
    unsigned            rptr;
745
    unsigned            ring_size;
766
    unsigned            ring_size;
746
    uint64_t            gpu_addr;
767
    uint64_t            gpu_addr;
747
    uint32_t            ptr_mask;
768
    uint32_t            ptr_mask;
748
	atomic_t		lock;
769
	atomic_t		lock;
749
    bool                enabled;
770
    bool                enabled;
750
};
771
};
751
 
772
 
752
struct r600_blit_cp_primitives {
773
struct r600_blit_cp_primitives {
753
	void (*set_render_target)(struct radeon_device *rdev, int format,
774
	void (*set_render_target)(struct radeon_device *rdev, int format,
754
				  int w, int h, u64 gpu_addr);
775
				  int w, int h, u64 gpu_addr);
755
	void (*cp_set_surface_sync)(struct radeon_device *rdev,
776
	void (*cp_set_surface_sync)(struct radeon_device *rdev,
756
				    u32 sync_type, u32 size,
777
				    u32 sync_type, u32 size,
757
				    u64 mc_addr);
778
				    u64 mc_addr);
758
	void (*set_shaders)(struct radeon_device *rdev);
779
	void (*set_shaders)(struct radeon_device *rdev);
759
	void (*set_vtx_resource)(struct radeon_device *rdev, u64 gpu_addr);
780
	void (*set_vtx_resource)(struct radeon_device *rdev, u64 gpu_addr);
760
	void (*set_tex_resource)(struct radeon_device *rdev,
781
	void (*set_tex_resource)(struct radeon_device *rdev,
761
				 int format, int w, int h, int pitch,
782
				 int format, int w, int h, int pitch,
762
				 u64 gpu_addr, u32 size);
783
				 u64 gpu_addr, u32 size);
763
	void (*set_scissors)(struct radeon_device *rdev, int x1, int y1,
784
	void (*set_scissors)(struct radeon_device *rdev, int x1, int y1,
764
			     int x2, int y2);
785
			     int x2, int y2);
765
	void (*draw_auto)(struct radeon_device *rdev);
786
	void (*draw_auto)(struct radeon_device *rdev);
766
	void (*set_default_state)(struct radeon_device *rdev);
787
	void (*set_default_state)(struct radeon_device *rdev);
767
};
788
};
768
 
789
 
769
struct r600_blit {
790
struct r600_blit {
770
	struct radeon_bo	*shader_obj;
791
	struct radeon_bo	*shader_obj;
771
	struct r600_blit_cp_primitives primitives;
792
	struct r600_blit_cp_primitives primitives;
772
	int max_dim;
793
	int max_dim;
773
	int ring_size_common;
794
	int ring_size_common;
774
	int ring_size_per_loop;
795
	int ring_size_per_loop;
775
	u64 shader_gpu_addr;
796
	u64 shader_gpu_addr;
776
	u32 vs_offset, ps_offset;
797
	u32 vs_offset, ps_offset;
777
	u32 state_offset;
798
	u32 state_offset;
778
	u32 state_len;
799
	u32 state_len;
779
};
800
};
780
 
801
 
781
/*
802
/*
782
 * SI RLC stuff
803
 * SI RLC stuff
783
 */
804
 */
784
struct si_rlc {
805
struct si_rlc {
785
	/* for power gating */
806
	/* for power gating */
786
	struct radeon_bo	*save_restore_obj;
807
	struct radeon_bo	*save_restore_obj;
787
	uint64_t		save_restore_gpu_addr;
808
	uint64_t		save_restore_gpu_addr;
788
	/* for clear state */
809
	/* for clear state */
789
	struct radeon_bo	*clear_state_obj;
810
	struct radeon_bo	*clear_state_obj;
790
	uint64_t		clear_state_gpu_addr;
811
	uint64_t		clear_state_gpu_addr;
791
};
812
};
792
 
813
 
793
int radeon_ib_get(struct radeon_device *rdev, int ring,
814
int radeon_ib_get(struct radeon_device *rdev, int ring,
794
		  struct radeon_ib *ib, struct radeon_vm *vm,
815
		  struct radeon_ib *ib, struct radeon_vm *vm,
795
		  unsigned size);
816
		  unsigned size);
796
void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib);
817
void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib);
-
 
818
void radeon_ib_sync_to(struct radeon_ib *ib, struct radeon_fence *fence);
797
int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
819
int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
798
		       struct radeon_ib *const_ib);
820
		       struct radeon_ib *const_ib);
799
int radeon_ib_pool_init(struct radeon_device *rdev);
821
int radeon_ib_pool_init(struct radeon_device *rdev);
800
void radeon_ib_pool_fini(struct radeon_device *rdev);
822
void radeon_ib_pool_fini(struct radeon_device *rdev);
801
int radeon_ib_ring_tests(struct radeon_device *rdev);
823
int radeon_ib_ring_tests(struct radeon_device *rdev);
802
/* Ring access between begin & end cannot sleep */
824
/* Ring access between begin & end cannot sleep */
803
bool radeon_ring_supports_scratch_reg(struct radeon_device *rdev,
825
bool radeon_ring_supports_scratch_reg(struct radeon_device *rdev,
804
				      struct radeon_ring *ring);
826
				      struct radeon_ring *ring);
805
void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
827
void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
806
int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
828
int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
807
int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
829
int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
808
void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *cp);
830
void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *cp);
809
void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *cp);
831
void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *cp);
810
void radeon_ring_undo(struct radeon_ring *ring);
832
void radeon_ring_undo(struct radeon_ring *ring);
811
void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *cp);
833
void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *cp);
812
int radeon_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
834
int radeon_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
813
void radeon_ring_force_activity(struct radeon_device *rdev, struct radeon_ring *ring);
835
void radeon_ring_force_activity(struct radeon_device *rdev, struct radeon_ring *ring);
814
void radeon_ring_lockup_update(struct radeon_ring *ring);
836
void radeon_ring_lockup_update(struct radeon_ring *ring);
815
bool radeon_ring_test_lockup(struct radeon_device *rdev, struct radeon_ring *ring);
837
bool radeon_ring_test_lockup(struct radeon_device *rdev, struct radeon_ring *ring);
816
unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring,
838
unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring,
817
			    uint32_t **data);
839
			    uint32_t **data);
818
int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
840
int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
819
			unsigned size, uint32_t *data);
841
			unsigned size, uint32_t *data);
820
int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ring_size,
842
int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ring_size,
821
		     unsigned rptr_offs, unsigned rptr_reg, unsigned wptr_reg,
843
		     unsigned rptr_offs, unsigned rptr_reg, unsigned wptr_reg,
822
		     u32 ptr_reg_shift, u32 ptr_reg_mask, u32 nop);
844
		     u32 ptr_reg_shift, u32 ptr_reg_mask, u32 nop);
823
void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *cp);
845
void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *cp);
824
 
846
 
825
 
847
 
826
/* r600 async dma */
848
/* r600 async dma */
827
void r600_dma_stop(struct radeon_device *rdev);
849
void r600_dma_stop(struct radeon_device *rdev);
828
int r600_dma_resume(struct radeon_device *rdev);
850
int r600_dma_resume(struct radeon_device *rdev);
829
void r600_dma_fini(struct radeon_device *rdev);
851
void r600_dma_fini(struct radeon_device *rdev);
830
 
852
 
831
void cayman_dma_stop(struct radeon_device *rdev);
853
void cayman_dma_stop(struct radeon_device *rdev);
832
int cayman_dma_resume(struct radeon_device *rdev);
854
int cayman_dma_resume(struct radeon_device *rdev);
833
void cayman_dma_fini(struct radeon_device *rdev);
855
void cayman_dma_fini(struct radeon_device *rdev);
834
 
856
 
835
/*
857
/*
836
 * CS.
858
 * CS.
837
 */
859
 */
838
struct radeon_cs_reloc {
860
struct radeon_cs_reloc {
839
//	struct drm_gem_object		*gobj;
861
//	struct drm_gem_object		*gobj;
840
	struct radeon_bo		*robj;
862
	struct radeon_bo		*robj;
841
	struct radeon_bo_list		lobj;
863
	struct radeon_bo_list		lobj;
842
    uint32_t                handle;
864
    uint32_t                handle;
843
    uint32_t                flags;
865
    uint32_t                flags;
844
};
866
};
845
 
867
 
846
struct radeon_cs_chunk {
868
struct radeon_cs_chunk {
847
	uint32_t		chunk_id;
869
	uint32_t		chunk_id;
848
	uint32_t		length_dw;
870
	uint32_t		length_dw;
849
	int kpage_idx[2];
871
	int kpage_idx[2];
850
	uint32_t                *kpage[2];
872
	uint32_t                *kpage[2];
851
	uint32_t		*kdata;
873
	uint32_t		*kdata;
852
	void __user *user_ptr;
874
	void __user *user_ptr;
853
	int last_copied_page;
875
	int last_copied_page;
854
	int last_page_index;
876
	int last_page_index;
855
};
877
};
856
 
878
 
857
struct radeon_cs_parser {
879
struct radeon_cs_parser {
858
	struct device		*dev;
880
	struct device		*dev;
859
	struct radeon_device	*rdev;
881
	struct radeon_device	*rdev;
860
	struct drm_file		*filp;
882
	struct drm_file		*filp;
861
	/* chunks */
883
	/* chunks */
862
	unsigned		nchunks;
884
	unsigned		nchunks;
863
	struct radeon_cs_chunk	*chunks;
885
	struct radeon_cs_chunk	*chunks;
864
	uint64_t		*chunks_array;
886
	uint64_t		*chunks_array;
865
	/* IB */
887
	/* IB */
866
	unsigned		idx;
888
	unsigned		idx;
867
	/* relocations */
889
	/* relocations */
868
	unsigned		nrelocs;
890
	unsigned		nrelocs;
869
	struct radeon_cs_reloc	*relocs;
891
	struct radeon_cs_reloc	*relocs;
870
	struct radeon_cs_reloc	**relocs_ptr;
892
	struct radeon_cs_reloc	**relocs_ptr;
871
	struct list_head	validated;
893
	struct list_head	validated;
872
	unsigned		dma_reloc_idx;
894
	unsigned		dma_reloc_idx;
873
	/* indices of various chunks */
895
	/* indices of various chunks */
874
	int			chunk_ib_idx;
896
	int			chunk_ib_idx;
875
	int			chunk_relocs_idx;
897
	int			chunk_relocs_idx;
876
	int			chunk_flags_idx;
898
	int			chunk_flags_idx;
877
	int			chunk_const_ib_idx;
899
	int			chunk_const_ib_idx;
878
	struct radeon_ib	ib;
900
	struct radeon_ib	ib;
879
	struct radeon_ib	const_ib;
901
	struct radeon_ib	const_ib;
880
	void			*track;
902
	void			*track;
881
	unsigned		family;
903
	unsigned		family;
882
	int parser_error;
904
	int parser_error;
883
	u32			cs_flags;
905
	u32			cs_flags;
884
	u32			ring;
906
	u32			ring;
885
	s32			priority;
907
	s32			priority;
886
};
908
};
887
 
909
 
888
extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
910
extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
889
extern u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx);
911
extern u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx);
890
 
912
 
891
struct radeon_cs_packet {
913
struct radeon_cs_packet {
892
	unsigned	idx;
914
	unsigned	idx;
893
	unsigned	type;
915
	unsigned	type;
894
	unsigned	reg;
916
	unsigned	reg;
895
	unsigned	opcode;
917
	unsigned	opcode;
896
	int		count;
918
	int		count;
897
	unsigned	one_reg_wr;
919
	unsigned	one_reg_wr;
898
};
920
};
899
 
921
 
900
typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
922
typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
901
				      struct radeon_cs_packet *pkt,
923
				      struct radeon_cs_packet *pkt,
902
				      unsigned idx, unsigned reg);
924
				      unsigned idx, unsigned reg);
903
typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
925
typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
904
				      struct radeon_cs_packet *pkt);
926
				      struct radeon_cs_packet *pkt);
905
 
927
 
906
 
928
 
907
/*
929
/*
908
 * AGP
930
 * AGP
909
 */
931
 */
910
int radeon_agp_init(struct radeon_device *rdev);
932
int radeon_agp_init(struct radeon_device *rdev);
911
void radeon_agp_resume(struct radeon_device *rdev);
933
void radeon_agp_resume(struct radeon_device *rdev);
912
void radeon_agp_suspend(struct radeon_device *rdev);
934
void radeon_agp_suspend(struct radeon_device *rdev);
913
void radeon_agp_fini(struct radeon_device *rdev);
935
void radeon_agp_fini(struct radeon_device *rdev);
914
 
936
 
915
 
937
 
916
/*
938
/*
917
 * Writeback
939
 * Writeback
918
 */
940
 */
919
struct radeon_wb {
941
struct radeon_wb {
920
	struct radeon_bo	*wb_obj;
942
	struct radeon_bo	*wb_obj;
921
	volatile uint32_t	*wb;
943
	volatile uint32_t	*wb;
922
	uint64_t		gpu_addr;
944
	uint64_t		gpu_addr;
923
	bool                    enabled;
945
	bool                    enabled;
924
	bool                    use_event;
946
	bool                    use_event;
925
};
947
};
926
 
948
 
927
#define RADEON_WB_SCRATCH_OFFSET 0
949
#define RADEON_WB_SCRATCH_OFFSET 0
928
#define RADEON_WB_RING0_NEXT_RPTR 256
950
#define RADEON_WB_RING0_NEXT_RPTR 256
929
#define RADEON_WB_CP_RPTR_OFFSET 1024
951
#define RADEON_WB_CP_RPTR_OFFSET 1024
930
#define RADEON_WB_CP1_RPTR_OFFSET 1280
952
#define RADEON_WB_CP1_RPTR_OFFSET 1280
931
#define RADEON_WB_CP2_RPTR_OFFSET 1536
953
#define RADEON_WB_CP2_RPTR_OFFSET 1536
932
#define R600_WB_DMA_RPTR_OFFSET   1792
954
#define R600_WB_DMA_RPTR_OFFSET   1792
933
#define R600_WB_IH_WPTR_OFFSET   2048
955
#define R600_WB_IH_WPTR_OFFSET   2048
934
#define CAYMAN_WB_DMA1_RPTR_OFFSET   2304
956
#define CAYMAN_WB_DMA1_RPTR_OFFSET   2304
-
 
957
#define R600_WB_UVD_RPTR_OFFSET  2560
935
#define R600_WB_EVENT_OFFSET     3072
958
#define R600_WB_EVENT_OFFSET     3072
936
 
959
 
937
/**
960
/**
938
 * struct radeon_pm - power management datas
961
 * struct radeon_pm - power management datas
939
 * @max_bandwidth:      maximum bandwidth the gpu has (MByte/s)
962
 * @max_bandwidth:      maximum bandwidth the gpu has (MByte/s)
940
 * @igp_sideport_mclk:  sideport memory clock Mhz (rs690,rs740,rs780,rs880)
963
 * @igp_sideport_mclk:  sideport memory clock Mhz (rs690,rs740,rs780,rs880)
941
 * @igp_system_mclk:    system clock Mhz (rs690,rs740,rs780,rs880)
964
 * @igp_system_mclk:    system clock Mhz (rs690,rs740,rs780,rs880)
942
 * @igp_ht_link_clk:    ht link clock Mhz (rs690,rs740,rs780,rs880)
965
 * @igp_ht_link_clk:    ht link clock Mhz (rs690,rs740,rs780,rs880)
943
 * @igp_ht_link_width:  ht link width in bits (rs690,rs740,rs780,rs880)
966
 * @igp_ht_link_width:  ht link width in bits (rs690,rs740,rs780,rs880)
944
 * @k8_bandwidth:       k8 bandwidth the gpu has (MByte/s) (IGP)
967
 * @k8_bandwidth:       k8 bandwidth the gpu has (MByte/s) (IGP)
945
 * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
968
 * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
946
 * @ht_bandwidth:       ht bandwidth the gpu has (MByte/s) (IGP)
969
 * @ht_bandwidth:       ht bandwidth the gpu has (MByte/s) (IGP)
947
 * @core_bandwidth:     core GPU bandwidth the gpu has (MByte/s) (IGP)
970
 * @core_bandwidth:     core GPU bandwidth the gpu has (MByte/s) (IGP)
948
 * @sclk:          	GPU clock Mhz (core bandwidth depends of this clock)
971
 * @sclk:          	GPU clock Mhz (core bandwidth depends of this clock)
949
 * @needed_bandwidth:   current bandwidth needs
972
 * @needed_bandwidth:   current bandwidth needs
950
 *
973
 *
951
 * It keeps track of various data needed to take powermanagement decision.
974
 * It keeps track of various data needed to take powermanagement decision.
952
 * Bandwidth need is used to determine minimun clock of the GPU and memory.
975
 * Bandwidth need is used to determine minimun clock of the GPU and memory.
953
 * Equation between gpu/memory clock and available bandwidth is hw dependent
976
 * Equation between gpu/memory clock and available bandwidth is hw dependent
954
 * (type of memory, bus size, efficiency, ...)
977
 * (type of memory, bus size, efficiency, ...)
955
 */
978
 */
956
 
979
 
957
enum radeon_pm_method {
980
enum radeon_pm_method {
958
	PM_METHOD_PROFILE,
981
	PM_METHOD_PROFILE,
959
	PM_METHOD_DYNPM,
982
	PM_METHOD_DYNPM,
960
};
983
};
961
 
984
 
962
enum radeon_dynpm_state {
985
enum radeon_dynpm_state {
963
	DYNPM_STATE_DISABLED,
986
	DYNPM_STATE_DISABLED,
964
	DYNPM_STATE_MINIMUM,
987
	DYNPM_STATE_MINIMUM,
965
	DYNPM_STATE_PAUSED,
988
	DYNPM_STATE_PAUSED,
966
	DYNPM_STATE_ACTIVE,
989
	DYNPM_STATE_ACTIVE,
967
	DYNPM_STATE_SUSPENDED,
990
	DYNPM_STATE_SUSPENDED,
968
};
991
};
969
enum radeon_dynpm_action {
992
enum radeon_dynpm_action {
970
	DYNPM_ACTION_NONE,
993
	DYNPM_ACTION_NONE,
971
	DYNPM_ACTION_MINIMUM,
994
	DYNPM_ACTION_MINIMUM,
972
	DYNPM_ACTION_DOWNCLOCK,
995
	DYNPM_ACTION_DOWNCLOCK,
973
	DYNPM_ACTION_UPCLOCK,
996
	DYNPM_ACTION_UPCLOCK,
974
	DYNPM_ACTION_DEFAULT
997
	DYNPM_ACTION_DEFAULT
975
};
998
};
976
 
999
 
977
enum radeon_voltage_type {
1000
enum radeon_voltage_type {
978
	VOLTAGE_NONE = 0,
1001
	VOLTAGE_NONE = 0,
979
	VOLTAGE_GPIO,
1002
	VOLTAGE_GPIO,
980
	VOLTAGE_VDDC,
1003
	VOLTAGE_VDDC,
981
	VOLTAGE_SW
1004
	VOLTAGE_SW
982
};
1005
};
983
 
1006
 
984
enum radeon_pm_state_type {
1007
enum radeon_pm_state_type {
985
	POWER_STATE_TYPE_DEFAULT,
1008
	POWER_STATE_TYPE_DEFAULT,
986
	POWER_STATE_TYPE_POWERSAVE,
1009
	POWER_STATE_TYPE_POWERSAVE,
987
	POWER_STATE_TYPE_BATTERY,
1010
	POWER_STATE_TYPE_BATTERY,
988
	POWER_STATE_TYPE_BALANCED,
1011
	POWER_STATE_TYPE_BALANCED,
989
	POWER_STATE_TYPE_PERFORMANCE,
1012
	POWER_STATE_TYPE_PERFORMANCE,
990
};
1013
};
991
 
1014
 
992
enum radeon_pm_profile_type {
1015
enum radeon_pm_profile_type {
993
	PM_PROFILE_DEFAULT,
1016
	PM_PROFILE_DEFAULT,
994
	PM_PROFILE_AUTO,
1017
	PM_PROFILE_AUTO,
995
	PM_PROFILE_LOW,
1018
	PM_PROFILE_LOW,
996
	PM_PROFILE_MID,
1019
	PM_PROFILE_MID,
997
	PM_PROFILE_HIGH,
1020
	PM_PROFILE_HIGH,
998
};
1021
};
999
 
1022
 
1000
#define PM_PROFILE_DEFAULT_IDX 0
1023
#define PM_PROFILE_DEFAULT_IDX 0
1001
#define PM_PROFILE_LOW_SH_IDX  1
1024
#define PM_PROFILE_LOW_SH_IDX  1
1002
#define PM_PROFILE_MID_SH_IDX  2
1025
#define PM_PROFILE_MID_SH_IDX  2
1003
#define PM_PROFILE_HIGH_SH_IDX 3
1026
#define PM_PROFILE_HIGH_SH_IDX 3
1004
#define PM_PROFILE_LOW_MH_IDX  4
1027
#define PM_PROFILE_LOW_MH_IDX  4
1005
#define PM_PROFILE_MID_MH_IDX  5
1028
#define PM_PROFILE_MID_MH_IDX  5
1006
#define PM_PROFILE_HIGH_MH_IDX 6
1029
#define PM_PROFILE_HIGH_MH_IDX 6
1007
#define PM_PROFILE_MAX         7
1030
#define PM_PROFILE_MAX         7
1008
 
1031
 
1009
struct radeon_pm_profile {
1032
struct radeon_pm_profile {
1010
	int dpms_off_ps_idx;
1033
	int dpms_off_ps_idx;
1011
	int dpms_on_ps_idx;
1034
	int dpms_on_ps_idx;
1012
	int dpms_off_cm_idx;
1035
	int dpms_off_cm_idx;
1013
	int dpms_on_cm_idx;
1036
	int dpms_on_cm_idx;
1014
};
1037
};
1015
 
1038
 
1016
enum radeon_int_thermal_type {
1039
enum radeon_int_thermal_type {
1017
	THERMAL_TYPE_NONE,
1040
	THERMAL_TYPE_NONE,
1018
	THERMAL_TYPE_RV6XX,
1041
	THERMAL_TYPE_RV6XX,
1019
	THERMAL_TYPE_RV770,
1042
	THERMAL_TYPE_RV770,
1020
	THERMAL_TYPE_EVERGREEN,
1043
	THERMAL_TYPE_EVERGREEN,
1021
	THERMAL_TYPE_SUMO,
1044
	THERMAL_TYPE_SUMO,
1022
	THERMAL_TYPE_NI,
1045
	THERMAL_TYPE_NI,
1023
	THERMAL_TYPE_SI,
1046
	THERMAL_TYPE_SI,
1024
};
1047
};
1025
 
1048
 
1026
struct radeon_voltage {
1049
struct radeon_voltage {
1027
	enum radeon_voltage_type type;
1050
	enum radeon_voltage_type type;
1028
	/* gpio voltage */
1051
	/* gpio voltage */
1029
	struct radeon_gpio_rec gpio;
1052
	struct radeon_gpio_rec gpio;
1030
	u32 delay; /* delay in usec from voltage drop to sclk change */
1053
	u32 delay; /* delay in usec from voltage drop to sclk change */
1031
	bool active_high; /* voltage drop is active when bit is high */
1054
	bool active_high; /* voltage drop is active when bit is high */
1032
	/* VDDC voltage */
1055
	/* VDDC voltage */
1033
	u8 vddc_id; /* index into vddc voltage table */
1056
	u8 vddc_id; /* index into vddc voltage table */
1034
	u8 vddci_id; /* index into vddci voltage table */
1057
	u8 vddci_id; /* index into vddci voltage table */
1035
	bool vddci_enabled;
1058
	bool vddci_enabled;
1036
	/* r6xx+ sw */
1059
	/* r6xx+ sw */
1037
	u16 voltage;
1060
	u16 voltage;
1038
	/* evergreen+ vddci */
1061
	/* evergreen+ vddci */
1039
	u16 vddci;
1062
	u16 vddci;
1040
};
1063
};
1041
 
1064
 
1042
/* clock mode flags */
1065
/* clock mode flags */
1043
#define RADEON_PM_MODE_NO_DISPLAY          (1 << 0)
1066
#define RADEON_PM_MODE_NO_DISPLAY          (1 << 0)
1044
 
1067
 
1045
struct radeon_pm_clock_info {
1068
struct radeon_pm_clock_info {
1046
	/* memory clock */
1069
	/* memory clock */
1047
	u32 mclk;
1070
	u32 mclk;
1048
	/* engine clock */
1071
	/* engine clock */
1049
	u32 sclk;
1072
	u32 sclk;
1050
	/* voltage info */
1073
	/* voltage info */
1051
	struct radeon_voltage voltage;
1074
	struct radeon_voltage voltage;
1052
	/* standardized clock flags */
1075
	/* standardized clock flags */
1053
	u32 flags;
1076
	u32 flags;
1054
};
1077
};
1055
 
1078
 
1056
/* state flags */
1079
/* state flags */
1057
#define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
1080
#define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
1058
 
1081
 
1059
struct radeon_power_state {
1082
struct radeon_power_state {
1060
	enum radeon_pm_state_type type;
1083
	enum radeon_pm_state_type type;
1061
	struct radeon_pm_clock_info *clock_info;
1084
	struct radeon_pm_clock_info *clock_info;
1062
	/* number of valid clock modes in this power state */
1085
	/* number of valid clock modes in this power state */
1063
	int num_clock_modes;
1086
	int num_clock_modes;
1064
	struct radeon_pm_clock_info *default_clock_mode;
1087
	struct radeon_pm_clock_info *default_clock_mode;
1065
	/* standardized state flags */
1088
	/* standardized state flags */
1066
	u32 flags;
1089
	u32 flags;
1067
	u32 misc; /* vbios specific flags */
1090
	u32 misc; /* vbios specific flags */
1068
	u32 misc2; /* vbios specific flags */
1091
	u32 misc2; /* vbios specific flags */
1069
	int pcie_lanes; /* pcie lanes */
1092
	int pcie_lanes; /* pcie lanes */
1070
};
1093
};
1071
 
1094
 
1072
/*
1095
/*
1073
 * Some modes are overclocked by very low value, accept them
1096
 * Some modes are overclocked by very low value, accept them
1074
 */
1097
 */
1075
#define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
1098
#define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
1076
 
1099
 
1077
struct radeon_pm {
1100
struct radeon_pm {
1078
	struct mutex		mutex;
1101
	struct mutex		mutex;
1079
	/* write locked while reprogramming mclk */
1102
	/* write locked while reprogramming mclk */
1080
	struct rw_semaphore	mclk_lock;
1103
	struct rw_semaphore	mclk_lock;
1081
	u32			active_crtcs;
1104
	u32			active_crtcs;
1082
	int			active_crtc_count;
1105
	int			active_crtc_count;
1083
	int			req_vblank;
1106
	int			req_vblank;
1084
	bool			vblank_sync;
1107
	bool			vblank_sync;
1085
	fixed20_12		max_bandwidth;
1108
	fixed20_12		max_bandwidth;
1086
	fixed20_12		igp_sideport_mclk;
1109
	fixed20_12		igp_sideport_mclk;
1087
	fixed20_12		igp_system_mclk;
1110
	fixed20_12		igp_system_mclk;
1088
	fixed20_12		igp_ht_link_clk;
1111
	fixed20_12		igp_ht_link_clk;
1089
	fixed20_12		igp_ht_link_width;
1112
	fixed20_12		igp_ht_link_width;
1090
	fixed20_12		k8_bandwidth;
1113
	fixed20_12		k8_bandwidth;
1091
	fixed20_12		sideport_bandwidth;
1114
	fixed20_12		sideport_bandwidth;
1092
	fixed20_12		ht_bandwidth;
1115
	fixed20_12		ht_bandwidth;
1093
	fixed20_12		core_bandwidth;
1116
	fixed20_12		core_bandwidth;
1094
	fixed20_12		sclk;
1117
	fixed20_12		sclk;
1095
	fixed20_12		mclk;
1118
	fixed20_12		mclk;
1096
	fixed20_12		needed_bandwidth;
1119
	fixed20_12		needed_bandwidth;
1097
	struct radeon_power_state *power_state;
1120
	struct radeon_power_state *power_state;
1098
	/* number of valid power states */
1121
	/* number of valid power states */
1099
	int                     num_power_states;
1122
	int                     num_power_states;
1100
	int                     current_power_state_index;
1123
	int                     current_power_state_index;
1101
	int                     current_clock_mode_index;
1124
	int                     current_clock_mode_index;
1102
	int                     requested_power_state_index;
1125
	int                     requested_power_state_index;
1103
	int                     requested_clock_mode_index;
1126
	int                     requested_clock_mode_index;
1104
	int                     default_power_state_index;
1127
	int                     default_power_state_index;
1105
	u32                     current_sclk;
1128
	u32                     current_sclk;
1106
	u32                     current_mclk;
1129
	u32                     current_mclk;
1107
	u16                     current_vddc;
1130
	u16                     current_vddc;
1108
	u16                     current_vddci;
1131
	u16                     current_vddci;
1109
	u32                     default_sclk;
1132
	u32                     default_sclk;
1110
	u32                     default_mclk;
1133
	u32                     default_mclk;
1111
	u16                     default_vddc;
1134
	u16                     default_vddc;
1112
	u16                     default_vddci;
1135
	u16                     default_vddci;
1113
	struct radeon_i2c_chan *i2c_bus;
1136
	struct radeon_i2c_chan *i2c_bus;
1114
	/* selected pm method */
1137
	/* selected pm method */
1115
	enum radeon_pm_method     pm_method;
1138
	enum radeon_pm_method     pm_method;
1116
	/* dynpm power management */
1139
	/* dynpm power management */
1117
//   struct delayed_work dynpm_idle_work;
1140
//   struct delayed_work dynpm_idle_work;
1118
	enum radeon_dynpm_state	dynpm_state;
1141
	enum radeon_dynpm_state	dynpm_state;
1119
	enum radeon_dynpm_action	dynpm_planned_action;
1142
	enum radeon_dynpm_action	dynpm_planned_action;
1120
	unsigned long		dynpm_action_timeout;
1143
	unsigned long		dynpm_action_timeout;
1121
	bool                    dynpm_can_upclock;
1144
	bool                    dynpm_can_upclock;
1122
	bool                    dynpm_can_downclock;
1145
	bool                    dynpm_can_downclock;
1123
	/* profile-based power management */
1146
	/* profile-based power management */
1124
	enum radeon_pm_profile_type profile;
1147
	enum radeon_pm_profile_type profile;
1125
	int                     profile_index;
1148
	int                     profile_index;
1126
	struct radeon_pm_profile profiles[PM_PROFILE_MAX];
1149
	struct radeon_pm_profile profiles[PM_PROFILE_MAX];
1127
	/* internal thermal controller on rv6xx+ */
1150
	/* internal thermal controller on rv6xx+ */
1128
	enum radeon_int_thermal_type int_thermal_type;
1151
	enum radeon_int_thermal_type int_thermal_type;
1129
	struct device	        *int_hwmon_dev;
1152
	struct device	        *int_hwmon_dev;
1130
};
1153
};
1131
 
1154
 
1132
int radeon_pm_get_type_index(struct radeon_device *rdev,
1155
int radeon_pm_get_type_index(struct radeon_device *rdev,
1133
			     enum radeon_pm_state_type ps_type,
1156
			     enum radeon_pm_state_type ps_type,
1134
			     int instance);
1157
			     int instance);
-
 
1158
/*
-
 
1159
 * UVD
-
 
1160
 */
-
 
1161
#define RADEON_MAX_UVD_HANDLES	10
-
 
1162
#define RADEON_UVD_STACK_SIZE	(1024*1024)
-
 
1163
#define RADEON_UVD_HEAP_SIZE	(1024*1024)
-
 
1164
 
-
 
1165
struct radeon_uvd {
-
 
1166
	struct radeon_bo	*vcpu_bo;
-
 
1167
	void			*cpu_addr;
-
 
1168
	uint64_t		gpu_addr;
-
 
1169
	atomic_t		handles[RADEON_MAX_UVD_HANDLES];
-
 
1170
	struct drm_file		*filp[RADEON_MAX_UVD_HANDLES];
-
 
1171
	struct delayed_work	idle_work;
-
 
1172
};
-
 
1173
 
-
 
1174
int radeon_uvd_init(struct radeon_device *rdev);
-
 
1175
void radeon_uvd_fini(struct radeon_device *rdev);
-
 
1176
int radeon_uvd_suspend(struct radeon_device *rdev);
-
 
1177
int radeon_uvd_resume(struct radeon_device *rdev);
-
 
1178
int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,
-
 
1179
			      uint32_t handle, struct radeon_fence **fence);
-
 
1180
int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,
-
 
1181
			       uint32_t handle, struct radeon_fence **fence);
-
 
1182
void radeon_uvd_force_into_uvd_segment(struct radeon_bo *rbo);
-
 
1183
void radeon_uvd_free_handles(struct radeon_device *rdev,
-
 
1184
			     struct drm_file *filp);
-
 
1185
int radeon_uvd_cs_parse(struct radeon_cs_parser *parser);
-
 
1186
void radeon_uvd_note_usage(struct radeon_device *rdev);
-
 
1187
int radeon_uvd_calc_upll_dividers(struct radeon_device *rdev,
-
 
1188
				  unsigned vclk, unsigned dclk,
-
 
1189
				  unsigned vco_min, unsigned vco_max,
-
 
1190
				  unsigned fb_factor, unsigned fb_mask,
-
 
1191
				  unsigned pd_min, unsigned pd_max,
-
 
1192
				  unsigned pd_even,
-
 
1193
				  unsigned *optimal_fb_div,
-
 
1194
				  unsigned *optimal_vclk_div,
-
 
1195
				  unsigned *optimal_dclk_div);
-
 
1196
int radeon_uvd_send_upll_ctlreq(struct radeon_device *rdev,
-
 
1197
                                unsigned cg_upll_func_cntl);
1135
 
1198
 
1136
struct r600_audio {
1199
struct r600_audio {
1137
	int			channels;
1200
	int			channels;
1138
	int			rate;
1201
	int			rate;
1139
	int			bits_per_sample;
1202
	int			bits_per_sample;
1140
	u8			status_bits;
1203
	u8			status_bits;
1141
	u8			category_code;
1204
	u8			category_code;
1142
};
1205
};
1143
/*
1206
/*
1144
 * ASIC specific functions.
1207
 * ASIC specific functions.
1145
 */
1208
 */
1146
struct radeon_asic {
1209
struct radeon_asic {
1147
	int (*init)(struct radeon_device *rdev);
1210
	int (*init)(struct radeon_device *rdev);
1148
	void (*fini)(struct radeon_device *rdev);
1211
	void (*fini)(struct radeon_device *rdev);
1149
	int (*resume)(struct radeon_device *rdev);
1212
	int (*resume)(struct radeon_device *rdev);
1150
	int (*suspend)(struct radeon_device *rdev);
1213
	int (*suspend)(struct radeon_device *rdev);
1151
	void (*vga_set_state)(struct radeon_device *rdev, bool state);
1214
	void (*vga_set_state)(struct radeon_device *rdev, bool state);
1152
	int (*asic_reset)(struct radeon_device *rdev);
1215
	int (*asic_reset)(struct radeon_device *rdev);
1153
	/* ioctl hw specific callback. Some hw might want to perform special
1216
	/* ioctl hw specific callback. Some hw might want to perform special
1154
	 * operation on specific ioctl. For instance on wait idle some hw
1217
	 * operation on specific ioctl. For instance on wait idle some hw
1155
	 * might want to perform and HDP flush through MMIO as it seems that
1218
	 * might want to perform and HDP flush through MMIO as it seems that
1156
	 * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
1219
	 * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
1157
	 * through ring.
1220
	 * through ring.
1158
	 */
1221
	 */
1159
	void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);
1222
	void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);
1160
	/* check if 3D engine is idle */
1223
	/* check if 3D engine is idle */
1161
	bool (*gui_idle)(struct radeon_device *rdev);
1224
	bool (*gui_idle)(struct radeon_device *rdev);
1162
	/* wait for mc_idle */
1225
	/* wait for mc_idle */
1163
	int (*mc_wait_for_idle)(struct radeon_device *rdev);
1226
	int (*mc_wait_for_idle)(struct radeon_device *rdev);
-
 
1227
	/* get the reference clock */
-
 
1228
	u32 (*get_xclk)(struct radeon_device *rdev);
-
 
1229
	/* get the gpu clock counter */
-
 
1230
	uint64_t (*get_gpu_clock_counter)(struct radeon_device *rdev);
1164
	/* gart */
1231
	/* gart */
1165
	struct {
1232
	struct {
1166
		void (*tlb_flush)(struct radeon_device *rdev);
1233
		void (*tlb_flush)(struct radeon_device *rdev);
1167
		int (*set_page)(struct radeon_device *rdev, int i, uint64_t addr);
1234
		int (*set_page)(struct radeon_device *rdev, int i, uint64_t addr);
1168
	} gart;
1235
	} gart;
1169
	struct {
1236
	struct {
1170
		int (*init)(struct radeon_device *rdev);
1237
		int (*init)(struct radeon_device *rdev);
1171
		void (*fini)(struct radeon_device *rdev);
1238
		void (*fini)(struct radeon_device *rdev);
1172
 
1239
 
1173
		u32 pt_ring_index;
1240
		u32 pt_ring_index;
1174
		void (*set_page)(struct radeon_device *rdev, uint64_t pe,
1241
		void (*set_page)(struct radeon_device *rdev,
-
 
1242
				 struct radeon_ib *ib,
-
 
1243
				 uint64_t pe,
1175
				 uint64_t addr, unsigned count,
1244
				 uint64_t addr, unsigned count,
1176
				 uint32_t incr, uint32_t flags);
1245
				 uint32_t incr, uint32_t flags);
1177
	} vm;
1246
	} vm;
1178
	/* ring specific callbacks */
1247
	/* ring specific callbacks */
1179
	struct {
1248
	struct {
1180
		void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
1249
		void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
1181
		int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib *ib);
1250
		int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib *ib);
1182
		void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence);
1251
		void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence);
1183
		void (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp,
1252
		void (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp,
1184
				       struct radeon_semaphore *semaphore, bool emit_wait);
1253
				       struct radeon_semaphore *semaphore, bool emit_wait);
1185
		int (*cs_parse)(struct radeon_cs_parser *p);
1254
		int (*cs_parse)(struct radeon_cs_parser *p);
1186
		void (*ring_start)(struct radeon_device *rdev, struct radeon_ring *cp);
1255
		void (*ring_start)(struct radeon_device *rdev, struct radeon_ring *cp);
1187
		int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
1256
		int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
1188
		int (*ib_test)(struct radeon_device *rdev, struct radeon_ring *cp);
1257
		int (*ib_test)(struct radeon_device *rdev, struct radeon_ring *cp);
1189
		bool (*is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
1258
		bool (*is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
1190
		void (*vm_flush)(struct radeon_device *rdev, int ridx, struct radeon_vm *vm);
1259
		void (*vm_flush)(struct radeon_device *rdev, int ridx, struct radeon_vm *vm);
1191
	} ring[RADEON_NUM_RINGS];
1260
	} ring[RADEON_NUM_RINGS];
1192
	/* irqs */
1261
	/* irqs */
1193
	struct {
1262
	struct {
1194
		int (*set)(struct radeon_device *rdev);
1263
		int (*set)(struct radeon_device *rdev);
1195
		int (*process)(struct radeon_device *rdev);
1264
		int (*process)(struct radeon_device *rdev);
1196
	} irq;
1265
	} irq;
1197
	/* displays */
1266
	/* displays */
1198
	struct {
1267
	struct {
1199
		/* display watermarks */
1268
		/* display watermarks */
1200
		void (*bandwidth_update)(struct radeon_device *rdev);
1269
		void (*bandwidth_update)(struct radeon_device *rdev);
1201
		/* get frame count */
1270
		/* get frame count */
1202
	u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
1271
	u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
1203
		/* wait for vblank */
1272
		/* wait for vblank */
1204
		void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
1273
		void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
1205
		/* set backlight level */
1274
		/* set backlight level */
1206
		void (*set_backlight_level)(struct radeon_encoder *radeon_encoder, u8 level);
1275
		void (*set_backlight_level)(struct radeon_encoder *radeon_encoder, u8 level);
1207
		/* get backlight level */
1276
		/* get backlight level */
1208
		u8 (*get_backlight_level)(struct radeon_encoder *radeon_encoder);
1277
		u8 (*get_backlight_level)(struct radeon_encoder *radeon_encoder);
-
 
1278
		/* audio callbacks */
-
 
1279
		void (*hdmi_enable)(struct drm_encoder *encoder, bool enable);
-
 
1280
		void (*hdmi_setmode)(struct drm_encoder *encoder, struct drm_display_mode *mode);
1209
	} display;
1281
	} display;
1210
	/* copy functions for bo handling */
1282
	/* copy functions for bo handling */
1211
	struct {
1283
	struct {
1212
		int (*blit)(struct radeon_device *rdev,
1284
		int (*blit)(struct radeon_device *rdev,
1213
			 uint64_t src_offset,
1285
			 uint64_t src_offset,
1214
			 uint64_t dst_offset,
1286
			 uint64_t dst_offset,
1215
			 unsigned num_gpu_pages,
1287
			 unsigned num_gpu_pages,
1216
			    struct radeon_fence **fence);
1288
			    struct radeon_fence **fence);
1217
		u32 blit_ring_index;
1289
		u32 blit_ring_index;
1218
		int (*dma)(struct radeon_device *rdev,
1290
		int (*dma)(struct radeon_device *rdev,
1219
			uint64_t src_offset,
1291
			uint64_t src_offset,
1220
			uint64_t dst_offset,
1292
			uint64_t dst_offset,
1221
			unsigned num_gpu_pages,
1293
			unsigned num_gpu_pages,
1222
			   struct radeon_fence **fence);
1294
			   struct radeon_fence **fence);
1223
		u32 dma_ring_index;
1295
		u32 dma_ring_index;
1224
		/* method used for bo copy */
1296
		/* method used for bo copy */
1225
	int (*copy)(struct radeon_device *rdev,
1297
	int (*copy)(struct radeon_device *rdev,
1226
		    uint64_t src_offset,
1298
		    uint64_t src_offset,
1227
		    uint64_t dst_offset,
1299
		    uint64_t dst_offset,
1228
		    unsigned num_gpu_pages,
1300
		    unsigned num_gpu_pages,
1229
			    struct radeon_fence **fence);
1301
			    struct radeon_fence **fence);
1230
		/* ring used for bo copies */
1302
		/* ring used for bo copies */
1231
		u32 copy_ring_index;
1303
		u32 copy_ring_index;
1232
	} copy;
1304
	} copy;
1233
	/* surfaces */
1305
	/* surfaces */
1234
	struct {
1306
	struct {
1235
		int (*set_reg)(struct radeon_device *rdev, int reg,
1307
		int (*set_reg)(struct radeon_device *rdev, int reg,
1236
				       uint32_t tiling_flags, uint32_t pitch,
1308
				       uint32_t tiling_flags, uint32_t pitch,
1237
				       uint32_t offset, uint32_t obj_size);
1309
				       uint32_t offset, uint32_t obj_size);
1238
		void (*clear_reg)(struct radeon_device *rdev, int reg);
1310
		void (*clear_reg)(struct radeon_device *rdev, int reg);
1239
	} surface;
1311
	} surface;
1240
	/* hotplug detect */
1312
	/* hotplug detect */
1241
	struct {
1313
	struct {
1242
		void (*init)(struct radeon_device *rdev);
1314
		void (*init)(struct radeon_device *rdev);
1243
		void (*fini)(struct radeon_device *rdev);
1315
		void (*fini)(struct radeon_device *rdev);
1244
		bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
1316
		bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
1245
		void (*set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
1317
		void (*set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
1246
	} hpd;
1318
	} hpd;
1247
	/* power management */
1319
	/* power management */
1248
	struct {
1320
	struct {
1249
		void (*misc)(struct radeon_device *rdev);
1321
		void (*misc)(struct radeon_device *rdev);
1250
		void (*prepare)(struct radeon_device *rdev);
1322
		void (*prepare)(struct radeon_device *rdev);
1251
		void (*finish)(struct radeon_device *rdev);
1323
		void (*finish)(struct radeon_device *rdev);
1252
		void (*init_profile)(struct radeon_device *rdev);
1324
		void (*init_profile)(struct radeon_device *rdev);
1253
		void (*get_dynpm_state)(struct radeon_device *rdev);
1325
		void (*get_dynpm_state)(struct radeon_device *rdev);
1254
	uint32_t (*get_engine_clock)(struct radeon_device *rdev);
1326
	uint32_t (*get_engine_clock)(struct radeon_device *rdev);
1255
	void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
1327
	void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
1256
	uint32_t (*get_memory_clock)(struct radeon_device *rdev);
1328
	uint32_t (*get_memory_clock)(struct radeon_device *rdev);
1257
	void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
1329
	void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
1258
	int (*get_pcie_lanes)(struct radeon_device *rdev);
1330
	int (*get_pcie_lanes)(struct radeon_device *rdev);
1259
	void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
1331
	void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
1260
	void (*set_clock_gating)(struct radeon_device *rdev, int enable);
1332
	void (*set_clock_gating)(struct radeon_device *rdev, int enable);
-
 
1333
		int (*set_uvd_clocks)(struct radeon_device *rdev, u32 vclk, u32 dclk);
1261
	} pm;
1334
	} pm;
1262
	/* pageflipping */
1335
	/* pageflipping */
1263
	struct {
1336
	struct {
1264
	void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
1337
	void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
1265
	u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
1338
	u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
1266
	void (*post_page_flip)(struct radeon_device *rdev, int crtc);
1339
	void (*post_page_flip)(struct radeon_device *rdev, int crtc);
1267
	} pflip;
1340
	} pflip;
1268
};
1341
};
1269
 
1342
 
1270
/*
1343
/*
1271
 * Asic structures
1344
 * Asic structures
1272
 */
1345
 */
1273
struct r100_asic {
1346
struct r100_asic {
1274
	const unsigned	*reg_safe_bm;
1347
	const unsigned	*reg_safe_bm;
1275
	unsigned	reg_safe_bm_size;
1348
	unsigned	reg_safe_bm_size;
1276
	u32		hdp_cntl;
1349
	u32		hdp_cntl;
1277
};
1350
};
1278
 
1351
 
1279
struct r300_asic {
1352
struct r300_asic {
1280
	const unsigned	*reg_safe_bm;
1353
	const unsigned	*reg_safe_bm;
1281
	unsigned	reg_safe_bm_size;
1354
	unsigned	reg_safe_bm_size;
1282
	u32		resync_scratch;
1355
	u32		resync_scratch;
1283
	u32		hdp_cntl;
1356
	u32		hdp_cntl;
1284
};
1357
};
1285
 
1358
 
1286
struct r600_asic {
1359
struct r600_asic {
1287
	unsigned max_pipes;
1360
	unsigned max_pipes;
1288
	unsigned max_tile_pipes;
1361
	unsigned max_tile_pipes;
1289
	unsigned max_simds;
1362
	unsigned max_simds;
1290
	unsigned max_backends;
1363
	unsigned max_backends;
1291
	unsigned max_gprs;
1364
	unsigned max_gprs;
1292
	unsigned max_threads;
1365
	unsigned max_threads;
1293
	unsigned max_stack_entries;
1366
	unsigned max_stack_entries;
1294
	unsigned max_hw_contexts;
1367
	unsigned max_hw_contexts;
1295
	unsigned max_gs_threads;
1368
	unsigned max_gs_threads;
1296
	unsigned sx_max_export_size;
1369
	unsigned sx_max_export_size;
1297
	unsigned sx_max_export_pos_size;
1370
	unsigned sx_max_export_pos_size;
1298
	unsigned sx_max_export_smx_size;
1371
	unsigned sx_max_export_smx_size;
1299
	unsigned sq_num_cf_insts;
1372
	unsigned sq_num_cf_insts;
1300
	unsigned tiling_nbanks;
1373
	unsigned tiling_nbanks;
1301
	unsigned tiling_npipes;
1374
	unsigned tiling_npipes;
1302
	unsigned tiling_group_size;
1375
	unsigned tiling_group_size;
1303
	unsigned		tile_config;
1376
	unsigned		tile_config;
1304
	unsigned		backend_map;
1377
	unsigned		backend_map;
1305
};
1378
};
1306
 
1379
 
1307
struct rv770_asic {
1380
struct rv770_asic {
1308
	unsigned max_pipes;
1381
	unsigned max_pipes;
1309
	unsigned max_tile_pipes;
1382
	unsigned max_tile_pipes;
1310
	unsigned max_simds;
1383
	unsigned max_simds;
1311
	unsigned max_backends;
1384
	unsigned max_backends;
1312
	unsigned max_gprs;
1385
	unsigned max_gprs;
1313
	unsigned max_threads;
1386
	unsigned max_threads;
1314
	unsigned max_stack_entries;
1387
	unsigned max_stack_entries;
1315
	unsigned max_hw_contexts;
1388
	unsigned max_hw_contexts;
1316
	unsigned max_gs_threads;
1389
	unsigned max_gs_threads;
1317
	unsigned sx_max_export_size;
1390
	unsigned sx_max_export_size;
1318
	unsigned sx_max_export_pos_size;
1391
	unsigned sx_max_export_pos_size;
1319
	unsigned sx_max_export_smx_size;
1392
	unsigned sx_max_export_smx_size;
1320
	unsigned sq_num_cf_insts;
1393
	unsigned sq_num_cf_insts;
1321
	unsigned sx_num_of_sets;
1394
	unsigned sx_num_of_sets;
1322
	unsigned sc_prim_fifo_size;
1395
	unsigned sc_prim_fifo_size;
1323
	unsigned sc_hiz_tile_fifo_size;
1396
	unsigned sc_hiz_tile_fifo_size;
1324
	unsigned sc_earlyz_tile_fifo_fize;
1397
	unsigned sc_earlyz_tile_fifo_fize;
1325
	unsigned tiling_nbanks;
1398
	unsigned tiling_nbanks;
1326
	unsigned tiling_npipes;
1399
	unsigned tiling_npipes;
1327
	unsigned tiling_group_size;
1400
	unsigned tiling_group_size;
1328
	unsigned		tile_config;
1401
	unsigned		tile_config;
1329
	unsigned		backend_map;
1402
	unsigned		backend_map;
1330
};
1403
};
1331
 
1404
 
1332
struct evergreen_asic {
1405
struct evergreen_asic {
1333
	unsigned num_ses;
1406
	unsigned num_ses;
1334
	unsigned max_pipes;
1407
	unsigned max_pipes;
1335
	unsigned max_tile_pipes;
1408
	unsigned max_tile_pipes;
1336
	unsigned max_simds;
1409
	unsigned max_simds;
1337
	unsigned max_backends;
1410
	unsigned max_backends;
1338
	unsigned max_gprs;
1411
	unsigned max_gprs;
1339
	unsigned max_threads;
1412
	unsigned max_threads;
1340
	unsigned max_stack_entries;
1413
	unsigned max_stack_entries;
1341
	unsigned max_hw_contexts;
1414
	unsigned max_hw_contexts;
1342
	unsigned max_gs_threads;
1415
	unsigned max_gs_threads;
1343
	unsigned sx_max_export_size;
1416
	unsigned sx_max_export_size;
1344
	unsigned sx_max_export_pos_size;
1417
	unsigned sx_max_export_pos_size;
1345
	unsigned sx_max_export_smx_size;
1418
	unsigned sx_max_export_smx_size;
1346
	unsigned sq_num_cf_insts;
1419
	unsigned sq_num_cf_insts;
1347
	unsigned sx_num_of_sets;
1420
	unsigned sx_num_of_sets;
1348
	unsigned sc_prim_fifo_size;
1421
	unsigned sc_prim_fifo_size;
1349
	unsigned sc_hiz_tile_fifo_size;
1422
	unsigned sc_hiz_tile_fifo_size;
1350
	unsigned sc_earlyz_tile_fifo_size;
1423
	unsigned sc_earlyz_tile_fifo_size;
1351
	unsigned tiling_nbanks;
1424
	unsigned tiling_nbanks;
1352
	unsigned tiling_npipes;
1425
	unsigned tiling_npipes;
1353
	unsigned tiling_group_size;
1426
	unsigned tiling_group_size;
1354
	unsigned tile_config;
1427
	unsigned tile_config;
1355
	unsigned backend_map;
1428
	unsigned backend_map;
1356
};
1429
};
1357
 
1430
 
1358
struct cayman_asic {
1431
struct cayman_asic {
1359
	unsigned max_shader_engines;
1432
	unsigned max_shader_engines;
1360
	unsigned max_pipes_per_simd;
1433
	unsigned max_pipes_per_simd;
1361
	unsigned max_tile_pipes;
1434
	unsigned max_tile_pipes;
1362
	unsigned max_simds_per_se;
1435
	unsigned max_simds_per_se;
1363
	unsigned max_backends_per_se;
1436
	unsigned max_backends_per_se;
1364
	unsigned max_texture_channel_caches;
1437
	unsigned max_texture_channel_caches;
1365
	unsigned max_gprs;
1438
	unsigned max_gprs;
1366
	unsigned max_threads;
1439
	unsigned max_threads;
1367
	unsigned max_gs_threads;
1440
	unsigned max_gs_threads;
1368
	unsigned max_stack_entries;
1441
	unsigned max_stack_entries;
1369
	unsigned sx_num_of_sets;
1442
	unsigned sx_num_of_sets;
1370
	unsigned sx_max_export_size;
1443
	unsigned sx_max_export_size;
1371
	unsigned sx_max_export_pos_size;
1444
	unsigned sx_max_export_pos_size;
1372
	unsigned sx_max_export_smx_size;
1445
	unsigned sx_max_export_smx_size;
1373
	unsigned max_hw_contexts;
1446
	unsigned max_hw_contexts;
1374
	unsigned sq_num_cf_insts;
1447
	unsigned sq_num_cf_insts;
1375
	unsigned sc_prim_fifo_size;
1448
	unsigned sc_prim_fifo_size;
1376
	unsigned sc_hiz_tile_fifo_size;
1449
	unsigned sc_hiz_tile_fifo_size;
1377
	unsigned sc_earlyz_tile_fifo_size;
1450
	unsigned sc_earlyz_tile_fifo_size;
1378
 
1451
 
1379
	unsigned num_shader_engines;
1452
	unsigned num_shader_engines;
1380
	unsigned num_shader_pipes_per_simd;
1453
	unsigned num_shader_pipes_per_simd;
1381
	unsigned num_tile_pipes;
1454
	unsigned num_tile_pipes;
1382
	unsigned num_simds_per_se;
1455
	unsigned num_simds_per_se;
1383
	unsigned num_backends_per_se;
1456
	unsigned num_backends_per_se;
1384
	unsigned backend_disable_mask_per_asic;
1457
	unsigned backend_disable_mask_per_asic;
1385
	unsigned backend_map;
1458
	unsigned backend_map;
1386
	unsigned num_texture_channel_caches;
1459
	unsigned num_texture_channel_caches;
1387
	unsigned mem_max_burst_length_bytes;
1460
	unsigned mem_max_burst_length_bytes;
1388
	unsigned mem_row_size_in_kb;
1461
	unsigned mem_row_size_in_kb;
1389
	unsigned shader_engine_tile_size;
1462
	unsigned shader_engine_tile_size;
1390
	unsigned num_gpus;
1463
	unsigned num_gpus;
1391
	unsigned multi_gpu_tile_size;
1464
	unsigned multi_gpu_tile_size;
1392
 
1465
 
1393
	unsigned tile_config;
1466
	unsigned tile_config;
1394
};
1467
};
1395
 
1468
 
1396
struct si_asic {
1469
struct si_asic {
1397
	unsigned max_shader_engines;
1470
	unsigned max_shader_engines;
1398
	unsigned max_tile_pipes;
1471
	unsigned max_tile_pipes;
1399
	unsigned max_cu_per_sh;
1472
	unsigned max_cu_per_sh;
1400
	unsigned max_sh_per_se;
1473
	unsigned max_sh_per_se;
1401
	unsigned max_backends_per_se;
1474
	unsigned max_backends_per_se;
1402
	unsigned max_texture_channel_caches;
1475
	unsigned max_texture_channel_caches;
1403
	unsigned max_gprs;
1476
	unsigned max_gprs;
1404
	unsigned max_gs_threads;
1477
	unsigned max_gs_threads;
1405
	unsigned max_hw_contexts;
1478
	unsigned max_hw_contexts;
1406
	unsigned sc_prim_fifo_size_frontend;
1479
	unsigned sc_prim_fifo_size_frontend;
1407
	unsigned sc_prim_fifo_size_backend;
1480
	unsigned sc_prim_fifo_size_backend;
1408
	unsigned sc_hiz_tile_fifo_size;
1481
	unsigned sc_hiz_tile_fifo_size;
1409
	unsigned sc_earlyz_tile_fifo_size;
1482
	unsigned sc_earlyz_tile_fifo_size;
1410
 
1483
 
1411
	unsigned num_tile_pipes;
1484
	unsigned num_tile_pipes;
1412
	unsigned num_backends_per_se;
1485
	unsigned num_backends_per_se;
1413
	unsigned backend_disable_mask_per_asic;
1486
	unsigned backend_disable_mask_per_asic;
1414
	unsigned backend_map;
1487
	unsigned backend_map;
1415
	unsigned num_texture_channel_caches;
1488
	unsigned num_texture_channel_caches;
1416
	unsigned mem_max_burst_length_bytes;
1489
	unsigned mem_max_burst_length_bytes;
1417
	unsigned mem_row_size_in_kb;
1490
	unsigned mem_row_size_in_kb;
1418
	unsigned shader_engine_tile_size;
1491
	unsigned shader_engine_tile_size;
1419
	unsigned num_gpus;
1492
	unsigned num_gpus;
1420
	unsigned multi_gpu_tile_size;
1493
	unsigned multi_gpu_tile_size;
1421
 
1494
 
1422
	unsigned tile_config;
1495
	unsigned tile_config;
-
 
1496
	uint32_t tile_mode_array[32];
1423
};
1497
};
1424
 
1498
 
1425
union radeon_asic_config {
1499
union radeon_asic_config {
1426
	struct r300_asic	r300;
1500
	struct r300_asic	r300;
1427
	struct r100_asic	r100;
1501
	struct r100_asic	r100;
1428
	struct r600_asic	r600;
1502
	struct r600_asic	r600;
1429
	struct rv770_asic	rv770;
1503
	struct rv770_asic	rv770;
1430
	struct evergreen_asic	evergreen;
1504
	struct evergreen_asic	evergreen;
1431
	struct cayman_asic	cayman;
1505
	struct cayman_asic	cayman;
1432
	struct si_asic		si;
1506
	struct si_asic		si;
1433
};
1507
};
1434
 
1508
 
1435
/*
1509
/*
1436
 * asic initizalization from radeon_asic.c
1510
 * asic initizalization from radeon_asic.c
1437
 */
1511
 */
1438
void radeon_agp_disable(struct radeon_device *rdev);
1512
void radeon_agp_disable(struct radeon_device *rdev);
1439
int radeon_asic_init(struct radeon_device *rdev);
1513
int radeon_asic_init(struct radeon_device *rdev);
1440
 
1514
 
1441
 
1515
 
1442
 
1516
 
1443
/* VRAM scratch page for HDP bug, default vram page */
1517
/* VRAM scratch page for HDP bug, default vram page */
1444
struct r600_vram_scratch {
1518
struct r600_vram_scratch {
1445
	struct radeon_bo		*robj;
1519
	struct radeon_bo		*robj;
1446
	volatile uint32_t		*ptr;
1520
	volatile uint32_t		*ptr;
1447
	u64				gpu_addr;
1521
	u64				gpu_addr;
1448
};
1522
};
1449
 
1523
 
1450
 
1524
 
1451
/*
1525
/*
1452
 * Core structure, functions and helpers.
1526
 * Core structure, functions and helpers.
1453
 */
1527
 */
1454
typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
1528
typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
1455
typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
1529
typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
1456
 
1530
 
1457
struct radeon_device {
1531
struct radeon_device {
1458
    struct device              *dev;
1532
    struct device              *dev;
1459
    struct drm_device          *ddev;
1533
    struct drm_device          *ddev;
1460
    struct pci_dev             *pdev;
1534
    struct pci_dev             *pdev;
1461
	struct rw_semaphore		exclusive_lock;
1535
	struct rw_semaphore		exclusive_lock;
1462
    /* ASIC */
1536
    /* ASIC */
1463
    union radeon_asic_config    config;
1537
    union radeon_asic_config    config;
1464
    enum radeon_family          family;
1538
    enum radeon_family          family;
1465
    unsigned long               flags;
1539
    unsigned long               flags;
1466
    int                         usec_timeout;
1540
    int                         usec_timeout;
1467
    enum radeon_pll_errata      pll_errata;
1541
    enum radeon_pll_errata      pll_errata;
1468
    int                         num_gb_pipes;
1542
    int                         num_gb_pipes;
1469
	int				            num_z_pipes;
1543
	int				            num_z_pipes;
1470
    int                         disp_priority;
1544
    int                         disp_priority;
1471
    /* BIOS */
1545
    /* BIOS */
1472
    uint8_t                     *bios;
1546
    uint8_t                     *bios;
1473
    bool                        is_atom_bios;
1547
    bool                        is_atom_bios;
1474
    uint16_t                    bios_header_start;
1548
    uint16_t                    bios_header_start;
1475
	struct radeon_bo		    *stollen_vga_memory;
1549
	struct radeon_bo		    *stollen_vga_memory;
1476
    /* Register mmio */
1550
    /* Register mmio */
1477
	resource_size_t			rmmio_base;
1551
	resource_size_t			rmmio_base;
1478
	resource_size_t			rmmio_size;
1552
	resource_size_t			rmmio_size;
1479
	/* protects concurrent MM_INDEX/DATA based register access */
1553
	/* protects concurrent MM_INDEX/DATA based register access */
1480
	spinlock_t mmio_idx_lock;
1554
	spinlock_t mmio_idx_lock;
1481
	void __iomem			*rmmio;
1555
	void __iomem			*rmmio;
1482
    radeon_rreg_t               mc_rreg;
1556
    radeon_rreg_t               mc_rreg;
1483
    radeon_wreg_t               mc_wreg;
1557
    radeon_wreg_t               mc_wreg;
1484
    radeon_rreg_t               pll_rreg;
1558
    radeon_rreg_t               pll_rreg;
1485
    radeon_wreg_t               pll_wreg;
1559
    radeon_wreg_t               pll_wreg;
1486
	uint32_t                        pcie_reg_mask;
1560
	uint32_t                        pcie_reg_mask;
1487
    radeon_rreg_t               pciep_rreg;
1561
    radeon_rreg_t               pciep_rreg;
1488
    radeon_wreg_t               pciep_wreg;
1562
    radeon_wreg_t               pciep_wreg;
1489
	/* io port */
1563
	/* io port */
1490
	void __iomem                    *rio_mem;
1564
	void __iomem                    *rio_mem;
1491
	resource_size_t			rio_mem_size;
1565
	resource_size_t			rio_mem_size;
1492
    struct radeon_clock         clock;
1566
    struct radeon_clock         clock;
1493
    struct radeon_mc            mc;
1567
    struct radeon_mc            mc;
1494
    struct radeon_gart          gart;
1568
    struct radeon_gart          gart;
1495
	struct radeon_mode_info		mode_info;
1569
	struct radeon_mode_info		mode_info;
1496
    struct radeon_scratch       scratch;
1570
    struct radeon_scratch       scratch;
1497
    struct radeon_mman          mman;
1571
    struct radeon_mman          mman;
1498
	struct radeon_fence_driver	fence_drv[RADEON_NUM_RINGS];
1572
	struct radeon_fence_driver	fence_drv[RADEON_NUM_RINGS];
1499
	wait_queue_head_t		fence_queue;
1573
	wait_queue_head_t		fence_queue;
1500
	struct mutex			ring_lock;
1574
	struct mutex			ring_lock;
1501
	struct radeon_ring		ring[RADEON_NUM_RINGS];
1575
	struct radeon_ring		ring[RADEON_NUM_RINGS];
1502
	bool				ib_pool_ready;
1576
	bool				ib_pool_ready;
1503
	struct radeon_sa_manager	ring_tmp_bo;
1577
	struct radeon_sa_manager	ring_tmp_bo;
1504
    struct radeon_irq       irq;
1578
    struct radeon_irq       irq;
1505
    struct radeon_asic         *asic;
1579
    struct radeon_asic         *asic;
1506
    struct radeon_gem       gem;
1580
    struct radeon_gem       gem;
1507
	struct radeon_pm		pm;
1581
	struct radeon_pm		pm;
-
 
1582
	struct radeon_uvd		uvd;
1508
	uint32_t			bios_scratch[RADEON_BIOS_NUM_SCRATCH];
1583
	uint32_t			bios_scratch[RADEON_BIOS_NUM_SCRATCH];
1509
    struct radeon_wb        wb;
1584
    struct radeon_wb        wb;
1510
	struct radeon_dummy_page	dummy_page;
1585
	struct radeon_dummy_page	dummy_page;
1511
    bool                shutdown;
1586
    bool                shutdown;
1512
    bool                suspend;
1587
    bool                suspend;
1513
	bool				need_dma32;
1588
	bool				need_dma32;
1514
	bool				accel_working;
1589
	bool				accel_working;
-
 
1590
	bool				fastfb_working; /* IGP feature*/
1515
	struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
1591
	struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
1516
	const struct firmware *me_fw;	/* all family ME firmware */
1592
	const struct firmware *me_fw;	/* all family ME firmware */
1517
	const struct firmware *pfp_fw;	/* r6/700 PFP firmware */
1593
	const struct firmware *pfp_fw;	/* r6/700 PFP firmware */
1518
	const struct firmware *rlc_fw;	/* r6/700 RLC firmware */
1594
	const struct firmware *rlc_fw;	/* r6/700 RLC firmware */
1519
	const struct firmware *mc_fw;	/* NI MC firmware */
1595
	const struct firmware *mc_fw;	/* NI MC firmware */
1520
	const struct firmware *ce_fw;	/* SI CE firmware */
1596
	const struct firmware *ce_fw;	/* SI CE firmware */
-
 
1597
	const struct firmware *uvd_fw;	/* UVD firmware */
1521
	struct r600_blit r600_blit;
1598
	struct r600_blit r600_blit;
1522
	struct r600_vram_scratch vram_scratch;
1599
	struct r600_vram_scratch vram_scratch;
1523
	int msi_enabled; /* msi enabled */
1600
	int msi_enabled; /* msi enabled */
1524
	struct r600_ih ih; /* r6/700 interrupt ring */
1601
	struct r600_ih ih; /* r6/700 interrupt ring */
1525
	struct si_rlc rlc;
1602
	struct si_rlc rlc;
1526
//	struct work_struct hotplug_work;
1603
//	struct work_struct hotplug_work;
1527
//	struct work_struct audio_work;
1604
//	struct work_struct audio_work;
1528
	int num_crtc; /* number of crtcs */
1605
	int num_crtc; /* number of crtcs */
1529
	struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
1606
	struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
1530
	bool			audio_enabled;
1607
	bool			audio_enabled;
-
 
1608
	bool has_uvd;
1531
//   struct r600_audio audio_status; /* audio stuff */
1609
//   struct r600_audio audio_status; /* audio stuff */
1532
//   struct notifier_block acpi_nb;
1610
//   struct notifier_block acpi_nb;
1533
	/* only one userspace can use Hyperz features or CMASK at a time */
1611
	/* only one userspace can use Hyperz features or CMASK at a time */
1534
//	struct drm_file *hyperz_filp;
1612
//	struct drm_file *hyperz_filp;
1535
//	struct drm_file *cmask_filp;
1613
//	struct drm_file *cmask_filp;
1536
	/* i2c buses */
1614
	/* i2c buses */
1537
	struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
1615
	struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
1538
	/* debugfs */
1616
	/* debugfs */
1539
//	struct radeon_debugfs	debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
1617
//	struct radeon_debugfs	debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
1540
	unsigned 		debugfs_count;
1618
	unsigned 		debugfs_count;
1541
	/* virtual memory */
1619
	/* virtual memory */
1542
	struct radeon_vm_manager	vm_manager;
1620
	struct radeon_vm_manager	vm_manager;
1543
	struct mutex			gpu_clock_mutex;
1621
	struct mutex			gpu_clock_mutex;
1544
	/* ACPI interface */
1622
	/* ACPI interface */
1545
//	struct radeon_atif		atif;
1623
//	struct radeon_atif		atif;
1546
//	struct radeon_atcs		atcs;
1624
//	struct radeon_atcs		atcs;
1547
};
1625
};
1548
 
1626
 
1549
int radeon_device_init(struct radeon_device *rdev,
1627
int radeon_device_init(struct radeon_device *rdev,
1550
		       struct drm_device *ddev,
1628
		       struct drm_device *ddev,
1551
		       struct pci_dev *pdev,
1629
		       struct pci_dev *pdev,
1552
		       uint32_t flags);
1630
		       uint32_t flags);
1553
void radeon_device_fini(struct radeon_device *rdev);
1631
void radeon_device_fini(struct radeon_device *rdev);
1554
int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
1632
int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
1555
 
1633
 
1556
uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg,
1634
uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg,
1557
		      bool always_indirect);
1635
		      bool always_indirect);
1558
void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v,
1636
void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v,
1559
		  bool always_indirect);
1637
		  bool always_indirect);
1560
u32 r100_io_rreg(struct radeon_device *rdev, u32 reg);
1638
u32 r100_io_rreg(struct radeon_device *rdev, u32 reg);
1561
void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
1639
void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
1562
 
1640
 
1563
/*
1641
/*
1564
 * Cast helper
1642
 * Cast helper
1565
 */
1643
 */
1566
#define to_radeon_fence(p) ((struct radeon_fence *)(p))
1644
#define to_radeon_fence(p) ((struct radeon_fence *)(p))
1567
 
1645
 
1568
/*
1646
/*
1569
 * Registers read & write functions.
1647
 * Registers read & write functions.
1570
 */
1648
 */
1571
#define RREG8(reg) readb((rdev->rmmio) + (reg))
1649
#define RREG8(reg) readb((rdev->rmmio) + (reg))
1572
#define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
1650
#define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
1573
#define RREG16(reg) readw((rdev->rmmio) + (reg))
1651
#define RREG16(reg) readw((rdev->rmmio) + (reg))
1574
#define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
1652
#define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
1575
#define RREG32(reg) r100_mm_rreg(rdev, (reg), false)
1653
#define RREG32(reg) r100_mm_rreg(rdev, (reg), false)
1576
#define RREG32_IDX(reg) r100_mm_rreg(rdev, (reg), true)
1654
#define RREG32_IDX(reg) r100_mm_rreg(rdev, (reg), true)
1577
#define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg), false))
1655
#define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg), false))
1578
#define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v), false)
1656
#define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v), false)
1579
#define WREG32_IDX(reg, v) r100_mm_wreg(rdev, (reg), (v), true)
1657
#define WREG32_IDX(reg, v) r100_mm_wreg(rdev, (reg), (v), true)
1580
#define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1658
#define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1581
#define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1659
#define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1582
#define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
1660
#define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
1583
#define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
1661
#define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
1584
#define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
1662
#define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
1585
#define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
1663
#define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
1586
#define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
1664
#define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
1587
#define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
1665
#define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
1588
#define RREG32_PCIE_P(reg) rdev->pciep_rreg(rdev, (reg))
1666
#define RREG32_PCIE_PORT(reg) rdev->pciep_rreg(rdev, (reg))
1589
#define WREG32_PCIE_P(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
1667
#define WREG32_PCIE_PORT(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
1590
#define WREG32_P(reg, val, mask)				\
1668
#define WREG32_P(reg, val, mask)				\
1591
	do {							\
1669
	do {							\
1592
		uint32_t tmp_ = RREG32(reg);			\
1670
		uint32_t tmp_ = RREG32(reg);			\
1593
		tmp_ &= (mask);					\
1671
		tmp_ &= (mask);					\
1594
		tmp_ |= ((val) & ~(mask));			\
1672
		tmp_ |= ((val) & ~(mask));			\
1595
		WREG32(reg, tmp_);				\
1673
		WREG32(reg, tmp_);				\
1596
	} while (0)
1674
	} while (0)
-
 
1675
#define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
-
 
1676
#define WREG32_OR(reg, or) WREG32_P(reg, or, ~or)
1597
#define WREG32_PLL_P(reg, val, mask)				\
1677
#define WREG32_PLL_P(reg, val, mask)				\
1598
	do {							\
1678
	do {							\
1599
		uint32_t tmp_ = RREG32_PLL(reg);		\
1679
		uint32_t tmp_ = RREG32_PLL(reg);		\
1600
		tmp_ &= (mask);					\
1680
		tmp_ &= (mask);					\
1601
		tmp_ |= ((val) & ~(mask));			\
1681
		tmp_ |= ((val) & ~(mask));			\
1602
		WREG32_PLL(reg, tmp_);				\
1682
		WREG32_PLL(reg, tmp_);				\
1603
	} while (0)
1683
	} while (0)
1604
#define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
1684
#define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
1605
#define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
1685
#define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
1606
 
1686
 
1607
/*
1687
/*
1608
 * Indirect registers accessor
1688
 * Indirect registers accessor
1609
 */
1689
 */
1610
static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
1690
static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
1611
{
1691
{
1612
	uint32_t r;
1692
	uint32_t r;
1613
 
1693
 
1614
	WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
1694
	WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
1615
	r = RREG32(RADEON_PCIE_DATA);
1695
	r = RREG32(RADEON_PCIE_DATA);
1616
	return r;
1696
	return r;
1617
}
1697
}
1618
 
1698
 
1619
static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
1699
static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
1620
{
1700
{
1621
	WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
1701
	WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
1622
	WREG32(RADEON_PCIE_DATA, (v));
1702
	WREG32(RADEON_PCIE_DATA, (v));
1623
}
1703
}
1624
 
1704
 
1625
void r100_pll_errata_after_index(struct radeon_device *rdev);
1705
void r100_pll_errata_after_index(struct radeon_device *rdev);
1626
 
1706
 
1627
 
1707
 
1628
/*
1708
/*
1629
 * ASICs helpers.
1709
 * ASICs helpers.
1630
 */
1710
 */
1631
#define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
1711
#define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
1632
			    (rdev->pdev->device == 0x5969))
1712
			    (rdev->pdev->device == 0x5969))
1633
#define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
1713
#define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
1634
        (rdev->family == CHIP_RV200) || \
1714
        (rdev->family == CHIP_RV200) || \
1635
        (rdev->family == CHIP_RS100) || \
1715
        (rdev->family == CHIP_RS100) || \
1636
        (rdev->family == CHIP_RS200) || \
1716
        (rdev->family == CHIP_RS200) || \
1637
        (rdev->family == CHIP_RV250) || \
1717
        (rdev->family == CHIP_RV250) || \
1638
        (rdev->family == CHIP_RV280) || \
1718
        (rdev->family == CHIP_RV280) || \
1639
        (rdev->family == CHIP_RS300))
1719
        (rdev->family == CHIP_RS300))
1640
#define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300)  || \
1720
#define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300)  || \
1641
        (rdev->family == CHIP_RV350) ||         \
1721
        (rdev->family == CHIP_RV350) ||         \
1642
        (rdev->family == CHIP_R350)  ||         \
1722
        (rdev->family == CHIP_R350)  ||         \
1643
        (rdev->family == CHIP_RV380) ||         \
1723
        (rdev->family == CHIP_RV380) ||         \
1644
        (rdev->family == CHIP_R420)  ||         \
1724
        (rdev->family == CHIP_R420)  ||         \
1645
        (rdev->family == CHIP_R423)  ||         \
1725
        (rdev->family == CHIP_R423)  ||         \
1646
        (rdev->family == CHIP_RV410) ||         \
1726
        (rdev->family == CHIP_RV410) ||         \
1647
        (rdev->family == CHIP_RS400) ||         \
1727
        (rdev->family == CHIP_RS400) ||         \
1648
        (rdev->family == CHIP_RS480))
1728
        (rdev->family == CHIP_RS480))
1649
#define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
1729
#define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
1650
		(rdev->ddev->pdev->device == 0x9443) || \
1730
		(rdev->ddev->pdev->device == 0x9443) || \
1651
		(rdev->ddev->pdev->device == 0x944B) || \
1731
		(rdev->ddev->pdev->device == 0x944B) || \
1652
		(rdev->ddev->pdev->device == 0x9506) || \
1732
		(rdev->ddev->pdev->device == 0x9506) || \
1653
		(rdev->ddev->pdev->device == 0x9509) || \
1733
		(rdev->ddev->pdev->device == 0x9509) || \
1654
		(rdev->ddev->pdev->device == 0x950F) || \
1734
		(rdev->ddev->pdev->device == 0x950F) || \
1655
		(rdev->ddev->pdev->device == 0x689C) || \
1735
		(rdev->ddev->pdev->device == 0x689C) || \
1656
		(rdev->ddev->pdev->device == 0x689D))
1736
		(rdev->ddev->pdev->device == 0x689D))
1657
#define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
1737
#define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
1658
#define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600)  ||	\
1738
#define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600)  ||	\
1659
			    (rdev->family == CHIP_RS690)  ||	\
1739
			    (rdev->family == CHIP_RS690)  ||	\
1660
			    (rdev->family == CHIP_RS740)  ||	\
1740
			    (rdev->family == CHIP_RS740)  ||	\
1661
			    (rdev->family >= CHIP_R600))
1741
			    (rdev->family >= CHIP_R600))
1662
#define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
1742
#define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
1663
#define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
1743
#define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
1664
#define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
1744
#define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
1665
#define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
1745
#define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
1666
			     (rdev->flags & RADEON_IS_IGP))
1746
			     (rdev->flags & RADEON_IS_IGP))
1667
#define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
1747
#define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
1668
#define ASIC_IS_DCE6(rdev) ((rdev->family >= CHIP_ARUBA))
1748
#define ASIC_IS_DCE6(rdev) ((rdev->family >= CHIP_ARUBA))
1669
#define ASIC_IS_DCE61(rdev) ((rdev->family >= CHIP_ARUBA) && \
1749
#define ASIC_IS_DCE61(rdev) ((rdev->family >= CHIP_ARUBA) && \
1670
			     (rdev->flags & RADEON_IS_IGP))
1750
			     (rdev->flags & RADEON_IS_IGP))
-
 
1751
#define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND))
-
 
1752
#define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN))
1671
 
1753
 
1672
/*
1754
/*
1673
 * BIOS helpers.
1755
 * BIOS helpers.
1674
 */
1756
 */
1675
#define RBIOS8(i) (rdev->bios[i])
1757
#define RBIOS8(i) (rdev->bios[i])
1676
#define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
1758
#define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
1677
#define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
1759
#define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
1678
 
1760
 
1679
int radeon_combios_init(struct radeon_device *rdev);
1761
int radeon_combios_init(struct radeon_device *rdev);
1680
void radeon_combios_fini(struct radeon_device *rdev);
1762
void radeon_combios_fini(struct radeon_device *rdev);
1681
int radeon_atombios_init(struct radeon_device *rdev);
1763
int radeon_atombios_init(struct radeon_device *rdev);
1682
void radeon_atombios_fini(struct radeon_device *rdev);
1764
void radeon_atombios_fini(struct radeon_device *rdev);
1683
 
1765
 
1684
 
1766
 
1685
/*
1767
/*
1686
 * RING helpers.
1768
 * RING helpers.
1687
 */
1769
 */
1688
#if DRM_DEBUG_CODE == 0
1770
#if DRM_DEBUG_CODE == 0
1689
static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
1771
static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
1690
{
1772
{
1691
	ring->ring[ring->wptr++] = v;
1773
	ring->ring[ring->wptr++] = v;
1692
	ring->wptr &= ring->ptr_mask;
1774
	ring->wptr &= ring->ptr_mask;
1693
	ring->count_dw--;
1775
	ring->count_dw--;
1694
	ring->ring_free_dw--;
1776
	ring->ring_free_dw--;
1695
}
1777
}
1696
#else
1778
#else
1697
/* With debugging this is just too big to inline */
1779
/* With debugging this is just too big to inline */
1698
void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
1780
void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
1699
#endif
1781
#endif
1700
 
1782
 
1701
/*
1783
/*
1702
 * ASICs macro.
1784
 * ASICs macro.
1703
 */
1785
 */
1704
#define radeon_init(rdev) (rdev)->asic->init((rdev))
1786
#define radeon_init(rdev) (rdev)->asic->init((rdev))
1705
#define radeon_fini(rdev) (rdev)->asic->fini((rdev))
1787
#define radeon_fini(rdev) (rdev)->asic->fini((rdev))
1706
#define radeon_resume(rdev) (rdev)->asic->resume((rdev))
1788
#define radeon_resume(rdev) (rdev)->asic->resume((rdev))
1707
#define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
1789
#define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
1708
#define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
1790
#define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
1709
#define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
1791
#define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
1710
#define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
1792
#define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
1711
#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
1793
#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
1712
#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p))
1794
#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p))
1713
#define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
1795
#define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
1714
#define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
1796
#define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
1715
#define radeon_asic_vm_set_page(rdev, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_page((rdev), (pe), (addr), (count), (incr), (flags)))
1797
#define radeon_asic_vm_set_page(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_page((rdev), (ib), (pe), (addr), (count), (incr), (flags)))
1716
#define radeon_ring_start(rdev, r, cp) (rdev)->asic->ring[(r)].ring_start((rdev), (cp))
1798
#define radeon_ring_start(rdev, r, cp) (rdev)->asic->ring[(r)].ring_start((rdev), (cp))
1717
#define radeon_ring_test(rdev, r, cp) (rdev)->asic->ring[(r)].ring_test((rdev), (cp))
1799
#define radeon_ring_test(rdev, r, cp) (rdev)->asic->ring[(r)].ring_test((rdev), (cp))
1718
#define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), (cp))
1800
#define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), (cp))
1719
#define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
1801
#define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
1720
#define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
1802
#define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
1721
#define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp))
1803
#define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp))
1722
#define radeon_ring_vm_flush(rdev, r, vm) (rdev)->asic->ring[(r)].vm_flush((rdev), (r), (vm))
1804
#define radeon_ring_vm_flush(rdev, r, vm) (rdev)->asic->ring[(r)].vm_flush((rdev), (r), (vm))
1723
#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
1805
#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
1724
#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
1806
#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
1725
#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
1807
#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
1726
#define radeon_set_backlight_level(rdev, e, l) (rdev)->asic->display.set_backlight_level((e), (l))
1808
#define radeon_set_backlight_level(rdev, e, l) (rdev)->asic->display.set_backlight_level((e), (l))
1727
#define radeon_get_backlight_level(rdev, e) (rdev)->asic->display.get_backlight_level((e))
1809
#define radeon_get_backlight_level(rdev, e) (rdev)->asic->display.get_backlight_level((e))
-
 
1810
#define radeon_hdmi_enable(rdev, e, b) (rdev)->asic->display.hdmi_enable((e), (b))
-
 
1811
#define radeon_hdmi_setmode(rdev, e, m) (rdev)->asic->display.hdmi_setmode((e), (m))
1728
#define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
1812
#define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
1729
#define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
1813
#define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
1730
#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (f))
1814
#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (f))
1731
#define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (f))
1815
#define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (f))
1732
#define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (f))
1816
#define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (f))
1733
#define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
1817
#define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
1734
#define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
1818
#define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
1735
#define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
1819
#define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
1736
#define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
1820
#define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
1737
#define radeon_set_engine_clock(rdev, e) (rdev)->asic->pm.set_engine_clock((rdev), (e))
1821
#define radeon_set_engine_clock(rdev, e) (rdev)->asic->pm.set_engine_clock((rdev), (e))
1738
#define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
1822
#define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
1739
#define radeon_set_memory_clock(rdev, e) (rdev)->asic->pm.set_memory_clock((rdev), (e))
1823
#define radeon_set_memory_clock(rdev, e) (rdev)->asic->pm.set_memory_clock((rdev), (e))
1740
#define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
1824
#define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
1741
#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
1825
#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
1742
#define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
1826
#define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
-
 
1827
#define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
1743
#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
1828
#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
1744
#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
1829
#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
1745
#define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
1830
#define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
1746
#define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
1831
#define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
1747
#define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
1832
#define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
1748
#define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
1833
#define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
1749
#define radeon_hpd_set_polarity(rdev, h) (rdev)->asic->hpd.set_polarity((rdev), (h))
1834
#define radeon_hpd_set_polarity(rdev, h) (rdev)->asic->hpd.set_polarity((rdev), (h))
1750
#define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
1835
#define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
1751
#define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
1836
#define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
1752
#define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
1837
#define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
1753
#define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
1838
#define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
1754
#define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
1839
#define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
1755
#define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm.get_dynpm_state((rdev))
1840
#define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm.get_dynpm_state((rdev))
1756
#define radeon_pre_page_flip(rdev, crtc) (rdev)->asic->pflip.pre_page_flip((rdev), (crtc))
1841
#define radeon_pre_page_flip(rdev, crtc) (rdev)->asic->pflip.pre_page_flip((rdev), (crtc))
1757
#define radeon_page_flip(rdev, crtc, base) (rdev)->asic->pflip.page_flip((rdev), (crtc), (base))
1842
#define radeon_page_flip(rdev, crtc, base) (rdev)->asic->pflip.page_flip((rdev), (crtc), (base))
1758
#define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc))
1843
#define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc))
1759
#define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
1844
#define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
1760
#define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
1845
#define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
-
 
1846
#define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
-
 
1847
#define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev))
1761
 
1848
 
1762
/* Common functions */
1849
/* Common functions */
1763
/* AGP */
1850
/* AGP */
1764
extern int radeon_gpu_reset(struct radeon_device *rdev);
1851
extern int radeon_gpu_reset(struct radeon_device *rdev);
-
 
1852
extern void r600_set_bios_scratch_engine_hung(struct radeon_device *rdev, bool hung);
1765
extern void radeon_agp_disable(struct radeon_device *rdev);
1853
extern void radeon_agp_disable(struct radeon_device *rdev);
1766
extern int radeon_modeset_init(struct radeon_device *rdev);
1854
extern int radeon_modeset_init(struct radeon_device *rdev);
1767
extern void radeon_modeset_fini(struct radeon_device *rdev);
1855
extern void radeon_modeset_fini(struct radeon_device *rdev);
1768
extern bool radeon_card_posted(struct radeon_device *rdev);
1856
extern bool radeon_card_posted(struct radeon_device *rdev);
1769
extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
1857
extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
1770
extern void radeon_update_display_priority(struct radeon_device *rdev);
1858
extern void radeon_update_display_priority(struct radeon_device *rdev);
1771
extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
1859
extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
1772
extern void radeon_scratch_init(struct radeon_device *rdev);
1860
extern void radeon_scratch_init(struct radeon_device *rdev);
1773
extern void radeon_wb_fini(struct radeon_device *rdev);
1861
extern void radeon_wb_fini(struct radeon_device *rdev);
1774
extern int radeon_wb_init(struct radeon_device *rdev);
1862
extern int radeon_wb_init(struct radeon_device *rdev);
1775
extern void radeon_wb_disable(struct radeon_device *rdev);
1863
extern void radeon_wb_disable(struct radeon_device *rdev);
1776
extern void radeon_surface_init(struct radeon_device *rdev);
1864
extern void radeon_surface_init(struct radeon_device *rdev);
1777
extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
1865
extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
1778
extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
1866
extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
1779
extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
1867
extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
1780
extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
1868
extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
1781
extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
1869
extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
1782
extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
1870
extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
1783
extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
1871
extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
1784
extern int radeon_resume_kms(struct drm_device *dev);
1872
extern int radeon_resume_kms(struct drm_device *dev);
1785
extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
1873
extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
1786
extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size);
1874
extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size);
-
 
1875
extern void radeon_program_register_sequence(struct radeon_device *rdev,
-
 
1876
					     const u32 *registers,
-
 
1877
					     const u32 array_size);
1787
 
1878
 
1788
/*
1879
/*
1789
 * vm
1880
 * vm
1790
 */
1881
 */
1791
int radeon_vm_manager_init(struct radeon_device *rdev);
1882
int radeon_vm_manager_init(struct radeon_device *rdev);
1792
void radeon_vm_manager_fini(struct radeon_device *rdev);
1883
void radeon_vm_manager_fini(struct radeon_device *rdev);
1793
void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm);
1884
void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm);
1794
void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm);
1885
void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm);
1795
int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm);
1886
int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm);
1796
void radeon_vm_add_to_lru(struct radeon_device *rdev, struct radeon_vm *vm);
1887
void radeon_vm_add_to_lru(struct radeon_device *rdev, struct radeon_vm *vm);
1797
struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
1888
struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
1798
				       struct radeon_vm *vm, int ring);
1889
				       struct radeon_vm *vm, int ring);
1799
void radeon_vm_fence(struct radeon_device *rdev,
1890
void radeon_vm_fence(struct radeon_device *rdev,
1800
		     struct radeon_vm *vm,
1891
		     struct radeon_vm *vm,
1801
		     struct radeon_fence *fence);
1892
		     struct radeon_fence *fence);
1802
uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr);
1893
uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr);
1803
int radeon_vm_bo_update_pte(struct radeon_device *rdev,
1894
int radeon_vm_bo_update_pte(struct radeon_device *rdev,
1804
			    struct radeon_vm *vm,
1895
			    struct radeon_vm *vm,
1805
			    struct radeon_bo *bo,
1896
			    struct radeon_bo *bo,
1806
			    struct ttm_mem_reg *mem);
1897
			    struct ttm_mem_reg *mem);
1807
void radeon_vm_bo_invalidate(struct radeon_device *rdev,
1898
void radeon_vm_bo_invalidate(struct radeon_device *rdev,
1808
			     struct radeon_bo *bo);
1899
			     struct radeon_bo *bo);
1809
struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
1900
struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
1810
				       struct radeon_bo *bo);
1901
				       struct radeon_bo *bo);
1811
struct radeon_bo_va *radeon_vm_bo_add(struct radeon_device *rdev,
1902
struct radeon_bo_va *radeon_vm_bo_add(struct radeon_device *rdev,
1812
				      struct radeon_vm *vm,
1903
				      struct radeon_vm *vm,
1813
				      struct radeon_bo *bo);
1904
				      struct radeon_bo *bo);
1814
int radeon_vm_bo_set_addr(struct radeon_device *rdev,
1905
int radeon_vm_bo_set_addr(struct radeon_device *rdev,
1815
			  struct radeon_bo_va *bo_va,
1906
			  struct radeon_bo_va *bo_va,
1816
			  uint64_t offset,
1907
			  uint64_t offset,
1817
			  uint32_t flags);
1908
			  uint32_t flags);
1818
int radeon_vm_bo_rmv(struct radeon_device *rdev,
1909
int radeon_vm_bo_rmv(struct radeon_device *rdev,
1819
		     struct radeon_bo_va *bo_va);
1910
		     struct radeon_bo_va *bo_va);
1820
 
1911
 
1821
/* audio */
1912
/* audio */
1822
void r600_audio_update_hdmi(struct work_struct *work);
1913
void r600_audio_update_hdmi(struct work_struct *work);
1823
 
1914
 
1824
/*
1915
/*
1825
 * R600 vram scratch functions
1916
 * R600 vram scratch functions
1826
 */
1917
 */
1827
int r600_vram_scratch_init(struct radeon_device *rdev);
1918
int r600_vram_scratch_init(struct radeon_device *rdev);
1828
void r600_vram_scratch_fini(struct radeon_device *rdev);
1919
void r600_vram_scratch_fini(struct radeon_device *rdev);
1829
 
1920
 
1830
/*
1921
/*
1831
 * r600 cs checking helper
1922
 * r600 cs checking helper
1832
 */
1923
 */
1833
unsigned r600_mip_minify(unsigned size, unsigned level);
1924
unsigned r600_mip_minify(unsigned size, unsigned level);
1834
bool r600_fmt_is_valid_color(u32 format);
1925
bool r600_fmt_is_valid_color(u32 format);
1835
bool r600_fmt_is_valid_texture(u32 format, enum radeon_family family);
1926
bool r600_fmt_is_valid_texture(u32 format, enum radeon_family family);
1836
int r600_fmt_get_blocksize(u32 format);
1927
int r600_fmt_get_blocksize(u32 format);
1837
int r600_fmt_get_nblocksx(u32 format, u32 w);
1928
int r600_fmt_get_nblocksx(u32 format, u32 w);
1838
int r600_fmt_get_nblocksy(u32 format, u32 h);
1929
int r600_fmt_get_nblocksy(u32 format, u32 h);
1839
 
1930
 
1840
/*
1931
/*
1841
 * r600 functions used by radeon_encoder.c
1932
 * r600 functions used by radeon_encoder.c
1842
 */
1933
 */
1843
struct radeon_hdmi_acr {
1934
struct radeon_hdmi_acr {
1844
	u32 clock;
1935
	u32 clock;
1845
 
1936
 
1846
	int n_32khz;
1937
	int n_32khz;
1847
	int cts_32khz;
1938
	int cts_32khz;
1848
 
1939
 
1849
	int n_44_1khz;
1940
	int n_44_1khz;
1850
	int cts_44_1khz;
1941
	int cts_44_1khz;
1851
 
1942
 
1852
	int n_48khz;
1943
	int n_48khz;
1853
	int cts_48khz;
1944
	int cts_48khz;
1854
 
1945
 
1855
};
1946
};
1856
 
1947
 
1857
extern struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock);
1948
extern struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock);
1858
 
-
 
1859
extern void r600_hdmi_enable(struct drm_encoder *encoder);
-
 
1860
extern void r600_hdmi_disable(struct drm_encoder *encoder);
-
 
1861
extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
1949
 
1862
extern u32 r6xx_remap_render_backend(struct radeon_device *rdev,
1950
extern u32 r6xx_remap_render_backend(struct radeon_device *rdev,
1863
				     u32 tiling_pipe_num,
1951
				     u32 tiling_pipe_num,
1864
				     u32 max_rb_num,
1952
				     u32 max_rb_num,
1865
				     u32 total_max_rb_num,
1953
				     u32 total_max_rb_num,
1866
				     u32 enabled_rb_mask);
1954
				     u32 enabled_rb_mask);
1867
 
1955
 
1868
/*
1956
/*
1869
 * evergreen functions used by radeon_encoder.c
1957
 * evergreen functions used by radeon_encoder.c
1870
 */
1958
 */
1871
 
-
 
1872
extern void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
-
 
1873
 
1959
 
1874
extern int ni_init_microcode(struct radeon_device *rdev);
1960
extern int ni_init_microcode(struct radeon_device *rdev);
1875
extern int ni_mc_load_microcode(struct radeon_device *rdev);
1961
extern int ni_mc_load_microcode(struct radeon_device *rdev);
1876
 
1962
 
1877
/* radeon_acpi.c */
1963
/* radeon_acpi.c */
1878
#if defined(CONFIG_ACPI)
1964
#if defined(CONFIG_ACPI)
1879
extern int radeon_acpi_init(struct radeon_device *rdev);
1965
extern int radeon_acpi_init(struct radeon_device *rdev);
1880
extern void radeon_acpi_fini(struct radeon_device *rdev);
1966
extern void radeon_acpi_fini(struct radeon_device *rdev);
1881
#else
1967
#else
1882
static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
1968
static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
1883
static inline void radeon_acpi_fini(struct radeon_device *rdev) { }
1969
static inline void radeon_acpi_fini(struct radeon_device *rdev) { }
1884
#endif
1970
#endif
1885
 
1971
 
1886
#include "radeon_object.h"
1972
#include "radeon_object.h"
1887
 
1973
 
1888
#define DRM_UDELAY(d)           udelay(d)
1974
#define DRM_UDELAY(d)           udelay(d)
1889
 
1975
 
1890
resource_size_t
1976
resource_size_t
1891
drm_get_resource_start(struct drm_device *dev, unsigned int resource);
1977
drm_get_resource_start(struct drm_device *dev, unsigned int resource);
1892
resource_size_t
1978
resource_size_t
1893
drm_get_resource_len(struct drm_device *dev, unsigned int resource);
1979
drm_get_resource_len(struct drm_device *dev, unsigned int resource);
1894
 
1980
 
1895
bool set_mode(struct drm_device *dev, struct drm_connector *connector,
1981
bool set_mode(struct drm_device *dev, struct drm_connector *connector,
1896
              videomode_t *mode, bool strict);
1982
              videomode_t *mode, bool strict);
1897
 
1983
 
1898
 
1984
 
1899
 
1985
#ifndef __TTM__
-
 
1986
#define radeon_ttm_set_active_vram_size(a, b)
1900
#define radeon_ttm_set_active_vram_size(a, b)
1987
#endif
1901
 
1988
 
1902
#endif
1989
#endif