void DPI1_WaitVSYNC(void) { wait_dpi_vsync = true; hrtimer_start(&hrtimer_vsync_dpi, ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi1)), HRTIMER_MODE_REL); wait_event_interruptible(_vsync_wait_queue_dpi, dpi_vsync); dpi_vsync = false; wait_dpi_vsync = false; }
void DPI1_InitVSYNC(unsigned int vsync_interval) { ktime_t ktime; vsync_timer_dpi1 = vsync_interval; ktime = ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi1)); hrtimer_init(&hrtimer_vsync_dpi, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_vsync_dpi.function = dpi1_vsync_hrtimer_func; // hrtimer_start(&hrtimer_vsync_dpi, ktime, HRTIMER_MODE_REL); }
void DPI_WaitVSYNC(void) { #ifndef BUILD_UBOOT wait_dpi_vsync = true; hrtimer_start(&hrtimer_vsync_dpi, ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi)), HRTIMER_MODE_REL); wait_event_interruptible(_vsync_wait_queue_dpi, dpi_vsync); dpi_vsync = false; wait_dpi_vsync = false; #endif }
void DPI_InitVSYNC(unsigned int vsync_interval) { #ifndef BUILD_UBOOT ktime_t ktime; vsync_timer_dpi = vsync_interval; ktime = ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi)); hrtimer_init(&hrtimer_vsync_dpi, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_vsync_dpi.function = dpi_vsync_hrtimer_func; hrtimer_start(&hrtimer_vsync_dpi, ktime, HRTIMER_MODE_REL); #endif }
enum hrtimer_restart dpi_vsync_hrtimer_func(struct hrtimer *timer) { long long ret; if(atomic_read(&wait_dpi_vsync)) { atomic_set(&wait_dpi_vsync, 0); atomic_set(&dpi_vsync, 1); wake_up_interruptible(&_vsync_wait_queue_dpi); // printk("hrtimer Vsync, and wake up\n"); } ret = hrtimer_forward_now(timer, ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi))); // printk("hrtimer callback\n"); return HRTIMER_RESTART; }
void DPI_PauseVSYNC(bool enable) { #ifndef BUILD_UBOOT if(enable){ if(0 <= hrtimer_cancel(&hrtimer_vsync_dpi)){ printk("[DPI_PauseVSYNC], cancel vsync timer]\n"); if(atomic_read(&wait_dpi_vsync)){ atomic_set(&wait_dpi_vsync, 0); atomic_set(&dpi_vsync, 1); wake_up_interruptible(&_vsync_wait_queue_dpi); printk("[DPI_PauseVSYNC], wait vsync so need wakeup event to avoid hang\n"); } } } else{ printk("[DPI_PauseVSYNC], restart vsync timer]\n"); hrtimer_start(&hrtimer_vsync_dpi, ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi)), HRTIMER_MODE_REL); } #endif }
static irqreturn_t _DPI_InterruptHandler(int irq, void *dev_id) { static int counter = 0; DPI_REG_INTERRUPT status = DPI_REG->INT_STATUS; // if (status.FIFO_EMPTY) ++ counter; if(status.VSYNC) { if(dpiIntCallback) dpiIntCallback(DISP_DPI_VSYNC_INT); #ifndef BUILD_UBOOT if(atomic_read(&wait_dpi_vsync)){ if(-1 != hrtimer_try_to_cancel(&hrtimer_vsync_dpi)){ atomic_set(&wait_dpi_vsync, 0); atomic_set(&dpi_vsync, 1); wake_up_interruptible(&_vsync_wait_queue_dpi); hrtimer_start(&hrtimer_vsync_dpi, ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi)), HRTIMER_MODE_REL); } } #endif } if (status.VSYNC && counter) { DISP_LOG_PRINT(ANDROID_LOG_ERROR, "DPI", "[Error] DPI FIFO is empty, " "received %d times interrupt !!!\n", counter); counter = 0; } if (status.FIFO_EMPTY) { DSI_handle_esd_recovery(); } _DPI_LogRefreshRate(status); OUTREG32(&DPI_REG->INT_STATUS, 0); return IRQ_HANDLED; }
static irqreturn_t _DPI_InterruptHandler(int irq, void *dev_id) { static int counter = 0; DPI_REG_INTERRUPT status = DPI_REG->INT_STATUS; // if (status.FIFO_EMPTY) ++ counter; if(status.VSYNC) { if(dpiIntCallback) dpiIntCallback(DISP_DPI_VSYNC_INT); #ifndef BUILD_UBOOT if(atomic_read(&wait_dpi_vsync)){ if(-1 != hrtimer_try_to_cancel(&hrtimer_vsync_dpi)){ atomic_set(&wait_dpi_vsync, 0); atomic_set(&dpi_vsync, 1); wake_up_interruptible(&_vsync_wait_queue_dpi); hrtimer_start(&hrtimer_vsync_dpi, ktime_set(0, VSYNC_US_TO_NS(vsync_timer_dpi)), HRTIMER_MODE_REL); } } #endif } if (status.VSYNC && counter) { DISP_LOG_PRINT(ANDROID_LOG_ERROR, "DPI", "[Error] DPI FIFO is empty, " "received %d times interrupt !!!\n", counter); counter = 0; } if (status.FIFO_EMPTY) { int need_reset = 0; unsigned long long temp = sched_clock(); unsigned int debug_while_loop_cnt = 0; volatile unsigned int dsi_state = INREG32(DSI_BASE+0x154); if((dsi_state & 0x1ff) == 0x80) { auto_sync_reset_count++; if(auto_sync_reset_count == 10) { auto_sync_reset_count = 0; need_reset = 2; } } else { auto_sync_reset_count = 0; } //printk("gmce,0x%08x, %d\n",(INREG32(DSI_BASE+0x154))&0x1ff, (unsigned int)(temp - last_fifo_empty_stamp)); if(_fifo_empty_monitor_insert((unsigned int)(temp - last_fifo_empty_stamp))) { need_reset = 1; } last_fifo_empty_stamp = temp; if(need_reset) { unsigned int mode, suspend; mode = DSI_GetMode(); suspend = DISP_GetSuspendMode(); if ((mode != CMD_MODE) && !suspend) { DPI_DisableClk(); #if 0 while(1) { debug_while_loop_cnt++; dsi_state = INREG32(DSI_BASE+0x154); if((dsi_state &0x1ff) == 0x100) break; if(debug_while_loop_cnt > 0x1000000) { printk("FATAL Error!! dsi in vact when dpi fifo empty, and can't into vfp until 0x100000 loops!!\n"); } } #endif DSI_clk_HS_mode(0); DSI_SetMode(CMD_MODE); DSI_Reset(); DSI_SetMode(SYNC_PULSE_VDO_MODE); DSI_clk_HS_mode(1); DPI_EnableClk(); DSI_EnableClk(); } printk("[DSI/DPI]reset[%d] mode[%d], suspend[%d]\n", need_reset, mode, suspend); need_reset = 0; } } _DPI_LogRefreshRate(status); OUTREG32(&DPI_REG->INT_STATUS, 0); return IRQ_HANDLED; }