summaryrefslogtreecommitdiffstats
path: root/dma
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-12-08 03:47:23 +0100
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-12-08 03:47:23 +0100
commit869ed99dbc3a645fee6de36e97e1e12127068f10 (patch)
treefa4a4e7ef977a3d3621ff5e96fb664e6fbc9e6fe /dma
parentddc77c1e819eee03a13efff4a9aa3161485f3f1f (diff)
downloadipecamera-869ed99dbc3a645fee6de36e97e1e12127068f10.tar.gz
ipecamera-869ed99dbc3a645fee6de36e97e1e12127068f10.tar.bz2
ipecamera-869ed99dbc3a645fee6de36e97e1e12127068f10.tar.xz
ipecamera-869ed99dbc3a645fee6de36e97e1e12127068f10.zip
new event architecture, first trial
Diffstat (limited to 'dma')
-rw-r--r--dma/nwl_engine.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index 806173d..ac87f08 100644
--- a/dma/nwl_engine.c
+++ b/dma/nwl_engine.c
@@ -266,10 +266,12 @@ int dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma,
}
int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, pcilib_dma_callback_t cb, void *cbattr) {
- int err, ret = 1;
+ int err, ret = PCILIB_STREAMING_REQ_PACKET;
size_t res = 0;
size_t bufnum;
size_t bufsize;
+ pcilib_timeout_t wait;
+
nwl_dma_t *ctx = (nwl_dma_t*)vctx;
size_t buf_size;
@@ -281,15 +283,15 @@ int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin
if (err) return err;
do {
- if (ret > 2) {
- bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, 0);
- if (bufnum == PCILIB_DMA_BUFFER_INVALID) return 0;
- } else {
- bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, timeout);
- if (bufnum == PCILIB_DMA_BUFFER_INVALID) {
- if (ret == 1) return PCILIB_ERROR_TIMEOUT;
- return 0;
- }
+ switch (ret&PCILIB_STREAMING_TIMEOUT_MASK) {
+ case PCILIB_STREAMING_CONTINUE: wait = PCILIB_DMA_TIMEOUT; break;
+ case PCILIB_STREAMING_WAIT: wait = timeout; break;
+ case PCILIB_STREAMING_CHECK: wait = 0; break;
+ }
+
+ bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, wait);
+ if (bufnum == PCILIB_DMA_BUFFER_INVALID) {
+ return (ret&PCILIB_STREAMING_FAIL)?PCILIB_ERROR_TIMEOUT:0;
}
// EOP is not respected in IPE Camera
@@ -300,8 +302,8 @@ int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin
ret = cb(cbattr, (eop?PCILIB_DMA_FLAG_EOP:0), bufsize, buf);
// DS: Fixme, it looks like we can avoid calling this for the sake of performance
// pcilib_kmem_sync_block(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_TODEVICE, bufnum);
- if (ret < 0) return -ret;
dma_nwl_return_buffer(ctx, info);
+ if (ret < 0) return -ret;
res += bufsize;