From patchwork Tue Jul 1 07:47:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 4456961 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 08D489F26C for ; Tue, 1 Jul 2014 07:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 237B0203EB for ; Tue, 1 Jul 2014 07:50:05 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 5497B203FB for ; Tue, 1 Jul 2014 07:50:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4845E2656D3; Tue, 1 Jul 2014 09:50:02 +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=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 17E52265706; Tue, 1 Jul 2014 09:49:12 +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 BB998265706; Tue, 1 Jul 2014 09:49:10 +0200 (CEST) Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by alsa0.perex.cz (Postfix) with ESMTP id AC07A2656BC for ; Tue, 1 Jul 2014 09:48:46 +0200 (CEST) Received: by mail-we0-f170.google.com with SMTP id w61so9186703wes.29 for ; Tue, 01 Jul 2014 00:48:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fYzEJEwJpVuGcRX4sz7pjzFVfxVNxq9poPSGwg1B+Lo=; b=jiDKlmMRQPvNgAIQSBaRpHQMvjeUtv5vLskyu/IVkCtgRl2uNxB0ou0PhA/hqan8rQ Mt6QirsZe2kS5N83uFCppxmXufu8YhrMSToPzEG7ZjCEfGT88nPQg/myZ0F8zs9fcnUM oI9zIKxPOZGYcVHPiY6t6jW7XMO6tKJuwQBu3QHIaWOp0c9Y+3O8vccDNCO6W2++BEZU ZcVAN9OE6gUOkPLa5Oe4+wdua3044Pj+r1Uumidvx0nxU4JF34OLx0SnKaEEHtbCMuRk 1mdowZgjI8zwIesISwgn0Y7JZCJ6/L2RS2B3BzL/WJlDu3qxHtZOCygaEfiBBu/FvNDZ 9bag== X-Gm-Message-State: ALoCoQn5KWcxB4FarOvYDpHPfA6lwsA71Hta24l8OCJ2a8irbosmJu4u12AAHVEC7V4i5Pdi1vj6 X-Received: by 10.180.91.194 with SMTP id cg2mr35402155wib.12.1404200926424; Tue, 01 Jul 2014 00:48:46 -0700 (PDT) Received: from localhost.localdomain (lau06-1-82-228-246-9.fbx.proxad.net. [82.228.246.9]) by mx.google.com with ESMTPSA id bq7sm40353720wib.7.2014.07.01.00.48.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Jul 2014 00:48:45 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de Date: Tue, 1 Jul 2014 09:47:55 +0200 Message-Id: <1404200881-32253-3-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404200881-32253-1-git-send-email-bcousson@baylibre.com> References: <1404200881-32253-1-git-send-email-bcousson@baylibre.com> Cc: misael.lopez@ti.com, alsa-devel@alsa-project.org, Benoit Cousson Subject: [alsa-devel] [PATCH v4 2/8] ASoC: pcm: Refactor soc_pcm_apply_msb for multicodecs 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 Refactor the function to facilitate the migration to multiple codecs. Fix a trailing space in the header as well. No functional change. Signed-off-by: Benoit Cousson --- sound/soc/soc-pcm.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 094676a..ab0712e 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -7,7 +7,7 @@ * Copyright (C) 2010 Texas Instruments Inc. * * Authors: Liam Girdwood - * Mark Brown + * Mark Brown * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -284,15 +284,10 @@ static int sample_sizes[] = { 24, 32, }; -static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static void soc_pcm_set_msb(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai, int bits) { - int ret, i, bits; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - bits = dai->driver->playback.sig_bits; - else - bits = dai->driver->capture.sig_bits; + int ret, i; if (!bits) return; @@ -310,6 +305,25 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, } } +static void soc_pcm_apply_msb(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 *codec_dai = rtd->codec_dai; + unsigned int bits = 0, cpu_bits; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + bits = codec_dai->driver->playback.sig_bits; + cpu_bits = cpu_dai->driver->playback.sig_bits; + } else { + bits = codec_dai->driver->capture.sig_bits; + cpu_bits = cpu_dai->driver->capture.sig_bits; + } + + soc_pcm_set_msb(substream, codec_dai, bits); + soc_pcm_set_msb(substream, cpu_dai, cpu_bits); +} + static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime, struct snd_soc_pcm_stream *codec_stream, struct snd_soc_pcm_stream *cpu_stream) @@ -433,8 +447,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) goto config_err; } - soc_pcm_apply_msb(substream, codec_dai); - soc_pcm_apply_msb(substream, cpu_dai); + soc_pcm_apply_msb(substream); /* Symmetry only applies if we've already got an active stream. */ if (cpu_dai->active) {