fdcadffc532320611434f0796f88269e3fadde2f
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.
27 #include "radeon_drm.h"
28 #include "r600_priv.h"
30 enum radeon_family
r600_get_family(struct radeon
*r600
)
35 enum chip_class
r600_get_family_class(struct radeon
*radeon
)
37 return radeon
->chip_class
;
40 static int r600_get_device(struct radeon
*r600
)
42 struct drm_radeon_info info
;
45 info
.request
= RADEON_INFO_DEVICE_ID
;
46 info
.value
= (uintptr_t)&r600
->device
;
47 return drmCommandWriteRead(r600
->fd
, DRM_RADEON_INFO
, &info
, sizeof(struct drm_radeon_info
));
50 struct radeon
*r600_new(int fd
, unsigned device
)
55 r600
= calloc(1, sizeof(*r600
));
60 r600
->device
= device
;
62 r
= r600_get_device(r600
);
64 R600_ERR("Failed to get device id\n");
69 r600
->family
= radeon_family_from_device(r600
->device
);
70 if (r600
->family
== CHIP_UNKNOWN
) {
71 R600_ERR("Unknown chipset 0x%04X\n", r600
->device
);
75 switch (r600
->family
) {
122 R600_ERR("unknown or unsupported chipset 0x%04X\n", r600
->device
);
127 switch (r600
->family
) {
136 r600
->chip_class
= R600
;
142 r600
->chip_class
= R700
;
149 r600
->chip_class
= EVERGREEN
;
152 R600_ERR("unknown or unsupported chipset 0x%04X\n", r600
->device
);
159 void r600_delete(struct radeon
*r600
)