⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_if.c

📁 Lcd interface between upper application layer and driver (MTK)
💻 C
📖 第 1 页 / 共 5 页
字号:
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
#include "kal_release.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h"       /* Task message communiction */
#include "syscomp_config.h"
#include "task_config.h"
#include "stacklib.h"
#include "stack_timer.h"      /*stack_timer_struct....definitions*/
#include "drv_comm.h"
#include "reg_base.h"
#include "gpt_sw.h"
#include "intrCtrl.h"
#include "gpio_sw.h"
#include "lcd_sw_inc.h"
#include "lcd_hw.h"
#include "lcd_sw.h"
#include "lcd_if.h"
#include "visual_comm.h"
#include "drv_hisr.h"
#if (defined(CAMERA_MODULE))
#include "ext_camera.h"
#endif /* CAMERA_MODULE */
#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	#include "visual_comm.h"
	#include "img_comm.h"
	#include "imgproc.h"
	#include "imgdma.h"
	#if (defined(ISP_SUPPORT))
		#include "isp_if.h"
	#endif
	#if (defined(MT6228)||defined(MT6229))
		#include "tv_out.h"
		#include "2d_engine.h"
	#endif
#endif

LCD_Funcs  *MainLCD;
LCD_Funcs  *SubLCD;

kal_uint8 lcd_dc_color_mode;

extern void LCD_FunConfig(void);
extern kal_bool lcd_assert_fail;
extern kal_bool INT_QueryExceptionStatus(void);

#ifndef __MAUI_BASIC__
extern kal_uint8 L1SM_GetHandle(void);
extern void L1SM_SleepEnable(kal_uint8 handle);
extern void L1SM_SleepDisable(kal_uint8 handle);
kal_uint8	lcd_sleep_mode_handler=0xFF;
#endif	/* __MAUI_BASIC__ */

#if (defined(MT6217)||defined(MT6218B)||defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	kal_uint8 jpeg_video_play_lcd_id;
	volatile kal_uint8 lcd_transfer_complete=KAL_FALSE;
	kal_eventgrpid lcd_event_id=NULL;

	volatile LCD_OPERATION_STATE_ENUM main_lcd_operation_state=LCD_IDLE_STATE;
	lcd_frame_update_struct main_lcd_fb_update_para;
	lcd_layer_struct lcd_layer_data[LCD_TOTAL_LAYER];
	kal_uint16 lcd_cmd_period_count;

	kal_uint8 lcd_output_mode=KAL_TRUE;
	kal_uint8 main_lcd_hw_trigger_output_mode=KAL_TRUE;
	kal_uint8 sub_lcd_hw_trigger_output_mode=KAL_TRUE;
	kal_bool wait_lcd_update_flag=KAL_FALSE;
	#if (!defined(MT6218B))
	kal_uint8 current_lcd_rotate_value=LCD_LAYER_ROTATE_NORMAL;
	#endif
	void (*lcd_block_cb) (void);
	#ifdef DUAL_LCD
	   extern LCD_Funcs  *SubLCD;
	   volatile LCD_OPERATION_STATE_ENUM sub_lcd_operation_state=LCD_IDLE_STATE;
	   lcd_frame_update_struct sub_lcd_fb_update_para;
	#endif
#elif (defined(MT6205B)||defined(MT6208))
	volatile LCD_OPERATION_STATE_ENUM main_lcd_operation_state=LCD_IDLE_STATE;
	lcd_frame_update_struct main_lcd_fb_update_para;
	#ifdef DUAL_LCD
	   extern LCD_Funcs  *SubLCD;
	   volatile LCD_OPERATION_STATE_ENUM sub_lcd_operation_state=LCD_IDLE_STATE;
	   lcd_frame_update_struct sub_lcd_fb_update_para;
	#endif
#endif

kal_uint16 old_lcd_cmd_period_count;
kal_bool hpi_power_on=KAL_FALSE;
kal_uint16 hpi_cmd_period_count;

kal_uint32 lcd_frame_buffer_address;
volatile kal_uint8 current_update_lcd=MAIN_LCD;

#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
volatile kal_bool lcd_cmd_latch_complete=KAL_FALSE;
kal_uint32 lcd_hw_trigger_roi_offset,lcd_hw_trigger_roi_size,lcd_hw_trigger_roi_ctrl;
kal_uint32 lcd_hw_trigger_layer;
volatile kal_uint8 lcd_hw_trigger_flag=KAL_FALSE;
	kal_uint32 lcd_hw_trigger_para[LCD_CMD_QUEUE_LENGTH];
