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