//! \file //! \brief NvStreams rawstream main file. //! //! \copyright //! SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. //! SPDX-License-Identifier: LicenseRef-NvidiaProprietary //! //! 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. #include "rawstream.h" #include NvSciSyncModule syncModule = NULL; NvSciBufModule bufModule = NULL; NvSciSyncAttrList producerSignalAttrs = NULL; NvSciSyncAttrList consumerSignalAttrs = NULL; NvSciSyncAttrList producerWaitAttrs = NULL; NvSciSyncAttrList consumerWaitAttrs = NULL; NvSciSyncAttrList prodToConsAttrs = NULL; NvSciSyncAttrList consToProdAttrs = NULL; NvSciSyncObj consumerSignalObj = NULL; NvSciSyncObj producerSignalObj = NULL; NvSciSyncObj consumerWaitObj = NULL; NvSciSyncObj producerWaitObj = NULL; NvSciBufAttrList producerWriteAttrs = NULL; NvSciBufAttrList consumerReadAttrs = NULL; NvSciBufAttrList combinedBufAttrs = NULL; Buffer buffers[totalBuffers]; IpcWrapper ipcWrapper; int late_attach = 0; int main(int argc, char *argv[]) { NvSciError err; int producer; const char* endpoint = "Unknown"; int ret = 0; int opt; producer = -1; while ((opt = getopt(argc, argv, "pcl")) != -1) { switch (opt) { case 'p': producer = 1; endpoint = "Producer"; break; case 'c': producer = 0; endpoint = "Consumer"; break; case 'l': late_attach = 1; break; default: fprintf(stderr, "Unknown option: '%c'\n", opt); } } if (producer == -1 || optind < argc) { fprintf(stderr, "Usage: ./rawstream [-l] {-p or -c}\n"); fprintf(stderr, "-p denotes producer, -c denotes consumer, -l denotes late-attach \n"); fprintf(stderr, "either -p or -c should be provided, while -l is optional param\n"); return 1; } fprintf(stderr, "%p application starting\n", endpoint); // Open sync module (shared by both all threads) err = NvSciSyncModuleOpen(&syncModule); if (NvSciError_Success != err) { fprintf(stderr, "%s unable to open sync module (%x)\n", endpoint, err); return 1; } // Open buf module (shared by both all threads) err = NvSciBufModuleOpen(&bufModule); if (NvSciError_Success != err) { fprintf(stderr, "%s unable to open buf module (%x)\n", endpoint, err); ret = 1; goto close_sync_module; } // Initialize IPC library err = NvSciIpcInit(); if (NvSciError_Success != err) { fprintf(stderr, "%s unable to init ipc library (%x)\n", endpoint, err); ret = 1; goto close_buf_module; } // Establish IPC communications based on endpoint // TODO: Settle on final IPC channel names if (producer == 1) { err = ipcInit("nvscisync_a_0", &ipcWrapper); } else { err = ipcInit("nvscisync_a_1", &ipcWrapper); } if (NvSciError_Success != err) { fprintf(stderr, "%s unable to initialize communication (%x)\n", endpoint, err); ret = 1; goto deinit_IPC; } // Test communication by exchanging a simple handshake message const int send_handshake = 12345; err = ipcSend(&ipcWrapper, &send_handshake, sizeof(send_handshake)); if (NvSciError_Success != err) { fprintf(stderr, "%s failed to send handshake (%x)\n", endpoint, err); ret = 1; goto deinit_IPC; } int recv_handshake = 0; ipcRecvFill(&ipcWrapper, &recv_handshake, sizeof(recv_handshake)); if (NvSciError_Success != err) { fprintf(stderr, "%s failed to receive handshake (%x)\n", endpoint, err); ret = 1; goto deinit_IPC; } if (send_handshake != recv_handshake) { fprintf(stderr, "%s handshake did not match (%x)\n", endpoint, err); ret = 1; goto deinit_IPC; } // Initialize buffer list for (uint32_t i=0; i 0; j--) { if (tmp & 1) { tmp = (tmp >> 1) ^ CRC32_POLYNOMIAL; } else { tmp >>= 1; } } crcTable[i] = tmp; } initialized = 1; } //Calculate CRC for the data for (y = 0U; y < height; y++) { for (x = 0U; x < width; x++) { tmp = (crc >> 8) & 0x00FFFFFFL; crc = tmp ^ crcTable[((uint32_t) crc ^ *(data_ptr + x)) & 0xFF]; } data_ptr += pitch; } return crc; }