summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-19 17:59:25 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-19 17:59:25 +0200
commitb646194911cd70e91e84c8354d5bac35b27156df (patch)
tree81a9b56faa50eaf04981ae9f756a5b84e4f4ba24
parent9e424252a35879f121e7ea4531a9ab3dda56d595 (diff)
downloadpcitool-b646194911cd70e91e84c8354d5bac35b27156df.tar.gz
pcitool-b646194911cd70e91e84c8354d5bac35b27156df.tar.bz2
pcitool-b646194911cd70e91e84c8354d5bac35b27156df.tar.xz
pcitool-b646194911cd70e91e84c8354d5bac35b27156df.zip
Few fixes for IPE Camera modification
-rw-r--r--cli.c4
-rw-r--r--dma/nwl_loopback.c65
-rw-r--r--ipecamera/image.c6
-rw-r--r--ipecamera/model.h2
-rwxr-xr-xtests/bench3.sh26
5 files changed, 70 insertions, 33 deletions
diff --git a/cli.c b/cli.c
index c5df898..cdbf9be 100644
--- a/cli.c
+++ b/cli.c
@@ -782,7 +782,9 @@ int WriteData(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_engine_addr_t dma,
if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (%lu) is specified", dma);
err = pcilib_write_dma(handle, dmaid, addr, size, buf, &ret);
if ((err)||(ret != size)) {
- if (!ret) Error("No data is written by DMA engine");
+ if (err == PCILIB_ERROR_TIMEOUT) Error("Timeout writting the data to DMA");
+ else if (err) Error("DMA engine returned a error while writing the data");
+ else if (!ret) Error("No data is written by DMA engine");
else Error("Only %lu bytes of %lu is written by DMA engine", ret, size);
}
break;
diff --git a/dma/nwl_loopback.c b/dma/nwl_loopback.c
index 1904177..a87c109 100644
--- a/dma/nwl_loopback.c
+++ b/dma/nwl_loopback.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -22,17 +23,19 @@ int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, si
val = packet_size;
nwl_write_register(val, ctx, ctx->base_addr, PKT_SIZE_ADDRESS);
- switch (direction) {
- case PCILIB_DMA_BIDIRECTIONAL:
- val = LOOPBACK;
- nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS);
- break;
- case PCILIB_DMA_TO_DEVICE:
- return -1;
- case PCILIB_DMA_FROM_DEVICE:
- val = PKTGENR;
- nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS);
- break;
+ if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) {
+ switch (direction) {
+ case PCILIB_DMA_BIDIRECTIONAL:
+ val = LOOPBACK;
+ nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS);
+ break;
+ case PCILIB_DMA_TO_DEVICE:
+ return -1;
+ case PCILIB_DMA_FROM_DEVICE:
+ val = PKTGENR;
+ nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS);
+ break;
+ }
}
ctx->loopback_started = 1;
@@ -48,15 +51,19 @@ int dma_nwl_stop_loopback(nwl_dma_t *ctx) {
/* Stop in any case, otherwise we can have problems in benchmark due to
engine initialized in previous run, and benchmark is only actual usage.
Otherwise, we should detect current loopback status during initialization */
- nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS);
- nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS);
+
+ if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) {
+ nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS);
+ nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS);
+ }
+
ctx->loopback_started = 0;
return 0;
}
double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction) {
- int i;
+ int iter, i;
int res;
int err;
size_t bytes;
@@ -100,10 +107,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
dma_nwl_enable_engine_irq(ctx, writeid);
#endif /* NWL_GENERATE_DMA_IRQ */
-
- if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) {
- dma_nwl_start_loopback(ctx, direction, size * sizeof(uint32_t));
- }
+ dma_nwl_start_loopback(ctx, direction, size * sizeof(uint32_t));
// Allocate memory and prepare data
buf = malloc(size * sizeof(uint32_t));
@@ -114,23 +118,23 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
return -1;
}
-#ifdef DEBUG_HARDWARE
+//#ifdef DEBUG_HARDWARE
if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e5);
usleep(100000);
pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
}
-#endif /* DEBUG_HARDWARE */
+//#endif /* DEBUG_HARDWARE */
// Benchmark
- for (i = 0; i < iterations; i++) {
- memset(cmp, 0x13 + i, size * sizeof(uint32_t));
+ for (iter = 0; iter < iterations; iter++) {
+ memset(cmp, 0x13 + iter, size * sizeof(uint32_t));
-#ifdef DEBUG_HARDWARE
+//#ifdef DEBUG_HARDWARE
if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
}
-#endif /* DEBUG_HARDWARE */
+//#endif /* DEBUG_HARDWARE */
gettimeofday(&start, NULL);
if (direction&PCILIB_DMA_TO_DEVICE) {
@@ -143,14 +147,13 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
}
}
-#ifdef DEBUG_HARDWARE
+//#ifdef DEBUG_HARDWARE
if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
- //usleep(1000000);
pcilib_write_register(ctx->pcilib, NULL, "control", 0x3e1);
}
+//#endif /* DEBUG_HARDWARE */
memset(buf, 0, size * sizeof(uint32_t));
-#endif /* DEBUG_HARDWARE */
err = pcilib_read_dma(ctx->pcilib, readid, addr, size * sizeof(uint32_t), buf, &bytes);
gettimeofday(&cur, NULL);
@@ -168,12 +171,12 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
if (buf[i] != cmp[i]) break;
bytes = i;
- printf("Expected: *%lx, Written:", 0x13 + i);
+ printf("Expected: *%lx, Written at position %lu:", 0x13 + iter, bytes);
for (; (i < size)&&(i < (bytes + 16)); i++) {
if (((i - bytes)%8)==0) printf("\n");
printf("% 10lx", buf[i]);
}
- printf("\n\n");
+ printf("\n");
error = "Written and read values does not match";
break;
@@ -216,7 +219,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
#endif /* DEBUG_HARDWARE */
if (error) {
- pcilib_warning("%s at iteration %i, error: %i, bytes: %zu", error, i, err, bytes);
+ pcilib_warning("%s at iteration %i, error: %i, bytes: %zu", error, iter, err, bytes);
}
#ifdef NWL_GENERATE_DMA_IRQ
@@ -224,7 +227,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
dma_nwl_disable_engine_irq(ctx, readid);
#endif /* NWL_GENERATE_DMA_IRQ */
- if (ctx->type == PCILIB_DMA_MODIFICATION_DEFAULT) dma_nwl_stop_loopback(ctx);
+ dma_nwl_stop_loopback(ctx);
__sync_synchronize();
diff --git a/ipecamera/image.c b/ipecamera/image.c
index 0fe8da8..62ab695 100644
--- a/ipecamera/image.c
+++ b/ipecamera/image.c
@@ -181,8 +181,12 @@ pcilib_dma_context_t *ipecamera_init_dma(pcilib_context_t *vctx) {
pcilib_error("The DMA engine is not configured in model");
return NULL;
}
-
+
+#ifdef IPECAMERA_DMA_R3
+ return model_info->dma_api->init(ctx->pcilib, PCILIB_NWL_MODIFICATION_IPECAMERA, NULL);
+#else
return model_info->dma_api->init(ctx->pcilib, PCILIB_DMA_MODIFICATION_DEFAULT, NULL);
+#endif
}
diff --git a/ipecamera/model.h b/ipecamera/model.h
index a460dde..9e78ab3 100644
--- a/ipecamera/model.h
+++ b/ipecamera/model.h
@@ -6,6 +6,8 @@
#include "pcilib.h"
#include "image.h"
+//#define IPECAMERA_DMA_R3
+
//#define IPECAMERA_REGISTER_SPACE 0xfeaffc00
#define IPECAMERA_REGISTER_SPACE 0x9000
#define IPECAMERA_REGISTER_WRITE (IPECAMERA_REGISTER_SPACE + 0)
diff --git a/tests/bench3.sh b/tests/bench3.sh
new file mode 100755
index 0000000..1108cd9
--- /dev/null
+++ b/tests/bench3.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+function pci {
+ PCILIB_PATH="/root/pcitool"
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
+}
+
+size=16
+bytes=`expr $size "*" 4`
+
+pci -w xrawdata_packet_length $bytes
+
+pci --start-dma dma1
+pci -w control 0x1e5
+sleep 1
+pci -w control 0x1e1
+
+for i in `seq 1 10`; do
+ pci -w control 0x1e1
+ pci -w dma1 -s $size "*$i"
+ pci -w control 0x3e1
+ pci -r dma1 -s $size -o bench.out
+done
+
+pci --stop-dma dma1
+