summaryrefslogtreecommitdiffstats
path: root/ipecamera/ipecamera.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2012-07-27 14:19:48 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2012-07-27 14:19:48 +0200
commit63ef59492469c08e8d3c7d8a186e4a765eae87b0 (patch)
tree30cbec701a68f20b8d70bbbf30ce786581b670f0 /ipecamera/ipecamera.c
parent4d7dc1f258d94fb94ae473b483eb5a638b2ae119 (diff)
downloadipecamera-63ef59492469c08e8d3c7d8a186e4a765eae87b0.tar.gz
ipecamera-63ef59492469c08e8d3c7d8a186e4a765eae87b0.tar.bz2
ipecamera-63ef59492469c08e8d3c7d8a186e4a765eae87b0.tar.xz
ipecamera-63ef59492469c08e8d3c7d8a186e4a765eae87b0.zip
Check for free space in camera DDR buffer before triggering event
Diffstat (limited to 'ipecamera/ipecamera.c')
-rw-r--r--ipecamera/ipecamera.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/ipecamera/ipecamera.c b/ipecamera/ipecamera.c
index 0710f4d..1ea54f4 100644
--- a/ipecamera/ipecamera.c
+++ b/ipecamera/ipecamera.c
@@ -105,6 +105,9 @@ pcilib_context_t *ipecamera_init(pcilib_t *pcilib) {
FIND_REG(adc_resolution_reg, "fpga", "adc_resolution");
FIND_REG(output_mode_reg, "fpga", "output_mode");
+
+ FIND_REG(max_frames_reg, "fpga", "ddr_max_frames");
+ FIND_REG(num_frames_reg, "fpga", "ddr_num_frames");
ctx->rdma = PCILIB_DMA_ENGINE_INVALID;
ctx->wdma = PCILIB_DMA_ENGINE_INVALID;
@@ -264,7 +267,6 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
CHECK_REG(status_reg, IPECAMERA_EXPECTED_STATUS);
if (err) return err;
-
ctx->event_id = 0;
ctx->preproc_id = 0;
ctx->reported_id = 0;
@@ -296,6 +298,10 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
ctx->image_size = ctx->dim.width * ctx->dim.height;
+
+ GET_REG(max_frames_reg, value);
+ ctx->max_frames = value;
+
ctx->buffer = malloc(ctx->padded_size * ctx->buffer_size);
if (!ctx->buffer) {
ipecamera_stop(vctx, PCILIB_EVENT_FLAGS_DEFAULT);
@@ -594,6 +600,10 @@ int ipecamera_trigger(pcilib_context_t *vctx, pcilib_event_t event, size_t trigg
pcilib_sleep_until_deadline(&ctx->next_trigger);
+ GET_REG(num_frames_reg, value);
+ if (value == ctx->max_frames) {
+ return PCILIB_ERROR_BUSY;
+ }
/*
do {
usleep(10);