From patchwork Thu Oct 24 16:45:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11210309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37E5214ED for ; Thu, 24 Oct 2019 16:46:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F53221925 for ; Thu, 24 Oct 2019 16:46:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F53221925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56EBB6E49A; Thu, 24 Oct 2019 16:46:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEB5B6E49A for ; Thu, 24 Oct 2019 16:46:48 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id n7so2778697wmc.3 for ; Thu, 24 Oct 2019 09:46:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WKBeVLYREt15Gh3e8xz+0QmQJOGSqeYITYZf2RyLHbw=; b=njbtZsokKmSyuRfhIpvQqnWMZZpUV0rHVSZoDv0lHfkO5uonAHu08yJkKXRhcViKMc iYKarHNKscz4wp8yorzFmf1ni+O8Q8j8Kw9SgetrkZ0nZBx5n21ETuVUB2hp2PZZk/Pw xYvWM/1YU29UwoxV4ZE7LxTh4w6RExTKir7pGXibvyitM6J7GDGdCPR+Wkx8z8swrfXs rZQ79iwUcagPNORHet+wABIDLeOy8VOikKN8z9hl62q4/aYJ5cFjuBuVfGJltXLGtT0M w7dPZKNbRWPlXDXk7oASIdIRkj6SK/k0BHur02FZsAs+zsR4KDSgHm7r50kLCJxOit5P ASHQ== X-Gm-Message-State: APjAAAU5kLphll9ZBJV4Uf48JgDj8/SZXm31dGWTnNjirxlgJ9EE+7z2 +n9OHsfcdq8bB8CwIJycN24= X-Google-Smtp-Source: APXvYqwRIWbOX1eE2QfXOf7xYJVmFGbmcJHphMcAF60WHywqSwZivxQL4msANSJjxLCMUVoAPPhUlw== X-Received: by 2002:a7b:cc01:: with SMTP id f1mr6132288wmh.113.1571935607081; Thu, 24 Oct 2019 09:46:47 -0700 (PDT) Received: from localhost (p2E5BE2CE.dip0.t-ipconnect.de. [46.91.226.206]) by smtp.gmail.com with ESMTPSA id c8sm2522429wml.44.2019.10.24.09.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:46:45 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH 31/32] drm/tegra: sor: Extract common audio enabling code Date: Thu, 24 Oct 2019 18:45:33 +0200 Message-Id: <20191024164534.132764-32-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191024164534.132764-1-thierry.reding@gmail.com> References: <20191024164534.132764-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WKBeVLYREt15Gh3e8xz+0QmQJOGSqeYITYZf2RyLHbw=; b=jZ2DuCClUsbZPw3pnaQmSqX6quDGwK0rbHR2dyP+ivScy3u9menmlTQrg/XNJ61hpQ 4kTYwAU4P7hYSd6GtYT7mzJwDNdPvRjY6An4A/OKgORv58TbJPuXID1vH0QqBJchVDSh HJ98PncdOlYPs2kvMXShX8AaQxA7jF5TEXlYranGf6Q/k4e7QPTlIc6P8pT+zTnGFSt/ PG9lgH+oiSrjta0+Pki+OyHPeumM5JQs8mysW+V3So9QbVee3/PcRtwuIH0zr7+K/9iV yrfQoQ9FlGjdLGboB4bME4um5KSIiSDOUlYJSV4C7X5WBN4g7wXALMgKMmjPwv1hudzs 63Qg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding The code to enable audio support is split into two parts, one being generic for the SOR and another part that is specific whether the SOR is in HDMI mode or in DP mode. Split out the common part in preparation for reusing the code in DP mode. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/sor.c | 43 +++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index b81e6d39aa32..478c001f4453 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -2002,6 +2002,30 @@ static void tegra_sor_audio_unprepare(struct tegra_sor *sor) tegra_sor_writel(sor, 0, SOR_INT_ENABLE); } +static void tegra_sor_audio_enable(struct tegra_sor *sor) +{ + u32 value; + + value = tegra_sor_readl(sor, SOR_AUDIO_CNTRL); + + /* select HDA audio input */ + value &= ~SOR_AUDIO_CNTRL_SOURCE_SELECT(SOURCE_SELECT_MASK); + value |= SOR_AUDIO_CNTRL_SOURCE_SELECT(SOURCE_SELECT_HDA); + + /* inject null samples */ + if (sor->format.channels != 2) + value &= ~SOR_AUDIO_CNTRL_INJECT_NULLSMPL; + else + value |= SOR_AUDIO_CNTRL_INJECT_NULLSMPL; + + value |= SOR_AUDIO_CNTRL_AFIFO_FLUSH; + + tegra_sor_writel(sor, value, SOR_AUDIO_CNTRL); + + /* enable advertising HBR capability */ + tegra_sor_writel(sor, SOR_AUDIO_SPARE_HBR_ENABLE, SOR_AUDIO_SPARE); +} + static int tegra_sor_hdmi_enable_audio_infoframe(struct tegra_sor *sor) { u8 buffer[HDMI_INFOFRAME_SIZE(AUDIO)]; @@ -2037,24 +2061,7 @@ static void tegra_sor_hdmi_audio_enable(struct tegra_sor *sor) { u32 value; - value = tegra_sor_readl(sor, SOR_AUDIO_CNTRL); - - /* select HDA audio input */ - value &= ~SOR_AUDIO_CNTRL_SOURCE_SELECT(SOURCE_SELECT_MASK); - value |= SOR_AUDIO_CNTRL_SOURCE_SELECT(SOURCE_SELECT_HDA); - - /* inject null samples */ - if (sor->format.channels != 2) - value &= ~SOR_AUDIO_CNTRL_INJECT_NULLSMPL; - else - value |= SOR_AUDIO_CNTRL_INJECT_NULLSMPL; - - value |= SOR_AUDIO_CNTRL_AFIFO_FLUSH; - - tegra_sor_writel(sor, value, SOR_AUDIO_CNTRL); - - /* enable advertising HBR capability */ - tegra_sor_writel(sor, SOR_AUDIO_SPARE_HBR_ENABLE, SOR_AUDIO_SPARE); + tegra_sor_audio_enable(sor); tegra_sor_writel(sor, 0, SOR_HDMI_ACR_CTRL);