24 #include <linux/pci.h>
26 #include <linux/slab.h>
40 #define ACPI_AC_CLASS "ac_adapter"
70 #define ATIF_NOTIFY_MASK 0x3
71 #define ATIF_NOTIFY_NONE 0
72 #define ATIF_NOTIFY_81 1
73 #define ATIF_NOTIFY_N 2
102 atif_arg.
pointer = &atif_arg_elements[0];
105 atif_arg_elements[0].
integer.value =
function;
114 atif_arg_elements[1].
integer.value = 0;
121 DRM_DEBUG_DRIVER(
"failed to evaluate ATIF got %s\n",
188 static int radeon_atif_verify_interface(
acpi_handle handle,
200 memset(&output, 0,
sizeof(output));
204 DRM_INFO(
"ATIF buffer is too small: %zu\n", size);
208 size =
min(
sizeof(output), size);
213 DRM_DEBUG_DRIVER(
"ATIF version %u\n",
output.version);
235 static int radeon_atif_get_notification_params(
acpi_handle handle,
255 memset(¶ms, 0,
sizeof(params));
256 size =
min(
sizeof(params), size);
259 DRM_DEBUG_DRIVER(
"SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
260 params.flags, params.valid_mask);
261 params.flags = params.flags & params.valid_mask;
279 DRM_DEBUG_DRIVER(
"Notification %s, command code = %#x\n",
280 (n->
enabled ?
"enabled" :
"disabled"),
297 static int radeon_atif_get_sbios_requests(
acpi_handle handle,
313 memset(req, 0,
sizeof(*req));
315 size =
min(
sizeof(*req), size);
317 DRM_DEBUG_DRIVER(
"SBIOS pending requests: %#x\n", req->
pending);
337 struct acpi_bus_event *
event)
344 DRM_DEBUG_DRIVER(
"event, device_class = %s, type = %#x\n",
345 event->device_class, event->type);
356 handle = DEVICE_ACPI_HANDLE(&rdev->
pdev->dev);
357 count = radeon_atif_get_sbios_requests(handle, &req);
362 DRM_DEBUG_DRIVER(
"ATIF: %d pending SBIOS requests\n", count);
368 DRM_DEBUG_DRIVER(
"Changing brightness to %d\n",
373 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
417 atcs_arg.pointer = &atcs_arg_elements[0];
420 atcs_arg_elements[0].integer.value =
function;
424 atcs_arg_elements[1].buffer.length = params->
length;
425 atcs_arg_elements[1].buffer.pointer = params->
pointer;
429 atcs_arg_elements[1].integer.value = 0;
436 DRM_DEBUG_DRIVER(
"failed to evaluate ATCS got %s\n",
474 static int radeon_atcs_verify_interface(
acpi_handle handle,
486 memset(&output, 0,
sizeof(output));
490 DRM_INFO(
"ATCS buffer is too small: %zu\n", size);
494 size =
min(
sizeof(output), size);
499 DRM_DEBUG_DRIVER(
"ATCS version %u\n",
output.version);
524 struct acpi_bus_event *
entry = (
struct acpi_bus_event *)data;
528 DRM_DEBUG_DRIVER(
"pm: AC\n");
530 DRM_DEBUG_DRIVER(
"pm: DC\n");
557 handle = DEVICE_ACPI_HANDLE(&rdev->
pdev->dev);
564 ret = radeon_atcs_verify_interface(handle, atcs);
566 DRM_DEBUG_DRIVER(
"Call to ATCS verify_interface failed: %d\n", ret);
570 ret = radeon_atif_verify_interface(handle, atif);
572 DRM_DEBUG_DRIVER(
"Call to ATIF verify_interface failed: %d\n", ret);
609 DRM_ERROR(
"Cannot find a backlight controller\n");
622 ret = radeon_atif_get_notification_params(handle,
625 DRM_DEBUG_DRIVER(
"Call to GET_SYSTEM_PARAMS failed: %d\n",
633 rdev->
acpi_nb.notifier_call = radeon_acpi_event;