40 #include "ccec/drivers/hdmi_cec_driver.h"
41 #include "ccec/drivers/iarmbus/CecIARMBusMgr.h"
42 #include "safec_lib.h"
44 #define CECDriverAssert(cond) do\
47 printf("Assert Failed at [%s][%d]\r\n", __FUNCTION__, __LINE__);\
62 pthread_mutex_t DriverMutex = PTHREAD_MUTEX_INITIALIZER;
63 #define DRIVER_LOCK() do{ pthread_mutex_lock(&DriverMutex);}while(0)
64 #define DRIVER_UNLOCK() do{pthread_mutex_unlock(&DriverMutex);}while(0)
66 static void cecRecvEventHandler(
const char *owner, IARM_EventId_t eventId,
void *data,
size_t len);
71 int retErr = HDMI_CEC_IO_SUCCESS;
76 printf(
"Sending SYNC ENABLE to Daemon\r\n");
77 IARM_Result_t ret = IARM_RESULT_SUCCESS;
79 memset(&data, 0,
sizeof(data));
83 printf(
"Sending ASYNC ENABLE to Daemon\r\n");
84 IARM_Result_t ret = IARM_RESULT_SUCCESS;
86 memset(&data, 0,
sizeof(data));
95 *handle = (int)driverCtx;
96 retErr = HDMI_CEC_IO_SUCCESS;
99 retErr = HDMI_CEC_IO_INVALID_STATE;
109 CECDriverAssert(handle == ((
int)driverCtx));
111 int retErr = HDMI_CEC_IO_SUCCESS;
112 if (driverCtx != 0) {
115 printf(
"Sending SYNC DISABLE to Daemon\r\n");
116 IARM_Result_t ret = IARM_RESULT_SUCCESS;
118 memset(&data, 0,
sizeof(data));
122 printf(
"Sending ASYNC DISABLE to Daemon\r\n");
123 IARM_Result_t ret = IARM_RESULT_SUCCESS;
125 memset(&data, 0,
sizeof(data));
135 retErr = HDMI_CEC_IO_SUCCESS;
138 retErr = HDMI_CEC_IO_INVALID_STATE;
149 CECDriverAssert(handle == ((
int)driverCtx));
150 int retErr = HDMI_CEC_IO_SUCCESS;
154 IARM_Result_t ret = IARM_RESULT_SUCCESS;
157 memset(&data, 0,
sizeof(data));
158 data.logicalAddress = logicalAddresses;
161 if( IARM_RESULT_SUCCESS != ret)
164 retErr = HDMI_CEC_IO_INVALID_STATE;
175 return HDMI_CEC_IO_SUCCESS;
182 CECDriverAssert(handle == ((
int)driverCtx));
183 int retErr = HDMI_CEC_IO_SUCCESS;
187 IARM_Result_t ret = IARM_RESULT_SUCCESS;
190 memset(&data, 0,
sizeof(data));
191 data.devType = devType;
194 if( IARM_RESULT_SUCCESS != ret)
197 retErr = HDMI_CEC_IO_INVALID_STATE;
201 *logicalAddresses = data.logicalAddress;
214 CECDriverAssert(handle == ((
int)driverCtx));
215 int retErr = HDMI_CEC_IO_SUCCESS;
219 IARM_Result_t ret = IARM_RESULT_SUCCESS;
222 memset(&data, 0,
sizeof(data));
225 if( IARM_RESULT_SUCCESS != ret)
228 retErr = HDMI_CEC_IO_INVALID_STATE;
232 *physicalAddresses = data.physicalAddress;
245 CECDriverAssert(handle == ((
int)driverCtx));
247 driverCtx->rxCB = cbfunc;
248 driverCtx->rxCBdata = data;
252 return HDMI_CEC_IO_SUCCESS;
258 CECDriverAssert(handle == ((
int)driverCtx));
260 driverCtx->txCB = cbfunc;
261 driverCtx->txCBdata = data;
265 return HDMI_CEC_IO_SUCCESS;
271 CECDriverAssert(handle == ((
int)driverCtx));
274 memset(&dataToSend, 0,
sizeof(dataToSend));
275 dataToSend.length = len;
276 MEMCPY_S(dataToSend.data,
sizeof(dataToSend.data), buf, len);
281 return HDMI_CEC_IO_SUCCESS;
284 int HdmiCecTx(
int handle,
const unsigned char *buf,
int len,
int *result)
287 CECDriverAssert(handle == ((
int)driverCtx));
288 IARM_Result_t ret = IARM_RESULT_SUCCESS;
291 memset(&dataToSend, 0,
sizeof(dataToSend));
292 dataToSend.length = len;
293 MEMCPY_S(dataToSend.data,
sizeof(dataToSend.data), buf, len);
295 if( IARM_RESULT_SUCCESS != ret)
299 return HDMI_CEC_IO_INVALID_STATE;
301 *result = dataToSend.retVal;
305 return HDMI_CEC_IO_SUCCESS;
309 static void cecRecvEventHandler(
const char *owner, IARM_EventId_t eventId,
void *data,
size_t len)
314 if (driverCtx->rxCB) {
317 driverCtx->rxCB((
int)driverCtx, driverCtx->rxCBdata, cecEventData->data, cecEventData->length);