/* * * Function Name: DSI_SetMaxRtnPktSize * * Description: Set Window * */ static Int32 DSI_SetMaxRtnPktSize(DISPDRV_HANDLE_T drvH, UInt8 size) { DispDrv_PANEL_t *pPanel = (DispDrv_PANEL_t *)drvH; CSL_DSI_CMND_t msg; UInt8 txData[2]; /* DCS Rd Command */ Int32 res = 0; CSL_LCD_RES_T cslRes; txData[0] = size; txData[1] = 0x0; msg.vc = pPanel->cmnd_mode->vc; msg.isLP = pPanel->disp_info->cmnd_LP; msg.endWithBta = FALSE; msg.reply = NULL; msg.dsiCmnd = DSI_DT_SH_MAX_RET_PKT_SIZE; msg.msg = &txData[0]; msg.msgLen = 2; msg.isLong = FALSE; msg.endWithBta = FALSE; DSI_INFO("[DISPDRV]: disCmnd[0x%02X]\n", DSI_DT_SH_MAX_RET_PKT_SIZE); cslRes = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); if (cslRes != CSL_LCD_OK) { DSI_ERR( "[DISPDRV]: ERR: Setting Max. Return Packet Size [0x%02X]\n\r" , DSI_DT_SH_MAX_RET_PKT_SIZE); res = -1; } return res; }
static void DISPDRV_WrCmndPn( DISPDRV_HANDLE_T drvH, UInt32 Pn, UInt8* Pdata ) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; // UInt8 msgData[4]; if(Pn <=2) { msg.dsiCmnd = DSI_DT_SH_DCS_WR_P1; msg.isLong = TRUE; } else { msg.dsiCmnd = DSI_DT_LG_DCS_WR; msg.isLong = FALSE; } msg.msg = &Pdata[0]; msg.msgLen = Pn; msg.vc = DISPDRV_VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.endWithBta = FALSE; CSL_DSI_SendPacket (pPanel->clientH, &msg, FALSE); }
/* * * Function Name: DSI_ExecCmndList * * Description: * */ static void DSI_ExecCmndList(DispDrv_PANEL_t *pPanel, char *buff) { CSL_DSI_CMND_t msg; int res = 0; msg.vc = pPanel->cmnd_mode->vc; msg.isLP = pPanel->disp_info->cmnd_LP; msg.endWithBta = FALSE; msg.reply = NULL; while (*buff) { uint8_t len = *buff++; if (len == (uint8_t)~0) { msleep(*buff++); } else { switch (len) { case 0: res = -1; break; case 1: msg.dsiCmnd = DSI_DT_SH_DCS_WR_P0; break; case 2: msg.dsiCmnd = DSI_DT_SH_DCS_WR_P1; break; default: if (len <= CSL_DSI_GetMaxTxMsgSize()) msg.dsiCmnd = DSI_DT_LG_DCS_WR; else res = -1; break; } if (res) { DSI_ERR("Packet size err %d\n", res); goto err_size; } msg.isLong = len > 2; msg.msg = buff; msg.msgLen = len; res = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); buff += len; } if (res) DSI_ERR("Error while sending packet %d\n", res); } err_size: return; }
//***************************************************************************** // // Function Name: DISPDRV_GenericRead // // Parameters: // // Description: Able to read up to CSL_DSI_GetMaxRxMsgSize bytes back // //***************************************************************************** static int DISPDRV_GenericRead( DISPDRV_HANDLE_T drvH, UInt8 reg, // register to read from UInt8* rx_buff, // read buffer UInt32* rx_size // no of bytes read back ) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; volatile CSL_DSI_REPLY_t rxMsg; // CSL DSI RX message UInt8 txData[1]; // DCS Rd Command Int32 res = 0; CSL_LCD_RES_T cslRes; msg.dsiCmnd = DSI_DT_SH_DCS_RD_P0; msg.msg = &txData[0]; msg.msgLen = 1; msg.vc = DISPDRV_VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = TRUE; rxMsg.pReadReply = rx_buff; msg.reply = (CSL_DSI_REPLY_t *)&rxMsg; *rx_size = 0; txData[0] = reg; cslRes = CSL_DSI_SendPacket( pPanel->clientH, &msg, FALSE ); if( (cslRes != CSL_LCD_OK) || ((rxMsg.type & DSI_RX_TYPE_READ_REPLY)==0) ) { LCD_DBG( LCD_DBG_ERR_ID, "[DISPDRV] %s: ERR" "Reading error\n\r", __FUNCTION__); res = -1; goto failed; } *rx_size = rxMsg.readReplySize; LCD_DBG( LCD_DBG_INIT_ID, "[DISPDRV] %s: We've Received %d Byte(s) " "Reading From Reg[0x%02X]\n", __FUNCTION__, (unsigned int)rxMsg.readReplySize, reg ); failed: return(res); } // DISPDRV_GenericRead
static int DISPDRV_ReadID(DISPDRV_HANDLE_T drvH, UInt8 reg) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; volatile CSL_DSI_REPLY_t rxMsg; // DSI RX message UInt8 txData[1]; // DCS Rd Command volatile UInt8 rxBuff[3]; // Read Buffer CSL_LCD_RES_T cslRes; msg.dsiCmnd = DSI_DT_SH_DCS_RD_P0; msg.msg = &txData[0]; msg.msgLen = 1; msg.vc = DISPDRV_VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = TRUE; rxMsg.pReadReply = (UInt8 *)&rxBuff[0]; msg.reply = (CSL_DSI_REPLY_t *)&rxMsg; txData[0] = reg; cslRes = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); if ((cslRes != CSL_LCD_OK) || ((rxMsg.type & DSI_RX_TYPE_READ_REPLY) == 0)) { LCD_DBG(LCD_DBG_ERR_ID, "[DISPDRV] %s: ERR" "Reading From Reg[0x%08X]\n\r", __FUNCTION__, (unsigned int)reg); return -1; } printk("[LCD] rxBuff[0]=0x%x, rxBuff[1]=0x%x, rxBuff[2]=0x%x\n", rxBuff[0], rxBuff[1], rxBuff[2]); if((rxBuff[0] == 0x5B) && (rxBuff[1] == 0x88) && (rxBuff[2] == 0x60)){ return LCD_PANEL_ID_ONE_L3; }else if((rxBuff[0] == 0x5B) && (rxBuff[1] == 0x89) && (rxBuff[2] == 0x60)){ return LCD_PANEL_ID_TWO_L4; } else{ return LCD_PANEL_ID_NOT_SET/*DEFAULT*/; } // return (rxBuff[0]); } // bcm91008_ale
static int DSI_panel_turn_on(DispDrv_PANEL_t *pPanel) { CSL_DSI_CMND_t msg; int res = 0; msg.dsiCmnd = DSI_DT_SH_TURN_ON; msg.msg = NULL; msg.msgLen = 0; msg.vc = pPanel->cmnd_mode->vc; msg.isLP = pPanel->disp_info->cmnd_LP; msg.isLong = FALSE; msg.endWithBta = FALSE; msg.reply = NULL; res = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); return res; }
//***************************************************************************** // // Function Name: bcm91008_alex_WrCmndP0 // // Parameters: reg = 08-bit register address (DCS command) // // Description: Register Write - DCS command byte, 0 parm // //***************************************************************************** static void DISPDRV_WrCmndP0(DISPDRV_HANDLE_T drvH, UInt32 reg) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData[4]; msg.dsiCmnd = DSI_DT_SH_DCS_WR_P0; msg.msg = &msgData[0]; msg.msgLen = 1; msg.vc = VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = FALSE; msgData[0] = reg; msgData[1] = 0; CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); }
/* * * Function Name: DSI_DCS_Read * * Description: DSI Read Reg * */ static Int32 DSI_DCS_Read(DispDrv_PANEL_t *pPanel, UInt8 reg, UInt8 *rxBuff, UInt8 buffLen) { CSL_DSI_CMND_t msg; CSL_DSI_REPLY_t rxMsg; /* DSI RX message */ UInt8 txData[2], i; /* DCS Rd Command */ Int32 res = 0; CSL_LCD_RES_T cslRes; msg.dsiCmnd = DSI_DT_SH_DCS_RD_P0; msg.msg = &txData[0]; msg.msgLen = 2; msg.vc = pPanel->cmnd_mode->vc; msg.isLP = pPanel->disp_info->cmnd_LP; if (buffLen > 2) msg.isLong = TRUE; else msg.isLong = FALSE; msg.endWithBta = TRUE; rxMsg.pReadReply = (UInt8 *)rxBuff; msg.reply = (CSL_DSI_REPLY_t *)&rxMsg; txData[0] = reg; txData[1] = 0x0; DSI_SetMaxRtnPktSize(pPanel, buffLen); cslRes = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); if ((cslRes != CSL_LCD_OK) || ((rxMsg.type & DSI_RX_TYPE_READ_REPLY) == 0)) { DSI_ERR( "[DISPDRV]: ERR: Reading From Reg[0x%08X]\n\r" , reg); res = -1; } else { DSI_INFO("[DISPDRV]: Command: 0x%02X\n", reg); for (i = 0; i < buffLen; i++) DSI_INFO("Parameter[%d]: [0x%02X]\n", i, rxBuff[i]); res = rxMsg.readReplySize; } return res; }
static int NT35512_panel_turn_on(NT35512_PANEL_t *pPanel) { CSL_DSI_CMND_t msg; int res = 0; UInt8 msg_buff[2]; msg.dsiCmnd = DSI_DT_SH_TURN_ON; msg.msg = &msg_buff[0]; msg.msgLen = 1; msg.vc = NT35512_VC; msg.isLP = NT35512_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = FALSE; msg.reply = NULL; res = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); NT35512_LOG(LCD_DBG_ERR_ID, "[DISPDRV] %s: DT[0x%02lX] SIZE[%lu]\n", __func__, msg.dsiCmnd, msg.msgLen); return res; }
//***************************************************************************** // // Function Name: DISPDRV_SetMaxRxSize // // Parameters: NONE // // Description: Tells periphereal not to send more than X data bytes back // in a single packet ( applies to all read operations ). // Limit is our RX FIFO size. // //***************************************************************************** static int DISPDRV_SetMaxRxSize(DISPDRV_HANDLE_T drvH) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData[2]; int res = 0; msgData[0] = CSL_DSI_GetMaxRxMsgSize(); // LSB first msgData[1] = 0; // assumption max <= 255, currently 10 msg.dsiCmnd = DSI_DT_SH_MAX_RET_PKT_SIZE; msg.msg = (UInt8 *)&msgData; msg.msgLen = 2; msg.vc = DISPDRV_VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = FALSE; CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); return (res); }
//***************************************************************************** // // Function Name: dsi_wrcmndP0 // // Parameters: reg = 08-bit register address (DCS command) // // Description: Register Write - DCS command byte, 0 parm // //***************************************************************************** static void dsi_wrcmndP0( DISPDRV_HANDLE_T drvH, UInt32 reg ) { dsic_panel_t *pPanel = (dsic_panel_t *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData[4]; msg.dsiCmnd = DSI_DT_SH_DCS_WR_P0; msg.msg = &msgData[0]; msg.msgLen = 2; msg.vc = DSI_VC; msg.isLP = DSI_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = FALSE; msgData[0] = reg; msgData[1] = 0; CSL_DSI_SendPacket (pPanel->clientH, &msg); }
static void dsi_set_max_ret_pkt_size( DISPDRV_HANDLE_T drvH, UInt32 reg ) { dsic_panel_t *pPanel = (dsic_panel_t *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData[4]; msg.dsiCmnd = DSI_DT_SH_MAX_RET_PKT_SIZE; msg.msg = &msgData[0]; msg.msgLen = 2; msg.vc = DSI_VC; msg.isLP = DSI_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = FALSE; msgData[0] = 2; msgData[1] = 0; CSL_DSI_SendPacket (pPanel->clientH, &msg); }
static int DSI_ReadReg(DISPDRV_HANDLE_T drvH, UInt8 reg, UInt8 *rxBuff) { DispDrv_PANEL_t *pPanel = (DispDrv_PANEL_t *)drvH; CSL_DSI_CMND_t msg; CSL_DSI_REPLY_t rxMsg; /* DSI RX message */ UInt8 txData[1]; /* DCS Rd Command */ Int32 res = 0; CSL_LCD_RES_T cslRes; msg.dsiCmnd = DSI_DT_SH_DCS_RD_P0; msg.msg = &txData[0]; msg.msgLen = 1; msg.vc = pPanel->cmnd_mode->vc; msg.isLP = FALSE; msg.isLong = FALSE; msg.endWithBta = TRUE; rxMsg.pReadReply = (UInt8 *)rxBuff; msg.reply = (CSL_DSI_REPLY_t *)&rxMsg; txData[0] = reg; cslRes = CSL_DSI_SendPacket(pPanel->clientH, &msg, FALSE); if ((cslRes != CSL_LCD_OK) || ((rxMsg.type & DSI_RX_TYPE_READ_REPLY) == 0)) { DSI_ERR("Reading From Reg[0x%08X]\n", reg); res = -1; } else { /* DSI_ERR("OK Reg[0x%08X] Val[0x%08X][0x%08X] Size=[0x%08X]\n", reg, rxBuff[1], rxBuff[0], rxMsg.readReplySize); */ res = rxMsg.readReplySize; } return res; }
//***************************************************************************** // // Function Name: DISPDRV_WrSendCmnd // Parameters: msg_buff = TX byte buffer // msg_size = size of message to be sent [bytes] // // Description: Send commands with variable no of parms // Assumption: DISPLAY's Controller Accepts DT Used // //***************************************************************************** static int DISPDRV_WrSendCmnd( DISPDRV_HANDLE_T drvH, UInt8 * msg_buff, UInt32 msg_size, UInt8 packet_type ) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; int res = 0; if(packet_type == GEN_TYPE) { switch(msg_size) { /* case 0: res = -1; break; */ case 0: msg.dsiCmnd = DSI_DT_SH_GEN_WR_P0; break; case 1: msg.dsiCmnd = DSI_DT_SH_GEN_WR_P1; break; case 2: msg.dsiCmnd = DSI_DT_SH_GEN_WR_P2; break; default: if( msg_size <= CSL_DSI_GetMaxTxMsgSize() ) { msg.dsiCmnd = DSI_DT_LG_GEN_WR; } else res = -1; break; } } else // DCS TYPE { switch(msg_size) { case 0: res = -1; break; case 1: msg.dsiCmnd = DSI_DT_SH_DCS_WR_P0; break; case 2: msg.dsiCmnd = DSI_DT_SH_DCS_WR_P1; break; default: if( msg_size <= CSL_DSI_GetMaxTxMsgSize() ) { msg.dsiCmnd = DSI_DT_LG_DCS_WR; } else res = -1; break; } } if( res == 0 ){ msg.msg = msg_buff; msg.msgLen = msg_size; msg.vc = DISPDRV_VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.isLong = msg_size > 2; msg.endWithBta = FALSE; CSL_DSI_SendPacket (pPanel->clientH, &msg, FALSE); } return(res); }
//***************************************************************************** // // Function Name: DISPDRV__IoCtlRd // // Parameters: // // Description: IOCTL RD Test Code - DCS Rd // //***************************************************************************** static int DISPDRV_IoCtlRd( DISPDRV_HANDLE_T drvH, DISPDRV_CTRL_RW_REG* acc ) { DISPDRV_PANEL_T *pPanel = (DISPDRV_PANEL_T *)drvH; CSL_DSI_CMND_t msg; CSL_DSI_REPLY_t rxMsg; UInt8 txData[1]; // DCS Rd Command UInt32 reg; UInt8 * pRxBuff = (UInt8*)acc->pBuff; Int32 res = 0; CSL_LCD_RES_T cslRes; memset( (void*)&rxMsg, 0, sizeof(CSL_DSI_REPLY_t) ); rxMsg.pReadReply = pRxBuff; msg.dsiCmnd = DSI_DT_SH_DCS_RD_P0; msg.msg = &txData[0]; msg.msgLen = 1; msg.vc = DISPDRV_VC; msg.isLP = DISPDRV_CMND_IS_LP; msg.isLong = FALSE; msg.endWithBta = TRUE; msg.reply = &rxMsg; txData[0] = acc->cmnd; cslRes = CSL_DSI_SendPacket ( pPanel->clientH, &msg, FALSE ); if( cslRes != CSL_LCD_OK ) { LCD_DBG ( LCD_DBG_ERR_ID, "[DISPDRV] %s: ERR" "Reading From Reg[0x%08X]\n\r", __FUNCTION__, (unsigned int)acc->cmnd ); res = -1; } else { reg = pRxBuff[0]; LCD_DBG ( LCD_DBG_INIT_ID, "[DISPDRV] %s: Reg[0x%08X] " "Value[0x%08X]\n\r", __FUNCTION__, (unsigned int)acc->cmnd, (unsigned int)reg ); if( rxMsg.type & DSI_RX_TYPE_TRIG ) { LCD_DBG ( LCD_DBG_INIT_ID, " TRIG : 0x%08X\n", (unsigned int)rxMsg.trigger ); } if( rxMsg.type & DSI_RX_TYPE_READ_REPLY ) { LCD_DBG ( LCD_DBG_INIT_ID, " RD STAT : 0x%08X\n", (unsigned int)rxMsg.readReplyRxStat ); LCD_DBG ( LCD_DBG_INIT_ID, " RD SIZE : %d\n" , rxMsg.readReplySize ); LCD_DBG ( LCD_DBG_INIT_ID, " RD BUFF : 0x%02X 0x%02X 0x%02X 0x%02X " "0x%02X 0x%02X 0x%02X 0x%02X\n", pRxBuff[0], pRxBuff[1], pRxBuff[2], pRxBuff[3], pRxBuff[4], pRxBuff[5], pRxBuff[6], pRxBuff[7] ); } if( rxMsg.type & DSI_RX_TYPE_ERR_REPLY ) { LCD_DBG ( LCD_DBG_INIT_ID, " ERR STAT: 0x%08X\n", (unsigned int)rxMsg.errReportRxStat ); } } return ( res ); } // DISPDRV__IoCtlRd
//***************************************************************************** // // Function Name: dsi_wrcmndPN // // Parameters: reg = 08-bit register address (DCS command) // value = 08-bit register data (DCS command parm) // // Description: Register Write - DCS command byte, 1 parm // //***************************************************************************** static void dsi_wrcmndPN( DISPDRV_HANDLE_T drvH, UInt32 reg, UInt32 datasize, UInt8* dataptr ) { #ifdef _BRCM_8BYTE_MSG_CONSTRAINT if(datasize <8) {//datasize <=7 dsic_panel_t *pPanel = (dsic_panel_t *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData [(datasize+1)]; int index = 0; msg.dsiCmnd = DSI_DT_LG_DCS_WR; msg.msg = &msgData[0]; msg.msgLen = datasize+1; msg.vc = DSI_VC; msg.isLP = DSI_CMND_IS_LP; msg.isLong = TRUE; msg.endWithBta = FALSE; msgData[0] = reg; for(index = 0; index < datasize; index++) { msgData[index+1] = dataptr[index] & 0x000000FF; } CSL_DSI_SendPacket (pPanel->clientH, &msg); } else {//TODO:following codes is just for HX8369A, it need to be replaced with DATA_CMD_FIFO+PIXEL_FIFO method dsic_panel_t *pPanel = (dsic_panel_t *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData [8]; int index = 0; int sendindex[10]; int sendsize[10]; int sendcounter = 0; int temp = 0; sendindex[0]=0; sendsize[0]=5; index += 5; sendcounter = 1; //calculate size while(index < datasize) { if((datasize-index)<6) { sendsize[sendcounter]=(datasize-index); sendcounter++; break; } else { sendsize[sendcounter]=6; index += 6; } sendcounter++; } //calculate index for(index = 1; index < sendcounter; index++) { temp += sendsize[index-1]; sendindex[index]=temp-1; } for(temp = 0; temp < sendcounter; temp++) { int size = (temp == 0) ? sendsize[temp]: (sendsize[temp]+1); msg.dsiCmnd = DSI_DT_LG_DCS_WR; msg.msg = &msgData[0]; if(temp == 0) msg.msgLen = sendsize[temp]+1; else msg.msgLen = sendsize[temp]+2; msg.vc = DSI_VC; msg.isLP = DSI_CMND_IS_LP; msg.isLong = TRUE; msg.endWithBta = FALSE; if(temp == 0) msgData[0] = reg; else msgData[0] = 0xFD; for(index = 0; index < size; index++) { msgData[index+1] = dataptr[sendindex[temp]+index] & 0x000000FF; } CSL_DSI_SendPacket (pPanel->clientH, &msg); } } #else dsic_panel_t *pPanel = (dsic_panel_t *)drvH; CSL_DSI_CMND_t msg; UInt8 msgData[(datasize + 1)]; int index = 0; msg.dsiCmnd = DSI_DT_LG_DCS_WR; msg.msg = &msgData[0]; msg.msgLen = datasize+1; msg.vc = DSI_VC; msg.isLP = DSI_CMND_IS_LP; msg.isLong = TRUE; msg.endWithBta = FALSE; //printk("[dsi_wrcmndPN]msgLen:%d\n",msg.msgLen); msgData[0] = reg; for(index = 0; index < datasize; index++) { msgData[index+1] = dataptr[index] & 0x000000FF; } CSL_DSI_SendPacket (pPanel->clientH, &msg); #endif //_BRCM_8BYTE_MSG_CONSTRAINT }