From patchwork Sat Aug 8 16:10:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 6975331 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 93CD1C05AC for ; Sat, 8 Aug 2015 16:12:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC14C205F7 for ; Sat, 8 Aug 2015 16:12:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9770520544 for ; Sat, 8 Aug 2015 16:12:34 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B85E4265133; Sat, 8 Aug 2015 18:12:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 668D32651A9; Sat, 8 Aug 2015 18:11:17 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id F31CD265161; Sat, 8 Aug 2015 18:11:15 +0200 (CEST) Received: from pandora.arm.linux.org.uk (pandora.arm.linux.org.uk [78.32.30.218]) by alsa0.perex.cz (Postfix) with ESMTP id C41F3264FFB for ; Sat, 8 Aug 2015 18:10:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References:In-Reply-To; bh=+EKQJy04qgSr8wi5HsohTszKOjYhL95/+Onpgp6qkmE=; b=RogFnf7ZwwPKWg/TNc+m+TWleTFustewJEV4SSQsll5COqPa1F26O4S/R69m8aUZ8m6VyzmO41yPEtGT4ROpouOcDBgPpHws5ewDZLaaDYUOM7TwX0OrbCaS8o7T6bunSXRIepBYPMs1P1ArHOOkQGTRDp/P5UW+0zUH7re8Ink=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:49571 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1ZO6hX-0006Sx-0J; Sat, 08 Aug 2015 17:10:27 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1ZO6hR-0003NE-Rq; Sat, 08 Aug 2015 17:10:21 +0100 In-Reply-To: <20150808160936.GN7557@n2100.arm.linux.org.uk> References: <20150808160936.GN7557@n2100.arm.linux.org.uk> From: Russell King To: linux-rockchip@lists.infradead.org, alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sat, 08 Aug 2015 17:10:21 +0100 Cc: Fabio Estevam , Takashi Iwai , Sascha Hauer , David Airlie , Mark Brown , Philipp Zabel , Yakir Yang , Andy Yan , Jon Nettleton Subject: [alsa-devel] [PATCH 4/9] drm: bridge/dw_hdmi-ahb-audio: allow larger buffer sizes X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP With multichannel audio, we need to allow larger buffer sizes to avoid XRUNs during playback. Push the buffer size up to 1024K, but as we maintain two buffers, ensure that the vmalloc buffer does not exceed the userspace buffer size. Signed-off-by: Russell King --- drivers/gpu/drm/bridge/dw_hdmi-ahb-audio.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw_hdmi-ahb-audio.c b/drivers/gpu/drm/bridge/dw_hdmi-ahb-audio.c index 3a8f32e04b63..4b537f9ce8f0 100644 --- a/drivers/gpu/drm/bridge/dw_hdmi-ahb-audio.c +++ b/drivers/gpu/drm/bridge/dw_hdmi-ahb-audio.c @@ -312,7 +312,7 @@ static struct snd_pcm_hardware dw_hdmi_hw = { SNDRV_PCM_RATE_192000, .channels_min = 2, .channels_max = 8, - .buffer_bytes_max = 64 * 1024, + .buffer_bytes_max = 1024 * 1024, .period_bytes_min = 256, .period_bytes_max = 8192, /* ERR004323: must limit to 8k */ .periods_min = 2, @@ -337,7 +337,15 @@ static int dw_hdmi_open(struct snd_pcm_substream *substream) if (ret < 0) return ret; - ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); + ret = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (ret < 0) + return ret; + + /* Limit the buffer size to the size of the preallocated buffer */ + ret = snd_pcm_hw_constraint_minmax(runtime, + SNDRV_PCM_HW_PARAM_BUFFER_SIZE, + 0, substream->dma_buffer.bytes); if (ret < 0) return ret; @@ -387,6 +395,7 @@ static int dw_hdmi_hw_free(struct snd_pcm_substream *substream) static int dw_hdmi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { + /* Allocate the PCM runtime buffer, which is exposed to userspace. */ return snd_pcm_lib_alloc_vmalloc_buffer(substream, params_buffer_bytes(params)); } @@ -552,8 +561,12 @@ static int snd_dw_hdmi_probe(struct platform_device *pdev) strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name)); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dw_hdmi_ops); + /* + * To support 8-channel 96kHz audio reliably, we need 512k + * to satisfy alsa with our restricted period (ERR004323). + */ snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - dev, 64 * 1024, 64 * 1024); + dev, 128 * 1024, 1024 * 1024); ret = snd_card_register(card); if (ret < 0)