diff options
-rw-r--r-- | ipecamera/ipecamera.c | 16 | ||||
-rw-r--r-- | ipecamera/private.h | 10 | ||||
-rw-r--r-- | ipecamera/reader.c | 10 | ||||
-rwxr-xr-x | tests/frame.sh | 2 | ||||
-rwxr-xr-x | tests/frame2.sh | 2 |
5 files changed, 35 insertions, 5 deletions
diff --git a/ipecamera/ipecamera.c b/ipecamera/ipecamera.c index 9b7482a..4ed2c5f 100644 --- a/ipecamera/ipecamera.c +++ b/ipecamera/ipecamera.c @@ -102,6 +102,9 @@ pcilib_context_t *ipecamera_init(pcilib_t *pcilib) { FIND_REG(line_reg, "cmosis", "start1"); FIND_REG(exposure_reg, "cmosis", "exp_time"); FIND_REG(flip_reg, "cmosis", "image_flipping"); + + FIND_REG(adc_resolution_reg, "fpga", "adc_resolution"); + FIND_REG(output_mode_reg, "fpga", "output_mode"); ctx->rdma = PCILIB_DMA_ENGINE_INVALID; ctx->wdma = PCILIB_DMA_ENGINE_INVALID; @@ -272,6 +275,19 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev ctx->dim.width = IPECAMERA_WIDTH; GET_REG(n_lines_reg, ctx->dim.height); + GET_REG(output_mode_reg, value); + switch (value) { + case IPECAMERA_MODE_16_CHAN_IO: + ctx->cmosis_outputs = 16; + break; + case IPECAMERA_MODE_4_CHAN_IO: + ctx->cmosis_outputs = 4; + break; + default: + pcilib_error("IPECamera reporting invalid output_mode 0x%lx", value); + return PCILIB_ERROR_INVALID_STATE; + } + ipecamera_compute_buffer_size(ctx, ctx->dim.height); ctx->raw_size = ctx->cur_raw_size; diff --git a/ipecamera/private.h b/ipecamera/private.h index a0fb4e4..2851515 100644 --- a/ipecamera/private.h +++ b/ipecamera/private.h @@ -31,6 +31,12 @@ #define IPECAMERA_IDLE 0x1E1 #define IPECAMERA_START_INTERNAL_STIMULI 0x1F1 +#define IPECAMERA_MODE_16_CHAN_IO 0 +#define IPECAMERA_MODE_4_CHAN_IO 2 + +#define IPECAMERA_MODE_12_BIT_ADC 2 +#define IPECAMERA_MODE_11_BIT_ADC 1 +#define IPECAMERA_MODE_10_BIT_ADC 0 typedef uint32_t ipecamera_payload_t; @@ -78,6 +84,9 @@ struct ipecamera_s { pcilib_register_t exposure_reg; pcilib_register_t flip_reg; + pcilib_register_t adc_resolution_reg; + pcilib_register_t output_mode_reg; + int started; /**< Camera is in grabbing mode (start function is called) */ int streaming; /**< Camera is in streaming mode (we are within stream call) */ int parse_data; /**< Indicates if some processing of the data is required, otherwise only rawdata_callback will be called */ @@ -103,6 +112,7 @@ struct ipecamera_s { size_t image_size; /**< Size of a single image in bytes */ + int cmosis_outputs; int width, height; diff --git a/ipecamera/reader.c b/ipecamera/reader.c index 645af48..cf5fc5c 100644 --- a/ipecamera/reader.c +++ b/ipecamera/reader.c @@ -25,8 +25,12 @@ int ipecamera_compute_buffer_size(ipecamera_t *ctx, size_t lines) { const size_t header_size = 8 * sizeof(ipecamera_payload_t); const size_t footer_size = 8 * sizeof(ipecamera_payload_t); - size_t raw_size = header_size + lines * line_size - 32 + footer_size; - size_t padded_blocks = raw_size / IPECAMERA_DMA_PACKET_LENGTH + ((raw_size % IPECAMERA_DMA_PACKET_LENGTH)?1:0); + size_t raw_size, padded_blocks; + + raw_size = header_size + lines * line_size - 32 + footer_size; + raw_size *= 16 / ctx->cmosis_outputs; + + padded_blocks = raw_size / IPECAMERA_DMA_PACKET_LENGTH + ((raw_size % IPECAMERA_DMA_PACKET_LENGTH)?1:0); ctx->cur_raw_size = raw_size; ctx->cur_full_size = padded_blocks * IPECAMERA_DMA_PACKET_LENGTH; @@ -37,7 +41,7 @@ int ipecamera_compute_buffer_size(ipecamera_t *ctx, size_t lines) { #endif /* IPECAMERA_BUG_EXTRA_DATA */ ctx->cur_padded_size = padded_blocks * IPECAMERA_DMA_PACKET_LENGTH; - + return 0; } diff --git a/tests/frame.sh b/tests/frame.sh index 1696320..cb2deb1 100755 --- a/tests/frame.sh +++ b/tests/frame.sh @@ -6,7 +6,7 @@ function pci { } pci --stop-dma dma1 -pci --reset +#pci --reset echo "Set packet size 1024 .. " pci -w number_lines 1088 diff --git a/tests/frame2.sh b/tests/frame2.sh index da05807..db3efcc 100755 --- a/tests/frame2.sh +++ b/tests/frame2.sh @@ -6,7 +6,7 @@ function pci { } pci --stop-dma dma1 -pci --reset +#pci --reset echo "Set packet size 1024 .. " pci -w number_lines 1088 |