aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorLyude Paul <lyude@redhat.com>2018-06-25 21:09:04 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-07-05 17:38:57 -0400
commit102c16a0246d77043e555e1e5b5de316bc068cbc (patch)
treededf1633f31baed7e4696cc8057cc8cd40a7ce64 /drivers/gpu/drm/amd
parent0c3d01744511f053c5f67737cb7a6a99c0216a84 (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')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h40
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c54
2 files changed, 53 insertions, 41 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 86e4d8bd52a6..219fea72beeb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -190,6 +190,7 @@ struct amdgpu_job;
190struct amdgpu_irq_src; 190struct amdgpu_irq_src;
191struct amdgpu_fpriv; 191struct amdgpu_fpriv;
192struct amdgpu_bo_va_mapping; 192struct amdgpu_bo_va_mapping;
193struct amdgpu_atif;
193 194
194enum amdgpu_cp_irq { 195enum amdgpu_cp_irq {
195 AMDGPU_CP_IRQ_GFX_EOP = 0, 196 AMDGPU_CP_IRQ_GFX_EOP = 0,
@@ -1278,43 +1279,6 @@ struct amdgpu_vram_scratch {
1278/* 1279/*
1279 * ACPI 1280 * ACPI
1280 */ 1281 */
1281struct amdgpu_atif_notification_cfg {
1282 bool enabled;
1283 int command_code;
1284};
1285
1286struct amdgpu_atif_notifications {
1287 bool display_switch;
1288 bool expansion_mode_change;
1289 bool thermal_state;
1290 bool forced_power_state;
1291 bool system_power_state;
1292 bool display_conf_change;
1293 bool px_gfx_switch;
1294 bool brightness_change;
1295 bool dgpu_display_event;
1296};
1297
1298struct amdgpu_atif_functions {
1299 bool system_params;
1300 bool sbios_requests;
1301 bool select_active_disp;
1302 bool lid_state;
1303 bool get_tv_standard;
1304 bool set_tv_standard;
1305 bool get_panel_expansion_mode;
1306 bool set_panel_expansion_mode;
1307 bool temperature_change;
1308 bool graphics_device_types;
1309};
1310
1311struct amdgpu_atif {
1312 struct amdgpu_atif_notifications notifications;
1313 struct amdgpu_atif_functions functions;
1314 struct amdgpu_atif_notification_cfg notification_cfg;
1315 struct amdgpu_encoder *encoder_for_bl;
1316};
1317
1318struct amdgpu_atcs_functions { 1282struct amdgpu_atcs_functions {
1319 bool get_ext_state; 1283 bool get_ext_state;
1320 bool pcie_perf_req; 1284 bool pcie_perf_req;
@@ -1475,7 +1439,7 @@ struct amdgpu_device {
1475#if defined(CONFIG_DEBUG_FS) 1439#if defined(CONFIG_DEBUG_FS)
1476 struct dentry *debugfs_regs[AMDGPU_DEBUGFS_MAX_COMPONENTS]; 1440 struct dentry *debugfs_regs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
1477#endif 1441#endif
1478 struct amdgpu_atif atif; 1442 struct amdgpu_atif *atif;
1479 struct amdgpu_atcs atcs; 1443 struct amdgpu_atcs atcs;
1480 struct mutex srbm_mutex; 1444 struct mutex srbm_mutex;
1481 /* GRBM index mutex. Protects concurrent access to GRBM index */ 1445 /* GRBM index mutex. Protects concurrent access to GRBM index */
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
37struct amdgpu_atif_notification_cfg {
38 bool enabled;
39 int command_code;
40};
41
42struct 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
54struct 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
67struct 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:
292static int amdgpu_atif_handler(struct amdgpu_device *adev, 329static 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,
642int amdgpu_acpi_init(struct amdgpu_device *adev) 680int 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:
720void amdgpu_acpi_fini(struct amdgpu_device *adev) 766void 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}