DSP trigger support for saa7134

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



Here is a patch for the saa7134 driver which adds support for
DSP triggering. I wrote it because ecasound seems to want that
feature. Please point out if I have misunderstood something in
implementing it.

diff -x '*.o*' -Nau saa7134-0.2.9/saa7134.h saa7134-0.2.9-jö/saa7134.h
--- saa7134-0.2.9/saa7134.h	2003-10-15 14:49:04.000000000 +0300
+++ saa7134-0.2.9-jö/saa7134.h	2003-11-19 16:12:10.000000000 +0200
@@ -324,6 +324,9 @@
 	unsigned int               dma_blk;
 	unsigned int               read_offset;
 	unsigned int               read_count;
+	/* dsp trigger support */
+	unsigned int               input_enabled;
+	unsigned int               read_pending;
 };
 
 /* IR input */
diff -x '*.o*' -Nau saa7134-0.2.9/saa7134-oss.c saa7134-0.2.9-jö/saa7134-oss.c
--- saa7134-0.2.9/saa7134-oss.c	2003-10-15 13:11:40.000000000 +0300
+++ saa7134-0.2.9-jö/saa7134-oss.c	2003-11-19 16:59:46.000000000 +0200
@@ -239,6 +239,7 @@
 	dev->oss.channels    = 1;
 	dev->oss.read_count  = 0;
 	dev->oss.read_offset = 0;
+	dev->oss.input_enabled = 1;
 	dsp_buffer_conf(dev,PAGE_SIZE,64);
 	err = dsp_buffer_init(dev);
 	if (0 != err)
@@ -278,6 +279,11 @@
 
 	add_wait_queue(&dev->oss.wq, &wait);
 	down(&dev->oss.lock);
+	if(!dev->oss.input_enabled) {
+		ret = -EAGAIN;
+		goto out;
+	}
+	dev->oss.read_pending=1;
 	while (count > 0) {
 		/* wait for data if needed */
 		if (0 == dev->oss.read_count) {
@@ -326,7 +332,9 @@
 		if (dev->oss.read_offset == dev->oss.bufsize)
 			dev->oss.read_offset = 0;
 	}
-	up(&dev->oss.lock);
+	dev->oss.read_pending=0;
+	if(!dev->oss.input_enabled) dsp_rec_stop(dev);
+ out:	up(&dev->oss.lock);
 	remove_wait_queue(&dev->oss.wq, &wait);
 	current->state = TASK_RUNNING;
 	return ret;
@@ -350,7 +358,7 @@
         case OSS_GETVERSION:
                 return put_user(SOUND_VERSION, (int *)arg);
         case SNDCTL_DSP_GETCAPS:
-		return 0;
+		return put_user(DSP_CAP_TRIGGER, (int *)arg);
 
         case SNDCTL_DSP_SPEED:
 		if (get_user(val, (int*)arg))
@@ -469,6 +477,29 @@
 			return -EFAULT;
 		return 0;
 	}
+	case SNDCTL_DSP_GETTRIGGER:
+		return put_user(dev->oss.input_enabled?PCM_ENABLE_INPUT:0,(int *)arg);
+	case SNDCTL_DSP_SETTRIGGER:
+		if (get_user(val, (int*)arg))
+			return -EFAULT;
+		if (val & PCM_ENABLE_INPUT) {
+			if (!dev->oss.input_enabled) {
+				down(&dev->oss.lock);
+				dev->oss.input_enabled = 1;
+				up(&dev->oss.lock);
+			}
+		} else {
+			if (dev->oss.input_enabled) {
+				down(&dev->oss.lock);
+				dev->oss.input_enabled = 0;
+				if(dev->oss.recording &&
+				   (!dev->oss.read_pending)) {
+					dsp_rec_stop(dev);
+				}
+				up(&dev->oss.lock);
+			}
+		}
+		return 0;
 	default:
 		return -EINVAL;
 	}
@@ -481,6 +512,7 @@
 
 	poll_wait(file, &dev->oss.wq, wait);
 
+	if (!dev->oss.input_enabled) return 0;
 	if (0 == dev->oss.read_count) {
 		down(&dev->oss.lock);
 		if (!dev->oss.recording)




[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux