public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Nikula <jhnikula@gmail.com>
To: Eduardo Valentin <eduardo.valentin@nokia.com>
Cc: Linux-OMAP <linux-omap@vger.kernel.org>,
	ALSA-Devel <alsa-devel@vger.kernel.org>,
	"Nurkkala Eero.An (EXT-Offcode/Oulu)"
	<ext-Eero.Nurkkala@nokia.com>,
	"\\\"Ujfalusi Peter (Nokia-D/Tampere)\\\""
	<peter.ujfalusi@nokia.com>
Subject: Re: [PATCHv2 08/20] OMAP: McBSP: Add link DMA mode selection
Date: Wed, 12 Aug 2009 14:51:26 +0300	[thread overview]
Message-ID: <20090812145126.bd028e6f.jhnikula@gmail.com> (raw)
In-Reply-To: <1249995931-26015-9-git-send-email-eduardo.valentin@nokia.com>

On Tue, 11 Aug 2009 16:05:19 +0300
Eduardo Valentin <eduardo.valentin@nokia.com> wrote:

> From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
> 
> It adds a new sysfs file, where the user can configure the mcbsp mode to use.
> If the mcbsp channel is in use, it does not allow the change.
> Than in omap_pcm_open we can call the omap_mcbsp_get_opmode to get the mode,
> store it, than use it to implement the different modes.

...
> +static ssize_t dma_op_mode_show(struct device *dev,
> +			struct device_attribute *attr, char *buf)
> +{
> +	struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
> +	int dma_op_mode;
> +
> +	spin_lock_irq(&mcbsp->lock);
> +	dma_op_mode = mcbsp->dma_op_mode;
> +	spin_unlock_irq(&mcbsp->lock);
> +
> +	return sprintf(buf, "current mode: %d\n"
> +			"possible mode values are:\n"
> +			"%d - %s\n"
> +			"%d - %s\n"
> +			"%d - %s\n",
> +			dma_op_mode,
> +			MCBSP_DMA_MODE_ELEMENT, "element mode",
> +			MCBSP_DMA_MODE_THRESHOLD, "threshold mode",
> +			MCBSP_DMA_MODE_FRAME, "frame mode");
> +}
> +

Btw: I hacked a patch below on top of the set for setting and reading the
operating mode in ascii. Freely usable, no guarantee :-)


-- 
Jarkko

