From patchwork Thu Jun 5 09:00:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4304081 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 298B49F1D6 for ; Thu, 5 Jun 2014 09:01:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6650120320 for ; Thu, 5 Jun 2014 09:01:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3B89C201B4 for ; Thu, 5 Jun 2014 09:01:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3F8C9265353; Thu, 5 Jun 2014 11:01:22 +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 07FAD265328; Thu, 5 Jun 2014 11:01:09 +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 484C42654B3; Thu, 5 Jun 2014 11:01:07 +0200 (CEST) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by alsa0.perex.cz (Postfix) with ESMTP id BE5F4265328 for ; Thu, 5 Jun 2014 11:00:49 +0200 (CEST) Received: by mail-pd0-f182.google.com with SMTP id r10so808491pdi.27 for ; Thu, 05 Jun 2014 02:00:48 -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=S+giklNTOa6g0ycMonsqi021KjTQHJ4vJSfF22J9pBX2FmVqN+UDa6zLRRNdBru+P6 3b1CXcHMJ7H1W9enOXu+HAl/NnsWAC4cgxjzIFlHVd9ky60MNiYoPfYwMoUHeUVRXqH4 XtTEkZiftZSqkSi9CTntwF2HTBpd+G8Y5xRdj9RtInsrBj25CW4WdmMDzLZ/aIJiFTlS 331Mp0fyZCkOVCoMpqPn/FyGeYW5KZVci8/La15zC+8/sZ9+WCIRmaSsPAeHU5062xAx 8vsKsXOobvpJ17cCedNasO0y14/XiqpgKy5wa9NvQrF6LnLXzvaDHP/GCGA+3/9o+LQV 9yOw== X-Received: by 10.68.129.68 with SMTP id nu4mr44346996pbb.76.1401958848186; Thu, 05 Jun 2014 02:00:48 -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 jd5sm20197277pbb.18.2014.06.05.02.00.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Jun 2014 02:00:47 -0700 (PDT) Date: Thu, 05 Jun 2014 18:00:45 +0900 Message-ID: <87k38vivcy.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: <87mwdrivhe.wl%kuninori.morimoto.gx@gmail.com> References: <87mwdrivhe.wl%kuninori.morimoto.gx@gmail.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: Linux-ALSA , cm-hiep@jinso.co.jp, Liam Girdwood , bd-phuc@jinso.co.jp, nx-nui@jinso.co.jp, Simon , h-inayoshi@jinso.co.jp, m-miura@jinso.co.jp, Kuninori Morimoto , nv-dung@jinso.co.jp Subject: [alsa-devel] [PATCH 2/4] 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)