#endif
#if (defined(MT6228)||defined(MT6229))
kal_uint8 lcd_sleeping_state=KAL_FALSE;
kal_uint32 lcd_hw_trigger_reg=0;
kal_uint32 lcd_roi_size_reg=0;
kal_uint32 lcd_ctrl_reg=0;
kal_uint32 lcd_cmq_para[LCD_CMD_QUEUE_LENGTH];
kal_uint8 tv_output_buffer_count=0xFF;
volatile kal_uint8 tv_full_screen=0;
kal_uint32 tv_output_buffer_base_address1;
kal_uint32 tv_output_buffer_base_address2;
kal_uint32 tv_output_buffer_offset_address1;
kal_uint32 tv_output_buffer_offset_address2;
kal_uint8 tv_output_buffer_rotate=0;

extern g2d_buffer_struct g2d_tv_output_dest_buff;
extern g2d_buffer_struct g2d_tv_output_src_buff;
extern g2d_bitblt_struct g2d_tv_output_bitblt;
extern kal_uint8 current_g2d_tv_output_bitblt_buffer;
extern void preview_tv_buffer_rotate_cb(void);
#endif
kal_uint8 lcd_rotate_value=0;
kal_uint32 current_lcd_hw_update_layer=0;
kal_bool lcd_window_swap_flag=KAL_FALSE;
kal_bool lcd_update_internal_ram=KAL_FALSE;

kal_uint32 lcd_roi_ctrl_shadow,lcd_roi_size_shadow,lcd_roi_offset_shadow;
kal_uint32 lcd_mem_out_address_shadow,lcd_mem_out_address_shadow1, lcd_mem_out_ctrl_shadow;
kal_uint8 lcd_hard_trigger_flag=0;

extern void init_lcd_interface(void);

#ifdef __LCD_ESD_RECOVERY__ 
extern kal_uint8 ext_camera_state; //for checking the ext_cam status

kal_bool lcd_ESD_check(void)
{           
   kal_bool ESD_check_result;
   
#if (defined(CAMERA_MODULE))      
/* if external camera is running do not disturb it*/
   if (ext_camera_state!=EXT_CAMERA_POWER_OFF_STATE)
   {
      kal_prompt_trace(MOD_ENG,"LCD_ESD ext_cam state miss %d",ext_camera_state);
      return KAL_TRUE;         
   }
#endif   
   
#ifndef DUAL_LCD
   if (main_lcd_operation_state==LCD_STANDBY_STATE)
   {
       lcd_power_up();  
       ESD_check_result = MainLCD->esd_check();
       lcd_power_down(); 
       if (ESD_check_result == KAL_FALSE)
       {
         main_lcd_operation_state=LCD_IDLE_STATE;//force to do the cool reset
       }
       return ESD_check_result;
   }else
   {
   /*LCD is not running in the STANDBY_STATE, avoid to disturb the LCD work*/
      return KAL_TRUE;
   }
   
          
#else
   if ((main_lcd_operation_state==LCD_STANDBY_STATE)&&
		  (sub_lcd_operation_state==LCD_STANDBY_STATE))
	{
		
		kal_prompt_trace(MOD_ENG,"LCD_ESD LCD state hit, both main/sub in standby state"); 
		   
		lcd_power_up();  
		
		ESD_check_result = MainLCD->esd_check();
		if (ESD_check_result == KAL_FALSE)
		{
			lcd_power_down();
		   main_lcd_operation_state=LCD_IDLE_STATE; //force to do the cool reset
		   sub_lcd_operation_state=LCD_IDLE_STATE; //force to do the cool reset
		   return KAL_FALSE;
		}
		  
		ESD_check_result = SubLCD->esd_check();
		if (ESD_check_result == KAL_FALSE)
		{
	      lcd_power_down();
	      main_lcd_operation_state=LCD_IDLE_STATE;//force to do the cool reset
	      sub_lcd_operation_state=LCD_IDLE_STATE;//force to do the cool reset
	      return KAL_FALSE;
		}      
		
		
		lcd_power_down();
		return KAL_TRUE;	
	}
	else
	{
	   /*LCD is not running in the STANDBY_STATE, avoid to disturb the LCD work*/
      kal_prompt_trace(MOD_ENG,"LCD_ESD LCD state miss main %d sub %d",main_lcd_operation_state,sub_lcd_operation_state);
      return KAL_TRUE;
   }
#endif	
}
#endif

kal_bool get_lcd_status(void)
{
#if (defined(MT6217)||defined(MT6218B)||defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	return (LCD_IS_RUNNING);
#endif
}

void lcd_power_up(void)
{
	kal_uint32 save_irq_mask;

   save_irq_mask=SaveAndSetIRQMask();
   DRV_Reg(DRVPDN_CON1) &= (~DRVPDN_CON1_LCD);  /* Power on LCD */
   RestoreIRQMask(save_irq_mask);
#ifndef __MAUI_BASIC__
   L1SM_SleepDisable(lcd_sleep_mode_handler);
#endif	/* __MAUI_BASIC__ */
}

