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

📄 ir_drv.c

📁 mp3 player program please read carefully.
💻 C
📖 第 1 页 / 共 3 页
字号:
/*****************************************************************************
** FILE
** ir_drv.c
**
** DESCRIPTION
** process IR keys and send to ir_cmd_xxx for actual process
**
**   Creater  : Terry
**   Maintain : Terry
**   ------------------------------------
**   Revision History
**   ------------------------------------
**   2003.02.12  seperate driver/parser from ir.c
**   2003.02.25  use define function
**   2004.07.23  maintain program
**
****************************************************************************/

#include "config.h"
#include "regmap.h"
#include "global.h"

#include "cfont.h"
#include "func.h"
#include "sio.h"
#include "ircmd.h"
#include "ircode.h"
#include "user_init.h" 
#include "iop.h"
#include "atapi_if.h"
#include "macro.h"
#include "osd.h"
#include "bitop.h"
#include "timer.h"
#ifdef TAS3001_AMP
#include "ti3001.h"
#endif

#ifdef TAS5026_AMP
#include "ti5026.h"
#endif
#ifdef DVB_SETUP
#include "../driver/message.h"
#endif

//=========================================================================================
// debug option define 
//=========================================================================================
#define WATCH_CUSTID    0
//#define DEBUG_IR_CODE //if you want to see which defined code for key, unmark it
#ifndef DVDRELEASE
#define IR_DBG	1
#define IRCMD_DBG
#endif
#ifndef IRCMD_DBG
#undef printf
#undef print_block
#define printf(f, a...) do {} while (0)
#define print_block(x,y) do {} while (0)
#endif


//=========================================================================================
// var. decalre 
//=========================================================================================
extern const BYTE ir_mapcode[256];  
extern UINT32 save_srn_start_t;
extern void ircmd_pre_paser(BYTE rx);
int rep_ir_times=0;

#ifdef SUPPORT_8202_DVB
#include "..\dvb_h\dvb_func.h"
#endif

#ifdef SUPPORT_DVD_NATIVE_GAME
extern UINT8 Dvb_ircmd_pre_parser(BYTE);
#endif

#ifdef QISHENG_DVD	// alan, 2003/9/7 07:08PM
static BYTE pressed=IRC_NULL;
static UINT16 irc_value;
static BYTE not_rdy_times=0;
#endif    


#ifdef TEST_VFD_PANNEL_AND_KEY//lijd 2005-5-16 16:19
BYTE  TestIrData=0;	 
extern  BYTE   Test_Stop_flag;
#endif
//=========================================================================================
// define function
//=========================================================================================
#ifdef IR_PHILIPS       
#define IOP_IR_DATA() ((regs0->iop_data[6]>>6)&0x5f)
#define TRANS_IR_CODE(rx) (rx&0x003f)
#elif defined(IR_PHILIPS_EASTECH)
		#define IOP_IR_DATA()((regs0->iop_data[6]&0xff00)>>8)
       #define TRANS_IR_CODE(rx)(rx & 0x00ff)
#elif  defined(IR_THOMSON)		//wurh modify for 8bit thomson ir keycode 2006-3-1 04:43下午
#define IOP_IR_DATA() ((BYTE)(regs0->iop_data[6]))
#define TRANS_IR_CODE(rx) (BYTE)(rx&0x00ff)
#elif  defined(IR_THOMSON_6BIT)       //wurh add for 6bit thomson ir keycode 2006-3-1 04:45下午
#define IOP_IR_DATA() ((BYTE)(regs0->iop_data[6]))
#define TRANS_IR_CODE(rx) (BYTE)(rx&0x003f)
#elif  defined(IR_M50560)
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) reverse_fun(rx)
#elif  defined(IR_AS1213)
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) reverse_fun(rx)
#elif  defined(IR_M3004)||defined(IR_ORITRON)||defined (IR_THOMSON_ANGUS)//LIJD 2005-6-20 14:08
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) reverse_fun(rx)
#elif  defined(IR_KONKA)//LIJD 2005-2-4 13:24
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) (BYTE)(rx&0x00ff)
#elif  defined(IR_TDP101)//lijd 2005-3-25 10:16
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) (BYTE)(rx&0x00ff)
#elif  defined(IR_HT220MCU)//2005-4-14 14:57 zhoulin
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) (BYTE)(rx&0x00ff)
#else
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) reverse_fun(rx)
#endif

