Compare commits

..

3 Commits

Author SHA1 Message Date
svcmobrel-release
d9d003cd7a Updating prebuilts and/or headers
1be6fc0d7406e0633b7e2cba49166a2f0a085cdd - gst-nvarguscamera/Makefile
ebface35fce001fdc5889214e11a84bf13cb5fde - gst-nvarguscamera/3rdpartyheaders.tbz2
599e80d95060e15842bc5d41b27ef7da35cbf8c0 - gst-nvarguscamera/gstnvarguscamerasrc.hpp
5d36eec5a4929d1a09ab8ca8e7f618b8f349275d - gst-nvarguscamera/gstnvarguscamerasrc.cpp
f2949ff626879be5aaeabf40e9ad8eab11238b6e - gst-nvarguscamera/gstnvarguscamera_utils.h
44b0e909f18f7e2f457ba501fc47d80ecedd150b - gst-nvarguscamera/nvbufsurface.h
5b71a3ab30d24949dcf3770e509d17dd1af64256 - gst-nvarguscamera/gstnvarguscamera_utils.cpp
fa14f1cb043a26a6465ce793ac78479d8f6afa02 - gst-nvarguscamera/gstnvdsbufferpool.h

Change-Id: I6dfbb6e2215141eb8a6a4264b94212a0ba0a808d
2025-08-25 17:18:07 -07:00
svcmobrel-release
02d35e5506 Updating prebuilts and/or headers
1be6fc0d7406e0633b7e2cba49166a2f0a085cdd - gst-nvarguscamera/Makefile
ebface35fce001fdc5889214e11a84bf13cb5fde - gst-nvarguscamera/3rdpartyheaders.tbz2
599e80d95060e15842bc5d41b27ef7da35cbf8c0 - gst-nvarguscamera/gstnvarguscamerasrc.hpp
5d36eec5a4929d1a09ab8ca8e7f618b8f349275d - gst-nvarguscamera/gstnvarguscamerasrc.cpp
f2949ff626879be5aaeabf40e9ad8eab11238b6e - gst-nvarguscamera/gstnvarguscamera_utils.h
44b0e909f18f7e2f457ba501fc47d80ecedd150b - gst-nvarguscamera/nvbufsurface.h
5b71a3ab30d24949dcf3770e509d17dd1af64256 - gst-nvarguscamera/gstnvarguscamera_utils.cpp
fa14f1cb043a26a6465ce793ac78479d8f6afa02 - gst-nvarguscamera/gstnvdsbufferpool.h

Change-Id: I24c361116b9461fd62b525b6e4c56c065d4f1903
2025-08-25 14:21:22 -07:00
svcmobrel-release
499d077ff9 Updating prebuilts and/or headers
1be6fc0d7406e0633b7e2cba49166a2f0a085cdd - gst-nvarguscamera/Makefile
ebface35fce001fdc5889214e11a84bf13cb5fde - gst-nvarguscamera/3rdpartyheaders.tbz2
599e80d95060e15842bc5d41b27ef7da35cbf8c0 - gst-nvarguscamera/gstnvarguscamerasrc.hpp
5d36eec5a4929d1a09ab8ca8e7f618b8f349275d - gst-nvarguscamera/gstnvarguscamerasrc.cpp
f2949ff626879be5aaeabf40e9ad8eab11238b6e - gst-nvarguscamera/gstnvarguscamera_utils.h
44b0e909f18f7e2f457ba501fc47d80ecedd150b - gst-nvarguscamera/nvbufsurface.h
5b71a3ab30d24949dcf3770e509d17dd1af64256 - gst-nvarguscamera/gstnvarguscamera_utils.cpp
fa14f1cb043a26a6465ce793ac78479d8f6afa02 - gst-nvarguscamera/gstnvdsbufferpool.h

Change-Id: I335d5e8b159ff3beaf3ac64bf2cf4f5ad1b4b721
2025-08-25 10:24:18 -07:00
6 changed files with 501 additions and 129 deletions

View File

@@ -1,10 +1,10 @@
Updating prebuilts and/or headers
ed8273ff6102bb0b4fa7975a401b12b3e95a7187 - gst-nvarguscamera/nvbufsurface.h
1be6fc0d7406e0633b7e2cba49166a2f0a085cdd - gst-nvarguscamera/Makefile
ebface35fce001fdc5889214e11a84bf13cb5fde - gst-nvarguscamera/3rdpartyheaders.tbz2
599e80d95060e15842bc5d41b27ef7da35cbf8c0 - gst-nvarguscamera/gstnvarguscamerasrc.hpp
5d36eec5a4929d1a09ab8ca8e7f618b8f349275d - gst-nvarguscamera/gstnvarguscamerasrc.cpp
f2949ff626879be5aaeabf40e9ad8eab11238b6e - gst-nvarguscamera/gstnvarguscamera_utils.h
44b0e909f18f7e2f457ba501fc47d80ecedd150b - gst-nvarguscamera/nvbufsurface.h
5b71a3ab30d24949dcf3770e509d17dd1af64256 - gst-nvarguscamera/gstnvarguscamera_utils.cpp
704bc9c630378dd0ab3da09d386464aaca369d05 - gst-nvarguscamera/gstnvarguscamerasrc.hpp
9fd26f352da599c05d8d648a43f9db533fa34a38 - gst-nvarguscamera/gstnvarguscamerasrc.cpp
148776e441cabf96340f87c88ba7ebd406ab0707 - gst-nvarguscamera/3rdpartyheaders.tbz2
fa14f1cb043a26a6465ce793ac78479d8f6afa02 - gst-nvarguscamera/gstnvdsbufferpool.h

View File

Binary file not shown.

View File

