int hdmi_drv_power_on(void) { int ret = 0; HDMI_FUNC(); mt65xx_eint_mask(CUST_EINT_MHL_NUM); #if 1 SiiMhlTxHwGpioResume(); //pmic_config_interface(0x87,0x1,0x01,0x0); /* Vanzo:lubaoquan on: Tue, 21 May 2013 22:35:29 +0800 * TODO: replace this line with your comment */ hwPowerOn(MT65XX_POWER_LDO_VGP5, VOL_1200, "HDMI"); // End of Vanzo: lubaoquan #endif //msleep(100); SiiMhlTxHwReset(5,5); //xuecheng HalInstallCheckDeviceCB(SiiCheckDevice); HalAcquireIsrLock(); siHdmiTx_VideoSel(HDMI_720P60); siHdmiTx_AudioSel(I2S_44); ret = SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS); HalReleaseIsrLock(); mt65xx_eint_unmask(CUST_EINT_MHL_NUM); return ret; }
ssize_t ReadDevCap(struct device *dev, struct device_attribute *attr, char *buf) { uint8_t regValue; int status = -EINVAL; SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "ReadDevCap called\n"); if(HalAcquireIsrLock() != HAL_RET_SUCCESS) { return -ERESTARTSYS; } do { if(gDriverContext.flags & MHL_STATE_FLAG_CONNECTED) { status = SiiTxGetPeerDevCapEntry(gDriverContext.devCapOffset, ®Value); if(status != 0) { status = -EAGAIN; break; } status = scnprintf(buf, PAGE_SIZE, "offset:0x%02x=0x%02x", gDriverContext.devCapOffset, regValue); } } while(false); HalReleaseIsrLock(); return status; }
/* * @brief Interrupt handler for MHL transmitter interrupts. * * @param[in] irq The number of the asserted IRQ line that caused * this handler to be called. * @param[in] data Data pointer passed when the interrupt was enabled, * which in this case is a pointer to the * MhlDeviceContext of the I2c device. * * @return Always returns IRQ_HANDLED. * *****************************************************************************/ static irqreturn_t HalThreadedIrqHandler(int irq, void *data) { pMhlDeviceContext pMhlDevContext = (pMhlDeviceContext)data; // SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalThreadedIrqHandler called\n"); if (HalAcquireIsrLock() == HAL_RET_SUCCESS) { /* if(pMhlDevContext->CheckDevice &&!pMhlDevContext->CheckDevice(0))//mhl device check; { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"mhl device errror\n"); HalReleaseIsrLock(); return IRQ_HANDLED; } */ if(pMhlDevContext->irqHandler) { (pMhlDevContext->irqHandler)(); } HalReleaseIsrLock(); } else { SII_DEBUG_PRINT(MSG_ERR,"------------- irq missing! -------------\n"); } return IRQ_HANDLED; }
ssize_t SendRcp(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long keyCode; int status = -EINVAL; SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"SendRcp received string: ""%s""\n", buf); if(HalAcquireIsrLock() != HAL_RET_SUCCESS) { return -ERESTARTSYS; } while(gDriverContext.flags & MHL_STATE_FLAG_RCP_READY) { if(strict_strtoul(buf, 0, &keyCode)) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Unable to convert keycode string\n"); break; } if(keyCode >= 0xFE) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"keycode (0x%x) is too large to be valid\n", (int)keyCode); break; } gDriverContext.flags &= ~(MHL_STATE_FLAG_RCP_RECEIVED | MHL_STATE_FLAG_RCP_ACK | MHL_STATE_FLAG_RCP_NAK); gDriverContext.flags |= MHL_STATE_FLAG_RCP_SENT; gDriverContext.keyCode = (uint8_t)keyCode; SiiMhlTxRcpSend((uint8_t)keyCode); status = count; break; } HalReleaseIsrLock(); return status; }
ssize_t SendRcpAck(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long keyCode = 0x100; unsigned long errCode = 0x100; char *pStr; int status = -EINVAL; SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"SendRcpAck received buf len = %d\n", count); while(count) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"SendRcpAck received string: ""%s""\n", buf); pStr = strstr(buf, "keycode="); if(pStr != NULL) { if(strict_strtoul(pStr + strlen("keycode="), 0, &keyCode)) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "Unable to convert keycode string\n"); break; } } pStr = strstr(buf, "errorcode="); if(pStr != NULL) { if(strict_strtoul(pStr + strlen("errorcode="), 0, &errCode)) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "Unable to convert keycode string\n"); break; } } while(--count&&*buf++); } if((keyCode > 0xFF) || (errCode > 0xFF)) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Invalid key code or error code "\ "specified, key code: 0x%02x error code: 0x%02x\n", (int)keyCode, (int)errCode); return status; } if(HalAcquireIsrLock() != HAL_RET_SUCCESS) { return -ERESTARTSYS; } while(gDriverContext.flags & MHL_STATE_FLAG_RCP_READY) { if((keyCode != gDriverContext.keyCode) || !(gDriverContext.flags & MHL_STATE_FLAG_RCP_RECEIVED)) { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "Attempting to ACK a key code that was not received!\n"); break; } if(errCode == 0) { SiiMhlTxRcpkSend((uint8_t)keyCode); } else { SiiMhlTxRcpeSend((uint8_t)errCode); } status = count; break; } HalReleaseIsrLock(); return status; }
static irqreturn_t HalSilExtDeviceIrqHandler(int irq, void *data) { pMhlDeviceContext pMhlDevContext = (pMhlDeviceContext)data; if (HalAcquireIsrLock() == HAL_RET_SUCCESS) { if(pMhlDevContext->CheckDevice &&!pMhlDevContext->CheckDevice(1)) { HalReleaseIsrLock(); return IRQ_HANDLED; } if(pMhlDevContext->ExtDeviceirqHandler) { (pMhlDevContext->ExtDeviceirqHandler)(); } HalReleaseIsrLock(); } else { SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"------------- ExtDevice irq missing! -------------\n"); return IRQ_HANDLED; } return IRQ_HANDLED; }
ssize_t ShowRcpAck(struct device *dev, struct device_attribute *attr, char *buf) { int status = -EINVAL; SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "ShowRcpAck called\n"); if(HalAcquireIsrLock() != HAL_RET_SUCCESS) { return -ERESTARTSYS; } if(gDriverContext.flags & (MHL_STATE_FLAG_RCP_ACK | MHL_STATE_FLAG_RCP_NAK)) { status = scnprintf(buf, PAGE_SIZE, "keycode=0x%02x errorcode=0x%02x", gDriverContext.keyCode, gDriverContext.errCode); } HalReleaseIsrLock(); return status; }
void hdmi_drv_power_on(void) { HDMI_FUNC(); mt65xx_eint_mask(CUST_EINT_HDMI_HPD_NUM); SiiMhlTxHwGpioResume(); pmic_config_interface(0x87,0x1,0x01,0x0); //msleep(100); SiiMhlTxHwReset(50,200); //xuecheng HalInstallCheckDeviceCB(SiiCheckDevice); HalAcquireIsrLock(); siHdmiTx_VideoSel(HDMI_720P60); siHdmiTx_AudioSel(I2S_44); SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS); HalReleaseIsrLock(); mt65xx_eint_unmask(CUST_EINT_HDMI_HPD_NUM); }
ssize_t ShowRcp(struct device *dev, struct device_attribute *attr, char *buf) { int status = 0; if(HalAcquireIsrLock() != HAL_RET_SUCCESS) { return -ERESTARTSYS; } if(gDriverContext.flags & (MHL_STATE_FLAG_RCP_SENT | MHL_STATE_FLAG_RCP_RECEIVED)) { status = scnprintf(buf, PAGE_SIZE, "0x%02x %s", gDriverContext.keyCode, gDriverContext.flags & MHL_STATE_FLAG_RCP_SENT? "sent" : "received"); } HalReleaseIsrLock(); return status; }
int32_t ResumeMhlTxDevice(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; } //msleep(200); HalInstallCheckDeviceCB(SiiCheckDevice); HalAcquireIsrLock(); siHdmiTx_VideoSel(HDMI_720P60); siHdmiTx_AudioSel(I2S_44); SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS); HalReleaseIsrLock(); return 0; }
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; }
long SiiMhlIoctl(struct file *pFile, unsigned int ioctlCode, unsigned long ioctlParam) { long retStatus = 0; Register_t RegisterInfo; uint8_t reg; UserControl_t user_control; if (HalAcquireIsrLock() != HAL_RET_SUCCESS) { return -ERESTARTSYS; } switch (ioctlCode) { case SII_IOCTRL_REGISTER_READ: retStatus = copy_from_user(&RegisterInfo, (Register_t *) ioctlParam, sizeof(Register_t)); if (!retStatus) { RegisterInfo.value = I2C_ReadByte(RegisterInfo.dev_address, RegisterInfo.subaddr); retStatus = copy_to_user((Register_t *) ioctlParam, &RegisterInfo, sizeof(Register_t)); } else { pr_info("register read error!\n"); } break; case SII_IOCTRL_REGISTER_WRITE: retStatus = copy_from_user(&RegisterInfo, (Register_t *) ioctlParam, sizeof(Register_t)); reg = I2C_ReadByte(RegisterInfo.dev_address, RegisterInfo.subaddr); reg = (reg & (~RegisterInfo.mask)) | (RegisterInfo.mask & RegisterInfo.value); I2C_WriteByte(RegisterInfo.dev_address, RegisterInfo.subaddr, reg); break; case SII_IOCTRL_USER: retStatus = copy_from_user(&user_control, (UserControl_t *) ioctlParam, sizeof(UserControl_t)); switch (user_control.ControlID) { case USER_GPIO_GET: /* HalGpioGetPin(user_control.SubCommand.GpioCtrl.GpioIndex, &user_control.SubCommand.GpioCtrl.Value); */ break; case USER_GPIO_SET: /* HalGpioSetPin(user_control.SubCommand.GpioCtrl.GpioIndex, user_control.SubCommand.GpioCtrl.Value); */ break; case USER_TRIGGER_EXT_INT: /* SiiTriggerExtInt(); */ break; case USER_TRIGGER_MHL_INT: { if (TestDelay != NULL) { SiiOsTimerDelete(TestDelay); TestDelay = NULL; } SiiOsTimerCreate("Abort Time Out", SiiMhlTimerTestCB, NULL, true, 2000, false, &TestDelay); } break; case USER_ON_OFF_MHL_INT: HalEnableIrq(user_control.SubCommand.iSubCommand ? 1 : 0); break; case USER_RESET_MHL_CHIP: SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS); break; case USER_READ_SINK_EDID: { #define _MASK_(aByte, bitMask, setBits) ((setBits) ? (aByte | bitMask) : (aByte & ~bitMask)) int RepeatNums = 5, i; int iRepeatCnt = 0; uint8_t reg; uint8_t reg_save; reg_save = reg = I2C_ReadByte(0x72, 0xC7); reg = _MASK_(reg, BIT0, 1); I2C_WriteByte(0x72, 0xc7, reg); do { if (++iRepeatCnt > RepeatNums) break; reg = I2C_ReadByte(0x72, 0xC7); HalTimerWait(10); } while (!(reg & BIT1)); if (iRepeatCnt > RepeatNums) { printk("try time out\n"); } else { reg = I2C_ReadByte(0x72, 0xC7); reg = _MASK_(reg, BIT2, 1); I2C_WriteByte(0x72, 0xc7, reg); for (i = 0; i < 256; i++) { } I2C_ReadBlock(0xa0, 0, user_control.SubCommand.EDID, 128); I2C_ReadBlock(0xa0, 128, &user_control.SubCommand.EDID[128], 128); I2C_WriteByte(0x72, 0xc7, reg_save); } } break; } retStatus = copy_to_user((UserControl_t *) ioctlParam, &user_control, sizeof(UserControl_t)); break; default: SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "SiiMhlIoctl, unrecognized ioctlCode 0x%0x received!\n", ioctlCode); retStatus = -EINVAL; break; } HalReleaseIsrLock(); return retStatus; }