Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

r600_drm.c 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
  3. *
  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:
  10. *
  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
  13. * Software.
  14. *
  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.
  22. *
  23. * Authors:
  24. * Jerome Glisse
  25. * Corbin Simpson <MostAwesomeDude@gmail.com>
  26. * Joakim Sindholt <opensource@zhasha.com>
  27. */
  28. #include "r600_priv.h"
  29. #include "util/u_memory.h"
  30. #include <errno.h>
  31. enum radeon_family r600_get_family(struct radeon *r600)
  32. {
  33. return r600->family;
  34. }
  35. enum chip_class r600_get_family_class(struct radeon *radeon)
  36. {
  37. return radeon->chip_class;
  38. }
  39. static unsigned radeon_family_from_device(unsigned device)
  40. {
  41. switch (device) {
  42. #define CHIPSET(pciid, name, family) case pciid: return CHIP_##family;
  43. #include "pci_ids/r600_pci_ids.h"
  44. #undef CHIPSET
  45. default:
  46. return CHIP_UNKNOWN;
  47. }
  48. }
  49. struct radeon *radeon_create(struct radeon_winsys *ws)
  50. {
  51. struct radeon *radeon = CALLOC_STRUCT(radeon);
  52. if (radeon == NULL) {
  53. return NULL;
  54. }
  55. radeon->ws = ws;
  56. ws->query_info(ws, &radeon->info);
  57. radeon->family = radeon_family_from_device(radeon->info.pci_id);
  58. if (radeon->family == CHIP_UNKNOWN) {
  59. fprintf(stderr, "Unknown chipset 0x%04X\n", radeon->info.pci_id);
  60. return radeon_destroy(radeon);
  61. }
  62. /* setup class */
  63. if (radeon->family == CHIP_CAYMAN) {
  64. radeon->chip_class = CAYMAN;
  65. } else if (radeon->family >= CHIP_CEDAR) {
  66. radeon->chip_class = EVERGREEN;
  67. } else if (radeon->family >= CHIP_RV730) {
  68. radeon->chip_class = R700;
  69. } else {
  70. radeon->chip_class = R600;
  71. }
  72. return radeon;
  73. }
  74. struct radeon *radeon_destroy(struct radeon *radeon)
  75. {
  76. if (radeon == NULL)
  77. return NULL;
  78. FREE(radeon);
  79. return NULL;
  80. }