예제 #1
0
static int hdmi_drv_init(void)
{
    halReturn_t     halStatus;
    SiiOsStatus_t osalStatus;
    printk("Starting %s\n", MHL_PART_NAME);

    if(!SiiCraInitialize())
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of CRA layer failed!\n");
        return -EIO;
    }
    osalStatus = SiiOsInit(0);
    if (osalStatus != SII_OS_STATUS_SUCCESS)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of OSAL failed, error code: %d\n",osalStatus);
        return -EIO;
    }
    halStatus = HalInit();
    if (halStatus != HAL_RET_SUCCESS)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of HAL failed, error code: %d\n",halStatus);
        SiiOsTerm();
        return -EIO;
    }

//#if MTK_project
    //xuecheng
    //I2c_Init();
//#endif

    halStatus = HalOpenI2cDevice(MHL_PART_NAME, MHL_DRIVER_NAME);
    if (halStatus != HAL_RET_SUCCESS)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Opening of I2c device %s failed, error code: %d\n",
                MHL_PART_NAME, halStatus);
        HalTerm();
        SiiOsTerm();
        return -EIO;
    }


    //msleep(200);
#ifdef SiI8338DRIVER_INTERRUPT_MODE
    halStatus = HalInstallIrqHandler(SiiMhlTxDeviceIsr);
    if (halStatus != HAL_RET_SUCCESS)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of HAL interrupt support failed, error code: %d\n",
                halStatus);
        HalCloseI2cDevice();
        HalTerm();
        SiiOsTerm();
        return -EIO;
    }

#else
    StartEventThread();     /* begin monitoring for events if using polling mode*/
#endif

    mhl_init_rmt_input_dev();

    return 0;
}
예제 #2
0
/*
 * i2c client ftn.
 */
