static void dma_callback(void *client_data) { unsigned long flags; spin_lock_irqsave(&camif_lock, flags); snapshot_active = 0; if (streaming_active) { camif_cleanfifo(); camera_dma_regs->ccr |= DCCR_EN; // restart DMA } else { camif_mode_clear(EN_DMA | EN_FIFO_FULL); } spin_unlock_irqrestore(&camif_lock, flags); #ifdef MEASURE_FR if (dmac_delta) { dmac_sum += machinecycles_to_usecs(do_getmachinecycles() - dmac_delta); dmac_N++; } dmac_delta = do_getmachinecycles(); #endif // callback to V4L2 layer capture_callback(callback_data); EXIT(); }
int get_arch_cycles(unsigned ref_jiffies) { extern unsigned long systimer_mark; extern unsigned long do_getmachinecycles(void); int ret; unsigned temp_jiffies; unsigned diff_jiffies; do { /* snapshot jiffies */ temp_jiffies = jiffies; barrier(); /* calculate cycles since the current jiffy */ ret = do_getmachinecycles() - systimer_mark; /* compensate for ref_jiffies in the past */ if (unlikely(diff_jiffies = jiffies - ref_jiffies)) ret += diff_jiffies * arch_cycles_per_jiffy; barrier(); /* repeat if we didn't have a consistent view of the world */ } while(unlikely(temp_jiffies != jiffies)); return ret; }