From patchwork Sun Jul 5 02:29:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 34080 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n652WPaB010248 for ; Sun, 5 Jul 2009 02:32:25 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n652V0Rx018055; Sat, 4 Jul 2009 21:31:05 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id n652Uw0e017933; Sat, 4 Jul 2009 21:30:59 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 8F2AA8062F; Sat, 4 Jul 2009 21:30:53 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id B80C68065F for ; Sat, 4 Jul 2009 21:30:17 -0500 (CDT) Received: from neches.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id n652UHTd014519 for ; Sat, 4 Jul 2009 21:30:17 -0500 (CDT) Received: from mail145-tx2-R.bigfish.com (mail-tx2.bigfish.com [65.55.88.113]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id n652UCIQ016164 for ; Sat, 4 Jul 2009 21:30:17 -0500 Received: from mail145-tx2 (localhost.localdomain [127.0.0.1]) by mail145-tx2-R.bigfish.com (Postfix) with ESMTP id 32E1AF6006D for ; Sun, 5 Jul 2009 02:30:12 +0000 (UTC) X-SpamScore: 0 X-BigFish: vps0(zzzz1202hzzz2dh66h) X-Spam-TCS-SCL: 5:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 63.231.195.112; Service: EHS Received: by mail145-tx2 (MessageSwitch) id 1246761010623489_9159; Sun, 5 Jul 2009 02:30:10 +0000 (UCT) Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net [63.231.195.112]) by mail145-tx2.bigfish.com (Postfix) with ESMTP id 7EE361BA8052 for ; Sun, 5 Jul 2009 02:30:10 +0000 (UTC) Received: from localhost (unknown [67.42.45.38]) by mpls-qmqp-01.inet.qwest.net (Postfix) with ESMTP id ED4111A9851; Sun, 5 Jul 2009 02:30:06 +0000 (UTC) Received: by localhost (Postfix, from userid 1002) id B7CD45882E5; Sat, 4 Jul 2009 19:30:01 -0700 (MST) From: Troy Kisky To: alsa-devel@alsa-project.org Date: Sat, 4 Jul 2009 19:29:55 -0700 Message-Id: <1246761001-21982-6-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1246761001-21982-5-git-send-email-troy.kisky@boundarydevices.com> References: <1246761001-21982-1-git-send-email-troy.kisky@boundarydevices.com> <1246761001-21982-2-git-send-email-troy.kisky@boundarydevices.com> <1246761001-21982-3-git-send-email-troy.kisky@boundarydevices.com> <1246761001-21982-4-git-send-email-troy.kisky@boundarydevices.com> <1246761001-21982-5-git-send-email-troy.kisky@boundarydevices.com> Cc: davinci-linux-open-source@linux.davincidsp.com, broonie@sirena.org.uk Subject: [PATCH V1 05/11] ASoC: DaVinci: i2s, only start sample generator if needed X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Only start sample generator if needed, and more cleanup on davinci_mcbsp_start. Signed-off-by: Troy Kisky --- sound/soc/davinci/davinci-i2s.c | 32 ++++++++++++++------------------ 1 files changed, 14 insertions(+), 18 deletions(-) diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 73a0fd8..4260965 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -146,11 +146,14 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, spcr & ~mask); toggle_clock(dev, playback); } - /* Start the sample generator and enable transmitter/receiver */ - spcr |= DAVINCI_MCBSP_SPCR_GRST; - davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); + if (dev->pcr & (DAVINCI_MCBSP_PCR_FSXM | DAVINCI_MCBSP_PCR_FSRM | + DAVINCI_MCBSP_PCR_CLKXM | DAVINCI_MCBSP_PCR_CLKRM)) { + /* Start the sample generator */ + spcr |= DAVINCI_MCBSP_SPCR_GRST; + davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); + } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (playback) { /* Stop the DMA to avoid data loss */ /* while the transmitter is out of reset to handle XSYNCERR */ if (platform->pcm_ops->trigger) { @@ -181,23 +184,16 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, if (ret < 0) printk(KERN_DEBUG "Playback DMA start failed\n"); } - /* Enable the transmitter */ - spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); - spcr |= DAVINCI_MCBSP_SPCR_XRST; - davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); - - } else { - - /* Enable the reciever */ - spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); - spcr |= DAVINCI_MCBSP_SPCR_RRST; - davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); } - - /* Start frame sync */ + /* Enable transmitter or receiver */ spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); - spcr |= DAVINCI_MCBSP_SPCR_FRST; + spcr |= mask; + + if (dev->pcr & (DAVINCI_MCBSP_PCR_FSXM | DAVINCI_MCBSP_PCR_FSRM)) { + /* Start frame sync */ + spcr |= DAVINCI_MCBSP_SPCR_FRST; + } davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); }