/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to dma/nwl_engine.c

  • Committer: Suren A. Chilingaryan
  • Date: 2011-12-08 02:47:23 UTC
  • Revision ID: csa@dside.dyndns.org-20111208024723-ym9uf3uoll6ym2a9
new event architecture, first trial

Show diffs side-by-side

added added

removed removed

Lines of Context:
266
266
}
267
267
 
268
268
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) {
269
 
    int err, ret = 1;
 
269
    int err, ret = PCILIB_STREAMING_REQ_PACKET;
270
270
    size_t res = 0;
271
271
    size_t bufnum;
272
272
    size_t bufsize;
 
273
    pcilib_timeout_t wait;
 
274
    
273
275
    nwl_dma_t *ctx = (nwl_dma_t*)vctx;
274
276
 
275
277
    size_t buf_size;
281
283
    if (err) return err;
282
284
    
283
285
    do {
284
 
        if (ret > 2) {
285
 
            bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, 0);
286
 
            if (bufnum == PCILIB_DMA_BUFFER_INVALID) return 0;
287
 
        } else {
288
 
            bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, timeout);
289
 
            if (bufnum == PCILIB_DMA_BUFFER_INVALID) {
290
 
                if (ret == 1) return PCILIB_ERROR_TIMEOUT;
291
 
                return 0;
292
 
            }
 
286
        switch (ret&PCILIB_STREAMING_TIMEOUT_MASK) {
 
287
            case PCILIB_STREAMING_CONTINUE: wait = PCILIB_DMA_TIMEOUT; break;
 
288
            case PCILIB_STREAMING_WAIT: wait = timeout; break;
 
289
            case PCILIB_STREAMING_CHECK: wait = 0; break;
 
290
        }
 
291
    
 
292
        bufnum = dma_nwl_wait_buffer(ctx, info, &bufsize, &eop, wait);
 
293
        if (bufnum == PCILIB_DMA_BUFFER_INVALID) {
 
294
            return (ret&PCILIB_STREAMING_FAIL)?PCILIB_ERROR_TIMEOUT:0;
293
295
        }
294
296
 
295
297
            // EOP is not respected in IPE Camera
300
302
        ret = cb(cbattr, (eop?PCILIB_DMA_FLAG_EOP:0), bufsize, buf);
301
303
//      DS: Fixme, it looks like we can avoid calling this for the sake of performance
302
304
//      pcilib_kmem_sync_block(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_TODEVICE, bufnum);
 
305
        dma_nwl_return_buffer(ctx, info);
303
306
        if (ret < 0) return -ret;
304
 
        dma_nwl_return_buffer(ctx, info);
305
307
        
306
308
        res += bufsize;
307
309