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 expansion_mode_change
;
47 bool forced_power_state
;
48 bool system_power_state
;
49 bool display_conf_change
;
51 bool brightness_change
;
52 bool dgpu_display_event
;
55 struct amdgpu_atif_functions
{
58 bool select_active_disp
;
62 bool get_panel_expansion_mode
;
63 bool set_panel_expansion_mode
;
64 bool temperature_change
;
65 bool graphics_device_types
;
71 struct amdgpu_atif_notifications notifications
;
72 struct amdgpu_atif_functions functions
;
73 struct amdgpu_atif_notification_cfg notification_cfg
;
74 struct amdgpu_encoder
*encoder_for_bl
;
77 /* Call the ATIF method
80 * amdgpu_atif_call - call an ATIF method
82 * @handle: acpi handle
83 * @function: the ATIF function to execute
84 * @params: ATIF function params
86 * Executes the requested ATIF function (all asics).
87 * Returns a pointer to the acpi output buffer.
89 static union acpi_object
*amdgpu_atif_call(struct amdgpu_atif
*atif
,
91 struct acpi_buffer
*params
)
94 union acpi_object atif_arg_elements
[2];
95 struct acpi_object_list atif_arg
;
96 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
99 atif_arg
.pointer
= &atif_arg_elements
[0];
101 atif_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
102 atif_arg_elements
[0].integer
.value
= function
;
105 atif_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
106 atif_arg_elements
[1].buffer
.length
= params
->length
;
107 atif_arg_elements
[1].buffer
.pointer
= params
->pointer
;
109 /* We need a second fake parameter */
110 atif_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
111 atif_arg_elements
[1].integer
.value
= 0;
114 status
= acpi_evaluate_object(atif
->handle
, NULL
, &atif_arg
,
117 /* Fail only if calling the method fails and ATIF is supported */
118 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
119 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
120 acpi_format_exception(status
));
121 kfree(buffer
.pointer
);
125 return buffer
.pointer
;
129 * amdgpu_atif_parse_notification - parse supported notifications
131 * @n: supported notifications struct
132 * @mask: supported notifications mask from ATIF
134 * Use the supported notifications mask from ATIF function
135 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
136 * are supported (all asics).
138 static void amdgpu_atif_parse_notification(struct amdgpu_atif_notifications
*n
, u32 mask
)
140 n
->display_switch
= mask
& ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED
;
141 n
->expansion_mode_change
= mask
& ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED
;
142 n
->thermal_state
= mask
& ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED
;
143 n
->forced_power_state
= mask
& ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED
;
144 n
->system_power_state
= mask
& ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED
;
145 n
->display_conf_change
= mask
& ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED
;
146 n
->px_gfx_switch
= mask
& ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED
;
147 n
->brightness_change
= mask
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED
;
148 n
->dgpu_display_event
= mask
& ATIF_DGPU_DISPLAY_EVENT_SUPPORTED
;
152 * amdgpu_atif_parse_functions - parse supported functions
154 * @f: supported functions struct
155 * @mask: supported functions mask from ATIF
157 * Use the supported functions mask from ATIF function
158 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
159 * are supported (all asics).
161 static void amdgpu_atif_parse_functions(struct amdgpu_atif_functions
*f
, u32 mask
)
163 f
->system_params
= mask
& ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED
;
164 f
->sbios_requests
= mask
& ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED
;
165 f
->select_active_disp
= mask
& ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED
;
166 f
->lid_state
= mask
& ATIF_GET_LID_STATE_SUPPORTED
;
167 f
->get_tv_standard
= mask
& ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED
;
168 f
->set_tv_standard
= mask
& ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED
;
169 f
->get_panel_expansion_mode
= mask
& ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED
;
170 f
->set_panel_expansion_mode
= mask
& ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED
;
171 f
->temperature_change
= mask
& ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED
;
172 f
->graphics_device_types
= mask
& ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED
;
176 * amdgpu_atif_verify_interface - verify ATIF
178 * @handle: acpi handle
179 * @atif: amdgpu atif struct
181 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
182 * to initialize ATIF and determine what features are supported
184 * returns 0 on success, error on failure.
186 static int amdgpu_atif_verify_interface(struct amdgpu_atif
*atif
)
188 union acpi_object
*info
;
189 struct atif_verify_interface output
;
193 info
= amdgpu_atif_call(atif
, ATIF_FUNCTION_VERIFY_INTERFACE
, NULL
);
197 memset(&output
, 0, sizeof(output
));
199 size
= *(u16
*) info
->buffer
.pointer
;
201 DRM_INFO("ATIF buffer is too small: %zu\n", size
);
205 size
= min(sizeof(output
), size
);
207 memcpy(&output
, info
->buffer
.pointer
, size
);
209 /* TODO: check version? */
210 DRM_DEBUG_DRIVER("ATIF version %u\n", output
.version
);
212 amdgpu_atif_parse_notification(&atif
->notifications
, output
.notification_mask
);
213 amdgpu_atif_parse_functions(&atif
->functions
, output
.function_bits
);
220 static acpi_handle
amdgpu_atif_probe_handle(acpi_handle dhandle
)
222 acpi_handle handle
= NULL
;
223 char acpi_method_name
[255] = { 0 };
224 struct acpi_buffer buffer
= { sizeof(acpi_method_name
), acpi_method_name
};
227 /* For PX/HG systems, ATIF and ATPX are in the iGPU's namespace, on dGPU only
228 * systems, ATIF is in the dGPU's namespace.
230 status
= acpi_get_handle(dhandle
, "ATIF", &handle
);
231 if (ACPI_SUCCESS(status
))
234 if (amdgpu_has_atpx()) {
235 status
= acpi_get_handle(amdgpu_atpx_get_dhandle(), "ATIF",
237 if (ACPI_SUCCESS(status
))
241 DRM_DEBUG_DRIVER("No ATIF handle found\n");
244 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
245 DRM_DEBUG_DRIVER("Found ATIF handle %s\n", acpi_method_name
);
250 * amdgpu_atif_get_notification_params - determine notify configuration
252 * @handle: acpi handle
253 * @n: atif notification configuration struct
255 * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
256 * to determine if a notifier is used and if so which one
257 * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n)
258 * where n is specified in the result if a notifier is used.
259 * Returns 0 on success, error on failure.
261 static int amdgpu_atif_get_notification_params(struct amdgpu_atif
*atif
)
263 union acpi_object
*info
;
264 struct amdgpu_atif_notification_cfg
*n
= &atif
->notification_cfg
;
265 struct atif_system_params params
;
269 info
= amdgpu_atif_call(atif
, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
,
276 size
= *(u16
*) info
->buffer
.pointer
;
282 memset(¶ms
, 0, sizeof(params
));
283 size
= min(sizeof(params
), size
);
284 memcpy(¶ms
, info
->buffer
.pointer
, size
);
286 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
287 params
.flags
, params
.valid_mask
);
288 params
.flags
= params
.flags
& params
.valid_mask
;
290 if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_NONE
) {
293 } else if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_81
) {
295 n
->command_code
= 0x81;
302 n
->command_code
= params
.command_code
;
306 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
307 (n
->enabled
? "enabled" : "disabled"),
314 * amdgpu_atif_get_sbios_requests - get requested sbios event
316 * @handle: acpi handle
317 * @req: atif sbios request struct
319 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
320 * to determine what requests the sbios is making to the driver
322 * Returns 0 on success, error on failure.
324 static int amdgpu_atif_get_sbios_requests(struct amdgpu_atif
*atif
,
325 struct atif_sbios_requests
*req
)
327 union acpi_object
*info
;
331 info
= amdgpu_atif_call(atif
, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
,
336 size
= *(u16
*)info
->buffer
.pointer
;
341 memset(req
, 0, sizeof(*req
));
343 size
= min(sizeof(*req
), size
);
344 memcpy(req
, info
->buffer
.pointer
, size
);
345 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req
->pending
);
347 count
= hweight32(req
->pending
);
355 * amdgpu_atif_handler - handle ATIF notify requests
357 * @adev: amdgpu_device pointer
358 * @event: atif sbios request struct
360 * Checks the acpi event and if it matches an atif event,
362 * Returns NOTIFY code
364 static int amdgpu_atif_handler(struct amdgpu_device
*adev
,
365 struct acpi_bus_event
*event
)
367 struct amdgpu_atif
*atif
= adev
->atif
;
370 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
371 event
->device_class
, event
->type
);
373 if (strcmp(event
->device_class
, ACPI_VIDEO_CLASS
) != 0)
377 !atif
->notification_cfg
.enabled
||
378 event
->type
!= atif
->notification_cfg
.command_code
)
382 if (atif
->functions
.sbios_requests
) {
383 struct atif_sbios_requests req
;
385 /* Check pending SBIOS requests */
386 count
= amdgpu_atif_get_sbios_requests(atif
, &req
);
391 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count
);
393 /* todo: add DC handling */
394 if ((req
.pending
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST
) &&
395 !amdgpu_device_has_dc_support(adev
)) {
396 struct amdgpu_encoder
*enc
= atif
->encoder_for_bl
;
399 struct amdgpu_encoder_atom_dig
*dig
= enc
->enc_priv
;
401 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
402 req
.backlight_level
);
404 amdgpu_display_backlight_set_level(adev
, enc
, req
.backlight_level
);
406 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
407 backlight_force_update(dig
->bl_dev
,
408 BACKLIGHT_UPDATE_HOTKEY
);
412 if (req
.pending
& ATIF_DGPU_DISPLAY_EVENT
) {
413 if ((adev
->flags
& AMD_IS_PX
) &&
414 amdgpu_atpx_dgpu_req_power_for_displays()) {
415 pm_runtime_get_sync(adev
->ddev
->dev
);
416 /* Just fire off a uevent and let userspace tell us what to do */
417 drm_helper_hpd_irq_event(adev
->ddev
);
418 pm_runtime_mark_last_busy(adev
->ddev
->dev
);
419 pm_runtime_put_autosuspend(adev
->ddev
->dev
);
422 /* TODO: check other events */
425 /* We've handled the event, stop the notifier chain. The ACPI interface
426 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
427 * userspace if the event was generated only to signal a SBIOS
433 /* Call the ATCS method
436 * amdgpu_atcs_call - call an ATCS method
438 * @handle: acpi handle
439 * @function: the ATCS function to execute
440 * @params: ATCS function params
442 * Executes the requested ATCS function (all asics).
443 * Returns a pointer to the acpi output buffer.
445 static union acpi_object
*amdgpu_atcs_call(acpi_handle handle
, int function
,
446 struct acpi_buffer
*params
)
449 union acpi_object atcs_arg_elements
[2];
450 struct acpi_object_list atcs_arg
;
451 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
454 atcs_arg
.pointer
= &atcs_arg_elements
[0];
456 atcs_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
457 atcs_arg_elements
[0].integer
.value
= function
;
460 atcs_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
461 atcs_arg_elements
[1].buffer
.length
= params
->length
;
462 atcs_arg_elements
[1].buffer
.pointer
= params
->pointer
;
464 /* We need a second fake parameter */
465 atcs_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
466 atcs_arg_elements
[1].integer
.value
= 0;
469 status
= acpi_evaluate_object(handle
, "ATCS", &atcs_arg
, &buffer
);
471 /* Fail only if calling the method fails and ATIF is supported */
472 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
473 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
474 acpi_format_exception(status
));
475 kfree(buffer
.pointer
);
479 return buffer
.pointer
;
483 * amdgpu_atcs_parse_functions - parse supported functions
485 * @f: supported functions struct
486 * @mask: supported functions mask from ATCS
488 * Use the supported functions mask from ATCS function
489 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
490 * are supported (all asics).
492 static void amdgpu_atcs_parse_functions(struct amdgpu_atcs_functions
*f
, u32 mask
)
494 f
->get_ext_state
= mask
& ATCS_GET_EXTERNAL_STATE_SUPPORTED
;
495 f
->pcie_perf_req
= mask
& ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED
;
496 f
->pcie_dev_rdy
= mask
& ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED
;
497 f
->pcie_bus_width
= mask
& ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED
;
501 * amdgpu_atcs_verify_interface - verify ATCS
503 * @handle: acpi handle
504 * @atcs: amdgpu atcs struct
506 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
507 * to initialize ATCS and determine what features are supported
509 * returns 0 on success, error on failure.
511 static int amdgpu_atcs_verify_interface(acpi_handle handle
,
512 struct amdgpu_atcs
*atcs
)
514 union acpi_object
*info
;
515 struct atcs_verify_interface output
;
519 info
= amdgpu_atcs_call(handle
, ATCS_FUNCTION_VERIFY_INTERFACE
, NULL
);
523 memset(&output
, 0, sizeof(output
));
525 size
= *(u16
*) info
->buffer
.pointer
;
527 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
531 size
= min(sizeof(output
), size
);
533 memcpy(&output
, info
->buffer
.pointer
, size
);
535 /* TODO: check version? */
536 DRM_DEBUG_DRIVER("ATCS version %u\n", output
.version
);
538 amdgpu_atcs_parse_functions(&atcs
->functions
, output
.function_bits
);
546 * amdgpu_acpi_is_pcie_performance_request_supported
548 * @adev: amdgpu_device pointer
550 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
551 * are supported (all asics).
552 * returns true if supported, false if not.
554 bool amdgpu_acpi_is_pcie_performance_request_supported(struct amdgpu_device
*adev
)
556 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
558 if (atcs
->functions
.pcie_perf_req
&& atcs
->functions
.pcie_dev_rdy
)
565 * amdgpu_acpi_pcie_notify_device_ready
567 * @adev: amdgpu_device pointer
569 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
571 * returns 0 on success, error on failure.
573 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device
*adev
)
576 union acpi_object
*info
;
577 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
579 /* Get the device handle */
580 handle
= ACPI_HANDLE(&adev
->pdev
->dev
);
584 if (!atcs
->functions
.pcie_dev_rdy
)
587 info
= amdgpu_atcs_call(handle
, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
, NULL
);
597 * amdgpu_acpi_pcie_performance_request
599 * @adev: amdgpu_device pointer
600 * @perf_req: requested perf level (pcie gen speed)
601 * @advertise: set advertise caps flag if set
603 * Executes the PCIE_PERFORMANCE_REQUEST method to
604 * change the pcie gen speed (all asics).
605 * returns 0 on success, error on failure.
607 int amdgpu_acpi_pcie_performance_request(struct amdgpu_device
*adev
,
608 u8 perf_req
, bool advertise
)
611 union acpi_object
*info
;
612 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
613 struct atcs_pref_req_input atcs_input
;
614 struct atcs_pref_req_output atcs_output
;
615 struct acpi_buffer params
;
619 if (amdgpu_acpi_pcie_notify_device_ready(adev
))
622 /* Get the device handle */
623 handle
= ACPI_HANDLE(&adev
->pdev
->dev
);
627 if (!atcs
->functions
.pcie_perf_req
)
630 atcs_input
.size
= sizeof(struct atcs_pref_req_input
);
631 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
632 atcs_input
.client_id
= adev
->pdev
->devfn
| (adev
->pdev
->bus
->number
<< 8);
633 atcs_input
.valid_flags_mask
= ATCS_VALID_FLAGS_MASK
;
634 atcs_input
.flags
= ATCS_WAIT_FOR_COMPLETION
;
636 atcs_input
.flags
|= ATCS_ADVERTISE_CAPS
;
637 atcs_input
.req_type
= ATCS_PCIE_LINK_SPEED
;
638 atcs_input
.perf_req
= perf_req
;
640 params
.length
= sizeof(struct atcs_pref_req_input
);
641 params
.pointer
= &atcs_input
;
644 info
= amdgpu_atcs_call(handle
, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
, ¶ms
);
648 memset(&atcs_output
, 0, sizeof(atcs_output
));
650 size
= *(u16
*) info
->buffer
.pointer
;
652 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
656 size
= min(sizeof(atcs_output
), size
);
658 memcpy(&atcs_output
, info
->buffer
.pointer
, size
);
662 switch (atcs_output
.ret_val
) {
663 case ATCS_REQUEST_REFUSED
:
666 case ATCS_REQUEST_COMPLETE
:
668 case ATCS_REQUEST_IN_PROGRESS
:
678 * amdgpu_acpi_event - handle notify events
680 * @nb: notifier block
684 * Calls relevant amdgpu functions in response to various
686 * Returns NOTIFY code
688 static int amdgpu_acpi_event(struct notifier_block
*nb
,
692 struct amdgpu_device
*adev
= container_of(nb
, struct amdgpu_device
, acpi_nb
);
693 struct acpi_bus_event
*entry
= (struct acpi_bus_event
*)data
;
695 if (strcmp(entry
->device_class
, ACPI_AC_CLASS
) == 0) {
696 if (power_supply_is_system_supplied() > 0)
697 DRM_DEBUG_DRIVER("pm: AC\n");
699 DRM_DEBUG_DRIVER("pm: DC\n");
701 amdgpu_pm_acpi_event_handler(adev
);
704 /* Check for pending SBIOS requests */
705 return amdgpu_atif_handler(adev
, entry
);
708 /* Call all ACPI methods here */
710 * amdgpu_acpi_init - init driver acpi support
712 * @adev: amdgpu_device pointer
714 * Verifies the AMD ACPI interfaces and registers with the acpi
715 * notifier chain (all asics).
716 * Returns 0 on success, error on failure.
718 int amdgpu_acpi_init(struct amdgpu_device
*adev
)
720 acpi_handle handle
, atif_handle
;
721 struct amdgpu_atif
*atif
;
722 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
725 /* Get the device handle */
726 handle
= ACPI_HANDLE(&adev
->pdev
->dev
);
728 if (!adev
->bios
|| !handle
)
731 /* Call the ATCS method */
732 ret
= amdgpu_atcs_verify_interface(handle
, atcs
);
734 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret
);
737 /* Probe for ATIF, and initialize it if found */
738 atif_handle
= amdgpu_atif_probe_handle(handle
);
742 atif
= kzalloc(sizeof(*atif
), GFP_KERNEL
);
744 DRM_WARN("Not enough memory to initialize ATIF\n");
747 atif
->handle
= atif_handle
;
749 /* Call the ATIF method */
750 ret
= amdgpu_atif_verify_interface(atif
);
752 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret
);
758 if (atif
->notifications
.brightness_change
) {
759 struct drm_encoder
*tmp
;
761 /* Find the encoder controlling the brightness */
762 list_for_each_entry(tmp
, &adev
->ddev
->mode_config
.encoder_list
,
764 struct amdgpu_encoder
*enc
= to_amdgpu_encoder(tmp
);
766 if ((enc
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) &&
768 struct amdgpu_encoder_atom_dig
*dig
= enc
->enc_priv
;
770 atif
->encoder_for_bl
= enc
;
777 if (atif
->functions
.sbios_requests
&& !atif
->functions
.system_params
) {
778 /* XXX check this workraround, if sbios request function is
779 * present we have to see how it's configured in the system
782 atif
->functions
.system_params
= true;
785 if (atif
->functions
.system_params
) {
786 ret
= amdgpu_atif_get_notification_params(atif
);
788 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
790 /* Disable notification */
791 atif
->notification_cfg
.enabled
= false;
796 adev
->acpi_nb
.notifier_call
= amdgpu_acpi_event
;
797 register_acpi_notifier(&adev
->acpi_nb
);
803 * amdgpu_acpi_fini - tear down driver acpi support
805 * @adev: amdgpu_device pointer
807 * Unregisters with the acpi notifier chain (all asics).
809 void amdgpu_acpi_fini(struct amdgpu_device
*adev
)
811 unregister_acpi_notifier(&adev
->acpi_nb
);