summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2006-10-25 14:29:10 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2006-10-25 14:29:10 (GMT)
commit16537e36a94c2b674ff4198c3e8e86f9bcb35782 (patch)
treefe80d780b3a8e895c95aa0f98d55c01b2b5cadbe
parent7bd31f117f311eb966beab75ff469df4cb58fdca (diff)
parallel port support: light and button
git-svn-id: svn://dyne.org/montevideo/ivysync@75 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--branches/lydia/Makefile2
-rw-r--r--branches/lydia/README6
-rw-r--r--branches/lydia/cmdline.cpp18
-rw-r--r--branches/lydia/parport.cpp105
-rw-r--r--branches/lydia/parport.h55
5 files changed, 184 insertions, 2 deletions
diff --git a/branches/lydia/Makefile b/branches/lydia/Makefile
index 03a5930..9062abb 100644
--- a/branches/lydia/Makefile
+++ b/branches/lydia/Makefile
@@ -24,7 +24,7 @@ CPPFLAGS = -I. -Ixmlrpc++ -Iportaudio -Wall -g -ggdb $(GTKFLAGS) $(AOFLAGS)
LIBS = xmlrpc++/libxmlrpc++.a portaudio/libportaudio.a -lpthread -lssl
IVYSYNC_OBJ = decoder.o thread.o linklist.o utils.o cmdline.o gui.o \
- pipe.o xmlrpc.o sound_device.o sndfile_decoder.o sound_decoder.o
+ pipe.o xmlrpc.o sound_device.o sndfile_decoder.o sound_decoder.o parport.o
all: xmlrpc ivysync
diff --git a/branches/lydia/README b/branches/lydia/README
index ef389c1..ddbcf02 100644
--- a/branches/lydia/README
+++ b/branches/lydia/README
@@ -1,7 +1,7 @@
,-_/ .---.
' | . , . . \___ . . ,-. ,-.
.^ | | / | | \ | | | | |
- `--' `' `-| `---' `-| ' ' `-' [ver 0.4]
+ `--' `' `-| `---' `-| ' ' `-' [ver 0.4 Jardin Secret]
/| /|
`-' `-' by Denis "jaromil" Rojo
Montevideo Artlab R&D
@@ -45,6 +45,8 @@ For more documentation, screenshots and download, go to the website:
== FEATURES
+ **** interactive (parallel port interfacing)
+
* full quality s/video or composite multiple output
* professional grade low cost solution
@@ -70,6 +72,8 @@ For more documentation, screenshots and download, go to the website:
* IvyTV compatible hardware decoder
+ * ppdev parport parport_pc kernel modules
+
*** RENT or BUY a syncstarter pre-configured for your needs ***
*** warranty and delivery services available, please contact: ***
diff --git a/branches/lydia/cmdline.cpp b/branches/lydia/cmdline.cpp
index a0197ec..9687d8c 100644
--- a/branches/lydia/cmdline.cpp
+++ b/branches/lydia/cmdline.cpp
@@ -37,6 +37,7 @@
#include <sound_device.h>
#include <xmlrpc.h>
#include <gui.h>
+#include <parport.h>
#include <utils.h>
@@ -63,6 +64,9 @@ SoundDevice *snd = NULL;
// Threaded daemon
IvySyncDaemon *ivydaemon = NULL;
+// Parallel port controller
+ParPort *parport = NULL;
+
char *help =
"Usage: ivysync [-hsDgt] [ -d /dev/video16 [ -p playmode files ] ]\n"
" -h --help show this help\n"
@@ -287,6 +291,8 @@ int main(int argc, char **argv) {
exit(0);
}
+
+
/////////////////////////////////
// setup the graphical interface
if(graphical)
@@ -351,6 +357,18 @@ int main(int argc, char **argv) {
snd->open(false, true);
////////////////////////////////
+ /////////////////////////////////
+ // Parallel port
+ parport = new ParPort();
+ parport->init();
+ // flash light at startup
+ parport->light(true);
+ jsleep(1,0);
+ parport->light(false);
+ parport->launch();
+
+
+
////////////////////////////////
/// Syncstart!
diff --git a/branches/lydia/parport.cpp b/branches/lydia/parport.cpp
new file mode 100644
index 0000000..3c5779d
--- /dev/null
+++ b/branches/lydia/parport.cpp
@@ -0,0 +1,105 @@
+/*
+ * Parallel port controller
+ *
+ * parallel port I/O by Harry
+ * C++ interface by Jaromil
+ *
+ * (c) Copyright 2004-2006 Harry & Jaromil
+ *
+ * This source code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * Please refer to the GNU Public License for more details.
+ *
+ * You should have received a copy of the GNU Public License along with
+ * this source code; if not, write to:
+ * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * to compile this sourcecode: gcc -o ivysync ivysync.c -lpthreads
+ * it should work on any POSIX system, including embedded hardware
+ * wherever the IvyTV drivers can also run (see http://ivtv.sf.net)
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/io.h>
+
+#include <parport.h>
+#include <utils.h>
+
+#define BASEPORT 0x378 /* lp1 */
+
+ParPort::ParPort()
+ : Thread() {
+
+ quit = false;
+ button_state = false;
+
+}
+
+ParPort::~ParPort() {
+ if( ioperm(BASEPORT, 3, 0) )
+ E("error closing parallel ports");
+}
+
+bool ParPort::init() {
+
+ if( ioperm(BASEPORT, 3, 1) ) {
+ E("error accessing parallel ports");
+ return false;
+ }
+
+ N("Parallel port initialized");
+ return true;
+
+}
+
+void ParPort::run() {
+ int status;
+
+ A("Parallel port polling started");
+
+ while(!quit) {
+
+ jsleep(0,100); // sleep for a while
+
+ // Read from the status port (BASE+2)
+ status = inb(BASEPORT + 1);
+
+ if( status == 120 ) {
+ button_state = true;
+ D("button has been pressed", status);
+ }
+
+ }
+
+}
+
+int ParPort::light(bool state) {
+ if(state) {
+ // Set the data signals (D0) of the port to high (255)
+ outb(255, BASEPORT);
+ D("switch light on");
+ } else {
+ // Set the data signals (D0-7) of the port to all low (0)
+ outb(0, BASEPORT);
+ D("switch light off");
+ }
+ return state;
+}
+
+int ParPort::button_reset() {
+ button_state = false;
+ return 1;
+}
+
+int ParPort::button_is_pressed() {
+ if(button_state) return 1;
+ else return 0;
+}
diff --git a/branches/lydia/parport.h b/branches/lydia/parport.h
new file mode 100644
index 0000000..76ab0d6
--- /dev/null
+++ b/branches/lydia/parport.h
@@ -0,0 +1,55 @@
+/*
+ * Parallel port controller
+ *
+ * parallel port I/O by Harry
+ * C++ interface by Jaromil
+ *
+ * (c) Copyright 2004-2006 Harry & Jaromil
+ *
+ * This source code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * Please refer to the GNU Public License for more details.
+ *
+ * You should have received a copy of the GNU Public License along with
+ * this source code; if not, write to:
+ * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * to compile this sourcecode: gcc -o ivysync ivysync.c -lpthreads
+ * it should work on any POSIX system, including embedded hardware
+ * wherever the IvyTV drivers can also run (see http://ivtv.sf.net)
+ *
+ */
+
+#ifndef __PARPORT_H__
+#define __PARPORT_H__
+
+#include <thread.h>
+
+class ParPort : public Thread {
+
+ public:
+ ParPort();
+ ~ParPort();
+
+ bool init();
+ void run();
+
+ int light(bool state); // switch light on/off
+
+ int button_reset(); // reset button to un-pressed state
+ int button_is_pressed(); // returns true if the button was pressed
+
+ private:
+
+ bool button_state;
+
+};
+
+
+#endif