From patchwork Thu Sep 13 13:37:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1452281 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5192DDF24C for ; Thu, 13 Sep 2012 13:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754611Ab2IMNiD (ORCPT ); Thu, 13 Sep 2012 09:38:03 -0400 Received: from na3sys009aog119.obsmtp.com ([74.125.149.246]:38041 "EHLO na3sys009aog119.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754304Ab2IMNiA (ORCPT ); Thu, 13 Sep 2012 09:38:00 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]) (using TLSv1) by na3sys009aob119.postini.com ([74.125.148.12]) with SMTP ID DSNKUFHhtxWBC1pxUfVicGcbRUF6uhC1tmBW@postini.com; Thu, 13 Sep 2012 06:38:00 PDT Received: by oago6 with SMTP id o6so1866617oag.19 for ; Thu, 13 Sep 2012 06:37:59 -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=Q0vsB+ZHqRo+Ejv9ZfQ/2+WH/N4f1jc7kBFX7/gHLEd12i152HJCQplz164MSZxezc KmbmCyeAJ189SlwMdhGkvQYRlOjrgW01nkeGnBPqTsI5mZvhdycdDZ/JU9fERmNjOX5N R7608VPj9PPM33WNFrrGoYCcFOK61aijvZNBD4kQFj1i9Nvt1kNqVSiCm6LJ2qySd1PT i/0uIH3/XCQCEIMpJaVlPCc4eeIhzAQYVbNz/mpU6ZzbdGTpgRudqOXFFwMHySZq4rmv f2CDB+cVmoGby3VHf57qQMSAz4t0TYQwMK/CKDYMgwD2xNBOPqcLGvCXYuntHKDqdX4k PJqw== Received: by 10.182.111.74 with SMTP id ig10mr2322458obb.14.1347543478945; Thu, 13 Sep 2012 06:37:58 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id n8sm19403567oec.5.2012.09.13.06.37.55 (version=SSLv3 cipher=OTHER); Thu, 13 Sep 2012 06:37:58 -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 v2 06/15] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode Date: Thu, 13 Sep 2012 16:37:56 +0300 Message-Id: <1347543485-339-7-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347543485-339-1-git-send-email-peter.ujfalusi@ti.com> References: <1347543485-339-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQnwHDa2QvhukEXdOhzIuUBQIrWEjzA0eMoQxzMcHJRMWLwnPwJtFcIm0OrrpJuis8DPXEuY 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;