int cecsenderr(void) { int val; __u8 buf[32]; int cmd_id; cmd_id = cectxcmdid_get(); val = HDMI_CECSENDERR; memcpy(&buf[CMD_OFFSET], &val, 4); memcpy(&buf[CMDID_OFFSET], &cmd_id, 4); val = 0; memcpy(&buf[CMDLEN_OFFSET], &val, 4); /* Send on socket */ return clientsocket_send(buf, CMDBUF_OFFSET + val); }
/* Get current hdcp state */ int hdcp_state(void) { int hdcpstateget; int result = HDCP_OK; int res; __u8 buf[128]; int val; __u32 cmd_id; cmd_id = get_new_cmd_id_ind(); /* Check hdcpstate */ hdcpstateget = open(HDCPSTATEGET_FILE, O_RDONLY); if (hdcpstateget < 0) { LOGHDMILIB("***** Failed to open %s *****", HDCPSTATEGET_FILE); result = SYSFS_FILE_FAILED; goto hdcp_state_end; } res = read(hdcpstateget, buf, sizeof(buf)); close(hdcpstateget); if (res != 1) { LOGHDMILIB("***** %s read error *****", HDCPSTATEGET_FILE); result = HDCPSTATE_FAIL; goto hdcp_state_end; } val = HDMI_HDCPSTATE; memcpy(&buf[CMD_OFFSET], &val, 4); memcpy(&buf[CMDID_OFFSET], &cmd_id, 4); val = 1; memcpy(&buf[CMDLEN_OFFSET], &val, 4); memcpy(&buf[CMDBUF_OFFSET], buf, val); /* Send on socket */ if (clientsocket_send(buf, CMDBUF_OFFSET + val) != 0) result = HDCPSTATE_FAIL; LOGHDMILIB("%s", dbg_hdcpstate(val)); hdcp_state_end: return result; }
/* Read received CEC message and forward on client socket */ int cecrx(void) { int cecreadfd; __u8 buf[32]; __u8 cecdata[32]; int cecsize; int cnt; int val; int res = 0; __u32 cmd_id; LOGHDMILIB("%s begin", __func__); cmd_id = get_new_cmd_id_ind(); cecreadfd = open(CECREAD_FILE, O_RDONLY); if (cecreadfd < 0) { LOGHDMILIBE("***** Failed to open %s *****", CECREAD_FILE); return -1; } cecsize = read(cecreadfd, buf, sizeof(buf)); close(cecreadfd); if (cecsize < 0) return -1; for (cnt = 0; cnt < cecsize; cnt++) LOGHDMILIB2("cecrx[%d]:%x", cnt, buf[cnt]); val = HDMI_CECRECVD; memcpy(&buf[CMD_OFFSET], &val, 4); memcpy(&buf[CMDID_OFFSET], &cmd_id, 4); val = cecsize; memcpy(&buf[CMDLEN_OFFSET], &val, 4); memcpy(&buf[CMDBUF_OFFSET], cecdata, val); /* Send on socket */ res = clientsocket_send(buf, CMDBUF_OFFSET + val); LOGHDMILIB("%s end", __func__); return res; }