#if defined(IR30)||defined(MINTON_LCD_PANEL_6322_KEY) 			//nono 2003-9-26 11:33 for YILI.
#define CHK_CUST_ID(unCustId) ((unCustId!=IR_ADDR_PATT)&&(unCustId!=IR_ADDR_PATT2))
#elif defined(DESAY_PHILIPS_IR)//CLEAD 2004-3-23 
#define CHK_CUST_ID(unCustId) ((unCustId!=IR_ADDR_PATT)&&(unCustId!=IR_ADDR_PATT2)&&(unCustId!=IR_ADDR_PATT3)&&(unCustId!=IR_ADDR_PATT4))
#elif defined(IR_GBM_PHILIPS)//yth 2004-3-23 
//#define CHK_CUST_ID(unCustId) ((unCustId!=IR_ADDR_PATT)&&(unCustId!=IR_ADDR_PATT2)&&(unCustId!=IR_ADDR_PATT3)&&(unCustId!=IR_ADDR_PATT4))
#define CHK_CUST_ID(unCustId) ((unCustId!=IR_ADDR_PATT)&&(unCustId!=IR_ADDR_PATT3))//gerry modified it,when TV mode,these keys should not be functional,2004-7-29 22:31
#elif defined(OP_DVD5121_PANEL) //qinhua add for 5121
#define CHK_CUST_ID(unCustId) ((unCustId!=IR_ADDR_PATT)&&(unCustId!=IR_ADDR_PATT_T))
#elif  defined(IR_PHILIPS_EASTECH)		//wangmin add for philhps rc6
#define CHK_CUST_ID(unCustId) ((unCustId!=IR_ADDR_PATT)&&(unCustId!=IR_ADDR_PATT2)&&(unCustId!=IR_ADDR_PATT3)&&(unCustId!=IR_ADDR_PATT4)&&(unCustId!=IR_ADDR_PATT5))
#else

	#ifdef IR_TOOL
	#define CHK_CUST_ID(unCustId) (unCustId!=IRAddr)
	#else
#define CHK_CUST_ID(unCustId) (unCustId!=IR_ADDR_PATT)

#endif 
#endif 

#ifdef IR_ADDR_PATT_ERR_SHOW_INVALID//nono 2-9-23 13:08
#define show_ir_custid_err() invalid_key()
/*//sunzhh marked for when "CHK_CUST_ID(unCustId)" judged error once in a while with the correct ir 2007/04/06
static inline void show_ir_custid_err(UINT16 unCustId)   // Added by LuoLiuyi at 2006-8-17
{
    if(!safe_on)	//Jack 07/02/01 added
    {
       	osd_init__();
		psprintf(linebuf,"IR ADDR UNMATCH R:%04x VS S:%04x", unCustId,IR_ADDR_PATT);
		strcpy(RegionValStr[REGION1], linebuf);
		PrintOsdMsg(STR_OS_SPACE, REGION1, 4, 1);	
	}
*/
#else
#define show_ir_custid_err();                       // Removed by LuoLiuyi at 2006-8-17
#endif

#if defined(IR30) //philip ir 			//2-10-15 11:12
void adj_ir_rxcode(UINT8 chk,UINT16 *rx,UINT16 offset)
{
    if(chk)
	{
		switch(*rx)
		{
			case 0x30:
			case 0x32:
			case 0x33:
			case 0x34:
				*rx+=offset;
			break;
			default:
				break;
		}
	}
}
#elif defined(MINTON_LCD_PANEL_6322_KEY) ////nono 2003-9-26 11:33 for YILI.
void adj_ir_rxcode(UINT8 chk,UINT16 *rx,UINT16 offset)
{
    if(chk)
	{
		switch(*rx)
		{
			case 0x41:
			case 0x57:
			case 0x00:
			case 0x10:
			case 0x4F:
			case 0x4B:
				*rx=*rx+offset+0x6C;
			break;
			default:
				break;
		}
	}
}
#else
#define adj_ir_rxcode(chk,rx,offset);
#endif
//TCL STANDBY

