summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--error.h3
-rw-r--r--ipecamera/ipecamera.c12
-rw-r--r--ipecamera/model.h4
-rw-r--r--ipecamera/private.h6
4 files changed, 20 insertions, 5 deletions
diff --git a/error.h b/error.h
index cbf2d98..20d1c09 100644
--- a/error.h
+++ b/error.h
@@ -21,7 +21,8 @@ enum {
PCILIB_ERROR_NOTAVAILABLE = ENAVAIL,
PCILIB_ERROR_NOTINITIALIZED = EBADFD,
PCILIB_ERROR_TOOBIG = EFBIG,
- PCILIB_ERROR_OVERWRITTEN = ESTALE
+ PCILIB_ERROR_OVERWRITTEN = ESTALE,
+ PCILIB_ERROR_BUSY = EBUSY
} pcilib_errot_t;
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);
diff --git a/ipecamera/model.h b/ipecamera/model.h
index 9034e59..4c527df 100644
--- a/ipecamera/model.h
+++ b/ipecamera/model.h
@@ -114,8 +114,8 @@ pcilib_register_description_t ipecamera_registers[] = {
{0x170, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "num_triggers", ""},
{0x180, 0, 32, 0x280, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "trigger_period", ""},
{0x190, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "temperature_sample_period", ""},
-{0x1a0, 0, 32, 0x64, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "max_frames", ""},
-{0x1b0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "num_frames", ""},
+{0x1a0, 0, 32, 0x64, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "ddr_max_frames", ""},
+{0x1b0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "ddr_num_frames", ""},
{0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}
};
diff --git a/ipecamera/private.h b/ipecamera/private.h
index 5dc10d1..a200b75 100644
--- a/ipecamera/private.h
+++ b/ipecamera/private.h
@@ -86,6 +86,9 @@ struct ipecamera_s {
pcilib_register_t adc_resolution_reg;
pcilib_register_t output_mode_reg;
+
+ pcilib_register_t max_frames_reg;
+ pcilib_register_t num_frames_reg;
int started; /**< Camera is in grabbing mode (start function is called) */
int streaming; /**< Camera is in streaming mode (we are within stream call) */
@@ -112,7 +115,8 @@ struct ipecamera_s {
size_t image_size; /**< Size of a single image in bytes */
- int cmosis_outputs;
+ size_t max_frames; /**< Maximal number of frames what may be buffered in camera DDR memory */
+ int cmosis_outputs; /**< Number of active cmosis outputs: 4 or 16 */
int width, height;