--- 
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 50a9fea..e637a28 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -1147,6 +1147,10 @@ static DEVICE_ATTR(prop, 0644, prop##_show, prop##_store);
 THRESHOLD_PROP_BUILDER(max_tx_thres);
 THRESHOLD_PROP_BUILDER(max_rx_thres);
 
+static const char *dma_op_modes[] = {
+	"element", "threshold", "frame",
+};
+
 static ssize_t dma_op_mode_show(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
@@ -1157,15 +1161,7 @@ static ssize_t dma_op_mode_show(struct device *dev,
 	dma_op_mode = mcbsp->dma_op_mode;
 	spin_unlock_irq(&mcbsp->lock);
 
-	return sprintf(buf, "current mode: %d\n"
-			"possible mode values are:\n"
-			"%d - %s\n"
-			"%d - %s\n"
-			"%d - %s\n",
-			dma_op_mode,
-			MCBSP_DMA_MODE_ELEMENT, "element mode",
-			MCBSP_DMA_MODE_THRESHOLD, "threshold mode",
-			MCBSP_DMA_MODE_FRAME, "frame mode");
+	return sprintf(buf, "%s\n", dma_op_modes[dma_op_mode]);
 }
 
 static ssize_t dma_op_mode_store(struct device *dev,
@@ -1173,12 +1169,19 @@ static ssize_t dma_op_mode_store(struct device *dev,
 				const char *buf, size_t size)
 {
 	struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
-	unsigned long val;
-	int status;
-
-	status = strict_strtoul(buf, 0, &val);
-	if (status)
-		return status;
+	const char * const *s;
+	char *p;
+	int len, mode = 0;
+
+	p = memchr(buf, '\n', size);
+	len = p ? p - buf : size;
+
+	for (s = &dma_op_modes[mode];
+	     mode < ARRAY_SIZE(dma_op_modes); s++, mode++)
+		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
+			break;
+	if (mode == ARRAY_SIZE(dma_op_modes))
+		return -EINVAL;
 
 	spin_lock_irq(&mcbsp->lock);
 
@@ -1187,12 +1190,7 @@ static ssize_t dma_op_mode_store(struct device *dev,
 		goto unlock;
 	}
 
-	if (val > MCBSP_DMA_MODE_FRAME || val < MCBSP_DMA_MODE_ELEMENT) {
-		size = -EINVAL;
-		goto unlock;
-	}
-
-	mcbsp->dma_op_mode = val;
+	mcbsp->dma_op_mode = mode;
 
 unlock:
 	spin_unlock_irq(&mcbsp->lock);


      parent reply	other threads:[~2009-08-12 11:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-11 13:05 [PATCHv2 00/20] OMAP ASoC changes in DMA utilization Eduardo Valentin
2009-08-11 13:05 ` [PATCHv2 01/20] OMAP: McBSP: Provide functions for ASoC frame syncronization Eduardo Valentin
2009-08-11 13:05   ` [PATCHv2 02/20] OMAP: McBSP: Add IRQEN, IRQSTATUS, THRESHOLD2 and THRESHOLD1 registers Eduardo Valentin
2009-08-11 13:05     ` [PATCHv2 03/20] OMAP: McBSP: Use appropriate value for startup delay Eduardo Valentin
2009-08-11 13:05       ` [PATCHv2 04/20] OMAP: McBSP: Add transmit/receive threshold handler Eduardo Valentin
2009-08-11 13:05         ` [PATCHv2 05/20] OMAP: McBSP: Create and export max_(r|t)x_thres property Eduardo Valentin
2009-08-11 13:05           ` [PATCHv2 06/20] OMAP3: McBSP: Lower the maximum buffersize for McBSP1,3,4,5 Eduardo Valentin
2009-08-11 13:05             ` [PATCHv2 07/20] OMAP: McBSP: Rename thres sysfs symbols Eduardo Valentin
2009-08-11 13:05               ` [PATCHv2 08/20] OMAP: McBSP: Add link DMA mode selection Eduardo Valentin
2009-08-11 13:05                 ` [PATCHv2 09/20] OMAP: McBSP: Wakeups utilized Eduardo Valentin
2009-08-11 13:05                   ` [PATCHv2 10/20] OMAP: McBSP: Change wakeup signals Eduardo Valentin
2009-08-11 13:05                     ` [PATCHv2 11/20] OMAP: McBSP: Retain McBSP FCLK clockactivity Eduardo Valentin
2009-08-11 13:05                       ` [PATCHv2 12/20] OMAP: McBSP: Configure NO IDLE mode for DMA mode different of threshold Eduardo Valentin
2009-08-11 13:05                         ` [PATCHv2 13/20] OMAP: McBSP: Do not enable wakeups for no-idle mode Eduardo Valentin
2009-08-11 13:05                           ` [PATCHv2 14/20] OMAP: McBSP: Let element DMA mode hit retention also Eduardo Valentin
2009-08-11 13:05                             ` [PATCHv2 15/20] ASoC: OMAP: Use McBSP threshold to playback and capture Eduardo Valentin
2009-08-11 13:05                               ` [PATCHv2 16/20] ASoC: OMAP: Use DMA operating mode of McBSP Eduardo Valentin
2009-08-11 13:05                                 ` [PATCHv2 17/20] ASoC: OMAP: Make DMA 64 aligned Eduardo Valentin
2009-08-11 13:05                                   ` [PATCHv2 18/20] ASoC: OMAP: Enable DMA burst mode Eduardo Valentin
2009-08-11 13:05                                     ` [PATCHv2 19/20] ASoC: Add runtime check for RFIG and XFIG Eduardo Valentin
2009-08-11 13:05                                       ` [PATCHv2 20/20] ASoC: Always syncronize audio transfers on frames Eduardo Valentin
2009-08-12 12:38                                 ` [PATCHv2 16/20] ASoC: OMAP: Use DMA operating mode of McBSP Jarkko Nikula
2009-08-12 13:03                                   ` Eduardo Valentin
2009-08-12 11:51                 ` Jarkko Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090812145126.bd028e6f.jhnikula@gmail.com \
    --to=jhnikula@gmail.com \
    --cc=alsa-devel@vger.kernel.org \
    --cc=eduardo.valentin@nokia.com \
    --cc=ext-Eero.Nurkkala@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=peter.ujfalusi@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox