radeon_acpi.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include <linux/pci.h>
  2. #include <linux/acpi.h>
  3. #include <linux/slab.h>
  4. #include <acpi/acpi_drivers.h>
  5. #include <acpi/acpi_bus.h>
  6. #include "drmP.h"
  7. #include "drm.h"
  8. #include "drm_sarea.h"
  9. #include "drm_crtc_helper.h"
  10. #include "radeon.h"
  11. #include <linux/vga_switcheroo.h>
  12. /* Call the ATIF method
  13. *
  14. * Note: currently we discard the output
  15. */
  16. static int radeon_atif_call(acpi_handle handle)
  17. {
  18. acpi_status status;
  19. union acpi_object atif_arg_elements[2];
  20. struct acpi_object_list atif_arg;
  21. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
  22. atif_arg.count = 2;
  23. atif_arg.pointer = &atif_arg_elements[0];
  24. atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
  25. atif_arg_elements[0].integer.value = 0;
  26. atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
  27. atif_arg_elements[1].integer.value = 0;
  28. status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer);
  29. /* Fail only if calling the method fails and ATIF is supported */
  30. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  31. DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
  32. acpi_format_exception(status));
  33. kfree(buffer.pointer);
  34. return 1;
  35. }
  36. kfree(buffer.pointer);
  37. return 0;
  38. }
  39. /* Call all ACPI methods here */
  40. int radeon_acpi_init(struct radeon_device *rdev)
  41. {
  42. acpi_handle handle;
  43. int ret;
  44. /* Get the device handle */
  45. handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev);
  46. /* No need to proceed if we're sure that ATIF is not supported */
  47. if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
  48. return 0;
  49. /* Call the ATIF method */
  50. ret = radeon_atif_call(handle);
  51. if (ret)
  52. return ret;
  53. return 0;
  54. }