summaryrefslogtreecommitdiffstats
path: root/src/grabbers/me4.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-16 10:15:15 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-16 10:15:15 +0100
commit2de85655bd50cfcd2a21267ecf4e5f91b0800a9c (patch)
tree0abf914efecdd76edc48043feb15aa4e96806464 /src/grabbers/me4.c
parent3d037dbe86665b59c6bb5d71f3d58558a5848d38 (diff)
downloadlibuca-2de85655bd50cfcd2a21267ecf4e5f91b0800a9c.tar.gz
libuca-2de85655bd50cfcd2a21267ecf4e5f91b0800a9c.tar.bz2
libuca-2de85655bd50cfcd2a21267ecf4e5f91b0800a9c.tar.xz
libuca-2de85655bd50cfcd2a21267ecf4e5f91b0800a9c.zip
Implement grab callback for Silicon Software me4
Diffstat (limited to 'src/grabbers/me4.c')
-rw-r--r--src/grabbers/me4.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index d6419e0..7bb687b 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -8,9 +8,10 @@
#include "uca.h"
#include "uca-grabber.h"
-struct uca_me4_grabber_t {
+struct fg_apc_data {
Fg_Struct *fg;
dma_mem *mem;
+ uca_grabber_grab_callback cb;
};
struct uca_sisofg_map_t {
@@ -39,8 +40,8 @@ static struct uca_sisofg_map_t uca_to_fg[] = {
{ UCA_GRABBER_INVALID, 0, false }
};
-#define GET_FG(grabber) (((struct uca_me4_grabber_t *) grabber->user)->fg)
-#define GET_MEM(grabber) (((struct uca_me4_grabber_t *) grabber->user)->mem)
+#define GET_FG(grabber) (((struct fg_apc_data *) grabber->user)->fg)
+#define GET_MEM(grabber) (((struct fg_apc_data *) grabber->user)->mem)
uint32_t uca_me4_destroy(struct uca_grabber_t *grabber)
{
@@ -103,7 +104,7 @@ uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t pixel_size, uint3
dma_mem *mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers);
if (mem != NULL) {
- ((struct uca_me4_grabber_t *) grabber->user)->mem = mem;
+ ((struct fg_apc_data *) grabber->user)->mem = mem;
return UCA_NO_ERROR;
}
return UCA_ERR_PROP_GENERAL;
@@ -145,11 +146,31 @@ uint32_t uca_me4_grab(struct uca_grabber_t *grabber, void **buffer)
return UCA_NO_ERROR;
}
+static int uca_me4_callback(frameindex_t frame, struct fg_apc_data *apc)
+{
+ apc->cb(frame, Fg_getImagePtr(apc->fg, frame, PORT_A));
+ return 0;
+}
+
uint32_t uca_me4_register_callback(struct uca_grabber_t *grabber, uca_grabber_grab_callback cb)
{
- grabber->callback = cb;
+ if (grabber->callback == NULL) {
+ grabber->callback = cb;
+ ((struct fg_apc_data *) grabber->user)->cb = cb;
+
+ struct FgApcControl ctrl;
+ ctrl.version = 0;
+ ctrl.data = (struct fg_apc_data *) grabber->user;
+ ctrl.func = &uca_me4_callback;
+ ctrl.flags = FG_APC_DEFAULTS;
+ ctrl.timeout = 1;
+
+ if (Fg_registerApcHandler(GET_FG(grabber), PORT_A, &ctrl, FG_APC_CONTROL_BASIC) != FG_OK)
+ return UCA_ERR_GRABBER_CALLBACK_REGISTRATION_FAILED;
+ }
+ else
+ return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED;
- /* TODO: add me4 registerApc stuff */
return UCA_NO_ERROR;
}
@@ -160,10 +181,12 @@ uint32_t uca_me4_init(struct uca_grabber_t **grabber)
return UCA_ERR_GRABBER_NOT_FOUND;
struct uca_grabber_t *uca = (struct uca_grabber_t *) malloc(sizeof(struct uca_grabber_t));
- struct uca_me4_grabber_t *me4 = (struct uca_me4_grabber_t *) malloc(sizeof(struct uca_me4_grabber_t));
+ struct fg_apc_data *me4 = (struct fg_apc_data *) malloc(sizeof(struct fg_apc_data));
- me4->fg = fg;
+ me4->fg = fg;
me4->mem = NULL;
+ me4->cb = NULL;
+
uca->user = me4;
uca->destroy = &uca_me4_destroy;
uca->set_property = &uca_me4_set_property;