diff options
author | Lyude Paul <lyude@redhat.com> | 2018-06-25 21:09:04 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-07-05 17:38:57 -0400 |
commit | 102c16a0246d77043e555e1e5b5de316bc068cbc (patch) | |
tree | dedf1633f31baed7e4696cc8057cc8cd40a7ce64 /drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | |
parent | 0c3d01744511f053c5f67737cb7a6a99c0216a84 (diff) |
drm/amdgpu: Make struct amdgpu_atif private to amdgpu_acpi.c
Currently, there is nothing in amdgpu that actually uses these structs
other than amdgpu_acpi.c. Additionally, since we're about to start
saving the correct ACPI handle to use for calling ATIF in this struct
this saves us from having to handle making sure that the acpi_handle
(and by proxy, the type definition for acpi_handle and all of the other
acpi headers) doesn't need to be included within the amdgpu_drv struct
itself. This follows the example set by amdgpu_atpx_handler.c.
Signed-off-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index 8fa850a070e0..22c7e8ec0b9a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | |||
@@ -34,6 +34,43 @@ | |||
34 | #include "amd_acpi.h" | 34 | #include "amd_acpi.h" |
35 | #include "atom.h" | 35 | #include "atom.h" |
36 | 36 | ||
37 | struct amdgpu_atif_notification_cfg { | ||
38 | bool enabled; | ||
39 | int command_code; | ||
40 | }; | ||
41 | |||
42 | struct amdgpu_atif_notifications { | ||
43 | bool display_switch; | ||
44 | bool expansion_mode_change; | ||
45 | bool thermal_state; | ||
46 | bool forced_power_state; | ||
47 | bool system_power_state; | ||
48 | bool display_conf_change; | ||
49 | bool px_gfx_switch; | ||
50 | bool brightness_change; | ||
51 | bool dgpu_display_event; | ||
52 | }; | ||
53 | |||
54 | struct amdgpu_atif_functions { | ||
55 | bool system_params; | ||
56 | bool sbios_requests; | ||
57 | bool select_active_disp; | ||
58 | bool lid_state; | ||
59 | bool get_tv_standard; | ||
60 | bool set_tv_standard; | ||
61 | bool get_panel_expansion_mode; | ||
62 | bool set_panel_expansion_mode; | ||
63 | bool temperature_change; | ||
64 | bool graphics_device_types; | ||
65 | }; | ||
66 | |||
67 | struct amdgpu_atif { | ||
68 | struct amdgpu_atif_notifications notifications; | ||
69 | struct amdgpu_atif_functions functions; | ||
70 | struct amdgpu_atif_notification_cfg notification_cfg; | ||
71 | struct amdgpu_encoder *encoder_for_bl; | ||
72 | }; | ||
73 | |||
37 | /* Call the ATIF method | 74 | /* Call the ATIF method |
38 | */ | 75 | */ |
39 | /** | 76 | /** |
@@ -292,7 +329,7 @@ out: | |||
292 | static int amdgpu_atif_handler(struct amdgpu_device *adev, | 329 | static int amdgpu_atif_handler(struct amdgpu_device *adev, |
293 | struct acpi_bus_event *event) | 330 | struct acpi_bus_event *event) |
294 | { | 331 | { |
295 | struct amdgpu_atif *atif = &adev->atif; | 332 | struct amdgpu_atif *atif = adev->atif; |
296 | struct atif_sbios_requests req; | 333 | struct atif_sbios_requests req; |
297 | acpi_handle handle; | 334 | acpi_handle handle; |
298 | int count; | 335 | int count; |
@@ -303,7 +340,8 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev, | |||
303 | if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) | 340 | if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) |
304 | return NOTIFY_DONE; | 341 | return NOTIFY_DONE; |
305 | 342 | ||
306 | if (!atif->notification_cfg.enabled || | 343 | if (!atif || |
344 | !atif->notification_cfg.enabled || | ||
307 | event->type != atif->notification_cfg.command_code) | 345 | event->type != atif->notification_cfg.command_code) |
308 | /* Not our event */ | 346 | /* Not our event */ |
309 | return NOTIFY_DONE; | 347 | return NOTIFY_DONE; |
@@ -642,7 +680,7 @@ static int amdgpu_acpi_event(struct notifier_block *nb, | |||
642 | int amdgpu_acpi_init(struct amdgpu_device *adev) | 680 | int amdgpu_acpi_init(struct amdgpu_device *adev) |
643 | { | 681 | { |
644 | acpi_handle handle; | 682 | acpi_handle handle; |
645 | struct amdgpu_atif *atif = &adev->atif; | 683 | struct amdgpu_atif *atif; |
646 | struct amdgpu_atcs *atcs = &adev->atcs; | 684 | struct amdgpu_atcs *atcs = &adev->atcs; |
647 | int ret; | 685 | int ret; |
648 | 686 | ||
@@ -659,11 +697,19 @@ int amdgpu_acpi_init(struct amdgpu_device *adev) | |||
659 | } | 697 | } |
660 | 698 | ||
661 | /* Call the ATIF method */ | 699 | /* Call the ATIF method */ |
700 | atif = kzalloc(sizeof(*atif), GFP_KERNEL); | ||
701 | if (!atif) { | ||
702 | DRM_WARN("Not enough memory to initialize ATIF\n"); | ||
703 | goto out; | ||
704 | } | ||
705 | |||
662 | ret = amdgpu_atif_verify_interface(handle, atif); | 706 | ret = amdgpu_atif_verify_interface(handle, atif); |
663 | if (ret) { | 707 | if (ret) { |
664 | DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret); | 708 | DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret); |
709 | kfree(atif); | ||
665 | goto out; | 710 | goto out; |
666 | } | 711 | } |
712 | adev->atif = atif; | ||
667 | 713 | ||
668 | if (atif->notifications.brightness_change) { | 714 | if (atif->notifications.brightness_change) { |
669 | struct drm_encoder *tmp; | 715 | struct drm_encoder *tmp; |
@@ -720,4 +766,6 @@ out: | |||
720 | void amdgpu_acpi_fini(struct amdgpu_device *adev) | 766 | void amdgpu_acpi_fini(struct amdgpu_device *adev) |
721 | { | 767 | { |
722 | unregister_acpi_notifier(&adev->acpi_nb); | 768 | unregister_acpi_notifier(&adev->acpi_nb); |
769 | if (adev->atif) | ||
770 | kfree(adev->atif); | ||
723 | } | 771 | } |