/alps/ipecamera

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

« back to all changes in this revision

Viewing changes to dma/nwl_engine_buffers.h

  • Committer: Suren A. Chilingaryan
  • Date: 2011-12-12 04:45:35 UTC
  • Revision ID: csa@dside.dyndns.org-20111212044535-6no1q7g230i8uvlv
multithread preprocessing of ipecamera frames and code reorganization

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#define NWL_RING_UPDATE(data, offset, mask, val) *(uint32_t*)(((char*)(data)) + (offset)) = ((*(uint32_t*)(((char*)(data)) + (offset)))&(mask))|(val)
4
4
 
5
5
static int dma_nwl_compute_read_s2c_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info, unsigned char *ring, uint32_t ring_pa) {
6
 
    size_t pos;
7
6
    uint32_t val;
8
7
 
9
8
    char *base = info->base_addr;
42
41
}
43
42
 
44
43
static int dma_nwl_compute_read_c2s_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info, unsigned char *ring, uint32_t ring_pa) {
45
 
    size_t pos;
46
44
    uint32_t val;
47
 
    size_t prev;
48
45
 
49
46
    char *base = info->base_addr;
50
47
 
51
 
    
52
48
    nwl_read_register(val, ctx, base, REG_SW_NEXT_BD);
53
49
    if ((val < ring_pa)||((val - ring_pa) % PCILIB_NWL_DMA_DESCRIPTOR_SIZE)) {
54
50
        if (val < ring_pa) pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_SW_NEXT_BD register value (%lx) is below start of the ring [%lx,%lx])", val, ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
112
108
        if (reuse_ring == reuse_pages) {
113
109
            if (reuse_ring & PCILIB_KMEM_REUSE_PARTIAL) pcilib_warning("Inconsistent DMA buffers are found (only part of required buffers is available), reinitializing...");
114
110
            else if (reuse_ring & PCILIB_KMEM_REUSE_REUSED) {
115
 
                if (reuse_ring & PCILIB_KMEM_REUSE_PERSISTENT == 0) pcilib_warning("Lost DMA buffers are found (non-persistent mode), reinitializing...");
116
 
                else if (reuse_ring & PCILIB_KMEM_REUSE_HARDWARE == 0) pcilib_warning("Lost DMA buffers are found (missing HW reference), reinitializing...");
 
111
                if ((reuse_ring & PCILIB_KMEM_REUSE_PERSISTENT) == 0) pcilib_warning("Lost DMA buffers are found (non-persistent mode), reinitializing...");
 
112
                else if ((reuse_ring & PCILIB_KMEM_REUSE_HARDWARE) == 0) pcilib_warning("Lost DMA buffers are found (missing HW reference), reinitializing...");
117
113
                else {
118
114
                    nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_CTRL_STATUS);
119
115
 
174
170
 
175
171
static size_t dma_nwl_clean_buffers(nwl_dma_t * ctx, pcilib_nwl_engine_description_t *info) {
176
172
    size_t res = 0;
177
 
    uint32_t status, control;
 
173
    uint32_t status;
178
174
 
179
175
    unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
180
176
    ring += info->tail * PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
282
278
 
283
279
 
284
280
static size_t dma_nwl_wait_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info, size_t *size, int *eop, pcilib_timeout_t timeout) {
285
 
    uint32_t val;
286
281
    struct timeval start, cur;
287
 
    uint32_t status_size, status, control;
 
282
    uint32_t status_size, status;
288
283
 
289
284
    unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
290
285
    
325
320
    return (size_t)-1;
326
321
}
327
322
 
 
323
/*
 
324
    // This function is not used now, but we may need it in the future
328
325
static int dma_nwl_is_overflown(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info) {
329
326
    uint32_t status;
330
327
    unsigned char *ring = pcilib_kmem_get_ua(ctx->pcilib, info->ring);
334
331
    status = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET);
335
332
    return status&DMA_BD_COMP_MASK?1:0;
336
333
}
 
334
*/
337
335
 
338
336
static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info) {
339
337
    uint32_t val;
357
355
    
358
356
    info->tail++;
359
357
    if (info->tail == info->ring_size) info->tail = 0;
 
358
    
 
359
    return 0;
360
360
}
361
361
 
362
362
int dma_nwl_get_status(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers) {
375
375
    status->ring_tail = info->tail;
376
376
    
377
377
    if (info->desc.direction == PCILIB_DMA_FROM_DEVICE) {
378
 
        size_t pos;
 
378
        size_t pos = 0;
379
379
        for (i = 0; i < info->ring_size; i++) {
380
380
            pos = status->ring_tail + i;
381
381
            if (pos >= info->ring_size) pos -= info->ring_size;