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>
31 #include <drm/drm_crtc_helper.h>
33 #include "amdgpu_pm.h"
34 #include "amdgpu_display.h"
38 struct amdgpu_atif_notification_cfg {
43 struct amdgpu_atif_notifications {
45 bool forced_power_state;
46 bool system_power_state;
47 bool brightness_change;
48 bool dgpu_display_event;
49 bool gpu_package_power_limit;
52 struct amdgpu_atif_functions {
55 bool temperature_change;
56 bool query_backlight_transfer_characteristics;
58 bool external_gpu_information;
64 struct amdgpu_atif_notifications notifications;
65 struct amdgpu_atif_functions functions;
66 struct amdgpu_atif_notification_cfg notification_cfg;
67 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
68 struct backlight_device *bd;
70 struct amdgpu_dm_backlight_caps backlight_caps;
73 /* Call the ATIF method
76 * amdgpu_atif_call - call an ATIF method
78 * @handle: acpi handle
79 * @function: the ATIF function to execute
80 * @params: ATIF function params
82 * Executes the requested ATIF function (all asics).
83 * Returns a pointer to the acpi output buffer.
85 static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
87 struct acpi_buffer *params)
90 union acpi_object atif_arg_elements[2];
91 struct acpi_object_list atif_arg;
92 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
95 atif_arg.pointer = &atif_arg_elements[0];
97 atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
98 atif_arg_elements[0].integer.value = function;
101 atif_arg_elements[1].type = ACPI_TYPE_BUFFER;
102 atif_arg_elements[1].buffer.length = params->length;
103 atif_arg_elements[1].buffer.pointer = params->pointer;
105 /* We need a second fake parameter */
106 atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
107 atif_arg_elements[1].integer.value = 0;
110 status = acpi_evaluate_object(atif->handle, NULL, &atif_arg,
113 /* Fail only if calling the method fails and ATIF is supported */
114 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
115 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
116 acpi_format_exception(status));
117 kfree(buffer.pointer);
121 return buffer.pointer;
125 * amdgpu_atif_parse_notification - parse supported notifications
127 * @n: supported notifications struct
128 * @mask: supported notifications mask from ATIF
130 * Use the supported notifications mask from ATIF function
131 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
132 * are supported (all asics).
134 static void amdgpu_atif_parse_notification(struct amdgpu_atif_notifications *n, u32 mask)
136 n->thermal_state = mask & ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED;
137 n->forced_power_state = mask & ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED;
138 n->system_power_state = mask & ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED;
139 n->brightness_change = mask & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED;
140 n->dgpu_display_event = mask & ATIF_DGPU_DISPLAY_EVENT_SUPPORTED;
141 n->gpu_package_power_limit = mask & ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST_SUPPORTED;
145 * amdgpu_atif_parse_functions - parse supported functions
147 * @f: supported functions struct
148 * @mask: supported functions mask from ATIF
150 * Use the supported functions mask from ATIF function
151 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
152 * are supported (all asics).
154 static void amdgpu_atif_parse_functions(struct amdgpu_atif_functions *f, u32 mask)
156 f->system_params = mask & ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED;
157 f->sbios_requests = mask & ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED;
158 f->temperature_change = mask & ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED;
159 f->query_backlight_transfer_characteristics =
160 mask & ATIF_QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS_SUPPORTED;
161 f->ready_to_undock = mask & ATIF_READY_TO_UNDOCK_NOTIFICATION_SUPPORTED;
162 f->external_gpu_information = mask & ATIF_GET_EXTERNAL_GPU_INFORMATION_SUPPORTED;
166 * amdgpu_atif_verify_interface - verify ATIF
168 * @handle: acpi handle
169 * @atif: amdgpu atif struct
171 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
172 * to initialize ATIF and determine what features are supported
174 * returns 0 on success, error on failure.
176 static int amdgpu_atif_verify_interface(struct amdgpu_atif *atif)
178 union acpi_object *info;
179 struct atif_verify_interface output;
183 info = amdgpu_atif_call(atif, ATIF_FUNCTION_VERIFY_INTERFACE, NULL);
187 memset(&output, 0, sizeof(output));
189 size = *(u16 *) info->buffer.pointer;
191 DRM_INFO("ATIF buffer is too small: %zu\n", size);
195 size = min(sizeof(output), size);
197 memcpy(&output, info->buffer.pointer, size);
199 /* TODO: check version? */
200 DRM_DEBUG_DRIVER("ATIF version %u\n", output.version);
202 amdgpu_atif_parse_notification(&atif->notifications, output.notification_mask);
203 amdgpu_atif_parse_functions(&atif->functions, output.function_bits);
210 static acpi_handle amdgpu_atif_probe_handle(acpi_handle dhandle)
212 acpi_handle handle = NULL;
213 char acpi_method_name[255] = { 0 };
214 struct acpi_buffer buffer = { sizeof(acpi_method_name), acpi_method_name };
217 /* For PX/HG systems, ATIF and ATPX are in the iGPU's namespace, on dGPU only
218 * systems, ATIF is in the dGPU's namespace.
220 status = acpi_get_handle(dhandle, "ATIF", &handle);
221 if (ACPI_SUCCESS(status))
224 if (amdgpu_has_atpx()) {
225 status = acpi_get_handle(amdgpu_atpx_get_dhandle(), "ATIF",
227 if (ACPI_SUCCESS(status))
231 DRM_DEBUG_DRIVER("No ATIF handle found\n");
234 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
235 DRM_DEBUG_DRIVER("Found ATIF handle %s\n", acpi_method_name);
240 * amdgpu_atif_get_notification_params - determine notify configuration
242 * @handle: acpi handle
243 * @n: atif notification configuration struct
245 * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
246 * to determine if a notifier is used and if so which one
247 * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n)
248 * where n is specified in the result if a notifier is used.
249 * Returns 0 on success, error on failure.
251 static int amdgpu_atif_get_notification_params(struct amdgpu_atif *atif)
253 union acpi_object *info;
254 struct amdgpu_atif_notification_cfg *n = &atif->notification_cfg;
255 struct atif_system_params params;
259 info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS,
266 size = *(u16 *) info->buffer.pointer;
272 memset(¶ms, 0, sizeof(params));
273 size = min(sizeof(params), size);
274 memcpy(¶ms, info->buffer.pointer, size);
276 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
277 params.flags, params.valid_mask);
278 params.flags = params.flags & params.valid_mask;
280 if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_NONE) {
283 } else if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_81) {
285 n->command_code = 0x81;
292 n->command_code = params.command_code;
296 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
297 (n->enabled ? "enabled" : "disabled"),
304 * amdgpu_atif_query_backlight_caps - get min and max backlight input signal
306 * @handle: acpi handle
308 * Execute the QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS ATIF function
309 * to determine the acceptable range of backlight values
311 * Backlight_caps.caps_valid will be set to true if the query is successful
313 * The input signals are in range 0-255
315 * This function assumes the display with backlight is the first LCD
317 * Returns 0 on success, error on failure.
319 static int amdgpu_atif_query_backlight_caps(struct amdgpu_atif *atif)
321 union acpi_object *info;
322 struct atif_qbtc_output characteristics;
323 struct atif_qbtc_arguments arguments;
324 struct acpi_buffer params;
328 arguments.size = sizeof(arguments);
329 arguments.requested_display = ATIF_QBTC_REQUEST_LCD1;
331 params.length = sizeof(arguments);
332 params.pointer = (void *)&arguments;
334 info = amdgpu_atif_call(atif,
335 ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS,
342 size = *(u16 *) info->buffer.pointer;
348 memset(&characteristics, 0, sizeof(characteristics));
349 size = min(sizeof(characteristics), size);
350 memcpy(&characteristics, info->buffer.pointer, size);
352 atif->backlight_caps.caps_valid = true;
353 atif->backlight_caps.min_input_signal =
354 characteristics.min_input_signal;
355 atif->backlight_caps.max_input_signal =
356 characteristics.max_input_signal;
363 * amdgpu_atif_get_sbios_requests - get requested sbios event
365 * @handle: acpi handle
366 * @req: atif sbios request struct
368 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
369 * to determine what requests the sbios is making to the driver
371 * Returns 0 on success, error on failure.
373 static int amdgpu_atif_get_sbios_requests(struct amdgpu_atif *atif,
374 struct atif_sbios_requests *req)
376 union acpi_object *info;
380 info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS,
385 size = *(u16 *)info->buffer.pointer;
390 memset(req, 0, sizeof(*req));
392 size = min(sizeof(*req), size);
393 memcpy(req, info->buffer.pointer, size);
394 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req->pending);
396 count = hweight32(req->pending);
404 * amdgpu_atif_handler - handle ATIF notify requests
406 * @adev: amdgpu_device pointer
407 * @event: atif sbios request struct
409 * Checks the acpi event and if it matches an atif event,
413 * NOTIFY_BAD or NOTIFY_DONE, depending on the event.
415 static int amdgpu_atif_handler(struct amdgpu_device *adev,
416 struct acpi_bus_event *event)
418 struct amdgpu_atif *atif = adev->atif;
421 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
422 event->device_class, event->type);
424 if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0)
427 /* Is this actually our event? */
429 !atif->notification_cfg.enabled ||
430 event->type != atif->notification_cfg.command_code) {
431 /* These events will generate keypresses otherwise */
432 if (event->type == ACPI_VIDEO_NOTIFY_PROBE)
438 if (atif->functions.sbios_requests) {
439 struct atif_sbios_requests req;
441 /* Check pending SBIOS requests */
442 count = amdgpu_atif_get_sbios_requests(atif, &req);
447 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
449 if (req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) {
450 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
452 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
453 req.backlight_level);
455 * XXX backlight_device_set_brightness() is
456 * hardwired to post BACKLIGHT_UPDATE_SYSFS.
457 * It probably should accept 'reason' parameter.
459 backlight_device_set_brightness(atif->bd, req.backlight_level);
464 if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
465 if (adev->flags & AMD_IS_PX) {
466 pm_runtime_get_sync(adev->ddev->dev);
467 /* Just fire off a uevent and let userspace tell us what to do */
468 drm_helper_hpd_irq_event(adev->ddev);
469 pm_runtime_mark_last_busy(adev->ddev->dev);
470 pm_runtime_put_autosuspend(adev->ddev->dev);
473 /* TODO: check other events */
476 /* We've handled the event, stop the notifier chain. The ACPI interface
477 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
478 * userspace if the event was generated only to signal a SBIOS
484 /* Call the ATCS method
487 * amdgpu_atcs_call - call an ATCS method
489 * @handle: acpi handle
490 * @function: the ATCS function to execute
491 * @params: ATCS function params
493 * Executes the requested ATCS function (all asics).
494 * Returns a pointer to the acpi output buffer.
496 static union acpi_object *amdgpu_atcs_call(acpi_handle handle, int function,
497 struct acpi_buffer *params)
500 union acpi_object atcs_arg_elements[2];
501 struct acpi_object_list atcs_arg;
502 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
505 atcs_arg.pointer = &atcs_arg_elements[0];
507 atcs_arg_elements[0].type = ACPI_TYPE_INTEGER;
508 atcs_arg_elements[0].integer.value = function;
511 atcs_arg_elements[1].type = ACPI_TYPE_BUFFER;
512 atcs_arg_elements[1].buffer.length = params->length;
513 atcs_arg_elements[1].buffer.pointer = params->pointer;
515 /* We need a second fake parameter */
516 atcs_arg_elements[1].type = ACPI_TYPE_INTEGER;
517 atcs_arg_elements[1].integer.value = 0;
520 status = acpi_evaluate_object(handle, "ATCS", &atcs_arg, &buffer);
522 /* Fail only if calling the method fails and ATIF is supported */
523 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
524 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
525 acpi_format_exception(status));
526 kfree(buffer.pointer);
530 return buffer.pointer;
534 * amdgpu_atcs_parse_functions - parse supported functions
536 * @f: supported functions struct
537 * @mask: supported functions mask from ATCS
539 * Use the supported functions mask from ATCS function
540 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
541 * are supported (all asics).
543 static void amdgpu_atcs_parse_functions(struct amdgpu_atcs_functions *f, u32 mask)
545 f->get_ext_state = mask & ATCS_GET_EXTERNAL_STATE_SUPPORTED;
546 f->pcie_perf_req = mask & ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED;
547 f->pcie_dev_rdy = mask & ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED;
548 f->pcie_bus_width = mask & ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED;
552 * amdgpu_atcs_verify_interface - verify ATCS
554 * @handle: acpi handle
555 * @atcs: amdgpu atcs struct
557 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
558 * to initialize ATCS and determine what features are supported
560 * returns 0 on success, error on failure.
562 static int amdgpu_atcs_verify_interface(acpi_handle handle,
563 struct amdgpu_atcs *atcs)
565 union acpi_object *info;
566 struct atcs_verify_interface output;
570 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_VERIFY_INTERFACE, NULL);
574 memset(&output, 0, sizeof(output));
576 size = *(u16 *) info->buffer.pointer;
578 DRM_INFO("ATCS buffer is too small: %zu\n", size);
582 size = min(sizeof(output), size);
584 memcpy(&output, info->buffer.pointer, size);
586 /* TODO: check version? */
587 DRM_DEBUG_DRIVER("ATCS version %u\n", output.version);
589 amdgpu_atcs_parse_functions(&atcs->functions, output.function_bits);
597 * amdgpu_acpi_is_pcie_performance_request_supported
599 * @adev: amdgpu_device pointer
601 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
602 * are supported (all asics).
603 * returns true if supported, false if not.
605 bool amdgpu_acpi_is_pcie_performance_request_supported(struct amdgpu_device *adev)
607 struct amdgpu_atcs *atcs = &adev->atcs;
609 if (atcs->functions.pcie_perf_req && atcs->functions.pcie_dev_rdy)
616 * amdgpu_acpi_pcie_notify_device_ready
618 * @adev: amdgpu_device pointer
620 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
622 * returns 0 on success, error on failure.
624 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev)
627 union acpi_object *info;
628 struct amdgpu_atcs *atcs = &adev->atcs;
630 /* Get the device handle */
631 handle = ACPI_HANDLE(&adev->pdev->dev);
635 if (!atcs->functions.pcie_dev_rdy)
638 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION, NULL);
648 * amdgpu_acpi_pcie_performance_request
650 * @adev: amdgpu_device pointer
651 * @perf_req: requested perf level (pcie gen speed)
652 * @advertise: set advertise caps flag if set
654 * Executes the PCIE_PERFORMANCE_REQUEST method to
655 * change the pcie gen speed (all asics).
656 * returns 0 on success, error on failure.
658 int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
659 u8 perf_req, bool advertise)
662 union acpi_object *info;
663 struct amdgpu_atcs *atcs = &adev->atcs;
664 struct atcs_pref_req_input atcs_input;
665 struct atcs_pref_req_output atcs_output;
666 struct acpi_buffer params;
670 if (amdgpu_acpi_pcie_notify_device_ready(adev))
673 /* Get the device handle */
674 handle = ACPI_HANDLE(&adev->pdev->dev);
678 if (!atcs->functions.pcie_perf_req)
681 atcs_input.size = sizeof(struct atcs_pref_req_input);
682 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
683 atcs_input.client_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
684 atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
685 atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
687 atcs_input.flags |= ATCS_ADVERTISE_CAPS;
688 atcs_input.req_type = ATCS_PCIE_LINK_SPEED;
689 atcs_input.perf_req = perf_req;
691 params.length = sizeof(struct atcs_pref_req_input);
692 params.pointer = &atcs_input;
695 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST, ¶ms);
699 memset(&atcs_output, 0, sizeof(atcs_output));
701 size = *(u16 *) info->buffer.pointer;
703 DRM_INFO("ATCS buffer is too small: %zu\n", size);
707 size = min(sizeof(atcs_output), size);
709 memcpy(&atcs_output, info->buffer.pointer, size);
713 switch (atcs_output.ret_val) {
714 case ATCS_REQUEST_REFUSED:
717 case ATCS_REQUEST_COMPLETE:
719 case ATCS_REQUEST_IN_PROGRESS:
729 * amdgpu_acpi_event - handle notify events
731 * @nb: notifier block
735 * Calls relevant amdgpu functions in response to various
737 * Returns NOTIFY code
739 static int amdgpu_acpi_event(struct notifier_block *nb,
743 struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, acpi_nb);
744 struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
746 if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) {
747 if (power_supply_is_system_supplied() > 0)
748 DRM_DEBUG_DRIVER("pm: AC\n");
750 DRM_DEBUG_DRIVER("pm: DC\n");
752 amdgpu_pm_acpi_event_handler(adev);
755 /* Check for pending SBIOS requests */
756 return amdgpu_atif_handler(adev, entry);
759 /* Call all ACPI methods here */
761 * amdgpu_acpi_init - init driver acpi support
763 * @adev: amdgpu_device pointer
765 * Verifies the AMD ACPI interfaces and registers with the acpi
766 * notifier chain (all asics).
767 * Returns 0 on success, error on failure.
769 int amdgpu_acpi_init(struct amdgpu_device *adev)
771 acpi_handle handle, atif_handle;
772 struct amdgpu_atif *atif;
773 struct amdgpu_atcs *atcs = &adev->atcs;
776 /* Get the device handle */
777 handle = ACPI_HANDLE(&adev->pdev->dev);
779 if (!adev->bios || !handle)
782 /* Call the ATCS method */
783 ret = amdgpu_atcs_verify_interface(handle, atcs);
785 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret);
788 /* Probe for ATIF, and initialize it if found */
789 atif_handle = amdgpu_atif_probe_handle(handle);
793 atif = kzalloc(sizeof(*atif), GFP_KERNEL);
795 DRM_WARN("Not enough memory to initialize ATIF\n");
798 atif->handle = atif_handle;
800 /* Call the ATIF method */
801 ret = amdgpu_atif_verify_interface(atif);
803 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret);
809 if (atif->notifications.brightness_change) {
810 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
811 if (amdgpu_device_has_dc_support(adev)) {
812 #if defined(CONFIG_DRM_AMD_DC)
813 struct amdgpu_display_manager *dm = &adev->dm;
814 atif->bd = dm->backlight_dev;
817 struct drm_encoder *tmp;
819 /* Find the encoder controlling the brightness */
820 list_for_each_entry(tmp, &adev->ddev->mode_config.encoder_list,
822 struct amdgpu_encoder *enc = to_amdgpu_encoder(tmp);
824 if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
826 struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
828 atif->bd = dig->bl_dev;
837 if (atif->functions.sbios_requests && !atif->functions.system_params) {
838 /* XXX check this workraround, if sbios request function is
839 * present we have to see how it's configured in the system
842 atif->functions.system_params = true;
845 if (atif->functions.system_params) {
846 ret = amdgpu_atif_get_notification_params(atif);
848 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
850 /* Disable notification */
851 atif->notification_cfg.enabled = false;
855 if (atif->functions.query_backlight_transfer_characteristics) {
856 ret = amdgpu_atif_query_backlight_caps(atif);
858 DRM_DEBUG_DRIVER("Call to QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS failed: %d\n",
860 atif->backlight_caps.caps_valid = false;
863 atif->backlight_caps.caps_valid = false;
867 adev->acpi_nb.notifier_call = amdgpu_acpi_event;
868 register_acpi_notifier(&adev->acpi_nb);
873 void amdgpu_acpi_get_backlight_caps(struct amdgpu_device *adev,
874 struct amdgpu_dm_backlight_caps *caps)
877 caps->caps_valid = false;
880 caps->caps_valid = adev->atif->backlight_caps.caps_valid;
881 caps->min_input_signal = adev->atif->backlight_caps.min_input_signal;
882 caps->max_input_signal = adev->atif->backlight_caps.max_input_signal;
886 * amdgpu_acpi_fini - tear down driver acpi support
888 * @adev: amdgpu_device pointer
890 * Unregisters with the acpi notifier chain (all asics).
892 void amdgpu_acpi_fini(struct amdgpu_device *adev)
894 unregister_acpi_notifier(&adev->acpi_nb);