summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-12 19:51:27 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-12 19:51:27 +0200
commit9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9 (patch)
treec7b4a4ca1008490d677b18a261743a0ff85cc9dc
parente455f83ca2e4ee7c39837309a422732167994cbf (diff)
downloadipecamera-9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9.tar.gz
ipecamera-9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9.tar.bz2
ipecamera-9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9.tar.xz
ipecamera-9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9.zip
Few fixes
-rw-r--r--cli.c20
-rw-r--r--dma.c3
-rw-r--r--dma/nwl.c23
-rw-r--r--dma/nwl_buffers.h2
4 files changed, 34 insertions, 14 deletions
diff --git a/cli.c b/cli.c
index 7ba7332..8834865 100644
--- a/cli.c
+++ b/cli.c
@@ -357,9 +357,9 @@ int Benchmark(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_engine_addr_t dma,
max_size = BENCH_MAX_DMA_SIZE;
}
- for (size = min_size; size < max_size; size *= 4) {
- mbs_in = pcilib_benchmark_dma(handle, dma, addr, size, BENCHMARK_ITERATIONS, PCILIB_DMA_FROM_DEVICE);
- mbs_out = pcilib_benchmark_dma(handle, dma, addr, size, BENCHMARK_ITERATIONS, PCILIB_DMA_TO_DEVICE);
+ for (size = min_size; size < min_size + 1/*max_size*/; size *= 4) {
+ mbs_in = -1;//pcilib_benchmark_dma(handle, dma, addr, size, BENCHMARK_ITERATIONS, PCILIB_DMA_FROM_DEVICE);
+ mbs_out = -1;//pcilib_benchmark_dma(handle, dma, addr, size, BENCHMARK_ITERATIONS, PCILIB_DMA_TO_DEVICE);
mbs = pcilib_benchmark_dma(handle, dma, addr, size, BENCHMARK_ITERATIONS, PCILIB_DMA_BIDIRECTIONAL);
err = pcilib_wait_irq(handle, 0, 0, &irqs);
if (err) irqs = 0;
@@ -801,9 +801,17 @@ int WriteRegister(pcilib_t *handle, pcilib_model_description_t *model_info, cons
unsigned long val;
pcilib_register_value_t value;
-
- if ((!isnumber(*data))||(sscanf(*data, "%li", &val) != 1)) {
- Error("Can't parse data value (%s) is not valid decimal number", data[i]);
+
+ if (!isnumber(*data)) {
+ if (sscanf(*data, "%li", &val) != 1) {
+ Error("Can't parse data value (%s) is not valid decimal number", *data);
+ }
+ } else if (!isxnumber(*data)) {
+ if (sscanf(*data, "%lx", &val) != 1) {
+ Error("Can't parse data value (%s) is not valid decimal number", *data);
+ }
+ } else {
+ Error("Can't parse data value (%s) is not valid decimal number", *data);
}
value = val;
diff --git a/dma.c b/dma.c
index 3cba0da..04f1446 100644
--- a/dma.c
+++ b/dma.c
@@ -165,6 +165,7 @@ static int pcilib_dma_read_callback(void *arg, pcilib_dma_flags_t flags, size_t
}
static int pcilib_dma_skip_callback(void *arg, pcilib_dma_flags_t flags, size_t bufsize, void *buf) {
+// if (arg) (*(uint32_t*)arg) += bufsize;
return 1;
}
@@ -214,7 +215,7 @@ int pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size
int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_engine_t dma) {
int err;
- size_t skipped;
+ size_t skipped = 0;
do {
// IMMEDIATE timeout is not working properly, so default is set
err = pcilib_stream_dma(ctx, dma, 0, 0, PCILIB_DMA_FLAGS_DEFAULT, PCILIB_DMA_TIMEOUT, pcilib_dma_skip_callback, &skipped);
diff --git a/dma/nwl.c b/dma/nwl.c
index c5240f0..b48e0a4 100644
--- a/dma/nwl.c
+++ b/dma/nwl.c
@@ -128,11 +128,13 @@ void dma_nwl_free(pcilib_dma_context_t *vctx) {
pcilib_dma_engine_t i;
nwl_dma_t *ctx = (nwl_dma_t*)vctx;
- dma_nwl_stop_loopback(ctx);
- dma_nwl_free_irq(ctx);
- dma_nwl_stop(ctx, PCILIB_DMA_ENGINE_ALL, PCILIB_DMA_FLAGS_DEFAULT);
-
- free(ctx);
+ if (ctx) {
+ dma_nwl_stop_loopback(ctx);
+ dma_nwl_free_irq(ctx);
+ dma_nwl_stop(ctx, PCILIB_DMA_ENGINE_ALL, PCILIB_DMA_FLAGS_DEFAULT);
+
+ free(ctx);
+ }
}
@@ -144,7 +146,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
uint32_t val;
uint32_t *buf, *cmp;
const char *error = NULL;
-// pcilib_register_value_t regval;
+ pcilib_register_value_t regval;
size_t us = 0;
struct timeval start, cur;
@@ -208,6 +210,11 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
// Benchmark
for (i = 0; i < iterations; i++) {
+// puts("====================================");
+ pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
+// pcilib_read_register(ctx->pcilib, NULL, "control", &regval);
+// printf("Control: %lx\n", regval);
+
gettimeofday(&start, NULL);
if (direction&PCILIB_DMA_TO_DEVICE) {
memcpy(buf, cmp, size * sizeof(uint32_t));
@@ -241,6 +248,10 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
nwl_read_register(val, ctx, write_base, REG_DMA_ENG_CTRL_STATUS);
printf("Write DMA control (after write): %lx\n", val);
*/
+ pcilib_write_register(ctx->pcilib, NULL, "control", 0x3e1);
+// pcilib_read_register(ctx->pcilib, NULL, "control", &regval);
+// printf("Control: %lx\n", regval);
+
memset(buf, 0, size * sizeof(uint32_t));
err = pcilib_read_dma(ctx->pcilib, readid, addr, size * sizeof(uint32_t), buf, &bytes);
diff --git a/dma/nwl_buffers.h b/dma/nwl_buffers.h
index 35f4781..565eccf 100644
--- a/dma/nwl_buffers.h
+++ b/dma/nwl_buffers.h
@@ -151,7 +151,7 @@ static size_t dma_nwl_get_next_buffer(nwl_dma_t * ctx, pcilib_nwl_engine_descrip
}
static int dma_nwl_push_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info, size_t size, int eop, pcilib_timeout_t timeout) {
- int flags;
+ int flags = 0;
uint32_t val;
unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);