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/acpi.h>
25 #include <linux/pci.h>
26 #include <linux/pm_runtime.h>
27 #include <linux/power_supply.h>
28 #include <linux/slab.h>
30 #include <acpi/acpi_bus.h>
31 #include <acpi/video.h>
33 #include <drm/drm_crtc_helper.h>
34 #include <drm/drm_probe_helper.h>
38 #include "radeon_acpi.h"
39 #include "radeon_pm.h"
41 #if defined(CONFIG_VGA_SWITCHEROO)
42 bool radeon_atpx_dgpu_req_power_for_displays(void);
44 static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
47 #define ACPI_AC_CLASS "ac_adapter"
49 struct atif_verify_interface
{
50 u16 size
; /* structure size in bytes (includes size field) */
51 u16 version
; /* version */
52 u32 notification_mask
; /* supported notifications mask */
53 u32 function_bits
; /* supported functions bit vector */
56 struct atif_system_params
{
57 u16 size
; /* structure size in bytes (includes size field) */
58 u32 valid_mask
; /* valid flags mask */
59 u32 flags
; /* flags */
60 u8 command_code
; /* notify command code */
63 struct atif_sbios_requests
{
64 u16 size
; /* structure size in bytes (includes size field) */
65 u32 pending
; /* pending sbios requests */
66 u8 panel_exp_mode
; /* panel expansion mode */
67 u8 thermal_gfx
; /* thermal state: target gfx controller */
68 u8 thermal_state
; /* thermal state: state id (0: exit state, non-0: state) */
69 u8 forced_power_gfx
; /* forced power state: target gfx controller */
70 u8 forced_power_state
; /* forced power state: state id */
71 u8 system_power_src
; /* system power source */
72 u8 backlight_level
; /* panel backlight level (0-255) */
75 #define ATIF_NOTIFY_MASK 0x3
76 #define ATIF_NOTIFY_NONE 0
77 #define ATIF_NOTIFY_81 1
78 #define ATIF_NOTIFY_N 2
80 struct atcs_verify_interface
{
81 u16 size
; /* structure size in bytes (includes size field) */
82 u16 version
; /* version */
83 u32 function_bits
; /* supported functions bit vector */
86 #define ATCS_VALID_FLAGS_MASK 0x3
88 struct atcs_pref_req_input
{
89 u16 size
; /* structure size in bytes (includes size field) */
90 u16 client_id
; /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
91 u16 valid_flags_mask
; /* valid flags mask */
92 u16 flags
; /* flags */
93 u8 req_type
; /* request type */
94 u8 perf_req
; /* performance request */
97 struct atcs_pref_req_output
{
98 u16 size
; /* structure size in bytes (includes size field) */
99 u8 ret_val
; /* return value */
102 /* Call the ATIF method
105 * radeon_atif_call - call an ATIF method
107 * @handle: acpi handle
108 * @function: the ATIF function to execute
109 * @params: ATIF function params
111 * Executes the requested ATIF function (all asics).
112 * Returns a pointer to the acpi output buffer.
114 static union acpi_object
*radeon_atif_call(acpi_handle handle
, int function
,
115 struct acpi_buffer
*params
)
118 union acpi_object atif_arg_elements
[2];
119 struct acpi_object_list atif_arg
;
120 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
123 atif_arg
.pointer
= &atif_arg_elements
[0];
125 atif_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
126 atif_arg_elements
[0].integer
.value
= function
;
129 atif_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
130 atif_arg_elements
[1].buffer
.length
= params
->length
;
131 atif_arg_elements
[1].buffer
.pointer
= params
->pointer
;
133 /* We need a second fake parameter */
134 atif_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
135 atif_arg_elements
[1].integer
.value
= 0;
138 status
= acpi_evaluate_object(handle
, "ATIF", &atif_arg
, &buffer
);
140 /* Fail only if calling the method fails and ATIF is supported */
141 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
142 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
143 acpi_format_exception(status
));
144 kfree(buffer
.pointer
);
148 return buffer
.pointer
;
152 * radeon_atif_parse_notification - parse supported notifications
154 * @n: supported notifications struct
155 * @mask: supported notifications mask from ATIF
157 * Use the supported notifications mask from ATIF function
158 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
159 * are supported (all asics).
161 static void radeon_atif_parse_notification(struct radeon_atif_notifications
*n
, u32 mask
)
163 n
->display_switch
= mask
& ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED
;
164 n
->expansion_mode_change
= mask
& ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED
;
165 n
->thermal_state
= mask
& ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED
;
166 n
->forced_power_state
= mask
& ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED
;
167 n
->system_power_state
= mask
& ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED
;
168 n
->display_conf_change
= mask
& ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED
;
169 n
->px_gfx_switch
= mask
& ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED
;
170 n
->brightness_change
= mask
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED
;
171 n
->dgpu_display_event
= mask
& ATIF_DGPU_DISPLAY_EVENT_SUPPORTED
;
175 * radeon_atif_parse_functions - parse supported functions
177 * @f: supported functions struct
178 * @mask: supported functions mask from ATIF
180 * Use the supported functions mask from ATIF function
181 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
182 * are supported (all asics).
184 static void radeon_atif_parse_functions(struct radeon_atif_functions
*f
, u32 mask
)
186 f
->system_params
= mask
& ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED
;
187 f
->sbios_requests
= mask
& ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED
;
188 f
->select_active_disp
= mask
& ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED
;
189 f
->lid_state
= mask
& ATIF_GET_LID_STATE_SUPPORTED
;
190 f
->get_tv_standard
= mask
& ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED
;
191 f
->set_tv_standard
= mask
& ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED
;
192 f
->get_panel_expansion_mode
= mask
& ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED
;
193 f
->set_panel_expansion_mode
= mask
& ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED
;
194 f
->temperature_change
= mask
& ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED
;
195 f
->graphics_device_types
= mask
& ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED
;
199 * radeon_atif_verify_interface - verify ATIF
201 * @handle: acpi handle
202 * @atif: radeon atif struct
204 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
205 * to initialize ATIF and determine what features are supported
207 * returns 0 on success, error on failure.
209 static int radeon_atif_verify_interface(acpi_handle handle
,
210 struct radeon_atif
*atif
)
212 union acpi_object
*info
;
213 struct atif_verify_interface output
;
217 info
= radeon_atif_call(handle
, ATIF_FUNCTION_VERIFY_INTERFACE
, NULL
);
221 memset(&output
, 0, sizeof(output
));
223 size
= *(u16
*) info
->buffer
.pointer
;
225 DRM_INFO("ATIF buffer is too small: %zu\n", size
);
229 size
= min(sizeof(output
), size
);
231 memcpy(&output
, info
->buffer
.pointer
, size
);
233 /* TODO: check version? */
234 DRM_DEBUG_DRIVER("ATIF version %u\n", output
.version
);
236 radeon_atif_parse_notification(&atif
->notifications
, output
.notification_mask
);
237 radeon_atif_parse_functions(&atif
->functions
, output
.function_bits
);
245 * radeon_atif_get_notification_params - determine notify configuration
247 * @handle: acpi handle
248 * @n: atif notification configuration struct
250 * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
251 * to determine if a notifier is used and if so which one
252 * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n)
253 * where n is specified in the result if a notifier is used.
254 * Returns 0 on success, error on failure.
256 static int radeon_atif_get_notification_params(acpi_handle handle
,
257 struct radeon_atif_notification_cfg
*n
)
259 union acpi_object
*info
;
260 struct atif_system_params params
;
264 info
= radeon_atif_call(handle
, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
, NULL
);
270 size
= *(u16
*) info
->buffer
.pointer
;
276 memset(¶ms
, 0, sizeof(params
));
277 size
= min(sizeof(params
), size
);
278 memcpy(¶ms
, info
->buffer
.pointer
, size
);
280 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
281 params
.flags
, params
.valid_mask
);
282 params
.flags
= params
.flags
& params
.valid_mask
;
284 if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_NONE
) {
287 } else if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_81
) {
289 n
->command_code
= 0x81;
296 n
->command_code
= params
.command_code
;
300 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
301 (n
->enabled
? "enabled" : "disabled"),
308 * radeon_atif_get_sbios_requests - get requested sbios event
310 * @handle: acpi handle
311 * @req: atif sbios request struct
313 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
314 * to determine what requests the sbios is making to the driver
316 * Returns 0 on success, error on failure.
318 static int radeon_atif_get_sbios_requests(acpi_handle handle
,
319 struct atif_sbios_requests
*req
)
321 union acpi_object
*info
;
325 info
= radeon_atif_call(handle
, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
, NULL
);
329 size
= *(u16
*)info
->buffer
.pointer
;
334 memset(req
, 0, sizeof(*req
));
336 size
= min(sizeof(*req
), size
);
337 memcpy(req
, info
->buffer
.pointer
, size
);
338 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req
->pending
);
340 count
= hweight32(req
->pending
);
348 * radeon_atif_handler - handle ATIF notify requests
350 * @rdev: radeon_device pointer
351 * @event: atif sbios request struct
353 * Checks the acpi event and if it matches an atif event,
355 * Returns NOTIFY code
357 static int radeon_atif_handler(struct radeon_device
*rdev
,
358 struct acpi_bus_event
*event
)
360 struct radeon_atif
*atif
= &rdev
->atif
;
361 struct atif_sbios_requests req
;
365 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
366 event
->device_class
, event
->type
);
368 if (strcmp(event
->device_class
, ACPI_VIDEO_CLASS
) != 0)
371 if (!atif
->notification_cfg
.enabled
||
372 event
->type
!= atif
->notification_cfg
.command_code
)
376 /* Check pending SBIOS requests */
377 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
378 count
= radeon_atif_get_sbios_requests(handle
, &req
);
383 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count
);
385 if (req
.pending
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST
) {
386 struct radeon_encoder
*enc
= atif
->encoder_for_bl
;
389 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
390 req
.backlight_level
);
392 radeon_set_backlight_level(rdev
, enc
, req
.backlight_level
);
394 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
395 if (rdev
->is_atom_bios
) {
396 struct radeon_encoder_atom_dig
*dig
= enc
->enc_priv
;
397 backlight_force_update(dig
->bl_dev
,
398 BACKLIGHT_UPDATE_HOTKEY
);
400 struct radeon_encoder_lvds
*dig
= enc
->enc_priv
;
401 backlight_force_update(dig
->bl_dev
,
402 BACKLIGHT_UPDATE_HOTKEY
);
407 if (req
.pending
& ATIF_DGPU_DISPLAY_EVENT
) {
408 if ((rdev
->flags
& RADEON_IS_PX
) &&
409 radeon_atpx_dgpu_req_power_for_displays()) {
410 pm_runtime_get_sync(rdev
->ddev
->dev
);
411 /* Just fire off a uevent and let userspace tell us what to do */
412 drm_helper_hpd_irq_event(rdev
->ddev
);
413 pm_runtime_mark_last_busy(rdev
->ddev
->dev
);
414 pm_runtime_put_autosuspend(rdev
->ddev
->dev
);
417 /* TODO: check other events */
419 /* We've handled the event, stop the notifier chain. The ACPI interface
420 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
421 * userspace if the event was generated only to signal a SBIOS
427 /* Call the ATCS method
430 * radeon_atcs_call - call an ATCS method
432 * @handle: acpi handle
433 * @function: the ATCS function to execute
434 * @params: ATCS function params
436 * Executes the requested ATCS function (all asics).
437 * Returns a pointer to the acpi output buffer.
439 static union acpi_object
*radeon_atcs_call(acpi_handle handle
, int function
,
440 struct acpi_buffer
*params
)
443 union acpi_object atcs_arg_elements
[2];
444 struct acpi_object_list atcs_arg
;
445 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
448 atcs_arg
.pointer
= &atcs_arg_elements
[0];
450 atcs_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
451 atcs_arg_elements
[0].integer
.value
= function
;
454 atcs_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
455 atcs_arg_elements
[1].buffer
.length
= params
->length
;
456 atcs_arg_elements
[1].buffer
.pointer
= params
->pointer
;
458 /* We need a second fake parameter */
459 atcs_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
460 atcs_arg_elements
[1].integer
.value
= 0;
463 status
= acpi_evaluate_object(handle
, "ATCS", &atcs_arg
, &buffer
);
465 /* Fail only if calling the method fails and ATIF is supported */
466 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
467 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
468 acpi_format_exception(status
));
469 kfree(buffer
.pointer
);
473 return buffer
.pointer
;
477 * radeon_atcs_parse_functions - parse supported functions
479 * @f: supported functions struct
480 * @mask: supported functions mask from ATCS
482 * Use the supported functions mask from ATCS function
483 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
484 * are supported (all asics).
486 static void radeon_atcs_parse_functions(struct radeon_atcs_functions
*f
, u32 mask
)
488 f
->get_ext_state
= mask
& ATCS_GET_EXTERNAL_STATE_SUPPORTED
;
489 f
->pcie_perf_req
= mask
& ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED
;
490 f
->pcie_dev_rdy
= mask
& ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED
;
491 f
->pcie_bus_width
= mask
& ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED
;
495 * radeon_atcs_verify_interface - verify ATCS
497 * @handle: acpi handle
498 * @atcs: radeon atcs struct
500 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
501 * to initialize ATCS and determine what features are supported
503 * returns 0 on success, error on failure.
505 static int radeon_atcs_verify_interface(acpi_handle handle
,
506 struct radeon_atcs
*atcs
)
508 union acpi_object
*info
;
509 struct atcs_verify_interface output
;
513 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_VERIFY_INTERFACE
, NULL
);
517 memset(&output
, 0, sizeof(output
));
519 size
= *(u16
*) info
->buffer
.pointer
;
521 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
525 size
= min(sizeof(output
), size
);
527 memcpy(&output
, info
->buffer
.pointer
, size
);
529 /* TODO: check version? */
530 DRM_DEBUG_DRIVER("ATCS version %u\n", output
.version
);
532 radeon_atcs_parse_functions(&atcs
->functions
, output
.function_bits
);
540 * radeon_acpi_is_pcie_performance_request_supported
542 * @rdev: radeon_device pointer
544 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
545 * are supported (all asics).
546 * returns true if supported, false if not.
548 bool radeon_acpi_is_pcie_performance_request_supported(struct radeon_device
*rdev
)
550 struct radeon_atcs
*atcs
= &rdev
->atcs
;
552 if (atcs
->functions
.pcie_perf_req
&& atcs
->functions
.pcie_dev_rdy
)
559 * radeon_acpi_pcie_notify_device_ready
561 * @rdev: radeon_device pointer
563 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
565 * returns 0 on success, error on failure.
567 int radeon_acpi_pcie_notify_device_ready(struct radeon_device
*rdev
)
570 union acpi_object
*info
;
571 struct radeon_atcs
*atcs
= &rdev
->atcs
;
573 /* Get the device handle */
574 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
578 if (!atcs
->functions
.pcie_dev_rdy
)
581 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
, NULL
);
591 * radeon_acpi_pcie_performance_request
593 * @rdev: radeon_device pointer
594 * @perf_req: requested perf level (pcie gen speed)
595 * @advertise: set advertise caps flag if set
597 * Executes the PCIE_PERFORMANCE_REQUEST method to
598 * change the pcie gen speed (all asics).
599 * returns 0 on success, error on failure.
601 int radeon_acpi_pcie_performance_request(struct radeon_device
*rdev
,
602 u8 perf_req
, bool advertise
)
605 union acpi_object
*info
;
606 struct radeon_atcs
*atcs
= &rdev
->atcs
;
607 struct atcs_pref_req_input atcs_input
;
608 struct atcs_pref_req_output atcs_output
;
609 struct acpi_buffer params
;
613 /* Get the device handle */
614 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
618 if (!atcs
->functions
.pcie_perf_req
)
621 atcs_input
.size
= sizeof(struct atcs_pref_req_input
);
622 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
623 atcs_input
.client_id
= rdev
->pdev
->devfn
| (rdev
->pdev
->bus
->number
<< 8);
624 atcs_input
.valid_flags_mask
= ATCS_VALID_FLAGS_MASK
;
625 atcs_input
.flags
= ATCS_WAIT_FOR_COMPLETION
;
627 atcs_input
.flags
|= ATCS_ADVERTISE_CAPS
;
628 atcs_input
.req_type
= ATCS_PCIE_LINK_SPEED
;
629 atcs_input
.perf_req
= perf_req
;
631 params
.length
= sizeof(struct atcs_pref_req_input
);
632 params
.pointer
= &atcs_input
;
635 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
, ¶ms
);
639 memset(&atcs_output
, 0, sizeof(atcs_output
));
641 size
= *(u16
*) info
->buffer
.pointer
;
643 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
647 size
= min(sizeof(atcs_output
), size
);
649 memcpy(&atcs_output
, info
->buffer
.pointer
, size
);
653 switch (atcs_output
.ret_val
) {
654 case ATCS_REQUEST_REFUSED
:
657 case ATCS_REQUEST_COMPLETE
:
659 case ATCS_REQUEST_IN_PROGRESS
:
669 * radeon_acpi_event - handle notify events
671 * @nb: notifier block
675 * Calls relevant radeon functions in response to various
677 * Returns NOTIFY code
679 static int radeon_acpi_event(struct notifier_block
*nb
,
683 struct radeon_device
*rdev
= container_of(nb
, struct radeon_device
, acpi_nb
);
684 struct acpi_bus_event
*entry
= (struct acpi_bus_event
*)data
;
686 if (strcmp(entry
->device_class
, ACPI_AC_CLASS
) == 0) {
687 if (power_supply_is_system_supplied() > 0)
688 DRM_DEBUG_DRIVER("pm: AC\n");
690 DRM_DEBUG_DRIVER("pm: DC\n");
692 radeon_pm_acpi_event_handler(rdev
);
695 /* Check for pending SBIOS requests */
696 return radeon_atif_handler(rdev
, entry
);
699 /* Call all ACPI methods here */
701 * radeon_acpi_init - init driver acpi support
703 * @rdev: radeon_device pointer
705 * Verifies the AMD ACPI interfaces and registers with the acpi
706 * notifier chain (all asics).
707 * Returns 0 on success, error on failure.
709 int radeon_acpi_init(struct radeon_device
*rdev
)
712 struct radeon_atif
*atif
= &rdev
->atif
;
713 struct radeon_atcs
*atcs
= &rdev
->atcs
;
716 /* Get the device handle */
717 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
719 /* No need to proceed if we're sure that ATIF is not supported */
720 if (!ASIC_IS_AVIVO(rdev
) || !rdev
->bios
|| !handle
)
723 /* Call the ATCS method */
724 ret
= radeon_atcs_verify_interface(handle
, atcs
);
726 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret
);
729 /* Call the ATIF method */
730 ret
= radeon_atif_verify_interface(handle
, atif
);
732 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret
);
736 if (atif
->notifications
.brightness_change
) {
737 struct drm_encoder
*tmp
;
738 struct radeon_encoder
*target
= NULL
;
740 /* Find the encoder controlling the brightness */
741 list_for_each_entry(tmp
, &rdev
->ddev
->mode_config
.encoder_list
,
743 struct radeon_encoder
*enc
= to_radeon_encoder(tmp
);
745 if ((enc
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) &&
747 if (rdev
->is_atom_bios
) {
748 struct radeon_encoder_atom_dig
*dig
= enc
->enc_priv
;
754 struct radeon_encoder_lvds
*dig
= enc
->enc_priv
;
763 atif
->encoder_for_bl
= target
;
766 if (atif
->functions
.sbios_requests
&& !atif
->functions
.system_params
) {
767 /* XXX check this workraround, if sbios request function is
768 * present we have to see how it's configured in the system
771 atif
->functions
.system_params
= true;
774 if (atif
->functions
.system_params
) {
775 ret
= radeon_atif_get_notification_params(handle
,
776 &atif
->notification_cfg
);
778 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
780 /* Disable notification */
781 atif
->notification_cfg
.enabled
= false;
786 rdev
->acpi_nb
.notifier_call
= radeon_acpi_event
;
787 register_acpi_notifier(&rdev
->acpi_nb
);
793 * radeon_acpi_fini - tear down driver acpi support
795 * @rdev: radeon_device pointer
797 * Unregisters with the acpi notifier chain (all asics).
799 void radeon_acpi_fini(struct radeon_device
*rdev
)
801 unregister_acpi_notifier(&rdev
->acpi_nb
);