[PATCH 1/5 v2] ASoC: S3C platform: Fix s3c2410_dma_started called at wrong time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



DMA part: No old API dropped. Add the s3c2410_dma_trigger() API used for
to start or to stop a DMA transfer. This API will reduce the miss use of
s3c2410_dma_started() function. User should provide the callback
functions, trigger event and the DMA channel number before calling this
API. These private data is packed in struct s3c2410_dma_client. No new
struct added.


--- a/arch/arm/plat-s3c/include/plat/dma.h	2009-08-24 13:29:03.000000000 +0800
+++ b/arch/arm/plat-s3c/include/plat/dma.h	2009-08-24 15:30:23.000000000 +0800
@@ -37,8 +37,23 @@
 	S3C2410_DMAOP_STARTED,		/* indicate channel started */
 };
 
+enum s3c2410_dma_trigger_event {
+	S3C2410_DMA_TRIGGER_START,		/* start a channel */
+	S3C2410_DMA_TRIGGER_STOP,		/* stop a channel */
+	S3C2410_DMA_TRIGGER_MAX,
+};
+
 struct s3c2410_dma_client {
-	char                *name;
+	char		*name;
+	unsigned int 	channel;		/* channel number */
+	/* trigger event */
+	enum s3c2410_dma_trigger_event event;
+	/* callback funtion from client to generate the DMA REQ signal */
+	int (*gen_request)(void *);
+	/* callback funtion from client to end the DMA request */
+	int (*end_request)(void *);
+	/* pravate data to the callback function */
+	void 		*private_data;
 };
 
 struct s3c2410_dma_chan;
@@ -73,6 +88,13 @@
 
 extern int s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op);
 
+/* s3c2410_dma_trigger
+ *
+ * trigger the DMA engine to start or stop
+*/
+
+extern int s3c2410_dma_trigger(struct s3c2410_dma_client *client);
+
 /* s3c2410_dma_setflags
  *
  * set the channel's flags to a given state
--- a/arch/arm/plat-s3c/dma.c	2009-08-24 15:26:07.000000000 +0800
+++ b/arch/arm/plat-s3c/dma.c	2009-08-24 15:27:09.000000000 +0800
@@ -84,3 +84,32 @@
 	return 0;
 }
 EXPORT_SYMBOL(s3c2410_dma_setflags);
+
+int s3c2410_dma_trigger(struct s3c2410_dma_client *client)
+{
+	int ret = 0;
+	if(!client || !(client->channel < DMACH_MAX)) {
+ 		pr_debug("%s: Invalid parameter\n", __func__);
+		return -EINVAL;
+	}
+
+	switch(client->event) {
+	case S3C2410_DMA_TRIGGER_START:
+		s3c2410_dma_ctrl(client->channel, S3C2410_DMAOP_START);
+		if(client->gen_request)
+			ret = client->gen_request(client->private_data);
+		s3c2410_dma_ctrl(client->channel, S3C2410_DMAOP_STARTED);
+		return ret;
+	case S3C2410_DMA_TRIGGER_STOP:
+		s3c2410_dma_ctrl(client->channel, S3C2410_DMAOP_STOP);
+		if(client->end_request)
+			ret = client->end_request(client->private_data);
+		return ret;
+	default:
+		pr_debug("%s: Invalid event\n", __func__);
+	}
+	return -EINVAL;
+}
+
+EXPORT_SYMBOL(s3c2410_dma_trigger);
+



_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux