dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Rex Zhu <Rex.Zhu@amd.com>
Subject: [PATCH 31/51] drm/amdgpu/powerplay: program display gap for tonga.
Date: Thu, 12 Nov 2015 01:18:21 -0500	[thread overview]
Message-ID: <1447309121-2480-32-git-send-email-alexander.deucher@amd.com> (raw)
In-Reply-To: <1447309121-2480-1-git-send-email-alexander.deucher@amd.com>

From: Rex Zhu <Rex.Zhu@amd.com>

Implement displaygap programming for tonga.  This is
required for properly mclk switching.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c | 91 +++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
index 1a02c7d..fe8b315 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
@@ -168,6 +168,13 @@ int tonga_add_voltage(struct pp_hwmgr *hwmgr,
 	return 0;
 }
 
+int tonga_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display)
+{
+	PPSMC_Msg msg = has_display? (PPSMC_Msg)PPSMC_HasDisplay : (PPSMC_Msg)PPSMC_NoDisplay;
+
+	return (smum_send_msg_to_smc(hwmgr->smumgr, msg) == 0) ?  0 : -1;
+}
+
 uint8_t tonga_get_voltage_id(pp_atomctrl_voltage_table *voltage_table,
 		uint32_t voltage)
 {
@@ -4392,6 +4399,10 @@ int tonga_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
 	PP_ASSERT_WITH_CODE((0 == tmp_result),
 		"Failed to populate initialize MC Reg table!", result = tmp_result);
 
+	tmp_result = tonga_notify_smc_display_change(hwmgr, false);
+	PP_ASSERT_WITH_CODE((0 == tmp_result),
+		"Failed to notify no display!", result = tmp_result);
+
 	/* enable SCLK control */
 	tmp_result = tonga_enable_sclk_control(hwmgr);
 	PP_ASSERT_WITH_CODE((0 == tmp_result),
@@ -5679,6 +5690,84 @@ static int tonga_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input
 	return result;
 }
 
+
+int tonga_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr)
+{
+	uint32_t num_active_displays = 0;
+	struct cgs_display_info info = {0};
+	info.mode_info = NULL;
+
+	cgs_get_active_displays_info(hwmgr->device, &info);
+
+	num_active_displays = info.display_count;
+
+	if (num_active_displays > 1)  /* to do && (pHwMgr->pPECI->displayConfiguration.bMultiMonitorInSync != TRUE)) */
+		tonga_notify_smc_display_change(hwmgr, false);
+	else
+		tonga_notify_smc_display_change(hwmgr, true);
+
+	return 0;
+}
+
+/**
+* Programs the display gap
+*
+* @param    hwmgr  the address of the powerplay hardware manager.
+* @return   always OK
+*/
+int tonga_program_display_gap(struct pp_hwmgr *hwmgr)
+{
+	struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
+	uint32_t num_active_displays = 0;
+	uint32_t display_gap = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixCG_DISPLAY_GAP_CNTL);
+	uint32_t display_gap2;
+	uint32_t pre_vbi_time_in_us;
+	uint32_t frame_time_in_us;
+	uint32_t ref_clock;
+	uint32_t refresh_rate = 0;
+	struct cgs_display_info info = {0};
+	struct cgs_mode_info mode_info;
+
+	info.mode_info = &mode_info;
+
+	cgs_get_active_displays_info(hwmgr->device, &info);
+	num_active_displays = info.display_count;
+
+	display_gap = PHM_SET_FIELD(display_gap, CG_DISPLAY_GAP_CNTL, DISP_GAP, (num_active_displays > 0)? DISPLAY_GAP_VBLANK_OR_WM : DISPLAY_GAP_IGNORE);
+	cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixCG_DISPLAY_GAP_CNTL, display_gap);
+
+	ref_clock = mode_info.ref_clock;
+	refresh_rate = mode_info.refresh_rate;
+
+	if(0 == refresh_rate)
+		refresh_rate = 60;
+
+	frame_time_in_us = 1000000 / refresh_rate;
+
+	pre_vbi_time_in_us = frame_time_in_us - 200 - mode_info.vblank_time_us;
+	display_gap2 = pre_vbi_time_in_us * (ref_clock / 100);
+
+	cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixCG_DISPLAY_GAP_CNTL2, display_gap2);
+
+	cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, data->soft_regs_start + offsetof(SMU72_SoftRegisters, PreVBlankGap), 0x64);
+
+	cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, data->soft_regs_start + offsetof(SMU72_SoftRegisters, VBlankTimeout), (frame_time_in_us - pre_vbi_time_in_us));
+
+	if (num_active_displays == 1)
+		tonga_notify_smc_display_change(hwmgr, true);
+
+	return 0;
+}
+
+int tonga_display_configuration_changed_task(struct pp_hwmgr *hwmgr)
+{
+
+	tonga_program_display_gap(hwmgr);
+
+	/* to do PhwTonga_CacUpdateDisplayConfiguration(pHwMgr); */
+	return 0;
+}
+
 static const struct pp_hwmgr_func tonga_hwmgr_funcs = {
 	.backend_init = &tonga_hwmgr_backend_init,
 	.backend_fini = &tonga_hwmgr_backend_fini,
@@ -5694,6 +5783,8 @@ static const struct pp_hwmgr_func tonga_hwmgr_funcs = {
 	.get_pp_table_entry = tonga_get_pp_table_entry,
 	.get_num_of_pp_table_entries = tonga_get_number_of_powerplay_table_entries,
 	.print_current_perforce_level = tonga_print_current_perforce_level,
+	.notify_smc_display_config_after_ps_adjustment = tonga_notify_smc_display_config_after_ps_adjustment,
+	.display_config_changed = tonga_display_configuration_changed_task,
 };
 
 int tonga_hwmgr_init(struct pp_hwmgr *hwmgr)
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-11-12  6:19 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12  6:17 [PATCH 00/51] Add amdgpu powerplay support Alex Deucher
2015-11-12  6:17 ` [PATCH 01/51] drm/amdgpu: share struct amdgpu_pm_state_type with powerplay module Alex Deucher
2015-11-12  6:17 ` [PATCH 02/51] drm/amdgpu: mv some definition from amdgpu_acpi.c to amdgpu_acpi.h Alex Deucher
2015-11-12  6:17 ` [PATCH 03/51] drm/amdgpu: mv amdgpu_acpi.h to amd/include/amd_acpi.h Alex Deucher
2015-11-12  6:17 ` [PATCH 04/51] drm/amdgpu: implement new cgs interface for acpi function Alex Deucher
2015-11-12  6:17 ` [PATCH 05/51] drm/amdgpu: implement cgs interface to query system info Alex Deucher
2015-11-12  6:17 ` [PATCH 06/51] drm/amdgpu: add new cgs interface to get display info (v2) Alex Deucher
2015-11-12  6:17 ` [PATCH 07/51] drm/amd/powerplay: add basic powerplay framework Alex Deucher
2015-11-12  6:17 ` [PATCH 08/51] drm/amdgpu: disable legacy path of firmware check if powerplay is enabled Alex Deucher
2015-11-12  6:17 ` [PATCH 09/51] drm/amdgpu: export amd_powerplay_func to amdgpu and other ip block Alex Deucher
2015-11-12  6:18 ` [PATCH 10/51] drm/amd/powerplay: add SMU manager sub-component Alex Deucher
2015-11-12  6:18 ` [PATCH 11/51] drm/amd/powerplay: add hardware " Alex Deucher
2015-11-12  6:18 ` [PATCH 12/51] drm/amd/powerplay: add Carrizo smu support Alex Deucher
2015-11-12  6:18 ` [PATCH 13/51] drm/amd/powerplay: add Carrizo dpm support Alex Deucher
2015-11-12  6:18 ` [PATCH 14/51] drm/amd/powerplay: add CG and PG support for carrizo Alex Deucher
2015-11-12  6:18 ` [PATCH 15/51] drm/amd/powerplay: add event manager sub-component Alex Deucher
2015-11-12  6:18 ` [PATCH 16/51] drm/amd/powerplay: implement functions of amd_powerplay_func Alex Deucher
2015-11-12  6:18 ` [PATCH 17/51] drm/amd/powerplay: Add ixSWRST_COMMAND_1 in bif_5_0_d.h Alex Deucher
2015-11-12  6:18 ` [PATCH 18/51] drm/amd/powerplay: Move smu7*.h from amdgpu to powerplay Alex Deucher
2015-11-12  6:18 ` [PATCH 19/51] drm/amd/powerplay: add header file for tonga smu and dpm Alex Deucher
2015-11-12  6:18 ` [PATCH 20/51] drm/amd/powerplay: Add Tonga SMU support Alex Deucher
2015-11-12  6:18 ` [PATCH 21/51] drm/amd/powerplay: add Tonga dpm support (v3) Alex Deucher
2015-11-12  6:18 ` [PATCH 22/51] drm/amd/powerplay: add/update headers for Fiji SMU and DPM Alex Deucher
2015-11-12  6:18 ` [PATCH 23/51] drm/amd/powerplay: update atomctrl for fiji Alex Deucher
2015-11-12  6:18 ` [PATCH 24/51] drm/amd/powerplay: add Fiji SMU support Alex Deucher
2015-11-12  6:18 ` [PATCH 25/51] drm/amd/powerplay: add Fiji DPM support Alex Deucher
2015-11-12  6:18 ` [PATCH 26/51] drm/amdgpu: add amdgpu.powerplay module option Alex Deucher
2015-11-12  6:18 ` [PATCH 27/51] drm/amd/amdgpu: enable powerplay and smc firmware loading for Fiji Alex Deucher
2015-11-12  6:18 ` [PATCH 28/51] drm/amdgpu/powerplay: add function point in hwmgr_funcs for program display gap Alex Deucher
2015-11-12  6:18 ` [PATCH 29/51] drm/amdgpu/poweprlay: export program display gap function to eventmgr Alex Deucher
2015-11-12  6:18 ` [PATCH 30/51] drm/amdgpu/powerplay: implement pem_task for display_configuration_change Alex Deucher
2015-11-12  6:18 ` Alex Deucher [this message]
2015-11-12  6:18 ` [PATCH 32/51] drm/amdgpu: enable powerplay module by default for tonga Alex Deucher
2015-11-12  6:18 ` [PATCH 33/51] drm/amdgpu: enable powerplay module by default for fiji Alex Deucher
2015-11-12  6:18 ` [PATCH 34/51] drm/amdgpu/powerplay: add some definition for other ip block to update cg pg Alex Deucher
2015-11-12  6:18 ` [PATCH 35/51] drm/amd/powerplay: add new function point in hwmgr_func for CG/PG Alex Deucher
2015-11-12  6:18 ` [PATCH 36/51] drm/amd/powerplay: Add CG and PG support for tonga Alex Deucher
2015-11-12  6:18 ` [PATCH 37/51] drm/amdgpu/powerplay: add new function point in hwmgr_funcs for thermal control Alex Deucher
2015-11-12  6:18 ` [PATCH 38/51] drm/amdgpu/powerplay: mv ppinterrupt.h to inc folder to share with other submodule Alex Deucher
2015-11-12  6:18 ` [PATCH 39/51] drm/amdgpu/powerplay: add thermal control interface in hwmgr Alex Deucher
2015-11-12  6:18 ` [PATCH 40/51] drm/amdgpu/powerplay: enable thermal interrupt task in eventmgr Alex Deucher
2015-11-12  6:18 ` [PATCH 41/51] drm/amdgpu/powerplay: implement thermal control for tonga Alex Deucher
2015-11-12  6:18 ` [PATCH 42/51] drm/amdgpu/powerplay: implement fan control interface in amd_powerplay_funcs Alex Deucher
2015-11-12  6:18 ` [PATCH 43/51] drm/amdgpu: export fan control functions to amdgpu Alex Deucher
2015-11-12  6:18 ` [PATCH 44/51] drm/amdgpu: enable sysfs interface for powerplay Alex Deucher
2015-11-12  6:18 ` [PATCH 45/51] drm/amdgpu: support per device powerplay enablement (v2) Alex Deucher
2015-11-12  6:18 ` [PATCH 46/51] drm/amd/powerplay: add and export hwmgr interface to eventmgr to check hw states Alex Deucher
2015-11-12  6:18 ` [PATCH 47/51] drm/amd/powerplay: implement new funcs to check current states for tonga Alex Deucher
2015-11-12  6:18 ` [PATCH 48/51] drm/amd/powerplay: refine the logic of whether need to update power state Alex Deucher
2015-11-12  6:18 ` [PATCH 49/51] drm/amd/powerplay/tonga: enable pcie and mclk forcing for low Alex Deucher
2015-11-12  6:18 ` [PATCH 50/51] drm/amd/powerplay/fiji: " Alex Deucher
2015-11-12  6:18 ` [PATCH 51/51] drm/amdgpu: extract pcie helpers to common header Alex Deucher
2015-11-12 11:05 ` [PATCH 00/51] Add amdgpu powerplay support Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447309121-2480-32-git-send-email-alexander.deucher@amd.com \
    --to=alexdeucher@gmail.com \
    --cc=Rex.Zhu@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox