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