39 #include <sys/types.h>
51 #include "CecIARMBusMgr.hpp"
53 #include "ccec/drivers/iarmbus/CecIARMBusMgr.h"
55 #include "ccec/CCEC.hpp"
56 #include "ccec/Assert.hpp"
57 #include "ccec/Connection.hpp"
58 #include "ccec/MessageDecoder.hpp"
59 #include "ccec/MessageProcessor.hpp"
61 #include "ccec/Util.hpp"
62 #include "ccec/driver/hdmi_cec_driver.h"
68 #define HEADER_OFFSET 0
69 #define OPCODE_OFFSET 1
75 static IARM_Result_t
_Send(
void *arg);
78 static IARM_Result_t _GetPhysicalAddress(
void *arg);
79 static IARM_Result_t
_Enable(
void *arg);
80 static IARM_Result_t _IsAvailable(
void *arg);
101 int hdmi_hotplug_event = eventData->data.hdmi_hpd.event;
102 CCEC_LOG( LOG_DEBUG,
"I-ARM CEC Mgr:: Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event);
105 CCEC_LOG(
LOG_INFO,
"I-ARM CEC Mgr:: no Closing soc driver due to HDMI disconnect event.\r\n");
111 CCEC_LOG( LOG_EXP,
"I-ARM CEC Mgr:: Caught Exception while calling LibCCEC::term()\r\n");
117 CCEC_LOG(
LOG_INFO,
"I-ARM CEC Mgr:: no Opening soc driver on receiving HDMI connect event\r\n");
125 CCEC_LOG( LOG_EXP,
"I-ARM CEC Mgr:: Caught Exception while calling LibCCEC::init()\r\n");
156 frameIn.append(cecEventData->data, cecEventData->length);
158 CCEC_LOG( LOG_DEBUG,
"cecSendEventHandler sending >>>>>>\r\n");
159 ((
Connection *)m_connection)->sendAsync(frameIn);
179 if (cecEventData->length == 1) {
182 param.enabled = cecEventData->data[0];
198 void notify(
const CECFrame &in)
const {
202 char strBuffer[50] = {0};
203 const char *opname =
"none";
204 Header header(in,HEADER_OFFSET);
205 memset(&dataRcvd, 0,
sizeof(dataRcvd));
206 if (in.length() <= IARM_BUS_CECMGR_MAX_DATA_LENGTH) {
207 dataRcvd.length = in.length();
208 memcpy(dataRcvd.data, in.getBuffer(), in.length());
209 for (
int i = 0; i< in.length(); i++)
211 snprintf(strBuffer + strlen(strBuffer) , (
sizeof(strBuffer) - strlen(strBuffer)) \
212 ,
"%02X ",(uint8_t) *(dataRcvd.data + i));
214 if (in.length() > OPCODE_OFFSET) {
215 opname = GetOpName(
OpCode(in,OPCODE_OFFSET).opCode());
216 CCEC_LOG(
LOG_INFO,
"%s to %s : opcode: %s :%s \n",header.from.toString().c_str(), \
217 header.to.toString().c_str(), opname, strBuffer);
219 CCEC_LOG( LOG_DEBUG,
"Broadcasting msg on IARMBus\r\n");
251 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
266 memset(&initData, 0,
sizeof(initData));
268 if(IARM_RESULT_SUCCESS != retVal)
270 CCEC_LOG( LOG_ERROR,
"IARM Broadcast event failed at %s error code : %d \r\n", __FUNCTION__, retVal);
273 return IARM_RESULT_SUCCESS;
285 return IARM_RESULT_SUCCESS;
298 if (started)
return IARM_RESULT_INVALID_STATE;
304 connection =
new Connection(LogicalAddress::UNREGISTERED,
false,
"CECIARMMgr::Connection::");
309 m_connection = connection;
312 return IARM_RESULT_SUCCESS;
328 CCEC_LOG( LOG_WARN,
"I-ARM CEC Mgr: HeartBeat at %s\r\n", ctime(&curr));
331 return IARM_RESULT_SUCCESS;
345 if (!started)
return IARM_RESULT_INVALID_STATE;
351 delete frameListener;
366 return IARM_RESULT_SUCCESS;
377 static IARM_Result_t
_Send(
void *arg)
381 const uint8_t *buf = NULL;
382 char strBuffer[50] = {0};
384 const char *opname =
"none";
385 frameIn.append(param->data,param->length);
386 frameIn.getBuffer(&buf, &len);
387 Header header(frameIn,HEADER_OFFSET);
388 for (
int i = 0; i < len; i++) {
389 snprintf(strBuffer + strlen(strBuffer) , (
sizeof(strBuffer) - strlen(strBuffer)) \
390 ,
"%02X ",(uint8_t) *(buf + i));
392 if (frameIn.length() > OPCODE_OFFSET) {
393 opname = GetOpName(
OpCode(frameIn,OPCODE_OFFSET).opCode());
394 CCEC_LOG(
LOG_INFO,
"%s to %s : opcode: %s :%s\n",header.from.toString().c_str(), \
395 header.to.toString().c_str(), opname, strBuffer);
401 param->retVal = HDMI_CEC_IO_SENT_AND_ACKD;
406 param->retVal = HDMI_CEC_IO_SENT_BUT_NOT_ACKD;
411 param->retVal = HDMI_CEC_IO_SENT_FAILED;
416 CCEC_LOG( LOG_DEBUG,
"Connection not ready >>>>>>\r\n");
417 return IARM_RESULT_INVALID_STATE;
419 return IARM_RESULT_SUCCESS;
433 IARM_Result_t retCode = IARM_RESULT_SUCCESS;
436 CCEC_LOG( LOG_DEBUG,
"Inside _GetLogicalAddress : for DevType : %d >>>>>>\r\n",param->devType);
442 CCEC_LOG(LOG_EXP,
"_GetLogicalAddress caught %s \r\n",e.what());
443 retCode = IARM_RESULT_INVALID_STATE;
446 CCEC_LOG( LOG_DEBUG,
"Inside _GetLogicalAddress : Logical Address : %d >>>>>>\r\n",param->logicalAddress);
462 IARM_Result_t retCode = IARM_RESULT_SUCCESS;
466 CCEC_LOG( LOG_DEBUG,
"Inside _AddLogicalAddress : for logicalAddress : %d >>>>>>\r\n",param->logicalAddress);
472 CCEC_LOG(LOG_EXP,
"_AddLogicalAddress caught %s \r\n",e.what());
473 retCode = IARM_RESULT_INVALID_STATE;
476 CCEC_LOG( LOG_DEBUG,
"Inside _AddLogicalAddress : Logical Address : %d >>>>>>\r\n",param->logicalAddress);
482 static IARM_Result_t _GetPhysicalAddress(
void *arg)
484 IARM_Result_t retCode = IARM_RESULT_SUCCESS;
487 CCEC_LOG( LOG_DEBUG,
"Inside _GetPhysicalAddress : >>>>>>\r\n");
493 CCEC_LOG(LOG_EXP,
"_GetPhysicalAddress caught %s \r\n",e.what());
494 retCode = IARM_RESULT_INVALID_STATE;
497 CCEC_LOG( LOG_DEBUG,
"Inside _GetPhysicalAddress : Physical Address : %x >>>>>>\r\n",param->physicalAddress);
512 IARM_Result_t retCode = IARM_RESULT_SUCCESS;
516 CCEC_LOG(
LOG_INFO,
"Inside _Enable : %d, %d >>>>>>\r\n", enabled, param->enabled);
518 enabled = param->enabled;
520 if (param->enabled) {
530 IARM_Result_t _IsAvailable(
void *arg)
532 CCEC_LOG( LOG_ERROR,
"[%s:%d] IARM_BUS_CECMGR_API_isAvailable is called",__FUNCTION__,__LINE__ );
533 return IARM_RESULT_SUCCESS;