From patchwork Wed Sep 12 11:46:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1443121 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 ED062E00A6 for ; Wed, 12 Sep 2012 11:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753335Ab2ILLtr (ORCPT ); Wed, 12 Sep 2012 07:49:47 -0400 Received: from na3sys009aog105.obsmtp.com ([74.125.149.75]:44966 "EHLO na3sys009aog105.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753498Ab2ILLqr (ORCPT ); Wed, 12 Sep 2012 07:46:47 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob105.postini.com ([74.125.148.12]) with SMTP ID DSNKUFB2JxPU4to5LTCdvrn55uURd9HPCIph@postini.com; Wed, 12 Sep 2012 04:46:47 PDT Received: by obbuo13 with SMTP id uo13so2442161obb.19 for ; Wed, 12 Sep 2012 04:46:46 -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=e7B9lkgCRrl6NlYJDSP48DYIGb6DiKr0Zbd1f0Z5cYHPrFTejepqpgXClabbk6sKux Jzp7nqwUTmz8ha5XsdBeM0+XcJ971SJDLJiI0XXyPd48s/JAh87pmncqZnMFkqyZY/bi P9k0BGfrSa79D1Tk0xIQLFJ4BtesOE/ktJpPOkZv8GtWdrEXzTLGTHGrcWITVsHcTP1d tohfEXh+kJGBo9tyOBgYc0K4APhHlA33Ay6T3S6e8zHJcVUi7UjpzZVe5oeTIYOOZ89D 1VRWq+NmgL00N7ezBqz0xMPAWPW5dJv2+oAAfslP6oxLJ2TV0w0Oy1Absvaz6rByrK2L ZO6w== Received: by 10.182.37.41 with SMTP id v9mr22065015obj.23.1347450406556; Wed, 12 Sep 2012 04:46:46 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id c6sm19835570obd.22.2012.09.12.04.46.43 (version=SSLv3 cipher=OTHER); Wed, 12 Sep 2012 04:46:46 -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 Subject: [PATCH 02/11] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode Date: Wed, 12 Sep 2012 14:46:58 +0300 Message-Id: <1347450427-27627-3-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347450427-27627-1-git-send-email-peter.ujfalusi@ti.com> References: <1347450427-27627-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQmG5lkG0oJrQgKtVJYigOHgWlI760FIay4eWzID6eDcmW6F3UGogjCrF7NaVfRPw1WfBC3E 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;