static inline void ir_tcl_standby(void)
{
#ifdef TCL_STANDBY    
        static BYTE powerkeystate=0;
        BYTE flag;
        flag = (regs0->gpio_in[2/16] >> (2%16)) & 0x01;
        if((!flag ) && powerkeystate)
        {
                call_ir_func(IRC_POWER);
                regs0->sft_cfg1 &= ~(0x1 << 3);//gpio 3 enable
                regs0->gpio_master[ 3/16 ] &= ~(0x1 << (3%16));//gpio 3 for iop
                regs0->gpio_master[ 2/16 ] &= ~(0x1 << (2%16));//gpio 2 for iop
        }
        powerkeystate = flag;
#endif        
}



//=========================================================================================
// debug function
//=========================================================================================
/*
* display ir id
*/
#ifndef IR_TOOL
#ifdef  DEBUG_IR_CODE
static inline void watch_ir_id(UINT16 rx)
{
    psprintf(linebuf, "IR:%02x, F:%02x", rx, ir_mapcode[rx]);
    strcpy(RegionValStr[REGION1], linebuf);
    PrintOsdMsg(STR_OS_SPACE, REGION1, 1, 1);
}
#else
#define  watch_ir_id(rx);   
#endif
#else
	static inline void watch_ir_id(UINT16 rx)
	{
	    psprintf(linebuf, "IR:%02x, F:%02x", rx, ir_mapcode[rx]);
	    strcpy(RegionValStr[REGION2], linebuf);
	    PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
	    //printf("IR:%02x,F:%02x\n",rx, ir_mapcode[rx]);
	    printf("%02x\n",rx);
	}
#endif
/*
* display ir's customer id
*/
#ifndef IR_TOOL
#if WATCH_CUSTID            
static inline void watch_ir_custm_id(UINT16 unCustId)
{
    psprintf(linebuf,"ID : %04x", unCustId);           
    strcpy(RegionValStr[REGION2], linebuf);
	PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
}
#else
#define watch_ir_custm_id(x);  
#endif
#else
	static inline void watch_ir_custm_id(UINT16 unCustId)
	{
	    	psprintf(linebuf,"ID : %04x", unCustId);           
	    	strcpy(RegionValStr[REGION2], linebuf);
		PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
		printf("%04x\r\n",unCustId);
			if(watch_ir_id_value)
			IRAddr=unCustId;
	}
#endif
/*
* monitor can input ir function
*/
#ifndef DVDRELEASE
UINT32 monir;
static inline void mon_ir(void)
{	  
    if (monir){
        call_ir_func(monir & 0xff);
        monir=0;
    }
}
#else
#define mon_ir();
#endif


