From 63ef59492469c08e8d3c7d8a186e4a765eae87b0 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 27 Jul 2012 14:19:48 +0200 Subject: Check for free space in camera DDR buffer before triggering event --- ipecamera/ipecamera.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ipecamera/ipecamera.c') 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); -- cgit v1.2.3