/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */1/*2* Copyright (C) 2020-2025 Intel Corporation3*/45#ifndef __UAPI_IVPU_DRM_H__6#define __UAPI_IVPU_DRM_H__78#include "drm.h"910#if defined(__cplusplus)11extern "C" {12#endif1314#define DRM_IVPU_GET_PARAM 0x0015#define DRM_IVPU_SET_PARAM 0x0116#define DRM_IVPU_BO_CREATE 0x0217#define DRM_IVPU_BO_INFO 0x0318#define DRM_IVPU_SUBMIT 0x0519#define DRM_IVPU_BO_WAIT 0x0620#define DRM_IVPU_METRIC_STREAMER_START 0x0721#define DRM_IVPU_METRIC_STREAMER_STOP 0x0822#define DRM_IVPU_METRIC_STREAMER_GET_DATA 0x0923#define DRM_IVPU_METRIC_STREAMER_GET_INFO 0x0a24#define DRM_IVPU_CMDQ_CREATE 0x0b25#define DRM_IVPU_CMDQ_DESTROY 0x0c26#define DRM_IVPU_CMDQ_SUBMIT 0x0d2728#define DRM_IOCTL_IVPU_GET_PARAM \29DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_GET_PARAM, struct drm_ivpu_param)3031#define DRM_IOCTL_IVPU_SET_PARAM \32DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SET_PARAM, struct drm_ivpu_param)3334#define DRM_IOCTL_IVPU_BO_CREATE \35DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_CREATE, struct drm_ivpu_bo_create)3637#define DRM_IOCTL_IVPU_BO_INFO \38DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_INFO, struct drm_ivpu_bo_info)3940#define DRM_IOCTL_IVPU_SUBMIT \41DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SUBMIT, struct drm_ivpu_submit)4243#define DRM_IOCTL_IVPU_BO_WAIT \44DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_WAIT, struct drm_ivpu_bo_wait)4546#define DRM_IOCTL_IVPU_METRIC_STREAMER_START \47DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_START, \48struct drm_ivpu_metric_streamer_start)4950#define DRM_IOCTL_IVPU_METRIC_STREAMER_STOP \51DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_STOP, \52struct drm_ivpu_metric_streamer_stop)5354#define DRM_IOCTL_IVPU_METRIC_STREAMER_GET_DATA \55DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_GET_DATA, \56struct drm_ivpu_metric_streamer_get_data)5758#define DRM_IOCTL_IVPU_METRIC_STREAMER_GET_INFO \59DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_GET_INFO, \60struct drm_ivpu_metric_streamer_get_data)6162#define DRM_IOCTL_IVPU_CMDQ_CREATE \63DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_CMDQ_CREATE, struct drm_ivpu_cmdq_create)6465#define DRM_IOCTL_IVPU_CMDQ_DESTROY \66DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_CMDQ_DESTROY, struct drm_ivpu_cmdq_destroy)6768#define DRM_IOCTL_IVPU_CMDQ_SUBMIT \69DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_CMDQ_SUBMIT, struct drm_ivpu_cmdq_submit)7071/**72* DOC: contexts73*74* VPU contexts have private virtual address space, job queues and priority.75* Each context is identified by an unique ID. Context is created on open().76*/7778#define DRM_IVPU_PARAM_DEVICE_ID 079#define DRM_IVPU_PARAM_DEVICE_REVISION 180#define DRM_IVPU_PARAM_PLATFORM_TYPE 281#define DRM_IVPU_PARAM_CORE_CLOCK_RATE 382#define DRM_IVPU_PARAM_NUM_CONTEXTS 483#define DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS 584#define DRM_IVPU_PARAM_CONTEXT_PRIORITY 6 /* Deprecated */85#define DRM_IVPU_PARAM_CONTEXT_ID 786#define DRM_IVPU_PARAM_FW_API_VERSION 887#define DRM_IVPU_PARAM_ENGINE_HEARTBEAT 988#define DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID 1089#define DRM_IVPU_PARAM_TILE_CONFIG 1190#define DRM_IVPU_PARAM_SKU 1291#define DRM_IVPU_PARAM_CAPABILITIES 139293#define DRM_IVPU_PLATFORM_TYPE_SILICON 09495/* Deprecated, use DRM_IVPU_JOB_PRIORITY */96#define DRM_IVPU_CONTEXT_PRIORITY_IDLE 097#define DRM_IVPU_CONTEXT_PRIORITY_NORMAL 198#define DRM_IVPU_CONTEXT_PRIORITY_FOCUS 299#define DRM_IVPU_CONTEXT_PRIORITY_REALTIME 3100101#define DRM_IVPU_JOB_PRIORITY_DEFAULT 0102#define DRM_IVPU_JOB_PRIORITY_IDLE 1103#define DRM_IVPU_JOB_PRIORITY_NORMAL 2104#define DRM_IVPU_JOB_PRIORITY_FOCUS 3105#define DRM_IVPU_JOB_PRIORITY_REALTIME 4106107/**108* DRM_IVPU_CAP_METRIC_STREAMER109*110* Metric streamer support. Provides sampling of various hardware performance111* metrics like DMA bandwidth and cache miss/hits. Can be used for profiling.112*/113#define DRM_IVPU_CAP_METRIC_STREAMER 1114/**115* DRM_IVPU_CAP_DMA_MEMORY_RANGE116*117* Driver has capability to allocate separate memory range118* accessible by hardware DMA.119*/120#define DRM_IVPU_CAP_DMA_MEMORY_RANGE 2121/**122* DRM_IVPU_CAP_MANAGE_CMDQ123*124* Driver supports explicit command queue operations like command queue create,125* command queue destroy and submit job on specific command queue.126*/127#define DRM_IVPU_CAP_MANAGE_CMDQ 3128129/**130* struct drm_ivpu_param - Get/Set VPU parameters131*/132struct drm_ivpu_param {133/**134* @param:135*136* Supported params:137*138* %DRM_IVPU_PARAM_DEVICE_ID:139* PCI Device ID of the VPU device (read-only)140*141* %DRM_IVPU_PARAM_DEVICE_REVISION:142* VPU device revision (read-only)143*144* %DRM_IVPU_PARAM_PLATFORM_TYPE:145* Returns %DRM_IVPU_PLATFORM_TYPE_SILICON on real hardware or device specific146* platform type when executing on a simulator or emulator (read-only)147*148* %DRM_IVPU_PARAM_CORE_CLOCK_RATE:149* Maximum frequency of the NPU data processing unit clock (read-only)150*151* %DRM_IVPU_PARAM_NUM_CONTEXTS:152* Maximum number of simultaneously existing contexts (read-only)153*154* %DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS:155* Lowest VPU virtual address available in the current context (read-only)156*157* %DRM_IVPU_PARAM_CONTEXT_ID:158* Current context ID, always greater than 0 (read-only)159*160* %DRM_IVPU_PARAM_FW_API_VERSION:161* Firmware API version array (read-only)162*163* %DRM_IVPU_PARAM_ENGINE_HEARTBEAT:164* Heartbeat value from an engine (read-only).165* Engine ID (i.e. DRM_IVPU_ENGINE_COMPUTE) is given via index.166*167* %DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID:168* Device-unique inference ID (read-only)169*170* %DRM_IVPU_PARAM_TILE_CONFIG:171* VPU tile configuration (read-only)172*173* %DRM_IVPU_PARAM_SKU:174* VPU SKU ID (read-only)175*176* %DRM_IVPU_PARAM_CAPABILITIES:177* Supported capabilities (read-only)178*/179__u32 param;180181/** @index: Index for params that have multiple instances */182__u32 index;183184/** @value: Param value */185__u64 value;186};187188#define DRM_IVPU_BO_SHAVE_MEM 0x00000001189#define DRM_IVPU_BO_HIGH_MEM DRM_IVPU_BO_SHAVE_MEM190#define DRM_IVPU_BO_MAPPABLE 0x00000002191#define DRM_IVPU_BO_DMA_MEM 0x00000004192193#define DRM_IVPU_BO_CACHED 0x00000000194#define DRM_IVPU_BO_UNCACHED 0x00010000195#define DRM_IVPU_BO_WC 0x00020000196#define DRM_IVPU_BO_CACHE_MASK 0x00030000197198#define DRM_IVPU_BO_FLAGS \199(DRM_IVPU_BO_HIGH_MEM | \200DRM_IVPU_BO_MAPPABLE | \201DRM_IVPU_BO_DMA_MEM | \202DRM_IVPU_BO_CACHE_MASK)203204/**205* struct drm_ivpu_bo_create - Create BO backed by SHMEM206*207* Create GEM buffer object allocated in SHMEM memory.208*/209struct drm_ivpu_bo_create {210/** @size: The size in bytes of the allocated memory */211__u64 size;212213/**214* @flags:215*216* Supported flags:217*218* %DRM_IVPU_BO_HIGH_MEM:219*220* Allocate VPU address from >4GB range.221* Buffer object with vpu address >4GB can be always accessed by the222* VPU DMA engine, but some HW generation may not be able to access223* this memory from then firmware running on the VPU management processor.224* Suitable for input, output and some scratch buffers.225*226* %DRM_IVPU_BO_MAPPABLE:227*228* Buffer object can be mapped using mmap().229*230* %DRM_IVPU_BO_CACHED:231*232* Allocated BO will be cached on host side (WB) and snooped on the VPU side.233* This is the default caching mode.234*235* %DRM_IVPU_BO_UNCACHED:236*237* Not supported. Use DRM_IVPU_BO_WC instead.238*239* %DRM_IVPU_BO_WC:240*241* Allocated BO will use write combining buffer for writes but reads will be242* uncached.243*/244__u32 flags;245246/** @handle: Returned GEM object handle */247__u32 handle;248249/** @vpu_addr: Returned VPU virtual address */250__u64 vpu_addr;251};252253/**254* struct drm_ivpu_bo_info - Query buffer object info255*/256struct drm_ivpu_bo_info {257/** @handle: Handle of the queried BO */258__u32 handle;259260/** @flags: Returned flags used to create the BO */261__u32 flags;262263/** @vpu_addr: Returned VPU virtual address */264__u64 vpu_addr;265266/**267* @mmap_offset:268*269* Returned offset to be used in mmap(). 0 in case the BO is not mappable.270*/271__u64 mmap_offset;272273/** @size: Returned GEM object size, aligned to PAGE_SIZE */274__u64 size;275};276277/* drm_ivpu_submit engines */278#define DRM_IVPU_ENGINE_COMPUTE 0279#define DRM_IVPU_ENGINE_COPY 1 /* Deprecated */280281/**282* struct drm_ivpu_submit - Submit commands to the VPU283*284* Execute a single command buffer on a given VPU engine.285* Handles to all referenced buffer objects have to be provided in @buffers_ptr.286*287* User space may wait on job completion using %DRM_IVPU_BO_WAIT ioctl.288*/289struct drm_ivpu_submit {290/**291* @buffers_ptr:292*293* A pointer to an u32 array of GEM handles of the BOs required for this job.294* The number of elements in the array must be equal to the value given by @buffer_count.295*296* The first BO is the command buffer. The rest of array has to contain all297* BOs referenced from the command buffer.298*/299__u64 buffers_ptr;300301/** @buffer_count: Number of elements in the @buffers_ptr */302__u32 buffer_count;303304/**305* @engine: Select the engine this job should be executed on306*307* %DRM_IVPU_ENGINE_COMPUTE:308*309* Performs Deep Learning Neural Compute Inference Operations310*/311__u32 engine;312313/** @flags: Reserved for future use - must be zero */314__u32 flags;315316/**317* @commands_offset:318*319* Offset inside the first buffer in @buffers_ptr containing commands320* to be executed. The offset has to be 8-byte aligned.321*/322__u32 commands_offset;323324/**325* @priority:326*327* Priority to be set for related job command queue, can be one of the following:328* %DRM_IVPU_JOB_PRIORITY_DEFAULT329* %DRM_IVPU_JOB_PRIORITY_IDLE330* %DRM_IVPU_JOB_PRIORITY_NORMAL331* %DRM_IVPU_JOB_PRIORITY_FOCUS332* %DRM_IVPU_JOB_PRIORITY_REALTIME333*/334__u32 priority;335};336337/**338* struct drm_ivpu_cmdq_submit - Submit commands to the VPU using explicit command queue339*340* Execute a single command buffer on a given command queue.341* Handles to all referenced buffer objects have to be provided in @buffers_ptr.342*343* User space may wait on job completion using %DRM_IVPU_BO_WAIT ioctl.344*/345struct drm_ivpu_cmdq_submit {346/**347* @buffers_ptr:348*349* A pointer to an u32 array of GEM handles of the BOs required for this job.350* The number of elements in the array must be equal to the value given by @buffer_count.351*352* The first BO is the command buffer. The rest of array has to contain all353* BOs referenced from the command buffer.354*/355__u64 buffers_ptr;356357/** @buffer_count: Number of elements in the @buffers_ptr */358__u32 buffer_count;359360/** @cmdq_id: ID for the command queue where job will be submitted */361__u32 cmdq_id;362363/** @flags: Reserved for future use - must be zero */364__u32 flags;365366/**367* @commands_offset:368*369* Offset inside the first buffer in @buffers_ptr containing commands370* to be executed. The offset has to be 8-byte aligned.371*/372__u32 commands_offset;373};374375/* drm_ivpu_bo_wait job status codes */376#define DRM_IVPU_JOB_STATUS_SUCCESS 0377#define DRM_IVPU_JOB_STATUS_ABORTED 256378379/**380* struct drm_ivpu_bo_wait - Wait for BO to become inactive381*382* Blocks until a given buffer object becomes inactive.383* With @timeout_ms set to 0 returns immediately.384*/385struct drm_ivpu_bo_wait {386/** @handle: Handle to the buffer object to be waited on */387__u32 handle;388389/** @flags: Reserved for future use - must be zero */390__u32 flags;391392/** @timeout_ns: Absolute timeout in nanoseconds (may be zero) */393__s64 timeout_ns;394395/**396* @job_status:397*398* Job status code which is updated after the job is completed.399* &DRM_IVPU_JOB_STATUS_SUCCESS or device specific error otherwise.400* Valid only if @handle points to a command buffer.401*/402__u32 job_status;403404/** @pad: Padding - must be zero */405__u32 pad;406};407408/**409* struct drm_ivpu_metric_streamer_start - Start collecting metric data410*/411struct drm_ivpu_metric_streamer_start {412/** @metric_group_mask: Indicates metric streamer instance */413__u64 metric_group_mask;414/** @sampling_period_ns: Sampling period in nanoseconds */415__u64 sampling_period_ns;416/**417* @read_period_samples:418*419* Number of samples after which user space will try to read the data.420* Reading the data after significantly longer period may cause data loss.421*/422__u32 read_period_samples;423/** @sample_size: Returned size of a single sample in bytes */424__u32 sample_size;425/** @max_data_size: Returned max @data_size from %DRM_IOCTL_IVPU_METRIC_STREAMER_GET_DATA */426__u32 max_data_size;427};428429/**430* struct drm_ivpu_metric_streamer_get_data - Copy collected metric data431*/432struct drm_ivpu_metric_streamer_get_data {433/** @metric_group_mask: Indicates metric streamer instance */434__u64 metric_group_mask;435/** @buffer_ptr: A pointer to a destination for the copied data */436__u64 buffer_ptr;437/** @buffer_size: Size of the destination buffer */438__u64 buffer_size;439/**440* @data_size: Returned size of copied metric data441*442* If the @buffer_size is zero, returns the amount of data ready to be copied.443*/444__u64 data_size;445};446447/* Command queue flags */448#define DRM_IVPU_CMDQ_FLAG_TURBO 0x00000001449450/**451* struct drm_ivpu_cmdq_create - Create command queue for job submission452*/453struct drm_ivpu_cmdq_create {454/** @cmdq_id: Returned ID of created command queue */455__u32 cmdq_id;456/**457* @priority:458*459* Priority to be set for related job command queue, can be one of the following:460* %DRM_IVPU_JOB_PRIORITY_DEFAULT461* %DRM_IVPU_JOB_PRIORITY_IDLE462* %DRM_IVPU_JOB_PRIORITY_NORMAL463* %DRM_IVPU_JOB_PRIORITY_FOCUS464* %DRM_IVPU_JOB_PRIORITY_REALTIME465*/466__u32 priority;467/**468* @flags:469*470* Supported flags:471*472* %DRM_IVPU_CMDQ_FLAG_TURBO473*474* Enable low-latency mode for the command queue. The NPU will maximize performance475* when executing jobs from such queue at the cost of increased power usage.476*/477__u32 flags;478};479480/**481* struct drm_ivpu_cmdq_destroy - Destroy a command queue482*/483struct drm_ivpu_cmdq_destroy {484/** @cmdq_id: ID of command queue to destroy */485__u32 cmdq_id;486};487488/**489* struct drm_ivpu_metric_streamer_stop - Stop collecting metric data490*/491struct drm_ivpu_metric_streamer_stop {492/** @metric_group_mask: Indicates metric streamer instance */493__u64 metric_group_mask;494};495496#if defined(__cplusplus)497}498#endif499500#endif /* __UAPI_IVPU_DRM_H__ */501502503