summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-10 10:25:12 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-10 10:25:12 +0100
commitf0cb3317a0cf8333c03b0a45e3bb25c7490f85ef (patch)
tree58ebebc3f22375fe5d1e40e851f0907476f701c9
parentc3b3cfd97b51bf6e6970156c92506cb6fa037b65 (diff)
downloaduca-f0cb3317a0cf8333c03b0a45e3bb25c7490f85ef.tar.gz
uca-f0cb3317a0cf8333c03b0a45e3bb25c7490f85ef.tar.bz2
uca-f0cb3317a0cf8333c03b0a45e3bb25c7490f85ef.tar.xz
uca-f0cb3317a0cf8333c03b0a45e3bb25c7490f85ef.zip
Add IPE infrastructure and make sure that cameras check grabber existence
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/cameras/ipe.c60
-rw-r--r--src/cameras/ipe.h9
-rw-r--r--src/cameras/pco.c3
-rw-r--r--src/cameras/pf.c5
-rw-r--r--src/uca.c12
6 files changed, 80 insertions, 10 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dd0475e..a11833b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,7 +33,6 @@ find_package(ClSerMe4)
# --- Add sources if camera/framegrabber access sources are available ---------
-# FIXME: create some kind of libphoton and search for it
if (PF_FOUND)
set(HAVE_PHOTON_FOCUS TRUE)
diff --git a/src/cameras/ipe.c b/src/cameras/ipe.c
new file mode 100644
index 0000000..30c7b16
--- /dev/null
+++ b/src/cameras/ipe.c
@@ -0,0 +1,60 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <pcilib.h>
+#include "uca.h"
+#include "uca-cam.h"
+#include "uca-grabber.h"
+
+#define set_void(p, type, value) { *((type *) p) = value; }
+
+static uint32_t uca_ipe_acquire_image(struct uca_camera_t *cam, void *buffer)
+{
+ return UCA_NO_ERROR;
+}
+
+static uint32_t uca_ipe_set_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+{
+ return UCA_NO_ERROR;
+}
+
+static uint32_t uca_ipe_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+{
+ return UCA_NO_ERROR;
+}
+
+uint32_t uca_ipe_start_recording(struct uca_camera_t *cam)
+{
+ return UCA_NO_ERROR;
+}
+
+uint32_t uca_ipe_stop_recording(struct uca_camera_t *cam)
+{
+ return UCA_NO_ERROR;
+}
+
+uint32_t uca_ipe_grab(struct uca_camera_t *cam, char *buffer)
+{
+ return UCA_NO_ERROR;
+}
+
+static uint32_t uca_ipe_destroy(struct uca_camera_t *cam)
+{
+ return UCA_NO_ERROR;
+}
+
+uint32_t uca_ipe_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
+{
+ /* Camera found, set function pointers... */
+ uca->destroy = &uca_ipe_destroy;
+ uca->set_property = &uca_ipe_set_property;
+ uca->get_property = &uca_ipe_get_property;
+ uca->start_recording = &uca_ipe_start_recording;
+ uca->stop_recording = &uca_ipe_stop_recording;
+ uca->grab = &uca_ipe_grab;
+
+ uca->state = UCA_CAM_CONFIGURABLE;
+ *cam = uca;
+
+ return UCA_NO_ERROR;
+}
diff --git a/src/cameras/ipe.h b/src/cameras/ipe.h
new file mode 100644
index 0000000..15ebdea
--- /dev/null
+++ b/src/cameras/ipe.h
@@ -0,0 +1,9 @@
+#ifndef __UNIFIED_CAMERA_ACCESS_IPE_H
+#define __UNIFIED_CAMERA_ACCESS_IPE_H
+
+struct uca_camera_t;
+struct uca_grabber_t;
+
+uint32_t uca_ipe_init(struct uca_camera_t **uca, struct uca_grabber_t *grabber);
+
+#endif
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index ccf7d90..cb286e8 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -239,6 +239,9 @@ uint32_t uca_pco_grab(struct uca_camera_t *cam, char *buffer)
uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
{
+ if (grabber == NULL)
+ return UCA_ERR_CAM_NOT_FOUND;
+
struct pco_edge_t *pco = pco_init();
if (pco == NULL) {
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index d32f62f..a39fd3d 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -208,10 +208,7 @@ static uint32_t uca_pf_destroy(struct uca_camera_t *cam)
uint32_t uca_pf_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
{
int num_ports;
- if (pfPortInit(&num_ports) < 0)
- return UCA_ERR_CAM_NOT_FOUND;
-
- if (pfDeviceOpen(0) < 0)
+ if ((grabber == NULL) || (pfPortInit(&num_ports) < 0) || (pfDeviceOpen(0) < 0))
return UCA_ERR_CAM_NOT_FOUND;
/* We could check if a higher baud rate is supported, but... forget about
diff --git a/src/uca.c b/src/uca.c
index 3e016d1..58125b3 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -114,12 +114,14 @@ struct uca_t *uca_init(void)
i++;
}
- if (grabber == NULL) {
- free(uca);
- return NULL;
- }
+ /* XXX: We could have no grabber (aka NULL) which is good anyway, since
+ * some cameras don't need a grabber device (such as the IPE camera),
+ * therefore we also probe each camera against the NULL grabber. However,
+ * each camera must make sure to check for such a situation. */
+
uca->grabbers = grabber;
- grabber->next = NULL;
+ if (grabber != NULL)
+ grabber->next = NULL;
/* Probe each camera that is configured */
i = 0;