Subversion Repositories Kolibri OS

Rev

Rev 1128 | Rev 1221 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

<
Rev Author Line No. Line
1117 serge 1
/*
2
 * Copyright 2008 Advanced Micro Devices, Inc.
3
 * Copyright 2008 Red Hat Inc.
4
 * Copyright 2009 Jerome Glisse.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
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
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
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,
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
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
22
 * OTHER DEALINGS IN THE SOFTWARE.
23
 *
24
 * Authors: Dave Airlie
25
 *          Alex Deucher
26
 *          Jerome Glisse
27
 */
28
#ifndef __RADEON_H__
29
#define __RADEON_H__
30
 
31
//#include "radeon_object.h"
32
 
33
/* TODO: Here are things that needs to be done :
34
 *	- surface allocator & initializer : (bit like scratch reg) should
35
 *	  initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
36
 *	  related to surface
37
 *	- WB : write back stuff (do it bit like scratch reg things)
38
 *	- Vblank : look at Jesse's rework and what we should do
39
 *	- r600/r700: gart & cp
40
 *	- cs : clean cs ioctl use bitmap & things like that.
41
 *	- power management stuff
42
 *	- Barrier in gart code
43
 *	- Unmappabled vram ?
44
 *	- TESTING, TESTING, TESTING
45
 */
46
 
1120 serge 47
#include 
1179 serge 48
#include 
1117 serge 49
 
1120 serge 50
#include 
1117 serge 51
 
1120 serge 52
#include 
1123 serge 53
#include "drm_edid.h"
1179 serge 54
 
55
#include "radeon_family.h"
1117 serge 56
#include "radeon_mode.h"
57
#include "radeon_reg.h"
58
 
59
#include 
60
 
1179 serge 61
/*
62
 * Modules parameters.
63
 */
64
extern int radeon_no_wb;
1123 serge 65
extern int radeon_modeset;
1117 serge 66
extern int radeon_dynclks;
1123 serge 67
extern int radeon_r4xx_atom;
1128 serge 68
extern int radeon_agpmode;
69
extern int radeon_vram_limit;
1117 serge 70
extern int radeon_gart_size;
1128 serge 71
extern int radeon_benchmarking;
1179 serge 72
extern int radeon_testing;
1123 serge 73
extern int radeon_connector_table;
1179 serge 74
extern int radeon_tv;
1117 serge 75
 
1179 serge 76
 
77
static inline uint8_t __raw_readb(const volatile void __iomem *addr)
78
{
79
    return *(const volatile uint8_t __force *) addr;
80
}
81
 
82
static inline uint16_t __raw_readw(const volatile void __iomem *addr)
83
{
84
    return *(const volatile uint16_t __force *) addr;
85
}
86
 
87
static inline uint32_t __raw_readl(const volatile void __iomem *addr)
88
{
89
    return *(const volatile uint32_t __force *) addr;
90
}
91
 
92
#define readb __raw_readb
93
#define readw __raw_readw
94
#define readl __raw_readl
95
 
96
 
97
 
98
static inline void __raw_writeb(uint8_t b, volatile void __iomem *addr)
99
{
100
    *(volatile uint8_t __force *) addr = b;
101
}
102
 
103
static inline void __raw_writew(uint16_t b, volatile void __iomem *addr)
104
{
105
    *(volatile uint16_t __force *) addr = b;
106
}
107
 
108
static inline void __raw_writel(uint32_t b, volatile void __iomem *addr)
109
{
110
    *(volatile uint32_t __force *) addr = b;
111
}
112
 
113
static inline void __raw_writeq(__u64 b, volatile void __iomem *addr)
114
{
115
        *(volatile __u64 *)addr = b;
116
}
117
 
118
#define writeb __raw_writeb
119
#define writew __raw_writew
120
#define writel __raw_writel
121
#define writeq __raw_writeq
122
 