@@ -1,28 +1,30 @@
/*
* Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2017-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* 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.
* modification, are permitted provided that the following conditions are met:
*
* 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
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder 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 AND CONTRIBUTORS "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 HOLDER 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.
*/
@@ -49,6 +51,7 @@
#include <EGLStream/NV/ImageNativeBuffer.h>
#include <iostream>
#include <fstream>
#include <map>
#include <math.h>
#include <pthread.h>
@@ -69,12 +72,7 @@
#define MIN_BUFFERS 6
#define MAX_BUFFERS 8
#define MIN_GAIN 1
#define MAX_GAIN 16
#define MIN_EXPOSURE_TIME 34000
#define MAX_EXPOSURE_TIME 358733000
// this is gain value applied by ISP, its default range is [1, 256].
#define MIN_DIGITAL_GAIN 1
#define MAX_DIGITAL_GAIN 256
@@ -83,6 +81,9 @@ static const int DEFAULT_FPS = 30;
static const uint64_t DEFAULT_WAIT_FOR_EVENT_TIMEOUT = 3000000000;
static const uint64_t DEFAULT_ACQUIRE_FRAME_TIMEOUT = 5000000000;
/* TODO: Remove this as camera o/p should always be BL. Will change once BL interop pipelines are supported for OpenRM */
static gboolean is_nvgpu = TRUE;
#ifdef __cplusplus
extern "C"
{
@@ -351,11 +352,13 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
src->frameInfo = g_slice_new(NvArgusFrameInfo);
src->frameInfo->fd = -1;
src->captureIdMap.clear();
GError *error = NULL;
while (true)
{
Argus::Status frame_status;
Argus::EventType frame_event;
GError *error = NULL;
Event* event = NULL;
IEvent* iEvent = NULL;
static GQuark domain = g_quark_from_static_string ("NvArgusCameraSrc");
@@ -380,6 +383,7 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
event = (Event* )iEventQueue_ptr->getEvent(iEventQueue_ptr->getSize() - 1);
iEvent = (IEvent*)interface_cast<const IEvent>(event);
if (!iEvent)
{
src->argus_in_error = TRUE;
@@ -407,7 +411,14 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
}
else if (frame_event == EVENT_TYPE_CAPTURE_STARTED)
{
if (src->show_latency) {
guint64 capture_id = iEvent->getCaptureId();
guint64 time = iEvent->getTime() / 1000;
src->captureIdMap.insert(std::pair<guint64, guint64>(capture_id, time));
}
else {
continue;
}
}
else if (frame_event == EVENT_TYPE_CAPTURE_COMPLETE)
{
@@ -563,12 +574,12 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
src->edgeEnhancementModePropSet = FALSE;
}
if(src->edgeEnhancementStrengthPropSet)
{
l_iEeSettings_ptr->setEdgeEnhanceStrength(src->controls.EdgeEnhancementStrength);
l_iCaptureSession->repeat(l_captureRequest);
src->edgeEnhancementStrengthPropSet = FALSE;
}
if(src->edgeEnhancementStrengthPropSet)
{
l_iEeSettings_ptr->setEdgeEnhanceStrength(src->controls.EdgeEnhancementStrength);
l_iCaptureSession->repeat(l_captureRequest);
src->edgeEnhancementStrengthPropSet = FALSE;
}
if(src->aeAntibandingPropSet)
{
@@ -596,6 +607,19 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
if(src->gainRangePropSet == TRUE)
{
if (src->controls.gainRange.low < sensorModeAnalogGainRange.min())
{
GST_ARGUS_PRINT("Invalid min gain value, using default minimum gain: %f instead.\n",
sensorModeAnalogGainRange.min());
src->controls.gainRange.low = sensorModeAnalogGainRange.min();
}
if (src->controls.gainRange.high > sensorModeAnalogGainRange.max())
{
GST_ARGUS_PRINT("Invalid max gain value, using default maximum gain: %f instead.\n",
sensorModeAnalogGainRange.max());
src->controls.gainRange.high = sensorModeAnalogGainRange.max();
}
sensorModeAnalogGainRange.min() = src->controls.gainRange.low;
sensorModeAnalogGainRange.max() = src->controls.gainRange.high;
l_iRequestSourceSettings_ptr->setGainRange(sensorModeAnalogGainRange);
@@ -614,6 +638,19 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
if(src->exposureTimePropSet == TRUE)
{
if (src->controls.exposureTimeRange.low < limitExposureTimeRange.min())
{
GST_ARGUS_PRINT("Invalid min exp value, using default minimum exp: %ju instead.\n",
limitExposureTimeRange.min());
src->controls.exposureTimeRange.low = limitExposureTimeRange.min();
}
if (src->controls.exposureTimeRange.high > limitExposureTimeRange.max())
{
GST_ARGUS_PRINT("Invalid max exp value, using default maximum exp: %ju instead.\n",
limitExposureTimeRange.max());
src->controls.exposureTimeRange.high = limitExposureTimeRange.max();
}
limitExposureTimeRange.min() = src->controls.exposureTimeRange.low;
limitExposureTimeRange.max() = src->controls.exposureTimeRange.high;
l_iRequestSourceSettings_ptr->setExposureTimeRange(limitExposureTimeRange);
@@ -675,6 +712,10 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
src->frameInfo->frameNum = iFrame->getNumber();
src->frameInfo->frameTime = iFrame->getTime();
src->frameInfo->captureTime = src->captureIdMap[iFrame->getNumber()];
src->captureIdMap.erase(iFrame->getNumber());
double latency = (iEvent->getTime()/1000.0 - src->frameInfo->captureTime)/1000.0;
GST_DEBUG_OBJECT (src, "START to COMPLETE %lu latency %.2lf ms", src->frameInfo->frameNum, latency);
g_mutex_lock (&src->argus_buffers_queue_lock);
g_queue_push_tail (src->argus_buffers, (src->frameInfo));
@@ -709,6 +750,9 @@ bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src)
g_slice_free (NvArgusFrameInfo, src->frameInfo);
if (error)
g_error_free(error);
if (!src->argus_in_error)
{
CONSUMER_PRINT("Done Success\n");
@@ -735,7 +779,7 @@ static bool execute(int32_t cameraIndex,
gfloat frameRate = 0, duration = 0;
uint32_t index = 0;
gint found = 0;
gint best_match = -1;
gint best_match = 0;
Range<float> sensorModeAnalogGainRange;
Range<float> ispDigitalGainRange;
Range<uint64_t> limitExposureTimeRange;
@@ -851,6 +895,7 @@ static bool execute(int32_t cameraIndex,
frameRate = src->fps_n/ src->fps_d;
duration = 1e9 * src->fps_d/ src->fps_n;
ISensorMode *iSensorMode[modes.size()];
for (index = 0; index < modes.size(); index++)
{
iSensorMode[index] = interface_cast<ISensorMode>(modes[index]);
@@ -866,21 +911,37 @@ static bool execute(int32_t cameraIndex,
sensorModeAnalogGainRange.min(), sensorModeAnalogGainRange.max(),
limitExposureTimeRange.min(), limitExposureTimeRange.max());
}
for (index = 0; index < modes.size(); index++)
{
iSensorMode[index] = interface_cast<ISensorMode>(modes[index]);
if (!iSensorMode[index] || src->argus_in_error)
ORIGINATE_ERROR("NULL SensorMode interface detected");
if (cameraMode == NVARGUSCAM_DEFAULT_SENSOR_MODE_STATE)
{
if (src->dol_sensormode && (iSensorMode[index]->getSensorModeType() != SENSOR_MODE_TYPE_BAYER_DOL))
{
best_match++;
continue;
}
if (streamSize.width() <= iSensorMode[index]->getResolution().width() &&
streamSize.height() <= iSensorMode[index]->getResolution().height() &&
duration >= (iSensorMode[index]->getFrameDurationRange().min()))
{
if (best_match == -1 || ((streamSize.width() == iSensorMode[index]->getResolution().width()) &&
if ((streamSize.width() == iSensorMode[index]->getResolution().width()) &&
(streamSize.height() == iSensorMode[index]->getResolution().height()) &&
(iSensorMode[best_match]->getFrameDurationRange().min() >= iSensorMode[index]->getFrameDurationRange().min()))){
(iSensorMode[best_match]->getFrameDurationRange().min() >= iSensorMode[index]->getFrameDurationRange().min())){
best_match = index;
found = 1;
break;
}
else if ((iSensorMode[index]->getResolution().width()) <= iSensorMode[best_match]->getResolution().width()) {
best_match = index;
else if ((iSensorMode[index]->getResolution().width()) < iSensorMode[best_match]->getResolution().width()) {
best_match = index;
found = 1;
break;
}
found = 1;
}
}
}
@@ -1095,6 +1156,19 @@ static bool execute(int32_t cameraIndex,
if(src->exposureTimePropSet == TRUE)
{
if (src->controls.exposureTimeRange.low < limitExposureTimeRange.min())
{
GST_ARGUS_PRINT("Invalid min exp value, using default minimum exp: %ju instead.\n",
limitExposureTimeRange.min());
src->controls.exposureTimeRange.low = limitExposureTimeRange.min();
}
if (src->controls.exposureTimeRange.high > limitExposureTimeRange.max())
{
GST_ARGUS_PRINT("Invalid max exp value, using default maximum exp: %ju instead.\n",
limitExposureTimeRange.max());
src->controls.exposureTimeRange.high = limitExposureTimeRange.max();
}
limitExposureTimeRange.min() = src->controls.exposureTimeRange.low;
limitExposureTimeRange.max() = src->controls.exposureTimeRange.high;
requestSourceSettings->setExposureTimeRange(limitExposureTimeRange);
@@ -1103,6 +1177,19 @@ static bool execute(int32_t cameraIndex,
if(src->gainRangePropSet == TRUE)
{
if (src->controls.gainRange.low < sensorModeAnalogGainRange.min())
{
GST_ARGUS_PRINT("Invalid min gain value, using default minimum gain: %f instead.\n",
sensorModeAnalogGainRange.min());
src->controls.gainRange.low = sensorModeAnalogGainRange.min();
}
if (src->controls.gainRange.high > sensorModeAnalogGainRange.max())
{
GST_ARGUS_PRINT("Invalid max gain value, using default maximum gain: %f instead.\n",
sensorModeAnalogGainRange.max());
src->controls.gainRange.high = sensorModeAnalogGainRange.max();
}
sensorModeAnalogGainRange.min() = src->controls.gainRange.low;
sensorModeAnalogGainRange.max() = src->controls.gainRange.high;
requestSourceSettings->setGainRange(sensorModeAnalogGainRange);
@@ -1221,6 +1308,7 @@ enum
{
PROP_0,
PROP_SILENT,
PROP_SHOW_LATENCY,
PROP_TIMEOUT,
PROP_WHITE_BALANCE,
PROP_SATURATION,
@@ -1240,7 +1328,8 @@ enum
PROP_AE_REGION,
PROP_AWB_LOCK,
PROP_EVENT_TIMEOUT,
PROP_ACQUIRE_TIMEOUT
PROP_ACQUIRE_TIMEOUT,
PROP_DOL_SENSOR_MODE
};
typedef struct AuxiliaryData {
@@ -1342,11 +1431,10 @@ gst_nv_memory_allocator_alloc (GstAllocator * allocator,
mem = g_slice_new0 (GstNVArgusMemory);
nvbuf = g_slice_new0 (GstNvArgusCameraSrcBuffer);
{
input_params.params.width = self->width;
input_params.params.height = self->height;
input_params.params.layout = NVBUF_LAYOUT_BLOCK_LINEAR;
input_params.params.layout = (is_nvgpu == TRUE) ? NVBUF_LAYOUT_BLOCK_LINEAR : NVBUF_LAYOUT_PITCH;
input_params.params.colorFormat = NVBUF_COLOR_FORMAT_NV12;
input_params.params.memType = NVBUF_MEM_SURFACE_ARRAY;
input_params.memtag = NvBufSurfaceTag_CAMERA;
@@ -1449,7 +1537,7 @@ static GstCaps * gst_nv_argus_camera_fixate (GstBaseSrc *src, GstCaps *caps)
static gboolean gst_nv_argus_camera_set_caps (GstBaseSrc *base, GstCaps *caps)
{
GstVideoInfo info;
GstVideoInfo info = {0};
GstCaps *old;
GstNvArgusCameraSrc *src = GST_NVARGUSCAMERASRC (base);
// write own allocator here
@@ -1481,18 +1569,22 @@ static gboolean gst_nv_argus_camera_set_caps (GstBaseSrc *base, GstCaps *caps)
gst_object_unref (src->pool);
src->pool = NULL;
}
src->pool = gst_nvds_buffer_pool_new();
GstStructure *config = gst_buffer_pool_get_config (src->pool);
gst_buffer_pool_config_set_params (config, src->outcaps, sizeof(NvBufSurface), MIN_BUFFERS, MAX_BUFFERS);
gst_structure_set (config,
"memtype", G_TYPE_UINT, NVBUF_MEM_DEFAULT,
"memtag", G_TYPE_UINT, NvBufSurfaceTag_CAMERA,
"gpu-id", G_TYPE_UINT, 0,
"batch-size", G_TYPE_UINT, 1, NULL);
gst_buffer_pool_set_config (src->pool, config);
src->argus_buffers = g_queue_new ();
src->nvmm_buffers = g_queue_new ();
gst_buffer_pool_set_active (src->pool, TRUE);
src->pool = gst_buffer_pool_new();
GstNVArgusMemoryAllocator *allocator =
(GstNVArgusMemoryAllocator *)g_object_new(gst_nv_memory_allocator_get_type(), NULL);
allocator->owner = src;
GstStructure *config = gst_buffer_pool_get_config(src->pool);
gst_buffer_pool_config_set_allocator(config, GST_ALLOCATOR(allocator), NULL);
gst_buffer_pool_config_set_params(config, NULL, sizeof(NvBufSurface), MIN_BUFFERS, MAX_BUFFERS);
gst_buffer_pool_set_config(src->pool, config);
src->argus_buffers = g_queue_new();
src->nvmm_buffers = g_queue_new();
gst_buffer_pool_set_active(src->pool, TRUE);
gst_object_unref(allocator);
src->consumer_thread = g_thread_new ("consumer_thread", consumer_thread, src);
@@ -1566,7 +1658,7 @@ static gboolean gst_nv_argus_camera_stop (GstBaseSrc * src_base)
}
g_thread_join(src->consumer_thread);
while (!g_queue_is_empty (src->nvmm_buffers)) {
while (!g_queue_is_empty (src->nvmm_buffers)) {
buf = (GstBuffer *) g_queue_pop_head (src->nvmm_buffers);
gst_buffer_unref (buf);
}
@@ -1670,7 +1762,7 @@ consumer_thread (gpointer src_base)
consumerFrameInfo = (NvArgusFrameInfo *) g_queue_pop_head (src->argus_buffers);
g_mutex_unlock (&src->argus_buffers_queue_lock);
if(&consumerFrameInfo->fd == NULL)
if(consumerFrameInfo == NULL)
{
goto done;
}
@@ -1685,14 +1777,34 @@ consumer_thread (gpointer src_base)
goto done;
}
mem = gst_buffer_peek_memory (buffer, 0);
GstMapInfo outmap = GST_MAP_INFO_INIT;
if (!mem) {
GST_ERROR_OBJECT(src, "no memory block");
GstNVArgusMemory *nv_mem = NULL;
mem = gst_buffer_peek_memory(buffer, 0);
GstMiniObject *miniobj = NULL;
nv_mem = (GstNVArgusMemory *)mem;
nv_mem->auxData.frame_num = consumerFrameInfo->frameNum;
nv_mem->auxData.timestamp = consumerFrameInfo->frameTime;
miniobj = GST_MINI_OBJECT_CAST(buffer);
if (gst_mini_object_is_writable(miniobj))
gst_mini_object_set_qdata(miniobj,
gst_buffer_metadata_quark, &((GstNVArgusMemory *)mem)->auxData, NULL);
if (consumerFrameInfo->fd == 0)
{
g_mutex_lock(&src->argus_buffer_consumed_lock);
g_cond_signal(&src->argus_buffer_consumed_cond);
src->is_argus_buffer_consumed = TRUE;
g_mutex_unlock(&src->argus_buffer_consumed_lock);
goto done;
}
NvBufSurface *surf = 0;
retn = NvBufSurfaceFromFd(nv_mem->nvcam_buf->dmabuf_fd, (void **)(&surf));
if (retn != 0) {
GST_ERROR_OBJECT(src, "NvBufSurfaceFromFd Failed");
goto done;
}
gst_buffer_map (buffer, &outmap, GST_MAP_WRITE);
NvBufSurface* surf = (NvBufSurface *)outmap.data;
NvBufSurface *nvbuf_surf = 0;
retn = NvBufSurfaceFromFd(consumerFrameInfo->fd, (void**)(&nvbuf_surf));
@@ -1701,6 +1813,7 @@ consumer_thread (gpointer src_base)
goto done;
}
retn = NvBufSurfTransform(nvbuf_surf, surf, &src->transform_params);
g_mutex_lock (&src->argus_buffer_consumed_lock);
g_cond_signal (&src->argus_buffer_consumed_cond);
src->is_argus_buffer_consumed = TRUE;
@@ -1711,7 +1824,14 @@ consumer_thread (gpointer src_base)
goto done;
}
gst_buffer_unmap (buffer, &outmap);
/* XXX: CAPTURE START event could be missing in some case,
* ignore the latency calcuation to avoid unreasonable latency */
if (src->show_latency && consumerFrameInfo->captureTime)
{
guint64 current_time = g_get_monotonic_time();
double latency = (current_time - consumerFrameInfo->captureTime)/1000.0;
GST_DEBUG_OBJECT (src, "capture id %lu latency %.2lf ms", consumerFrameInfo->frameNum, latency);
}
g_mutex_lock (&src->nvmm_buffers_queue_lock);
g_queue_push_tail (src->nvmm_buffers, buffer);
@@ -1831,22 +1951,12 @@ static gboolean set_range (GstNvArgusCameraSrc *src, guint prop_id)
{
if(prop_id == PROP_GAIN_RANGE)
{
if (array[0] < MIN_GAIN || array[1] > MAX_GAIN) {
GST_ARGUS_PRINT("Invalid Gain Range Input\n");
ret = FALSE;
goto done;
}
range.low = array[0];
range.high = array[1];
src->controls.gainRange = range;
}
else if(prop_id == PROP_EXPOSURE_TIME_RANGE)
{
if (array[0] < MIN_EXPOSURE_TIME || array[1] > MAX_EXPOSURE_TIME) {
GST_ARGUS_PRINT("Invalid Exposure Time Range Input\n");
ret = FALSE;
goto done;
}
range.low = array[0];
range.high = array[1];
src->controls.exposureTimeRange = range;
@@ -1977,6 +2087,11 @@ gst_nv_argus_camera_src_class_init (GstNvArgusCameraSrcClass * klass)
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_SHOW_LATENCY,
g_param_spec_boolean ("show-latency", "show-latency",
"Show capture latency between start of frame and GstBuffer push",
FALSE, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_TIMEOUT,
g_param_spec_uint ("timeout", "timeout",
"timeout to capture in seconds (Either specify timeout or num-buffers, not both)",
@@ -2030,7 +2145,7 @@ gst_nv_argus_camera_src_class_init (GstNvArgusCameraSrcClass * klass)
"\t\t\tUse string with values of ISP Digital Gain Range (low, high)\n"
"\t\t\tin that order, to set the property.\n"
"\t\t\teg: ispdigitalgainrange=\"1 8\"",
NVARGUSCAM_DEFAULT_GAIN_RANGE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
NVARGUSCAM_DEFAULT_DIGITAL_GAIN_RANGE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_TNR_STRENGTH,
g_param_spec_float ("tnr-strength", "TNR Strength",
@@ -2090,6 +2205,11 @@ gst_nv_argus_camera_src_class_init (GstNvArgusCameraSrcClass * klass)
DEFAULT_ACQUIRE_FRAME_TIMEOUT, G_MAXUINT64, DEFAULT_ACQUIRE_FRAME_TIMEOUT,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_DOL_SENSOR_MODE,
g_param_spec_boolean ("dol_sm", "DOL Sensor Mode",
"Select the DOL Sensor Mode. This will be overrided when sensor-mode is explicitly set",
FALSE, (GParamFlags) G_PARAM_READWRITE));
gst_element_class_set_details_simple(gstelement_class,
"NvArgusCameraSrc",
"Video/Capture",
@@ -2115,6 +2235,7 @@ gst_nv_argus_camera_src_init (GstNvArgusCameraSrc * src)
src->stop_requested = FALSE;
src->unlock_requested = FALSE;
src->silent = TRUE;
src->show_latency = FALSE;
src->outcaps = NULL;
src->timeout = 0;
src->event_timeout = DEFAULT_WAIT_FOR_EVENT_TIMEOUT;
@@ -2181,6 +2302,10 @@ static void gst_nv_argus_camera_src_finalize (GObject *object)
g_free (src->ispDigitalGainRangeString);
src->ispDigitalGainRangeString = NULL;
}
if(src->outcaps) {
gst_caps_unref (src->outcaps);
src->outcaps = NULL;
}
}
static void
@@ -2194,6 +2319,9 @@ gst_nv_argus_camera_src_set_property (GObject * object, guint prop_id,
case PROP_SILENT:
src->silent = g_value_get_boolean (value);
break;
case PROP_SHOW_LATENCY:
src->show_latency = g_value_get_boolean (value);
break;
case PROP_TIMEOUT:
src->timeout = g_value_get_uint (value);
break;
@@ -2309,6 +2437,9 @@ gst_nv_argus_camera_src_set_property (GObject * object, guint prop_id,
case PROP_ACQUIRE_TIMEOUT:
src->acquire_timeout = g_value_get_uint64(value);
break;
case PROP_DOL_SENSOR_MODE:
src->dol_sensormode = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2326,6 +2457,9 @@ gst_nv_argus_camera_src_get_property (GObject * object, guint prop_id,
case PROP_SILENT:
g_value_set_boolean (value, src->silent);
break;
case PROP_SHOW_LATENCY:
g_value_set_boolean (value, src->show_latency);
break;
case PROP_TIMEOUT:
g_value_set_uint (value, src->timeout);
break;
@@ -2386,6 +2520,9 @@ gst_nv_argus_camera_src_get_property (GObject * object, guint prop_id,
case PROP_ACQUIRE_TIMEOUT:
g_value_set_uint64 (value, src->acquire_timeout);
break;
case PROP_DOL_SENSOR_MODE:
g_value_set_boolean(value, src->dol_sensormode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2401,6 +2538,16 @@ gst_nv_argus_camera_src_get_property (GObject * object, guint prop_id,
static gboolean
nvarguscamerasrc_init (GstPlugin * nvarguscamerasrc)
{
int result = -1;
result = (gboolean)system("lsmod | grep 'nvgpu' > /dev/null");
if (result == 0) {
is_nvgpu = TRUE;
}
else {
is_nvgpu = FALSE;
}
/* debug category for fltering log messages
*
* exchange the string 'Template nvarguscamerasrc' with your description

View File

@@ -1,28 +1,30 @@
/*
* Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* 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.
* modification, are permitted provided that the following conditions are met:
*
* 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
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder 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 AND CONTRIBUTORS "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 HOLDER 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.
*/
@@ -113,6 +115,7 @@ typedef struct NvArgusFrameInfo
gint fd;
guint64 frameNum;
guint64 frameTime;
guint64 captureTime;
} NvArgusFrameInfo;
struct _GstNvArgusCameraSrc
@@ -125,6 +128,7 @@ struct _GstNvArgusCameraSrc
GThread *argus_thread;
gboolean silent;
gboolean show_latency;
GstBufferPool *pool;
@@ -188,6 +192,7 @@ struct _GstNvArgusCameraSrc
gboolean aeRegionPropSet;
gboolean awbLockPropSet;
gboolean argus_in_error;
gboolean dol_sensormode;
void *iRequest_ptr;
void *iCaptureSession_ptr;
void *AeRegion_ptr;
@@ -204,6 +209,9 @@ struct _GstNvArgusCameraSrc
Argus::UniqueObj<Argus::OutputStreamSettings> streamSettings;
Argus::UniqueObj<Argus::Request> request;
NvArgusFrameInfo *frameInfo;
/* Key: capture id, value: timestamp */
std::map<guint64, guint64> captureIdMap;
};
struct _GstNvArgusCameraSrcClass

View File

@@ -1,11 +1,13 @@
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
*
* 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.
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
* property and proprietary rights in and to this material, related
* documentation and any modifications thereto. Any use, reproduction,
* disclosure or distribution of this material and related documentation
* without an express license agreement from NVIDIA CORPORATION or
* its affiliates is strictly prohibited.
*/
/**
@@ -278,6 +280,38 @@ typedef enum
NVBUF_COLOR_FORMAT_NV12_12LE_709,
/** Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 12-bit multi-planar. */
NVBUF_COLOR_FORMAT_NV12_12LE_709_ER,
/** Specifies 8 bit GRAY scale ER - single plane */
NVBUF_COLOR_FORMAT_GRAY8_ER,
/** Specifies BT.709 colorspace - Y/CbCr 4:2:2 planar */
NVBUF_COLOR_FORMAT_UYVY_709,
/** Specifies BT.709 colorspace - Y/CbCr ER 4:2:2 planar */
NVBUF_COLOR_FORMAT_UYVY_709_ER,
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 planar */
NVBUF_COLOR_FORMAT_UYVY_2020,
/** Specifies 16 bit GRAY scale - single plane */
NVBUF_COLOR_FORMAT_GRAY16_LE,
/** Specifies 64 bit BGRA (B16 G16 R16 A16) interleaved */
NVBUF_COLOR_FORMAT_BGRA64_LE,
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 multi-planar. */
NVBUF_COLOR_FORMAT_NV16_2020,
/** Specifies BT.601_ER colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_10LE_ER,
/** Specifies BT.709 colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_10LE_709,
/** Specifies BT.709_ER colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_10LE_709_ER,
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_10LE_2020,
/** Specifies BT.601 colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_12LE,
/** Specifies BT.601_ER colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_12LE_ER,
/** Specifies BT.709 colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_12LE_709,
/** Specifies BT.709_ER colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_12LE_709_ER,
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
NVBUF_COLOR_FORMAT_NV16_12LE_2020,
NVBUF_COLOR_FORMAT_LAST
} NvBufSurfaceColorFormat;
@@ -341,7 +375,9 @@ typedef struct NvBufSurfacePlaneParamsEx
uint32_t physicaladdress[NVBUF_MAX_PLANES];
/** flags associated with planes */
uint64_t flags[NVBUF_MAX_PLANES];
/** DRM modifier for plane */
uint64_t drmModifier[NVBUF_MAX_PLANES];
/** Holds the reserved space for future use. */
void * _reserved[STRUCTURE_PADDING * NVBUF_MAX_PLANES];
} NvBufSurfacePlaneParamsEx;
@@ -364,19 +400,25 @@ typedef struct NvBufSurfacePlaneParams
uint32_t psize[NVBUF_MAX_PLANES];
/** Holds the number of bytes occupied by a pixel in each plane. */
uint32_t bytesPerPix[NVBUF_MAX_PLANES];
/** Holds the reserved space for future use. */
void * _reserved[STRUCTURE_PADDING * NVBUF_MAX_PLANES];
} NvBufSurfacePlaneParams;
/**
* Holds Chroma Subsampling parameters for NvBufSurface allocation.
* The members chromaLocHoriz and chromaLocVert accept these values:
* 0: Left horizontal or top vertical position
* 1: Center horizontal or center vertical position
* 2: Right horizontal or bottom vertical position
*/
typedef struct NvBufSurfaceChromaSubsamplingParams
{
/** location settings */
uint8_t chromaLocHoriz;
uint8_t chromaLocVert;
/** Reserved for alignment */
uint8_t _reserved[6];
} NvBufSurfaceChromaSubsamplingParams;
/**
@@ -402,6 +444,8 @@ typedef struct NvBufSurfaceCreateParams {
NvBufSurfaceLayout layout;
/** Holds the type of memory to be allocated. */
NvBufSurfaceMemType memType;
/** Holds the reserved space for future use. */
void * _reserved[STRUCTURE_PADDING];
} NvBufSurfaceCreateParams;
/**
@@ -409,24 +453,24 @@ typedef struct NvBufSurfaceCreateParams {
* (Applicable for NvBufSurfaceAllocate API)
*/
typedef struct NvBufSurfaceAllocateParams {
/** Hold legacy NvBufSurface creation parameters */
/** Hold legacy NvBufSurface creation parameters */
NvBufSurfaceCreateParams params;
/** Display scan format */
/** Display scan format */
NvBufSurfaceDisplayScanFormat displayscanformat;
/** Chroma Subsampling parameters */
/** Chroma Subsampling parameters */
NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
/** components tag to be used for memory allocation */
/** components tag to be used for memory allocation */
NvBufSurfaceTag memtag;
/** disable pitch padding allocation only applicable for cuda and system memory allocation
pitch would be width times bytes per pixel for the plane, for odd width it would be
multiple of 2, also note for some non standard video resolution cuda kernels may fail
/** disable pitch padding allocation only applicable for cuda and system memory allocation
pitch would be width times bytes per pixel for the plane, for odd width it would be
multiple of 2, also note for some non standard video resolution cuda kernels may fail
due to unaligned pitch
*/
*/
bool disablePitchPadding;
/** Used void* from custom param for 64 bit machine, using other uint32_t param */
/** Used void* from custom param for 64 bit machine, using other uint32_t param */
uint32_t _reservedParam;
void * _reserved[STRUCTURE_PADDING-1];
/** Holds the reserved space for future use. */
void * _reserved[STRUCTURE_PADDING];
} NvBufSurfaceAllocateParams;
/**
@@ -437,7 +481,11 @@ typedef struct NvBufSurfaceMappedAddr {
void * addr[NVBUF_MAX_PLANES];
/** Holds a pointer to a mapped EGLImage. */
void *eglImage;
/** Holds a pointer to a mapped NVRM memory */
void *nvmmPtr;
/** Holds a pointer to a mapped CUDA memory */
void *cudaPtr;
/** Holds the reserved space for future use. */
void * _reserved[STRUCTURE_PADDING];
} NvBufSurfaceMappedAddr;
@@ -462,6 +510,32 @@ typedef struct NvBufSurfaceParamsEx {
void * _reserved[STRUCTURE_PADDING];
} NvBufSurfaceParamsEx;
/**
* Holds information of CUDA buffer.
* Applicable for tegra OpenRM only.
*/
typedef struct NvBufSurfaceCudaBuffer {
/**
* Holds a base pointer to allocated CUDA memory.
* It is different from dataPtr when CUDA allocated
* address is not page aligned for image buffers.
* It is same as dataPtr for other buffers.
*/
void *basePtr;
/**
* Holds a page aligned data pointer to CUDA memory for image buffers
* if CUDA allocated address is not page aligned.
* It is same as basePtr for other buffers.
*/
void *dataPtr;
/** Holds a pointer to external CUDA memory for imported CUDA buffers */
void *extMem;
/** Holds a pointer to external CUDA mipmaped array for imported CUDA buffers */
void *mipmap;
/** Reserved */
uint8_t reserved[64];
} NvBufSurfaceCudaBuffer;
/**
* Hold the information of single buffer in the batch.
*/
@@ -491,8 +565,10 @@ typedef struct NvBufSurfaceParams {
NvBufSurfaceMappedAddr mappedAddr;
/** pointers of extended parameters of single buffer in the batch.*/
NvBufSurfaceParamsEx *paramex;
/** Holds a pointer to CUDA buffer. Applicable for only CUDA Device and CUDA Host memory on tegra OpenRM.*/
NvBufSurfaceCudaBuffer *cudaBuffer;
void * _reserved[STRUCTURE_PADDING - 1];
void * _reserved[STRUCTURE_PADDING];
} NvBufSurfaceParams;
/**
@@ -513,6 +589,8 @@ typedef struct NvBufSurface {
NvBufSurfaceMemType memType;
/** Holds a pointer to an array of batched buffers. */
NvBufSurfaceParams *surfaceList;
/** Holds a flag for Imported buffer. */
bool isImportedBuf;
void * _reserved[STRUCTURE_PADDING];
} NvBufSurface;
@@ -542,6 +620,23 @@ typedef struct NvBufSurfaceMapPlaneParams
uint8_t reserved[64];
} NvBufSurfaceMapPlaneParams;
/**
* CUDA IPC memory handle for NvBufSurface
*/
typedef struct NvBufSurfaceCudaIpcMemHandle_t
{
char reserved[64];
} NvBufSurfaceCudaIpcMemHandle;
/**
* The extended map parameters NvBufSurface
*/
typedef struct NvBufSurfaceExtendedMapParams_t
{
NvBufSurfaceCudaIpcMemHandle memHandle;
void *reserved[64];
} NvBufSurfaceExtendedMapParams;
/**
* Holds buffer parameters to map the buffer received from another process.
*/
@@ -566,9 +661,44 @@ typedef struct NvBufSurfaceMapParams {
NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
/** Holds plane parameters */
NvBufSurfaceMapPlaneParams planes[NVBUF_MAX_PLANES];
/** Holds the extended Map parameters */
void *extendedMapParams;
/** Holds the reserved space for future use. */
void *_reserved[STRUCTURE_PADDING];
} NvBufSurfaceMapParams;
/**
* Holds information about mapped CUDA buffer
*/
typedef struct NvBufSurfaceNvmmBuffer {
/** Holds a pointer to mapped nvmm memory */
void *dataPtr;
/** Holds a DMABUF FD */
uint64_t bufferDesc;
/** Reserved */
uint8_t reserved[64];
} NvBufSurfaceMapParams;
} NvBufSurfaceNvmmBuffer;
/**
* Defines the type of underlying kernel driver detected for GPU access.
*/
typedef enum {
NVBUF_DRIVER_TYPE_UNKNOWN = 0,
NVBUF_DRIVER_TYPE_NVGPU,
NVBUF_DRIVER_TYPE_RM
} NvBufSurfaceDriverType;
/**
* Holds information about the underlying device.
*/
typedef struct NvBufSurfaceDeviceInfo {
/** The detected device type (nvgpu, OpenRM, etc.). */
NvBufSurfaceDriverType driverType;
/** Indicates if VIC is present on the platform. */
bool isVicPresent;
/** Reserved for future use. */
uint8_t reserved[64];
} NvBufSurfaceDeviceInfo;
/**
* \brief Allocates a batch of buffers.
@@ -699,7 +829,7 @@ int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
* This function can be used to copy plane memory content from source raw buffer pointer
* to specific destination batch buffer of supported memory type.
*
* @param[in] surf pointer to NvBufSurface structure.
* @param[in] Surf pointer to NvBufSurface structure.
* @param[in] index index of buffer in the batch.
* @param[in] plane index of plane in buffer.
* @param[in] out_width aligned width of the raw data plane.
@@ -708,7 +838,7 @@ int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
*
* @return 0 for success, -1 for failure.
*/
int NvBufSurface2Raw (NvBufSurface *Surf, unsigned int index, unsigned int plane, unsigned int outwidth, unsigned int outheight, unsigned char *ptr);
int NvBufSurface2Raw (NvBufSurface *Surf, unsigned int index, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr);
/**
* \brief Copies the raw buffer plane memory content to the NvBufSurface plane memory of a specific
@@ -722,11 +852,11 @@ int NvBufSurface2Raw (NvBufSurface *Surf, unsigned int index, unsigned int plane
* @param[in] plane index of plane in buffer.
* @param[in] in_width aligned width of the raw data plane.
* @param[in] in_height aligned height of the raw data plane.
* @param[in] surf pointer to NvBufSurface structure.
* @param[in] Surf pointer to NvBufSurface structure.
*
* @return 0 for success, -1 for failure.
*/
int Raw2NvBufSurface (unsigned char *ptr, unsigned int index, unsigned int plane, unsigned int inwidth, unsigned int inheight, NvBufSurface *Surf);
int Raw2NvBufSurface (unsigned char *ptr, unsigned int index, unsigned int plane, unsigned int in_width, unsigned int in_height, NvBufSurface *Surf);
/**
* Syncs the HW memory cache for the CPU.
@@ -850,7 +980,94 @@ int NvBufSurfaceImport (NvBufSurface **out_nvbuf_surf, const NvBufSurfaceMapPara
*/
int NvBufSurfaceGetMapParams (const NvBufSurface *surf, int index, NvBufSurfaceMapParams *params);
/** @} */
/**
* \brief Creates an CUDA buffer from the memory of one or more
* \ref NvBufSurface buffers.
*
* Only memory type \ref NVBUF_MEM_SURFACE_ARRAY is supported.
*
* This function returns the created CUDA buffer by storing its address at
* \a surf->surfaceList->mappedAddr->cudaPtr. (\a surf is a pointer to
* an NvBufSurface. \a surfaceList is a pointer to an \ref NvBufSurfaceParams.
* \a mappedAddr is a pointer to an \ref NvBufSurfaceMappedAddr.
* \a cudaPtr is a pointer to an \ref NvBufSurfaceCudaBuffer.
*
* You can use this function in scenarios where a CUDA operation on Jetson
* hardware memory (identified by \ref NVBUF_MEM_SURFACE_ARRAY) is required.
* The NvBufSurfaceCudaBuffer struct provided by this function can be used
* to get dataPtr of CUDA memory.
*
* @param[in,out] surf A pointer to an NvBufSurface structure. The function
* stores a pointer to the created CUDA buffer in
* a descendant of this structure; see the notes above.
* @param[in] index Index of a buffer in the batch. -1 specifies all buffers
* in the batch.
*
* @return 0 for success, or -1 otherwise.
*/
int NvBufSurfaceMapCudaBuffer (NvBufSurface *surf, int index);
/**
* \brief Destroys the previously created CUDA buffer.
*
* @param[in] surf A pointer to an \ref NvBufSurface structure.
* @param[in] index The index of a buffer in the batch. -1 specifies all
* buffers in the batch.
*
* @return 0 if successful, or -1 otherwise.
*/
int NvBufSurfaceUnMapCudaBuffer (NvBufSurface *surf, int index);
/**
* \brief Creates an NVMM buffer from the memory of one or more
* \ref NvBufSurface buffers.
*
* Only memory type \ref NVBUF_MEM_CUDA_DEVICE and \ref NVBUF_MEM_CUDA_PINNED
* are supported.
*
* This function returns the created NVMM buffer by storing its address at
* \a surf->surfaceList->mappedAddr->nvmmPtr. (\a surf is a pointer to
* an NvBufSurface. \a surfaceList is a pointer to an \ref NvBufSurfaceParams.
* \a mappedAddr is a pointer to an \ref NvBufSurfaceMappedAddr.
* \a nvmmPtr is a pointer to NVMM buffer of memory type \ref NVBUF_MEM_SURFACE_ARRAY.
*
* You can use this function in scenarios where a NVBUF_MEM_SURFACE_ARRAY operation
* on Jetson hardware memory identified by \ref NVBUF_MEM_CUDA_DEVICE and
* \ref NVBUF_MEM_CUDA_PINNED are required.
*
* @param[in,out] surf A pointer to an NvBufSurface structure. The function
* stores a pointer to the created NVMM buffer in
* a descendant of this structure; see the notes above.
* @param[in] index Index of a buffer in the batch. -1 specifies all buffers
* in the batch.
*
* @return 0 for success, or -1 otherwise.
*/
int NvBufSurfaceMapNvmmBuffer (NvBufSurface *surf, int index);
/**
* \brief Destroys the previously created NVMM buffer.
*
* @param[in] surf A pointer to an \ref NvBufSurface structure.
* @param[in] index The index of a buffer in the batch. -1 specifies all
* buffers in the batch.
*
* @return 0 if successful, or -1 otherwise.
*/
int NvBufSurfaceUnMapNvmmBuffer (NvBufSurface *surf, int index);
/**
* \brief Retrieves information about the underlying GPU device driver.
*
* @param[out] info Pointer to NvBufSurfaceDeviceInfo structure.
*
* @return 0 if successful, or -1 otherwise.
*
* This function attempts to determine if the system is using 'nvgpu' or
* an OpenRM-based driver by checking loaded kernel modules. Also it checks
* if VIC is present on the platform.
*/
int NvBufSurfaceGetDeviceInfo (NvBufSurfaceDeviceInfo *info);
#ifdef __cplusplus
}

View File

@@ -1 +1 @@
jetson_35.5_APT1
daily-2025.08.25.1_l4t/l4t-r38.2