radeon_acpi.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. printk(KERN_DEBUG "failed to evaluate ATIF got %s\n", acpi_format_exception(status));
  32. kfree(buffer.pointer);
  33. return 1;
  34. }
  35. kfree(buffer.pointer);
  36. return 0;
  37. }
  38. /* Call all ACPI methods here */
  39. int radeon_acpi_init(struct radeon_device *rdev)
  40. {
  41. acpi_handle handle;
  42. int ret;
  43. /* No need to proceed if we're sure that ATIF is not supported */
  44. if (!ASIC_IS_AVIVO(rdev) || !rdev->bios)
  45. return 0;
  46. /* Get the device handle */
  47. handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev);
  48. /* Call the ATIF method */
  49. ret = radeon_atif_call(handle);
  50. if (ret)
  51. return ret;
  52. return 0;
  53. }