static int __devinit mhl_Sii8334_probe(struct i2c_client *client,
			const struct i2c_device_id *dev_id)
{
    int ret = 0;
    if(match_id(&mhl_Sii8334_idtable[0], client)){
        sii8334_PAGE_TPI = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully\n", dev_id->name);
    }
    /*
    else if(match_id(&mhl_Sii8334_idtable[1], client)){
        sii8334_PAGE_TX_L0 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully \n", dev_id->name);
    }
    */
    else if(match_id(&mhl_Sii8334_idtable[2], client)){
        sii8334_PAGE_TX_L1 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully \n", dev_id->name);
    }else if(match_id(&mhl_Sii8334_idtable[3], client)){
        sii8334_PAGE_TX_2 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully\n", dev_id->name);
    }else if(match_id(&mhl_Sii8334_idtable[4], client)){
        sii8334_PAGE_TX_3 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully\n", dev_id->name);
    }else if(match_id(&mhl_Sii8334_idtable[5], client))    {
        sii8334_PAGE_CBUS = client;
        dev_info(&client->adapter->dev, "attached %s "
            "into i2c adapter successfully\n", dev_id->name);
    }else{
        dev_info(&client->adapter->dev, "invalid i2c adapter: can not found dev_id matched\n");
        return -EIO;
    }
    
    
    if(sii8334_PAGE_TPI != NULL 
      //&&sii8334_PAGE_TX_L0 != NULL 
      &&sii8334_PAGE_TX_L1 != NULL 
      && sii8334_PAGE_TX_2 != NULL
      && sii8334_PAGE_TX_3 != NULL
      && sii8334_PAGE_CBUS != NULL){
        
        Sii8334_plat_data = sii8334_PAGE_TPI->dev.platform_data;
        #ifdef mhl_power_dbg
        ret = Sii8334_plat_data->mhl_power_on();
        if(ret){
            printk("%s:call mhl_power_on failed.\n", __func__);	
        }
	  //added by zhangyue on 2011-11-21 for config irq	
	  Sii8334_plat_data->mhl_irq_config();
	  //added by zhangyue on 2011-11-21 end
        #endif
        if(false == Sii8334_mhl_reset()){
            printk("/nCan't find the reset function in your platform file============================================\n");
            return -EIO;
        }
        
        // Announce on RS232c port.
        //
        printk("\n============================================\n");
        printk("SiI-8334 Driver Version based on 8051 driver Version 1.14 \n");
        printk("============================================\n");
        
        //
        // Initialize the registers as required. Setup firmware vars.
        //
        
	  SiiMhlTxInitialize();
        
        #ifdef SiI8334DRIVER_INTERRUPT_MODE
        #ifdef zy_dbg_err_handle
        sii8334work = kmalloc(sizeof(*sii8334work), GFP_KERNEL);
         if(NULL == sii8334work){
            printk(KERN_ERR "NO memory for allocating sii8334work.\n");
            ret = -ENOMEM;
            goto ERR_ALLOC_INT_WORK;
        }
        #else
        sii8334work = kmalloc(sizeof(*sii8334work), GFP_ATOMIC);
        #endif
        INIT_WORK(sii8334work, work_queue); 
        #ifdef mhl_power_dbg
        #ifdef zy_dbg_err_handle
        ResumeWork = kmalloc(sizeof(*ResumeWork ),  GFP_ATOMIC);
        if(NULL == ResumeWork){
            printk(KERN_ERR "NO memory for allocating ResumeWork.\n");
	      ret = -ENOMEM;
            goto ERR_ALLOC_RESUM_WORK;
        }
        #else
        ResumeWork = kmalloc(sizeof(*ResumeWork ),  GFP_ATOMIC);
        #endif
        INIT_DELAYED_WORK(ResumeWork, ResumeWorkFunc);
        #endif
        #ifdef ZY_IMPLEMENT_RCP
        mhl_state.rmt_input = input_allocate_device();
        if(NULL == mhl_state.rmt_input){
            printk(KERN_INFO "Bad input_allocate_device()\n");
	      ret = -ENOMEM;
	      goto ERR_ALLOC_INPUT;
        }
	
        mhl_init_rmt_input_dev();
        //Register with the Input subsystem	
        ret = input_register_device(mhl_state.rmt_input);
        if(ret){
            printk(KERN_INFO "Register input device failed.\n ");
            goto ERR_REG_INPUT;
        }
        #endif
        #ifdef zy_dbg_irq
	  //modified by zhangyue on 2011-12-07 
	  //for debugging, because some time, the irq handler not run when the irq came.
	  ret = request_threaded_irq(sii8334_PAGE_TPI->irq, NULL, Sii8334_mhl_interrupt, IRQ_TYPE_LEVEL_LOW |IRQF_ONESHOT, 
        	sii8334_PAGE_TPI->name, sii8334_PAGE_TPI); 
	 #else
        ret = request_irq(sii8334_PAGE_TPI->irq, Sii8334_mhl_interrupt, IRQ_TYPE_LEVEL_LOW,
        sii8334_PAGE_TPI->name, sii8334_PAGE_TPI); 
	  #endif
	  
        if (ret){
            printk(KERN_INFO "%s:%d:Sii8334 interrupt failed\n", __func__,__LINE__);	
            #ifdef zy_dbg_err_handle
            goto ERR_REQ_IRQ;
            #endif
            //free_irq(irq, iface);
        }else{
            #ifdef zy_usrspace_enalbe_mhl_irq
		//modified by zhangyue on 2011-12-26 for debugging the mhl charging	start
		disable_irq(sii8334_PAGE_TPI->irq);
		HalTimerWait(40);//sleep 40ms
		enable_irq(sii8334_PAGE_TPI->irq);
            //disable_irq(sii8334_PAGE_TPI->irq);
		//modified by zhangyue on 2011-12-26 for debugging the mhl charging	end
	      #else
            enable_irq_wake(sii8334_PAGE_TPI->irq);
	      #endif  
            //printk(KERN_INFO "%s:%d:Sii8334 interrupt successed\n", __func__,__LINE__);	
        }
        #ifdef zy_usrspace_enalbe_mhl_irq
        mhl_state.irq_Inited = false;
	 #endif
        #ifdef mhl_power_dbg
        mhl_state.state = true;
        #endif
        #else
        StartEventThread();		/* begin monitoring for events if using polling mode*/
        #endif
        #ifdef zy_dbg_err_handle
        goto ERR_ALLOC_INT_WORK;
        #endif
    ERR_REQ_IRQ:
        input_unregister_device(mhl_state.rmt_input);
    ERR_REG_INPUT:
        input_free_device(mhl_state.rmt_input);
    ERR_ALLOC_INPUT:
        kfree(ResumeWork);
    ERR_ALLOC_RESUM_WORK:
        kfree(sii8334work);
    }
ERR_ALLOC_INT_WORK:
    return ret;
}
int32_t StartMhlTxDevice(void)
{
	halReturn_t		halStatus;
	SiiOsStatus_t	osalStatus;
    printk("Starting %s\n", MHL_PART_NAME);

	SiiMhlTxHwReset(10,200);  
    if(!SiiCraInitialize())
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of CRA layer failed!\n");
    	return -EIO;
    }
    osalStatus = SiiOsInit(0);
    if (osalStatus != SII_OS_STATUS_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of OSAL failed, error code: %d\n",osalStatus);
    	return -EIO;
    }
    halStatus = HalInit();
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of HAL failed, error code: %d\n",halStatus);
    	SiiOsTerm();
    	return -EIO;
    }