#ifdef MALATA_KEY
#include "fsNAV.h"
BYTE malata_key_check(BYTE rx);
BYTE malata_key_check(BYTE rx)
{
//20051207  tiany test  
//if(rx == IRC_1) rx =  IRC_EJECT;
//if(rx == IRC_2) rx =  IRC_UP_NEXT ;
//if(rx == IRC_0) rx =  IRC_DOWM_PREV ;
//if(rx == IRC_5) rx =  IRC_LEFT_FR ;
//if(rx == IRC_7) rx =  IRC_RIGHT_FF ;
#ifdef ONE_TWO_THREE_FOUR_CHANGE//tianye 200607
if(rx == IRC_1) {xxx = 0; yyy = 0;}
if(rx == IRC_2) {xxx = 0; yyy = 1;}
if(rx == IRC_3) {xxx = 1; yyy = 0;}
if(rx == IRC_4) {xxx = 1; yyy = 1;}
#endif//end=> #ifdef ONE_TWO_THREE_FOUR_CHANGE

//--------------------------
 BYTE  flag_direction_key = 0;
 if((rx == IRC_AUD_LANGUAGE)&&(cd_type_loaded!=CDDVD))
 {

       if((rx == IRC_AUD_LANGUAGE)&&(cd_type_loaded == CDROM)&& (pFsJpeg->gifsFuncBtn == FS_FUNC_OTHER))
       {
            rx = IRC_AUD_LANGUAGE  ;
	 }
	 else
	 {
   		rx =  IRC_CHANNEL;
 	 }
 }


 if((full_scrn&SETUP)||(full_scrn&CUSTM)||(Is_Dvb_State())||(full_scrn&GOTO)
   ||/*(is_menu()&&(cd_type_loaded==CDDVD))||*/(vpp_zoom>=ZOOMIN_BASE && vpp_zoom<=ZOOMIN_MAX)
   ||((cd_type_loaded==CDROM)&&(pFsJpeg->gifsState != FS_STATE_OTHER))
   ||((HL_exist)&&(cd_type_loaded==CDDVD))//20060206 tiany add fix err
   )//20060525 tiany mark  /*(is_menu()&&(cd_type_loaded==CDDVD))||*/ for key err
 {
   flag_direction_key = 1;
 }
 switch(rx)
 {
   case(IRC_UP_NEXT): 
   {
      if(flag_direction_key)
	  {
        	rx = IRC_UP;
	  }
	  else
	  {
	    	rx = IRC_NEXT;
	  }
      break;
   }		 
   case(IRC_DOWM_PREV):
   {
	  if(flag_direction_key)
	  {
        	rx = IRC_DOWN;
	  }
	  else
	  {
	    	rx = IRC_PREV;
	  }
      break;
   }	   
   case(IRC_LEFT_FR): 
   {
	  if(flag_direction_key)
	  {
        	rx = IRC_LEFT;
	  }
	  else
	  {
	    	rx = IRC_BACKWARD;
	  }
      break;
   }
   case(IRC_RIGHT_FF): 
   {
	  if(flag_direction_key)
	  {
        	rx = IRC_RIGHT;
	  }
	  else
	  {
	    	rx = IRC_FORWARD;
	  }
      break;
   }
   default:
			break;
    };
   return rx; 
} 
#endif//end=>#ifdef MALATA_KEY


//=========================================================================================
// ir driver function
//=========================================================================================
/*
* encode ir id
*/
int reverse_fun(int rx)
{
    rx=rx&IRC_MASK;

    return revn(rx,8);
}
/*
** FUNCTION
** reset_ir
**
** DESCRIPTION
** reset IR interface (and queue) according to irconfig.h
*/
void    reset_ir(void)
{
#if defined(QISHENG_DVD)||defined(SUPPORT_IR_GAME)	//alan, 2003/9/7 08:05PM
	regs0->iop_data[IR_PORT]|=IrRepeatRate(6);
#elif defined(HOLD_VOL_KEY_FAST_REPEAT)
    regs0->iop_data[IR_PORT]|=IrRepeatRate(1);
#elif defined(IR_GBM_PHILIPS)||defined(IR_PHILIPS)//gerry modified philips ir timing for lijd's suggestion,2004-8-4 16:35
	regs0->iop_data[IR_PORT]|=IrRepeatRate(2);
#elif ( defined(IR_M3004)||defined(IR_ORITRON) )&& !defined (OP_DVD5121_PANEL)
    regs0->iop_data[IR_PORT]|=IrRepeatRate(8);	
#elif  defined(OP_DVD5121_PANEL) //qinhua ,add for5121
   regs0->iop_data[IR_PORT]|=IrRepeatRate(1);		
#elif  defined(IR_THOMSON)//wurh add 2006-3-21 05:31下午
    regs0->iop_data[IR_PORT]|=IrRepeatRate(8);
#elif  defined(IR_KONKA)//nono 20050224
    regs0->iop_data[IR_PORT]|=IrRepeatRate(8);
#elif  defined(IR_TDP101)//lijd 2005-3-25 10:17
    regs0->iop_data[IR_PORT]|=IrRepeatRate(6);      
#elif  defined(IR_THOMSON_ANGUS)

⌨️ 快捷键说明

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