]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/dev/drm2/radeon/radeon_acpi.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / dev / drm2 / radeon / radeon_acpi.c
1 /*
2  * Copyright 2012 Advanced Micro Devices, Inc.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  *
22  */
23
24 #include <sys/cdefs.h>
25 __FBSDID("$FreeBSD$");
26
27 #include <dev/drm2/drmP.h>
28 #include <dev/drm2/drm_crtc_helper.h>
29 #include "radeon.h"
30 #include "radeon_acpi.h"
31 #include "atom.h"
32
33 #define ACPI_AC_CLASS           "ac_adapter"
34
35 extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev);
36
37 struct atif_verify_interface {
38         u16 size;               /* structure size in bytes (includes size field) */
39         u16 version;            /* version */
40         u32 notification_mask;  /* supported notifications mask */
41         u32 function_bits;      /* supported functions bit vector */
42 } __packed;
43
44 struct atif_system_params {
45         u16 size;               /* structure size in bytes (includes size field) */
46         u32 valid_mask;         /* valid flags mask */
47         u32 flags;              /* flags */
48         u8 command_code;        /* notify command code */
49 } __packed;
50
51 struct atif_sbios_requests {
52         u16 size;               /* structure size in bytes (includes size field) */
53         u32 pending;            /* pending sbios requests */
54         u8 panel_exp_mode;      /* panel expansion mode */
55         u8 thermal_gfx;         /* thermal state: target gfx controller */
56         u8 thermal_state;       /* thermal state: state id (0: exit state, non-0: state) */
57         u8 forced_power_gfx;    /* forced power state: target gfx controller */
58         u8 forced_power_state;  /* forced power state: state id */
59         u8 system_power_src;    /* system power source */
60         u8 backlight_level;     /* panel backlight level (0-255) */
61 } __packed;
62
63 #define ATIF_NOTIFY_MASK        0x3
64 #define ATIF_NOTIFY_NONE        0
65 #define ATIF_NOTIFY_81          1
66 #define ATIF_NOTIFY_N           2
67
68 struct atcs_verify_interface {
69         u16 size;               /* structure size in bytes (includes size field) */
70         u16 version;            /* version */
71         u32 function_bits;      /* supported functions bit vector */
72 } __packed;
73
74 /* Call the ATIF method
75  */
76 /**
77  * radeon_atif_call - call an ATIF method
78  *
79  * @handle: acpi handle
80  * @function: the ATIF function to execute
81  * @params: ATIF function params
82  *
83  * Executes the requested ATIF function (all asics).
84  * Returns a pointer to the acpi output buffer.
85  */
86 static ACPI_OBJECT *radeon_atif_call(ACPI_HANDLE handle, int function,
87                 ACPI_BUFFER *params)
88 {
89         ACPI_STATUS status;
90         ACPI_OBJECT atif_arg_elements[2];
91         ACPI_OBJECT_LIST atif_arg;
92         ACPI_BUFFER buffer = { ACPI_ALLOCATE_BUFFER, NULL };
93
94         atif_arg.Count = 2;
95         atif_arg.Pointer = &atif_arg_elements[0];
96
97         atif_arg_elements[0].Type = ACPI_TYPE_INTEGER;
98         atif_arg_elements[0].Integer.Value = function;
99
100         if (params) {
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;
104         } else {
105                 /* We need a second fake parameter */
106                 atif_arg_elements[1].Type = ACPI_TYPE_INTEGER;
107                 atif_arg_elements[1].Integer.Value = 0;
108         }
109
110         status = AcpiEvaluateObject(handle, "ATIF", &atif_arg, &buffer);
111
112         /* Fail only if calling the method fails and ATIF is supported */
113         if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
114                 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
115                                  AcpiFormatException(status));
116                 AcpiOsFree(buffer.Pointer);
117                 return NULL;
118         }
119
120         return buffer.Pointer;
121 }
122
123 /**
124  * radeon_atif_parse_notification - parse supported notifications
125  *
126  * @n: supported notifications struct
127  * @mask: supported notifications mask from ATIF
128  *
129  * Use the supported notifications mask from ATIF function
130  * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
131  * are supported (all asics).
132  */
133 static void radeon_atif_parse_notification(struct radeon_atif_notifications *n, u32 mask)
134 {
135         n->display_switch = mask & ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED;
136         n->expansion_mode_change = mask & ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED;
137         n->thermal_state = mask & ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED;
138         n->forced_power_state = mask & ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED;
139         n->system_power_state = mask & ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED;
140         n->display_conf_change = mask & ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED;
141         n->px_gfx_switch = mask & ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED;
142         n->brightness_change = mask & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED;
143         n->dgpu_display_event = mask & ATIF_DGPU_DISPLAY_EVENT_SUPPORTED;
144 }
145
146 /**
147  * radeon_atif_parse_functions - parse supported functions
148  *
149  * @f: supported functions struct
150  * @mask: supported functions mask from ATIF
151  *
152  * Use the supported functions mask from ATIF function
153  * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
154  * are supported (all asics).
155  */
156 static void radeon_atif_parse_functions(struct radeon_atif_functions *f, u32 mask)
157 {
158         f->system_params = mask & ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED;
159         f->sbios_requests = mask & ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED;
160         f->select_active_disp = mask & ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED;
161         f->lid_state = mask & ATIF_GET_LID_STATE_SUPPORTED;
162         f->get_tv_standard = mask & ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED;
163         f->set_tv_standard = mask & ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED;
164         f->get_panel_expansion_mode = mask & ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED;
165         f->set_panel_expansion_mode = mask & ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED;
166         f->temperature_change = mask & ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED;
167         f->graphics_device_types = mask & ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED;
168 }
169
170 /**
171  * radeon_atif_verify_interface - verify ATIF
172  *
173  * @handle: acpi handle
174  * @atif: radeon atif struct
175  *
176  * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
177  * to initialize ATIF and determine what features are supported
178  * (all asics).
179  * returns 0 on success, error on failure.
180  */
181 static int radeon_atif_verify_interface(ACPI_HANDLE handle,
182                 struct radeon_atif *atif)
183 {
184         ACPI_OBJECT *info;
185         struct atif_verify_interface output;
186         size_t size;
187         int err = 0;
188
189         info = radeon_atif_call(handle, ATIF_FUNCTION_VERIFY_INTERFACE, NULL);
190         if (!info)
191                 return -EIO;
192
193         memset(&output, 0, sizeof(output));
194
195         size = *(u16 *) info->Buffer.Pointer;
196         if (size < 12) {
197                 DRM_INFO("ATIF buffer is too small: %zu\n", size);
198                 err = -EINVAL;
199                 goto out;
200         }
201         size = min(sizeof(output), size);
202
203         memcpy(&output, info->Buffer.Pointer, size);
204
205         /* TODO: check version? */
206         DRM_DEBUG_DRIVER("ATIF version %u\n", output.version);
207
208         radeon_atif_parse_notification(&atif->notifications, output.notification_mask);
209         radeon_atif_parse_functions(&atif->functions, output.function_bits);
210
211 out:
212         AcpiOsFree(info);
213         return err;
214 }
215
216 /**
217  * radeon_atif_get_notification_params - determine notify configuration
218  *
219  * @handle: acpi handle
220  * @n: atif notification configuration struct
221  *
222  * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
223  * to determine if a notifier is used and if so which one
224  * (all asics).  This is either Notify(VGA, 0x81) or Notify(VGA, n)
225  * where n is specified in the result if a notifier is used.
226  * Returns 0 on success, error on failure.
227  */
228 static int radeon_atif_get_notification_params(ACPI_HANDLE handle,
229                 struct radeon_atif_notification_cfg *n)
230 {
231         ACPI_OBJECT *info;
232         struct atif_system_params params;
233         size_t size;
234         int err = 0;
235
236         info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS, NULL);
237         if (!info) {
238                 err = -EIO;
239                 goto out;
240         }
241
242         size = *(u16 *) info->Buffer.Pointer;
243         if (size < 10) {
244                 err = -EINVAL;
245                 goto out;
246         }
247
248         memset(&params, 0, sizeof(params));
249         size = min(sizeof(params), size);
250         memcpy(&params, info->Buffer.Pointer, size);
251
252         DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
253                         params.flags, params.valid_mask);
254         params.flags = params.flags & params.valid_mask;
255
256         if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_NONE) {
257                 n->enabled = false;
258                 n->command_code = 0;
259         } else if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_81) {
260                 n->enabled = true;
261                 n->command_code = 0x81;
262         } else {
263                 if (size < 11) {
264                         err = -EINVAL;
265                         goto out;
266                 }
267                 n->enabled = true;
268                 n->command_code = params.command_code;
269         }
270
271 out:
272         DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
273                         (n->enabled ? "enabled" : "disabled"),
274                         n->command_code);
275         AcpiOsFree(info);
276         return err;
277 }
278
279 /**
280  * radeon_atif_get_sbios_requests - get requested sbios event
281  *
282  * @handle: acpi handle
283  * @req: atif sbios request struct
284  *
285  * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
286  * to determine what requests the sbios is making to the driver
287  * (all asics).
288  * Returns 0 on success, error on failure.
289  */
290 static int radeon_atif_get_sbios_requests(ACPI_HANDLE handle,
291                 struct atif_sbios_requests *req)
292 {
293         ACPI_OBJECT *info;
294         size_t size;
295         int count = 0;
296
297         info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS, NULL);
298         if (!info)
299                 return -EIO;
300
301         size = *(u16 *)info->Buffer.Pointer;
302         if (size < 0xd) {
303                 count = -EINVAL;
304                 goto out;
305         }
306         memset(req, 0, sizeof(*req));
307
308         size = min(sizeof(*req), size);
309         memcpy(req, info->Buffer.Pointer, size);
310         DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req->pending);
311
312         count = hweight32(req->pending);
313
314 out:
315         AcpiOsFree(info);
316         return count;
317 }
318
319 /**
320  * radeon_atif_handler - handle ATIF notify requests
321  *
322  * @rdev: radeon_device pointer
323  * @event: atif sbios request struct
324  *
325  * Checks the acpi event and if it matches an atif event,
326  * handles it.
327  * Returns NOTIFY code
328  */
329 void radeon_atif_handler(struct radeon_device *rdev,
330     UINT32 type)
331 {
332         struct radeon_atif *atif = &rdev->atif;
333         struct atif_sbios_requests req;
334         ACPI_HANDLE handle;
335         int count;
336
337         DRM_DEBUG_DRIVER("event, type = %#x\n",
338                         type);
339
340         if (!atif->notification_cfg.enabled ||
341                         type != atif->notification_cfg.command_code)
342                 /* Not our event */
343                 return;
344
345         /* Check pending SBIOS requests */
346         handle = rdev->acpi.handle;
347         count = radeon_atif_get_sbios_requests(handle, &req);
348
349         if (count <= 0)
350                 return;
351
352         DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
353
354         if (req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) {
355                 struct radeon_encoder *enc = atif->encoder_for_bl;
356
357                 if (enc) {
358                         DRM_DEBUG_DRIVER("Changing brightness to %d\n",
359                                         req.backlight_level);
360
361                         radeon_set_backlight_level(rdev, enc, req.backlight_level);
362
363 #ifdef FREEBSD_WIP
364                         if (rdev->is_atom_bios) {
365                                 struct radeon_encoder_atom_dig *dig = enc->enc_priv;
366                                 backlight_force_update(dig->bl_dev,
367                                                        BACKLIGHT_UPDATE_HOTKEY);
368                         } else {
369                                 struct radeon_encoder_lvds *dig = enc->enc_priv;
370                                 backlight_force_update(dig->bl_dev,
371                                                        BACKLIGHT_UPDATE_HOTKEY);
372                         }
373 #endif /* FREEBSD_WIP */
374                 }
375         }
376         /* TODO: check other events */
377
378         /* We've handled the event, stop the notifier chain. The ACPI interface
379          * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
380          * userspace if the event was generated only to signal a SBIOS
381          * request.
382          */
383 }
384
385 /* Call the ATCS method
386  */
387 /**
388  * radeon_atcs_call - call an ATCS method
389  *
390  * @handle: acpi handle
391  * @function: the ATCS function to execute
392  * @params: ATCS function params
393  *
394  * Executes the requested ATCS function (all asics).
395  * Returns a pointer to the acpi output buffer.
396  */
397 static union acpi_object *radeon_atcs_call(ACPI_HANDLE handle, int function,
398                                            ACPI_BUFFER *params)
399 {
400         ACPI_STATUS status;
401         ACPI_OBJECT atcs_arg_elements[2];
402         ACPI_OBJECT_LIST atcs_arg;
403         ACPI_BUFFER buffer = { ACPI_ALLOCATE_BUFFER, NULL };
404
405         atcs_arg.Count = 2;
406         atcs_arg.Pointer = &atcs_arg_elements[0];
407
408         atcs_arg_elements[0].Type = ACPI_TYPE_INTEGER;
409         atcs_arg_elements[0].Integer.Value = function;
410
411         if (params) {
412                 atcs_arg_elements[1].Type = ACPI_TYPE_BUFFER;
413                 atcs_arg_elements[1].Buffer.Length = params->Length;
414                 atcs_arg_elements[1].Buffer.Pointer = params->Pointer;
415         } else {
416                 /* We need a second fake parameter */
417                 atcs_arg_elements[1].Type = ACPI_TYPE_INTEGER;
418                 atcs_arg_elements[1].Integer.Value = 0;
419         }
420
421         status = AcpiEvaluateObject(handle, "ATCS", &atcs_arg, &buffer);
422
423         /* Fail only if calling the method fails and ATIF is supported */
424         if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
425                 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
426                                  AcpiFormatException(status));
427                 AcpiOsFree(buffer.Pointer);
428                 return NULL;
429         }
430
431         return buffer.Pointer;
432 }
433
434 /**
435  * radeon_atcs_parse_functions - parse supported functions
436  *
437  * @f: supported functions struct
438  * @mask: supported functions mask from ATCS
439  *
440  * Use the supported functions mask from ATCS function
441  * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
442  * are supported (all asics).
443  */
444 static void radeon_atcs_parse_functions(struct radeon_atcs_functions *f, u32 mask)
445 {
446         f->get_ext_state = mask & ATCS_GET_EXTERNAL_STATE_SUPPORTED;
447         f->pcie_perf_req = mask & ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED;
448         f->pcie_dev_rdy = mask & ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED;
449         f->pcie_bus_width = mask & ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED;
450 }
451
452 /**
453  * radeon_atcs_verify_interface - verify ATCS
454  *
455  * @handle: acpi handle
456  * @atcs: radeon atcs struct
457  *
458  * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
459  * to initialize ATCS and determine what features are supported
460  * (all asics).
461  * returns 0 on success, error on failure.
462  */
463 static int radeon_atcs_verify_interface(ACPI_HANDLE handle,
464                                         struct radeon_atcs *atcs)
465 {
466         ACPI_OBJECT *info;
467         struct atcs_verify_interface output;
468         size_t size;
469         int err = 0;
470
471         info = radeon_atcs_call(handle, ATCS_FUNCTION_VERIFY_INTERFACE, NULL);
472         if (!info)
473                 return -EIO;
474
475         memset(&output, 0, sizeof(output));
476
477         size = *(u16 *) info->Buffer.Pointer;
478         if (size < 8) {
479                 DRM_INFO("ATCS buffer is too small: %zu\n", size);
480                 err = -EINVAL;
481                 goto out;
482         }
483         size = min(sizeof(output), size);
484
485         memcpy(&output, info->Buffer.Pointer, size);
486
487         /* TODO: check version? */
488         DRM_DEBUG_DRIVER("ATCS version %u\n", output.version);
489
490         radeon_atcs_parse_functions(&atcs->functions, output.function_bits);
491
492 out:
493         AcpiOsFree(info);
494         return err;
495 }
496
497 /**
498  * radeon_acpi_event - handle notify events
499  *
500  * @nb: notifier block
501  * @val: val
502  * @data: acpi event
503  *
504  * Calls relevant radeon functions in response to various
505  * acpi events.
506  * Returns NOTIFY code
507  */
508 static void radeon_acpi_event(ACPI_HANDLE handle, UINT32 type,
509     void *context)
510 {
511         struct radeon_device *rdev = (struct radeon_device *)context;
512
513 #ifdef FREEBSD_WIP
514         if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) {
515                 if (power_supply_is_system_supplied() > 0)
516                         DRM_DEBUG_DRIVER("pm: AC\n");
517                 else
518                         DRM_DEBUG_DRIVER("pm: DC\n");
519
520                 radeon_pm_acpi_event_handler(rdev);
521         }
522 #endif /* FREEBSD_WIP */
523
524         /* Check for pending SBIOS requests */
525         radeon_atif_handler(rdev, type);
526 }
527
528 /* Call all ACPI methods here */
529 /**
530  * radeon_acpi_init - init driver acpi support
531  *
532  * @rdev: radeon_device pointer
533  *
534  * Verifies the AMD ACPI interfaces and registers with the acpi
535  * notifier chain (all asics).
536  * Returns 0 on success, error on failure.
537  */
538 int radeon_acpi_init(struct radeon_device *rdev)
539 {
540         ACPI_HANDLE handle;
541         struct radeon_atif *atif = &rdev->atif;
542         struct radeon_atcs *atcs = &rdev->atcs;
543         int ret;
544
545         /* Get the device handle */
546         handle = acpi_get_handle(rdev->dev);
547
548         /* No need to proceed if we're sure that ATIF is not supported */
549         if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
550                 return 0;
551
552         /* Call the ATCS method */
553         ret = radeon_atcs_verify_interface(handle, atcs);
554         if (ret) {
555                 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret);
556         }
557
558         /* Call the ATIF method */
559         ret = radeon_atif_verify_interface(handle, atif);
560         if (ret) {
561                 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret);
562                 goto out;
563         }
564
565         if (atif->notifications.brightness_change) {
566                 struct drm_encoder *tmp;
567                 struct radeon_encoder *target = NULL;
568
569                 /* Find the encoder controlling the brightness */
570                 list_for_each_entry(tmp, &rdev->ddev->mode_config.encoder_list,
571                                 head) {
572                         struct radeon_encoder *enc = to_radeon_encoder(tmp);
573
574                         if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
575                             enc->enc_priv) {
576                                 if (rdev->is_atom_bios) {
577                                         struct radeon_encoder_atom_dig *dig = enc->enc_priv;
578                                         if (dig->bl_dev) {
579                                                 target = enc;
580                                                 break;
581                                         }
582                                 } else {
583                                         struct radeon_encoder_lvds *dig = enc->enc_priv;
584                                         if (dig->bl_dev) {
585                                                 target = enc;
586                                                 break;
587                                         }
588                                 }
589                         }
590                 }
591
592                 atif->encoder_for_bl = target;
593                 if (!target) {
594                         /* Brightness change notification is enabled, but we
595                          * didn't find a backlight controller, this should
596                          * never happen.
597                          */
598                         DRM_ERROR("Cannot find a backlight controller\n");
599                 }
600         }
601
602         if (atif->functions.sbios_requests && !atif->functions.system_params) {
603                 /* XXX check this workraround, if sbios request function is
604                  * present we have to see how it's configured in the system
605                  * params
606                  */
607                 atif->functions.system_params = true;
608         }
609
610         if (atif->functions.system_params) {
611                 ret = radeon_atif_get_notification_params(handle,
612                                 &atif->notification_cfg);
613                 if (ret) {
614                         DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
615                                         ret);
616                         /* Disable notification */
617                         atif->notification_cfg.enabled = false;
618                 }
619         }
620
621 out:
622         rdev->acpi.handle = handle;
623         rdev->acpi.notifier_call = radeon_acpi_event;
624         AcpiInstallNotifyHandler(handle, ACPI_DEVICE_NOTIFY,
625             rdev->acpi.notifier_call, rdev);
626
627         return ret;
628 }
629
630 /**
631  * radeon_acpi_fini - tear down driver acpi support
632  *
633  * @rdev: radeon_device pointer
634  *
635  * Unregisters with the acpi notifier chain (all asics).
636  */
637 void radeon_acpi_fini(struct radeon_device *rdev)
638 {
639         AcpiRemoveNotifyHandler(rdev->acpi.handle, ACPI_DEVICE_NOTIFY,
640             rdev->acpi.notifier_call);
641 }