RDK Documentation (Open Sourced RDK Components)
iarmcec.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #include <string.h>
21 #include "comcastIrKeyCodes.h"
22 #include "libIBus.h"
23 #include "videoOutputPort.hpp"
24 #include "host.hpp"
25 #include "CecIARMBusMgr.h"
26 #include "iarmcec.h"
27 #include "safec_lib.h"
28 
29 bool IARMCEC_SendCECActiveSource(bool bCecLocalLogic, int keyType, int keyCode)
30 {
31  errno_t rc = -1;
32  bool status = 0;
33  IARM_Result_t ret = IARM_RESULT_SUCCESS;
35  unsigned char buf[4] = {0x0F, 0x82, 0x00, 0x00}; //Active source event opcode 0x82
36 
37  if(bCecLocalLogic && (keyType == KET_KEYDOWN) && (keyCode == KED_MENU))
38  {
39  //get and update logical address in buf
41  memset(&data, 0, sizeof(data));
42  data.devType = 1;
43  ret = IARM_Bus_Call(IARM_BUS_CECMGR_NAME,IARM_BUS_CECMGR_API_GetLogicalAddress,(void *)&data, sizeof(data));
44  if( IARM_RESULT_SUCCESS == ret)
45  {
46  buf[0] |= data.logicalAddress << 4;
47  //get and update physical address in buf
48  uint8_t physAddress[4] = {0xF,0xF,0xF,0xF};
49  try
50  {
52  if (vPort.isDisplayConnected())
53  {
54  vPort.getDisplay().getPhysicallAddress(physAddress[0],physAddress[1],physAddress[2],physAddress[3]);
55  buf[2] |= ((physAddress[0] << 4)|(physAddress[1]));
56  buf[3] |= ((physAddress[2] << 4)|(physAddress[3]));
57 
58  memset(&dataToSend, 0, sizeof(dataToSend));
59  dataToSend.length = 4;
60  rc = memcpy_s(dataToSend.data,sizeof(dataToSend.data), buf, dataToSend.length);
61  if(rc!=EOK)
62  {
63  ERR_CHK(rc);
64  }
65  ret = IARM_Bus_Call(IARM_BUS_CECMGR_NAME,IARM_BUS_CECMGR_API_Send,(void *)&dataToSend, sizeof(dataToSend));
66  if( IARM_RESULT_SUCCESS == ret)
67  {
68  LOG("%s: send CEC ActiveSource buf:%x:%x:%x:%x\r\n",__FUNCTION__,buf[0],buf[1],buf[2],buf[3]);
69  if(!vPort.isActive())
70  status = true;
71  }
72  else
73  {
74  LOG("%s: Failed to send CEC ActiveSource ret:%d \r\n",__FUNCTION__,ret);
75  }
76  }
77  }
78  catch(const std::exception e)
79  {
80  LOG("%s: failed to get physAddress\r\n",__FUNCTION__);
81  }
82  }
83  else
84  {
85  LOG("%s failed to get logicalAddress\r\n",__FUNCTION__);
86  }
87  }
88  return status;
89 }
90 
91 bool IARMCEC_SendCECImageViewOn(bool bCecLocalLogic)
92 {
93  errno_t rc = -1;
94  bool status = 0;
95  IARM_Result_t ret = IARM_RESULT_SUCCESS;
97  unsigned char buf[2] = {0x00, 0x04}; //Image view on event opcode 0x04
98 
99  if(bCecLocalLogic)
100  {
101  //get and update logical address in buf
103  memset(&data, 0, sizeof(data));
104  data.devType = 1;
105  ret = IARM_Bus_Call(IARM_BUS_CECMGR_NAME,IARM_BUS_CECMGR_API_GetLogicalAddress,(void *)&data, sizeof(data));
106  if( IARM_RESULT_SUCCESS == ret)
107  {
108  buf[0] |= data.logicalAddress << 4;
109  //get and update physical address in buf
110 
111  memset(&dataToSend, 0, sizeof(dataToSend));
112  dataToSend.length = 2;
113  rc = memcpy_s(dataToSend.data,sizeof(dataToSend.data), buf, dataToSend.length);
114  if(rc!=EOK)
115  {
116  ERR_CHK(rc);
117  }
118  ret = IARM_Bus_Call(IARM_BUS_CECMGR_NAME,IARM_BUS_CECMGR_API_Send,(void *)&dataToSend, sizeof(dataToSend));
119  if( IARM_RESULT_SUCCESS == ret)
120  {
121  LOG("%s: send CEC ImageViewOn buf:%x:%x\r\n",__FUNCTION__,buf[0],buf[1]);
122  status = true;
123  }
124  }
125  else
126  {
127  LOG("%s failed to get logicalAddress\r\n",__FUNCTION__);
128  }
129  }
130  return status;
131 }
device::VideoOutputPort::isActive
bool isActive() const
This API is used to check if Port is connected to active port of Sink device.
Definition: videoOutputPort.cpp:415
device::VideoOutputPort::Display::getPhysicallAddress
void getPhysicallAddress(uint8_t &physicalAddressA, uint8_t &physicalAddressB, uint8_t &physicalAddressC, uint8_t &physicalAddressD) const
This function gets the physical address of the HDMI node of the video display device.
Definition: videoOutputPort.hpp:196
device::VideoOutputPort::isDisplayConnected
bool isDisplayConnected() const
This API is used to Check if the port is currently connected to any display device.
Definition: videoOutputPort.cpp:381
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
device::VideoOutputPort
Class extending enumerable to implement the videoooutputport interface.
Definition: videoOutputPort.hpp:59
IARM_BUS_CECMGR_NAME
#define IARM_BUS_CECMGR_NAME
Definition: CecIARMBusMgr.h:41
device::VideoOutputPort::getDisplay
const VideoOutputPort::Display & getDisplay()
This API is used to get the display device information currently connected to the output port....
Definition: videoOutputPort.cpp:328
IARMCEC_SendCECActiveSource
bool IARMCEC_SendCECActiveSource(bool bCecLocalLogic, int keyType, int keyCode)
Utility function to send ActiveSource CEC event to TV.
Definition: iarmcec.c:29
libIBus.h
RDK IARM-Bus API Declarations.
IARMCEC_SendCECImageViewOn
bool IARMCEC_SendCECImageViewOn(bool bCecLocalLogic)
Utility function to send ImageViewOn CEC event to TV.
Definition: iarmcec.c:91
videoOutputPort.hpp
It contains class and structure refrenced by the videooutputport.cpp file.
keyType
Definition: reset.c:85
device::Host::getVideoOutputPort
VideoOutputPort & getVideoOutputPort(const std::string &name)
This API is used to get the reference to the video output port by its name. The name of the port must...
Definition: host.cpp:350
device::Host::getInstance
static Host & getInstance(void)
This API is used to get a reference to the single instance of the Host object.
Definition: host.cpp:88
_IARM_Bus_CECMgr_GetLogicalAddress_Param_t
Definition: CecIARMBusMgr.h:77
_IARM_Bus_CECMgr_Send_Param_t
Definition: CecIARMBusMgr.h:71