RDK Documentation (Open Sourced RDK Components)
dsDisplay.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 
21 
22 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup rpc
26 * @{
27 **/
28 
29 
30 #include "dsDisplay.h"
31 #include "dsclientlogger.h"
32 #include <sys/types.h>
33 #include <stdint.h>
34 #include <string.h>
35 #include "dsError.h"
36 #include "dsUtl.h"
37 #include "dsRpc.h"
38 #include "dsMgr.h"
39 #include "iarmUtil.h"
40 #include "libIARM.h"
41 #include "libIBus.h"
42 #include "dsTypes.h"
43 #include "stdlib.h"
44 
45 #include "safec_lib.h"
46 
48 {
49  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
50 
51  printf("<<<<< VDISP is initialized in Multi-App Mode >>>>>>>>\r\n");
52 
53  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
54  (char *)IARM_BUS_DSMGR_API_dsDisplayInit,
55  NULL,
56  0);
57 
58  if (IARM_RESULT_SUCCESS == rpcRet)
59  {
60  return dsERR_NONE;
61  }
62  return dsERR_GENERAL;
63 }
64 
65 dsError_t dsGetDisplay(dsVideoPortType_t vType, int index, intptr_t *handle)
66 {
67 
68  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
69  _DEBUG_ENTER();
70  _RETURN_IF_ERROR((handle) != NULL, dsERR_INVALID_PARAM);
71 
73 
74  param.type = vType;
75  param.index = index;
76  param.handle = NULL;
77 
78  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
79  (char *)IARM_BUS_DSMGR_API_dsGetDisplay,
80  (void *)&param,
81  sizeof(param));
82 
83  if (IARM_RESULT_SUCCESS == rpcRet)
84  {
85  *handle = param.handle;
86  return dsERR_NONE;
87  }
88 
89  return dsERR_GENERAL ;
90 
91 }
92 
94 {
95  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
96 
97  _DEBUG_ENTER();
98 
100  param.handle = handle;
101 
102 
103 
104  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
105  (char *)IARM_BUS_DSMGR_API_dsGetDisplayAspectRatio,
106  (void *)&param,
107  sizeof(param));
108 
109  if (IARM_RESULT_SUCCESS == rpcRet)
110  {
111  *aspect = param.aspectRatio;
112  return dsERR_NONE;
113  }
114 
115  return dsERR_GENERAL ;
116 
117 }
118 
119 dsError_t dsGetEDID(intptr_t handle, dsDisplayEDID_t *edid)
120 {
121  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
122 
123  _DEBUG_ENTER();
124 
126 
127  memset(&param,0,sizeof(dsDisplayGetEDIDParam_t));
128  param.handle = handle;
129 
130 
131  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
132  (char *)IARM_BUS_DSMGR_API_dsGetEDID,
133  (void *)&param,
134  sizeof(param));
135  errno_t rc = -1;
136  rc = memcpy_s(edid,sizeof(dsDisplayEDID_t), &param.edid, sizeof(param.edid));
137  if(rc!=EOK)
138  {
139  ERR_CHK(rc);
140  }
141  if (IARM_RESULT_SUCCESS == rpcRet)
142  {
143  return dsERR_NONE;
144  }
145 
146  return dsERR_GENERAL ;
147 }
148 
149 dsError_t dsGetEDIDBytes(intptr_t handle, unsigned char **edid, int *length)
150 {
151  errno_t rc = -1;
152  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
153 
154  _DEBUG_ENTER();
155 
157 
158  param.handle = handle;
159 
160  printf("dsCLI::getEDIDBytes \r\n");
161 
162  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
163  (char *)IARM_BUS_DSMGR_API_dsGetEDIDBytes,
164  (void *)&param,
165  sizeof(param));
166 
167  if (IARM_RESULT_SUCCESS == rpcRet)
168  {
169  if (param.result == dsERR_NONE) {
170  printf("dsCLI ::getEDIDBytes returns %d bytes\r\n", param.length);
171  *edid = (unsigned char *)malloc(param.length);
172  if (*edid) {
173  rc = memcpy_s(*edid,param.length, param.bytes, param.length);
174  if(rc!=EOK)
175  {
176  ERR_CHK(rc);
177  }
178  *length = param.length;
179  return dsERR_NONE;
180  }
181  else {
182  return dsERR_GENERAL;
183  }
184  }
185  else {
186  return (dsError_t)param.result;
187  }
188  }
189  else {
190  return dsERR_GENERAL;
191  }
192 }
193 
195 {
196  _DEBUG_ENTER();
197 
198  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
199 
200  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
201  (char *)IARM_BUS_DSMGR_API_dsDisplayTerm,
202  NULL,
203  0);
204 
205  if (IARM_RESULT_SUCCESS == rpcRet)
206  {
207  return dsERR_NONE;
208  }
209 
210  return dsERR_GENERAL ;
211 }
212 
213 
214 /** @} */
215 /** @} */
_dsDisplayGetAspectRatioParam_t
Definition: dsRpc.h:597
dsGetDisplayAspectRatio
dsError_t dsGetDisplayAspectRatio(intptr_t handle, dsVideoAspectRatio_t *aspect)
This function gets the aspect ratio for the dsiaply device. This function returns the aspect ratio of...
Definition: dsDisplay.c:93
dsVideoAspectRatio_t
enum _dsVideoAspectRatio_t dsVideoAspectRatio_t
_dsDisplayGetEDIDParam_t
Definition: dsRpc.h:602
dsGetDisplay
dsError_t dsGetDisplay(dsVideoPortType_t vType, int index, intptr_t *handle)
Get the handle of a display device.
Definition: dsDisplay.c:65
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.
dsVideoPortType_t
enum _dsVideoPortType_t dsVideoPortType_t
dsError.h
Device Settings HAL error codes.
dsGetEDIDBytes
dsError_t dsGetEDIDBytes(intptr_t handle, unsigned char **edid, int *length)
This function is used to get the EDID buffer and length of the connected display.
Definition: dsDisplay.c:149
dsUtl.h
Device Settings HAL utilities.
dsGetEDID
dsError_t dsGetEDID(intptr_t handle, dsDisplayEDID_t *edid)
Get the EDID information from the specified display device.
Definition: dsDisplay.c:119
dsERR_GENERAL
@ dsERR_GENERAL
Definition: dsError.h:86
dsDisplayTerm
dsError_t dsDisplayTerm(void)
This function deinitialize the display sub-system. This function deallocates the data structures used...
Definition: dsDisplay.c:194
dsDisplayInit
dsError_t dsDisplayInit()
Initialize the Display sub-system.
Definition: dsDisplay.c:47
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
_dsDisplayGetEDIDBytesParam_t
Definition: dsRpc.h:613
libIBus.h
RDK IARM-Bus API Declarations.
dsDisplay.h
_dsDisplayEDID_t
Defines the structure that is used to get the EDID information of the video display.
Definition: dsTypes.h:901
_dsDisplayGetHandleParam_t
Definition: dsRpc.h:591
dsERR_INVALID_PARAM
@ dsERR_INVALID_PARAM
Definition: dsError.h:87
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84