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"
40 #if defined(CONFIG_VGA_SWITCHEROO)
41 bool radeon_atpx_dgpu_req_power_for_displays(void);
43 static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
46 #define ACPI_AC_CLASS "ac_adapter"
48 extern void radeon_pm_acpi_event_handler(struct radeon_device
*rdev
);
50 struct atif_verify_interface
{
51 u16 size
; /* structure size in bytes (includes size field) */
52 u16 version
; /* version */
53 u32 notification_mask
; /* supported notifications mask */
54 u32 function_bits
; /* supported functions bit vector */
57 struct atif_system_params
{
58 u16 size
; /* structure size in bytes (includes size field) */
59 u32 valid_mask
; /* valid flags mask */
60 u32 flags
; /* flags */
61 u8 command_code
; /* notify command code */
64 struct atif_sbios_requests
{
65 u16 size
; /* structure size in bytes (includes size field) */
66 u32 pending
; /* pending sbios requests */
67 u8 panel_exp_mode
; /* panel expansion mode */
68 u8 thermal_gfx
; /* thermal state: target gfx controller */
69 u8 thermal_state
; /* thermal state: state id (0: exit state, non-0: state) */
70 u8 forced_power_gfx
; /* forced power state: target gfx controller */
71 u8 forced_power_state
; /* forced power state: state id */
72 u8 system_power_src
; /* system power source */
73 u8 backlight_level
; /* panel backlight level (0-255) */
76 #define ATIF_NOTIFY_MASK 0x3
77 #define ATIF_NOTIFY_NONE 0
78 #define ATIF_NOTIFY_81 1
79 #define ATIF_NOTIFY_N 2
81 struct atcs_verify_interface
{
82 u16 size
; /* structure size in bytes (includes size field) */
83 u16 version
; /* version */
84 u32 function_bits
; /* supported functions bit vector */
87 #define ATCS_VALID_FLAGS_MASK 0x3
89 struct atcs_pref_req_input
{
90 u16 size
; /* structure size in bytes (includes size field) */
91 u16 client_id
; /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
92 u16 valid_flags_mask
; /* valid flags mask */
93 u16 flags
; /* flags */
94 u8 req_type
; /* request type */
95 u8 perf_req
; /* performance request */
98 struct atcs_pref_req_output
{
99 u16 size
; /* structure size in bytes (includes size field) */
100 u8 ret_val
; /* return value */
103 /* Call the ATIF method
106 * radeon_atif_call - call an ATIF method
108 * @handle: acpi handle
109 * @function: the ATIF function to execute
110 * @params: ATIF function params
112 * Executes the requested ATIF function (all asics).
113 * Returns a pointer to the acpi output buffer.
115 static union acpi_object
*radeon_atif_call(acpi_handle handle
, int function
,
116 struct acpi_buffer
*params
)
119 union acpi_object atif_arg_elements
[2];
120 struct acpi_object_list atif_arg
;
121 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
124 atif_arg
.pointer
= &atif_arg_elements
[0];
126 atif_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
127 atif_arg_elements
[0].integer
.value
= function
;
130 atif_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
131 atif_arg_elements
[1].buffer
.length
= params
->length
;
132 atif_arg_elements
[1].buffer
.pointer
= params
->pointer
;
134 /* We need a second fake parameter */
135 atif_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
136 atif_arg_elements
[1].integer
.value
= 0;
139 status
= acpi_evaluate_object(handle
, "ATIF", &atif_arg
, &buffer
);
141 /* Fail only if calling the method fails and ATIF is supported */
142 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
143 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
144 acpi_format_exception(status
));
145 kfree(buffer
.pointer
);
149 return buffer
.pointer
;
153 * radeon_atif_parse_notification - parse supported notifications
155 * @n: supported notifications struct
156 * @mask: supported notifications mask from ATIF
158 * Use the supported notifications mask from ATIF function
159 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
160 * are supported (all asics).
162 static void radeon_atif_parse_notification(struct radeon_atif_notifications
*n
, u32 mask
)
164 n
->display_switch
= mask
& ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED
;
165 n
->expansion_mode_change
= mask
& ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED
;
166 n
->thermal_state
= mask
& ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED
;
167 n
->forced_power_state
= mask
& ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED
;
168 n
->system_power_state
= mask
& ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED
;
169 n
->display_conf_change
= mask
& ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED
;
170 n
->px_gfx_switch
= mask
& ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED
;
171 n
->brightness_change
= mask
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED
;
172 n
->dgpu_display_event
= mask
& ATIF_DGPU_DISPLAY_EVENT_SUPPORTED
;
176 * radeon_atif_parse_functions - parse supported functions
178 * @f: supported functions struct
179 * @mask: supported functions mask from ATIF
181 * Use the supported functions mask from ATIF function
182 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
183 * are supported (all asics).
185 static void radeon_atif_parse_functions(struct radeon_atif_functions
*f
, u32 mask
)
187 f
->system_params
= mask
& ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED
;
188 f
->sbios_requests
= mask
& ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED
;
189 f
->select_active_disp
= mask
& ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED
;
190 f
->lid_state
= mask
& ATIF_GET_LID_STATE_SUPPORTED
;
191 f
->get_tv_standard
= mask
& ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED
;
192 f
->set_tv_standard
= mask
& ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED
;
193 f
->get_panel_expansion_mode
= mask
& ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED
;
194 f
->set_panel_expansion_mode
= mask
& ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED
;
195 f
->temperature_change
= mask
& ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED
;
196 f
->graphics_device_types
= mask
& ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED
;
200 * radeon_atif_verify_interface - verify ATIF
202 * @handle: acpi handle
203 * @atif: radeon atif struct
205 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
206 * to initialize ATIF and determine what features are supported
208 * returns 0 on success, error on failure.
210 static int radeon_atif_verify_interface(acpi_handle handle
,
211 struct radeon_atif
*atif
)
213 union acpi_object
*info
;
214 struct atif_verify_interface output
;
218 info
= radeon_atif_call(handle
, ATIF_FUNCTION_VERIFY_INTERFACE
, NULL
);
222 memset(&output
, 0, sizeof(output
));
224 size
= *(u16
*) info
->buffer
.pointer
;
226 DRM_INFO("ATIF buffer is too small: %zu\n", size
);
230 size
= min(sizeof(output
), size
);
232 memcpy(&output
, info
->buffer
.pointer
, size
);
234 /* TODO: check version? */
235 DRM_DEBUG_DRIVER("ATIF version %u\n", output
.version
);
237 radeon_atif_parse_notification(&atif
->notifications
, output
.notification_mask
);
238 radeon_atif_parse_functions(&atif
->functions
, output
.function_bits
);
246 * radeon_atif_get_notification_params - determine notify configuration
248 * @handle: acpi handle
249 * @n: atif notification configuration struct
251 * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
252 * to determine if a notifier is used and if so which one
253 * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n)
254 * where n is specified in the result if a notifier is used.
255 * Returns 0 on success, error on failure.
257 static int radeon_atif_get_notification_params(acpi_handle handle
,
258 struct radeon_atif_notification_cfg
*n
)
260 union acpi_object
*info
;
261 struct atif_system_params params
;
265 info
= radeon_atif_call(handle
, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
, NULL
);
271 size
= *(u16
*) info
->buffer
.pointer
;
277 memset(¶ms
, 0, sizeof(params
));
278 size
= min(sizeof(params
), size
);
279 memcpy(¶ms
, info
->buffer
.pointer
, size
);
281 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
282 params
.flags
, params
.valid_mask
);
283 params
.flags
= params
.flags
& params
.valid_mask
;
285 if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_NONE
) {
288 } else if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_81
) {
290 n
->command_code
= 0x81;
297 n
->command_code
= params
.command_code
;
301 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
302 (n
->enabled
? "enabled" : "disabled"),
309 * radeon_atif_get_sbios_requests - get requested sbios event
311 * @handle: acpi handle
312 * @req: atif sbios request struct
314 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
315 * to determine what requests the sbios is making to the driver
317 * Returns 0 on success, error on failure.
319 static int radeon_atif_get_sbios_requests(acpi_handle handle
,
320 struct atif_sbios_requests
*req
)
322 union acpi_object
*info
;
326 info
= radeon_atif_call(handle
, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
, NULL
);
330 size
= *(u16
*)info
->buffer
.pointer
;
335 memset(req
, 0, sizeof(*req
));
337 size
= min(sizeof(*req
), size
);
338 memcpy(req
, info
->buffer
.pointer
, size
);
339 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req
->pending
);
341 count
= hweight32(req
->pending
);
349 * radeon_atif_handler - handle ATIF notify requests
351 * @rdev: radeon_device pointer
352 * @event: atif sbios request struct
354 * Checks the acpi event and if it matches an atif event,
356 * Returns NOTIFY code
358 static int radeon_atif_handler(struct radeon_device
*rdev
,
359 struct acpi_bus_event
*event
)
361 struct radeon_atif
*atif
= &rdev
->atif
;
362 struct atif_sbios_requests req
;
366 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
367 event
->device_class
, event
->type
);
369 if (strcmp(event
->device_class
, ACPI_VIDEO_CLASS
) != 0)
372 if (!atif
->notification_cfg
.enabled
||
373 event
->type
!= atif
->notification_cfg
.command_code
)
377 /* Check pending SBIOS requests */
378 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
379 count
= radeon_atif_get_sbios_requests(handle
, &req
);
384 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count
);
386 if (req
.pending
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST
) {
387 struct radeon_encoder
*enc
= atif
->encoder_for_bl
;
390 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
391 req
.backlight_level
);
393 radeon_set_backlight_level(rdev
, enc
, req
.backlight_level
);
395 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
396 if (rdev
->is_atom_bios
) {
397 struct radeon_encoder_atom_dig
*dig
= enc
->enc_priv
;
398 backlight_force_update(dig
->bl_dev
,
399 BACKLIGHT_UPDATE_HOTKEY
);
401 struct radeon_encoder_lvds
*dig
= enc
->enc_priv
;
402 backlight_force_update(dig
->bl_dev
,
403 BACKLIGHT_UPDATE_HOTKEY
);
408 if (req
.pending
& ATIF_DGPU_DISPLAY_EVENT
) {
409 if ((rdev
->flags
& RADEON_IS_PX
) &&
410 radeon_atpx_dgpu_req_power_for_displays()) {
411 pm_runtime_get_sync(rdev
->ddev
->dev
);
412 /* Just fire off a uevent and let userspace tell us what to do */
413 drm_helper_hpd_irq_event(rdev
->ddev
);
414 pm_runtime_mark_last_busy(rdev
->ddev
->dev
);
415 pm_runtime_put_autosuspend(rdev
->ddev
->dev
);
418 /* TODO: check other events */
420 /* We've handled the event, stop the notifier chain. The ACPI interface
421 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
422 * userspace if the event was generated only to signal a SBIOS
428 /* Call the ATCS method
431 * radeon_atcs_call - call an ATCS method
433 * @handle: acpi handle
434 * @function: the ATCS function to execute
435 * @params: ATCS function params
437 * Executes the requested ATCS function (all asics).
438 * Returns a pointer to the acpi output buffer.
440 static union acpi_object
*radeon_atcs_call(acpi_handle handle
, int function
,
441 struct acpi_buffer
*params
)
444 union acpi_object atcs_arg_elements
[2];
445 struct acpi_object_list atcs_arg
;
446 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
449 atcs_arg
.pointer
= &atcs_arg_elements
[0];
451 atcs_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
452 atcs_arg_elements
[0].integer
.value
= function
;
455 atcs_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
456 atcs_arg_elements
[1].buffer
.length
= params
->length
;
457 atcs_arg_elements
[1].buffer
.pointer
= params
->pointer
;
459 /* We need a second fake parameter */
460 atcs_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
461 atcs_arg_elements
[1].integer
.value
= 0;
464 status
= acpi_evaluate_object(handle
, "ATCS", &atcs_arg
, &buffer
);
466 /* Fail only if calling the method fails and ATIF is supported */
467 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
468 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
469 acpi_format_exception(status
));
470 kfree(buffer
.pointer
);
474 return buffer
.pointer
;
478 * radeon_atcs_parse_functions - parse supported functions
480 * @f: supported functions struct
481 * @mask: supported functions mask from ATCS
483 * Use the supported functions mask from ATCS function
484 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
485 * are supported (all asics).
487 static void radeon_atcs_parse_functions(struct radeon_atcs_functions
*f
, u32 mask
)
489 f
->get_ext_state
= mask
& ATCS_GET_EXTERNAL_STATE_SUPPORTED
;
490 f
->pcie_perf_req
= mask
& ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED
;
491 f
->pcie_dev_rdy
= mask
& ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED
;
492 f
->pcie_bus_width
= mask
& ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED
;
496 * radeon_atcs_verify_interface - verify ATCS
498 * @handle: acpi handle
499 * @atcs: radeon atcs struct
501 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
502 * to initialize ATCS and determine what features are supported
504 * returns 0 on success, error on failure.
506 static int radeon_atcs_verify_interface(acpi_handle handle
,
507 struct radeon_atcs
*atcs
)
509 union acpi_object
*info
;
510 struct atcs_verify_interface output
;
514 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_VERIFY_INTERFACE
, NULL
);
518 memset(&output
, 0, sizeof(output
));
520 size
= *(u16
*) info
->buffer
.pointer
;
522 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
526 size
= min(sizeof(output
), size
);
528 memcpy(&output
, info
->buffer
.pointer
, size
);
530 /* TODO: check version? */
531 DRM_DEBUG_DRIVER("ATCS version %u\n", output
.version
);
533 radeon_atcs_parse_functions(&atcs
->functions
, output
.function_bits
);
541 * radeon_acpi_is_pcie_performance_request_supported
543 * @rdev: radeon_device pointer
545 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
546 * are supported (all asics).
547 * returns true if supported, false if not.
549 bool radeon_acpi_is_pcie_performance_request_supported(struct radeon_device
*rdev
)
551 struct radeon_atcs
*atcs
= &rdev
->atcs
;
553 if (atcs
->functions
.pcie_perf_req
&& atcs
->functions
.pcie_dev_rdy
)
560 * radeon_acpi_pcie_notify_device_ready
562 * @rdev: radeon_device pointer
564 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
566 * returns 0 on success, error on failure.
568 int radeon_acpi_pcie_notify_device_ready(struct radeon_device
*rdev
)
571 union acpi_object
*info
;
572 struct radeon_atcs
*atcs
= &rdev
->atcs
;
574 /* Get the device handle */
575 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
579 if (!atcs
->functions
.pcie_dev_rdy
)
582 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
, NULL
);
592 * radeon_acpi_pcie_performance_request
594 * @rdev: radeon_device pointer
595 * @perf_req: requested perf level (pcie gen speed)
596 * @advertise: set advertise caps flag if set
598 * Executes the PCIE_PERFORMANCE_REQUEST method to
599 * change the pcie gen speed (all asics).
600 * returns 0 on success, error on failure.
602 int radeon_acpi_pcie_performance_request(struct radeon_device
*rdev
,
603 u8 perf_req
, bool advertise
)
606 union acpi_object
*info
;
607 struct radeon_atcs
*atcs
= &rdev
->atcs
;
608 struct atcs_pref_req_input atcs_input
;
609 struct atcs_pref_req_output atcs_output
;
610 struct acpi_buffer params
;
614 /* Get the device handle */
615 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
619 if (!atcs
->functions
.pcie_perf_req
)
622 atcs_input
.size
= sizeof(struct atcs_pref_req_input
);
623 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
624 atcs_input
.client_id
= rdev
->pdev
->devfn
| (rdev
->pdev
->bus
->number
<< 8);
625 atcs_input
.valid_flags_mask
= ATCS_VALID_FLAGS_MASK
;
626 atcs_input
.flags
= ATCS_WAIT_FOR_COMPLETION
;
628 atcs_input
.flags
|= ATCS_ADVERTISE_CAPS
;
629 atcs_input
.req_type
= ATCS_PCIE_LINK_SPEED
;
630 atcs_input
.perf_req
= perf_req
;
632 params
.length
= sizeof(struct atcs_pref_req_input
);
633 params
.pointer
= &atcs_input
;
636 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
, ¶ms
);
640 memset(&atcs_output
, 0, sizeof(atcs_output
));
642 size
= *(u16
*) info
->buffer
.pointer
;
644 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
648 size
= min(sizeof(atcs_output
), size
);
650 memcpy(&atcs_output
, info
->buffer
.pointer
, size
);
654 switch (atcs_output
.ret_val
) {
655 case ATCS_REQUEST_REFUSED
:
658 case ATCS_REQUEST_COMPLETE
:
660 case ATCS_REQUEST_IN_PROGRESS
:
670 * radeon_acpi_event - handle notify events
672 * @nb: notifier block
676 * Calls relevant radeon functions in response to various
678 * Returns NOTIFY code
680 static int radeon_acpi_event(struct notifier_block
*nb
,
684 struct radeon_device
*rdev
= container_of(nb
, struct radeon_device
, acpi_nb
);
685 struct acpi_bus_event
*entry
= (struct acpi_bus_event
*)data
;
687 if (strcmp(entry
->device_class
, ACPI_AC_CLASS
) == 0) {
688 if (power_supply_is_system_supplied() > 0)
689 DRM_DEBUG_DRIVER("pm: AC\n");
691 DRM_DEBUG_DRIVER("pm: DC\n");
693 radeon_pm_acpi_event_handler(rdev
);
696 /* Check for pending SBIOS requests */
697 return radeon_atif_handler(rdev
, entry
);
700 /* Call all ACPI methods here */
702 * radeon_acpi_init - init driver acpi support
704 * @rdev: radeon_device pointer
706 * Verifies the AMD ACPI interfaces and registers with the acpi
707 * notifier chain (all asics).
708 * Returns 0 on success, error on failure.
710 int radeon_acpi_init(struct radeon_device
*rdev
)
713 struct radeon_atif
*atif
= &rdev
->atif
;
714 struct radeon_atcs
*atcs
= &rdev
->atcs
;
717 /* Get the device handle */
718 handle
= ACPI_HANDLE(&rdev
->pdev
->dev
);
720 /* No need to proceed if we're sure that ATIF is not supported */
721 if (!ASIC_IS_AVIVO(rdev
) || !rdev
->bios
|| !handle
)
724 /* Call the ATCS method */
725 ret
= radeon_atcs_verify_interface(handle
, atcs
);
727 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret
);
730 /* Call the ATIF method */
731 ret
= radeon_atif_verify_interface(handle
, atif
);
733 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret
);
737 if (atif
->notifications
.brightness_change
) {
738 struct drm_encoder
*tmp
;
739 struct radeon_encoder
*target
= NULL
;
741 /* Find the encoder controlling the brightness */
742 list_for_each_entry(tmp
, &rdev
->ddev
->mode_config
.encoder_list
,
744 struct radeon_encoder
*enc
= to_radeon_encoder(tmp
);
746 if ((enc
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) &&
748 if (rdev
->is_atom_bios
) {
749 struct radeon_encoder_atom_dig
*dig
= enc
->enc_priv
;
755 struct radeon_encoder_lvds
*dig
= enc
->enc_priv
;
764 atif
->encoder_for_bl
= target
;
767 if (atif
->functions
.sbios_requests
&& !atif
->functions
.system_params
) {
768 /* XXX check this workraround, if sbios request function is
769 * present we have to see how it's configured in the system
772 atif
->functions
.system_params
= true;
775 if (atif
->functions
.system_params
) {
776 ret
= radeon_atif_get_notification_params(handle
,
777 &atif
->notification_cfg
);
779 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
781 /* Disable notification */
782 atif
->notification_cfg
.enabled
= false;
787 rdev
->acpi_nb
.notifier_call
= radeon_acpi_event
;
788 register_acpi_notifier(&rdev
->acpi_nb
);
794 * radeon_acpi_fini - tear down driver acpi support
796 * @rdev: radeon_device pointer
798 * Unregisters with the acpi notifier chain (all asics).
800 void radeon_acpi_fini(struct radeon_device
*rdev
)
802 unregister_acpi_notifier(&rdev
->acpi_nb
);