7d5583fd287d2aadacc1b91ee0b21fad0892897d
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Corbin Simpson <MostAwesomeDude@gmail.com>
26 * Joakim Sindholt <opensource@zhasha.com>
29 #include "r600_priv.h"
30 #include "r600_drm_public.h"
31 #include "util/u_memory.h"
34 #ifndef RADEON_INFO_NUM_TILE_PIPES
35 #define RADEON_INFO_NUM_TILE_PIPES 0xb
38 #ifndef RADEON_INFO_BACKEND_MAP
39 #define RADEON_INFO_BACKEND_MAP 0xd
42 enum radeon_family
r600_get_family(struct radeon
*r600
)
47 enum chip_class
r600_get_family_class(struct radeon
*radeon
)
49 return radeon
->chip_class
;
52 struct r600_tiling_info
*r600_get_tiling_info(struct radeon
*radeon
)
54 return &radeon
->tiling_info
;
57 unsigned r600_get_clock_crystal_freq(struct radeon
*radeon
)
59 return radeon
->info
.r600_clock_crystal_freq
;
62 unsigned r600_get_num_backends(struct radeon
*radeon
)
64 return radeon
->info
.r600_num_backends
;
67 unsigned r600_get_num_tile_pipes(struct radeon
*radeon
)
69 return radeon
->info
.r600_num_tile_pipes
;
72 unsigned r600_get_backend_map(struct radeon
*radeon
)
74 return radeon
->info
.r600_backend_map
;
77 unsigned r600_get_minor_version(struct radeon
*radeon
)
79 return radeon
->info
.drm_minor
;
82 static int r600_interpret_tiling(struct radeon
*radeon
, uint32_t tiling_config
)
84 switch ((tiling_config
& 0xe) >> 1) {
86 radeon
->tiling_info
.num_channels
= 1;
89 radeon
->tiling_info
.num_channels
= 2;
92 radeon
->tiling_info
.num_channels
= 4;
95 radeon
->tiling_info
.num_channels
= 8;
101 switch ((tiling_config
& 0x30) >> 4) {
103 radeon
->tiling_info
.num_banks
= 4;
106 radeon
->tiling_info
.num_banks
= 8;
112 switch ((tiling_config
& 0xc0) >> 6) {
114 radeon
->tiling_info
.group_bytes
= 256;
117 radeon
->tiling_info
.group_bytes
= 512;
125 static int eg_interpret_tiling(struct radeon
*radeon
, uint32_t tiling_config
)
127 switch (tiling_config
& 0xf) {
129 radeon
->tiling_info
.num_channels
= 1;
132 radeon
->tiling_info
.num_channels
= 2;
135 radeon
->tiling_info
.num_channels
= 4;
138 radeon
->tiling_info
.num_channels
= 8;
144 switch ((tiling_config
& 0xf0) >> 4) {
146 radeon
->tiling_info
.num_banks
= 4;
149 radeon
->tiling_info
.num_banks
= 8;
152 radeon
->tiling_info
.num_banks
= 16;
159 switch ((tiling_config
& 0xf00) >> 8) {
161 radeon
->tiling_info
.group_bytes
= 256;
164 radeon
->tiling_info
.group_bytes
= 512;
172 static int radeon_drm_get_tiling(struct radeon
*radeon
)
174 uint32_t tiling_config
= radeon
->info
.r600_tiling_config
;
179 if (radeon
->chip_class
== R600
|| radeon
->chip_class
== R700
) {
180 return r600_interpret_tiling(radeon
, tiling_config
);
182 return eg_interpret_tiling(radeon
, tiling_config
);
186 struct radeon
*radeon_create(struct radeon_winsys
*ws
)
188 struct radeon
*radeon
= CALLOC_STRUCT(radeon
);
189 if (radeon
== NULL
) {
194 ws
->query_info(ws
, &radeon
->info
);
196 radeon
->family
= radeon_family_from_device(radeon
->info
.pci_id
);
197 if (radeon
->family
== CHIP_UNKNOWN
) {
198 fprintf(stderr
, "Unknown chipset 0x%04X\n", radeon
->info
.pci_id
);
199 return radeon_destroy(radeon
);
202 switch (radeon
->family
) {
211 radeon
->chip_class
= R600
;
212 /* set default group bytes, overridden by tiling info ioctl */
213 radeon
->tiling_info
.group_bytes
= 256;
219 radeon
->chip_class
= R700
;
220 /* set default group bytes, overridden by tiling info ioctl */
221 radeon
->tiling_info
.group_bytes
= 256;
234 radeon
->chip_class
= EVERGREEN
;
235 /* set default group bytes, overridden by tiling info ioctl */
236 radeon
->tiling_info
.group_bytes
= 512;
239 radeon
->chip_class
= CAYMAN
;
240 /* set default group bytes, overridden by tiling info ioctl */
241 radeon
->tiling_info
.group_bytes
= 512;
244 fprintf(stderr
, "%s unknown or unsupported chipset 0x%04X\n",
245 __func__
, radeon
->info
.pci_id
);
249 if (radeon_drm_get_tiling(radeon
))
255 struct radeon
*radeon_destroy(struct radeon
*radeon
)