From patchwork Fri Oct 18 23:30:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 3070521 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5A92B9F288 for ; Fri, 18 Oct 2013 23:39:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70C8B20489 for ; Fri, 18 Oct 2013 23:39:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2B3742047C for ; Fri, 18 Oct 2013 23:39:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EEE6C43698 for ; Fri, 18 Oct 2013 16:39:42 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f175.google.com (mail-qc0-f175.google.com [209.85.216.175]) by gabe.freedesktop.org (Postfix) with ESMTP id C77FCE758D for ; Fri, 18 Oct 2013 16:30:22 -0700 (PDT) Received: by mail-qc0-f175.google.com with SMTP id v2so3709666qcr.20 for ; Fri, 18 Oct 2013 16:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=jFYSLIKasdCIxT0OEOs934gw9sDNQA1lhgsEdqvBfDg=; b=lmJJ6DRbecfam+hVLNuiUkkUOZgzBgRim3dtoKsMUZzeRragBbWBn8wHjVhaD+2H/j 86vy9IdPgusoKn0iq9VekO8Jdvffaml5Y1tcaGKG11d5JeIiICP0SMfEQX4QWxWeFg6e kUMcfc8/p5sSRBZzjnJuUgWBrwZD7GBBQERF+94YzRF6cxsUHIPi0HbSmahODzN/cuF1 nXYBSDnamEZoGdIwl37tsLw0GtnwjRm5YKPW6tGLsvgTF+bq7ndnzcZAcVnvuZNVBhAI 408Yde3udo3nSA0aXbCanLa9guIs5lppItJ/Gioa9CuzI0dWKxhanhkllogWIFX/84xF pY7A== X-Received: by 10.224.125.4 with SMTP id w4mr7888303qar.75.1382139022236; Fri, 18 Oct 2013 16:30:22 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by mx.google.com with ESMTPSA id x10sm10604172qas.5.2013.10.18.16.30.21 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2013 16:30:21 -0700 (PDT) From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon/audio: use actual pll clock for setting up dto Date: Fri, 18 Oct 2013 19:30:15 -0400 Message-Id: <1382139015-2714-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 Cc: Alex Deucher X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the actual pll clock (rather than the mode clock) to set up the audio dto. This fixes audio playback speed issues when the pll clock does not exactly match the mode clock. Signed-off-by: Alex Deucher Reviewed-by: Christian König --- drivers/gpu/drm/radeon/atombios_crtc.c | 2 ++ drivers/gpu/drm/radeon/evergreen_hdmi.c | 9 +++++---- drivers/gpu/drm/radeon/r600_hdmi.c | 16 +++++++++------- drivers/gpu/drm/radeon/radeon_mode.h | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index bf87f6d..3a6059f 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c @@ -1027,6 +1027,8 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode radeon_compute_pll_legacy(pll, radeon_crtc->adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, &ref_div, &post_div); + radeon_crtc->pll_clock = pll_clock * 10; /* convert to khz units */ + atombios_crtc_program_ss(rdev, ATOM_DISABLE, radeon_crtc->pll_id, radeon_crtc->crtc_id, &radeon_crtc->ss); diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index 6787365..0d55870 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c @@ -225,7 +225,7 @@ static void evergreen_hdmi_update_avi_infoframe(struct drm_encoder *encoder, frame[0xC] | (frame[0xD] << 8) | (header[1] << 24)); } -static void evergreen_audio_set_dto(struct drm_encoder *encoder, u32 clock) +static void evergreen_audio_set_dto(struct drm_encoder *encoder) { struct drm_device *dev = encoder->dev; struct radeon_device *rdev = dev->dev_private; @@ -233,9 +233,10 @@ static void evergreen_audio_set_dto(struct drm_encoder *encoder, u32 clock) struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); u32 base_rate = 24000; - u32 max_ratio = clock / base_rate; + u32 max_ratio = radeon_crtc->pll_clock / base_rate; u32 dto_phase; - u32 dto_modulo = clock; + /* need to use the exact pll clock here to keep audio rate correct */ + u32 dto_modulo = radeon_crtc->pll_clock; u32 wallclock_ratio; u32 dto_cntl; @@ -296,7 +297,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode return; offset = dig->afmt->offset; - evergreen_audio_set_dto(encoder, mode->clock); + evergreen_audio_set_dto(encoder); WREG32(HDMI_VBI_PACKET_CONTROL + offset, HDMI_NULL_SEND); /* send null packets when required */ diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c index 21f2b74..b8c444e 100644 --- a/drivers/gpu/drm/radeon/r600_hdmi.c +++ b/drivers/gpu/drm/radeon/r600_hdmi.c @@ -219,16 +219,18 @@ static void r600_hdmi_audio_workaround(struct drm_encoder *encoder) value, ~HDMI0_AUDIO_TEST_EN); } -void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock) +static void r600_audio_set_dto(struct drm_encoder *encoder) { struct drm_device *dev = encoder->dev; struct radeon_device *rdev = dev->dev_private; struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; + struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); u32 base_rate = 24000; - u32 max_ratio = clock / base_rate; + u32 max_ratio = radeon_crtc->pll_clock / base_rate; u32 dto_phase; - u32 dto_modulo = clock; + /* need to use the exact pll clock here to keep audio rate correct */ + u32 dto_modulo = radeon_crtc->pll_clock; u32 wallclock_ratio; u32 dto_cntl; @@ -279,17 +281,17 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock) */ if (dig->dig_encoder == 0) { WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); - WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100); + WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo * 100); WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */ } else { WREG32(DCCG_AUDIO_DTO1_PHASE, base_rate * 100); - WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100); + WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo * 100); WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ } } else { /* according to the reg specs, this should be DCE2.0 and DCE3.0/3.1 */ WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) | - AUDIO_DTO_MODULE(clock / 10)); + AUDIO_DTO_MODULE(dto_modulo / 10)); } } @@ -420,7 +422,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod return; offset = dig->afmt->offset; - r600_audio_set_dto(encoder, mode->clock); + r600_audio_set_dto(encoder); WREG32(HDMI0_VBI_PACKET_CONTROL + offset, HDMI0_NULL_SEND); /* send null packets when required */ diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h index 8b4e712..5b5339b 100644 --- a/drivers/gpu/drm/radeon/radeon_mode.h +++ b/drivers/gpu/drm/radeon/radeon_mode.h @@ -341,6 +341,7 @@ struct radeon_crtc { u32 wm_low; u32 wm_high; struct drm_display_mode hw_mode; + u32 pll_clock; /* actual clock generated by the pll */ }; struct radeon_encoder_primary_dac {