NVIDIA DRIVE OS Linux API Reference

5.1.3.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvros_egl_utils.h
Go to the documentation of this file.
1 /*Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
2 
3 NVIDIA CORPORATION and its licensors retain all intellectual property
4 and proprietary rights in and to this software, related documentation
5 and any modifications thereto. Any use, reproduction, disclosure or
6 distribution of this software and related documentation without an express
7 license agreement from NVIDIA CORPORATION is strictly prohibited.*/
8 
9 #ifndef _NVROSEGLUTIL_H_
10 #define _NVROSEGLUTIL_H_
11 
12 #include <EGL/egl.h>
13 #include <EGL/eglext.h>
14 
15 #include "nvmedia_core.h"
16 #include "nvroscommon.h"
17 #include "egl_extensions.h"
18 
19 #include "cuda.h"
20 #include "cudaEGL.h"
21 
34  namespace nvros
35  {
49 typedef enum _ConsumerType
50 {
51 
56 
61 
66 
72 
77 
81 
84 } ConsumerType;
85 
90 typedef enum _ProducerType
91 {
92 
97 
102 
107 
112 
116 
119 } ProducerType;
120 
125 typedef enum _WinSys
126 {
127 
129  X11 = 0,
130 
133 
136 
139 
142 } WinSys;
143 
147 typedef enum _OpMode
148 {
149 
151  MAILBOX = 0,
152 
155 
158 } OpMode;
159 
169 typedef struct _EglUtilOptions
170 {
172  uint8_t winSizeX;
173 
175  uint8_t winSizeY;
176 
178  uint8_t winOffsetX;
179 
181  uint8_t winOffsetY;
182 
184  uint8_t dispId;
185 
187  uint8_t winId;
189 
198 typedef struct _EglUtilState
199 {
204  EGLDisplay display;
205 
210  EGLSurface surface;
211 
216  EGLConfig config;
217 
222  EGLContext context;
223 
225  EGLint width;
226 
228  EGLint height;
229 
231  EGLint xoffset;
232 
234  EGLint yoffset;
235 
237  EGLint displayId;
238 
240  EGLint windowId;
241 } EglUtilState;
242 
251 typedef struct _CudaEglParams {
252 
257  EGLDisplay display;
258 
263  EGLStreamKHR eglStream;
264 
269  CUcontext context;
270 
275  CUeglStreamConnection cuEglConn;
276 } CudaEglParams;
277 
286 
287 public:
300  NvRosEglUtil(ConsumerType cons_type, WinSys win_sys_type, OpMode op_mode);
301 
311  NvRosEglUtil(ProducerType prod_type, WinSys win_sys_type, OpMode op_mode);
312 
316  ~NvRosEglUtil();
317 
328 
343  NvRosErr EglUtilInit(EglUtilOptions* options, EglUtilState* eglUtil);
344 
358  EGLStreamKHR EglStreamInit(EGLDisplay display, const char* socket_path);
359 
370  EGLint GetStreamState(EGLDisplay display, EGLStreamKHR eglStream);
371 
383  NvRosErr InitConsumer(EGLDisplay display, EGLStreamKHR eglStream);
384 
398  NvRosErr InitConsumer(EGLDisplay display, EGLStreamKHR eglStream,
399  CudaEglParams* cudaConsumerParams);
400 
410  NvRosErr EglStreamFinish(EGLDisplay display, EGLStreamKHR eglStream);
411 
422 
423 private:
424  ConsumerType mConsType;
425  ProducerType mProdType;
426  WinSys mWinSys;
427  OpMode mOpMode;
428 
429  typedef struct _EglDeviceState {
430  EGLDeviceEXT egl_dev;
431  int drm_fd;
432  int32_t drm_crtc_id;
433  uint32_t drm_conn_id;
434  EGLStreamKHR egl_str;
435  EGLOutputLayerEXT egl_lyr;
436  } EglDeviceState;
437 
438  EglDeviceState* eglDeviceState;
439 
440  //Private methods
441  NvRosErr EglUtilSetupExtensions();
442  NvRosErr WindowSystemInit(EglUtilState* state);
443  NvRosErr WindowSystemWindowInit(EglUtilState* state);
444  NvRosErr WindowSystemEglSurfaceCreate(EglUtilState* state);
445  NvRosErr GetOutputLayer(EglUtilState* state);
446  NvRosErr WindowSystemTerminate(void);
447  NvRosErr WindowSystemWindowTerminate(EglUtilState* state);
448  EGLStreamKHR InitConsumerEglStream(EGLDisplay display, const char* socket_path);
449  EGLStreamKHR InitProducerEglStream(EGLDisplay display, const char* socket_path);
450  NvRosErr EGLStreamSendFd(const char* socket_name, int fd);
451  int EGLStreamReceiveFd(const char* socket_name);
452  NvRosErr InitEglOutputConsumer(EGLDisplay display, EGLStreamKHR eglStream);
453  NvRosErr InitCudaConsumer(EGLDisplay display, EGLStreamKHR eglStream,
454  CudaEglParams* cudaCondumerParams);
455  NvRosErr DeInitCudaConsumer(CudaEglParams* cudaConsParams);
456 
457 };
459 }
460 #endif
No window system.
_ConsumerType
Declares all EGL consumer types supported by NvMedia EGLStream library.
struct nvros::_EglUtilState EglUtilState
Holds EGL related parameters.
NvRosErr EglStreamFinish(EGLDisplay display, EGLStreamKHR eglStream)
Closes the EGLStream that is set up by the same NvRosEglUtil object.
enum nvros::_WinSys WinSys
Declares all window systems supported by NvMedia EGLStream library.
uint8_t winOffsetX
Offset of window in the horizontal direction.
Video producer.
_WinSys
Declares all window systems supported by NvMedia EGLStream library.
X11 window system.
NvRosEglUtil(ConsumerType cons_type, WinSys win_sys_type, OpMode op_mode)
Instantiates NvRosEglUtil class for the EGL consumer role.
CUcontext context
Handle to the CUDA context.
EGLDisplay display
Handle to the EGLDisplay.
struct nvros::_EglUtilOptions EglUtilOptions
Holds required window system related parameters when initializing EGLStream.
Class to initialize the EGLStream for the following roles: EGLOUTPUT_CONSUMER, CUDA_CONSUMER, CUDA_PRODUCER, IMAGE_PRODUCER.
~NvRosEglUtil()
Destroys NvRosEglUtil object.
EGLStream in mailbox mode.
Image consumer.
enum nvros::_ProducerType ProducerType
Declares all EGL producer types supported by NvMedia EGLStream library.
EGLDisplay display
References EGLDisplay when creating the EGLStream.
EGLContext context
References EGLContext.
EGLint height
Height of the EGLDisplay.
Default window system.
Image producer.
_OpMode
Declares modes of operation for EGLStream.
CUeglStreamConnection cuEglConn
Handle to the CUDA EGLStream connection.
NVIDIA Media Interface: Core
NvMediaStatus
The set of all possible error codes.
Definition: nvmedia_core.h:199
EGLint yoffset
Offset in the vertical direction.
Default EGLStream mode.
NvRosErr EglUtilInit(EglUtilOptions *options, EglUtilState *eglUtil)
Initializes EGL utility structures.
NvMediaStatus CheckNvMediaEGLStreamVersion(void)
Checks version of NvMedia EGLStream library.
NvRosErr EglUtilDeInit(EglUtilState *state)
Terminates the entire EGLStream setup that was initialized through previous EglUtilInit and EglStream...
Invalid producer type.
EGLint xoffset
Offset in X direction.
EGLStream in FIFO mode.
EGLint windowId
Window ID.
EGLint width
Width of the EGLDisplay.
EGLStreamKHR EglStreamInit(EGLDisplay display, const char *socket_path)
Initializes an EGLStream over a given EGLDisplay through EglUtilInit and a given socket path...
struct nvros::_CudaEglParams CudaEglParams
Holds CUDA EGL related parameters.
EGLint GetStreamState(EGLDisplay display, EGLStreamKHR eglStream)
Gets the current state of EGLStream.
Holds required window system related parameters when initializing EGLStream.
Default producer.
CUDA® consumer.
Egldevice window system.
Default consumer.
Video consumer.
uint8_t dispId
Display ID.
uint8_t winSizeX
Size of window in the horizontal direction.
EGLConfig config
References EGLConfig.
enum nvros::_OpMode OpMode
Declares modes of operation for EGLStream.
uint8_t winOffsetY
Offset of window in the vertical direction.
enum nvros::_NvRosErrCode NvRosErr
Declares error codes for all NvROS modules and packages.
Wayland window system.
enum nvros::_ConsumerType ConsumerType
Declares all EGL consumer types supported by NvMedia EGLStream library.
_ProducerType
Declares all EGL producer types supported by NvMedia EGLStream library.
Holds EGL related parameters.
uint8_t winSizeY
Size of window in the vertical direction.
uint8_t winId
Window ID.
EGL output consumer.
EGLSurface surface
References EGLSurface.
NVIDIA Robot Operating System : Common Enums, Macros, and Constants
NvRosErr InitConsumer(EGLDisplay display, EGLStreamKHR eglStream)
Initializes an EGL consumer in EGLOUTPUT role over specified EGLDisplay and EGLStreamKHR handles...
EGLStreamKHR eglStream
Handle to the EGLStream.
Holds CUDA EGL related parameters.
EGLint displayId
Display ID.
Invalid consumer type.