This source file includes following definitions.
- amdgpu_atif_call
- amdgpu_atif_parse_notification
- amdgpu_atif_parse_functions
- amdgpu_atif_verify_interface
- amdgpu_atif_probe_handle
- amdgpu_atif_get_notification_params
- amdgpu_atif_query_backlight_caps
- amdgpu_atif_get_sbios_requests
- amdgpu_atif_handler
- amdgpu_atcs_call
- amdgpu_atcs_parse_functions
- amdgpu_atcs_verify_interface
- amdgpu_acpi_is_pcie_performance_request_supported
- amdgpu_acpi_pcie_notify_device_ready
- amdgpu_acpi_pcie_performance_request
- amdgpu_acpi_event
- amdgpu_acpi_init
- amdgpu_acpi_get_backlight_caps
- amdgpu_acpi_fini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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>
30
31 #include <drm/drm_crtc_helper.h>
32 #include "amdgpu.h"
33 #include "amdgpu_pm.h"
34 #include "amdgpu_display.h"
35 #include "amd_acpi.h"
36 #include "atom.h"
37
38 struct amdgpu_atif_notification_cfg {
39 bool enabled;
40 int command_code;
41 };
42
43 struct amdgpu_atif_notifications {
44 bool thermal_state;
45 bool forced_power_state;
46 bool system_power_state;
47 bool brightness_change;
48 bool dgpu_display_event;
49 bool gpu_package_power_limit;
50 };
51
52 struct amdgpu_atif_functions {
53 bool system_params;
54 bool sbios_requests;
55 bool temperature_change;
56 bool query_backlight_transfer_characteristics;
57 bool ready_to_undock;
58 bool external_gpu_information;
59 };
60
61 struct amdgpu_atif {
62 acpi_handle handle;
63
64 struct amdgpu_atif_notifications notifications;
65 struct amdgpu_atif_functions functions;
66 struct amdgpu_atif_notification_cfg notification_cfg;
67 struct amdgpu_encoder *encoder_for_bl;
68 struct amdgpu_dm_backlight_caps backlight_caps;
69 };
70
71
72
73
74
75
76
77
78
79
80
81
82
83 static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
84 int function,
85 struct acpi_buffer *params)
86 {
87 acpi_status status;
88 union acpi_object atif_arg_elements[2];
89 struct acpi_object_list atif_arg;
90 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
91
92 atif_arg.count = 2;
93 atif_arg.pointer = &atif_arg_elements[0];
94
95 atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
96 atif_arg_elements[0].integer.value = function;
97
98 if (params) {
99 atif_arg_elements[1].type = ACPI_TYPE_BUFFER;
100 atif_arg_elements[1].buffer.length = params->length;
101 atif_arg_elements[1].buffer.pointer = params->pointer;
102 } else {
103
104 atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
105 atif_arg_elements[1].integer.value = 0;
106 }
107
108 status = acpi_evaluate_object(atif->handle, NULL, &atif_arg,
109 &buffer);
110
111
112 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
113 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
114 acpi_format_exception(status));
115 kfree(buffer.pointer);
116 return NULL;
117 }
118
119 return buffer.pointer;
120 }
121
122
123
124
125
126
127
128
129
130
131
132 static void amdgpu_atif_parse_notification(struct amdgpu_atif_notifications *n, u32 mask)
133 {
134 n->thermal_state = mask & ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED;
135 n->forced_power_state = mask & ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED;
136 n->system_power_state = mask & ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED;
137 n->brightness_change = mask & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED;
138 n->dgpu_display_event = mask & ATIF_DGPU_DISPLAY_EVENT_SUPPORTED;
139 n->gpu_package_power_limit = mask & ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST_SUPPORTED;
140 }
141
142
143
144
145
146
147
148
149
150
151
152 static void amdgpu_atif_parse_functions(struct amdgpu_atif_functions *f, u32 mask)
153 {
154 f->system_params = mask & ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED;
155 f->sbios_requests = mask & ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED;
156 f->temperature_change = mask & ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED;
157 f->query_backlight_transfer_characteristics =
158 mask & ATIF_QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS_SUPPORTED;
159 f->ready_to_undock = mask & ATIF_READY_TO_UNDOCK_NOTIFICATION_SUPPORTED;
160 f->external_gpu_information = mask & ATIF_GET_EXTERNAL_GPU_INFORMATION_SUPPORTED;
161 }
162
163
164
165
166
167
168
169
170
171
172
173
174 static int amdgpu_atif_verify_interface(struct amdgpu_atif *atif)
175 {
176 union acpi_object *info;
177 struct atif_verify_interface output;
178 size_t size;
179 int err = 0;
180
181 info = amdgpu_atif_call(atif, ATIF_FUNCTION_VERIFY_INTERFACE, NULL);
182 if (!info)
183 return -EIO;
184
185 memset(&output, 0, sizeof(output));
186
187 size = *(u16 *) info->buffer.pointer;
188 if (size < 12) {
189 DRM_INFO("ATIF buffer is too small: %zu\n", size);
190 err = -EINVAL;
191 goto out;
192 }
193 size = min(sizeof(output), size);
194
195 memcpy(&output, info->buffer.pointer, size);
196
197
198 DRM_DEBUG_DRIVER("ATIF version %u\n", output.version);
199
200 amdgpu_atif_parse_notification(&atif->notifications, output.notification_mask);
201 amdgpu_atif_parse_functions(&atif->functions, output.function_bits);
202
203 out:
204 kfree(info);
205 return err;
206 }
207
208 static acpi_handle amdgpu_atif_probe_handle(acpi_handle dhandle)
209 {
210 acpi_handle handle = NULL;
211 char acpi_method_name[255] = { 0 };
212 struct acpi_buffer buffer = { sizeof(acpi_method_name), acpi_method_name };
213 acpi_status status;
214
215
216
217
218 status = acpi_get_handle(dhandle, "ATIF", &handle);
219 if (ACPI_SUCCESS(status))
220 goto out;
221
222 if (amdgpu_has_atpx()) {
223 status = acpi_get_handle(amdgpu_atpx_get_dhandle(), "ATIF",
224 &handle);
225 if (ACPI_SUCCESS(status))
226 goto out;
227 }
228
229 DRM_DEBUG_DRIVER("No ATIF handle found\n");
230 return NULL;
231 out:
232 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
233 DRM_DEBUG_DRIVER("Found ATIF handle %s\n", acpi_method_name);
234 return handle;
235 }
236
237
238
239
240
241
242
243
244
245
246
247
248
249 static int amdgpu_atif_get_notification_params(struct amdgpu_atif *atif)
250 {
251 union acpi_object *info;
252 struct amdgpu_atif_notification_cfg *n = &atif->notification_cfg;
253 struct atif_system_params params;
254 size_t size;
255 int err = 0;
256
257 info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS,
258 NULL);
259 if (!info) {
260 err = -EIO;
261 goto out;
262 }
263
264 size = *(u16 *) info->buffer.pointer;
265 if (size < 10) {
266 err = -EINVAL;
267 goto out;
268 }
269
270 memset(¶ms, 0, sizeof(params));
271 size = min(sizeof(params), size);
272 memcpy(¶ms, info->buffer.pointer, size);
273
274 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
275 params.flags, params.valid_mask);
276 params.flags = params.flags & params.valid_mask;
277
278 if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_NONE) {
279 n->enabled = false;
280 n->command_code = 0;
281 } else if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_81) {
282 n->enabled = true;
283 n->command_code = 0x81;
284 } else {
285 if (size < 11) {
286 err = -EINVAL;
287 goto out;
288 }
289 n->enabled = true;
290 n->command_code = params.command_code;
291 }
292
293 out:
294 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
295 (n->enabled ? "enabled" : "disabled"),
296 n->command_code);
297 kfree(info);
298 return err;
299 }
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317 static int amdgpu_atif_query_backlight_caps(struct amdgpu_atif *atif)
318 {
319 union acpi_object *info;
320 struct atif_qbtc_output characteristics;
321 struct atif_qbtc_arguments arguments;
322 struct acpi_buffer params;
323 size_t size;
324 int err = 0;
325
326 arguments.size = sizeof(arguments);
327 arguments.requested_display = ATIF_QBTC_REQUEST_LCD1;
328
329 params.length = sizeof(arguments);
330 params.pointer = (void *)&arguments;
331
332 info = amdgpu_atif_call(atif,
333 ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS,
334 ¶ms);
335 if (!info) {
336 err = -EIO;
337 goto out;
338 }
339
340 size = *(u16 *) info->buffer.pointer;
341 if (size < 10) {
342 err = -EINVAL;
343 goto out;
344 }
345
346 memset(&characteristics, 0, sizeof(characteristics));
347 size = min(sizeof(characteristics), size);
348 memcpy(&characteristics, info->buffer.pointer, size);
349
350 atif->backlight_caps.caps_valid = true;
351 atif->backlight_caps.min_input_signal =
352 characteristics.min_input_signal;
353 atif->backlight_caps.max_input_signal =
354 characteristics.max_input_signal;
355 out:
356 kfree(info);
357 return err;
358 }
359
360
361
362
363
364
365
366
367
368
369
370
371 static int amdgpu_atif_get_sbios_requests(struct amdgpu_atif *atif,
372 struct atif_sbios_requests *req)
373 {
374 union acpi_object *info;
375 size_t size;
376 int count = 0;
377
378 info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS,
379 NULL);
380 if (!info)
381 return -EIO;
382
383 size = *(u16 *)info->buffer.pointer;
384 if (size < 0xd) {
385 count = -EINVAL;
386 goto out;
387 }
388 memset(req, 0, sizeof(*req));
389
390 size = min(sizeof(*req), size);
391 memcpy(req, info->buffer.pointer, size);
392 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req->pending);
393
394 count = hweight32(req->pending);
395
396 out:
397 kfree(info);
398 return count;
399 }
400
401
402
403
404
405
406
407
408
409
410
411
412
413 static int amdgpu_atif_handler(struct amdgpu_device *adev,
414 struct acpi_bus_event *event)
415 {
416 struct amdgpu_atif *atif = adev->atif;
417 int count;
418
419 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
420 event->device_class, event->type);
421
422 if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0)
423 return NOTIFY_DONE;
424
425
426 if (!atif ||
427 !atif->notification_cfg.enabled ||
428 event->type != atif->notification_cfg.command_code) {
429
430 if (event->type == ACPI_VIDEO_NOTIFY_PROBE)
431 return NOTIFY_BAD;
432 else
433 return NOTIFY_DONE;
434 }
435
436 if (atif->functions.sbios_requests) {
437 struct atif_sbios_requests req;
438
439
440 count = amdgpu_atif_get_sbios_requests(atif, &req);
441
442 if (count <= 0)
443 return NOTIFY_BAD;
444
445 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
446
447
448 if ((req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) &&
449 !amdgpu_device_has_dc_support(adev)) {
450 struct amdgpu_encoder *enc = atif->encoder_for_bl;
451
452 if (enc) {
453 struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
454
455 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
456 req.backlight_level);
457
458 amdgpu_display_backlight_set_level(adev, enc, req.backlight_level);
459
460 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
461 backlight_force_update(dig->bl_dev,
462 BACKLIGHT_UPDATE_HOTKEY);
463 #endif
464 }
465 }
466 if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
467 if (adev->flags & AMD_IS_PX) {
468 pm_runtime_get_sync(adev->ddev->dev);
469
470 drm_helper_hpd_irq_event(adev->ddev);
471 pm_runtime_mark_last_busy(adev->ddev->dev);
472 pm_runtime_put_autosuspend(adev->ddev->dev);
473 }
474 }
475
476 }
477
478
479
480
481
482
483 return NOTIFY_BAD;
484 }
485
486
487
488
489
490
491
492
493
494
495
496
497
498 static union acpi_object *amdgpu_atcs_call(acpi_handle handle, int function,
499 struct acpi_buffer *params)
500 {
501 acpi_status status;
502 union acpi_object atcs_arg_elements[2];
503 struct acpi_object_list atcs_arg;
504 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
505
506 atcs_arg.count = 2;
507 atcs_arg.pointer = &atcs_arg_elements[0];
508
509 atcs_arg_elements[0].type = ACPI_TYPE_INTEGER;
510 atcs_arg_elements[0].integer.value = function;
511
512 if (params) {
513 atcs_arg_elements[1].type = ACPI_TYPE_BUFFER;
514 atcs_arg_elements[1].buffer.length = params->length;
515 atcs_arg_elements[1].buffer.pointer = params->pointer;
516 } else {
517
518 atcs_arg_elements[1].type = ACPI_TYPE_INTEGER;
519 atcs_arg_elements[1].integer.value = 0;
520 }
521
522 status = acpi_evaluate_object(handle, "ATCS", &atcs_arg, &buffer);
523
524
525 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
526 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
527 acpi_format_exception(status));
528 kfree(buffer.pointer);
529 return NULL;
530 }
531
532 return buffer.pointer;
533 }
534
535
536
537
538
539
540
541
542
543
544
545 static void amdgpu_atcs_parse_functions(struct amdgpu_atcs_functions *f, u32 mask)
546 {
547 f->get_ext_state = mask & ATCS_GET_EXTERNAL_STATE_SUPPORTED;
548 f->pcie_perf_req = mask & ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED;
549 f->pcie_dev_rdy = mask & ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED;
550 f->pcie_bus_width = mask & ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED;
551 }
552
553
554
555
556
557
558
559
560
561
562
563
564 static int amdgpu_atcs_verify_interface(acpi_handle handle,
565 struct amdgpu_atcs *atcs)
566 {
567 union acpi_object *info;
568 struct atcs_verify_interface output;
569 size_t size;
570 int err = 0;
571
572 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_VERIFY_INTERFACE, NULL);
573 if (!info)
574 return -EIO;
575
576 memset(&output, 0, sizeof(output));
577
578 size = *(u16 *) info->buffer.pointer;
579 if (size < 8) {
580 DRM_INFO("ATCS buffer is too small: %zu\n", size);
581 err = -EINVAL;
582 goto out;
583 }
584 size = min(sizeof(output), size);
585
586 memcpy(&output, info->buffer.pointer, size);
587
588
589 DRM_DEBUG_DRIVER("ATCS version %u\n", output.version);
590
591 amdgpu_atcs_parse_functions(&atcs->functions, output.function_bits);
592
593 out:
594 kfree(info);
595 return err;
596 }
597
598
599
600
601
602
603
604
605
606
607 bool amdgpu_acpi_is_pcie_performance_request_supported(struct amdgpu_device *adev)
608 {
609 struct amdgpu_atcs *atcs = &adev->atcs;
610
611 if (atcs->functions.pcie_perf_req && atcs->functions.pcie_dev_rdy)
612 return true;
613
614 return false;
615 }
616
617
618
619
620
621
622
623
624
625
626 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev)
627 {
628 acpi_handle handle;
629 union acpi_object *info;
630 struct amdgpu_atcs *atcs = &adev->atcs;
631
632
633 handle = ACPI_HANDLE(&adev->pdev->dev);
634 if (!handle)
635 return -EINVAL;
636
637 if (!atcs->functions.pcie_dev_rdy)
638 return -EINVAL;
639
640 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION, NULL);
641 if (!info)
642 return -EIO;
643
644 kfree(info);
645
646 return 0;
647 }
648
649
650
651
652
653
654
655
656
657
658
659
660 int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
661 u8 perf_req, bool advertise)
662 {
663 acpi_handle handle;
664 union acpi_object *info;
665 struct amdgpu_atcs *atcs = &adev->atcs;
666 struct atcs_pref_req_input atcs_input;
667 struct atcs_pref_req_output atcs_output;
668 struct acpi_buffer params;
669 size_t size;
670 u32 retry = 3;
671
672 if (amdgpu_acpi_pcie_notify_device_ready(adev))
673 return -EINVAL;
674
675
676 handle = ACPI_HANDLE(&adev->pdev->dev);
677 if (!handle)
678 return -EINVAL;
679
680 if (!atcs->functions.pcie_perf_req)
681 return -EINVAL;
682
683 atcs_input.size = sizeof(struct atcs_pref_req_input);
684
685 atcs_input.client_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
686 atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
687 atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
688 if (advertise)
689 atcs_input.flags |= ATCS_ADVERTISE_CAPS;
690 atcs_input.req_type = ATCS_PCIE_LINK_SPEED;
691 atcs_input.perf_req = perf_req;
692
693 params.length = sizeof(struct atcs_pref_req_input);
694 params.pointer = &atcs_input;
695
696 while (retry--) {
697 info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST, ¶ms);
698 if (!info)
699 return -EIO;
700
701 memset(&atcs_output, 0, sizeof(atcs_output));
702
703 size = *(u16 *) info->buffer.pointer;
704 if (size < 3) {
705 DRM_INFO("ATCS buffer is too small: %zu\n", size);
706 kfree(info);
707 return -EINVAL;
708 }
709 size = min(sizeof(atcs_output), size);
710
711 memcpy(&atcs_output, info->buffer.pointer, size);
712
713 kfree(info);
714
715 switch (atcs_output.ret_val) {
716 case ATCS_REQUEST_REFUSED:
717 default:
718 return -EINVAL;
719 case ATCS_REQUEST_COMPLETE:
720 return 0;
721 case ATCS_REQUEST_IN_PROGRESS:
722 udelay(10);
723 break;
724 }
725 }
726
727 return 0;
728 }
729
730
731
732
733
734
735
736
737
738
739
740
741 static int amdgpu_acpi_event(struct notifier_block *nb,
742 unsigned long val,
743 void *data)
744 {
745 struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, acpi_nb);
746 struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
747
748 if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) {
749 if (power_supply_is_system_supplied() > 0)
750 DRM_DEBUG_DRIVER("pm: AC\n");
751 else
752 DRM_DEBUG_DRIVER("pm: DC\n");
753
754 amdgpu_pm_acpi_event_handler(adev);
755 }
756
757
758 return amdgpu_atif_handler(adev, entry);
759 }
760
761
762
763
764
765
766
767
768
769
770
771 int amdgpu_acpi_init(struct amdgpu_device *adev)
772 {
773 acpi_handle handle, atif_handle;
774 struct amdgpu_atif *atif;
775 struct amdgpu_atcs *atcs = &adev->atcs;
776 int ret;
777
778
779 handle = ACPI_HANDLE(&adev->pdev->dev);
780
781 if (!adev->bios || !handle)
782 return 0;
783
784
785 ret = amdgpu_atcs_verify_interface(handle, atcs);
786 if (ret) {
787 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret);
788 }
789
790
791 atif_handle = amdgpu_atif_probe_handle(handle);
792 if (!atif_handle)
793 goto out;
794
795 atif = kzalloc(sizeof(*atif), GFP_KERNEL);
796 if (!atif) {
797 DRM_WARN("Not enough memory to initialize ATIF\n");
798 goto out;
799 }
800 atif->handle = atif_handle;
801
802
803 ret = amdgpu_atif_verify_interface(atif);
804 if (ret) {
805 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret);
806 kfree(atif);
807 goto out;
808 }
809 adev->atif = atif;
810
811 if (atif->notifications.brightness_change) {
812 struct drm_encoder *tmp;
813
814
815 list_for_each_entry(tmp, &adev->ddev->mode_config.encoder_list,
816 head) {
817 struct amdgpu_encoder *enc = to_amdgpu_encoder(tmp);
818
819 if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
820 enc->enc_priv) {
821 struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
822 if (dig->bl_dev) {
823 atif->encoder_for_bl = enc;
824 break;
825 }
826 }
827 }
828 }
829
830 if (atif->functions.sbios_requests && !atif->functions.system_params) {
831
832
833
834
835 atif->functions.system_params = true;
836 }
837
838 if (atif->functions.system_params) {
839 ret = amdgpu_atif_get_notification_params(atif);
840 if (ret) {
841 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
842 ret);
843
844 atif->notification_cfg.enabled = false;
845 }
846 }
847
848 if (atif->functions.query_backlight_transfer_characteristics) {
849 ret = amdgpu_atif_query_backlight_caps(atif);
850 if (ret) {
851 DRM_DEBUG_DRIVER("Call to QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS failed: %d\n",
852 ret);
853 atif->backlight_caps.caps_valid = false;
854 }
855 } else {
856 atif->backlight_caps.caps_valid = false;
857 }
858
859 out:
860 adev->acpi_nb.notifier_call = amdgpu_acpi_event;
861 register_acpi_notifier(&adev->acpi_nb);
862
863 return ret;
864 }
865
866 void amdgpu_acpi_get_backlight_caps(struct amdgpu_device *adev,
867 struct amdgpu_dm_backlight_caps *caps)
868 {
869 if (!adev->atif) {
870 caps->caps_valid = false;
871 return;
872 }
873 caps->caps_valid = adev->atif->backlight_caps.caps_valid;
874 caps->min_input_signal = adev->atif->backlight_caps.min_input_signal;
875 caps->max_input_signal = adev->atif->backlight_caps.max_input_signal;
876 }
877
878
879
880
881
882
883
884
885 void amdgpu_acpi_fini(struct amdgpu_device *adev)
886 {
887 unregister_acpi_notifier(&adev->acpi_nb);
888 kfree(adev->atif);
889 }