Updating prebuilts and/or headers

83e21353d1fe20cba4bd630c3b41c1615b8268ed - nvbuf_utils.h
15e77cc11e0be2e813a2a51eaa4256b1026dd16b - gst-nvdrmvideosink/gstnvdrmvideosink.h
464f6823a2241ec38d94c786e23d13dd4b4e2a14 - gst-nvdrmvideosink/Makefile
9585158bb7964cd32f4567f2c0f3504b7c9cf0fd - gst-nvdrmvideosink/gstnvdrmvideosink.c
444ba0e5976368618bd65182f9618af35e0b7946 - gst-nvdrmvideosink/LICENSE.libgstnvdrmvideosink
c318d575f2c7cd3e805b4283f48da5547b152fd6 - gst-nvdrmvideosink/util/vt_switch.c
8920bb914f4fcd79c81652e1e7ac1bd4d35fff41 - gst-nvdrmvideosink/util/drmutil.c
ef0f0a9b3cfbf3d5f2359e9185a75d258201e20a - gst-nvdrmvideosink/util/drmutil.h
31762975c758c9a6c0a0f2a811d6850440f347b6 - gst-nvdrmvideosink/util/vt_switch.h

Change-Id: I9715aadbf369362fab3f00231f7526785f087023
This commit is contained in:
svcmobrel-release
2022-08-15 08:53:40 -07:00
parent d35a74a868
commit 90f8a25cf3
12 changed files with 3360 additions and 0 deletions

11
commitFile.txt Normal file
View File

@@ -0,0 +1,11 @@
Updating prebuilts and/or headers
83e21353d1fe20cba4bd630c3b41c1615b8268ed - nvbuf_utils.h
15e77cc11e0be2e813a2a51eaa4256b1026dd16b - gst-nvdrmvideosink/gstnvdrmvideosink.h
464f6823a2241ec38d94c786e23d13dd4b4e2a14 - gst-nvdrmvideosink/Makefile
9585158bb7964cd32f4567f2c0f3504b7c9cf0fd - gst-nvdrmvideosink/gstnvdrmvideosink.c
444ba0e5976368618bd65182f9618af35e0b7946 - gst-nvdrmvideosink/LICENSE.libgstnvdrmvideosink
c318d575f2c7cd3e805b4283f48da5547b152fd6 - gst-nvdrmvideosink/util/vt_switch.c
8920bb914f4fcd79c81652e1e7ac1bd4d35fff41 - gst-nvdrmvideosink/util/drmutil.c
ef0f0a9b3cfbf3d5f2359e9185a75d258201e20a - gst-nvdrmvideosink/util/drmutil.h
31762975c758c9a6c0a0f2a811d6850440f347b6 - gst-nvdrmvideosink/util/vt_switch.h

View File

@@ -0,0 +1,36 @@
The software listed below is provided under the following terms and
has dependencies upon third-party open source software, including
portions of the GStreamer framework; refer to those software packages
for additional licensing information.
libgstnvdrmvideosink (libgstnvdrmvideosink.so)
------------------------------------
/*
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

View File

@@ -0,0 +1,74 @@
###############################################################################
# Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
SO_NAME := libgstnvdrmvideosink.so
DEST_DIR ?= /usr/lib/aarch64-linux-gnu/gstreamer-1.0
SRCS := gstnvdrmvideosink.c \
util/drmutil.c \
util/vt_switch.c
INCLUDES += -I/usr/lib/aarch64-linux-gnu/glib-2.0/include/ \
-I./util/ \
-I/usr/include/ \
-I/usr/include/libdrm/ \
-I../
INCLUDES += -I/usr/src/jetson_multimedia_api/include/
PKGS := glib-2.0 \
gstreamer-1.0 \
gstreamer-base-1.0 \
gstreamer-video-1.0
OBJS := $(SRCS:.c=.o)
CFLAGS := `pkg-config --cflags $(PKGS)`
LDFLAGS = -Wl,--no-undefined -L/usr/lib/aarch64-linux-gnu/tegra
LIBS = -lnvbufsurface -lnvbufsurftransform -lEGL -ldrm
LIBS += `pkg-config --libs $(PKGS)`
all: $(SO_NAME)
%.o: %.c
$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
$(SO_NAME): $(OBJS)
$(CC) -shared -o $(SO_NAME) $(OBJS) $(LIBS) $(LDFLAGS)
.PHONY: install
install: $(SO_NAME)
cp -vp $(SO_NAME) $(DEST_DIR)
.PHONY: clean
clean:
rm -rf $(OBJS) $(SO_NAME)

View File

@@ -0,0 +1,53 @@
###############################################################################
#
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
Steps to compile the "gst-nvdrmvideosink" sources:
1) Install gstreamer related packages using the command:
sudo apt-get install gstreamer1.0-tools \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-libav libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev libegl1-mesa-dev \
libdrm-dev
2) Extract the package "libgstnvvideosinks_src.tbz2" as follow:
tar xvjf libgstnvvideosinks_src.tbz2`
4) cd "gst-nvdrmvideosink"
5) run "make" to create "libgstnvdrmvideosink.so"
6) run "make install" to install "libgstnvdrmvideosink.so" in
"/usr/lib/aarch64-linux-gnu/gstreamer-1.0".
7) run "DEST_DIR=<location> make install" to install at different <location>.

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GST_NVDRMVIDEOSINK_H__
#define __GST_NVDRMVIDEOSINK_H__
#include <gst/gst.h>
#include "drmutil.h"
#include "vt_switch.h"
G_BEGIN_DECLS
/* #defines don't like whitespacey bits */
#define GST_TYPE_NVDRMVIDEOSINK \
(gst_nv_drm_video_sink_get_type())
#define GST_NVDRMVIDEOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_NVDRMVIDEOSINK,GstNvDrmVideoSink))
#define GST_NVDRMVIDEOSINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_NVDRMVIDEOSINK,GstNvDrmVideoSinkClass))
#define GST_IS_NVDRMVIDEOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_NVDRMVIDEOSINK))
#define GST_IS_NVDRMVIDEOSINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NVDRMVIDEOSINK))
typedef struct _GstNvDrmVideoSink GstNvDrmVideoSink;
typedef struct _GstNvDrmVideoSinkClass GstNvDrmVideoSinkClass;
struct _GstNvDrmVideoSink
{
GstVideoSink parent;
GstPad *sinkpad;
GstCaps *outcaps;
gint width;
gint height;
gint fps_n;
gint fps_d;
GstVideoFormat videoFormat;
struct drm_util_fb fb[2];
struct drm_util_fb dumb;
gint conn_id;
gint crtc_id;
gint plane_id;
gint offset_x;
gint offset_y;
gint color_range;
guint buf_id[2];
gint using_NVMM;
gint frame_count;
gint fd;
gint is_drc_on;
gboolean set_mode;
drmModeModeInfoPtr mode;
drmModeCrtcPtr default_crtcProp;
gint num_modes;
gint drm_format;
GstBuffer *last_buf;
drmModeConnector *conn_info;
gint drm_bo_handles[2][4];
struct vt_info vtinfo;
gint do_vtswitch;
gboolean nvbuf_api_version_new;
gint is_nvidia_drm;
gint is_tegra_drm;
};
struct _GstNvDrmVideoSinkClass
{
GstVideoSinkClass parent_class;
};
GType gst_nv_drm_video_sink_get_type (void);
G_END_DECLS
#endif /* __GST_NVDRMVIDEOSINK_H__ */

View File

