TaskRequestMap_t *RPC_SyncInitTaskMap(void) { TaskRequestMap_t *taskMap = GetMapForCurrentTask(); if (!taskMap) { taskMap = GetNewMapForCurrentTask(); assert(taskMap); // fill in struct (task field is already filled in by GetNewMapForCurrentTask() call) taskMap->ackSema = OSSEMAPHORE_Create(1, OSSUSPEND_PRIORITY); assert(taskMap->ackSema); // start in signalled state OSSEMAPHORE_Obtain(taskMap->ackSema, TICKS_FOREVER); taskMap->rspSema = OSSEMAPHORE_Create(1, OSSUSPEND_PRIORITY); assert(taskMap->rspSema); // start in signalled state OSSEMAPHORE_Obtain(taskMap->rspSema, TICKS_FOREVER); } taskMap->tid = 0; taskMap->ack = ACK_FAILED; taskMap->state = RPC_SYNC_STATE_WAITING_FOR_ACK; taskMap->isResultPending = FALSE; taskMap->result = RESULT_ERROR; taskMap->data = NULL; taskMap->dataLen = 0; taskMap->rspSize = 0; taskMap->releaseC2Buf = TRUE; taskMap->dataBufHandle = NULL; return taskMap; }
//=========================================================== // // Function Name: AUDDRV_VoiceRender_Resume // // Description: Stop the data transfer in voice render driver. // //================================================================== Result_t AUDDRV_VoiceRender_Stop( VORENDER_TYPE_t type, Boolean immediately ) { VORENDER_Drv_t *audDrv = NULL; VORENDER_MSG_t msg; Log_DebugPrintf(LOGID_AUDIO, " AUDDRV_VoiceRender_Stop::Stop capture. type = 0x%x, immediately = 0x%x\n", type, immediately); audDrv = GetDriverByType (type); if (audDrv == NULL) return RESULT_ERROR; memset (&msg, 0, sizeof(VORENDER_MSG_t)); if (immediately == TRUE) { msg.msgID = VORENDER_MSG_STOP; } else { msg.msgID = VORENDER_MSG_FINISH; } OSQUEUE_Post(audDrv->msgQueue, (QMsg_t*)&msg, TICKS_FOREVER); // make sure the task is stopped. if (immediately == TRUE) { OSSEMAPHORE_Obtain (audDrv->stopSema, TICKS_FOREVER); } return RESULT_OK; }
//=========================================================== // // Function Name: AUDDRV_VoiceRender_Write // // Description: Send audio data to voice render driver. // //================================================================== UInt32 AUDDRV_VoiceRender_Write( VORENDER_TYPE_t type, UInt8* pBuf, UInt32 nSize ) { VORENDER_Drv_t *audDrv = NULL; VORENDER_MSG_t msg; audDrv = GetDriverByType (type); if (audDrv == NULL) return RESULT_ERROR; memset (&msg, 0, sizeof(VORENDER_MSG_t)); msg.msgID = VORENDER_MSG_ADD_BUFFER; msg.parm1 = (UInt32)pBuf; msg.parm2 = nSize; OSQUEUE_Post(audDrv->msgQueue, (QMsg_t*)&msg, TICKS_FOREVER); // wait for the data copy finished. OSSEMAPHORE_Obtain (audDrv->addBufSema, TICKS_FOREVER); Log_DebugPrintf(LOGID_AUDIO, "AUDDRV_VoiceRender_Write :: srcBufCopied = 0x%x\n", audDrv->srcBufCopied); return audDrv->srcBufCopied; }
// =================================================================== // // Function Name: AUDDRV_VoiceCapture_Stop // // Description: Stop data transfer of voice capture driver. // // ==================================================================== Result_t AUDDRV_VoiceCapture_Stop( VOCAPTURE_TYPE_t type, Boolean immediately ) { VOCAPTURE_Drv_t *audDrv = NULL; VOCAPTURE_MSG_t msg; audDrv = GetDriverByType (type); if (audDrv == NULL) return RESULT_ERROR; memset (&msg, 0, sizeof(VOCAPTURE_MSG_t)); msg.msgID = VOCAPTURE_MSG_STOP; OSQUEUE_Post(audDrv->msgQueue, (QMsg_t*)&msg, TICKS_FOREVER); // make sure the task is stopped. OSSEMAPHORE_Obtain (audDrv->stopSema, TICKS_FOREVER); Log_DebugPrintf(LOGID_AUDIO, " : AUDDRV_VoiceCapture_Stop::Stop capture. type = 0x%x, audDrv->type = 0x%x\n", type, audDrv->drvType); return RESULT_OK; }
/* * * Function Name: cslDsi1UpdateTask * * Description: DSI Controller 0 Update Task * */ static void cslDsi1UpdateTask(void) { DSI_UPD_REQ_MSG_T updMsg; OSStatus_t osStat; CSL_LCD_RES_T res; DSI_HANDLE dsiH = &dsiBus[1]; for (;;) { res = CSL_LCD_OK; /* Wait for update request */ OSQUEUE_Pend(dsiH->updReqQ, (QMsg_t *)&updMsg, TICKS_FOREVER); /* Wait For signal from eof DMA */ osStat = OSSEMAPHORE_Obtain(dsiH->semaDma, TICKS_IN_MILLISECONDS(updMsg.updReq. timeOut_ms)); if (osStat != OSSTATUS_SUCCESS) { if (osStat == OSSTATUS_TIMEOUT) { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI] %s: " "TIMED OUT While waiting for " "EOF DMA\n", __func__); res = CSL_LCD_OS_TOUT; } else { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI] %s: " "OS ERR While waiting for EOF DMA\n", __func__); res = CSL_LCD_OS_ERR; } cslDsiDmaStop(&updMsg); } if (res == CSL_LCD_OK) res = cslDsiWaitForInt(dsiH, 100); else cslDsiWaitForInt(dsiH, 1); chal_dsi_de1_enable(dsiH->chalH, FALSE); chal_dsi_tx_start(dsiH->chalH, TX_PKT_ENG_1, FALSE); chal_dsi_tx_start(dsiH->chalH, TX_PKT_ENG_2, FALSE); if (!updMsg.clientH->hasLock) OSSEMAPHORE_Release(dsiH->semaDsi); if (updMsg.updReq.cslLcdCb) { updMsg.updReq.cslLcdCb(res, &updMsg.updReq.cslLcdCbRec); } else { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI] %s: " "Callback EQ NULL, Skipping\n", __func__); } } }
/** * This function will initialize Cam Driver. * To Initialize to default settings, HAL_CAM_Init(NULL); * To change default settings use ACTION_CAM_GetCameraSettings to get a copy of default camera settings, * Modify default settings in HAL_CAM_Action_settings_st_tand pass back in HAL_CAM_Init(HAL_LCD_config_st* HAL_LCD_config) * driver will copy new settings to local and initialize Camera. */ HAL_CAM_Result_en_t HAL_CAM_Init( CamSensorSelect_t sensor_select, ///< (in) Select Camera Sensor HAL_CAM_config_st_t* config_st ///< (out) device configuration structure ) { // Result_t result = RESULT_OK; HAL_CAM_Result_en_t hal_result = HAL_CAM_SUCCESS; pr_debug("HAL_CAM_Init \r\n"); #if 0 // Obtain Hal Cam Action Semaphore if( sHalCamActionSema == NULL ) { sHalCamActionSema = OSSEMAPHORE_Create( 1, OSSUSPEND_PRIORITY ); OSSEMAPHORE_ChangeName(sHalCamActionSema, "HalCamAction"); pr_debug("sHalCamActionSema Created \r\n"); } OSSEMAPHORE_Obtain(sHalCamActionSema,TICKS_FOREVER); if (config_st != NULL) { // Get Current Camera Default Settings CAM_GetCameraSettings(config_st->cam_config_st, CamPowerOff, sensor_select); } // Initialize Camera Driver and Sensor result = CAM_Init(sensor_select); switch (result) { case CAM_UNSUPPORTED: hal_result = HAL_CAM_ERROR_ACTION_NOT_SUPPORTED; break; case CAM_FAILED: hal_result = HAL_CAM_ERROR_INTERNAL_ERROR; break; case RESULT_DONE: hal_result = HAL_CAM_SUCCESS; break; case RESULT_OK: hal_result = HAL_CAM_SUCCESS; break; default: hal_result = HAL_CAM_ERROR_ACTION_NOT_SUPPORTED; break; } // Release Hal Cam Action Semaphore OSSEMAPHORE_Release(sHalCamActionSema); #endif return hal_result; }
/* * * Function Name: CSL_DSI_Lock * * Description: Lock DSI Interface For Exclusive Use By a Client * */ void CSL_DSI_Lock(CSL_LCD_HANDLE client) { DSI_CLIENT clientH = (DSI_CLIENT) client; DSI_HANDLE dsiH = (DSI_HANDLE)clientH->lcdH; if (clientH->hasLock) WARN(TRUE, "[CSL DSI][%d] %s: " "DSI Client Lock/Unlock Not balanced\n", dsiH->bus, __func__); else { OSSEMAPHORE_Obtain(dsiH->semaDsi, TICKS_FOREVER); clientH->hasLock = TRUE; } }
// get unused task/response map struct to be used with current task TaskRequestMap_t *GetNewMapForCurrentTask() { TaskRequestMap_t *taskMap = NULL; UInt8 i; OSSEMAPHORE_Obtain(semaTaskReq, TICKS_FOREVER); for (i = 0; i < MAX_TASKS_NUM; i++) { _DBG_(RPC_TRACE ("GetNewMapForCurrentTask detail task %lx index = %d\r\n", (UInt32)((sTaskRequestMap + i)->task), i)); if (NULL == (sTaskRequestMap + i)->task) { (sTaskRequestMap + i)->task = (Task_t) OSTASK_GetCurrentTask(); taskMap = (sTaskRequestMap + i); break; } } if (MAX_TASKS_NUM == i) { for (i = 0; i < MAX_TASKS_NUM; i++) { _DBG_(RPC_TRACE ("GetNewMapForCurrentTask 2nd loop task %lx index = %d\r\n", (UInt32)((sTaskRequestMap + i)->task), i)); if (FALSE == OSTASK_IsValidTask((sTaskRequestMap + i)->task)) { (sTaskRequestMap + i)->task = (Task_t) OSTASK_GetCurrentTask(); taskMap = (sTaskRequestMap + i); break; } } } OSSEMAPHORE_Release(semaTaskReq); _DBG_(RPC_TRACE ("GetNewMapForCurrentTask task %lx index= %d\r\n", (UInt32)OSTASK_GetCurrentTask(), i)); return taskMap; }
/** Prepare to issue a RPC request. @param data (in) pointer to buffer to store response @param size (in) size of response buffer @return transaction ID for request @note If size is -1, this indicates that the response size is variable and buffer should be allocated by the RPC callback handler. The buffer will be freed by the caller of RPC_SyncWaitForResponse **/ UInt32 RPC_SyncCreateTID(void *data, Int32 size) { UInt32 tid; TaskRequestMap_t *taskMap = NULL; //Protect the tid with semaphore OSSEMAPHORE_Obtain(semaTaskReq, TICKS_FOREVER); tid = sCurrTID; if (0 == ++sCurrTID) { sCurrTID = 1; } OSSEMAPHORE_Release(semaTaskReq); taskMap = RPC_SyncInitTaskMap(); taskMap->tid = tid; taskMap->data = data; taskMap->dataLen = size; return tid; }
/* * * Function Name: CSL_DSI_SendPacketTrigger * * Description: Send TRIGGER Message * */ CSL_LCD_RES_T CSL_DSI_SendTrigger(CSL_LCD_HANDLE client, UInt8 trig) { DSI_HANDLE dsiH; DSI_CLIENT clientH; CSL_LCD_RES_T res; clientH = (DSI_CLIENT) client; dsiH = (DSI_HANDLE)clientH->lcdH; if (!clientH->hasLock) OSSEMAPHORE_Obtain(dsiH->semaDsi, TICKS_FOREVER); if (dsiH->ulps) { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI][%d] %s: " "ERR, Link Is In ULPS\n", dsiH->bus, __func__); res = CSL_LCD_BAD_STATE; goto exit_err; } chal_dsi_clr_status(dsiH->chalH, 0xFFFFFFFF); #ifdef __CSL_DSI_USE_INT__ cslDsiEnaIntEvent(dsiH, (UInt32)CHAL_DSI_ISTAT_TXPKT1_DONE); #endif chal_dsi_tx_trig(dsiH->chalH, TX_PKT_ENG_1, trig); #ifdef __CSL_DSI_USE_INT__ res = cslDsiWaitForInt(dsiH, 100); #else res = cslDsiWaitForStatAny_Poll(dsiH, CHAL_DSI_STAT_TXPKT1_DONE, NULL, 100); #endif exit_err: if (!clientH->hasLock) OSSEMAPHORE_Release(dsiH->semaDsi); return res; }
/* * * Function Name: cslDsiWaitForInt * * Description: * */ static CSL_LCD_RES_T cslDsiWaitForInt(DSI_HANDLE dsiH, UInt32 tout_msec) { OSStatus_t osRes; CSL_LCD_RES_T res = CSL_LCD_OK; osRes = OSSEMAPHORE_Obtain(dsiH->semaInt, TICKS_IN_MILLISECONDS(tout_msec)); if (osRes != OSSTATUS_SUCCESS) { cslDsiDisInt(dsiH); if (osRes == OSSTATUS_TIMEOUT) { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI] %s: " "ERR Timed Out!\n", __func__); res = CSL_LCD_OS_TOUT; } else { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI] %s: " "ERR OS Err...!\n", __func__); res = CSL_LCD_OS_ERR; } } return res; }
/** Retrieve the response from a RPC function call. Note that this includes the ack result as well. @param tid (in) Transaction id for request. @param cid (in) Client id for request @param ack (out) Ack result for request @param msgType (out) Message type of response. @param dataSize (out) Actual data size copied to response data buffer @param timeout (in) timer value @return Result code of response. **/ Result_t RPC_SyncWaitForResponseTimer(UInt32 tid, UInt8 cid, RPC_ACK_Result_t *ack, MsgType_t *msgType, UInt32 *dataSize, UInt32 timeout) { OSStatus_t semaStatus; Result_t result = RESULT_OK; TaskRequestMap_t *taskMap = GetMapForCurrentTask(); assert(taskMap); // wait to be signalled that request has been ack'd semaStatus = OSSEMAPHORE_Obtain(taskMap->ackSema, (Ticks_t) timeout); //If you see this assert then likely remote processor does not free the buffers. //- Likely cause is CAPI2 Task on remote processor is stuck waiting on a Queue. //- or Watchdog issue where CAPI2 Task does not get chance to run. //- or Remote processor is completely DEAD if (semaStatus == OSSTATUS_TIMEOUT) return RESULT_TIMER_EXPIRED; else if (semaStatus != OSSTATUS_SUCCESS) return RESULT_ERROR; *ack = taskMap->ack; // request ack'd by comm proc? if (ACK_SUCCESS == taskMap->ack) { // synchronous response or error response from async api? if (!taskMap->isResultPending) { // yes, so wait to be signalled that response is ready taskMap->state = RPC_SYNC_STATE_WAITING_FOR_RSP; semaStatus = OSSEMAPHORE_Obtain(taskMap->rspSema, (Ticks_t) timeout); //If you see this assert then likely remote processor does not free the buffers. //- Likely cause is CAPI2 Task on remote processor is stuck waiting on a Queue. //- or Watchdog issue where CAPI2 Task does not get chance to run. //- or Remote processor is completely DEAD if (semaStatus == OSSTATUS_TIMEOUT) return RESULT_TIMER_EXPIRED; else if (semaStatus != OSSTATUS_SUCCESS) return RESULT_ERROR; if (msgType) { *msgType = taskMap->msgType; } if (dataSize) { *dataSize = taskMap->rspSize; } result = taskMap->result; } else { } taskMap->state = RPC_SYNC_STATE_DONE; } else { taskMap->state = RPC_SYNC_STATE_DONE; return RESULT_ERROR; } _DBG_(RPC_TRACE ("RPC_SyncWaitForResponseTimer tid=%d cid=%d msg=%d ack=%d\r\n", (int)tid, cid, taskMap->msgType, taskMap->ack)); _DBG_(RPC_TRACE ("RPC_SyncWaitForResponseTimer pend=%d sz=%d rs=%d task=0x%p\r\n", taskMap->isResultPending, (int)taskMap->rspSize, result, (void *)OSTASK_GetCurrentTask())); return result; }
//============================================================================================== // Function Name: AMRWB_Render_TaskEntry // // Description: The main task entry of voice render when using DSP AMRWB decoder //============================================================== static void AMRWB_Render_TaskEntry () { VORENDER_MSG_t msg; OSStatus_t status; VORENDER_Drv_t *audDrv = &sAMRWB_Drv; Log_DebugPrintf(LOGID_AUDIO, "AMRWBRender_TaskEntry: AMRWBRender_TaskEntry is running \r\n"); while(TRUE) { status = OSQUEUE_Pend( audDrv->msgQueue, (QMsg_t *)&msg, TICKS_FOREVER ); if (status == OSSTATUS_SUCCESS) { Log_DebugPrintf(LOGID_AUDIO, " AMRWBRender_TaskEntry::msgID = 0x%x.\n", msg.msgID); switch (msg.msgID) { case VORENDER_MSG_SET_TRANSFER: audDrv->callbackThreshold = (UInt32)msg.parm1; audDrv->interruptInterval = (UInt32)msg.parm2; break; case VORENDER_MSG_CONFIG: ConfigAudDrv (audDrv, (VORENDER_Configure_t *)msg.parm1); break; case VORENDER_MSG_REGISTER_BUFDONE_CB: audDrv->bufDoneCb = (AUDDRV_VoiceRender_BufDoneCB_t)msg.parm1; break; case VORENDER_MSG_START: Log_DebugPrintf(LOGID_AUDIO, " AMRWBRender_TaskEntry::Start render\n"); // Need to reset them, otherwise will use the values from the last play. arm_writeIndex = 0; dsp_readIndex = 0; dspif_AMRWB_play_start ( audDrv->config.playbackMode, audDrv->config.mixMode, audDrv->config.samplingRate, audDrv->config.speechMode, // used by AMRNB and AMRWB audDrv->config.dataRateSelection, // used by AMRNB and AMRWB audDrv->numFramesPerInterrupt); // need to reset sema after start dsp. dsp can send duplicate msgs to us. OSSEMAPHORE_ResetCnt(audDrv->stopDspAmrWbSema); break; case VORENDER_MSG_FINISH: audDrv->isFinishing = TRUE; break; case VORENDER_MSG_STOP: Log_DebugPrintf(LOGID_AUDIO, " AMRWBRender_TaskEntry::Stop render.\n"); dspif_AMRWB_play_init_stop(); //make sure dsp is stopped OSSEMAPHORE_Obtain (audDrv->stopDspAmrWbSema, TICKS_FOREVER); dspif_AMRWB_play_stop(); CheckBufDoneUponStop(audDrv); Log_DebugPrintf(LOGID_AUDIO, " AMRWBRender_TaskEntry::Stop render - done.\n"); OSSEMAPHORE_Release (audDrv->stopSema); break; case VORENDER_MSG_PAUSE: break; case VORENDER_MSG_RESUME: break; case VORENDER_MSG_ADD_BUFFER: CopyBufferToQueue (audDrv, (UInt8 *)msg.parm1, msg.parm2); OSSEMAPHORE_Release (audDrv->addBufSema); break; case VORENDER_MSG_FLUSH_BUFFER: Log_DebugPrintf(LOGID_AUDIO, "AMRWBRender_TaskEntry:: Flushed queue.\n"); // flush the data in the Q AUDQUE_Flush(audDrv->audQueue); // Need to reset them, otherwise will use the values from the last play. arm_writeIndex = 0; dsp_readIndex = 0; // this will make dsp to flush data inside dsp dspif_AMRWB_play_start ( audDrv->config.playbackMode, audDrv->config.mixMode, audDrv->config.samplingRate, audDrv->config.speechMode, // used by AMRNB and AMRWB audDrv->config.dataRateSelection, // used by AMRNB and AMRWB audDrv->numFramesPerInterrupt); // need to reset sema after start dsp. dsp can send duplicate msgs to us. OSSEMAPHORE_ResetCnt(audDrv->stopDspAmrWbSema); break; case VORENDER_MSG_SHM_REQUEST: ProcessSharedMemRequest (audDrv, (UInt16)msg.parm1, (UInt16)msg.parm2); break; default: Log_DebugPrintf(LOGID_AUDIO, "AMRWBRender_TaskEntry: Unsupported msg, msgID = 0x%x \r\n", msg.msgID); break; } } } }
/** Retrieve the response from a RPC function call. Note that this includes the ack result as well. @param tid (in) Transaction id for request. @param cid (in) Client id for request @param ack (out) Ack result for request @param msgType (out) Message type of response. @param dataSize (out) Actual data size copied to response data buffer @return Result code of response. **/ Result_t RPC_SyncWaitForResponse(UInt32 tid, UInt8 cid, RPC_ACK_Result_t *ack, MsgType_t *msgType, UInt32 *dataSize) { OSStatus_t semaStatus; Result_t result = RESULT_OK; TaskRequestMap_t *taskMap = GetMapForCurrentTask(); assert(taskMap); // wait to be signalled that request has been ack'd semaStatus = OSSEMAPHORE_Obtain(taskMap->ackSema, RPC_SEMAPHORE_TIMEOUT); //If you see this assert then likely remote processor does not free the buffers. //- Likely cause is CAPI2 Task on remote processor is stuck waiting on a Queue. //- or Watchdog issue where CAPI2 Task does not get chance to run. //- or Remote processor is completely DEAD #ifdef FUSE_APPS_PROCESSOR xassert(REMOTE_CP_NOT_RESPONDING, semaStatus); #else xassert(REMOTE_AP_NOT_RESPONDING, semaStatus); #endif *ack = taskMap->ack; // request ack'd by comm proc? if (ACK_SUCCESS == taskMap->ack) { // synchronous response or error response from async api? if (!taskMap->isResultPending) { // yes, so wait to be signalled that response is ready taskMap->state = RPC_SYNC_STATE_WAITING_FOR_RSP; semaStatus = OSSEMAPHORE_Obtain(taskMap->rspSema, RPC_SEMAPHORE_TIMEOUT); //If you see this assert then likely remote processor does not free the buffers. //- Likely cause is CAPI2 Task on remote processor is stuck waiting on a Queue. //- or Watchdog issue where CAPI2 Task does not get chance to run. //- or Remote processor is completely DEAD #ifdef FUSE_APPS_PROCESSOR xassert(REMOTE_CP_NOT_RESPONDING, semaStatus); #else xassert(REMOTE_AP_NOT_RESPONDING, semaStatus); #endif if (msgType) { *msgType = taskMap->msgType; } if (dataSize) { *dataSize = taskMap->rspSize; } result = taskMap->result; } else { } taskMap->state = RPC_SYNC_STATE_DONE; } else if (ACK_CRITICAL_ERROR == taskMap->ack) { /* CP reset */ taskMap->state = RPC_SYNC_STATE_DONE; result = RESULT_ERROR; } else { xassert(FALSE, taskMap->ack); } _DBG_(RPC_TRACE ("RPC_SyncWaitForResponse tid=%d cid=%d msg=%d ack=%d\r\n", (int)tid, cid, taskMap->msgType, taskMap->ack)); _DBG_(RPC_TRACE ("RPC_SyncWaitForResponse pend=%d sz=%d rs=%d task=%p \r\n", taskMap->isResultPending, (int)taskMap->rspSize, result, (void *)OSTASK_GetCurrentTask())); return result; }
/* * * Function Name: CSL_DSI_SendPacket * * Description: Send DSI Packet (non-pixel data) with an option to end it * with BTA. * If BTA is requested, command.reply MUST be valid * */ CSL_LCD_RES_T CSL_DSI_SendPacket(CSL_LCD_HANDLE client, pCSL_DSI_CMND command, Boolean isTE) { DSI_HANDLE dsiH; DSI_CLIENT clientH; CSL_LCD_RES_T res = CSL_LCD_OK; CHAL_DSI_TX_CFG_t txPkt; CHAL_DSI_RES_t chalRes; UInt32 stat; UInt32 event; UInt32 pfifo_len = 0; clientH = (DSI_CLIENT) client; dsiH = (DSI_HANDLE)clientH->lcdH; if (command->msgLen > CHAL_DSI_TX_MSG_MAX) { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI][%d] %s: " "ERR, TX Packet Size To Big\n", dsiH->bus, __func__, command->vc); return CSL_LCD_MSG_SIZE; } if (command->endWithBta && (command->reply == NULL)) { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI][%d] %s: " "ERR, VC[%d] BTA Requested But pReply Eq NULL\n", dsiH->bus, __func__, command->vc); return CSL_LCD_API_ERR; } if (!clientH->hasLock) OSSEMAPHORE_Obtain(dsiH->semaDsi, TICKS_FOREVER); if (dsiH->ulps) { LCD_DBG(LCD_DBG_ERR_ID, "[CSL DSI][%d] %s: " "ERR, VC[%d] Link Is In ULPS\n", dsiH->bus, __func__, command->vc); if (!clientH->hasLock) OSSEMAPHORE_Release(dsiH->semaDsi); return CSL_LCD_BAD_STATE; } txPkt.dsiCmnd = command->dsiCmnd; txPkt.msg = command->msg; txPkt.msgLen = command->msgLen; txPkt.vc = command->vc; txPkt.isLP = command->isLP; txPkt.endWithBta = command->endWithBta; txPkt.isTe = isTE; txPkt.vmWhen = CHAL_DSI_CMND_WHEN_BEST_EFFORT; txPkt.repeat = 1; txPkt.start = 1; chal_dsi_clr_status(dsiH->chalH, 0xFFFFFFFF); #ifdef __CSL_DSI_USE_INT__ if (txPkt.endWithBta) { event = CHAL_DSI_ISTAT_PHY_RX_TRIG | CHAL_DSI_ISTAT_RX2_PKT | CHAL_DSI_ISTAT_RX1_PKT; } else { event = CHAL_DSI_ISTAT_TXPKT1_DONE; } cslDsiEnaIntEvent(dsiH, event); #else if (txPkt.endWithBta) { event = CHAL_DSI_STAT_PHY_RX_TRIG | CHAL_DSI_STAT_RX2_PKT | CHAL_DSI_STAT_RX1_PKT; } else { event = CHAL_DSI_STAT_TXPKT1_DONE; } #endif if (txPkt.msgLen <= 2) { LCD_DBG(LCD_DBG_ID, "[CSL DSI][%d] %s: " "SHORT, MSG_LEN[%d]\n", dsiH->bus, __func__, txPkt.msgLen); txPkt.msgLenCFifo = 0; /* NA to short */ chalRes = chal_dsi_tx_short(dsiH->chalH, TX_PKT_ENG_1, &txPkt); if (chalRes != CHAL_DSI_OK) { res = CSL_LCD_MSG_SIZE; goto exit_err; } } else { if (txPkt.msgLen <= CHAL_DSI_CMND_FIFO_SIZE_B) { txPkt.msgLenCFifo = txPkt.msgLen; chalRes = chal_dsi_wr_cfifo(dsiH->chalH, txPkt.msg, txPkt.msgLenCFifo); if (chalRes != CHAL_DSI_OK) { res = CSL_LCD_MSG_SIZE; goto exit_err; } LCD_DBG(LCD_DBG_ID, "[CSL DSI][%d] %s: " "LONG FROM CMND FIFO ONLY," " CMND_FIFO[%d] PIXEL_FIFO[%d]\n", dsiH->bus, __func__, txPkt.msgLenCFifo, txPkt.msgLen - txPkt.msgLenCFifo); chalRes = chal_dsi_tx_long(dsiH->chalH, TX_PKT_ENG_1, &txPkt); if (chalRes != CHAL_DSI_OK) { res = CSL_LCD_MSG_SIZE; goto exit_err; } } else { if (txPkt.msgLen > CHAL_DSI_PIXEL_FIFO_SIZE_B) { txPkt.msgLenCFifo = txPkt.msgLen - CHAL_DSI_PIXEL_FIFO_SIZE_B; } else { txPkt.msgLenCFifo = txPkt.msgLen % 4; } pfifo_len = txPkt.msgLen - txPkt.msgLenCFifo; LCD_DBG(LCD_DBG_ID, "[CSL DSI][%d] %s: " "LONG FROM BOTH FIFOs, " "CMND_FIFO[%d] PIXEL_FIFO[%d]\n", dsiH->bus, __func__, txPkt.msgLenCFifo, txPkt.msgLen - txPkt.msgLenCFifo); chalRes = chal_dsi_wr_cfifo(dsiH->chalH, txPkt.msg, txPkt.msgLenCFifo); if (chalRes != CHAL_DSI_OK) { res = CSL_LCD_MSG_SIZE; goto exit_err; } if (pfifo_len > DE1_DEF_THRESHOLD_B) { chal_dsi_de1_set_dma_thresh(dsiH->chalH, pfifo_len >> 2); } chal_dsi_de1_set_cm(dsiH->chalH, DE1_CM_BE); chal_dsi_de1_enable(dsiH->chalH, TRUE); chalRes = chal_dsi_wr_pfifo_be(dsiH->chalH, txPkt.msg + txPkt.msgLenCFifo, txPkt.msgLen - txPkt.msgLenCFifo); if (chalRes != CHAL_DSI_OK) { res = CSL_LCD_MSG_SIZE; goto exit_err; } chalRes = chal_dsi_tx_long(dsiH->chalH, TX_PKT_ENG_1, &txPkt); if (chalRes != CHAL_DSI_OK) { res = CSL_LCD_MSG_SIZE; goto exit_err; } } }
/** * This function will perform specific action from defined list, copy of parameters passed thru parm structure. * */ HAL_CAM_Result_en_t HAL_CAM_Ctrl( HAL_CAM_Action_en_t action, ///< (in) device action void* data, ///< (in/out) structure pointer to additional parameters for Set, Get, and IS void* callback ///< (in) callback function device driver calls once action complete, NULL if not needed ) { Result_t result = RESULT_OK; HAL_CAM_Result_en_t hal_result = HAL_CAM_SUCCESS; #if 0 CamIntfConfig_st_t *pSensorIntfConfig; pr_debug("HAL_CAM_Ctrl(): action=%d \r\n", action); // Obtain Hal Cam Action Semaphore if( sHalCamActionSema == NULL ) { sHalCamActionSema = OSSEMAPHORE_Create( 1, OSSUSPEND_PRIORITY ); OSSEMAPHORE_ChangeName(sHalCamActionSema, "HalCamAction"); pr_debug("sHalCamActionSema Created \r\n"); } OSSEMAPHORE_Obtain(sHalCamActionSema,TICKS_FOREVER); #endif switch (action) { // *** Actions handled by hal camera driver // Camera Configuration #if 0 case ACTION_CAM_SetPowerMode: ///< CamPowerOff/CamPowerOn interface and sensor, use HAL_CAM_Action_power_mode_st_t to set result = CAM_SetPowerMode( ((HAL_CAM_Action_power_mode_st_t *)data)->sensor, ((HAL_CAM_Action_power_mode_st_t *)data)->mode ); break; case ACTION_CAM_GetCameraSettings: ///< Get Interface and Nominal/Min/Max camera settings, use HAL_CAM_Action_settings_st_t to get result = CAM_GetCameraSettings(((HAL_CAM_Action_settings_st_t *)data)->cam_config_st, ((HAL_CAM_Action_settings_st_t *)data)->mode, ((HAL_CAM_Action_settings_st_t *)data)->sensor); break; case ACTION_CAM_GetCameraInterface: ///< Get I2C and Camera Controller interface settings, use HAL_CAM_Action_cam_interface_st_t to get pSensorIntfConfig = CAM_GetCameraInterface( ((HAL_CAM_Action_cam_interface_st_t *)data)->sensor ); ((HAL_CAM_Action_cam_interface_st_t *)data)->i2c_dev_id = pSensorIntfConfig->sensor_config_i2c->i2c_device_id; ((HAL_CAM_Action_cam_interface_st_t *)data)->i2c_max_page = pSensorIntfConfig->sensor_config_i2c->i2c_max_page; ((HAL_CAM_Action_cam_interface_st_t *)data)->i2c_sub_addr_op = pSensorIntfConfig->sensor_config_i2c->i2c_sub_adr_op; // ((HAL_CAM_Action_cam_interface_st_t *)data)->controller_config = CAM_CNTRL_GetConfig(); break; // Image Capture Modes case ACTION_CAM_CaptureImage: ///< Capture camera image, use HAL_CAM_Action_capture_image_st_t to enable result = CAM_CaptureImage( ((HAL_CAM_Action_capture_image_st_t *)data)->size, ((HAL_CAM_Action_capture_image_st_t *)data)->format, ((HAL_CAM_Action_capture_image_st_t *)data)->sensor, ((HAL_CAM_Action_capture_image_st_t *)data)->buf, callback ); break; case ACTION_CAM_CaptureVideo: ///< Start camera video capture, use HAL_CAM_Action_capture_video_st_t to enable result = CAM_CaptureVideo( ((HAL_CAM_Action_capture_video_st_t *)data)->size, ((HAL_CAM_Action_capture_video_st_t *)data)->format, ((HAL_CAM_Action_capture_video_st_t *)data)->sensor, ((HAL_CAM_Action_capture_video_st_t *)data)->buf0, ((HAL_CAM_Action_capture_video_st_t *)data)->buf1, callback ); break; case ACTION_CAM_PreviewPPzoom: ///< Start camera preview/video capture, use HAL_CAM_Action_preview_PPzoom_st_t to enable result = CAM_PreviewPPzoom( ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->window_scale, ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->format, ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->sensor, ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->flash_mode, ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->mode, ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->buf0, ((HAL_CAM_Action_preview_PPzoom_st_t *)data)->buf1, callback ); break; case ACTION_CAM_StillsPPzoom: ///< Start camera preview/video capture, use HAL_CAM_Action_preview_PPzoom_st_t to enable result = CAM_StillsPPzoom( ((HAL_CAM_Action_stills_PPzoom_st_t *)data)->window_scale, ((HAL_CAM_Action_stills_PPzoom_st_t *)data)->format, ((HAL_CAM_Action_stills_PPzoom_st_t *)data)->sensor, ((HAL_CAM_Action_stills_PPzoom_st_t *)data)->flash_mode, ((HAL_CAM_Action_stills_PPzoom_st_t *)data)->buf, callback ); break; case ACTION_CAM_CapImageWithThumbNail: ///< Capture camera image with thumbnail, use HAL_CAM_Action_capture_image_with_thumbnail_st_t to enable result = CAM_CapImageWithThumbNail( ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->size, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->format, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->sensor, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->buf, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->thumbnail_width, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->thumbnail_height, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->thumbnail_format, ((HAL_CAM_Action_capture_image_with_thumbnail_st_t *)data)->thumbnail_buf, callback ); break; case ACTION_CAM_CapVideoWithViewFinder: ///< Start camera video capture with viewfinder, use HAL_CAM_Action_capture_video_with_viewfinder_st_t to enable result = CAM_CapVideoWithViewfinder( ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->size, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->format, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->sensor, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->buf0, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->buf1,((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->viewfinder_size, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->viewfinder_format, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->viewfinder_buf0, ((HAL_CAM_Action_capture_video_with_viewfinder_st_t *)data)->viewfinder_buf1, callback ); break; case ACTION_CAM_StopCapture: ///< Stop video or image capture, no additional parameters result = CAM_StopCapture(); break; case ACTION_CAM_PauseCapture: ///< Pause viewfinder, video capture, no additional parameters result = CAM_PauseCapture(); break; case ACTION_CAM_ResumeCapture: ///< Resume viewfinder, video capture, no additional parameters result = CAM_ResumeCapture(); break; // Operation Control Settings case ACTION_CAM_SetWindowScale: ///< Set the Camera window size and scale factors, use HAL_CAM_Action_window_scale_st_t to set result = CAM_SetWindowScale( (CamImageSize_t)((HAL_CAM_Action_window_scale_st_t *)data)->size, (UInt32)((HAL_CAM_Action_window_scale_st_t *)data)->start_pixel, (UInt32)((HAL_CAM_Action_window_scale_st_t *)data)->end_pixel, (UInt32)((HAL_CAM_Action_window_scale_st_t *)data)->start_line, (UInt32)((HAL_CAM_Action_window_scale_st_t *)data)->end_line, (UInt32)((HAL_CAM_Action_window_scale_st_t *)data)->horizontal_SDF, (UInt32)((HAL_CAM_Action_window_scale_st_t *)data)->vertical_SDF ); break; case ACTION_CAM_SetZoom: ///< Set required zoom, use (UInt16) HAL_CAM_Action_param_st_t to set result = CAM_SetZoom( (UInt16)(((HAL_CAM_Action_param_st_t *)data)->param) ); break; case ACTION_CAM_GetMaxWindowSize: ///< Camera Maximum Pixel Window size, use HAL_CAM_Action_window_st_t to get pSensorIntfConfig = CAM_GetCameraInterface( ((HAL_CAM_Action_window_st_t *)data)->sensor ); ((HAL_CAM_Action_window_st_t *)data)->width = pSensorIntfConfig->sensor_config_caps->output_st.max_width; ((HAL_CAM_Action_window_st_t *)data)->height = pSensorIntfConfig->sensor_config_caps->output_st.max_height; break; case ACTION_CAM_GetMaxZoom: ///< Get maximum zoom allowed, use (UInt16) HAL_CAM_Action_param_st_t to get #if defined(SS_2153) && defined(BROOKLYN_HW) ((HAL_CAM_Action_param_st_t *)data)->param = (UInt16)CAM_GetMaxZoom(); #else ((HAL_CAM_Action_param_st_t *)data)->param = (UInt16)CAM_GetMaxZoom(((HAL_CAM_Action_param_st_t *)data)->sensor); #endif break; // Flash Settings case ACTION_CAM_SetFlashEnable: ///< Set flash enable TRUE/FALSE, use (Boolean) HAL_CAM_Action_param_st_t to set result = CAM_SetFlashEnable(*((Boolean*)((HAL_CAM_Action_param_st_t *)data)->param) ); break; // Register Callback case ACTION_CAM_SetESD_CB: ///< ESD callback setting result = CAM_SetEsdCb((((HAL_CAM_Action_param_st_t *)data)->param), ((HAL_CAM_Action_param_st_t *)data)->sensor ); break; #endif // Resolution not handled by all camera device drivers #if 0 case ACTION_CAM_GetSensorResolution: ///< Get matching image size from passed pixel width and height, use HAL_CAM_Action_image_size_st_t to get CamImageSize_t result = CAMDRV_GetResolution(((HAL_CAM_Action_resolution_st_t *)data)->size, ((HAL_CAM_Action_resolution_st_t *)data)->mode, ((HAL_CAM_Action_resolution_st_t *)data)->sensor, ((HAL_CAM_Action_resolution_st_t *)data)->sensor_size); break; #endif // *** Actions for Camera Sensor Driver Only *** (No baseband control, handled by camera device driver) // Default: CAMDRV_xxx() Functions // ********************************************************************************************************* // ********************************************************************************************************* // *** All other Customer Defined Actions: Handled by camera device driver only default: pr_debug("HAL_CAM_Ctrl(): HAL_CAMDRV_Ctrl(): \r\n"); result = CAMDRV_ActionCtrl(action, data, callback); if (result != RESULT_OK) { pr_debug("HAL_CAM_Ctrl(): HAL_CAMDRV_Ctrl(): ERROR: Invalid Action=%d \r\n", action); } break; } switch (result) { case CAM_UNSUPPORTED: hal_result = HAL_CAM_ERROR_ACTION_NOT_SUPPORTED; break; case CAM_FAILED: hal_result = HAL_CAM_ERROR_INTERNAL_ERROR; break; case RESULT_DONE: hal_result = HAL_CAM_SUCCESS; break; case RESULT_OK: hal_result = HAL_CAM_SUCCESS; break; default: hal_result = HAL_CAM_ERROR_ACTION_NOT_SUPPORTED; break; } #if 0 // Release Hal Cam Action Semaphore OSSEMAPHORE_Release(sHalCamActionSema); #endif return hal_result; }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //HAL_AUDIO_Ctrl // Client call this function to execute audio HAL functions. // This function for the message to worker thread to do actual work //---------------------------------------------------------------- Result_t AUDIO_Ctrl_Trigger( BRCM_AUDIO_ACTION_en_t action_code, void *arg_param, void *callback, int block ) { TMsgAudioCtrl msgAudioCtrl; Result_t status = RESULT_OK; unsigned int len; OSStatus_t osStatus; { //BRCM_AUDIO_Control_Params_un_t *paudioControlParam = (BRCM_AUDIO_Control_Params_un_t *)arg_param; DEBUG("AudioHalThread action=%d\r\n", action_code); } msgAudioCtrl.action_code = action_code; if(arg_param) memcpy(&msgAudioCtrl.param, arg_param, sizeof(BRCM_AUDIO_Control_Params_un_t)); else memset(&msgAudioCtrl.param, 0, sizeof(BRCM_AUDIO_Control_Params_un_t)); msgAudioCtrl.pCallBack = callback; msgAudioCtrl.block = block; len = kfifo_in_locked(&sgThreadData.m_pkfifo, (unsigned char *)&msgAudioCtrl, sizeof(TMsgAudioCtrl), &sgThreadData.m_lock); if(len != sizeof(TMsgAudioCtrl)) { DEBUG("Error AUDIO_Ctrl_Trigger len=%d expected %d \n", len, sizeof(TMsgAudioCtrl)); return RESULT_ERROR; } queue_work(sgThreadData.pWorkqueue_AudioControl, &sgThreadData.mwork); if(block) { // wait for 10sec osStatus = OSSEMAPHORE_Obtain(sgThreadData.action_complete,1280); if(osStatus != OSSTATUS_SUCCESS) { DEBUG("AUDIO_Ctrl_Trigger Timeout=%d\r\n",osStatus); } while(1) { //wait for output from output fifo len = kfifo_out_locked(&sgThreadData.m_pkfifo_out, (unsigned char *)&msgAudioCtrl, sizeof(TMsgAudioCtrl), &sgThreadData.m_lock_out); if( (len != sizeof(TMsgAudioCtrl)) && (len!=0) ) DEBUG("Error AUDIO_Ctrl_Trigger len=%d expected %d in=%d, out=%d\n", len, sizeof(TMsgAudioCtrl), sgThreadData.m_pkfifo_out.in, sgThreadData.m_pkfifo_out.out); if(len == 0) //FIFO empty sleep return status; if(arg_param) memcpy(arg_param,&msgAudioCtrl.param, sizeof(BRCM_AUDIO_Control_Params_un_t)); else memset(arg_param, 0, sizeof(BRCM_AUDIO_Control_Params_un_t)); } } return status; }