RDK Documentation (Open Sourced RDK Components)
dsHost.cpp
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 
21 
22 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup rpc
26 * @{
27 **/
28 
29 
30 #include <stdio.h>
31 #include <string.h>
32 #include "dsRpc.h"
33 #include "dsMgr.h"
34 #include "dsError.h"
35 #include "dsTypes.h"
36 #include "iarmUtil.h"
37 #include "libIARM.h"
38 #include "libIBus.h"
39 #include "dsHost.h"
40 
41 #include "safec_lib.h"
42 
44 {
45  _DEBUG_ENTER();
46 
48  param.mode = mode;
49  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
50  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
51  (char *)IARM_BUS_DSMGR_API_dsSetPreferredSleepMode,
52  (void *)&param,
53  sizeof(param));
54  if (IARM_RESULT_SUCCESS == rpcRet)
55  {
56  return dsERR_NONE;
57  }
58 
59  return dsERR_GENERAL ;
60 
61 }
62 
64 {
65  _DEBUG_ENTER();
66 
68 
69  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
70 
71  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
72  (char *)IARM_BUS_DSMGR_API_dsGetPreferredSleepMode,
73  (void *)&param,
74  sizeof(param));
75 
76  if (IARM_RESULT_SUCCESS != rpcRet)
77  {
78  return dsERR_GENERAL ;
79  }
80 
81  *mode = param.mode;
82 
83  return dsERR_NONE;
84 
85 }
86 
87 
88 dsError_t dsGetCPUTemperature(float *cpuTemperature)
89 {
90  _DEBUG_ENTER();
91 
92  dsCPUThermalParam param;
93 
94  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
95 
96  param.temperature = 0.0;
97 
98  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
99  (char *)IARM_BUS_DSMGR_API_dsGetCPUTemperature,
100  (void *)&param,
101  sizeof(param));
102 
103  if (IARM_RESULT_SUCCESS != rpcRet)
104  {
105  return dsERR_GENERAL ;
106  }
107 
108  *cpuTemperature = param.temperature;
109 
110  return dsERR_NONE;
111 }
112 
113 
114 dsError_t dsGetVersion(uint32_t *versionNumber)
115 {
116  _DEBUG_ENTER();
117 
118  dsVesrionParam param;
119 
120  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
121 
122  param.versionNumber = 0x10000;
123 
124  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
125  (char *)IARM_BUS_DSMGR_API_dsGetVersion,
126  (void *)&param,
127  sizeof(param));
128 
129  if (IARM_RESULT_SUCCESS != rpcRet)
130  {
131  return dsERR_GENERAL ;
132  }
133 
134  *versionNumber = param.versionNumber;
135 
136  return dsERR_NONE;
137 }
138 
139 dsError_t dsSetVersion(uint32_t versionNumber)
140 {
141  _DEBUG_ENTER();
142 
143  dsVesrionParam param;
144 
145  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
146 
147  param.versionNumber = versionNumber;
148 
149  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
150  (char *)IARM_BUS_DSMGR_API_dsSetVersion,
151  (void *)&param,
152  sizeof(param));
153 
154  if (IARM_RESULT_SUCCESS != rpcRet)
155  {
156  return dsERR_GENERAL ;
157  }
158 
159  return dsERR_NONE;
160 }
161 
163 {
164  errno_t rc = -1;
165  _DEBUG_ENTER();
166 
168 
169  param.result = dsERR_NONE;
170 
171  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
172 
173  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
174  (char *)IARM_BUS_DSMGR_API_dsGetSocIDFromSDK,
175  (void *)&param,
176  sizeof(param));
177 
178  if (IARM_RESULT_SUCCESS != rpcRet)
179  {
180  return dsERR_GENERAL ;
181  }
182  rc = strcpy_s(socID,sizeof(param.socID),param.socID);
183  if(rc!=EOK)
184  {
185  ERR_CHK(rc);
186  }
187  return dsERR_NONE;
188 
189 }
190 
191 dsError_t dsGetHostEDID( unsigned char *edid, int *length)
192 {
193  errno_t rc = -1;
194  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
195 
196  _DEBUG_ENTER();
197 
199  printf("dsCLI::getHostEDID \r\n");
200 
201  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
202  (char *)IARM_BUS_DSMGR_API_dsGetHostEDID,
203  (void *)&param,
204  sizeof(param));
205 
206  if (IARM_RESULT_SUCCESS == rpcRet)
207  {
208  if (param.result == dsERR_NONE) {
209  printf("dsCLI ::getHostEDID returns %d bytes\r\n", param.length);
210  rc = memcpy_s((void *)edid,param.length, param.bytes, param.length);
211  if(rc!=EOK)
212  {
213  ERR_CHK(rc);
214  }
215  *length = param.length;
216  return dsERR_NONE;
217  }
218  else {
219  return (dsError_t)param.result;
220  }
221  }
222  else {
223  return dsERR_GENERAL;
224  }
225 }
226 
227 /** @} */
228 /** @} */
dsSetVersion
dsError_t dsSetVersion(uint32_t versionNumber)
Allows the application to set the runtime version of the dsHAL.
Definition: dsHost.cpp:139
dsSleepMode_t
enum _dsSleepMode_t dsSleepMode_t
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
dsTypes.h
Device Settings HAL types.
_dsCPUThermalParam
Definition: dsRpc.h:694
dsError.h
Device Settings HAL error codes.
dsGetCPUTemperature
dsError_t dsGetCPUTemperature(float *cpuTemperature)
This function gets the CPU temperature in centrigade.
Definition: dsHost.cpp:88
dsERR_GENERAL
@ dsERR_GENERAL
Definition: dsError.h:86
dsGetPreferredSleepMode
dsError_t dsGetPreferredSleepMode(dsSleepMode_t *mode)
This function returns the preferred sleep mode which is persisted.
Definition: dsHost.cpp:63
dsSetPreferredSleepMode
dsError_t dsSetPreferredSleepMode(dsSleepMode_t mode)
This function sets the preferred sleep mode which needs to be persisted.
Definition: dsHost.cpp:43
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
_dsDisplayGetEDIDBytesParam_t
Definition: dsRpc.h:613
libIBus.h
RDK IARM-Bus API Declarations.
dsGetHostEDID
dsError_t dsGetHostEDID(unsigned char *edid, int *length)
This function is used to get the host EDID and length.
Definition: dsHost.cpp:191
_dsPreferredSleepMode
Definition: dsRpc.h:689
dsGetVersion
dsError_t dsGetVersion(uint32_t *versionNumber)
Get DS HAL API Version.
Definition: dsHost.cpp:114
_dsVesrionParam
Definition: dsRpc.h:699
dsGetSocIDFromSDK
dsError_t dsGetSocIDFromSDK(char *socID)
This function returns SOC ID.
Definition: dsHost.cpp:162
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
_dsGetSocIDFromSDKParam_t
Definition: dsRpc.h:877