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

📄 ir_drv.~c

📁 Sunplus 8202S source code.
💻 ~C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
** 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

//=========================================================================================
// 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 UINT8 f_skip_polling_ir;
extern UINT32 save_srn_start_t;
extern void ircmd_pre_paser(BYTE rx);
int rep_ir_times=0;

#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    


//=========================================================================================
// 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_THOMSON)
#define IOP_IR_DATA() ((BYTE)(regs0->iop_data[6]))
#define TRANS_IR_CODE(rx) (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)//LIJD 2004-12-27 14:25
#define IOP_IR_DATA() (regs0->iop_data[6])
#define TRANS_IR_CODE(rx) reverse_fun(rx)
#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
#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()
#else
#define show_ir_custid_err();
#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
*/
#if (!defined(DVDRELEASE)||defined(SPHE1000))
UINT32 monir;
UINT32 from4189;

#ifdef DVB_SETUP
UINT32 monir_setup;
//UINT32 monir_get_property;

extern void SP_DvbDvdSetup(UINT32 cmd);
//extern void SP_SetGet_Property(UINT32 cmd);
#endif

static inline void mon_ir(void)
{	  
    if (monir){
        call_ir_func(monir & 0xff);
        monir=0;
    }
	  
#ifdef DVB_SETUP
    if (monir_setup){
        SP_DvbDvdSetup(monir_setup);	//xsyan add
        monir_setup=0;
    }		
//	if(monir_get_property){
//			SP_SetGet_Property(monir_get_property);
//			monir_get_property=0;
//		}			
#endif

}
#else
#define mon_ir();
#endif




//=========================================================================================
// 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(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);
#else
    regs0->iop_data[IR_PORT]|=IrRepeatRate(4);
#endif
}

/*
* detect ir key input,using to search tuner band
*/
//#ifdef SUPPORT_TUNER       // add tuner 2-6-14 23:17
BYTE key_input(void)
{
    BYTE res;
    //need to add vfd key input
    
    if(regs0->iop_data[IR_PORT]&IR_RDY)
      res=1;
    else
      res=0;

   return res;
}
//#endif

#if defined(DESAY_PHILIPS_IR)||defined(IR_GBM_PHILIPS)
UINT16    desay_philips_ir_move(UINT16 rx)
{

	if(((regs0->iop_data[6]>>6)&0x5f) == IR_ADDR_PATT)
        {
	switch(rx)
                {
                case 0x30:
                case 0x32:
                case 0x33:
                case 0x34:
                    rx+=0x10;
                    break;
                case 0x11:
                case 0x12:
                case 0x13:
                    rx+=0x40;
                    break;
                default:
                    break;
               	}
            }
       else	if(((regs0->iop_data[6]>>6)&0x5f) == IR_ADDR_PATT2)
            {
			    switch(rx)
                {

                case 0x06:
                    rx+=0x40;
                    break;
                case 0x02c:
                case 0x02e:
                case 0x02f:
                    rx+=0x20;
                    break;
                default:
                    break;
                	}
            }
       else	if(((regs0->iop_data[6]>>6)&0x5f) == IR_ADDR_PATT3)
       {
                switch(rx)
                {
			    case 0x032:
                case 0x033:
                    rx+=0x15;
                    break;
                default:
                    break;
                	}
		}
       else	if(((regs0->iop_data[6]>>6)&0x5f) == IR_ADDR_PATT4)
            {
			    switch(rx)
                {

                case 0x2c:
                	rx+=0x30;
                    break;
                default:
                    break;
                	}
            }
	return rx;            
}
#endif //CLEAD 2004-3-23

#ifdef  IR_GBM_PHILIPS  //added by wangwei,2004-8-16 20:09
    UINT16  gbm_philips_ir_move(UINT16 rx)
    {
        desay_philips_ir_move(rx);
    }
#endif  //IR_GBM_PHILIPS

/*
* call ir post function (ir parser)
*/
#if defined(DEBUG_IR_CODE)||defined(IR_PHILIPS)
static inline BYTE Call_Ir_Fun(UINT16 rx)
{
#ifdef	 DESAY_PHILIPS_IR

	rx=desay_philips_ir_move(rx);
    rx = ir_mapcode[(BYTE) rx];    
    #ifndef IR_TOOL
    printf("\n ir(705) rx = %x \n",rx);
    call_ir_func(rx);
    #endif
#elif defined(IR_GBM_PHILIPS)
	rx=gbm_philips_ir_move(rx);
    #ifdef DEBUG_IR_CODE//gerry add it for philips ir,2004-8-4 16:41
	watch_ir_id(rx);
	return; 
    #endif
    rx = ir_mapcode[(BYTE) rx];    
    #ifndef IR_TOOL
    printf("\n ir(705) rx = %x \n",rx);
    call_ir_func(rx);
    #endif
#else
    #ifdef DEBUG_IR_CODE//gerry add it for philips ir,2004-8-4 16:41
	watch_ir_id(rx);
	return; 
    #endif
    rx = ir_mapcode[(BYTE) rx];    
    #ifndef IR_TOOL
    printf("\n ir(705) rx = %x \n",rx);
    call_ir_func(rx);
    #endif
#endif
	return rx;
}
#else
static inline BYTE Call_Ir_Fun(UINT16 rx)
{
	if(rx >= MAX_IR_MAP) // Out of MAP range?
        return 0;

    rx = ir_mapcode[(BYTE) rx];    
    #ifndef IR_TOOL
    printf("\n ir(705) rx = %x \n",rx);

⌨️ 快捷键说明

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