//#if MTK_project
    //xuecheng
    //I2c_Init();
//#endif
  
    halStatus = HalOpenI2cDevice(MHL_PART_NAME, MHL_DRIVER_NAME);
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Opening of I2c device %s failed, error code: %d\n",
    			MHL_PART_NAME, halStatus);
    	HalTerm();
    	SiiOsTerm();
    	return -EIO;
    }
		

	msleep(200);
	
#ifdef SiI8338DRIVER_INTERRUPT_MODE
    halStatus = HalInstallIrqHandler(SiiMhlTxDeviceIsr);
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of HAL interrupt support failed, error code: %d\n",
    			halStatus);
    	HalCloseI2cDevice();
    	HalTerm();
    	SiiOsTerm();
    	return -EIO;
    }

#else
		StartEventThread();		/* begin monitoring for events if using polling mode*/
#endif
    //xuecheng

    HalInstallCheckDeviceCB(SiiCheckDevice);
	HalAcquireIsrLock();
	siHdmiTx_VideoSel(HDMI_720P60);
	siHdmiTx_AudioSel(I2S_44);
    SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
    HalReleaseIsrLock();
    return 0;
}
예제 #4
0
/*
 * i2c client ftn.
 */
static int __devinit mhl_Sii8334_probe(struct i2c_client *client,
			const struct i2c_device_id *dev_id)
{
	int ret = 0;

	if(match_id(&mhl_Sii8334_idtable[0], client))
	{
		sii8334_PAGE_TPI = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	/*
	else if(match_id(&mhl_Sii8334_idtable[1], client))
	{
		sii8334_PAGE_TX_L0 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully \n", dev_id->name);
	}
	*/
	else if(match_id(&mhl_Sii8334_idtable[2], client))
	{
		sii8334_PAGE_TX_L1 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully \n", dev_id->name);
	}
	else if(match_id(&mhl_Sii8334_idtable[3], client))
	{
		sii8334_PAGE_TX_2 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	else if(match_id(&mhl_Sii8334_idtable[4], client))
	{
		sii8334_PAGE_TX_3 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	else if(match_id(&mhl_Sii8334_idtable[5], client))
	{
		sii8334_PAGE_CBUS = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	else
	{
		dev_info(&client->adapter->dev, "invalid i2c adapter: can not found dev_id matched\n");
		return -EIO;
	}


	if(sii8334_PAGE_TPI != NULL 
		//&&sii8334_PAGE_TX_L0 != NULL 
		&&sii8334_PAGE_TX_L1 != NULL 
		&& sii8334_PAGE_TX_2 != NULL
		&& sii8334_PAGE_TX_3 != NULL
		&& sii8334_PAGE_CBUS != NULL)
	{
		// Announce on RS232c port.
		//
		printk("\n============================================\n");
		printk("SiI-8334 Driver Version based on 8051 driver Version 1.0066 \n");
		printk("============================================\n");
		
		if(false == Sii8334_mhl_reset()){
			printk("/nCan't find the reset function in your platform file============================================\n");
			return -EIO;
			}

		//
		// Initialize the registers as required. Setup firmware vars.
		//
	
		SiiMhlTxInitialize();
		
		#ifdef SiI8334DRIVER_INTERRUPT_MODE
		sii8334work = kmalloc(sizeof(*sii8334work), GFP_ATOMIC);
		INIT_WORK(sii8334work, work_queue); 
		
		ret = request_irq(sii8334_PAGE_TPI->irq, Sii8334_mhl_interrupt, IRQ_TYPE_LEVEL_LOW,
					  sii8334_PAGE_TPI->name, sii8334_PAGE_TPI);
		if (ret)
			printk(KERN_INFO "%s:%d:Sii8334 interrupt failed\n", __func__,__LINE__);	
			//free_irq(irq, iface);
		else{
			enable_irq_wake(sii8334_PAGE_TPI->irq);	
			//printk(KERN_INFO "%s:%d:Sii8334 interrupt successed\n", __func__,__LINE__);	
			}
		#else
		StartEventThread();		/* begin monitoring for events if using polling mode*/
		#endif
	}
	return ret;
}