123
//#define writeb(b,addr) *(volatile uint8_t* ) addr = (uint8_t)b
124
//#define writew(b,addr) *(volatile uint16_t*) addr = (uint16_t)b
125
//#define writel(b,addr) *(volatile uint32_t*) addr = (uint32_t)b
126
 
127
 
1117 serge 128
/*
129
 * Copy from radeon_drv.h so we don't have to include both and have conflicting
130
 * symbol;
131
 */
1120 serge 132
#define RADEON_MAX_USEC_TIMEOUT         100000  /* 100 ms */
133
#define RADEON_IB_POOL_SIZE             16
1117 serge 134
#define RADEON_DEBUGFS_MAX_NUM_FILES	32
1120 serge 135
#define RADEONFB_CONN_LIMIT             4
1179 serge 136
#define RADEON_BIOS_NUM_SCRATCH		8
1117 serge 137
 
138
/*
139
 * Errata workarounds.
140
 */
141
enum radeon_pll_errata {
142
    CHIP_ERRATA_R300_CG             = 0x00000001,
143
    CHIP_ERRATA_PLL_DUMMYREADS      = 0x00000002,
144
    CHIP_ERRATA_PLL_DELAY           = 0x00000004
145
};
146
 
147
 
148
struct radeon_device;
149
 
150
 
151
/*
152
 * BIOS.
153
 */
154
bool radeon_get_bios(struct radeon_device *rdev);
155
 
1179 serge 156
 
1117 serge 157
/*
1179 serge 158
 * Dummy page
159
 */
160
struct radeon_dummy_page {
161
	struct page	*page;
162
	dma_addr_t	addr;
163
};
164
int radeon_dummy_page_init(struct radeon_device *rdev);
165
void radeon_dummy_page_fini(struct radeon_device *rdev);
166
 
167
 
168
/*
1117 serge 169
 * Clocks
170
 */
171
struct radeon_clock {
172
	struct radeon_pll p1pll;
173
	struct radeon_pll p2pll;
174
	struct radeon_pll spll;
175
	struct radeon_pll mpll;
176
	/* 10 Khz units */
177
	uint32_t default_mclk;
178
	uint32_t default_sclk;
179
};
180
 
1179 serge 181
 
1117 serge 182
/*
183
 * Fences.
184
 */
185
struct radeon_fence_driver {
186
	uint32_t			scratch_reg;
187
//	atomic_t			seq;
188
	uint32_t			last_seq;
189
	unsigned long			count_timeout;
190
//	wait_queue_head_t		queue;
191
//	rwlock_t			lock;
1120 serge 192
	struct list_head		created;
193
	struct list_head		emited;
194
	struct list_head		signaled;
1117 serge 195
};
196
 
197
struct radeon_fence {
198
	struct radeon_device		*rdev;
199
//	struct kref			kref;
1120 serge 200
	struct list_head		list;
1117 serge 201
	/* protected by radeon_fence.lock */
202
	uint32_t			seq;
203
	unsigned long			timeout;
204
	bool				emited;
205
	bool				signaled;
206
};
207
 
208
int radeon_fence_driver_init(struct radeon_device *rdev);
209
void radeon_fence_driver_fini(struct radeon_device *rdev);
210
int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence);
211
int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
212
void radeon_fence_process(struct radeon_device *rdev);
213
bool radeon_fence_signaled(struct radeon_fence *fence);
214
int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
215
int radeon_fence_wait_next(struct radeon_device *rdev);
216
int radeon_fence_wait_last(struct radeon_device *rdev);
217
struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
218
void radeon_fence_unref(struct radeon_fence **fence);
219
 
1179 serge 220
/*
221
 * Tiling registers
222
 */
223
struct radeon_surface_reg {
224
	struct radeon_object *robj;
225
};
1117 serge 226
 
1179 serge 227
#define RADEON_GEM_MAX_SURFACES 8
228
 
1117 serge 229
/*
230
 * Radeon buffer.
231
 */
232
struct radeon_object;
233
 
234
struct radeon_object_list {
1120 serge 235
	struct list_head	list;
1117 serge 236
	struct radeon_object	*robj;