2 * Copyright 2012 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
24 #include <linux/pci.h>
25 #include <linux/acpi.h>
26 #include <linux/slab.h>
27 #include <linux/power_supply.h>
28 #include <linux/pm_runtime.h>
29 #include <acpi/video.h>
30 #include <acpi/actbl.h>
32 #include <drm/drm_crtc_helper.h>
34 #include "amdgpu_pm.h"
35 #include "amdgpu_display.h"
39 struct amdgpu_atif_notification_cfg {
44 struct amdgpu_atif_notifications {
46 bool forced_power_state;
47 bool system_power_state;
48 bool brightness_change;
49 bool dgpu_display_event;
50 bool gpu_package_power_limit;
53 struct amdgpu_atif_functions {
56 bool temperature_change;
57 bool query_backlight_transfer_characteristics;
59 bool external_gpu_information;
65 struct amdgpu_atif_notifications notifications;
66 struct amdgpu_atif_functions functions;
67 struct amdgpu_atif_notification_cfg notification_cfg;
68 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
69 struct backlight_device *bd;
71 struct amdgpu_dm_backlight_caps backlight_caps;
74 /* Call the ATIF method
77 * amdgpu_atif_call - call an ATIF method
79 * @handle: acpi handle
80 * @function: the ATIF function to execute
81 * @params: ATIF function params
83 * Executes the requested ATIF function (all asics).
84 * Returns a pointer to the acpi output buffer.
86 static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
88 struct acpi_buffer *params)
91 union acpi_object atif_arg_elements[2];
92 struct acpi_object_list atif_arg;
93 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
96 atif_arg.pointer = &atif_arg_elements[0];
98 atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
99 atif_arg_elements[0].integer.value = function;
102 atif_arg_elements[1].type = ACPI_TYPE_BUFFER;
103 atif_arg_elements[1].buffer.length = params->length;
104 atif_arg_elements[1].buffer.pointer = params->pointer;
106 /* We need a second fake parameter */
107 atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
108 atif_arg_elements[1].integer.value = 0;
111 status = acpi_evaluate_object(atif->handle, NULL, &atif_arg,
114 /* Fail only if calling the method fails and ATIF is supported */
115 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
116 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
117 acpi_format_exception(status));
118 kfree(buffer.pointer);
122 return buffer.pointer;
126 * amdgpu_atif_parse_notification - parse supported notifications
128 * @n: supported notifications struct
129 * @mask: supported notifications mask from ATIF
131 * Use the supported notifications mask from ATIF function
132 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
133 * are supported (all asics).
135 static void amdgpu_atif_parse_notification(struct amdgpu_atif_notifications *n, u32 mask)
137 n->thermal_state = mask & ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED;
138 n->forced_power_state = mask & ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED;
139 n->system_power_state = mask & ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED;
140 n->brightness_change = mask & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED;
141 n->dgpu_display_event = mask & ATIF_DGPU_DISPLAY_EVENT_SUPPORTED;
142 n->gpu_package_power_limit = mask & ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST_SUPPORTED;
146 * amdgpu_atif_parse_functions - parse supported functions
148 * @f: supported functions struct
149 * @mask: supported functions mask from ATIF
151 * Use the supported functions mask from ATIF function
152 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
153 * are supported (all asics).
155 static void amdgpu_atif_parse_functions(struct amdgpu_atif_functions *f, u32 mask)
157 f->system_params = mask & ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED;
158 f->sbios_requests = mask & ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED;
159 f->temperature_change = mask & ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED;
160 f->query_backlight_transfer_characteristics =
161 mask & ATIF_QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS_SUPPORTED;
162 f->ready_to_undock = mask & ATIF_READY_TO_UNDOCK_NOTIFICATION_SUPPORTED;
163 f->external_gpu_information = mask & ATIF_GET_EXTERNAL_GPU_INFORMATION_SUPPORTED;
167 * amdgpu_atif_verify_interface - verify ATIF
169 * @handle: acpi handle
170 * @atif: amdgpu atif struct
172 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
173 * to initialize ATIF and determine what features are supported
175 * returns 0 on success, error on failure.
177 static int amdgpu_atif_verify_interface(struct amdgpu_atif *atif)
179 union acpi_object *info;
180 struct atif_verify_interface output;
184 info = amdgpu_atif_call(atif, ATIF_FUNCTION_VERIFY_INTERFACE, NULL);
188 memset(&output, 0, sizeof(output));
190 size = *(u16 *) info->buffer.pointer;
192 DRM_INFO("ATIF buffer is too small: %zu\n", size);
196 size = min(sizeof(output), size);
198 memcpy(&output, info->buffer.pointer, size);
200 /* TODO: check version? */
201 DRM_DEBUG_DRIVER("ATIF version %u\n", output.version);
203 amdgpu_atif_parse_notification(&atif->notifications, output.notification_mask);
204 amdgpu_atif_parse_functions(&atif->functions, output.function_bits);
211 static acpi_handle amdgpu_atif_probe_handle(acpi_handle dhandle)
213 acpi_handle handle = NULL;
214 char acpi_method_name[255] = { 0 };
215 struct acpi_buffer buffer = { sizeof(acpi_method_name), acpi_method_name };
218 /* For PX/HG systems, ATIF and ATPX are in the iGPU's namespace, on dGPU only
219 * systems, ATIF is in the dGPU's namespace.
221 status = acpi_get_handle(dhandle, "ATIF", &handle);
222 if (ACPI_SUCCESS(status))
225 if (amdgpu_has_atpx()) {
226 status = acpi_get_handle(amdgpu_atpx_get_dhandle(), "ATIF",
228 if (ACPI_SUCCESS(status))
232 DRM_DEBUG_DRIVER("No ATIF handle found\n");
235 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
236 DRM_DEBUG_DRIVER("Found ATIF handle %s\n", acpi_method_name);
241 * amdgpu_atif_get_notification_params - determine notify configuration
243 * @handle: acpi handle
244 * @n: atif notification configuration struct
246 * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
247 * to determine if a notifier is used and if so which one
248 * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n)
249 * where n is specified in the result if a notifier is used.
250 * Returns 0 on success, error on failure.
252 static int amdgpu_atif_get_notification_params(struct amdgpu_atif *atif)
254 union acpi_object *info;
255 struct amdgpu_atif_notification_cfg *n = &atif->notification_cfg;
256 struct atif_system_params params;
260 info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS,
267 size = *(u16 *) info->buffer.pointer;
273 memset(¶ms, 0, sizeof(params));
274 size = min(sizeof(params), size);
275 memcpy(¶ms, info->buffer.pointer, size);
277 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
278 params.flags, params.valid_mask);
279 params.flags = params.flags & params.valid_mask;
281 if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_NONE) {
284 } else if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_81) {
286 n->command_code = 0x81;
293 n->command_code = params.command_code;
297 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
298 (n->enabled ? "enabled" : "disabled"),
305 * amdgpu_atif_query_backlight_caps - get min and max backlight input signal
307 * @handle: acpi handle
309 * Execute the QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS ATIF function
310 * to determine the acceptable range of backlight values
312 * Backlight_caps.caps_valid will be set to true if the query is successful
314 * The input signals are in range 0-255
316 * This function assumes the display with backlight is the first LCD
318 * Returns 0 on success, error on failure.
320 static int amdgpu_atif_query_backlight_caps(struct amdgpu_atif *atif)
322 union acpi_object *info;
323 struct atif_qbtc_output characteristics;
324 struct atif_qbtc_arguments arguments;
325 struct acpi_buffer params;
329 arguments.size = sizeof(arguments);
330 arguments.requested_display = ATIF_QBTC_REQUEST_LCD1;
332 params.length = sizeof(arguments);
333 params.pointer = (void *)&arguments;
335 info = amdgpu_atif_call(atif,
336 ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS,
343 size = *(u16 *) info->buffer.pointer;
349 memset(&characteristics, 0, sizeof(characteristics));
350 size = min(sizeof(characteristics), size);
351 memcpy(&characteristics, info->buffer.pointer, size);
353 atif->backlight_caps.caps_valid = true;
354 atif->backlight_caps.min_input_signal =
355 characteristics.min_input_signal;
356 atif->backlight_caps.max_input_signal =
357 characteristics.max_input_signal;
364 * amdgpu_atif_get_sbios_requests - get requested sbios event
366 * @handle: acpi handle
367 * @req: atif sbios request struct
369 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
370 * to determine what requests the sbios is making to the driver
372 * Returns 0 on success, error on failure.
374 static int amdgpu_atif_get_sbios_requests(struct amdgpu_atif *atif,
375 struct atif_sbios_requests *req)
377 union acpi_object *info;
381 info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS,
386 size = *(u16 *)info->buffer.pointer;
391 memset(req, 0, sizeof(*req));
393 size = min(sizeof(*req), size);
394 memcpy(req, info->buffer.pointer, size);
395 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req->pending);
397 count = hweight32(req->pending);
405 * amdgpu_atif_handler - handle ATIF notify requests
407 * @adev: amdgpu_device pointer
408 * @event: atif sbios request struct
410 * Checks the acpi event and if it matches an atif event,
414 * NOTIFY_BAD or NOTIFY_DONE, depending on the event.
416 static int amdgpu_atif_handler(struct amdgpu_device *adev,
417 struct acpi_bus_event *event)
419 struct amdgpu_atif *atif = adev->atif;
422 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
423 event->device_class, event->type);
425 if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0)
428 /* Is this actually our event? */
430 !atif->notification_cfg.enabled ||
431 event->type != atif->notification_cfg.command_code) {
432 /* These events will generate keypresses otherwise */
433 if (event->type == ACPI_VIDEO_NOTIFY_PROBE)
439 if (atif->functions.sbios_requests) {
440 struct atif_sbios_requests req;
442 /* Check pending SBIOS requests */
443 count = amdgpu_atif_get_sbios_requests(atif, &req);
448 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
450 if (req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) {
451 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
453 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
454 req.backlight_level);
456 * XXX backlight_device_set_brightness() is
457 * hardwired to post BACKLIGHT_UPDATE_SYSFS.
458 * It probably should accept 'reason' parameter.
460 backlight_device_set_brightness(atif->bd, req.backlight_level);
465 if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
466 if (adev->flags & AMD_IS_PX) {
467 pm_runtime_get_sync(adev_to_drm(adev)->dev);
468 /* Just fire off a uevent and let userspace tell us what to do */
469 drm_helper_hpd_irq_event(adev_to_drm(adev));
470 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
471 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
474 /* TODO: check other events */
477 /* We've handled the event, stop the notifier chain. The ACPI interface
478 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
479 * userspace if the event was generated only to signal a SBIOS
485 /* Call the ATCS method
488 * amdgpu_atcs_call - call an ATCS method
490 * @handle: acpi handle
491 * @function: the ATCS function to execute
492 * @params: ATCS function params
494 * Executes the requested ATCS function (all asics).
495 * Returns a pointer to the acpi output buffer.
497 static union acpi_object *amdgpu_atcs_call(acpi_handle handle, int function,
498 struct acpi_buffer *params)
501 union acpi_object atcs_arg_elements[2];
502 struct acpi_object_list atcs_arg;
503 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
506 atcs_arg.pointer = &atcs_arg_elements[0];
508 atcs_arg_elements[0].type = ACPI_TYPE_INTEGER;
509 atcs_arg_elements[0].integer.value = function;
512 atcs_arg_elements[1].type = ACPI_TYPE_BUFFER;
513 atcs_arg_elements[1].buffer.length = params->length;
514 atcs_arg_elements[1].buffer.pointer = params->pointer;
516 /* We need a second fake parameter */
517 atcs_arg_elements[1].type = ACPI_TYPE_INTEGER;
518 atcs_arg_elements[1].integer.value = 0;
521 status = acpi_evaluate_object(handle, "ATCS", &atcs_arg, &buffer);
523 /* Fail only if calling the method fails and ATIF is supported */
524 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
525 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
526 acpi_format_exception(status));
527 kfree(buffer.pointer);
531 return buffer.pointer;
535 * amdgpu_atcs_parse_functions - parse supported functions
537 * @f: supported functions struct
538 * @mask: supported functions mask from ATCS
540 * Use the supported functions mask from ATCS function
541 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
542 * are supported (all asics).
544 static void amdgpu_atcs_parse_functions(struct amdgpu_atcs_functions *f, u32 mask)
546 f->get_ext_state = mask & ATCS_GET_EXTERNAL_STATE_SUPPORTED;
547 f->pcie_perf_req = mask & ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED;
548 f->pcie_dev_rdy = mask & ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED;
549 f->pcie_bus_width = mask & ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED;
553 * amdgpu_atcs_verify_interface - verify ATCS
555 * @handle: acpi handle
556 * @atcs: amdgpu atcs struct
558 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
559 * to initialize ATCS and determine what features are supported
561 * returns 0 on success, error on failure.
563 static int amdgpu_atcs_verify_interface(acpi_handle handle,
564 struct amdgpu_atcs *atcs)
566 union acpi_object *info;
567 struct atcs_verify_interface output;
571 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_VERIFY_INTERFACE, NULL);
575 memset(&output, 0, sizeof(output));
577 size = *(u16 *) info->buffer.pointer;
579 DRM_INFO("ATCS buffer is too small: %zu\n", size);
583 size = min(sizeof(output), size);
585 memcpy(&output, info->buffer.pointer, size);
587 /* TODO: check version? */
588 DRM_DEBUG_DRIVER("ATCS version %u\n", output.version);
590 amdgpu_atcs_parse_functions(&atcs->functions, output.function_bits);
598 * amdgpu_acpi_is_pcie_performance_request_supported
600 * @adev: amdgpu_device pointer
602 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
603 * are supported (all asics).
604 * returns true if supported, false if not.
606 bool amdgpu_acpi_is_pcie_performance_request_supported(struct amdgpu_device *adev)
608 struct amdgpu_atcs *atcs = &adev->atcs;
610 if (atcs->functions.pcie_perf_req && atcs->functions.pcie_dev_rdy)
617 * amdgpu_acpi_pcie_notify_device_ready
619 * @adev: amdgpu_device pointer
621 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
623 * returns 0 on success, error on failure.
625 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev)
628 union acpi_object *info;
629 struct amdgpu_atcs *atcs = &adev->atcs;
631 /* Get the device handle */
632 handle = ACPI_HANDLE(&adev->pdev->dev);
636 if (!atcs->functions.pcie_dev_rdy)
639 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION, NULL);
649 * amdgpu_acpi_pcie_performance_request
651 * @adev: amdgpu_device pointer
652 * @perf_req: requested perf level (pcie gen speed)
653 * @advertise: set advertise caps flag if set
655 * Executes the PCIE_PERFORMANCE_REQUEST method to
656 * change the pcie gen speed (all asics).
657 * returns 0 on success, error on failure.
659 int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
660 u8 perf_req, bool advertise)
663 union acpi_object *info;
664 struct amdgpu_atcs *atcs = &adev->atcs;
665 struct atcs_pref_req_input atcs_input;
666 struct atcs_pref_req_output atcs_output;
667 struct acpi_buffer params;
671 if (amdgpu_acpi_pcie_notify_device_ready(adev))
674 /* Get the device handle */
675 handle = ACPI_HANDLE(&adev->pdev->dev);
679 if (!atcs->functions.pcie_perf_req)
682 atcs_input.size = sizeof(struct atcs_pref_req_input);
683 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
684 atcs_input.client_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
685 atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
686 atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
688 atcs_input.flags |= ATCS_ADVERTISE_CAPS;
689 atcs_input.req_type = ATCS_PCIE_LINK_SPEED;
690 atcs_input.perf_req = perf_req;
692 params.length = sizeof(struct atcs_pref_req_input);
693 params.pointer = &atcs_input;
696 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST, ¶ms);
700 memset(&atcs_output, 0, sizeof(atcs_output));
702 size = *(u16 *) info->buffer.pointer;
704 DRM_INFO("ATCS buffer is too small: %zu\n", size);
708 size = min(sizeof(atcs_output), size);
710 memcpy(&atcs_output, info->buffer.pointer, size);
714 switch (atcs_output.ret_val) {
715 case ATCS_REQUEST_REFUSED:
718 case ATCS_REQUEST_COMPLETE:
720 case ATCS_REQUEST_IN_PROGRESS:
730 * amdgpu_acpi_event - handle notify events
732 * @nb: notifier block
736 * Calls relevant amdgpu functions in response to various
738 * Returns NOTIFY code
740 static int amdgpu_acpi_event(struct notifier_block *nb,
744 struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, acpi_nb);
745 struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
747 if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) {
748 if (power_supply_is_system_supplied() > 0)
749 DRM_DEBUG_DRIVER("pm: AC\n");
751 DRM_DEBUG_DRIVER("pm: DC\n");
753 amdgpu_pm_acpi_event_handler(adev);
756 /* Check for pending SBIOS requests */
757 return amdgpu_atif_handler(adev, entry);
760 /* Call all ACPI methods here */
762 * amdgpu_acpi_init - init driver acpi support
764 * @adev: amdgpu_device pointer
766 * Verifies the AMD ACPI interfaces and registers with the acpi
767 * notifier chain (all asics).
768 * Returns 0 on success, error on failure.
770 int amdgpu_acpi_init(struct amdgpu_device *adev)
772 acpi_handle handle, atif_handle;
773 struct amdgpu_atif *atif;
774 struct amdgpu_atcs *atcs = &adev->atcs;
777 /* Get the device handle */
778 handle = ACPI_HANDLE(&adev->pdev->dev);
780 if (!adev->bios || !handle)
783 /* Call the ATCS method */
784 ret = amdgpu_atcs_verify_interface(handle, atcs);
786 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret);
789 /* Probe for ATIF, and initialize it if found */
790 atif_handle = amdgpu_atif_probe_handle(handle);
794 atif = kzalloc(sizeof(*atif), GFP_KERNEL);
796 DRM_WARN("Not enough memory to initialize ATIF\n");
799 atif->handle = atif_handle;
801 /* Call the ATIF method */
802 ret = amdgpu_atif_verify_interface(atif);
804 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret);
810 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
811 if (atif->notifications.brightness_change) {
812 if (amdgpu_device_has_dc_support(adev)) {
813 #if defined(CONFIG_DRM_AMD_DC)
814 struct amdgpu_display_manager *dm = &adev->dm;
815 atif->bd = dm->backlight_dev;
818 struct drm_encoder *tmp;
820 /* Find the encoder controlling the brightness */
821 list_for_each_entry(tmp, &adev_to_drm(adev)->mode_config.encoder_list,
823 struct amdgpu_encoder *enc = to_amdgpu_encoder(tmp);
825 if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
827 struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
829 atif->bd = dig->bl_dev;
838 if (atif->functions.sbios_requests && !atif->functions.system_params) {
839 /* XXX check this workraround, if sbios request function is
840 * present we have to see how it's configured in the system
843 atif->functions.system_params = true;
846 if (atif->functions.system_params) {
847 ret = amdgpu_atif_get_notification_params(atif);
849 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
851 /* Disable notification */
852 atif->notification_cfg.enabled = false;
856 if (atif->functions.query_backlight_transfer_characteristics) {
857 ret = amdgpu_atif_query_backlight_caps(atif);
859 DRM_DEBUG_DRIVER("Call to QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS failed: %d\n",
861 atif->backlight_caps.caps_valid = false;
864 atif->backlight_caps.caps_valid = false;
868 adev->acpi_nb.notifier_call = amdgpu_acpi_event;
869 register_acpi_notifier(&adev->acpi_nb);
874 void amdgpu_acpi_get_backlight_caps(struct amdgpu_device *adev,
875 struct amdgpu_dm_backlight_caps *caps)
878 caps->caps_valid = false;
881 caps->caps_valid = adev->atif->backlight_caps.caps_valid;
882 caps->min_input_signal = adev->atif->backlight_caps.min_input_signal;
883 caps->max_input_signal = adev->atif->backlight_caps.max_input_signal;
887 * amdgpu_acpi_fini - tear down driver acpi support
889 * @adev: amdgpu_device pointer
891 * Unregisters with the acpi notifier chain (all asics).
893 void amdgpu_acpi_fini(struct amdgpu_device *adev)
895 unregister_acpi_notifier(&adev->acpi_nb);
900 * amdgpu_acpi_is_s0ix_supported
902 * returns true if supported, false if not.
904 bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev)
906 #if defined(CONFIG_AMD_PMC) || defined(CONFIG_AMD_PMC_MODULE)
907 if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
908 if (adev->flags & AMD_IS_APU)