@@ -0,0 +1,624 @@
/*
* Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "drmutil.h"
#include <sys/mman.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <drm_fourcc.h>
#include <unistd.h>
#include <drm_mode.h>
#include <tegra_drm.h>
#include <gst/gst.h>
static const struct util_format
{
uint32_t drm_format;
int num_buffers;
struct
{
int w; // width divisor from overall fb_width (luma size)
int h; // height divisor from overall fb_height (luma size)
int bpp;
} buffers[3];
} util_formats[] = {
// drm fourcc type #buffers w1 h1 bpp1 w2 h2 bpp2 w3 h3 bpp3
// drm fourcc type #buffers w1 h1 bpp1 w2 h2 bpp2 w3 h3 bpp3
{
DRM_FORMAT_ARGB8888, 1, { {
1, 1, 32}, {
0, 0, 0}, {
0, 0, 0}}}, {
DRM_FORMAT_ABGR8888, 1, { {
1, 1, 32}, {
0, 0, 0}, {
0, 0, 0}}}, {
DRM_FORMAT_NV12, 2, { {
1, 1, 8}, {
2, 2, 16}, {
0, 0, 0}}}, {
DRM_FORMAT_YUV420, 3, { {
1, 1, 8}, {
2, 2, 8}, {
2, 2, 8}}} , {
DRM_FORMAT_XRGB8888, 1, { {
1, 1, 32}, {
0, 0, 0}, {
0, 0, 0}}} , {
DRM_FORMAT_UYVY, 1, { {
1, 1, 16}, {
0, 0, 0}, {
0, 0, 0}}}, {
DRM_FORMAT_YUYV, 1, { {
1, 1, 16}, {
0, 0, 0}, {
0, 0, 0}}} , {
DRM_FORMAT_XBGR8888, 1, { {
1, 1, 32}, {
0, 0, 0}, {
0, 0, 0}}} , {
DRM_FORMAT_NV16, 2, { {
1, 1, 8}, {
2, 1, 16}, {
0, 0, 0}}}, {
DRM_FORMAT_NV61, 2, { {
1, 1, 8}, {
2, 1, 16}, {
0, 0, 0}}}, {
DRM_FORMAT_NV24, 2, { {
1, 1, 8}, {
1, 1, 16}, {
0, 0, 0}}}, {
DRM_FORMAT_YVU420, 3, { {
1, 1, 8}, {
2, 2, 8}, {
2, 2, 8}}}, {
DRM_FORMAT_YUV444, 3, { {
1, 1, 8}, {
1, 1, 8}, {
1, 1, 8}}}
};
int
drm_util_init (int *fd, drmModeConnector ** conn_info_s, int *conn_id_s,
int *crtc_id_s, int *plane_id_s, struct vt_info *vtinfo, gint do_vtswitch,
gint *is_nvidia_drm, gint *is_tegra_drm)
{
int conn_index = *conn_id_s;
int plane_index = *plane_id_s;
int crtc_index = *crtc_id_s;
uint32_t conn_id = 0;
uint32_t enc_id;
uint32_t crtc_id;
drmModeRes *res_info = NULL;
drmModePlaneRes *plane_res_info = NULL;
drmModeEncoder *enc_info = NULL;
drmModeCrtc *crtc_info = NULL;
drmModePlane *plane_info = NULL;
drmVersion *version = NULL;
int is;
int ret = 0;
if (do_vtswitch) {
if (!acquire_vt(vtinfo)) {
g_print ("Failed to acquire vt\n");
return 0;
}
}
// Open the DRM device.
*fd = open ("/dev/dri/card0", O_RDWR);
if (*fd < 0) {
*fd = drmOpen("drm-nvdc", NULL);
if(*fd < 0) {
g_print ("Could not open DRM failed \n");
return 0;
}
}
version = drmGetVersion(*fd);
if (version == NULL) {
g_print("Failed to get drm version\n");
drmClose (*fd);
return 0;
}
*is_nvidia_drm = 0;
if (!strcmp(version->name, "nvidia-drm")) {
*is_nvidia_drm = 1;
}
*is_tegra_drm = 0;
if (!strcmp(version->name, "tegra")) {
*is_tegra_drm = 1;
}
drmFreeVersion(version);
if (drmSetClientCap (*fd, DRM_CLIENT_CAP_ATOMIC, 1)) {
g_print ("Failed to set atomic cap \n");
return 0;
}
if (drmSetClientCap (*fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) {
g_print ("Failed to set universal planes \n");
return 0;
}
// Obtain DRM-KMS resources
res_info = drmModeGetResources (*fd);
if (!res_info) {
g_print ("Couldn't obtain DRM-KMS resources \n");
goto free_resources;
}
if (res_info->count_connectors < 1) {
g_print ("No connectors \n");
goto free_resources;
}
// If user has not mentioned any conn_id
if (conn_index == INT_MAX) {
// Find a valid/connected connector
for (conn_index = 0; conn_index < res_info->count_connectors ; conn_index++) {
conn_id = res_info->connectors[conn_index];
*conn_info_s = drmModeGetConnector(*fd, conn_id);
if ((*conn_info_s) && (*conn_info_s)->connection == DRM_MODE_CONNECTED) {
*conn_id_s = conn_id;
break;
}
drmModeFreeConnector(*conn_info_s);
}
} else if (conn_index < res_info->count_connectors && conn_index >=0){
conn_id = res_info->connectors[conn_index];
*conn_id_s = conn_id;
*conn_info_s = drmModeGetConnector (*fd, conn_id);
}
// Check bound
if ((conn_index >= res_info->count_connectors) || (conn_index < 0)) {
g_print ("Invalid connector id \n");
goto free_resources;
}
if (!(*conn_info_s)) {
g_print ("Unable to obtain info for connector id(%d) \n", conn_id);
goto free_resources;
}
// Set Encoder Info
enc_id = (*conn_info_s)->encoder_id;
enc_info = drmModeGetEncoder (*fd, enc_id);
if (!enc_info) {
// If connector does not have a connected encoder use first one
enc_id = (*conn_info_s)->encoders[0];
enc_info = drmModeGetEncoder (*fd, enc_id);
if (!enc_info) {
g_print ("Unable to find suitable encoder \n");
goto free_resources;
}
}
// Set CRTC info
crtc_id = enc_info->crtc_id;
crtc_info = drmModeGetCrtc (*fd, crtc_id);
// If the encoder has no connected CRTC, use the first one supported
if (!crtc_info && enc_info->possible_crtcs) {
crtc_id = res_info->crtcs[ffs (enc_info->possible_crtcs) - 1];
crtc_info = drmModeGetCrtc (*fd, crtc_id);
}
*crtc_id_s = crtc_id;
drmModeFreeEncoder (enc_info);
if (!crtc_info) {
g_print ("Unable to find usable crtc for encoder \n");
goto free_resources;
}
// Identify the index of our chosen crtc from the resource list.
// Index is needed to match planes with crtcs
crtc_index = -1;
for (is = 0; is < res_info->count_crtcs; is++) {
if (res_info->crtcs[is] == crtc_id) {
crtc_index = is;
break;
}
}
if (crtc_index == -1) {
printf ("Unable to locate crtc_id=%d in resource list\n", crtc_id);
goto free_resources;
}
// Set Plane Info
plane_res_info = drmModeGetPlaneResources (*fd);
int plane_count = plane_res_info->count_planes;
if (!plane_res_info) {
g_print ("Unable to get plane resource info \n");
goto free_resources;
}
// If user has not mentioned any plane_id
if (plane_index == INT_MAX) {
plane_index = 0;
}
// Check bound
if ((plane_index >= plane_count) || (plane_index < 0)) {
g_print ("Invalid plane id \n");
goto free_resources;
}
int i;
for (i = 0; i < plane_count; i++) {
int plane_id = plane_res_info->planes[i];
plane_info = drmModeGetPlane (*fd, plane_id);
if (!plane_info) {
printf ("Unable to get plane info\n");
return 0;
}
if (plane_info->possible_crtcs & (1 << crtc_index)) {
if (plane_index == 0) {
*plane_id_s = plane_id;
break;
} else {
plane_index--;
}
}
drmModeFreePlane (plane_info);
}
if (plane_index != 0) {
goto free_resources;
}
//drm_util_init success
ret = 1;
// Free the resource information structures
free_resources:
if (plane_info)
drmModeFreePlane (plane_info);
if (plane_res_info)
drmModeFreePlaneResources (plane_res_info);
if (crtc_info)
drmModeFreeCrtc (crtc_info);
if (res_info)
drmModeFreeResources (res_info);
if (!ret){
if (*conn_info_s) {
drmModeFreeConnector (*conn_info_s);
}
drmClose (*fd);
}
return ret;
}
static int
get_format_info (uint32_t drm_format, struct util_format *uf)
{
int i;
int fsize = sizeof (util_formats) / sizeof (util_formats[0]);
for (i = 0; i < fsize; i++) {
if (util_formats[i].drm_format == drm_format) {
*uf = util_formats[i];
return 1;
}
}
return 0;
}
uint8_t *
drm_util_mmap_dumb_bo (int fd, __u32 handle, __u64 size)
{
struct drm_mode_map_dumb mreq;
uint8_t *map = NULL;
drmVersion *version;
/* prepare buffer for memory mapping */
memset (&mreq, 0, sizeof (mreq));
mreq.handle = handle;
if (drmIoctl (fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq) != 0) {
g_print ("cannot map dumb buffer\n");
return NULL;
}
version = drmGetVersion(fd);
if (version == NULL) {
g_print("Failed to get drm version\n");
return NULL;
}
if (!strcmp(version->name, "nvidia-drm") ||
!strcmp(version->name, "tegra")) {
map = (uint8_t*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
mreq.offset);
if (map == MAP_FAILED) {
g_print("cannot mmap dumb buffer\n");
drmFreeVersion(version);
return NULL;
}
} else {
map = (uint8_t *) (mreq.offset);
}
drmFreeVersion(version);
return map;
}
// Create a buffer object of the requested size.
// Return the bo handle and the mapping
int
drm_util_create_dumb_bo (int fd, int width, int height,
int bpp, struct drm_util_bo *util_bo)
{
struct drm_mode_create_dumb creq;
struct drm_mode_destroy_dumb dreq;
int ret;
uint8_t *map = NULL;
/* create dumb buffer */
memset (&creq, 0, sizeof (creq));
creq.width = width;
creq.height = height;
creq.bpp = bpp;
ret = drmIoctl (fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq);
if (ret < 0) {
g_print ("cannot create dumb buffer\n");
return 0;
}
map = drm_util_mmap_dumb_bo (fd, creq.handle, creq.size);
if (map == NULL) {
goto err_destroy;
}
/* clear the buffer object */
memset (map, 0x00, creq.size);
util_bo->bo_handle = creq.handle;
util_bo->width = width;
util_bo->height = height;
util_bo->pitch = creq.pitch;
util_bo->data = map;
util_bo->size = creq.size;
return 1;
err_destroy:
memset (&dreq, 0, sizeof (dreq));
dreq.handle = creq.handle;
drmIoctl (fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq);
return 0;
}
int
drm_util_fill_data (struct drm_util_fb *util_fb, uint8_t * p,
uint32_t sizeInput)
{
int i, j;
int w = util_fb->width;
int h = util_fb->height;
int fmt = util_fb->format;
struct util_format uf;
if (!get_format_info (util_fb->format, &uf)) {
GST_ERROR ("DRM test helper library can't draw in a FB of type %x\n",
util_fb->format);
return 1;
}
switch (fmt) {
case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XBGR8888:
memcpy (util_fb->bo[0].data, p, sizeInput);
break;
case DRM_FORMAT_NV16:
case DRM_FORMAT_NV61:
case DRM_FORMAT_NV24:
case DRM_FORMAT_NV12:
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
uint32_t off_y = util_fb->bo[0].pitch * j + i;
util_fb->bo[0].data[off_y] = *p++;
}
}
for (j = 0; j < (h / uf.buffers[1].h); j++) {
for (i = 0; (i < w / uf.buffers[1].w); i++) {
uint32_t off_u =
(util_fb->bo[1].pitch * j) + (i * uf.buffers[1].bpp / 8);
util_fb->bo[1].data[off_u] = *p++;
util_fb->bo[1].data[off_u + 1] = *p++;
}
}
break;
case DRM_FORMAT_YVU420:
case DRM_FORMAT_YUV420:
case DRM_FORMAT_YUV444:
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
uint32_t off_y = util_fb->bo[0].pitch * j + i;
util_fb->bo[0].data[off_y] = *p++;
}
}
for (j = 0; j < (h / uf.buffers[1].h); j++) {
for (i = 0; i < (w / uf.buffers[1].w); i++) {
uint32_t off_y = util_fb->bo[1].pitch * j + i;
util_fb->bo[1].data[off_y] = *p++;
}
}
for (j = 0; (j < (h / uf.buffers[1].h)); j++) {
for (i = 0; (i < (w / uf.buffers[1].w)); i++) {
uint32_t off_y = util_fb->bo[2].pitch * j + i;
util_fb->bo[2].data[off_y] = *p++;
}
}
break;
case DRM_FORMAT_UYVY:
case DRM_FORMAT_YUYV:
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
uint32_t off_y = util_fb->bo[0].pitch * j + i * 2;
util_fb->bo[0].data[off_y + 0] = *p++;
util_fb->bo[0].data[off_y + 1] = *p++;
}
}
break;
default:
g_print ("Fill format not defined \n");
return 1;
}
return 0;
}
int
gem_set_params (int fd, uint32_t nvhandle, uint32_t nvblocksize)
{
struct drm_tegra_gem_set_tiling args;
memset (&args, 0, sizeof (args));
args.handle = nvhandle;
args.mode = DRM_TEGRA_GEM_TILING_MODE_BLOCK;
args.value = nvblocksize;
int ret = drmIoctl (fd, DRM_IOCTL_TEGRA_GEM_SET_TILING, &args);
if (ret < 0) {
g_print ("Failed to set tiling parameters \n");
return -1;
}
return 1;
}
int
drm_util_destroy_dumb_bo (int fd, struct drm_util_bo *util_bo)
{
struct drm_mode_destroy_dumb dreq;
munmap (util_bo->data, util_bo->size);
memset (&dreq, 0, sizeof (dreq));
dreq.handle = util_bo->bo_handle;
drmIoctl (fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq);
return 1;
}
// Destroy an FB and its BOs
int
drm_util_destroy_dumb_fb (int fd, struct drm_util_fb *util_fb)
{
int i = 0;
for (i = 0; i < util_fb->num_buffers; i++) {
drm_util_destroy_dumb_bo (fd, &util_fb->bo[i]);
}
util_fb->num_buffers = 0;
drmModeRmFB (fd, util_fb->fb_id);
return 1;
}
// Create an FB of the requested size. Return the fb_id and the mapping
int
drm_util_create_dumb_fb (int fd, int width, int height,
int drm_format, struct drm_util_fb *util_fb)
{
int buf_count;
int ret = 1;
int i = 0;
struct util_format uf;
if (!get_format_info (drm_format, &uf)) {
g_print ("DRM test helper library can't make a FB of type %d\n",
drm_format);
return 0;
}
buf_count = uf.num_buffers;
uint32_t buf_id;
uint32_t bo_handles[4] = { 0 };
uint32_t pitches[4] = { 0 };
uint32_t offsets[4] = { 0 };
util_fb->num_buffers = 0;
/* create dumb buffers */
for (i = 0; i < buf_count; i++) {
struct drm_util_bo *util_bo = &(util_fb->bo[i]);
ret = drm_util_create_dumb_bo (fd, width / uf.buffers[i].w,
height / uf.buffers[i].h, uf.buffers[i].bpp, util_bo);
if (ret <= 0) {
g_print ("cannot create dumb buffer\n");
goto err_destroy;
}
bo_handles[i] = util_fb->bo[i].bo_handle;
pitches[i] = util_fb->bo[i].pitch;
offsets[i] = 0;
util_fb->num_buffers++;
}
/* create framebuffer object for the dumb-buffer */
ret = drmModeAddFB2 (fd, width, height, drm_format, bo_handles,
pitches, offsets, &buf_id, 0);
if (ret) {
g_print ("cannot create framebuffer\n");
goto err_destroy;
}
util_fb->fb_id = buf_id;
util_fb->width = width;
util_fb->height = height;
util_fb->format = drm_format;
return 1;
err_destroy:
drm_util_destroy_dumb_fb (fd, util_fb);
return 0;
}
// Close GEM buffers
int
drm_util_close_gem_bo (int fd, uint32_t bo_handle)
{
struct drm_gem_close gemCloseArgs;
memset (&gemCloseArgs, 0, sizeof (gemCloseArgs));
gemCloseArgs.handle = bo_handle;
int ret = drmIoctl (fd, DRM_IOCTL_GEM_CLOSE, &gemCloseArgs);
if (ret < 0) {
return 0;
}
return 1;
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DRMUTIL_H
#define _DRMUTIL_H
#include "vt_switch.h"
#include "xf86drm.h"
#include "xf86drmMode.h"
struct drm_util_bo
{
uint32_t bo_handle;
int width;
int height;
int pitch;
uint8_t *data;
size_t size;
};
struct drm_util_fb
{
uint32_t fb_id;
int width;
int height;
int format;
struct drm_util_bo bo[4];
int num_buffers;
};
// Fill drm dumb buffer with a test pattern
int drm_util_fill_data (struct drm_util_fb *util_fb, uint8_t * p,
uint32_t sizeInput);
int drm_util_init (int *fd, drmModeConnector **conn_info, int *conn_id, int *crtc_id,
int *plane_id, struct vt_info *vtinfo, int do_vtswitch,
int *is_nvidia_drm, int *is_tegra_drm);
// Returns a DRM buffer_object handle allocated of size (w,h)
int drm_util_create_dumb_bo (int fd, int w, int h,
int bpp, struct drm_util_bo *util_bo);
uint8_t *drm_util_mmap_dumb_bo (int fd, __u32 handle, __u64 size);
// Set gem buffer parameters
int gem_set_params (int fd, uint32_t nvhandle, uint32_t nvblocksize);
// Returns a DRM framebuffer ID allocated of size (w,h)
int drm_util_create_dumb_fb (int fd, int w, int h,
int drm_format, struct drm_util_fb *util_fb);
int count_format_types(void);
// Close GEM buffers
int drm_util_close_gem_bo (int fd, uint32_t bo_handle);
// Destroy an FB and its BOs
int drm_util_destroy_dumb_bo (int fd, struct drm_util_bo *util_bo);
int drm_util_destroy_dumb_fb (int fd, struct drm_util_fb *util_fb);
#endif

View File

@@ -0,0 +1,185 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <linux/kd.h>
#include "vt_switch.h"
/*
* release_vt - Sets the tty back to TEXT mode.
*/
void release_vt(struct vt_info *info)
{
int ret;
int kd_mode;
if (info->console_fd < 0) {
return;
}
ret = ioctl(info->console_fd, KDSETMODE, KD_TEXT);
if (ret < 0) {
printf("KDSETMODE KD_TEXT failed, err=%s\n", strerror(errno));
goto fail;
}
ret = ioctl(info->console_fd, KDGETMODE, &kd_mode);
if (ret < 0) {
printf("KDGETMODE failed, err=%s\n", strerror(errno));
goto fail;
}
if (info->active_vt >= 0) {
ret = ioctl(info->console_fd, VT_ACTIVATE, info->active_vt);
if (ret < 0) {
printf("VT_ACTIVATE failed, err=%s\n", strerror(errno));
goto fail;
}
ret = ioctl(info->console_fd, VT_WAITACTIVE, info->active_vt);
if (ret < 0) {
printf("VT_WAITACTIVE failed, err= %s\n", strerror(errno));
goto fail;
}
}
fail:
close(info->console_fd);
info->console_fd = -1;
info->active_vt = -1;
}
/*
* acquire_vt - Sets the tty to GRAPHICAL mode.
*/
int acquire_vt(struct vt_info *info)
{
int i, ret, fd, vtno, kd_mode;
struct vt_stat vts;
const char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
static char vtname[11];
fd = open("/dev/tty0", O_WRONLY);
if (fd < 0) {
printf("Can't open /dev/tty0 err=%s\n", strerror(errno));
return 0;
}
ret = ioctl(fd, VT_OPENQRY, &vtno);
if (ret < 0) {
printf("VT_OPENQRY failed, err=%s\n", strerror(errno));
close(fd);
return 0;
}
if (vtno == -1) {
printf("Can't find free VT\n");
close(fd);
return 0;
}
printf("Using VT number %d\n", vtno);
close(fd);
i = 0;
while (vcs[i] != NULL) {
snprintf(vtname, sizeof(vtname), vcs[i], vtno);
info->console_fd = open(vtname, O_RDWR | O_NDELAY, 0);
if (info->console_fd >= 0) {
break;
}
i++;
}
if (info->console_fd < 0) {
printf("Can't open virtual console %d\n", vtno);
return 0;
}
ret = ioctl(info->console_fd, KDGETMODE, &kd_mode);
if (ret < 0) {
printf("KDGETMODE failed, err=%s\n", strerror(errno));
goto fail;
}
if (kd_mode != KD_TEXT) {
printf("%s is already in graphics mode, "
"seems like some display server running\n", vtname);
}
ret = ioctl(info->console_fd, VT_ACTIVATE, vtno);
if (ret < 0) {
printf("VT_ACTIVATE failed, err=%s\n", strerror(errno));
goto fail;
}
ret = ioctl(info->console_fd, VT_WAITACTIVE, vtno);
if (ret < 0) {
printf("VT_WAITACTIVE failed, err=%s\n", strerror(errno));
goto fail;
}
ret = ioctl(info->console_fd, VT_GETSTATE, &vts);
if (ret < 0) {
printf("VT_GETSTATE failed, err=%s\n", strerror(errno));
goto fail;
} else {
info->active_vt = vts.v_active;
}
ret = ioctl(info->console_fd, KDSETMODE, KD_GRAPHICS);
if (ret < 0) {
printf("KDSETMODE KD_GRAPHICS failed, err=%s\n", strerror(errno));
goto fail;
}
ret = ioctl(info->console_fd, KDGETMODE, &kd_mode);
if (ret < 0) {
printf("KDGETMODE failed, err=%s\n", strerror(errno));
goto fail;
}
if (kd_mode != KD_TEXT) {
printf("%s is in graphics mode\n", vtname);
}
return 1;
fail:
close (info->console_fd);
return 0;
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VT_SWITCH_H
#define _VT_SWITCH_H
struct vt_info {
int console_fd;
int active_vt;
};
int acquire_vt(struct vt_info *info);
void release_vt(struct vt_info *info);
#endif

897
nvbuf_utils.h Normal file
View File

@@ -0,0 +1,897 @@
/*
* Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA Corporation is strictly prohibited.
*/
/**
* @file
* <b>NVIDIA Multimedia Utilities: Buffering and Transform/Composition/Blending</b>
*
*/
/**
* @defgroup ee_nvbuffering_group NvBufUtils API (Deprecated)
* @ingroup ds_nvbuf_api
* NVIDIA buffering utility library for use by applications.
* The utility also transforms, composits, and blends.
* @{
*/
#ifndef _NVBUF_UTILS_H_
#define _NVBUF_UTILS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <errno.h>
#include <stdbool.h>
/**
* Defines the maximum number of planes for a video frame.
*/
#define MAX_NUM_PLANES 4
/**
* Defines the maximum number of input video frames that can be used for composition.
*/
#define MAX_COMPOSITE_FRAME 16
/**
* Defines the default values for chroma subsampling.
* The default value matches JPEG/MPEG use cases.
*/
#define NVBUF_CHROMA_SUBSAMPLING_HORIZ_DEFAULT 0
#define NVBUF_CHROMA_SUBSAMPLING_VERT_DEFAULT 1
/**
* Defines the maximum number of sync object parameters.
*/
#define NVBUF_MAX_SYNCOBJ_PARAMS 5
/**
* Use this value to represent an infinite wait interval.
* A value of zero should not be interpreted as infinite,
* it should be interpreted as "time out immediately" and
* simply check whether the event has already happened.
*/
#define NVBUFFER_SYNCPOINT_WAIT_INFINITE 0xFFFFFFFF
/**
* Defines Payload types for NvBuffer.
*/
typedef enum
{
/** buffer payload with hardware memory handle for set of planes. */
NvBufferPayload_SurfArray,
/** buffer payload with hardware memory handle for specific memory size. */
NvBufferPayload_MemHandle,
} NvBufferPayloadType;
/**
* Defines display scan formats for NvBuffer video planes.
*/
typedef enum
{
/** Progessive scan formats. */
NvBufferDisplayScanFormat_Progressive = 0,
/** Interlaced scan formats. */
NvBufferDisplayScanFormat_Interlaced,
} NvBufferDisplayScanFormat;
/**
* Defines Layout formats for NvBuffer video planes.
*/
typedef enum
{
/** Pitch Layout. */
NvBufferLayout_Pitch,
/** BlockLinear Layout. */
NvBufferLayout_BlockLinear,
} NvBufferLayout;
/**
* Defines memory access flags for NvBuffer.
*/
typedef enum
{
/** Memory read. */
NvBufferMem_Read,
/** Memory write. */
NvBufferMem_Write,
/** Memory read & write. */
NvBufferMem_Read_Write,
} NvBufferMemFlags;
/**
* Defines tags that identify the components requesting a memory allocation.
* The tags can be used later to identify the total memory allocated to
* particular types of components.
*/
typedef enum
{
/** tag None. */
NvBufferTag_NONE = 0x0,
/** tag for Camera. */
NvBufferTag_CAMERA = 0x200,
/** tag for Jpeg Encoder/Decoder. */
NvBufferTag_JPEG = 0x1500,
/** tag for VPR Buffers. */
NvBufferTag_PROTECTED = 0x1504,
/** tag for H264/H265 Video Encoder. */
NvBufferTag_VIDEO_ENC = 0x1200,
/** tag for H264/H265/VP9 Video Decoder. */
NvBufferTag_VIDEO_DEC = 0x1400,
/** tag for Video Transform/Composite. */
NvBufferTag_VIDEO_CONVERT = 0xf01,
} NvBufferTag;
/**
* Defines color formats for NvBuffer.
*/
typedef enum
{
/** BT.601 colorspace - YUV420 multi-planar. */
NvBufferColorFormat_YUV420,
/** BT.601 colorspace - YUV420 multi-planar. */
NvBufferColorFormat_YVU420,
/** BT.601 colorspace - YUV422 multi-planar. */
NvBufferColorFormat_YUV422,
/** BT.601 colorspace - YUV420 ER multi-planar. */
NvBufferColorFormat_YUV420_ER,
/** BT.601 colorspace - YVU420 ER multi-planar. */
NvBufferColorFormat_YVU420_ER,
/** BT.601 colorspace - Y/CbCr 4:2:0 multi-planar. */
NvBufferColorFormat_NV12,
/** BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar. */
NvBufferColorFormat_NV12_ER,
/** BT.601 colorspace - Y/CbCr 4:2:0 multi-planar. */
NvBufferColorFormat_NV21,
/** BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar. */
NvBufferColorFormat_NV21_ER,
/** BT.601 colorspace - YUV 4:2:2 planar. */
NvBufferColorFormat_UYVY,
/** BT.601 colorspace - YUV ER 4:2:2 planar. */
NvBufferColorFormat_UYVY_ER,
/** BT.601 colorspace - YUV 4:2:2 planar. */
NvBufferColorFormat_VYUY,
/** BT.601 colorspace - YUV ER 4:2:2 planar. */
NvBufferColorFormat_VYUY_ER,
/** BT.601 colorspace - YUV 4:2:2 planar. */
NvBufferColorFormat_YUYV,
/** BT.601 colorspace - YUV ER 4:2:2 planar. */
NvBufferColorFormat_YUYV_ER,
/** BT.601 colorspace - YUV 4:2:2 planar. */
NvBufferColorFormat_YVYU,
/** BT.601 colorspace - YUV ER 4:2:2 planar. */
NvBufferColorFormat_YVYU_ER,
/** LegacyRGBA colorspace - BGRA-8-8-8-8 planar. */
NvBufferColorFormat_ABGR32,
/** LegacyRGBA colorspace - XRGB-8-8-8-8 planar. */
NvBufferColorFormat_XRGB32,
/** LegacyRGBA colorspace - ARGB-8-8-8-8 planar. */
NvBufferColorFormat_ARGB32,
/** BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
NvBufferColorFormat_NV12_10LE,
/** BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
NvBufferColorFormat_NV12_10LE_709,
/** BT.709_ER colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
NvBufferColorFormat_NV12_10LE_709_ER,
/** BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
NvBufferColorFormat_NV12_10LE_2020,
/** BT.601 colorspace - Y/CrCb 4:2:0 10-bit multi-planar. */
NvBufferColorFormat_NV21_10LE,
/** BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar. */
NvBufferColorFormat_NV12_12LE,
/** BT.2020 colorspace - Y/CbCr 4:2:0 12-bit multi-planar. */
NvBufferColorFormat_NV12_12LE_2020,
/** BT.601 colorspace - Y/CrCb 4:2:0 12-bit multi-planar. */
NvBufferColorFormat_NV21_12LE,
/** BT.709 colorspace - YUV420 multi-planar. */
NvBufferColorFormat_YUV420_709,
/** BT.709 colorspace - YUV420 ER multi-planar. */
NvBufferColorFormat_YUV420_709_ER,
/** BT.709 colorspace - Y/CbCr 4:2:0 multi-planar. */
NvBufferColorFormat_NV12_709,
/** BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar. */
NvBufferColorFormat_NV12_709_ER,
/** BT.2020 colorspace - YUV420 multi-planar. */
NvBufferColorFormat_YUV420_2020,
/** BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar. */
NvBufferColorFormat_NV12_2020,
/** BT.601 colorspace - YUV444 multi-planar. */
NvBufferColorFormat_YUV444,
/** Optical flow */
NvBufferColorFormat_SignedR16G16,
/** Optical flow SAD calculation Buffer format */
NvBufferColorFormat_A32,
/** 8-bit grayscale. */
NvBufferColorFormat_GRAY8,
/** BT.601 colorspace - Y/CbCr 4:2:2 multi-planar. */
NvBufferColorFormat_NV16,
/** BT.601 colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
NvBufferColorFormat_NV16_10LE,
/** BT.601 colorspace - Y/CbCr 4:4:4 multi-planar. */
NvBufferColorFormat_NV24,
/** BT.601 colorspace - Y/CrCb 4:4:4 10-bit multi-planar. */
NvBufferColorFormat_NV24_10LE,
/** BT.601_ER colorspace - Y/CbCr 4:2:2 multi-planar. */
NvBufferColorFormat_NV16_ER,
/** BT.601_ER colorspace - Y/CbCr 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_ER,
/** BT.709 colorspace - Y/CbCr 4:2:2 multi-planar. */
NvBufferColorFormat_NV16_709,
/** BT.709 colorspace - Y/CbCr 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_709,
/** BT.709_ER colorspace - Y/CbCr 4:2:2 multi-planar. */
NvBufferColorFormat_NV16_709_ER,
/** BT.709_ER colorspace - Y/CbCr 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_709_ER,
/** BT.709 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_10LE_709,
/** BT.709 ER colorspace - Y/CbCr 10 bit 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_10LE_709_ER,
/** BT.2020 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_10LE_2020,
/** BT.2020 colorspace - Y/CbCr 12 bit 4:4:4 multi-planar. */
NvBufferColorFormat_NV24_12LE_2020,
/** Non-linear RGB BT.709 colorspace - RGBA-10-10-10-2 planar. */
NvBufferColorFormat_RGBA_10_10_10_2_709,
/** Non-linear RGB BT.2020 colorspace - RGBA-10-10-10-2 planar. */
NvBufferColorFormat_RGBA_10_10_10_2_2020,
/** Non-linear RGB BT.709 colorspace - BGRA-10-10-10-2 planar. */
NvBufferColorFormat_BGRA_10_10_10_2_709,
/** Non-linear RGB BT.2020 colorspace - BGRA-10-10-10-2 planar. */
NvBufferColorFormat_BGRA_10_10_10_2_2020,
/** Invalid color format. */
NvBufferColorFormat_Invalid,
} NvBufferColorFormat;
/**
* Defines video flip methods.
*/
typedef enum
{
/** Video flip none. */
NvBufferTransform_None,
/** Video flip rotate 90 degree counter-clockwise. */
NvBufferTransform_Rotate90,
/** Video flip rotate 180 degree. */
NvBufferTransform_Rotate180,
/** Video flip rotate 270 degree counter-clockwise. */
NvBufferTransform_Rotate270,
/** Video flip with respect to X-axis. */
NvBufferTransform_FlipX,
/** Video flip with respect to Y-axis. */
NvBufferTransform_FlipY,
/** Video flip transpose. */
NvBufferTransform_Transpose,
/** Video flip inverse transpode. */
NvBufferTransform_InvTranspose,
} NvBufferTransform_Flip;
/**
* Defines transform video filter types.
*/
typedef enum
{
/** transform filter nearest. */
NvBufferTransform_Filter_Nearest,
/** transform filter bilinear. */
NvBufferTransform_Filter_Bilinear,
/** transform filter 5 tap. */
NvBufferTransform_Filter_5_Tap,
/** transform filter 10 tap. */
NvBufferTransform_Filter_10_Tap,
/** transform filter smart. */
NvBufferTransform_Filter_Smart,
/** transform filter nicest. */
NvBufferTransform_Filter_Nicest,
} NvBufferTransform_Filter;
/**
* Defines flags to indicate for valid transform.
*/
typedef enum {
/** transform flag to crop source rectangle. */
NVBUFFER_TRANSFORM_CROP_SRC = 1,
/** transform flag to crop destination rectangle. */
NVBUFFER_TRANSFORM_CROP_DST = 1 << 1,
/** transform flag to set filter type. */
NVBUFFER_TRANSFORM_FILTER = 1 << 2,
/** transform flag to set flip method. */
NVBUFFER_TRANSFORM_FLIP = 1 << 3,
} NvBufferTransform_Flag;
/**
* Defines flags that specify valid composition/blending operations.
*/
typedef enum {
/** flag to set for composition. */
NVBUFFER_COMPOSITE = 1,
/** flag to set for blending. */
NVBUFFER_BLEND = 1 << 1,
/** composition flag to set filter type. */
NVBUFFER_COMPOSITE_FILTER = 1 << 2,
} NvBufferComposite_Flag;
/**
* Holds parameters for buffer sync point object.
* sync object params is simply a data structure containing [sync point ID,value] pair.
* This can be used by clients to describe an event that might want to wait for.
*/
typedef struct _NvBufferSyncObjParams
{
uint32_t syncpointID;
uint32_t value;
}NvBufferSyncObjParams;
/**
* buffer sync point object.
*/
typedef struct _NvBufferSyncObjRec
{
NvBufferSyncObjParams insyncobj[NVBUF_MAX_SYNCOBJ_PARAMS];
uint32_t num_insyncobj;
NvBufferSyncObjParams outsyncobj;
uint32_t use_outsyncobj;
}NvBufferSyncObj;
/**
* Holds composition background r,g,b colors.
*/
typedef struct
{
/** background color value for r. */
float r;
/** background color value for g. */
float g;
/** background color value for b. */
float b;
}NvBufferCompositeBackground;
/**
* Holds coordinates for a rectangle.
*/
typedef struct
{
/** rectangle top. */
uint32_t top;
/** rectangle left. */
uint32_t left;
/** rectangle width. */
uint32_t width;
/** rectangle height. */
uint32_t height;
}NvBufferRect;
/**
* Holds an opaque NvBuffer session type required for parallel buffer
* tranformations and compositions. Operations using a single session are
* scheduled sequentially, after the previous operation finishes. Operations for
* multiple sessions are scheduled in parallel.
*/
typedef struct _NvBufferSession * NvBufferSession;
/**
* Holds Chroma Subsampling parameters.
*/
typedef struct _NvBufferChromaSubSamplingParams
{
/** location settings */
uint8_t chromaLocHoriz;
uint8_t chromaLocVert;
}NvBufferChromaSubsamplingParams;
#define NVBUF_CHROMA_SUBSAMPLING_PARAMS_DEFAULT \
{ \
NVBUF_CHROMA_SUBSAMPLING_HORIZ_DEFAULT, \
NVBUF_CHROMA_SUBSAMPLING_VERT_DEFAULT \
}
/**
* Holds the input parameters for hardware buffer creation.
*/
typedef struct _NvBufferCreateParams
{
/** width of the buffer. */
int32_t width;
/** height of the buffer. */
int32_t height;
/** payload type of the buffer. */
NvBufferPayloadType payloadType;
/** size of the memory.(Applicale for NvBufferPayload_MemHandle) */
int32_t memsize;
/** layout of the buffer. */
NvBufferLayout layout;
/** colorformat of the buffer. */
NvBufferColorFormat colorFormat;
/** tag to associate with the buffer. */
NvBufferTag nvbuf_tag;
}NvBufferCreateParams;
/**
* Holds parameters for a hardware buffer.
*/
typedef struct _NvBufferParams
{
/** Holds the DMABUF FD of the hardware buffer. */
uint32_t dmabuf_fd;
/** pointer to hardware buffer memory. */
void *nv_buffer;
/** payload type of the buffer. */
NvBufferPayloadType payloadType;
/** size of the memory.(Applicale for NvBufferPayload_MemHandle) */
int32_t memsize;
/** size of hardware buffer. */
uint32_t nv_buffer_size;
/** video format type of hardware buffer. */
NvBufferColorFormat pixel_format;
/** number of planes of hardware buffer. */
uint32_t num_planes;
/** width of each planes of hardware buffer. */
uint32_t width[MAX_NUM_PLANES];
/** height of each planes of hardware buffer. */
uint32_t height[MAX_NUM_PLANES];
/** pitch of each planes of hardware buffer. */
uint32_t pitch[MAX_NUM_PLANES];
/** memory offset values of each video planes of hardware buffer. */
uint32_t offset[MAX_NUM_PLANES];
/** size of each vodeo planes of hardware buffer. */
uint32_t psize[MAX_NUM_PLANES];
/** layout type of each planes of hardware buffer. */
uint32_t layout[MAX_NUM_PLANES];
}NvBufferParams;
/**
* Holds extended parameters for a hardware buffer.
*/
typedef struct _NvBufferParamsEx
{
/** nvbuffer basic parameters. */
NvBufferParams params;
/** offset in bytes from the start of the buffer to the first valid byte.
(Applicale for NvBufferPayload_MemHandle) */
int32_t startofvaliddata;
/** size of the valid data from the first to the last valid byte.
(Applicale for NvBufferPayload_MemHandle) */
int32_t sizeofvaliddatainbytes;
/** display scan format - progressive/interlaced. */
NvBufferDisplayScanFormat scanformat[MAX_NUM_PLANES];
/** offset of the second field for interlaced buffer. */
uint32_t secondfieldoffset[MAX_NUM_PLANES];
/** block height of the planes for blockLinear layout hardware buffer. */
uint32_t blockheightlog2[MAX_NUM_PLANES];
/** physical address of allocated planes. */
uint32_t physicaladdress[MAX_NUM_PLANES];
/** flags associated with planes */
uint64_t flags[MAX_NUM_PLANES];
/** metadata associated with the hardware buffer. */
void *payloadmetaInfo;
/** chroma subsampling parameters */
NvBufferChromaSubsamplingParams chromaSubsampling;
/** get buffer vpr information. */
bool is_protected;
/** buffer sync point object parameters */
NvBufferSyncObj syncobj;
/** reserved field. */
void *reserved;
}NvBufferParamsEx;
/**
* Holds parameters related to compositing/blending.
*/
typedef struct _NvBufferCompositeParams
{
/** flag to indicate which of the composition/blending parameters are valid. */
uint32_t composite_flag;
/** number of the input buffers to be composited. */
uint32_t input_buf_count;
/** filters to use for composition. */
NvBufferTransform_Filter composite_filter[MAX_COMPOSITE_FRAME];
/** alpha values of input buffers for the blending. */
float dst_comp_rect_alpha[MAX_COMPOSITE_FRAME];
/** source rectangle coordinates of input buffers for composition. */
NvBufferRect src_comp_rect[MAX_COMPOSITE_FRAME];
/** destination rectangle coordinates of input buffers for composition. */
NvBufferRect dst_comp_rect[MAX_COMPOSITE_FRAME];
/** background color values for composition. */
NvBufferCompositeBackground composite_bgcolor;
/** NvBufferSession to be used for composition. If NULL, the default session
* is used. */
NvBufferSession session;
}NvBufferCompositeParams;
/**
* Holds parameters for buffer transform functions.
*/
typedef struct _NvBufferTransformParams
{
/** flag to indicate which of the transform parameters are valid. */
uint32_t transform_flag;
/** flip method. */
NvBufferTransform_Flip transform_flip;
/** transform filter. */
NvBufferTransform_Filter transform_filter;
/** source rectangle coordinates for crop opeartion. */
NvBufferRect src_rect;
/** destination rectangle coordinates for crop opeartion. */
NvBufferRect dst_rect;
/** NvBufferSession to be used for transform. If NULL, the default session
* is used. */
NvBufferSession session;
}NvBufferTransformParams;
/**
* This method can be used to wait on sync point ID.
*
* @param[in] syncobj_params sync point object parameters.
* @param[in] timeout sync point wait timeout value.
*
* @returns 0 for success, -1 for failure
*/
int NvBufferSyncObjWait (NvBufferSyncObjParams *syncobj_params, unsigned int timeout);
/**
* This method can be used to get hardware Buffer struct size.
*
* @returns hardware Buffer struct size.
*/
int NvBufferGetSize (void);
/**
* Creates an instance of EGLImage from a DMABUF FD.
*
* @param[in] display An EGLDisplay object used during the creation
* of the EGLImage. If NULL, nvbuf_utils() uses
* its own instance of EGLDisplay.
* @param[in] dmabuf_fd DMABUF FD of the buffer from which the EGLImage
* is to be created.
*
* @returns `EGLImageKHR` for success, `NULL` for failure
*/
EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd);
/**
* Destroys an EGLImage object.
*
* @param[in] display An EGLDisplay object used to destroy the EGLImage.
* If NULL, nvbuf_utils() uses its own instance of
* EGLDisplay.
* @param[in] eglImage The EGLImageKHR object to be destroyed.
*
* @returns 0 for success, -1 for failure
*/
int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage);
/**
* Allocates a hardware buffer (deprecated).
*
* @deprecated Use NvBufferCreateEx() instead.
* @param[out] dmabuf_fd Returns the DMABUF FD of the hardware buffer.
* @param[in] width Buffer width, in bytes.
* @param[in] height Buffer height, in bytes.
* @param[in] layout Layout of the buffer.
* @param[in] colorFormat Color format of the buffer.
*
* @return 0 if successful, or -1 otherwise.
*/
int NvBufferCreate (int *dmabuf_fd, int width, int height,
NvBufferLayout layout, NvBufferColorFormat colorFormat);
/**
* Allocates a hardware buffer.
*
* @param[out] dmabuf_fd Returns the DMABUF FD of the hardware buffer.
* @param[in] input_params Input parameters for hardware buffer creation.
*
* @returns 0 for success, -1 for failure
*/
int NvBufferCreateEx (int *dmabuf_fd, NvBufferCreateParams *input_params);
/**
* Allocates a hardware buffer for interlace scan format.
*
* @param[out] dmabuf_fd Returns the DMABUF FD of the hardware buffer.
* @param[in] input_params Input parameters for hardware buffer creation.
*
* @returns 0 for success, -1 for failure
*/
int NvBufferCreateInterlace (int *dmabuf_fd, NvBufferCreateParams *input_params);
/**
* Allocates a hardware buffer with a given chroma subsampling location.
*
* @param[in] dmabuf_fd DMABUF FD of the buffer.
* @param[in] input_params Input parameters for hardware buffer creation.
* @param[in] chromaSubsampling Chroma location parameters.
*
* @returns 0 for success, -1 for failure
*/
int NvBufferCreateWithChromaLoc (int *dmabuf_fd, NvBufferCreateParams *input_params, NvBufferChromaSubsamplingParams *chromaSubsampling);
/**
* Gets buffer parameters.
* @param[in] dmabuf_fd `DMABUF FD` of buffer.
* @param[out] params A pointer to the structure to fill with parameters.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params);
/**
* Gets buffer extended parameters.
* @param[in] dmabuf_fd `DMABUF FD` of buffer.
* @param[out] exparams A pointer to the structure to fill with extended parameters.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferGetParamsEx (int dmabuf_fd, NvBufferParamsEx *exparams);
/**
* Destroys a hardware buffer.
* @param[in] dmabuf_fd Specifies the `dmabuf_fd` `hw_buffer` to destroy.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferDestroy (int dmabuf_fd);
/**
* Extracts the `dmabuf_fd` from the hardware buffer.
* @param[in] nvbuf Specifies the `hw_buffer`.
* @param[out] dmabuf_fd Returns DMABUF FD of `hw_buffer`.
*
* @returns 0 for success, -1 for failure.
*/
int ExtractFdFromNvBuffer (void *nvbuf, int *dmabuf_fd);
/**
* Releases the `dmabuf_fd` buffer.
* @see ExtractfdFromNvBuffer()
* @param[in] dmabuf_fd Specifies the `dmabuf_fd` to release.
*
* @returns 0 for success, -1 for failure.
*/
int NvReleaseFd (int dmabuf_fd);
/**
* Syncs the hardware memory cache for the CPU.
*
* \sa NvBufferMemMap for the purpose of the function
*
* @param[in] dmabuf_fd DMABUF FD of buffer.
* @param[in] plane video frame plane.
* @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
/**
* Syncs the hardware memory cache for the CPU, API to be used for another process.
*
* \sa NvBufferMemMapEx for the purpose of the function
*
* @param[in] dmabuf_fd DMABUF FD of buffer.
* @param[in] exparams extended parameters for a hardware buffer.
* @param[in] plane video frame plane.
* @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemSyncForCpuEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr);
/**
* Syncs the hardware memory cache for the device.
*
* \sa NvBufferMemMap for the purpose of the function
*
* @param[in] dmabuf_fd DMABUF FD of buffer.
* @param[in] plane video frame plane.
* @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemSyncForDevice (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
/**
* Syncs the hardware memory cache for the device, API to be used for another process.
*
* \sa NvBufferMemMapEx for the purpose of the function
*
* @param[in] dmabuf_fd DMABUF FD of buffer.
* @param[in] exparams extended parameters for a hardware buffer.
* @param[in] plane video frame plane.
* @param[in] pVirtAddr Virtual Address pointer of the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemSyncForDeviceEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr);
/**
* Gets the memory-mapped virtual address of the plane.
*
* The client must call NvBufferMemSyncForCpu() with the virtual address returned
* by this function before accessing the mapped memory in CPU.
*
* After memory mapping is complete, mapped memory modification
* must be coordinated between the CPU and hardware device as
* follows:
* - CPU: If the CPU modifies any mapped memory, the client must call
* NvBufferMemSyncForDevice() before any hardware device accesses the memory.
* - Hardware device: If the mapped memory is modified by any hardware device,
* the client must call NvBufferMemSyncForCpu() before CPU accesses the memory.
*
* @param[in] dmabuf_fd DMABUF FD of buffer.
* @param[in] plane video frame plane.(Applies to @ref NvBufferPayload_SurfArray.)
* @param[in] memflag NvBuffer memory flag.
* @param[out] pVirtAddr Virtual Address pointer of the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
/**
* Gets the memory-mapped virtual address of the plane, API to be used for another process.
*
* The client must call NvBufferMemSyncForCpuEx() with the virtual address returned
* by this function before accessing the mapped memory in CPU in another process.
*
* After memory mapping is complete, mapped memory modification
* must be coordinated between the CPU and hardware device as
* follows:
* - CPU: If the CPU modifies any mapped memory, the client must call
* NvBufferMemSyncForDeviceEx() before any hardware device accesses the memory.
* - Hardware device: If the mapped memory is modified by any hardware device,
* the client must call NvBufferMemSyncForCpuEx() before CPU accesses the memory.
*
* @param[in] dmabuf_fd DMABUF FD of buffer.
* @param[in] exparams extended parameters for a hardware buffer.
* @param[in] plane video frame plane.(Applies to @ref NvBufferPayload_SurfArray.)
* @param[in] memflag NvBuffer memory flag.
* @param[out] pVirtAddr Virtual Address pointer of the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemMapEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
/**
* Unmaps the mapped virtual address of the plane.
*
* If the following conditions are both true, the client must call
* NvBufferMemSyncForDevice() before unmapping the memory:
* - Mapped memory was modified by the CPU.
* - Mapped memory will be accessed by a hardware device.
*
* @param[in] dmabuf_fd DMABUF FD of the buffer.
* @param[in] plane Video frame plane. Applies to
* @ref NvBufferPayload_SurfArray.
* @param[in] pVirtAddr Virtual address pointer to the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
/**
* Unmaps the mapped virtual address of the plane, API to be used for another process.
*
* If the following conditions are both true, the client must call
* NvBufferMemSyncForDeviceEx() before unmapping the memory in another process:
* - Mapped memory was modified by the CPU.
* - Mapped memory will be accessed by a hardware device.
*
* @param[in] dmabuf_fd DMABUF FD of the buffer.
* @param[in] exparams extended parameters for a hardware buffer.
* @param[in] plane Video frame plane. Applies to
* @ref NvBufferPayload_SurfArray.
* @param[in] pVirtAddr Virtual address pointer to the memory-mapped plane.
*
* @returns 0 for success, -1 for failure.
*/
int NvBufferMemUnMapEx (int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr);
/**
* Copies the NvBuffer plane contents to a raw buffer plane.
* @param[in] dmabuf_fd DMABUF FD of NvBuffer.
* @param[in] plane video frame plane.
* @param[in] out_width aligned width of the raw data plane.
* @param[in] out_height aligned height of the raw data plane.
* @param[in] ptr pointer to the output raw plane data.
*
* @returns 0 for success, -1 for failure.
*/
int NvBuffer2Raw (int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr);
/**
* Copies raw buffer plane contents to an NvBuffer plane.
* @param[in] ptr pointer to the input raw plane data.
* @param[in] plane video frame plane.
* @param[in] in_width aligned width of the raw data plane.
* @param[in] in_height aligned height of the raw data plane.
* @param[in] dmabuf_fd DMABUF FD of NvBuffer.
*
* @returns 0 for success, -1 for failure.
*/
int Raw2NvBuffer (unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd);
/**
* Creates a new NvBufferSession for parallel scheduling of
* buffer transformations and compositions.
*
* @returns A session pointer, NULL for failure.
*/
NvBufferSession NvBufferSessionCreate(void);
/**
* Destroys an existing \ref NvBufferSession.
* @param[in] session An existing NvBufferSession.
*/
void NvBufferSessionDestroy(NvBufferSession session);
/**
* Transforms one DMA buffer to another DMA buffer.
* This function can support transforms for copying, scaling, fliping, rotating, and cropping.
* @param[in] src_dmabuf_fd DMABUF FD of source buffer
* @param[in] dst_dmabuf_fd DMABUF FD of destination buffer
* @param[in] transform_params transform parameters
*
* @return 0 for sucess, -1 for failure.
*/
int NvBufferTransform (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params);
/**
* Transforms one DMA buffer to another DMA buffer, API to be used for another process.
* This function can support transforms for copying, scaling, fliping, rotating, and cropping.
* @param[in] src_dmabuf_fd DMABUF FD of source buffer
* @param[in] input_params extended input parameters for a hardware buffer.
* @param[in] dst_dmabuf_fd DMABUF FD of destination buffer
* @param[in] output_params extended output parameters for a hardware buffer.
* @param[in] transform_params transform parameters
*
* @return 0 for sucess, -1 for failure.
*/
int NvBufferTransformEx (int src_dmabuf_fd, NvBufferParamsEx *input_params, int dst_dmabuf_fd, NvBufferParamsEx *output_params, NvBufferTransformParams *transform_params);
/**
* Transforms one DMA buffer to another DMA buffer asyncroniously (non-blocking).
* This function can support transforms for copying, scaling, fliping, rotating, and cropping.
* @param[in] src_dmabuf_fd DMABUF FD of source buffer
* @param[in] dst_dmabuf_fd DMABUF FD of destination buffer
* @param[in] transform_params transform parameters
* @param[in] syncobj nvbuffer sync point object
*
* @return 0 for sucess, -1 for failure.
*/
int NvBufferTransformAsync (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params, NvBufferSyncObj *syncobj);
/**
* \brief Composites multiple input DMA buffers to one output DMA buffer.
*
* This function can composite multiple input frames to one output.
*
* @param[in] src_dmabuf_fds An array of DMABUF FDs of source buffers.
* These buffers are composited together. Output
* is copied to the output buffer referenced by
* @a dst_dmabuf_fd.
* @param[in] dst_dmabuf_fd DMABUF FD of the compositing destination buffer.
* @param[in] composite_params Compositing parameters.
*/
int NvBufferComposite (int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params);
#ifdef __cplusplus
}
#endif
/** @} */
#endif

1
push_info.txt Normal file
View File

@@ -0,0 +1 @@
jetson_35.1