summaryrefslogtreecommitdiffstats
path: root/dma/nwl_loopback.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 16:43:47 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 16:43:47 +0200
commit21d12d6157061bca3926607a248ccc16d6b07bd1 (patch)
treea74c3e0960725c92800399d913242e78c91e69cf /dma/nwl_loopback.c
parent4fe2032eca29d7f7a0fdf23ef0f3d2c324aeeba2 (diff)
downloadipecamera-21d12d6157061bca3926607a248ccc16d6b07bd1.tar.gz
ipecamera-21d12d6157061bca3926607a248ccc16d6b07bd1.tar.bz2
ipecamera-21d12d6157061bca3926607a248ccc16d6b07bd1.tar.xz
ipecamera-21d12d6157061bca3926607a248ccc16d6b07bd1.zip
Correctly detect the tail pointer of C2S ring
Diffstat (limited to 'dma/nwl_loopback.c')
-rw-r--r--dma/nwl_loopback.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/dma/nwl_loopback.c b/dma/nwl_loopback.c
index 3c2c124..de17962 100644
--- a/dma/nwl_loopback.c
+++ b/dma/nwl_loopback.c
@@ -16,7 +16,8 @@
int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, size_t packet_size) {
uint32_t val;
- // Re-initializing always
+ ctx->loopback_started = 1;
+ dma_nwl_stop_loopback(ctx);
val = packet_size;
nwl_write_register(val, ctx, ctx->base_addr, PKT_SIZE_ADDRESS);
@@ -24,17 +25,16 @@ int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, si
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;
}
- 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 = 1;
return 0;
@@ -42,6 +42,8 @@ int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, si
int dma_nwl_stop_loopback(nwl_dma_t *ctx) {
uint32_t val = 0;
+
+ if (!ctx->loopback_started) return 0;
/* Stop in any case, otherwise we can have problems in benchmark due to
engine initialized in previous run, and benchmark is only actual usage.