void lcd_power_down(void)
{
	kal_uint32 save_irq_mask;
	volatile kal_uint8 i;	

#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	#ifndef DUAL_LCD
	if ((main_lcd_operation_state!=LCD_HW_UPDATE_STATE)&&	(main_lcd_operation_state!=LCD_DC_UPDATE_STATE))
	{
		while (LCD_IS_RUNNING) {};
		for (i=0;i<10;i++);
	}
	#else
	if ((main_lcd_operation_state!=LCD_HW_UPDATE_STATE)&&(main_lcd_operation_state!=LCD_DC_UPDATE_STATE)&&
		 (sub_lcd_operation_state!=LCD_HW_UPDATE_STATE)&&(sub_lcd_operation_state!=LCD_DC_UPDATE_STATE))
	{
		while (LCD_IS_RUNNING) {};
		for (i=0;i<10;i++);
	}
	#endif
#endif	
#if (defined(MT6217)||defined(MT6218B)||defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	if (wait_lcd_update_flag==KAL_FALSE)
	{
		STOP_LCD_TRANSFER;
	}
#endif
#ifndef DUAL_LCD
	if (((main_lcd_operation_state==LCD_STANDBY_STATE)||
		 (main_lcd_operation_state==LCD_SLEEP_STATE))&&
		 (hpi_power_on==KAL_FALSE))
	{
   	save_irq_mask=SaveAndSetIRQMask();
		DRV_Reg(DRVPDN_CON1) |= (DRVPDN_CON1_LCD);  /* Power off LCD */
   	RestoreIRQMask(save_irq_mask);
#ifndef __MAUI_BASIC__
		L1SM_SleepEnable(lcd_sleep_mode_handler);
#endif /* __MAUI_BASIC__ */
	}
#else
	if ((((main_lcd_operation_state==LCD_STANDBY_STATE)||
		  (main_lcd_operation_state==LCD_SLEEP_STATE))&&
		  ((sub_lcd_operation_state==LCD_STANDBY_STATE)||
		   (sub_lcd_operation_state==LCD_SLEEP_STATE)))&&
		 (hpi_power_on==KAL_FALSE))
	{
   	save_irq_mask=SaveAndSetIRQMask();
		DRV_Reg(DRVPDN_CON1) |= (DRVPDN_CON1_LCD);  /* Power off LCD */
   	RestoreIRQMask(save_irq_mask);
#ifndef __MAUI_BASIC__
		L1SM_SleepEnable(lcd_sleep_mode_handler);
#endif /* __MAUI_BASIC__ */
	}
#endif
}	/* lcd_power_down() */

void hpi_power_ctrl(kal_uint8 on)
{
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))	
	if (on==KAL_TRUE)
	{
		hpi_power_on=KAL_TRUE;
		lcd_power_up();
		old_lcd_cmd_period_count=lcd_cmd_period_count;
		if (hpi_cmd_period_count>old_lcd_cmd_period_count)
		{
			SET_LCD_ROI_CTRL_CMD_LATENCY(hpi_cmd_period_count);
		}
	}
	else if (on==KAL_FALSE)
	{
		hpi_power_on=KAL_FALSE;
		if (hpi_cmd_period_count > old_lcd_cmd_period_count)
		{
			SET_LCD_ROI_CTRL_CMD_LATENCY(old_lcd_cmd_period_count);
		}
		lcd_power_down();
	}
#endif	
}	/* hpi_power_ctrl() */

void set_hpi_low_period_count(kal_uint8 low_period)
{
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	hpi_cmd_period_count=low_period;
#endif	
}	/* set_hpi_low_period_count() */

void swap_lcd_layer_window(kal_uint32 swap_layer)
{
#if (defined(MT6217)||defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
	kal_uint16 width,height;

	lcd_power_up();
	switch (swap_layer)
	{
		case LCD_LAYER0_ENABLE:
			width=GET_LCD_LAYER0_WINDOW_WIDTH;
			height=GET_LCD_LAYER0_WINDOW_HEIGHT;
			SET_LCD_LAYER0_WINDOW_SIZE(height,width);
		break;
		case LCD_LAYER1_ENABLE:
			width=GET_LCD_LAYER1_WINDOW_WIDTH;
			height=GET_LCD_LAYER1_WINDOW_HEIGHT;
			SET_LCD_LAYER1_WINDOW_SIZE(height,width);
		break;
		case LCD_LAYER2_ENABLE:
			width=GET_LCD_LAYER2_WINDOW_WIDTH;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -