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 <acpi/acpi_drivers.h>
29 #include <acpi/acpi_bus.h>
30 #include <acpi/video.h>
33 #include <drm/drm_crtc_helper.h>
35 #include "radeon_acpi.h"
38 #include <linux/vga_switcheroo.h>
40 #define ACPI_AC_CLASS "ac_adapter"
42 extern void radeon_pm_acpi_event_handler(struct radeon_device
*rdev
);
44 struct atif_verify_interface
{
45 u16 size
; /* structure size in bytes (includes size field) */
46 u16 version
; /* version */
47 u32 notification_mask
; /* supported notifications mask */
48 u32 function_bits
; /* supported functions bit vector */
51 struct atif_system_params
{
52 u16 size
; /* structure size in bytes (includes size field) */
53 u32 valid_mask
; /* valid flags mask */
54 u32 flags
; /* flags */
55 u8 command_code
; /* notify command code */
58 struct atif_sbios_requests
{
59 u16 size
; /* structure size in bytes (includes size field) */
60 u32 pending
; /* pending sbios requests */
61 u8 panel_exp_mode
; /* panel expansion mode */
62 u8 thermal_gfx
; /* thermal state: target gfx controller */
63 u8 thermal_state
; /* thermal state: state id (0: exit state, non-0: state) */
64 u8 forced_power_gfx
; /* forced power state: target gfx controller */
65 u8 forced_power_state
; /* forced power state: state id */
66 u8 system_power_src
; /* system power source */
67 u8 backlight_level
; /* panel backlight level (0-255) */
70 #define ATIF_NOTIFY_MASK 0x3
71 #define ATIF_NOTIFY_NONE 0
72 #define ATIF_NOTIFY_81 1
73 #define ATIF_NOTIFY_N 2
75 struct atcs_verify_interface
{
76 u16 size
; /* structure size in bytes (includes size field) */
77 u16 version
; /* version */
78 u32 function_bits
; /* supported functions bit vector */
81 #define ATCS_VALID_FLAGS_MASK 0x3
83 struct atcs_pref_req_input
{
84 u16 size
; /* structure size in bytes (includes size field) */
85 u16 client_id
; /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
86 u16 valid_flags_mask
; /* valid flags mask */
87 u16 flags
; /* flags */
88 u8 req_type
; /* request type */
89 u8 perf_req
; /* performance request */
92 struct atcs_pref_req_output
{
93 u16 size
; /* structure size in bytes (includes size field) */
94 u8 ret_val
; /* return value */
97 /* Call the ATIF method
100 * radeon_atif_call - call an ATIF method
102 * @handle: acpi handle
103 * @function: the ATIF function to execute
104 * @params: ATIF function params
106 * Executes the requested ATIF function (all asics).
107 * Returns a pointer to the acpi output buffer.
109 static union acpi_object
*radeon_atif_call(acpi_handle handle
, int function
,
110 struct acpi_buffer
*params
)
113 union acpi_object atif_arg_elements
[2];
114 struct acpi_object_list atif_arg
;
115 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
118 atif_arg
.pointer
= &atif_arg_elements
[0];
120 atif_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
121 atif_arg_elements
[0].integer
.value
= function
;
124 atif_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
125 atif_arg_elements
[1].buffer
.length
= params
->length
;
126 atif_arg_elements
[1].buffer
.pointer
= params
->pointer
;
128 /* We need a second fake parameter */
129 atif_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
130 atif_arg_elements
[1].integer
.value
= 0;
133 status
= acpi_evaluate_object(handle
, "ATIF", &atif_arg
, &buffer
);
135 /* Fail only if calling the method fails and ATIF is supported */
136 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
137 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
138 acpi_format_exception(status
));
139 kfree(buffer
.pointer
);
143 return buffer
.pointer
;
147 * radeon_atif_parse_notification - parse supported notifications
149 * @n: supported notifications struct
150 * @mask: supported notifications mask from ATIF
152 * Use the supported notifications mask from ATIF function
153 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
154 * are supported (all asics).
156 static void radeon_atif_parse_notification(struct radeon_atif_notifications
*n
, u32 mask
)
158 n
->display_switch
= mask
& ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED
;
159 n
->expansion_mode_change
= mask
& ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED
;
160 n
->thermal_state
= mask
& ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED
;
161 n
->forced_power_state
= mask
& ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED
;
162 n
->system_power_state
= mask
& ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED
;
163 n
->display_conf_change
= mask
& ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED
;
164 n
->px_gfx_switch
= mask
& ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED
;
165 n
->brightness_change
= mask
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED
;
166 n
->dgpu_display_event
= mask
& ATIF_DGPU_DISPLAY_EVENT_SUPPORTED
;
170 * radeon_atif_parse_functions - parse supported functions
172 * @f: supported functions struct
173 * @mask: supported functions mask from ATIF
175 * Use the supported functions mask from ATIF function
176 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
177 * are supported (all asics).
179 static void radeon_atif_parse_functions(struct radeon_atif_functions
*f
, u32 mask
)
181 f
->system_params
= mask
& ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED
;
182 f
->sbios_requests
= mask
& ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED
;
183 f
->select_active_disp
= mask
& ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED
;
184 f
->lid_state
= mask
& ATIF_GET_LID_STATE_SUPPORTED
;
185 f
->get_tv_standard
= mask
& ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED
;
186 f
->set_tv_standard
= mask
& ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED
;
187 f
->get_panel_expansion_mode
= mask
& ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED
;
188 f
->set_panel_expansion_mode
= mask
& ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED
;
189 f
->temperature_change
= mask
& ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED
;
190 f
->graphics_device_types
= mask
& ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED
;
194 * radeon_atif_verify_interface - verify ATIF
196 * @handle: acpi handle
197 * @atif: radeon atif struct
199 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
200 * to initialize ATIF and determine what features are supported
202 * returns 0 on success, error on failure.
204 static int radeon_atif_verify_interface(acpi_handle handle
,
205 struct radeon_atif
*atif
)
207 union acpi_object
*info
;
208 struct atif_verify_interface output
;
212 info
= radeon_atif_call(handle
, ATIF_FUNCTION_VERIFY_INTERFACE
, NULL
);
216 memset(&output
, 0, sizeof(output
));
218 size
= *(u16
*) info
->buffer
.pointer
;
220 DRM_INFO("ATIF buffer is too small: %zu\n", size
);
224 size
= min(sizeof(output
), size
);
226 memcpy(&output
, info
->buffer
.pointer
, size
);
228 /* TODO: check version? */
229 DRM_DEBUG_DRIVER("ATIF version %u\n", output
.version
);
231 radeon_atif_parse_notification(&atif
->notifications
, output
.notification_mask
);
232 radeon_atif_parse_functions(&atif
->functions
, output
.function_bits
);
240 * radeon_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 radeon_atif_get_notification_params(acpi_handle handle
,
252 struct radeon_atif_notification_cfg
*n
)
254 union acpi_object
*info
;
255 struct atif_system_params params
;
259 info
= radeon_atif_call(handle
, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
, NULL
);
265 size
= *(u16
*) info
->buffer
.pointer
;
271 memset(¶ms
, 0, sizeof(params
));
272 size
= min(sizeof(params
), size
);
273 memcpy(¶ms
, info
->buffer
.pointer
, size
);
275 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
276 params
.flags
, params
.valid_mask
);
277 params
.flags
= params
.flags
& params
.valid_mask
;
279 if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_NONE
) {
282 } else if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_81
) {
284 n
->command_code
= 0x81;
291 n
->command_code
= params
.command_code
;
295 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
296 (n
->enabled
? "enabled" : "disabled"),
303 * radeon_atif_get_sbios_requests - get requested sbios event
305 * @handle: acpi handle
306 * @req: atif sbios request struct
308 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
309 * to determine what requests the sbios is making to the driver
311 * Returns 0 on success, error on failure.
313 static int radeon_atif_get_sbios_requests(acpi_handle handle
,
314 struct atif_sbios_requests
*req
)
316 union acpi_object
*info
;
320 info
= radeon_atif_call(handle
, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
, NULL
);
324 size
= *(u16
*)info
->buffer
.pointer
;
329 memset(req
, 0, sizeof(*req
));
331 size
= min(sizeof(*req
), size
);
332 memcpy(req
, info
->buffer
.pointer
, size
);
333 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req
->pending
);
335 count
= hweight32(req
->pending
);
343 * radeon_atif_handler - handle ATIF notify requests
345 * @rdev: radeon_device pointer
346 * @event: atif sbios request struct
348 * Checks the acpi event and if it matches an atif event,
350 * Returns NOTIFY code
352 int radeon_atif_handler(struct radeon_device
*rdev
,
353 struct acpi_bus_event
*event
)
355 struct radeon_atif
*atif
= &rdev
->atif
;
356 struct atif_sbios_requests req
;
360 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
361 event
->device_class
, event
->type
);
363 if (strcmp(event
->device_class
, ACPI_VIDEO_CLASS
) != 0)
366 if (!atif
->notification_cfg
.enabled
||
367 event
->type
!= atif
->notification_cfg
.command_code
)
371 /* Check pending SBIOS requests */
372 handle
= DEVICE_ACPI_HANDLE(&rdev
->pdev
->dev
);
373 count
= radeon_atif_get_sbios_requests(handle
, &req
);
378 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count
);
380 if (req
.pending
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST
) {
381 struct radeon_encoder
*enc
= atif
->encoder_for_bl
;
384 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
385 req
.backlight_level
);
387 radeon_set_backlight_level(rdev
, enc
, req
.backlight_level
);
389 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
390 if (rdev
->is_atom_bios
) {
391 struct radeon_encoder_atom_dig
*dig
= enc
->enc_priv
;
392 backlight_force_update(dig
->bl_dev
,
393 BACKLIGHT_UPDATE_HOTKEY
);
395 struct radeon_encoder_lvds
*dig
= enc
->enc_priv
;
396 backlight_force_update(dig
->bl_dev
,
397 BACKLIGHT_UPDATE_HOTKEY
);
402 /* TODO: check other events */
404 /* We've handled the event, stop the notifier chain. The ACPI interface
405 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
406 * userspace if the event was generated only to signal a SBIOS
412 /* Call the ATCS method
415 * radeon_atcs_call - call an ATCS method
417 * @handle: acpi handle
418 * @function: the ATCS function to execute
419 * @params: ATCS function params
421 * Executes the requested ATCS function (all asics).
422 * Returns a pointer to the acpi output buffer.
424 static union acpi_object
*radeon_atcs_call(acpi_handle handle
, int function
,
425 struct acpi_buffer
*params
)
428 union acpi_object atcs_arg_elements
[2];
429 struct acpi_object_list atcs_arg
;
430 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
433 atcs_arg
.pointer
= &atcs_arg_elements
[0];
435 atcs_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
436 atcs_arg_elements
[0].integer
.value
= function
;
439 atcs_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
440 atcs_arg_elements
[1].buffer
.length
= params
->length
;
441 atcs_arg_elements
[1].buffer
.pointer
= params
->pointer
;
443 /* We need a second fake parameter */
444 atcs_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
445 atcs_arg_elements
[1].integer
.value
= 0;
448 status
= acpi_evaluate_object(handle
, "ATCS", &atcs_arg
, &buffer
);
450 /* Fail only if calling the method fails and ATIF is supported */
451 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
452 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
453 acpi_format_exception(status
));
454 kfree(buffer
.pointer
);
458 return buffer
.pointer
;
462 * radeon_atcs_parse_functions - parse supported functions
464 * @f: supported functions struct
465 * @mask: supported functions mask from ATCS
467 * Use the supported functions mask from ATCS function
468 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
469 * are supported (all asics).
471 static void radeon_atcs_parse_functions(struct radeon_atcs_functions
*f
, u32 mask
)
473 f
->get_ext_state
= mask
& ATCS_GET_EXTERNAL_STATE_SUPPORTED
;
474 f
->pcie_perf_req
= mask
& ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED
;
475 f
->pcie_dev_rdy
= mask
& ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED
;
476 f
->pcie_bus_width
= mask
& ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED
;
480 * radeon_atcs_verify_interface - verify ATCS
482 * @handle: acpi handle
483 * @atcs: radeon atcs struct
485 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
486 * to initialize ATCS and determine what features are supported
488 * returns 0 on success, error on failure.
490 static int radeon_atcs_verify_interface(acpi_handle handle
,
491 struct radeon_atcs
*atcs
)
493 union acpi_object
*info
;
494 struct atcs_verify_interface output
;
498 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_VERIFY_INTERFACE
, NULL
);
502 memset(&output
, 0, sizeof(output
));
504 size
= *(u16
*) info
->buffer
.pointer
;
506 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
510 size
= min(sizeof(output
), size
);
512 memcpy(&output
, info
->buffer
.pointer
, size
);
514 /* TODO: check version? */
515 DRM_DEBUG_DRIVER("ATCS version %u\n", output
.version
);
517 radeon_atcs_parse_functions(&atcs
->functions
, output
.function_bits
);
525 * radeon_acpi_is_pcie_performance_request_supported
527 * @rdev: radeon_device pointer
529 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
530 * are supported (all asics).
531 * returns true if supported, false if not.
533 bool radeon_acpi_is_pcie_performance_request_supported(struct radeon_device
*rdev
)
535 struct radeon_atcs
*atcs
= &rdev
->atcs
;
537 if (atcs
->functions
.pcie_perf_req
&& atcs
->functions
.pcie_dev_rdy
)
544 * radeon_acpi_pcie_notify_device_ready
546 * @rdev: radeon_device pointer
548 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
550 * returns 0 on success, error on failure.
552 int radeon_acpi_pcie_notify_device_ready(struct radeon_device
*rdev
)
555 union acpi_object
*info
;
556 struct radeon_atcs
*atcs
= &rdev
->atcs
;
558 /* Get the device handle */
559 handle
= DEVICE_ACPI_HANDLE(&rdev
->pdev
->dev
);
563 if (!atcs
->functions
.pcie_dev_rdy
)
566 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
, NULL
);
576 * radeon_acpi_pcie_performance_request
578 * @rdev: radeon_device pointer
579 * @perf_req: requested perf level (pcie gen speed)
580 * @advertise: set advertise caps flag if set
582 * Executes the PCIE_PERFORMANCE_REQUEST method to
583 * change the pcie gen speed (all asics).
584 * returns 0 on success, error on failure.
586 int radeon_acpi_pcie_performance_request(struct radeon_device
*rdev
,
587 u8 perf_req
, bool advertise
)
590 union acpi_object
*info
;
591 struct radeon_atcs
*atcs
= &rdev
->atcs
;
592 struct atcs_pref_req_input atcs_input
;
593 struct atcs_pref_req_output atcs_output
;
594 struct acpi_buffer params
;
598 /* Get the device handle */
599 handle
= DEVICE_ACPI_HANDLE(&rdev
->pdev
->dev
);
603 if (!atcs
->functions
.pcie_perf_req
)
606 atcs_input
.size
= sizeof(struct atcs_pref_req_input
);
607 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
608 atcs_input
.client_id
= rdev
->pdev
->devfn
| (rdev
->pdev
->bus
->number
<< 8);
609 atcs_input
.valid_flags_mask
= ATCS_VALID_FLAGS_MASK
;
610 atcs_input
.flags
= ATCS_WAIT_FOR_COMPLETION
;
612 atcs_input
.flags
|= ATCS_ADVERTISE_CAPS
;
613 atcs_input
.req_type
= ATCS_PCIE_LINK_SPEED
;
614 atcs_input
.perf_req
= perf_req
;
616 params
.length
= sizeof(struct atcs_pref_req_input
);
617 params
.pointer
= &atcs_input
;
620 info
= radeon_atcs_call(handle
, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
, ¶ms
);
624 memset(&atcs_output
, 0, sizeof(atcs_output
));
626 size
= *(u16
*) info
->buffer
.pointer
;
628 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
632 size
= min(sizeof(atcs_output
), size
);
634 memcpy(&atcs_output
, info
->buffer
.pointer
, size
);
638 switch (atcs_output
.ret_val
) {
639 case ATCS_REQUEST_REFUSED
:
642 case ATCS_REQUEST_COMPLETE
:
644 case ATCS_REQUEST_IN_PROGRESS
:
654 * radeon_acpi_event - handle notify events
656 * @nb: notifier block
660 * Calls relevant radeon functions in response to various
662 * Returns NOTIFY code
664 static int radeon_acpi_event(struct notifier_block
*nb
,
668 struct radeon_device
*rdev
= container_of(nb
, struct radeon_device
, acpi_nb
);
669 struct acpi_bus_event
*entry
= (struct acpi_bus_event
*)data
;
671 if (strcmp(entry
->device_class
, ACPI_AC_CLASS
) == 0) {
672 if (power_supply_is_system_supplied() > 0)
673 DRM_DEBUG_DRIVER("pm: AC\n");
675 DRM_DEBUG_DRIVER("pm: DC\n");
677 radeon_pm_acpi_event_handler(rdev
);
680 /* Check for pending SBIOS requests */
681 return radeon_atif_handler(rdev
, entry
);
684 /* Call all ACPI methods here */
686 * radeon_acpi_init - init driver acpi support
688 * @rdev: radeon_device pointer
690 * Verifies the AMD ACPI interfaces and registers with the acpi
691 * notifier chain (all asics).
692 * Returns 0 on success, error on failure.
694 int radeon_acpi_init(struct radeon_device
*rdev
)
697 struct radeon_atif
*atif
= &rdev
->atif
;
698 struct radeon_atcs
*atcs
= &rdev
->atcs
;
701 /* Get the device handle */
702 handle
= DEVICE_ACPI_HANDLE(&rdev
->pdev
->dev
);
704 /* No need to proceed if we're sure that ATIF is not supported */
705 if (!ASIC_IS_AVIVO(rdev
) || !rdev
->bios
|| !handle
)
708 /* Call the ATCS method */
709 ret
= radeon_atcs_verify_interface(handle
, atcs
);
711 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret
);
714 /* Call the ATIF method */
715 ret
= radeon_atif_verify_interface(handle
, atif
);
717 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret
);
721 if (atif
->notifications
.brightness_change
) {
722 struct drm_encoder
*tmp
;
723 struct radeon_encoder
*target
= NULL
;
725 /* Find the encoder controlling the brightness */
726 list_for_each_entry(tmp
, &rdev
->ddev
->mode_config
.encoder_list
,
728 struct radeon_encoder
*enc
= to_radeon_encoder(tmp
);
730 if ((enc
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) &&
732 if (rdev
->is_atom_bios
) {
733 struct radeon_encoder_atom_dig
*dig
= enc
->enc_priv
;
739 struct radeon_encoder_lvds
*dig
= enc
->enc_priv
;
748 atif
->encoder_for_bl
= target
;
750 /* Brightness change notification is enabled, but we
751 * didn't find a backlight controller, this should
754 DRM_ERROR("Cannot find a backlight controller\n");
758 if (atif
->functions
.sbios_requests
&& !atif
->functions
.system_params
) {
759 /* XXX check this workraround, if sbios request function is
760 * present we have to see how it's configured in the system
763 atif
->functions
.system_params
= true;
766 if (atif
->functions
.system_params
) {
767 ret
= radeon_atif_get_notification_params(handle
,
768 &atif
->notification_cfg
);
770 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
772 /* Disable notification */
773 atif
->notification_cfg
.enabled
= false;
778 rdev
->acpi_nb
.notifier_call
= radeon_acpi_event
;
779 register_acpi_notifier(&rdev
->acpi_nb
);
785 * radeon_acpi_fini - tear down driver acpi support
787 * @rdev: radeon_device pointer
789 * Unregisters with the acpi notifier chain (all asics).
791 void radeon_acpi_fini(struct radeon_device
*rdev
)
793 unregister_acpi_notifier(&rdev
->acpi_nb
);