From patchwork Thu Jul 5 10:13:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 141114 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1752822ljj; Thu, 5 Jul 2018 03:14:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcdFr/Jsqcy/YxI8P4PlsgOn4xuJ+JwS1Km+CxZRPu4FBjg/vNsOxvBjEUemCGYVD7CDr9j X-Received: by 2002:adf:8541:: with SMTP id 59-v6mr3839146wrh.223.1530785650269; Thu, 05 Jul 2018 03:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530785650; cv=none; d=google.com; s=arc-20160816; b=IDFupZzFF6978k3O1v8NDCyrthOg9JkAqDZRWMtZc+XIAnQTgFOazt2G2aLYLyMmlM Up3/nzYnEsUHzhOdtYZTM9S9nbCM+Pv8wVhbRxikgzNfSN1DnjKhMBepMJQQU8c1Voxb IWBepgIltW/Is6QQIpKXiCKfvghktgSBsb850kYl4XPblvZ8aV5mFtOhVZoDOAaoIPir USoM4H47zF1mDX8Oi9bOeqylXnXQVn97ZN5M5SX/D/42b7TvnUVwu/r9lTk4rAj7yuIb 5M85Xh9aHbBPUDcRV8jeDuzYGPf55gFKmSOCvCzTXGe3nHIh7RG6OvaW0/Z0+lfOpKRp glnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=5ef2T2cnCqxW7OYnOrz9CzF3FKQJYvQk9kvAfIZ2xKc=; b=jJ3+XGDBCUxNAFcEgsGX4rAFWGQvbAdVKD3BEIYWArpc7ltfoou+d3/wWvTHU3XGIo DvtBreyad5WYd7PwafTjvzfK27gIAYs+X/qnpOjp8ZHXEPvJoQDaLxDd8Gc+s7bimBK1 v5s4WBZ8n4LdP020UlcDKUc9Z0ZVTiPHVo0JR4xJ22LMfFyNcYgJ2/SUOGn6qhzQASu1 0ekBH/C/lPHeEoQMUYcCJC8bdNtZYXxaGlKgVhBftCgdN6doVRtpqCxX44zqGTBfVtRc YclQ6V3cFwfvIlVHUOkuonzkZpypB/90Xuij7WiMOtg4I2PRLfjImuLoAfFjbWrsCq+o owIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=NaBRTITC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id u10-v6si4889127wre.436.2018.07.05.03.14.10; Thu, 05 Jul 2018 03:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=NaBRTITC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7C4A72676E7; Thu, 5 Jul 2018 12:14:04 +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 DAD3D267601; Thu, 5 Jul 2018 12:14:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_SOFTFAIL, T_DKIMWL_WL_MED autolearn=disabled version=3.4.0 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by alsa0.perex.cz (Postfix) with ESMTP id 1A88326735C for ; Thu, 5 Jul 2018 12:13:57 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id b188-v6so10190148wme.3 for ; Thu, 05 Jul 2018 03:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TXdUAVIbftx6DVW3m0tqzagDNSKCycxA7cOp98dNZx0=; b=NaBRTITCwK0dffFBAuyFSlxPZsYsGRtUsxV55v/00NNLYLCpykl+kjzNFI6iW92O2x SxEh7+nt0a6GbzleCq2X+W3NVdMpycMo0klf/gkXYeyVp/+GSbniGmtvAHComgX7Ie+H HwHc8/pioGaVVwVEs1CmawjIcP3OG9kgw2n4kTCEfpSnz+O7QeIaNv0DQAIQhonHVXvI 6uEFKIl2BVIXp5z0YDngdEe3uB/BR07EHJ5kzUMaGxtgKV3yYd7FCaFx4L6toafrGz2t pYAchQjwtBHgKjtb9nY/u/fBopxvZinQoiykbL0OMpUfzVOwYjvBuoA98lXieYfU5Dwa WRDA== 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; bh=TXdUAVIbftx6DVW3m0tqzagDNSKCycxA7cOp98dNZx0=; b=Ep8EFR4r/rX76NkMCa+QV3x5jsu+juBH9yd2OE1rKqNi9j0npd7MInjcbFw2qaKh9w gQHut8z/QguXG7aMVpNirClRYgwaWK4bZ7wFkzt1o/BRWlRWYO8R+fMwYCvMZfspwFXN hyFXUdWFkwLSVdWgctwfOWcimUU03CUafpXxAFBPXzq2Lw3ioWL60BU3iyNuBENUSH2Q Klh3HluDiPdgX1AE/NhEtmKRGZqQZgjGoPI7wrmRchOO2nhbNsKCxbCBQ180/Lvvp++2 eZxgdRzWdR54Se8wXYNqBH6X3wlrOMLCRewdbNIyzx8d+wF8Bp+rg6AOT45XSC5M8mw2 WFvg== X-Gm-Message-State: APt69E3W4108tcQjD6WTN9UeocgJSVAwkhV0OpHBtuv+oYyStY28zPL+ WsrVqjJHEBx7d2IgJOgshP3qUg== X-Received: by 2002:a1c:8d0a:: with SMTP id p10-v6mr3847502wmd.121.1530785637626; Thu, 05 Jul 2018 03:13:57 -0700 (PDT) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z18-v6sm5175510wrr.76.2018.07.05.03.13.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jul 2018 03:13:57 -0700 (PDT) From: Jerome Brunet To: Liam Girdwood , Mark Brown Date: Thu, 5 Jul 2018 12:13:48 +0200 Message-Id: <20180705101349.7520-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180705101349.7520-1-jbrunet@baylibre.com> References: <20180705101349.7520-1-jbrunet@baylibre.com> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jerome Brunet Subject: [alsa-devel] [PATCH 1/2] ASoC: dpcm: rework runtime stream merge 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The goal of this patch is to simplify a bit dpcm runtime stream merge by removing several local variables. ATM, merge functions return the BE 'filter' values which should then be filtered against the FE stream values. This create a lot of local variable and unnecessary init of min and max. Instead of this, we can pass the FE stream values directly and let the BE filtering functions perform the merge 'in-place' Signed-off-by: Jerome Brunet --- sound/soc/soc-pcm.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) -- 2.14.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b959af4cff3a..54141a69b6b0 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1672,29 +1672,28 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) } static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime, - struct snd_soc_pcm_stream *stream, - u64 formats) + struct snd_soc_pcm_stream *stream) { runtime->hw.rate_min = stream->rate_min; runtime->hw.rate_max = stream->rate_max; runtime->hw.channels_min = stream->channels_min; runtime->hw.channels_max = stream->channels_max; if (runtime->hw.formats) - runtime->hw.formats &= formats & stream->formats; + runtime->hw.formats &= stream->formats; else - runtime->hw.formats = formats & stream->formats; + runtime->hw.formats = stream->formats; runtime->hw.rates = stream->rates; } -static u64 dpcm_runtime_base_format(struct snd_pcm_substream *substream) +static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream, + u64 *formats) { struct snd_soc_pcm_runtime *fe = substream->private_data; struct snd_soc_dpcm *dpcm; - u64 formats = ULLONG_MAX; int stream = substream->stream; if (!fe->dai_link->dpcm_merged_format) - return formats; + return; /* * It returns merged BE codec format @@ -1722,16 +1721,14 @@ static u64 dpcm_runtime_base_format(struct snd_pcm_substream *substream) else codec_stream = &codec_dai_drv->capture; - formats &= codec_stream->formats; + *formats &= codec_stream->formats; } } - - return formats; } -static void dpcm_runtime_base_chan(struct snd_pcm_substream *substream, - unsigned int *channels_min, - unsigned int *channels_max) +static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream, + unsigned int *channels_min, + unsigned int *channels_max) { struct snd_soc_pcm_runtime *fe = substream->private_data; struct snd_soc_dpcm *dpcm; @@ -1740,9 +1737,6 @@ static void dpcm_runtime_base_chan(struct snd_pcm_substream *substream, if (!fe->dai_link->dpcm_merged_chan) return; - *channels_min = 0; - *channels_max = UINT_MAX; - /* * It returns merged BE codec channel; * if FE want to use it (= dpcm_merged_chan) @@ -1789,18 +1783,15 @@ static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver; - u64 format = dpcm_runtime_base_format(substream); - unsigned int channels_min = 0, channels_max = UINT_MAX; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback, format); + dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback); else - dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture, format); - - dpcm_runtime_base_chan(substream, &channels_min, &channels_max); + dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture); - runtime->hw.channels_min = max(channels_min, runtime->hw.channels_min); - runtime->hw.channels_max = min(channels_max, runtime->hw.channels_max); + dpcm_runtime_merge_format(substream, &runtime->hw.formats); + dpcm_runtime_merge_chan(substream, &runtime->hw.channels_min, + &runtime->hw.channels_max); } static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd);