From d8cf86fa9569aac8b93e91a23622b32655c474e2 Mon Sep 17 00:00:00 2001 From: anupamg Date: Thu, 15 Aug 2024 20:29:18 +0000 Subject: [PATCH] DCE-KMD: Add OS abstraction - Add OS abstraction for DCE-KMD driver as it will be used for Linux as well as HVRTOS. - The original OS abstraction headers are maintined under display/drivers repo (display/drivers/server/os/include/). - From that copy, only linux-kmd relevant headers are mirrored here as there's no need to mirror HVRTOS related headers. - But we need a copy here as we cannot include external paths in kernel builds. JIRA TDS-16126 Change-Id: Iabebef33719c38a8aa4db8573a0dd7dd7e5f83f6 Signed-off-by: anupamg Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3194862 Reviewed-by: Arun Swain GVS: buildbot_gerritrpt --- drivers/platform/tegra/dce/Makefile | 1 + .../platform/tegra/dce/os/include/atomic.h | 24 +++ .../tegra/dce/os/include/linux-kmd/atomic.h | 37 +++++ .../tegra/dce/os/include/linux-kmd/os-cond.h | 132 +++++++++++++++ .../dce/os/include/linux-kmd/os-dce-device.h | 98 +++++++++++ .../dce/os/include/linux-kmd/os-dce-log.h | 33 ++++ .../tegra/dce/os/include/linux-kmd/os-ivc.h | 155 ++++++++++++++++++ .../platform/tegra/dce/os/include/os-cond.h | 24 +++ .../tegra/dce/os/include/os-dce-device.h | 24 +++ .../tegra/dce/os/include/os-dce-events.h | 25 +++ .../tegra/dce/os/include/os-dce-log.h | 72 ++++++++ .../tegra/dce/os/include/os-dce-workqueue.h | 30 ++++ .../platform/tegra/dce/os/include/os-ivc.h | 24 +++ .../platform/tegra/dce/os/include/os-lock.h | 24 +++ .../platform/tegra/dce/os/include/os-utils.h | 24 +++ drivers/platform/tegra/dce/os/include/types.h | 24 +++ 16 files changed, 751 insertions(+) create mode 100644 drivers/platform/tegra/dce/os/include/atomic.h create mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h create mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/os-cond.h create mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h create mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-log.h create mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/os-ivc.h create mode 100644 drivers/platform/tegra/dce/os/include/os-cond.h create mode 100644 drivers/platform/tegra/dce/os/include/os-dce-device.h create mode 100644 drivers/platform/tegra/dce/os/include/os-dce-events.h create mode 100644 drivers/platform/tegra/dce/os/include/os-dce-log.h create mode 100644 drivers/platform/tegra/dce/os/include/os-dce-workqueue.h create mode 100644 drivers/platform/tegra/dce/os/include/os-ivc.h create mode 100644 drivers/platform/tegra/dce/os/include/os-lock.h create mode 100644 drivers/platform/tegra/dce/os/include/os-utils.h create mode 100644 drivers/platform/tegra/dce/os/include/types.h diff --git a/drivers/platform/tegra/dce/Makefile b/drivers/platform/tegra/dce/Makefile index bbbf8622..0fb6666d 100644 --- a/drivers/platform/tegra/dce/Makefile +++ b/drivers/platform/tegra/dce/Makefile @@ -14,6 +14,7 @@ endif # CONFIG_TEGRA_OOT_MODULE ccflags-y += -I$(srctree.nvidia-oot)/include ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/include +ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/os/include obj-$(CONFIG_TEGRA_DCE) += tegra-dce.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-ast.o diff --git a/drivers/platform/tegra/dce/os/include/atomic.h b/drivers/platform/tegra/dce/os/include/atomic.h new file mode 100644 index 00000000..99b4231f --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/atomic.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_ATOMIC_H +#define NVDISPLAY_SERVER_ATOMIC_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_ATOMIC_H */ diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h b/drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h new file mode 100644 index 00000000..8985cbae --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_ATOMIC_LINUX_H +#define NVDISPLAY_SERVER_ATOMIC_LINUX_H + +#include + +/** 32 bit atomic variable. */ +typedef atomic_t os_atomic_t; + +static inline void os_atomic_set(os_atomic_t *v, int i) +{ + atomic_set(v, i); + return; +} + +static inline int os_atomic_read(os_atomic_t *v) +{ + return atomic_read(v); +} + +static inline int os_atomic_add_unless(os_atomic_t *v, int a, int u) +{ + return atomic_add_unless(v, a, u); +} + +#endif /* NVDISPLAY_SERVER_ATOMIC_LINUX_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/os-cond.h b/drivers/platform/tegra/dce/os/include/linux-kmd/os-cond.h new file mode 100644 index 00000000..2c824a60 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/linux-kmd/os-cond.h @@ -0,0 +1,132 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_COND_LINUX_H +#define NVDISPLAY_SERVER_OS_COND_LINUX_H + +#include +#include + +struct dce_cond { + bool initialized; + wait_queue_head_t wq; +}; + +/** + * DCE_COND_WAIT - Wait for a condition to be true + * + * @c - The condition variable to sleep on + * @condition - The condition that needs to be true + * + * Wait for a condition to become true. + */ +#define DCE_COND_WAIT(c, condition) \ +({\ + int ret = 0; \ + wait_event((c)->wq, condition); \ + ret;\ +}) + +/** + * DCE_COND_WAIT_INTERRUPTIBLE - Wait for a condition to be true + * + * @c - The condition variable to sleep on + * @condition - The condition that needs to be true + * + * Wait for a condition to become true. Returns -ERESTARTSYS + * on signal. + */ +#define DCE_COND_WAIT_INTERRUPTIBLE(c, condition) \ +({ \ + int ret = 0; \ + ret = wait_event_interruptible((c)->wq, condition); \ + ret; \ +}) + +/** + * DCE_COND_WAIT_TIMEOUT - Wait for a condition to be true + * + * @c - The condition variable to sleep on + * @condition - The condition that needs to be true + * @timeout_ms - Timeout in milliseconds, or 0 for infinite wait. + * This parameter must be a u32. Since this is a macro, this is + * enforced by assigning a typecast NULL pointer to a u32 tmp + * variable which will generate a compiler warning (or error if + * the warning is configured as an error). + * + * Wait for a condition to become true. Returns -ETIMEOUT if + * the wait timed out with condition false. + */ +#define DCE_COND_WAIT_TIMEOUT(c, condition, timeout_ms) \ +({\ + int ret = 0; \ + /* This is the assignment to enforce a u32 for timeout_ms */ \ + u32 *tmp = (typeof(timeout_ms) *)NULL; \ + (void)tmp; \ + if (timeout_ms > 0U) { \ + long _ret = wait_event_timeout((c)->wq, condition, \ + msecs_to_jiffies(timeout_ms)); \ + if (_ret == 0) \ + ret = -ETIMEDOUT; \ + } else { \ + wait_event((c)->wq, condition); \ + } \ + ret;\ +}) + +/** + * DCE_COND_WAIT_INTERRUPTIBLE_TIMEOUT - Wait for a condition to be true + * + * @c - The condition variable to sleep on + * @condition - The condition that needs to be true + * @timeout_ms - Timeout in milliseconds, or 0 for infinite wait. + * This parameter must be a u32. Since this is a macro, this is + * enforced by assigning a typecast NULL pointer to a u32 tmp + * variable which will generate a compiler warning (or error if + * the warning is configured as an error). + * + * Wait for a condition to become true. Returns -ETIMEOUT if + * the wait timed out with condition false or -ERESTARTSYS on + * signal. + */ +#define DCE_COND_WAIT_INTERRUPTIBLE_TIMEOUT(c, condition, timeout_ms) \ +({ \ + int ret = 0; \ + /* This is the assignment to enforce a u32 for timeout_ms */ \ + u32 *tmp = (typeof(timeout_ms) *)NULL; \ + (void)tmp; \ + if (timeout_ms > 0U) { \ + long _ret = wait_event_interruptible_timeout((c)->wq, \ + condition, msecs_to_jiffies(timeout_ms)); \ + if (_ret == 0) \ + ret = -ETIMEDOUT; \ + else if (_ret == -ERESTARTSYS) \ + ret = -ERESTARTSYS; \ + } else { \ + ret = wait_event_interruptible((c)->wq, condition); \ + } \ + ret; \ +}) + +int dce_cond_init(struct dce_cond *cond); + +void dce_cond_signal(struct dce_cond *cond); + +void dce_cond_signal_interruptible(struct dce_cond *cond); + +int dce_cond_broadcast(struct dce_cond *cond); + +int dce_cond_broadcast_interruptible(struct dce_cond *cond); + +void dce_cond_destroy(struct dce_cond *cond); + +#endif /* NVDISPLAY_SERVER_OS_COND_LINUX_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h b/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h new file mode 100644 index 00000000..0cadf25a --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h @@ -0,0 +1,98 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_DCE_DEVICE_LINUX_H +#define NVDISPLAY_SERVER_OS_DCE_DEVICE_LINUX_H + +#include +#include +#include + +/** + * struct dce_device - DCE data structure for storing + * linux device specific info. + */ +struct dce_device { + /** + * @d : OS agnostic dce struct. Stores all runitme info for dce cluster + * elements. + */ + struct tegra_dce d; + /** + * @dev : Pointer to DCE Cluster's Linux device struct. + */ + struct device *dev; + /** + * @pdata : Pointer to dce platform data struct. + */ + struct dce_platform_data *pdata; + /** + * @max_cpu_irqs : stores maximum no. os irqs from DCE cluster to CPU + * for this platform. + */ + u8 max_cpu_irqs; + /** + * @regs : Stores the cpu-mapped base address of DCE Cluster. Will be + * used for MMIO transactions to DCE elements. + */ + void __iomem *regs; +#ifdef CONFIG_DEBUG_FS + /** + * @debugfs : Debugfs node for DCE Linux device. + */ + struct dentry *debugfs; + /** + * @ext_test_status : Return code for external client tests run via + * debugfs + */ + s32 ext_test_status; +#endif +}; + +/** + * dce_device_from_dce - inline function to get linux os data from the + * os agnostic struct tegra_dc + * @d : Pointer to the os agnostic tegra_dce data structure. + * + * Return : pointer to struct dce_device + */ +static inline struct dce_device *dce_device_from_dce(struct tegra_dce *d) +{ + return container_of(d, struct dce_device, d); +} + +/** + * dev_from_dce - inline function to get linux device from the + * os agnostic struct tegra_dce + * @d : Pointer to the os agnostic tegra_dce data structure. + * + * Return : pointer to struct device + */ +static inline struct device *dev_from_dce(struct tegra_dce *d) +{ + return dce_device_from_dce(d)->dev; +} + +/** + * pdata_from_dce - inline function to get dce platform data from + * the os agnostic struct tegra_dc. + * + * @d : Pointer to the os agnostic tegra_dce data structure. + * + * Return : pointer to struct device + */ +static inline struct dce_platform_data *pdata_from_dce(struct tegra_dce *d) +{ + return ((struct dce_device *)dev_get_drvdata(dev_from_dce(d)))->pdata; +} + +#endif /* NVDISPLAY_SERVER_OS_DCE_DEVICE_LINUX_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-log.h b/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-log.h new file mode 100644 index 00000000..3e9a854b --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-log.h @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +/* + * Linux implementation for logging support. + */ + +#ifndef NVDISPLAY_SERVER_OS_DCE_LOG_LINUX_H +#define NVDISPLAY_SERVER_OS_DCE_LOG_LINUX_H + +struct tegra_dce; + +enum dce_log_type { + DCE_ERROR, + DCE_WARNING, + DCE_INFO, + DCE_DEBUG, +}; + +__printf(5, 6) +void dce_log_msg(struct tegra_dce *d, const char *func_name, int line, + enum dce_log_type type, const char *fmt, ...); + +#endif /* NVDISPLAY_SERVER_OS_DCE_LOG_LINUX_H */ diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/os-ivc.h b/drivers/platform/tegra/dce/os/include/linux-kmd/os-ivc.h new file mode 100644 index 00000000..2167f574 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/linux-kmd/os-ivc.h @@ -0,0 +1,155 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_IVC_LINUX_H +#define NVDISPLAY_SERVER_OS_IVC_LINUX_H + +#include +#include + +typedef struct tegra_ivc os_ivc_t; + +/* + * Kernel API tegra_ivc_init() needs notify function as non NULL. + * We don't have a usecase for notify function as we handle it + * separately in our signaling module. + */ +static void ivc_signal_target(struct tegra_ivc *ivc, void *data) +{ + // Empty function. +} + + +/* Returns 0 on success, or a negative error value if failed. */ +static inline int os_ivc_init(os_ivc_t *ivc, + void *recv_base, void *send_base, + dma_addr_t rx_phys, dma_addr_t tx_phys, /* TODO: Confirm if it's ok to remove IOVA args. These shouldn't be required here. */ + unsigned int num_frames, size_t frame_size) +{ +#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) /* Linux v6.2 */ + struct iosys_map rx, tx; + struct iosys_map *prx = &rx, *ptx = &tx; + iosys_map_set_vaddr(prx, recv_base); + iosys_map_set_vaddr(ptx, send_base); +#else + void *prx = recv_base; + void *ptx = send_base; +#endif + + return tegra_ivc_init(ivc, NULL, + prx, rx_phys, + ptx, tx_phys, + num_frames, frame_size, + ivc_signal_target, NULL); +} + +static inline void os_ivc_reset(os_ivc_t *ivc) +{ + return tegra_ivc_reset(ivc); +} + +/* Returns 0 on success, or a negative error value if failed. */ +static inline int os_ivc_notified(os_ivc_t *ivc) +{ + return tegra_ivc_notified(ivc); +} + +/* + * Return negative err code on Failure, or 0 on Success. + * This function will populate address of next write frame + * info functions ppframe input argument. + */ +static inline int os_ivc_get_next_write_frame(os_ivc_t *ivc, void **ppframe) +{ + int err = 0; + +#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) /* Linux v6.2 */ + struct iosys_map pframe; + + err = tegra_ivc_write_get_next_frame(ivc, &pframe); + if (err) { + iosys_map_clear(&pframe); + goto done; + } +#else + void *pframe = NULL; + + pframe = tegra_ivc_write_get_next_frame(ivc); + if (IS_ERR(pframe)) { + err = -ENOMEM; + goto done; + } +#endif + + *ppframe = pframe; + +done: + return err; +} + +/* Returns 0, or a negative error value if failed. */ +static inline int os_ivc_write_advance(os_ivc_t *ivc) +{ + return tegra_ivc_write_advance(ivc); +} + +/* + * Return negative err code on Failure, or 0 on Success. + * This function will populate address of next read frame + * info functions ppframe input argument. + */ +static inline int os_ivc_get_next_read_frame(os_ivc_t *ivc, void **ppframe) +{ + int err = 0; + +#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) /* Linux v6.2 */ + struct iosys_map pframe; + + err = tegra_ivc_read_get_next_frame(ivc, &pframe); + if (err) { + iosys_map_clear(&pframe); + goto done; + } +#else + void *pframe = NULL; + + pframe = tegra_ivc_read_get_next_frame(ivc); + if (IS_ERR(pframe)) { + err = -ENOMEM; + goto done; + } +#endif + + *ppframe = pframe; + +done: + return err; +} + +/* Returns 0, or a negative error value if failed. */ +static inline int os_ivc_read_advance(os_ivc_t *ivc) +{ + return tegra_ivc_read_advance(ivc); +} + +/* TODO: Need safe coversion between size_t and uint32_t types. */ +static inline uint32_t os_ivc_align(uint32_t size) +{ + return (uint32_t)tegra_ivc_align((size_t) size); +} + +static inline uint32_t os_ivc_total_queue_size(uint32_t size) +{ + return tegra_ivc_total_queue_size(size); +} + +#endif /* NVDISPLAY_SERVER_OS_IVC_LINUX_H */ diff --git a/drivers/platform/tegra/dce/os/include/os-cond.h b/drivers/platform/tegra/dce/os/include/os-cond.h new file mode 100644 index 00000000..0d0309f2 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-cond.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_COND_H +#define NVDISPLAY_SERVER_OS_COND_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_OS_COND_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-dce-device.h b/drivers/platform/tegra/dce/os/include/os-dce-device.h new file mode 100644 index 00000000..4e6a6c63 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-dce-device.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_DCE_DEVICE_H +#define NVDISPLAY_SERVER_OS_DCE_DEVICE_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_OS_DCE_DEVICE_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-dce-events.h b/drivers/platform/tegra/dce/os/include/os-dce-events.h new file mode 100644 index 00000000..996a118b --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-dce-events.h @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_DCE_EVENTS_H +#define NVDISPLAY_SERVER_OS_DCE_EVENTS_H + +#ifdef __KERNEL__ +#define CREATE_TRACE_POINTS +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_OS_DCE_EVENTS_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-dce-log.h b/drivers/platform/tegra/dce/os/include/os-dce-log.h new file mode 100644 index 00000000..e11fb100 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-dce-log.h @@ -0,0 +1,72 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_DCE_LOG_H +#define NVDISPLAY_SERVER_OS_DCE_LOG_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +/** + * dce_err - Print an error + * + * @d - Pointer to tegra_dce. + * @fmt - A format string (printf style). + * @arg... - Arguments for the format string. + * + * Uncondtionally print an error message. + */ +#define dce_err(d, fmt, arg...) \ + dce_log_msg(d, __func__, __LINE__, DCE_ERROR, fmt, ##arg) + +/** + * dce_warn - Print a warning + * + * @d - Pointer to tegra_dce. + * @fmt - A format string (printf style). + * @arg... - Arguments for the format string. + * + * Uncondtionally print a warming message. + */ +#define dce_warn(d, fmt, arg...) \ + dce_log_msg(d, __func__, __LINE__, DCE_WARNING, fmt, ##arg) + +/** + * dce_info - Print an info message + * + * @d - Pointer to tegra_dce. + * @fmt - A format string (printf style). + * @arg... - Arguments for the format string. + * + * Unconditionally print an information message. + */ +#define dce_info(d, fmt, arg...) \ + dce_log_msg(d, __func__, __LINE__, DCE_INFO, fmt, ##arg) + +/** + * dce_debug - Print a debug message + * + * @d - Pointer to tegra_dce. + * @fmt - A format string (printf style). + * @arg... - Arguments for the format string. + * + * print a debug message. + */ +#define dce_debug(d, fmt, arg...) \ + dce_log_msg(d, __func__, __LINE__, DCE_DEBUG, fmt, ##arg) + +#endif /* NVDISPLAY_SERVER_OS_DCE_LOG_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-dce-workqueue.h b/drivers/platform/tegra/dce/os/include/os-dce-workqueue.h new file mode 100644 index 00000000..36c7c344 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-dce-workqueue.h @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_DCE_WQ_H +#define NVDISPLAY_SERVER_OS_DCE_WQ_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +int dce_init_work(struct tegra_dce *d, + struct dce_work_struct *work, + void (*work_fn)(struct tegra_dce *d)); + +void dce_schedule_work(struct dce_work_struct *work); + +#endif /* NVDISPLAY_SERVER_OS_DCE_WQ_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-ivc.h b/drivers/platform/tegra/dce/os/include/os-ivc.h new file mode 100644 index 00000000..f37109f3 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-ivc.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_IVC_H +#define NVDISPLAY_SERVER_OS_IVC_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_OS_IVC_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-lock.h b/drivers/platform/tegra/dce/os/include/os-lock.h new file mode 100644 index 00000000..e7c26420 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-lock.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_LOCK_H +#define NVDISPLAY_SERVER_OS_LOCK_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_OS_LOCK_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-utils.h b/drivers/platform/tegra/dce/os/include/os-utils.h new file mode 100644 index 00000000..b69f4281 --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/os-utils.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_OS_UTILS_H +#define NVDISPLAY_SERVER_OS_UTILS_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_OS_UTILS_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/types.h b/drivers/platform/tegra/dce/os/include/types.h new file mode 100644 index 00000000..b915a03d --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/types.h @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 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. + */ + +#ifndef NVDISPLAY_SERVER_TYPES_H +#define NVDISPLAY_SERVER_TYPES_H + +#ifdef __KERNEL__ +#include +#elif defined(NVDISPLAY_SERVER_HVRTOS) +#include "hvrtos/types.h" +#else +#error "OS Not Supported" +#endif + +#endif /* NVDISPLAY_SERVER_TYPES_H */ \ No newline at end of file