summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-28 16:34:21 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-28 16:34:21 +0100
commit7296b7a6f4368e8cad39169340770c78166b95cd (patch)
treec20ddd79f94abc33658aaac830c45dbc45a7f1b4
parentd3221c2e96b4a19fce6dff7af16d859ae05a690b (diff)
downloaduca-7296b7a6f4368e8cad39169340770c78166b95cd.tar.gz
uca-7296b7a6f4368e8cad39169340770c78166b95cd.tar.bz2
uca-7296b7a6f4368e8cad39169340770c78166b95cd.tar.xz
uca-7296b7a6f4368e8cad39169340770c78166b95cd.zip
Add buffer allocation
-rw-r--r--src/grabbers/me4.c28
-rw-r--r--src/uca-grabber.h8
-rw-r--r--test/test.c4
3 files changed, 35 insertions, 5 deletions
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index aa61946..c879dfd 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -7,7 +7,13 @@
#include "uca.h"
#include "uca-grabber.h"
-#define GET_FG(grabber) ((Fg_Struct *)(grabber->user))
+struct uca_me4_grabber_t {
+ Fg_Struct *fg;
+ dma_mem *mem;
+};
+
+#define GET_FG(grabber) (((struct uca_me4_grabber_t *) grabber->user)->fg)
+#define GET_MEM(grabber) (((struct uca_me4_grabber_t *) grabber->user)->mem)
uint32_t uca_me4_destroy(struct uca_grabber_t *grabber)
{
@@ -24,6 +30,19 @@ uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_property_i
return Fg_getParameter(GET_FG(grabber), property, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL;
}
+uint32_t uca_me4_allocate(struct uca_grabber_t *grabber, uint32_t n_buffers)
+{
+ if (GET_MEM(grabber) != NULL)
+ /* FIXME: invent better error code */
+ 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);
+ /* FIXME: get size of pixel */
+ ((struct uca_me4_grabber_t *) grabber->user)->mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*sizeof(uint16_t), n_buffers);
+}
+
uint32_t uca_me4_init(struct uca_grabber_t **grabber)
{
/* FIXME: find out if this board/grabber is running */
@@ -32,10 +51,15 @@ uint32_t uca_me4_init(struct uca_grabber_t **grabber)
return UCA_ERR_INIT_NOT_FOUND;
struct uca_grabber_t *uca = (struct uca_grabber_t *) malloc(sizeof(struct uca_grabber_t));
- uca->user = fg;
+ struct uca_me4_grabber_t *me4 = (struct uca_me4_grabber_t *) malloc(sizeof(struct uca_me4_grabber_t));
+
+ me4->fg = fg;
+ me4->mem = NULL;
+ uca->user = me4;
uca->destroy = &uca_me4_destroy;
uca->set_property = &uca_me4_set_property;
uca->get_property = &uca_me4_get_property;
+ uca->allocate = &uca_me4_allocate;
*grabber = uca;
return UCA_NO_ERROR;
diff --git a/src/uca-grabber.h b/src/uca-grabber.h
index 0704610..3c48681 100644
--- a/src/uca-grabber.h
+++ b/src/uca-grabber.h
@@ -31,6 +31,13 @@ typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber_t *grabber, enu
*/
typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enum uca_property_ids property, void *data);
+/**
+ * \brief Allocate buffers with current width, height and bitdepth
+ * \note Subsequent changes of width and height might corrupt memory
+ */
+typedef uint32_t (*uca_grabber_allocate) (struct uca_grabber_t *grabber, uint32_t n_buffers);
+
+
struct uca_grabber_t {
struct uca_grabber_t *next;
@@ -39,6 +46,7 @@ struct uca_grabber_t {
uca_grabber_destroy destroy;
uca_grabber_set_property set_property;
uca_grabber_get_property get_property;
+ uca_grabber_allocate allocate;
/* Private */
void *user;
diff --git a/test/test.c b/test/test.c
index 4a39ab2..0649c64 100644
--- a/test/test.c
+++ b/test/test.c
@@ -35,9 +35,7 @@ int main(int argc, char *argv[])
uint8_t uint8_value;
const char *unit_map[] = {
- "px", "bits",
- "ns", "µs", "ms", "s",
- "rows", ""
+ "px", "bits", "ns", "µs", "ms", "s", "rows", ""
};
while (cam != NULL) {