From patchwork Sun Feb 16 21:35:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 3658861 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C6D4BF13A for ; Sun, 16 Feb 2014 21:36:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08B07201E4 for ; Sun, 16 Feb 2014 21:36:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 69145201EF for ; Sun, 16 Feb 2014 21:35:58 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6F17A2616FF; Sun, 16 Feb 2014 22:35:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 83D212616FF; Sun, 16 Feb 2014 22:35:39 +0100 (CET) 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 2F3C1261A09; Sun, 16 Feb 2014 22:35:38 +0100 (CET) Received: from smtp-out-011.synserver.de (smtp-out-190.synserver.de [212.40.185.190]) by alsa0.perex.cz (Postfix) with ESMTP id 0FDD72610B7 for ; Sun, 16 Feb 2014 22:35:30 +0100 (CET) Received: (qmail 13592 invoked by uid 0); 16 Feb 2014 21:35:24 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 13511 Received: from ppp-46-244-154-140.dynamic.mnet-online.de (HELO lars-adi-laptop.fritz.box) [46.244.154.140] by 217.119.54.73 with SMTP; 16 Feb 2014 21:35:24 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Sun, 16 Feb 2014 22:35:37 +0100 Message-Id: <1392586537-8198-1-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 Cc: Russell King , alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH] ASoC: uda134x: Use core for applying symmetry constraitns 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 X-Virus-Scanned: ClamAV using ClamSMTP Let the core take care of applying sample rate and sample bits constraints instead of open-coding this in the driver. Signed-off-by: Lars-Peter Clausen --- Only compile tested --- sound/soc/codecs/uda134x.c | 52 +++------------------------------------------- 1 file changed, 3 insertions(+), 49 deletions(-) diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index c94d4c1..43b88ee 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -34,9 +34,6 @@ struct uda134x_priv { int sysclk; int dai_fmt; - - struct snd_pcm_substream *master_substream; - struct snd_pcm_substream *slave_substream; }; /* In-data addresses are hard-coded into the reg-cache values */ @@ -156,49 +153,6 @@ static int uda134x_mute(struct snd_soc_dai *dai, int mute) return 0; } -static int uda134x_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct snd_soc_codec *codec = dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); - struct snd_pcm_runtime *master_runtime; - - if (uda134x->master_substream) { - master_runtime = uda134x->master_substream->runtime; - - pr_debug("%s constraining to %d bits at %d\n", __func__, - master_runtime->sample_bits, - master_runtime->rate); - - snd_pcm_hw_constraint_minmax(substream->runtime, - SNDRV_PCM_HW_PARAM_RATE, - master_runtime->rate, - master_runtime->rate); - - snd_pcm_hw_constraint_minmax(substream->runtime, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - master_runtime->sample_bits, - master_runtime->sample_bits); - - uda134x->slave_substream = substream; - } else - uda134x->master_substream = substream; - - return 0; -} - -static void uda134x_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct snd_soc_codec *codec = dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); - - if (uda134x->master_substream == substream) - uda134x->master_substream = uda134x->slave_substream; - - uda134x->slave_substream = NULL; -} - static int uda134x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -208,7 +162,7 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); u8 hw_params; - if (substream == uda134x->slave_substream) { + if (dai->active) { pr_debug("%s ignoring hw_params for slave substream\n", __func__); return 0; @@ -447,8 +401,6 @@ static const struct snd_soc_dapm_route uda134x_dapm_routes[] = { }; static const struct snd_soc_dai_ops uda134x_dai_ops = { - .startup = uda134x_startup, - .shutdown = uda134x_shutdown, .hw_params = uda134x_hw_params, .digital_mute = uda134x_mute, .set_sysclk = uda134x_set_dai_sysclk, @@ -475,6 +427,8 @@ static struct snd_soc_dai_driver uda134x_dai = { }, /* pcm operations */ .ops = &uda134x_dai_ops, + .symmetric_rates = 1, + .symmetric_samplebits = 1, }; static int uda134x_soc_probe(struct snd_soc_codec *codec)