From patchwork Mon Jun 23 00:55:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4397031 Return-Path: X-Original-To: patchwork-linux-sh@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 888E99F26E for ; Mon, 23 Jun 2014 00:55:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B76162022A for ; Mon, 23 Jun 2014 00:55:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB3FA2024F for ; Mon, 23 Jun 2014 00:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751600AbaFWAzm (ORCPT ); Sun, 22 Jun 2014 20:55:42 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:61681 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531AbaFWAzm (ORCPT ); Sun, 22 Jun 2014 20:55:42 -0400 Received: by mail-pd0-f173.google.com with SMTP id r10so4994210pdi.4 for ; Sun, 22 Jun 2014 17:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:to:cc:in-reply-to:references:from:subject :user-agent:mime-version:content-type; bh=bTqpr89i1lwvMib5DD6kekiVOB9TNYVtkbuBeauK3Nc=; b=jp068TtLPwOmZY92dy1qoJcZRajTdiuXRrtD5pQz0w7D+fZaZU5MFTqLDffjrCAW4r PYDB96rTcvLWCgBqV5ZS0jXy0zd57yBLYOr/YG9Bnb72tS8owctPwpz9DJWSZjyLOw3q p3kOtqjK+I1ojvSlzfKy6TQy3zhV9LH2kzCDDy3MRATPjEupVYITY71CifnwKxzSucnY 9dBGJY4T7FTUFQdYSbRCmTACwWisbScRW7Hz0oQp1XPpXGyFlUW/ljYo++wFL9Oii1oQ rJUUCPrAPLTP27keGVvLm0THRZ/a7WUIy6VrcU0LOzwdPXufK6C9BzDv+mXtTmfiZa+w Df3A== X-Received: by 10.68.132.42 with SMTP id or10mr24137984pbb.80.1403484941636; Sun, 22 Jun 2014 17:55:41 -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 it4sm23905687pbc.39.2014.06.22.17.55.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 22 Jun 2014 17:55:41 -0700 (PDT) Date: Sun, 22 Jun 2014 17:55:41 -0700 (PDT) Message-ID: <8738ewtpf2.wl%kuninori.morimoto.gx@renesas.com> To: Mark Brown Cc: Kuninori Morimoto , Linux-ALSA , Liam Girdwood , Simon , linux-sh@vger.kernel.org In-Reply-To: <8761jstphc.wl%kuninori.morimoto.gx@gmail.com> References: <87d2e6zjhf.wl%kuninori.morimoto.gx@gmail.com> <8761jstphc.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto Subject: [PATCH 02/10 v2] ASoC: fsi: add fsi_pointer_update() for common pointer method User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.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 --- v1 -> v2 - no change 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)