From patchwork Sun Oct 13 16:26:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 3033671 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5DE8BBF924 for ; Sun, 13 Oct 2013 16:27:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F29F203EC for ; Sun, 13 Oct 2013 16:27:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1B399203EB for ; Sun, 13 Oct 2013 16:27:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F401BE6313 for ; Sun, 13 Oct 2013 09:27:39 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id C814CE6273 for ; Sun, 13 Oct 2013 09:26:34 -0700 (PDT) Received: by mail-ee0-f49.google.com with SMTP id d41so2827744eek.8 for ; Sun, 13 Oct 2013 09:26:32 -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=TTc0Kl7GJ3I/zdgEi4lEqVOVDI5T7BajCvwVI/cHP24=; b=vDohLrrhqu5aO0Fyu8QFmH0yMa3VV3qkc7SYKfft/f0eC4SJ5BDINlBTs9IcHCD0wx RxJT15IxUijNMiM5NpNyz3Cb7R4pheqDGNSN8m9/Se2bdTAbU0lLI+GxgtgFDeis5yQv RDzi5rE3aVd9Xe4r59k8eEYyaErVWrWVMz67EGfFcJncpQiigfPiLSM4CIPael1mvRj4 he3no0jYzSUPiZnhTXqweR+Pq3eY/9zSeHCZHiNK0QShw1dgEr842v904KKfPjfu8gO6 IVk8waUV2unjqJ1ludLXb+7CZzEo+Vd79d2vb+q1UVBy3rxLoscWMN8CXi3MMrjXcZsE 14/Q== X-Received: by 10.14.246.11 with SMTP id p11mr49164143eer.9.1381681592747; Sun, 13 Oct 2013 09:26:32 -0700 (PDT) Received: from linux-samsung700g7a.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPSA id r48sm142203167eev.14.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 13 Oct 2013 09:26:32 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: dri-devel@lists.freedesktop.org Subject: [RFC][PATCH] drm/radeon: put DCE4 audio init/fini in evergreen_hdmi.c Date: Sun, 13 Oct 2013 18:26:24 +0200 Message-Id: <1381681584-14810-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.7.10.4 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.6 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 That allow us to use registers defined in evergreend.h. --- This is another proposal for HDMI code improvment. I'll start testing my patches soon, so I hope to re-send all of them in the following days. --- drivers/gpu/drm/radeon/evergreen.c | 4 +-- drivers/gpu/drm/radeon/evergreen_hdmi.c | 56 +++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/r600_audio.c | 15 ++------- drivers/gpu/drm/radeon/radeon_asic.h | 4 +++ 4 files changed, 65 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index 52fa3be..68a5200 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c @@ -5246,7 +5246,7 @@ static int evergreen_startup(struct radeon_device *rdev) return r; } - r = r600_audio_init(rdev); + r = dce4_audio_init(rdev); if (r) { DRM_ERROR("radeon: audio init failed\n"); return r; @@ -5288,7 +5288,7 @@ int evergreen_resume(struct radeon_device *rdev) int evergreen_suspend(struct radeon_device *rdev) { - r600_audio_fini(rdev); + dce4_audio_fini(rdev); uvd_v1_0_fini(rdev); radeon_uvd_suspend(rdev); r700_cp_stop(rdev); diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index 9153b24..98b420e 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c @@ -403,3 +403,59 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable) DRM_DEBUG("%sabling HDMI interface @ 0x%04X for encoder 0x%x\n", enable ? "En" : "Dis", dig->afmt->offset, radeon_encoder->encoder_id); } + +static void dce4_audio_enable(struct radeon_device *rdev, + struct r600_audio_pin *pin, + bool enable) +{ + static u32 ctl_bits = PIN0_AUDIO_ENABLED | + PIN1_AUDIO_ENABLED | + PIN2_AUDIO_ENABLED | + PIN3_AUDIO_ENABLED | + AUDIO_ENABLED; + u32 tmp; + + tmp = RREG32(AZ_HOT_PLUG_CONTROL); + if (enable) { + tmp |= ctl_bits; + WREG32_P(0x5e80, 0x1, ~0x03ffffff); + } else { + tmp &= ~ctl_bits; + } + WREG32(AZ_HOT_PLUG_CONTROL, tmp); + + DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id); +} + +int dce4_audio_init(struct radeon_device *rdev) +{ + if (!radeon_audio || ASIC_IS_NODCE(rdev)) + return 0; + + rdev->audio.enabled = true; + + rdev->audio.num_pins = 1; + rdev->audio.pin[0].channels = -1; + rdev->audio.pin[0].rate = -1; + rdev->audio.pin[0].bits_per_sample = -1; + rdev->audio.pin[0].status_bits = 0; + rdev->audio.pin[0].category_code = 0; + rdev->audio.pin[0].id = 0; + + dce4_audio_enable(rdev, &rdev->audio.pin[0], true); + + return 0; +} + +void dce4_audio_fini(struct radeon_device *rdev) +{ + int i; + + if (!rdev->audio.enabled) + return; + + for (i = 0; i < rdev->audio.num_pins; i++) + dce4_audio_enable(rdev, &rdev->audio.pin[i], false); + + rdev->audio.enabled = false; +} diff --git a/drivers/gpu/drm/radeon/r600_audio.c b/drivers/gpu/drm/radeon/r600_audio.c index 47fc2b8..1511cc5 100644 --- a/drivers/gpu/drm/radeon/r600_audio.c +++ b/drivers/gpu/drm/radeon/r600_audio.c @@ -146,18 +146,9 @@ static void r600_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin, bool enable) { - u32 value = 0; - - if (ASIC_IS_DCE4(rdev)) { - if (enable) { - value |= 0x81000000; /* Required to enable audio */ - value |= 0x0e1000f0; /* fglrx sets that too */ - } - WREG32(EVERGREEN_AUDIO_ENABLE, value); - } else { - WREG32_P(R600_AUDIO_ENABLE, - enable ? 0x81000000 : 0x0, ~0x81000000); - } + WREG32_P(R600_AUDIO_ENABLE, + enable ? 0x81000000 : 0x0, ~0x81000000); + DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id); } diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 86d871b..5cf52c0 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h @@ -469,6 +469,10 @@ int rv770_dpm_force_performance_level(struct radeon_device *rdev, enum radeon_dpm_forced_level level); bool rv770_dpm_vblank_too_short(struct radeon_device *rdev); +/* DCE4 */ +int dce4_audio_init(struct radeon_device *rdev); +void dce4_audio_fini(struct radeon_device *rdev); + /* * evergreen */