From patchwork Fri Sep 14 12:05:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1458031 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C2FBF402E1 for ; Fri, 14 Sep 2012 12:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759557Ab2INMGH (ORCPT ); Fri, 14 Sep 2012 08:06:07 -0400 Received: from na3sys009aog133.obsmtp.com ([74.125.149.82]:47090 "EHLO na3sys009aog133.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759510Ab2INMGE (ORCPT ); Fri, 14 Sep 2012 08:06:04 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob133.postini.com ([74.125.148.12]) with SMTP ID DSNKUFMdqSHtjV4DNtZ9g1Ggb9gVsDYkR7YC@postini.com; Fri, 14 Sep 2012 05:06:03 PDT Received: by obbuo13 with SMTP id uo13so6097363obb.19 for ; Fri, 14 Sep 2012 05:05:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=3PHgDXLlqMwKMC7eomKbuewUjWcvrIjQohMCQXW/HoU=; b=hUQ+jS1aXuRlvsxfDIgvDYVfw9kOczBAK15+SD4BLWm14kL8MybvNPC0HwXYEObPTv zc9BLXAUZvIAG8MCttCXKomLLPHuhXEaC9eca6b33A+jmn1vr+yu1voROmKImjYE64y9 sFOYuEapJJNY7+lSi1FYor/tSg8fbSv+6BB9PMUxoDNivO+J35p1bktlaqEM2ROykBo4 1Y+2yOrh6mqciNRxUvKhgir+K4dPRM/Xxp1TsGj6GcN06mtabl5CXeg/M5A/9j+lt8lb VLvn1u6mPJORvIGwxkZJftoowIF44LsDHBkRRuhO/jksHjtiDacF2pfSe3+LY2Kty49M h7ZQ== Received: by 10.182.31.102 with SMTP id z6mr2655238obh.66.1347624357670; Fri, 14 Sep 2012 05:05:57 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id ac10sm1615600obc.7.2012.09.14.05.05.54 (version=SSLv3 cipher=OTHER); Fri, 14 Sep 2012 05:05:57 -0700 (PDT) From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Tony Lindgren , Russell King , Vinod Koul , Dan Williams , Jarkko Nikula Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik , Ricardo Neri , Lars-Peter Clausen Subject: [PATCH v3 06/15] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode Date: Fri, 14 Sep 2012 15:05:49 +0300 Message-Id: <1347624358-25582-7-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347624358-25582-1-git-send-email-peter.ujfalusi@ti.com> References: <1347624358-25582-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQkF42iiBzVe045nOnSNwrTNTiDw/9PyeSiunTuorzKgSKsU5Nz6NDDbNJvhkTBPBNKX+A6j Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org When McBSP is configured in threshold mode we can use sDMA packet mode in all cases. Signed-off-by: Peter Ujfalusi --- sound/soc/omap/omap-mcbsp.c | 47 ++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 2e91a86..fe3debc 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) */ if (dma_data->packet_size) words = dma_data->packet_size; - else if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) - words = snd_pcm_lib_period_bytes(substream) / - (mcbsp->wlen / 8); else words = 1; @@ -251,6 +248,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, dma_data->set_threshold = omap_mcbsp_set_threshold; if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) { int period_words, max_thrsh; + int divider = 0; period_words = params_period_bytes(params) / (wlen / 8); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -258,34 +256,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, else max_thrsh = mcbsp->max_rx_thres; /* - * If the period contains less or equal number of words, - * we are using the original threshold mode setup: - * McBSP threshold = sDMA frame size = period_size - * Otherwise we switch to sDMA packet mode: - * McBSP threshold = sDMA packet size - * sDMA frame size = period size + * Use sDMA packet mode if McBSP is in threshold mode: + * If period words less than the FIFO size the packet + * size is set to the number of period words, otherwise + * Look for the biggest threshold value which divides + * the period size evenly. */ - if (period_words > max_thrsh) { - int divider = 0; - - /* - * Look for the biggest threshold value, which - * divides the period size evenly. - */ - divider = period_words / max_thrsh; - if (period_words % max_thrsh) - divider++; - while (period_words % divider && - divider < period_words) - divider++; - if (divider == period_words) - return -EINVAL; - - pkt_size = period_words / divider; - sync_mode = OMAP_DMA_SYNC_PACKET; - } else { - sync_mode = OMAP_DMA_SYNC_FRAME; - } + divider = period_words / max_thrsh; + if (period_words % max_thrsh) + divider++; + while (period_words % divider && + divider < period_words) + divider++; + if (divider == period_words) + return -EINVAL; + + pkt_size = period_words / divider; + sync_mode = OMAP_DMA_SYNC_PACKET; } else if (channels > 1) { /* Use packet mode for non mono streams */ pkt_size = channels;