From patchwork Wed Jun 18 08:56:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4374261 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 4C0DD9F3B4 for ; Wed, 18 Jun 2014 08:59:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6790320218 for ; Wed, 18 Jun 2014 08:59:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 36DED200FF for ; Wed, 18 Jun 2014 08:59:14 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 52E292656FD; Wed, 18 Jun 2014 10:59:08 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 22B9626569E; Wed, 18 Jun 2014 10:57:23 +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 7D33C2656AD; Wed, 18 Jun 2014 10:57:22 +0200 (CEST) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by alsa0.perex.cz (Postfix) with ESMTP id 019E2265683 for ; Wed, 18 Jun 2014 10:56:02 +0200 (CEST) Received: by mail-pa0-f49.google.com with SMTP id lj1so525558pab.22 for ; Wed, 18 Jun 2014 01:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:message-id:from:subject:user-agent:to:cc:in-reply-to :references:mime-version:content-type; bh=5ESC+wv/6GQgORhoiRvkwdanD3En+4LmsGhy1A6uE20=; b=km2C1cJhf5VRaNK2wDe+FA+Tqk0a9KOzYZ3R+m4EM918OSKhxLpOZhRe7x+IFy509L KfG6FM63yGxKlk93ObU9kfsM3zcoFkOdhNnq61MjLTGI5X5SqqEqzx+NnouI54ltC1QC QZRE5gUS/O3+qSVhRVL8klublF/XE3giwMkEtG8qELCGOxDBGCIXPZ6iP2jsGIY4XgwN Lk6p01XtnJ7VZhb/a3L9QSFRvGCtWJ/zAH+9MsEHxpe35xj8i7n6K/m+Sc+CxUja/eKH 6ewMVSRqGBtNr8ugMlsqX8fUVQ11lexr8RS48Nao8gtnD1R5yN4fB8VHloVTtrSSsgVm 4niA== X-Received: by 10.69.20.74 with SMTP id ha10mr665339pbd.127.1403081761797; Wed, 18 Jun 2014 01:56:01 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id ln2sm7193521pab.35.2014.06.18.01.56.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 18 Jun 2014 01:56:01 -0700 (PDT) Date: Wed, 18 Jun 2014 17:56:02 +0900 Message-ID: <8761jyzjdp.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Mark Brown In-Reply-To: <87d2e6zjhf.wl%kuninori.morimoto.gx@gmail.com> References: <87d2e6zjhf.wl%kuninori.morimoto.gx@gmail.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: linux-sh@vger.kernel.org, Linux-ALSA , Simon , Kuninori Morimoto , Liam Girdwood Subject: [alsa-devel] [PATCH 05/12] ASoC: fsi: add fsi_pointer_update() for common pointer method 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto fsi PIO/DMA handler are using each own pointer update method, but these can be share. Signed-off-by: Kuninori Morimoto --- sound/soc/sh/fsi.c | 57 ++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 7a6b632..820a408 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1041,6 +1041,26 @@ static int fsi_clk_set_rate_cpg(struct device *dev, return ret; } +static void fsi_pointer_update(struct fsi_stream *io, int size) +{ + io->buff_sample_pos += size; + + if (io->buff_sample_pos >= + io->period_samples * (io->period_pos + 1)) { + struct snd_pcm_substream *substream = io->substream; + struct snd_pcm_runtime *runtime = substream->runtime; + + io->period_pos++; + + if (io->period_pos >= runtime->periods) { + io->buff_sample_pos = 0; + io->period_pos = 0; + } + + snd_pcm_period_elapsed(substream); + } +} + /* * pio data transfer handler */ @@ -1107,31 +1127,11 @@ static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io, void (*run32)(struct fsi_priv *fsi, u8 *buf, int samples), int samples) { - struct snd_pcm_runtime *runtime; - struct snd_pcm_substream *substream; u8 *buf; - int over_period; if (!fsi_stream_is_working(fsi, io)) return -EINVAL; - over_period = 0; - substream = io->substream; - runtime = substream->runtime; - - /* FSI FIFO has limit. - * So, this driver can not send periods data at a time - */ - if (io->buff_sample_pos >= - io->period_samples * (io->period_pos + 1)) { - - over_period = 1; - io->period_pos = (io->period_pos + 1) % runtime->periods; - - if (0 == io->period_pos) - io->buff_sample_pos = 0; - } - buf = fsi_pio_get_area(fsi, io); switch (io->sample_width) { @@ -1145,11 +1145,7 @@ static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io, return -EINVAL; } - /* update buff_sample_pos */ - io->buff_sample_pos += samples; - - if (over_period) - snd_pcm_period_elapsed(substream); + fsi_pointer_update(io, samples); return 0; } @@ -1307,20 +1303,11 @@ static void fsi_dma_complete(void *data) { struct fsi_stream *io = (struct fsi_stream *)data; struct fsi_priv *fsi = fsi_stream_to_priv(io); - struct snd_pcm_runtime *runtime = io->substream->runtime; - io->buff_sample_pos += io->period_samples; - io->period_pos++; - - if (io->period_pos >= runtime->periods) { - io->period_pos = 0; - io->buff_sample_pos = 0; - } + fsi_pointer_update(io, io->period_samples); fsi_count_fifo_err(fsi); fsi_stream_transfer(io); - - snd_pcm_period_elapsed(io->substream); } static void fsi_dma_do_work(struct work_struct *work)