summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-21 12:37:12 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-21 12:37:12 +0100
commit195ead4d9aa4f1ed244558d49cee348a5ae6e939 (patch)
treece8cb54595b89b8cc9adb683b453d0e0999454f0
parentef5dfb7febd8881158e493451a27a2500ced14cb (diff)
downloadlibuca-195ead4d9aa4f1ed244558d49cee348a5ae6e939.tar.gz
libuca-195ead4d9aa4f1ed244558d49cee348a5ae6e939.tar.bz2
libuca-195ead4d9aa4f1ed244558d49cee348a5ae6e939.tar.xz
libuca-195ead4d9aa4f1ed244558d49cee348a5ae6e939.zip
Fix grabber allocation and callback registration for me4 and pf
-rw-r--r--src/cameras/pf.c3
-rw-r--r--src/grabbers/me4.c10
-rw-r--r--test/grab.c24
3 files changed, 22 insertions, 15 deletions
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index 5ae35ab..a653b99 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -168,7 +168,7 @@ uint32_t uca_pf_start_recording(struct uca_camera *cam)
uint32_t uca_pf_stop_recording(struct uca_camera *cam)
{
- return UCA_NO_ERROR;
+ return cam->grabber->stop_acquire(cam->grabber);
}
uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer, void *metadata)
@@ -219,6 +219,7 @@ uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber)
uca->start_recording = &uca_pf_start_recording;
uca->stop_recording = &uca_pf_stop_recording;
uca->grab = &uca_pf_grab;
+ uca->register_callback = &uca_pf_register_callback;
/* Prepare frame grabber for recording */
int val = UCA_CL_8BIT_FULL_8;
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 8868deb..42632af 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -75,8 +75,9 @@ uint32_t uca_me4_set_property(struct uca_grabber *grabber, enum uca_grabber_cons
return UCA_ERR_PROP_INVALID;
if (fg_prop->interpret_data) {
- /* Data is not a value but a constant that we need to translate to
- * Silicon Software speak. Therefore, we try to find it in the map also. */
+ /* Data is not a value but a SiSo specific constant that we need to
+ * translate to Silicon Software speak. Therefore, we try to find it in
+ * the map. */
struct uca_sisofg_map_t *constant = uca_me4_find_property(*((uint32_t *) data));
if (constant != NULL)
return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, &constant->fg_id, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_INVALID;
@@ -103,8 +104,8 @@ uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_
return UCA_ERR_PROP_GENERAL;
uint32_t width, height;
- uca_me4_get_property(grabber, FG_WIDTH, &width);
- uca_me4_get_property(grabber, FG_HEIGHT, &height);
+ uca_me4_get_property(grabber, UCA_GRABBER_WIDTH, &width);
+ uca_me4_get_property(grabber, UCA_GRABBER_HEIGHT, &height);
dma_mem *mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers);
if (mem != NULL) {
@@ -206,6 +207,7 @@ uint32_t uca_me4_init(struct uca_grabber **grabber)
uca->acquire = &uca_me4_acquire;
uca->stop_acquire = &uca_me4_stop_acquire;
uca->grab = &uca_me4_grab;
+ uca->register_callback = &uca_me4_register_callback;
uca->callback = NULL;
*grabber = uca;
diff --git a/test/grab.c b/test/grab.c
index 3e429ed..34b90c8 100644
--- a/test/grab.c
+++ b/test/grab.c
@@ -4,6 +4,10 @@
#include "uca.h"
#include "uca-cam.h"
+#define handle_error(errno) {if ((errno) != UCA_NO_ERROR) printf("error at <%s:%i>\n", \
+ __FILE__, __LINE__);}
+
+
int main(int argc, char *argv[])
{
struct uca *u = uca_init(NULL);
@@ -15,24 +19,24 @@ int main(int argc, char *argv[])
/* take first camera */
struct uca_camera *cam = u->cameras;
- uint32_t val = 1;
- cam->set_property(cam, UCA_PROP_EXPOSURE, &val);
+ uint32_t val = 2000;
+ handle_error(cam->set_property(cam, UCA_PROP_EXPOSURE, &val));
val = 0;
- cam->set_property(cam, UCA_PROP_DELAY, &val);
+ handle_error(cam->set_property(cam, UCA_PROP_DELAY, &val));
uint32_t width, height, bits;
- cam->get_property(cam, UCA_PROP_WIDTH, &width, 0);
- cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0);
- cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0);
+ handle_error(cam->get_property(cam, UCA_PROP_WIDTH, &width, 0));
+ handle_error(cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0));
+ handle_error(cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0));
- uca_cam_alloc(cam, 10);
+ handle_error(uca_cam_alloc(cam, 10));
const int pixel_size = bits == 8 ? 1 : 2;
uint16_t *buffer = (uint16_t *) malloc(width * height * pixel_size);
- cam->start_recording(cam);
- cam->grab(cam, (char *) buffer, NULL);
- cam->stop_recording(cam);
+ handle_error(cam->start_recording(cam));
+ handle_error(cam->grab(cam, (char *) buffer, NULL));
+ handle_error(cam->stop_recording(cam));
uca_destroy(u);
FILE *fp = fopen("out.raw", "wb");